PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 2.0.8
Tutor LMS – eLearning and online course solution v2.0.8
4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.11 1.2.12 1.2.13 1.2.20 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.4.0 2.5.0 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.4.0 3.4.1 3.4.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 / views / quiz / attempt-details.php
tutor / views / quiz Last commit date
header-context 4 years ago attempt-details.php 3 years ago attempt-table.php 3 years ago contexts.php 4 years ago header.php 4 years ago instructor-feedback.php 4 years ago
attempt-details.php
661 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ){
4 exit;
5 }
6
7 $enabled_hide_quiz_details = tutor_utils()->get_option( 'hide_quiz_details' );
8 if ( ! is_admin() && ! current_user_can( 'tutor_instructor') && true === $enabled_hide_quiz_details ) {
9 exit;
10 }
11
12 extract($data); // $user_id, $attempt_id, $attempt_data(nullable), $context(nullable)
13
14 !isset($attempt_data) ? $attempt_data = tutor_utils()->get_attempt($attempt_id) : 0;
15 !isset($context) ? $context=null : 0;
16
17 if (!$attempt_id || !$attempt_data || $user_id!=$attempt_data->user_id){
18 echo '<p>'.__('Attempt not found or access permission denied', 'tutor').'</p>';
19 return;
20 }
21
22 if ( isset( $user_id ) && $user_id > 0 ) {
23 $user = get_userdata( $user_id );
24 if ( ! $user ) {
25 return;
26 }
27 }
28
29 function tutor_render_answer_list( $answers= array(), $dump_data=false ){
30 if(!empty($answers)){
31
32 echo '<div class="correct-answer-wrap">';
33
34 $multi_texts = array();
35 foreach ($answers as $key => $ans) {
36 $type = isset($ans->answer_view_format) ? $ans->answer_view_format : 'text_image';
37
38 if (isset($ans->answer_two_gap_match)) {
39 echo '<div class="matching-type">';
40 }
41
42 switch ($type) {
43 case 'text_image':
44 echo '<div class="text-image-type tutor-mb-4">';
45 if(isset($ans->image_id)){
46 $img_url = wp_get_attachment_image_url($ans->image_id);
47 if($img_url){
48 echo '<span class="image"><img src="'.$img_url.'" /></span>';
49 }
50 }
51 if(isset($ans->answer_title)) {
52 echo '<span class="caption">'.stripslashes($ans->answer_title).'</span>';
53 }
54 echo '</div>';
55 break;
56
57 case 'text':
58 $ans_string = '<span class="tutor-fs-7 tutor-fw-medium tutor-color-black">'
59 .esc_html( $ans->answer_title ).
60 '</span>';
61
62 if(isset($ans->answer_title) && !isset($ans->answer_two_gap_match)) {
63 $multi_texts[$ans->answer_title] = $ans_string;
64 } else {
65 echo $ans_string;
66 }
67 break;
68
69 case 'image':
70 echo '<div class="image-type">';
71 if(isset($ans->image_id)){
72 $img_url = wp_get_attachment_image_url($ans->image_id);
73 if($img_url){
74 echo '<span class="image"><img src="'.$img_url.'" />'.'</span>';
75 }
76 }
77 echo '</div>';
78 break;
79 }
80
81
82 if (isset($ans->answer_two_gap_match)) {
83 // echo '<div class="matching-separator">&nbsp;-&nbsp;</div>';
84 echo '<div class="image-match">'.stripslashes($ans->answer_two_gap_match).'</div>';
85 echo '</div>';
86 }
87 }
88 echo count($multi_texts) ? implode(', ', $multi_texts) : '';
89
90 echo '</div>';
91 }
92 }
93
94 function tutor_render_fill_in_the_blank_answer($get_db_answers_by_question, $answer_titles) {
95
96 $spaces = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
97
98 // Loop through the answers
99 foreach ($get_db_answers_by_question as $db_answer){
100 $count_dash_fields = substr_count($db_answer->answer_title, '{dash}');
101
102 if ($count_dash_fields){
103 $dash_string = array();
104 $input_data = array();
105 for($i=0; $i<$count_dash_fields; $i++){
106 $ans_title = (!empty($answer_titles[$i]) && !ctype_space($answer_titles[$i])) ? $answer_titles[$i] : null;
107 $input_data[] = $ans_title ? "<span class='filled_dash_unser'>{$ans_title}</span>" : $spaces;
108 }
109
110 $answer_title = $db_answer->answer_title;
111
112 foreach($input_data as $index=>$replace){
113 $replace = '<span style="text-decoration:underline;">'.$replace.'</span>';
114 $answer_title = preg_replace('/{dash}/i', $replace, $answer_title, 1);
115 }
116 echo str_replace('{dash}', "<span class='filled_dash_unser'>{$spaces}</span>", stripslashes($answer_title));
117 }
118 }
119 }
120
121 // Prepare student data
122 if(!isset($user_data)) {
123 $user_data = get_userdata( $user_id );
124 }
125
126 // Prepare atttempt meta info
127 extract(tutor_utils()->get_quiz_attempt_timing($attempt_data)); // $attempt_duration, $attempt_duration_taken;
128
129 // Prepare the correct/incorrect answer count for the first summary table
130 $answers = tutor_utils()->get_quiz_answers_by_attempt_id($attempt_id);
131 $correct = 0;
132 $incorrect = 0;
133 if(is_array($answers) && count($answers) > 0) {
134 foreach ($answers as $answer){
135 if ( (bool) isset( $answer->is_correct ) ? $answer->is_correct : '' ) {
136 $correct++;
137 } else {
138 if ($answer->question_type === 'open_ended' || $answer->question_type === 'short_answer'){
139 } else {
140 $incorrect++;
141 }
142 }
143 }
144 }
145
146 // Prepare the column list for the first summary table
147 $page_key ='attempt-details-summary';
148 $table_1_columns = include __DIR__ . '/contexts.php';
149
150 // Prepare the column list for the second table (eery single answer list)
151 $page_key = 'attempt-details-answers';
152 $table_2_columns = include __DIR__ . '/contexts.php';
153
154 include __DIR__ . '/header.php';
155
156 $attempt_info = @unserialize( $attempt_data->attempt_info );
157
158 if ( is_array( $attempt_info ) ) {
159 $attempt_type = '';
160 // Allowed duration
161 if ( isset( $attempt_info['time_limit'] ) ) {
162 $attempt_duration = tutor_utils()->second_to_formated_time( $attempt_info['time_limit']['time_limit_seconds'], $attempt_info['time_limit']['time_type'] );
163 }
164 if ( 'days' == $attempt_info['time_limit']['time_type'] ) {
165 $attempt_type = 'hours';
166 }
167 if ( 'hours' == $attempt_info['time_limit']['time_type'] ) {
168 $attempt_type = 'minutes';
169 }
170 if ( 'minutes' == $attempt_info['time_limit']['time_type'] ) {
171 $attempt_type = 'minutes';
172 }
173
174 // Taken duration
175 $seconds = strtotime( $attempt_data->attempt_ended_at ) - strtotime( $attempt_data->attempt_started_at );
176 $attempt_duration_taken = tutor_utils()->second_to_formated_time( $seconds, $attempt_type );
177 }
178 ?>
179
180 <?php echo is_admin() ? '<div class="tutor-admin-body">' : ''; ?>
181 <div class="tutor-table-responsive tutor-mb-32">
182 <table class="tutor-table my-quiz-attempts">
183 <thead>
184 <tr>
185 <?php foreach($table_1_columns as $key => $column) : ?>
186 <th><?php echo $column; ?></th>
187 <?php endforeach; ?>
188 </tr>
189 </thead>
190
191 <tbody>
192 <tr>
193 <?php foreach( $table_1_columns as $key => $column ) : ?>
194 <td>
195 <?php if ( $key == 'user' ) : ?>
196 <div class="tutor-d-flex tutor-align-center">
197 <?php echo tutor_utils()->get_tutor_avatar( $user_id ); ?>
198 <div class="tutor-ml-16">
199 <div>
200 <?php echo $user_data ? $user_data->display_name : ''; ?>
201 </div>
202 <a href="<?php echo esc_url( tutor_utils()->profile_url($user_id, false) ) ?>" class="tutor-iconic-btn">
203 <span class="tutor-icon-external-link"></span>
204 </a>
205 </div>
206 </div>
207
208 <?php elseif ( $key == 'date' ) : ?>
209 <div>
210 <?php echo date_i18n(get_option('date_format'), strtotime($attempt_data->attempt_started_at)); ?>
211 </div>
212 <div>
213 <?php echo date_i18n(get_option('time_format'), strtotime($attempt_data->attempt_started_at)); ?>
214 </div>
215 <?php elseif ( $key == 'qeustion_count' ) : ?>
216 <?php echo $attempt_data->total_questions; ?>
217 <?php elseif ( $key == 'quiz_time' ) : ?>
218 <?php echo $attempt_duration; ?>
219 <?php elseif ( $key == 'attempt_time' ) : ?>
220 <?php echo $attempt_duration_taken; ?>
221 <?php elseif ( $key == 'total_marks' ) : ?>
222 <?php echo $attempt_data->total_marks; ?>
223 <?php elseif ( $key == 'pass_marks' ) : ?>
224 <?php
225 $pass_marks = ($total_marks * $passing_grade) / 100;
226 echo number_format_i18n($pass_marks, 2);
227
228 $pass_mark_percent = $passing_grade;
229 echo ' ('.$pass_mark_percent.'%)';
230 ?>
231 <?php elseif ( $key == 'correct_answer' ) : ?>
232 <?php echo $correct; ?>
233 <?php elseif ( $key == 'incorrect_answer' ) : ?>
234 <?php echo $incorrect; ?>
235 <?php elseif ( $key == 'earned_marks' ) : ?>
236 <?php
237 echo $attempt_data->earned_marks;
238 $earned_percentage = $attempt_data->earned_marks > 0 ? ( number_format(($attempt_data->earned_marks * 100) / $attempt_data->total_marks)) : 0;
239 echo ' ('.$earned_percentage.'%)';
240 ?>
241 <?php elseif ( $key == 'result' ) : ?>
242 <?php
243 $ans_array = is_array( $answers ) ? $answers : array();
244 $has_pending = count( array_filter( $ans_array, function( $ans ) {
245 return $ans->is_correct === null;
246 }));
247
248 if ( $has_pending ) {
249 echo '<span class="tutor-badge-label label-warning">'.__('Pending', 'tutor').'</span>';
250 } else if ( $earned_percentage >= $pass_mark_percent ) {
251 echo '<span class="tutor-badge-label label-success">'.__('Pass', 'tutor').'</span>';
252 } else {
253 echo '<span class="tutor-badge-label label-danger">'.__('Fail', 'tutor').'</span>';
254 }
255 ?>
256 <?php endif; ?>
257 </td>
258 <?php endforeach; ?>
259 </tr>
260 </tbody>
261 </table>
262 </div>
263
264 <?php
265 // instructor feedback.
266 global $wp_query;
267 $query_vars = $wp_query->query_vars;
268 $page_name = isset( $query_vars['tutor_dashboard_page'] ) ? $query_vars['tutor_dashboard_page'] : '';
269 $attempt_info = unserialize( $attempt_data->attempt_info );
270 $feedback = is_array( $attempt_info ) && isset( $attempt_info['instructor_feedback'] ) ? $attempt_info['instructor_feedback'] : '';
271 // don't show on instructor quiz attempt since below already have feedback box area.
272 if ( '' !== $feedback && 'my-quiz-attempts' === $page_name ) {
273 ?>
274 <div class="tutor-quiz-attempt-note tutor-instructor-note tutor-my-32 tutor-py-20 tutor-px-24 tutor-py-sm-32 tutor-px-sm-36">
275 <div class="tutor-in-title tutor-fs-6 tutor-fw-medium tutor-color-black">
276 <?php esc_html_e( 'Instructor Note', 'tutor' ); ?>
277 </div>
278 <div class="tutor-in-body tutor-fs-6 tutor-color-secondary tutor-pt-12 tutor-pt-sm-16">
279 <?php echo wp_kses_post( $feedback ); ?>
280 </div>
281 </div>
282 <?php } ?>
283
284 <?php
285 if (is_array($answers) && count($answers)){
286 echo $context!='course-single-previous-attempts' ? '<div class="tutor-fs-6 tutor-fw-medium tutor-color-black tutor-mt-24">'.__('Quiz Overview', 'tutor').'</div>' : '';
287 ?>
288 <div class="tutor-table-responsive tutor-mt-16">
289 <table class="tutor-table tutor-quiz-attempt-details tutor-mb-32">
290 <thead>
291 <tr>
292 <?php foreach($table_2_columns as $key => $column) : ?>
293 <th><?php echo $column; ?></th>
294 <?php endforeach; ?>
295 </tr>
296 </thead>
297
298 <tbody>
299 <?php
300 $answer_i = 0;
301 foreach ($answers as $answer){
302 $answer_i++;
303 $question_type = tutor_utils()->get_question_types($answer->question_type);
304
305 $answer_status = 'wrong';
306
307 // If already correct, then show it
308 if ( (bool)$answer->is_correct ) {
309 $answer_status = 'correct';
310 }
311
312 // Image answering also needs review since the answer texts are not meant to match exactly
313 else if (in_array($answer->question_type, array('open_ended', 'short_answer', 'image_answering'))){
314 $answer_status = $answer->is_correct===null ? 'pending' : 'wrong';
315 }
316 ?>
317
318 <tr class="tutor-quiz-answer-status-<?php echo esc_html( $answer_status ); ?>">
319 <?php foreach($table_2_columns as $key => $column): ?>
320 <?php
321 switch($key) {
322 case 'no' :
323 ?>
324 <td class="no">
325 <span class="tutor-fs-7 tutor-fw-medium tutor-color-black">
326 <?php echo $answer_i; ?>
327 </span>
328 </td>
329 <?php
330 break;
331
332 case 'type' :
333 ?>
334 <td class="type">
335 <?php $type = tutor_utils()->get_question_types( $answer->question_type ); ?>
336 <div class="tooltip-wrap tooltip-icon tutor-d-flex">
337 <?php echo $question_type['icon'] ?? ''; ?>
338 <span class="tooltip-txt tooltip-top">
339 <?php echo $type['name'] ?? ''; ?>
340 </span>
341 </div>
342 </td>
343 <?php
344 break;
345
346 case 'questions' :
347 ?>
348 <td class="questions">
349 <span class="tutor-fs-7 tutor-fw-medium tutor-d-flex tutor-align-center">
350 <?php echo stripslashes($answer->question_title); ?>
351 </span>
352 </td>
353 <?php
354 break;
355
356 case 'given_answer' :
357 ?>
358 <td class="given-answer">
359 <?php
360 // Single choice
361 if ( $answer->question_type === 'single_choice' ) {
362 $get_answers = tutor_utils()->get_answer_by_id($answer->given_answer);
363 tutor_render_answer_list($get_answers);
364 }
365
366
367 // True false or single choise
368 if ($answer->question_type === 'true_false'){
369 $get_answers = tutor_utils()->get_answer_by_id($answer->given_answer);
370 $answer_titles = wp_list_pluck($get_answers, 'answer_title');
371 $answer_titles = array_map('stripslashes', $answer_titles);
372
373 echo '<span class="tutor-fs-7 tutor-fw-medium tutor-color-black">'.
374 implode('</p><p>', $answer_titles).
375 '</span>';
376 }
377
378 // Multiple choice
379 elseif ($answer->question_type === 'multiple_choice'){
380 $get_answers = tutor_utils()->get_answer_by_id(maybe_unserialize($answer->given_answer));
381 tutor_render_answer_list($get_answers);
382 }
383
384 // Fill in the blank
385 elseif ($answer->question_type === 'fill_in_the_blank'){
386 $answer_titles = maybe_unserialize($answer->given_answer);
387 $get_db_answers_by_question = tutor_utils()->get_answers_by_quiz_question($answer->question_id);
388
389 echo tutor_render_fill_in_the_blank_answer($get_db_answers_by_question, $answer_titles);
390 }
391
392 // Open ended or short answer
393 elseif ($answer->question_type === 'open_ended' || $answer->question_type === 'short_answer'){
394 if ($answer->given_answer){
395 echo wpautop(stripslashes($answer->given_answer));
396 }
397 }
398
399 // Ordering
400 elseif ($answer->question_type === 'ordering'){
401 $ordering_ids = maybe_unserialize($answer->given_answer);
402 foreach ($ordering_ids as $ordering_id){
403 $get_answers = tutor_utils()->get_answer_by_id($ordering_id);
404 tutor_render_answer_list($get_answers);
405 }
406 }
407
408 // Matching
409 elseif ($answer->question_type === 'matching'){
410
411 $ordering_ids = maybe_unserialize($answer->given_answer);
412 $original_saved_answers = tutor_utils()->get_answers_by_quiz_question($answer->question_id);
413
414 $answers = array();
415
416 foreach ($original_saved_answers as $key => $original_saved_answer){
417 $provided_answer_order_id = isset($ordering_ids[$key]) ? $ordering_ids[$key] : 0;
418 $provided_answer_order = tutor_utils()->get_answer_by_id($provided_answer_order_id);
419 if(tutor_utils()->count($provided_answer_order)){
420 foreach ($provided_answer_order as $provided_answer_order);
421 $original_saved_answer->answer_two_gap_match = $provided_answer_order->answer_two_gap_match;
422 $answers[] = $original_saved_answer;
423 }
424 }
425
426 tutor_render_answer_list( $answers );
427 }
428
429 elseif ($answer->question_type === 'image_matching'){
430
431 $ordering_ids = maybe_unserialize($answer->given_answer);
432 $original_saved_answers = tutor_utils()->get_answers_by_quiz_question($answer->question_id);
433
434 $answers = array();
435
436 foreach ($original_saved_answers as $key => $original_saved_answer){
437 $provided_answer_order_id = isset($ordering_ids[$key]) ? $ordering_ids[$key] : 0;
438 $provided_answer_order = tutor_utils()->get_answer_by_id($provided_answer_order_id);
439 foreach ($provided_answer_order as $provided_answer_order);
440
441 if($provided_answer_order->answer_title) {
442 $original_saved_answer->answer_view_format = 'text_image';
443 $original_saved_answer->answer_title = $provided_answer_order->answer_title;
444 $answers[] = $original_saved_answer;
445 }
446 }
447
448 tutor_render_answer_list( $answers );
449 }
450
451 elseif ($answer->question_type === 'image_answering'){
452
453 $ordering_ids = maybe_unserialize($answer->given_answer);
454
455 $answers = array();
456
457 foreach ($ordering_ids as $answer_id => $image_answer){
458 $db_answers = tutor_utils()->get_answer_by_id($answer_id);
459 foreach ($db_answers as $db_answer);
460 $db_answer->answer_title = $image_answer;
461 $db_answer->answer_view_format = 'text_image';
462 $answers[] = $db_answer;
463
464 }
465
466 tutor_render_answer_list( $answers );
467 }
468 ?>
469 </td>
470 <?php
471 break;
472
473 case 'correct_answer' :
474 ?>
475 <td class="correct-answer">
476 <?php
477 if (($answer->question_type != 'open_ended' && $answer->question_type != 'short_answer')) {
478
479 global $wpdb;
480
481 // True false
482 if ( $answer->question_type === 'true_false' ) {
483 $correct_answer = $wpdb->get_var( $wpdb->prepare(
484 "SELECT answer_title FROM {$wpdb->prefix}tutor_quiz_question_answers
485 WHERE belongs_question_id = %d
486 AND belongs_question_type='true_false'
487 AND is_correct = 1",
488 $answer->question_id
489 ) );
490
491 echo '<span class="tutor-fs-7 tutor-fw-medium tutor-color-black">' .
492 $correct_answer .
493 '</span>';
494 }
495
496 // Single choice
497 elseif ( $answer->question_type === 'single_choice' ) {
498 $correct_answer = $wpdb->get_results( $wpdb->prepare(
499 "SELECT answer_title, image_id, answer_view_format
500 FROM {$wpdb->prefix}tutor_quiz_question_answers
501 WHERE belongs_question_id = %d
502 AND belongs_question_type='single_choice' AND
503 is_correct = 1",
504 $answer->question_id
505 ) );
506
507 tutor_render_answer_list($correct_answer);
508 }
509
510 // Multiple choice
511 elseif ( $answer->question_type === 'multiple_choice' ) {
512 $correct_answer = $wpdb->get_results( $wpdb->prepare(
513 "SELECT answer_title, image_id, answer_view_format
514 FROM {$wpdb->prefix}tutor_quiz_question_answers
515 WHERE belongs_question_id = %d
516 AND belongs_question_type='multiple_choice'
517 AND is_correct = 1 ;",
518 $answer->question_id
519 ) );
520
521 tutor_render_answer_list($correct_answer);
522 }
523
524 // Fill in the blanks
525 elseif ( $answer->question_type === 'fill_in_the_blank' ) {
526 $correct_answer = $wpdb->get_var( $wpdb->prepare(
527 "SELECT answer_two_gap_match FROM {$wpdb->prefix}tutor_quiz_question_answers
528 WHERE belongs_question_id = %d
529 AND belongs_question_type='fill_in_the_blank'",
530 $answer->question_id
531 ) );
532
533 $answer_titles = explode('|', stripslashes($correct_answer));
534 $get_db_answers_by_question = tutor_utils()->get_answers_by_quiz_question($answer->question_id);
535
536 echo tutor_render_fill_in_the_blank_answer($get_db_answers_by_question, $answer_titles);
537 }
538
539 // Ordering
540 elseif ( $answer->question_type === 'ordering' ) {
541 $correct_answer = $wpdb->get_results( $wpdb->prepare(
542 "SELECT answer_title, image_id, answer_view_format
543 FROM {$wpdb->prefix}tutor_quiz_question_answers
544 WHERE belongs_question_id = %d
545 AND belongs_question_type='ordering'
546 ORDER BY answer_order ASC;",
547 $answer->question_id
548 ) );
549
550 foreach($correct_answer as $ans) {
551 tutor_render_answer_list(array($ans));
552 }
553 }
554
555 // Matching
556 elseif( $answer->question_type === 'matching' ){
557 $correct_answer = $wpdb->get_results( $wpdb->prepare(
558 "SELECT answer_title, image_id, answer_two_gap_match, answer_view_format
559 FROM {$wpdb->prefix}tutor_quiz_question_answers
560 WHERE belongs_question_id = %d
561 AND belongs_question_type='matching'
562 ORDER BY answer_order ASC;",
563 $answer->question_id
564 ) );
565
566 tutor_render_answer_list($correct_answer);
567 }
568
569 // Image matching
570 elseif( $answer->question_type === 'image_matching' ) {
571 $correct_answer = $wpdb->get_results( $wpdb->prepare(
572 "SELECT answer_title, image_id, answer_two_gap_match
573 FROM {$wpdb->prefix}tutor_quiz_question_answers
574 WHERE belongs_question_id = %d
575 AND belongs_question_type='image_matching'
576 ORDER BY answer_order ASC;",
577 $answer->question_id
578 ) );
579
580 tutor_render_answer_list($correct_answer, true);
581 }
582
583 // Image Answering
584 elseif ($answer->question_type === 'image_answering'){
585
586 $correct_answer = $wpdb->get_results( $wpdb->prepare(
587 "SELECT answer_title, image_id, answer_two_gap_match
588 FROM {$wpdb->prefix}tutor_quiz_question_answers
589 WHERE belongs_question_id = %d
590 AND belongs_question_type='image_answering'
591 ORDER BY answer_order ASC;",
592 $answer->question_id
593 ) );
594
595 !is_array($correct_answer) ? $correct_answer=array() : 0;
596
597 echo '<div class="answer-image-matched-wrap">';
598 foreach ($correct_answer as $image_answer){
599 ?>
600 <div class="image-matching-item">
601 <p class="dragged-img-rap"><img src="<?php echo wp_get_attachment_image_url( $image_answer->image_id); ?>" /> </p>
602 <p class="dragged-caption"><?php echo $image_answer->answer_title; ?></p>
603 </div>
604 <?php
605 }
606 echo '</div>';
607 }
608 }
609 ?>
610 </td>
611 <?php
612 break;
613
614 case 'answer' :
615 ?>
616 <td class="answer">
617 <?php
618 switch($answer_status) {
619 case 'correct' :
620 echo '<span class="tutor-badge-label label-success">'.__('Correct', 'tutor').'</span>';
621 break;
622
623 case 'pending' :
624 echo '<span class="tutor-badge-label label-warning">'.__('Pending', 'tutor').'</span>';
625 break;
626
627 case 'wrong' :
628 echo '<span class="tutor-badge-label label-danger">'.__('Incorrect', 'tutor').'</span>';
629 break;
630 }
631 ?>
632 </td>
633 <?php
634 break;
635
636 case 'manual_review' :
637 ?>
638 <td class="tutor-text-center tutor-nowrap-ellipsis">
639 <a href="javascript:;" data-back-url="<?php echo $back_url; ?>" data-attempt-id="<?php echo $attempt_id; ?>" data-attempt-answer-id="<?php echo $answer->attempt_answer_id; ?>" data-mark-as="correct" data-context="<?php echo $context; ?>" title="<?php _e('Mark as correct', 'tutor'); ?>" class="quiz-manual-review-action tutor-mr-12 tutor-icon-rounded tutor-color-success">
640 <i class="tutor-icon-mark"></i>
641 </a>
642 <a href="javascript:;" data-back-url="<?php echo $back_url; ?>" data-attempt-id="<?php echo $attempt_id; ?>" data-attempt-answer-id="<?php echo $answer->attempt_answer_id; ?>" data-mark-as="incorrect" data-context="<?php echo $context; ?>" title="<?php _e('Mark as In correct', 'tutor'); ?>" class="quiz-manual-review-action tutor-icon-rounded tutor-color-danger">
643 <i class="tutor-icon-times"></i>
644 </a>
645 </td>
646 <?php
647 }
648 ?>
649 <?php endforeach; ?>
650 </tr>
651 <?php
652 }
653 ?>
654 </tbody>
655 </table>
656 </div>
657 <?php
658 }
659 ?>
660
661 <?php echo is_admin() ? '</div>' : ''; ?>