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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
454 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
101 $rand_choice = false;
102 if($question_type == 'single_choice' || $question_type == 'multiple_choice'){
103 $choice = maybe_unserialize($question->question_settings);
104 if(isset($choice['randomize_question'])){
105 $rand_choice = $choice['randomize_question'] == 1 ? true : false;
106 }
107 }
108
109 $answers = tutor_utils()->get_answers_by_quiz_question($question->question_id, $rand_choice);
110 $show_question_mark = (bool) tutor_utils()->avalue_dot('show_question_mark', $question_settings);
111 $answer_required = (bool) tutils()->array_get('answer_required', $question_settings);
112
113 echo '<h4 class="question-text">';
114 if ( ! $hide_question_number_overview){
115 echo $question_i. ". ";
116 }
117 echo stripslashes($question->question_title);
118 echo '</h4>';
119
120 if ($show_question_mark){
121 echo '<p class="question-marks"> '.__('Marks : ', 'tutor').$question->question_mark.' </p>';
122 }
123
124 $question_description = stripslashes($question->question_description);
125 if ($question_description){
126 echo "<p class='question-description'>{$question_description}</p>";
127 }
128 ?>
129
130 <div class="tutor-quiz-answers-wrap question-type-<?php echo $question_type; ?> <?php echo $answer_required? 'quiz-answer-required':''; ?> ">
131 <?php
132 if ( is_array($answers) && count($answers) ) {
133 foreach ($answers as $answer){
134 $answer_title = stripslashes($answer->answer_title);
135
136 if ( $question_type === 'true_false' || $question_type === 'single_choice' ) {
137 ?>
138 <label class="answer-view-<?php echo $answer->answer_view_format; ?>">
139 <div class="quiz-answer-input-body">
140 <?php
141 if ($answer->answer_view_format === 'image' || $answer->answer_view_format === 'text_image'){
142 ?>
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 ?>
149 <div class="quiz-answer-input-bottom">
150 <div class="quiz-answer-input-field">
151 <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; ?>">
152 <span>&nbsp;</span>
153 <?php
154 if ($answer->answer_view_format !== 'image'){ echo $answer_title;}
155 ?>
156 </div>
157 </div>
158 </div>
159 </label>
160 <?php
161 }elseif ($question_type === 'multiple_choice'){
162 ?>
163 <label class="answer-view-<?php echo $answer->answer_view_format; ?>">
164
165
166 <div class="quiz-answer-input-body">
167 <?php if ($answer->answer_view_format === 'image' || $answer->answer_view_format === 'text_image'){ ?>
168 <div class="quiz-answer-image-wrap">
169 <img src="<?php echo wp_get_attachment_image_url($answer->image_id, 'full') ?>" />
170 </div>
171 <?php } ?>
172
173 <div class="quiz-answer-input-bottom">
174 <div class="quiz-answer-input-field">
175 <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; ?>">
176 <span>&nbsp;</span>
177 <?php if ($answer->answer_view_format !== 'image'){
178 echo $answer_title;
179 } ?>
180 </div>
181 </div>
182 </div>
183 </label>
184 <?php
185 }
186 elseif ($question_type === 'fill_in_the_blank'){
187 ?>
188 <p class="fill-in-the-blank-field">
189 <?php
190 $count_dash_fields = substr_count($answer_title, '{dash}');
191 if ($count_dash_fields){
192
193 $dash_string = array();
194 $input_data = array();
195 for($i=1; $i <=$count_dash_fields; $i ++){
196 $dash_string[] = '{dash}';
197 $input_data[] = "<input type='text' name='attempt[{$is_started_quiz->attempt_id}][quiz_question][{$question->question_id}][]' class='fill-in-the-blank-text-input' />";
198 }
199 echo str_replace($dash_string, $input_data, $answer_title);
200 }
201 ?>
202 </p>
203 <?php
204 }
205 elseif ($question_type === 'ordering'){
206 ?>
207 <div class="question-type-ordering-item">
208 <div class="answer-title">
209 <?php
210 if ($answer->answer_view_format !== 'image'){
211 echo "<p class='tutor-quiz-answer-title'>{$answer_title}</p>";
212 }
213 if ($answer->answer_view_format === 'image' || $answer->answer_view_format === 'text_image'){
214 ?>
215 <div class="quiz-answer-image-wrap">
216 <img src="<?php echo wp_get_attachment_image_url($answer->image_id, 'full') ?>" />
217 </div>
218 <?php
219 }
220 ?>
221 </div>
222 <span class="answer-sorting-bar"><i class="tutor-icon-menu-2"></i> </span>
223 <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; ?>" >
224 </div>
225 <?php
226 }
227 }
228
229 /**
230 * Question type matchind and image matching
231 */
232 if ($question_type === 'matching' || $question_type === 'image_matching'){
233 ?>
234 <div class="quiz-answers-type-matching-wrap <?php echo 'answer-type-'.$question_type ?> ">
235 <div class="quiz-draggable-rand-answers">
236 <?php
237 $rand_answers = tutor_utils()->get_answers_by_quiz_question($question->question_id, true);
238 foreach ($rand_answers as $rand_answer){
239 ?>
240 <div class="quiz-draggable-answer-item">
241 <?php
242 if ($question_type === 'matching'){
243 echo "<span class='draggable-answer-title'>{$rand_answer->answer_two_gap_match}</span>";
244 }else{
245 echo "<span class='draggable-answer-title'>{$rand_answer->answer_title}</span>";
246 }
247 ?>
248 <span class="draggable-answer-icon"> <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 $rand_answer->answer_id; ?>" >
250 </div>
251 <?php
252 }
253 ?>
254 </div>
255
256 <div class="quiz-answer-matching-items-wrap">
257 <?php
258 foreach ($answers as $answer){
259 ?>
260 <div class="quiz-answer-item-matching">
261 <div class="quiz-answer-matching-title">
262 <?php
263 if ($question_type === 'matching') {
264
265 if ($answer->answer_view_format !== 'image'){
266 echo "<p class='tutor-quiz-answer-title'>{$answer->answer_title}</p>";
267 }
268 if ($answer->answer_view_format === 'image' || $answer->answer_view_format === 'text_image'){
269 ?>
270 <div class="quiz-answer-image-wrap">
271 <img src="<?php echo wp_get_attachment_image_url($answer->image_id, 'full') ?>" />
272 </div>
273 <?php
274 }
275 }elseif (intval($answer->image_id)){
276 echo '<img src="'.wp_get_attachment_image_url($answer->image_id, 'full').'" />';
277 }
278 ?>
279 </div>
280 <div class="quiz-answer-matching-droppable"></div>
281 </div>
282 <?php
283 }
284 ?>
285
286 </div>
287 </div>
288 <?php
289 }
290 }
291
292 /**
293 * For Open Ended Question Type
294 */
295 if ($question_type === 'open_ended' || $question_type === 'short_answer'){
296 ?>
297 <textarea class="question_type_<?php echo $question_type; ?>" name="attempt[<?php echo
298 $is_started_quiz->attempt_id; ?>][quiz_question][<?php echo $question->question_id; ?>]"></textarea>
299 <?php
300 if ($question_type === 'short_answer') {
301 $get_option_meta = tutor_utils()->get_quiz_option($quiz_id);
302 if(isset($get_option_meta['short_answer_characters_limit'])){
303 if($get_option_meta['short_answer_characters_limit'] != "" ){
304 $characters_limit = tutor_utils()->avalue_dot('short_answer_characters_limit', $quiz_attempt_info);
305 echo '<p class="answer_limit_desc"> characters remaining <span class="characters_remaining">'.$characters_limit.'</span> </p>';
306 }
307 }
308 }
309 if ($question_type === 'open_ended') {
310 $get_option_meta = tutor_utils()->get_quiz_option($quiz_id);
311 if(isset($get_option_meta['open_ended_answer_characters_limit'])){
312 if($get_option_meta['open_ended_answer_characters_limit'] != "" ){
313 $characters_limit = $get_option_meta['open_ended_answer_characters_limit'];
314 echo '<p class="answer_limit_desc"> characters remaining <span class="characters_remaining">'.$characters_limit.'</span> </p>';
315 }
316 }
317 }
318 }
319
320
321 if ($question_type === 'image_answering'){
322 ?>
323 <div class="quiz-image-answering-wrap">
324 <?php
325 foreach ($answers as $answer){
326 ?>
327 <div class="quiz-image-answering-answer">
328 <?php
329 if (intval($answer->image_id)){
330 ?>
331 <div class="quiz-image-answering-image-wrap">
332 <?php echo '<img src="'.wp_get_attachment_image_url($answer->image_id, 'full').'" />'; ?>
333 </div>
334
335 <div class="quiz-image-answering-input-field-wrap">
336 <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; ?>]" >
337 </div>
338 <?php
339 }
340 ?>
341 </div>
342 <?php
343 }
344 ?>
345 </div>
346 <?php
347 }
348 ?>
349
350 <div class="answer-help-block"></div>
351
352 </div>
353
354 <?php
355 if ($question_layout_view !== 'question_below_each_other'){
356 if ($next_question){
357 ?>
358 <div class="quiz-answer-footer-bar">
359 <div class="quiz-footer-button">
360 <button type="button" value="quiz_answer_submit" class="tutor-button
361 tutor-success tutor-quiz-answer-next-btn"><?php _e( 'Answer &amp; Next Question', 'tutor' ); ?></button>
362 </div>
363 </div>
364 <?php
365 }else{
366 ?>
367 <div class="quiz-answer-footer-bar">
368 <div class="quiz-footer-button">
369 <button type="submit" name="quiz_answer_submit_btn" value="quiz_answer_submit" class="tutor-button tutor-success"><?php
370 _e( 'Submit Quiz', 'tutor' ); ?></button>
371 </div>
372 </div>
373 <?php
374 }
375 }
376 ?>
377 </div>
378
379 <?php
380 }
381
382 if ($question_layout_view === 'question_below_each_other'){
383 ?>
384 <div class="quiz-answer-footer-bar">
385 <div class="quiz-footer-button">
386 <button type="submit" name="quiz_answer_submit_btn" value="quiz_answer_submit" class="tutor-button
387 tutor-success"><?php _e( 'Submit Quiz', 'tutor' ); ?></button>
388 </div>
389 </div>
390 <?php } ?>
391
392 </form>
393 </div>
394
395 <?php
396
397 }else{
398 ?>
399 <div class="start-quiz-wrap">
400 <form id="tutor-finish-quiz" method="post">
401 <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?>
402
403 <input type="hidden" value="<?php echo $quiz_id; ?>" name="quiz_id"/>
404 <input type="hidden" value="tutor_finish_quiz_attempt" name="tutor_action"/>
405
406 <button type="submit" class="tutor-button" name="finish_quiz_btn" value="finish_quiz">
407 <i class="icon-floppy"></i> <?php _e( 'Finish', 'tutor' ); ?>
408 </button>
409 </form>
410 </div>
411
412 <?php
413 }
414 }else{
415 if ($attempt_remaining > 0 || $attempts_allowed == 0) {
416 do_action('tuotr_quiz/start_form/before', $quiz_id);
417 ?>
418 <div class="start-quiz-wrap">
419 <form id="tutor-start-quiz" method="post">
420 <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?>
421
422 <input type="hidden" value="<?php echo $quiz_id; ?>" name="quiz_id"/>
423 <input type="hidden" value="tutor_start_quiz" name="tutor_action"/>
424
425 <button type="submit" class="tutor-button" name="start_quiz_btn" value="start_quiz">
426 <i class="icon-hourglass-1"></i> <?php _e( 'Start Quiz', 'tutor' ); ?>
427 </button>
428 </form>
429 </div>
430
431 <?php
432 do_action('tuotr_quiz/start_form/after', $quiz_id);
433 }
434
435
436
437 if ($previous_attempts){
438 do_action('tutor_quiz/previous_attempts_html/before', $previous_attempts, $quiz_id);
439
440 ob_start();
441 tutor_load_template('single.quiz.previous-attempts', compact('previous_attempts', 'quiz_id'));
442 $previous_attempts_html = ob_get_clean();
443 echo apply_filters('tutor_quiz/previous_attempts_html', $previous_attempts_html, $previous_attempts, $quiz_id);
444
445 do_action('tutor_quiz/previous_attempts/after', $previous_attempts, $quiz_id);
446 }
447 }
448
449
450 tutor_next_previous_pagination();
451
452 do_action('tutor_quiz/body/after', $quiz_id);
453 ?>
454 </div>