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