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