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.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / templates / single / quiz / body.php
tutor / templates / single / quiz Last commit date
body.php 6 years ago content.php 6 years ago no_course_belongs.php 6 years ago previous-attempts.php 6 years ago single_quiz_contents.php 6 years ago top.php 6 years ago
body.php
433 lines
1 <?php
2 /**
3 * @package TutorLMS/Templates
4 * @version 1.5.7
5 */
6
7
8 global $post;
9 $currentPost = $post;
10
11 $quiz_id = get_the_ID();
12 $is_started_quiz = tutor_utils()->is_started_quiz();
13
14 $previous_attempts = tutor_utils()->quiz_attempts();
15 $attempted_count = is_array($previous_attempts) ? count($previous_attempts) : 0;
16 $questions_order = tutor_utils()->get_quiz_option($quiz_id, 'questions_order', 'rand');
17 $attempts_allowed = tutor_utils()->get_quiz_option($quiz_id, 'attempts_allowed', 0);
18 $passing_grade = tutor_utils()->get_quiz_option($quiz_id, 'passing_grade', 0);
19
20 $attempt_remaining = $attempts_allowed - $attempted_count;
21 ?>
22
23 <div id="tutor-quiz-body" class="tutor-quiz-body tutor-quiz-body-<?php the_ID(); ?>">
24 <?php
25
26 do_action('tutor_quiz/body/before', $quiz_id);
27
28 if ($is_started_quiz){
29 $quiz_attempt_info = tutor_utils()->quiz_attempt_info($is_started_quiz->attempt_info);
30 $quiz_attempt_info['date_time_now'] = date("Y-m-d H:i:s", tutor_time());
31
32 $time_limit_seconds = tutor_utils()->avalue_dot('time_limit.time_limit_seconds', $quiz_attempt_info);
33 $question_layout_view = tutor_utils()->avalue_dot('question_layout_view', $quiz_attempt_info);
34
35 $hide_quiz_time_display = (bool) tutor_utils()->avalue_dot('hide_quiz_time_display', $quiz_attempt_info);
36 $hide_question_number_overview = (bool) tutor_utils()->avalue_dot('hide_question_number_overview', $quiz_attempt_info);
37
38 $remaining_time_secs = (strtotime($is_started_quiz->attempt_started_at) + $time_limit_seconds ) - strtotime($quiz_attempt_info['date_time_now']);
39
40 $remaining_time_context = tutor_utils()->seconds_to_time_context($remaining_time_secs);
41 $questions = tutor_utils()->get_random_questions_by_quiz();
42 ?>
43
44 <div class="quiz-head-meta-info">
45 <?php
46 if ( ! $hide_quiz_time_display){
47 ?>
48 <div class="time-remaining">
49 <?php _e('Time remaining : '); ?> <span id="tutor-quiz-time-update" data-attempt-settings="<?php echo esc_attr(json_encode($is_started_quiz)) ?>" data-attempt-meta="<?php echo esc_attr(json_encode($quiz_attempt_info)) ?>"><?php echo $remaining_time_context; ?></span>
50 </div>
51 <?php } ?>
52 </div>
53
54 <?php
55 if (is_array($questions) && count($questions)) {
56 ?>
57 <div id="tutor-quiz-attempt-questions-wrap" data-question-layout-view="<?php echo $question_layout_view; ?>">
58
59 <?php
60 if ($question_layout_view === 'question_pagination'){
61 $question_i = 0;
62 ?>
63 <div class="tutor-quiz-questions-pagination">
64 <ul>
65 <?php
66 foreach ($questions as $question) {
67 $question_i++;
68 echo "<li><a href='#quiz-attempt-single-question-{$question->question_id}' class='tutor-quiz-question-paginate-item'>{$question_i}</a> </li>";
69 }
70 ?>
71 </ul>
72 </div>
73 <?php
74 }
75 ?>
76
77 <form id="tutor-answering-quiz" method="post">
78 <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?>
79 <input type="hidden" value="<?php echo $is_started_quiz->attempt_id; ?>" name="attempt_id"/>
80 <input type="hidden" value="tutor_answering_quiz_question" name="tutor_action"/>
81 <?php
82 $question_i = 0;
83 foreach ($questions as $question) {
84 $question_i++;
85 $question_settings = maybe_unserialize($question->question_settings);
86
87 $style_display = ($question_layout_view !== 'question_below_each_other' && $question_i == 1) ? 'block' : 'none';
88 if ($question_layout_view === 'question_below_each_other'){
89 $style_display = 'block';
90 }
91
92 $next_question = isset($questions[$question_i]) ? $questions[$question_i] : false;
93 ?>
94 <div id="quiz-attempt-single-question-<?php echo $question->question_id; ?>" class="quiz-attempt-single-question quiz-attempt-single-question-<?php echo $question_i; ?>" style="display: <?php echo $style_display; ?> ;" <?php echo $next_question ? "data-next-question-id='#quiz-attempt-single-question-{$next_question->question_id}'" : '' ; ?> >
95
96 <?php echo "<input type='hidden' name='attempt[{$is_started_quiz->attempt_id}][quiz_question_ids][]' value='{$question->question_id}' />";
97
98
99 $question_type = $question->question_type;
100 $answers = tutor_utils()->get_answers_by_quiz_question($question->question_id);
101 $show_question_mark = (bool) tutor_utils()->avalue_dot('show_question_mark', $question_settings);
102 $answer_required = (bool) tutils()->array_get('answer_required', $question_settings);
103
104 echo '<h4 class="question-text">';
105 if ( ! $hide_question_number_overview){
106 echo $question_i. ". ";
107 }
108 echo stripslashes($question->question_title);
109 echo '</h4>';
110
111 if ($show_question_mark){
112 echo '<p class="question-marks"> '.__('Marks : ', 'tutor').$question->question_mark.' </p>';
113 }
114
115 $question_description = stripslashes(esc_html($question->question_description));
116 if ($question_description){
117 echo "<p class='question-description'>{$question_description}</p>";
118 }
119 ?>
120
121 <div class="tutor-quiz-answers-wrap question-type-<?php echo $question_type; ?> <?php echo $answer_required? 'quiz-answer-required':''; ?> ">
122 <?php
123 if ( is_array($answers) && count($answers) ) {
124 foreach ($answers as $answer){
125 $answer_title = stripslashes($answer->answer_title);
126
127 if ( $question_type === 'true_false' || $question_type === 'single_choice' ) {
128 ?>
129 <label class="answer-view-<?php echo $answer->answer_view_format; ?>">
130 <div class="quiz-answer-input-body">
131 <?php
132 if ($answer->answer_view_format === 'image' || $answer->answer_view_format === 'text_image'){
133 ?>
134 <div class="quiz-answer-image-wrap">
135 <img src="<?php echo wp_get_attachment_image_url($answer->image_id, 'full') ?>" />
136 </div>
137 <?php
138 }
139 ?>
140 <div class="quiz-answer-input-bottom">
141 <div class="quiz-answer-input-field">
142 <input name="attempt[<?php echo $is_started_quiz->attempt_id; ?>][quiz_question][<?php echo $question->question_id; ?>]" type="radio" value="<?php echo $answer->answer_id; ?>">
143 <span>&nbsp;</span>
144 <?php
145 if ($answer->answer_view_format !== 'image'){ echo $answer_title;}
146 ?>
147 </div>
148 </div>
149 </div>
150 </label>
151 <?php
152 }elseif ($question_type === 'multiple_choice'){
153 ?>
154 <label class="answer-view-<?php echo $answer->answer_view_format; ?>">
155
156
157 <div class="quiz-answer-input-body">
158 <?php if ($answer->answer_view_format === 'image' || $answer->answer_view_format === 'text_image'){ ?>
159 <div class="quiz-answer-image-wrap">
160 <img src="<?php echo wp_get_attachment_image_url($answer->image_id, 'full') ?>" />
161 </div>
162 <?php } ?>
163
164 <div class="quiz-answer-input-bottom">
165 <div class="quiz-answer-input-field">
166 <input name="attempt[<?php echo $is_started_quiz->attempt_id; ?>][quiz_question][<?php echo $question->question_id; ?>][]" type="checkbox" value="<?php echo $answer->answer_id; ?>">
167 <span>&nbsp;</span>
168 <?php if ($answer->answer_view_format !== 'image'){
169 echo $answer_title;
170 } ?>
171 </div>
172 </div>
173 </div>
174 </label>
175 <?php
176 }
177 elseif ($question_type === 'fill_in_the_blank'){
178 ?>
179 <p class="fill-in-the-blank-field">
180 <?php
181 $count_dash_fields = substr_count($answer_title, '{dash}');
182 if ($count_dash_fields){
183
184 $dash_string = array();
185 $input_data = array();
186 for($i=1; $i <=$count_dash_fields; $i ++){
187 $dash_string[] = '{dash}';
188 $input_data[] = "<input type='text' name='attempt[{$is_started_quiz->attempt_id}][quiz_question][{$question->question_id}][]' class='fill-in-the-blank-text-input' />";
189 }
190 echo str_replace($dash_string, $input_data, $answer_title);
191 }
192 ?>
193 </p>
194 <?php
195 }
196 elseif ($question_type === 'ordering'){
197 ?>
198 <div class="question-type-ordering-item">
199 <div class="answer-title">
200 <?php
201 if ($answer->answer_view_format !== 'image'){
202 echo "<p class='tutor-quiz-answer-title'>{$answer_title}</p>";
203 }
204 if ($answer->answer_view_format === 'image' || $answer->answer_view_format === 'text_image'){
205 ?>
206 <div class="quiz-answer-image-wrap">
207 <img src="<?php echo wp_get_attachment_image_url($answer->image_id, 'full') ?>" />
208 </div>
209 <?php
210 }
211 ?>
212 </div>
213 <span class="answer-sorting-bar"><i class="tutor-icon-menu-2"></i> </span>
214 <input type="hidden" name="attempt[<?php echo $is_started_quiz->attempt_id; ?>][quiz_question][<?php echo $question->question_id; ?>][answers][]" value="<?php echo $answer->answer_id; ?>" >
215 </div>
216 <?php
217 }
218 }
219
220 /**
221 * Question type matchind and image matching
222 */
223 if ($question_type === 'matching' || $question_type === 'image_matching'){
224 ?>
225 <div class="quiz-answers-type-matching-wrap <?php echo 'answer-type-'.$question_type ?> ">
226 <div class="quiz-draggable-rand-answers">
227 <?php
228 $rand_answers = tutor_utils()->get_answers_by_quiz_question($question->question_id, true);
229 foreach ($rand_answers as $rand_answer){
230 ?>
231 <div class="quiz-draggable-answer-item">
232 <?php
233 if ($question_type === 'matching'){
234 echo "<span class='draggable-answer-title'>{$rand_answer->answer_two_gap_match}</span>";
235 }else{
236 echo "<span class='draggable-answer-title'>{$rand_answer->answer_title}</span>";
237 }
238 ?>
239 <span class="draggable-answer-icon"> <i class="tutor-icon-menu-2"></i> </span>
240 <input type="hidden" name="attempt[<?php echo $is_started_quiz->attempt_id; ?>][quiz_question][<?php echo $question->question_id; ?>][answers][]" value="<?php echo $rand_answer->answer_id; ?>" >
241 </div>
242 <?php
243 }
244 ?>
245 </div>
246
247 <div class="quiz-answer-matching-items-wrap">
248 <?php
249 foreach ($answers as $answer){
250 ?>
251 <div class="quiz-answer-item-matching">
252 <div class="quiz-answer-matching-title">
253 <?php
254 if ($question_type === 'matching') {
255
256 if ($answer->answer_view_format !== 'image'){
257 echo "<p class='tutor-quiz-answer-title'>{$answer->answer_title}</p>";
258 }
259 if ($answer->answer_view_format === 'image' || $answer->answer_view_format === 'text_image'){
260 ?>
261 <div class="quiz-answer-image-wrap">
262 <img src="<?php echo wp_get_attachment_image_url($answer->image_id, 'full') ?>" />
263 </div>
264 <?php
265 }
266 }elseif (intval($answer->image_id)){
267 echo '<img src="'.wp_get_attachment_image_url($answer->image_id, 'full').'" />';
268 }
269 ?>
270 </div>
271 <div class="quiz-answer-matching-droppable"></div>
272 </div>
273 <?php
274 }
275 ?>
276
277 </div>
278 </div>
279 <?php
280 }
281 }
282
283 /**
284 * For Open Ended Question Type
285 */
286 if ($question_type === 'open_ended' || $question_type === 'short_answer'){
287 ?>
288 <textarea class="question_type_<?php echo $question_type; ?>" name="attempt[<?php echo
289 $is_started_quiz->attempt_id; ?>][quiz_question][<?php echo $question->question_id; ?>]"></textarea>
290 <?php
291
292 if ($question_type === 'short_answer'){
293 $characters_limit = tutor_utils()->avalue_dot('short_answer_characters_limit', $quiz_attempt_info);
294 echo '<p class="answer_limit_desc"> characters remaining <span class="characters_remaining">'.$characters_limit.'</span> </p>';
295 }
296
297 }
298
299
300 if ($question_type === 'image_answering'){
301 ?>
302 <div class="quiz-image-answering-wrap">
303 <?php
304 foreach ($answers as $answer){
305 ?>
306 <div class="quiz-image-answering-answer">
307 <?php
308 if (intval($answer->image_id)){
309 ?>
310 <div class="quiz-image-answering-image-wrap">
311 <?php echo '<img src="'.wp_get_attachment_image_url($answer->image_id, 'full').'" />'; ?>
312 </div>
313
314 <div class="quiz-image-answering-input-field-wrap">
315 <input type="text" name="attempt[<?php echo $is_started_quiz->attempt_id; ?>][quiz_question][<?php echo $question->question_id; ?>][answer_id][<?php echo $answer->answer_id; ?>]" >
316 </div>
317 <?php
318 }
319 ?>
320 </div>
321 <?php
322 }
323 ?>
324 </div>
325 <?php
326 }
327 ?>
328
329 <div class="answer-help-block"></div>
330
331 </div>
332
333 <?php
334 if ($question_layout_view !== 'question_below_each_other'){
335 if ($next_question){
336 ?>
337 <div class="quiz-answer-footer-bar">
338 <div class="quiz-footer-button">
339 <button type="button" value="quiz_answer_submit" class="tutor-button
340 tutor-success tutor-quiz-answer-next-btn"><?php _e( 'Answer &amp; Next Question', 'tutor' ); ?></button>
341 </div>
342 </div>
343 <?php
344 }else{
345 ?>
346 <div class="quiz-answer-footer-bar">
347 <div class="quiz-footer-button">
348 <button type="submit" name="quiz_answer_submit_btn" value="quiz_answer_submit" class="tutor-button tutor-success"><?php
349 _e( 'Submit Quiz', 'tutor' ); ?></button>
350 </div>
351 </div>
352 <?php
353 }
354 }
355 ?>
356 </div>
357
358 <?php
359 }
360
361 if ($question_layout_view === 'question_below_each_other'){
362 ?>
363 <div class="quiz-answer-footer-bar">
364 <div class="quiz-footer-button">
365 <button type="submit" name="quiz_answer_submit_btn" value="quiz_answer_submit" class="tutor-button
366 tutor-success"><?php _e( 'Submit Quiz', 'tutor' ); ?></button>
367 </div>
368 </div>
369 <?php } ?>
370
371 </form>
372 </div>
373
374 <?php
375
376 }else{
377 ?>
378 <div class="start-quiz-wrap">
379 <form id="tutor-finish-quiz" method="post">
380 <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?>
381
382 <input type="hidden" value="<?php echo $quiz_id; ?>" name="quiz_id"/>
383 <input type="hidden" value="tutor_finish_quiz_attempt" name="tutor_action"/>
384
385 <button type="submit" class="tutor-button" name="finish_quiz_btn" value="finish_quiz">
386 <i class="icon-floppy"></i> <?php _e( 'Finish', 'tutor' ); ?>
387 </button>
388 </form>
389 </div>
390
391 <?php
392 }
393 }else{
394 if ($attempt_remaining > 0 || $attempts_allowed == 0) {
395 do_action('tuotr_quiz/start_form/before', $quiz_id);
396 ?>
397 <div class="start-quiz-wrap">
398 <form id="tutor-start-quiz" method="post">
399 <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?>
400
401 <input type="hidden" value="<?php echo $quiz_id; ?>" name="quiz_id"/>
402 <input type="hidden" value="tutor_start_quiz" name="tutor_action"/>
403
404 <button type="submit" class="tutor-button" name="start_quiz_btn" value="start_quiz">
405 <i class="icon-hourglass-1"></i> <?php _e( 'Start Quiz', 'tutor' ); ?>
406 </button>
407 </form>
408 </div>
409
410 <?php
411 do_action('tuotr_quiz/start_form/after', $quiz_id);
412 }
413
414
415
416 if ($previous_attempts){
417 do_action('tutor_quiz/previous_attempts_html/before', $previous_attempts, $quiz_id);
418
419 ob_start();
420 tutor_load_template('single.quiz.previous-attempts', compact('previous_attempts', 'quiz_id'));
421 $previous_attempts_html = ob_get_clean();
422 echo apply_filters('tutor_quiz/previous_attempts_html', $previous_attempts_html, $previous_attempts, $quiz_id);
423
424 do_action('tutor_quiz/previous_attempts/after', $previous_attempts, $quiz_id);
425 }
426 }
427
428
429 tutor_next_previous_pagination();
430
431 do_action('tutor_quiz/body/after', $quiz_id);
432 ?>
433 </div>