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