tools
6 years ago
add_new_instructor.php
6 years ago
addons.php
6 years ago
answer.php
6 years ago
enable_disable_addons.php
6 years ago
get-pro.php
6 years ago
instructors.php
6 years ago
question_answer.php
6 years ago
quiz_attempts.php
6 years ago
students.php
6 years ago
tools.php
6 years ago
tutor-pro-addons.php
6 years ago
uninstall.php
6 years ago
view_attempt.php
6 years ago
withdraw_requests.php
6 years ago
view_attempt.php
330 lines
| 1 | <?php |
| 2 | $attempt_id = (int) sanitize_text_field($_GET['attempt_id']); |
| 3 | $attempt = tutor_utils()->get_attempt($attempt_id); |
| 4 | |
| 5 | if ( ! $attempt){ |
| 6 | ?> |
| 7 | <h1><?php _e('Attempt not found', 'tutor'); ?></h1> |
| 8 | <?php |
| 9 | return; |
| 10 | } |
| 11 | |
| 12 | $quiz_attempt_info = tutor_utils()->quiz_attempt_info($attempt->attempt_info); |
| 13 | $answers = tutor_utils()->get_quiz_answers_by_attempt_id($attempt->attempt_id); |
| 14 | |
| 15 | $user_id = tutor_utils()->avalue_dot('user_id', $attempt); |
| 16 | $user = get_userdata($user_id); |
| 17 | ?> |
| 18 | |
| 19 | |
| 20 | <div class="tutor-quiz-attempt-review-wrap"> |
| 21 | <h2 class="attempt-review-title"> <i class="tutor-icon-list"></i> <?php _e('View Attempts', 'tutor'); ?></h2> |
| 22 | |
| 23 | <div class="tutor-quiz-attempt-info-row"> |
| 24 | <div class="attempt-view-top"> |
| 25 | <div class="attempt-info-col"> |
| 26 | <div class="attempt-user-details"> |
| 27 | <div class="attempt-user-avatar"> |
| 28 | <img src="<?php echo esc_url(get_avatar_url($user_id)) ?>" alt="<?php echo esc_attr($user->display_name); ?>"> |
| 29 | </div> |
| 30 | <div class="attempt-info-content"> |
| 31 | <h5><?php echo __('Student Name', 'tutor'); ?></h5> |
| 32 | <h4><?php echo $user->display_name; ?></h4> |
| 33 | </div> |
| 34 | </div> |
| 35 | </div> |
| 36 | |
| 37 | <div class="attempt-info-col"> |
| 38 | <div class="attempt-info-content"> |
| 39 | <h5><?php echo __('Quiz', 'tutor'); ?></h5> |
| 40 | <h4> |
| 41 | <?php |
| 42 | echo "<a href='" .admin_url("post.php?post={$attempt->quiz_id}&action=edit")."'>".get_the_title($attempt->quiz_id)."</a>"; |
| 43 | ?> |
| 44 | </h4> |
| 45 | </div> |
| 46 | </div> |
| 47 | |
| 48 | <div class="attempt-info-col"> |
| 49 | <div class="attempt-info-content"> |
| 50 | <h5><?php echo __('Attempt Time', 'tutor'); ?></h5> |
| 51 | <h4> |
| 52 | <?php echo date_i18n(get_option('date_format'), strtotime($attempt->attempt_started_at)).' '.date_i18n(get_option('time_format'), strtotime($attempt->attempt_started_at)); ?> |
| 53 | </h4> |
| 54 | </div> |
| 55 | </div> |
| 56 | |
| 57 | <div class="attempt-info-col"> |
| 58 | <div class="attempt-info-content"> |
| 59 | <h5><?php echo __('Status', 'tutor'); ?></h5> |
| 60 | <h4> |
| 61 | <?php |
| 62 | $status = ucwords(str_replace('quiz_', '', $attempt->attempt_status)); |
| 63 | echo $status; |
| 64 | ?> |
| 65 | </h4> |
| 66 | </div> |
| 67 | </div> |
| 68 | </div> |
| 69 | |
| 70 | <div class="attempt-view-bottom"> |
| 71 | <div class="attempt-info-col"> |
| 72 | <div class="attempt-info-content"> |
| 73 | <h5><?php echo __('Course', 'tutor'); ?></h5> |
| 74 | <h4> |
| 75 | <?php |
| 76 | $quiz = tutor_utils()->get_course_by_quiz($attempt->quiz_id); |
| 77 | if ($quiz) { |
| 78 | echo "<a href='".admin_url( "post.php?post={$quiz->ID}&action=edit" ) . "'>". get_the_title( $quiz->ID )."</a>"; |
| 79 | } |
| 80 | ?> |
| 81 | </h4> |
| 82 | </div> |
| 83 | </div> |
| 84 | |
| 85 | <div class="attempt-info-col"> |
| 86 | <div class="attempt-info-content"> |
| 87 | <h5><?php echo __('Result', 'tutor'); ?></h5> |
| 88 | <h4> |
| 89 | <?php |
| 90 | $pass_mark_percent = tutor_utils()->get_quiz_option($attempt->quiz_id, 'passing_grade', 0); |
| 91 | $earned_percentage = $attempt->earned_marks > 0 ? ( number_format(($attempt->earned_marks * 100) / $attempt->total_marks)) : 0; |
| 92 | $output = ''; |
| 93 | if ($earned_percentage >= $pass_mark_percent){ |
| 94 | $output .= '<span class="result-pass">'.__('Pass', 'tutor').'</span>'; |
| 95 | }else{ |
| 96 | $output .= '<span class="result-fail">'.__('Fail', 'tutor').'</span>'; |
| 97 | } |
| 98 | |
| 99 | $output .= "".$attempt->earned_marks." out of {$attempt->total_marks}"; |
| 100 | $output .= "<span>, Marks earned ({$earned_percentage}%)</span>"; |
| 101 | echo $output; |
| 102 | ?> |
| 103 | </h4> |
| 104 | </div> |
| 105 | </div> |
| 106 | |
| 107 | <div class="attempt-info-col"> |
| 108 | <div class="attempt-info-content"> |
| 109 | <h5><?php echo __('Quiz Time', 'tutor'); ?></h5> |
| 110 | <h4> |
| 111 | <?php |
| 112 | $time_limit_seconds = tutor_utils()->avalue_dot('time_limit.time_limit_seconds', $quiz_attempt_info); |
| 113 | echo tutor_utils()->seconds_to_time_context($time_limit_seconds); |
| 114 | ?> |
| 115 | </h4> |
| 116 | </div> |
| 117 | </div> |
| 118 | |
| 119 | <div class="attempt-info-col"> |
| 120 | <div class="attempt-info-content"> |
| 121 | <h5><?php echo __('Attempt Time', 'tutor'); ?></h5> |
| 122 | <h4> |
| 123 | <?php |
| 124 | $attempt_time_sec = strtotime($attempt->attempt_ended_at) - strtotime($attempt->attempt_started_at); |
| 125 | echo tutor_utils()->seconds_to_time_context($attempt_time_sec); |
| 126 | ?> |
| 127 | </h4> |
| 128 | </div> |
| 129 | |
| 130 | </div> |
| 131 | |
| 132 | </div> |
| 133 | |
| 134 | </div> |
| 135 | |
| 136 | |
| 137 | <div class="attempt-review-notice-wrap"> |
| 138 | <?php |
| 139 | if (is_array($answers) && count($answers)) { |
| 140 | $question_no = 0; |
| 141 | $required_review = array(); |
| 142 | |
| 143 | foreach ($answers as $answer){ |
| 144 | $question_no++; |
| 145 | if ($answer->question_type === 'open_ended' || $answer->question_type === 'short_answer'){ |
| 146 | $required_review[] = $question_no; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | if (count($required_review)){ |
| 151 | echo '<p class="attempt-review-notice"> <i class="tutor-icon-warning-2"></i> <strong>Reminder: </strong> Please review answers for question no. '.implode(', ', $required_review).' </p>'; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | |
| 156 | ?> |
| 157 | |
| 158 | <?php if ((bool) $attempt->is_manually_reviewed ){ |
| 159 | ?> |
| 160 | <p class="attempt-review-at"> |
| 161 | <span class="circle-arrow">↻ </span> |
| 162 | <strong> |
| 163 | <?php _e('Manually reviewed at: ', 'tutor'); ?> |
| 164 | </strong> |
| 165 | <?php echo date_i18n(get_option('date_format'), strtotime($attempt->manually_reviewed_at)).' '.date_i18n(get_option('time_format'), strtotime($attempt->manually_reviewed_at)); ?> |
| 166 | </p> |
| 167 | <?php |
| 168 | } ?> |
| 169 | |
| 170 | </div> |
| 171 | |
| 172 | <?php |
| 173 | if (is_array($answers) && count($answers)){ |
| 174 | |
| 175 | ?> |
| 176 | <div class="quiz-attempt-answers-wrap"> |
| 177 | |
| 178 | <div class="attempt-answers-header"> |
| 179 | <h3><?php _e('Quiz Overview', 'tutor'); ?></h3> |
| 180 | </div> |
| 181 | |
| 182 | <table class="wp-list-table"> |
| 183 | <tr> |
| 184 | <th><?php _e('Type', 'tutor'); ?></th> |
| 185 | <th><?php _e('No.', 'tutor'); ?></th> |
| 186 | <th><?php _e('Question', 'tutor'); ?></th> |
| 187 | <th><?php _e('Given Answers', 'tutor'); ?></th> |
| 188 | <th><?php _e('Correct/Incorrect', 'tutor'); ?></th> |
| 189 | <th><?php _e('Manual Review', 'tutor'); ?></th> |
| 190 | </tr> |
| 191 | <?php |
| 192 | $answer_i = 0; |
| 193 | foreach ($answers as $answer){ |
| 194 | $answer_i++; |
| 195 | $question_type = tutor_utils()->get_question_types($answer->question_type); |
| 196 | ?> |
| 197 | <tr> |
| 198 | <td><?php echo $question_type['icon']; ?></td> |
| 199 | <td><?php echo $answer_i; ?></td> |
| 200 | <td><?php echo stripslashes($answer->question_title); ?></td> |
| 201 | <td> |
| 202 | <?php |
| 203 | if ($answer->question_type === 'true_false' || $answer->question_type === 'single_choice' ){ |
| 204 | $get_answers = tutor_utils()->get_answer_by_id($answer->given_answer); |
| 205 | $answer_titles = wp_list_pluck($get_answers, 'answer_title'); |
| 206 | $answer_titles = array_map('stripslashes', $answer_titles); |
| 207 | echo '<p>'.implode('</p><p>', $answer_titles).'</p>'; |
| 208 | }elseif ($answer->question_type === 'multiple_choice'){ |
| 209 | $get_answers = tutor_utils()->get_answer_by_id(maybe_unserialize($answer->given_answer)); |
| 210 | $answer_titles = wp_list_pluck($get_answers, 'answer_title'); |
| 211 | $answer_titles = array_map('stripslashes', $answer_titles); |
| 212 | echo '<p>'.implode('</p><p>', $answer_titles).'</p>'; |
| 213 | }elseif ($answer->question_type === 'fill_in_the_blank'){ |
| 214 | $answer_titles = maybe_unserialize($answer->given_answer); |
| 215 | $get_db_answers_by_question = tutor_utils()->get_answers_by_quiz_question($answer->question_id); |
| 216 | foreach ($get_db_answers_by_question as $db_answer); |
| 217 | $count_dash_fields = substr_count($db_answer->answer_title, '{dash}'); |
| 218 | if ($count_dash_fields){ |
| 219 | $dash_string = array(); |
| 220 | $input_data = array(); |
| 221 | for($i=0; $i<$count_dash_fields; $i++){ |
| 222 | //$dash_string[] = '{dash}'; |
| 223 | $input_data[] = isset($answer_titles[$i]) ? "<span class='filled_dash_unser'>{$answer_titles[$i]}</span>" : "______"; |
| 224 | } |
| 225 | $answer_title = $db_answer->answer_title; |
| 226 | foreach($input_data as $replace){ |
| 227 | $answer_title = preg_replace('/{dash}/i', $replace, $answer_title, 1); |
| 228 | } |
| 229 | echo str_replace('{dash}', '_____', $answer_title); |
| 230 | } |
| 231 | |
| 232 | }elseif ($answer->question_type === 'open_ended' || $answer->question_type === 'short_answer'){ |
| 233 | |
| 234 | if ($answer->given_answer){ |
| 235 | echo wpautop(stripslashes($answer->given_answer)); |
| 236 | } |
| 237 | |
| 238 | }elseif ($answer->question_type === 'ordering'){ |
| 239 | |
| 240 | $ordering_ids = maybe_unserialize($answer->given_answer); |
| 241 | foreach ($ordering_ids as $ordering_id){ |
| 242 | $get_answers = tutor_utils()->get_answer_by_id($ordering_id); |
| 243 | $answer_titles = wp_list_pluck($get_answers, 'answer_title'); |
| 244 | $answer_titles = array_map('stripslashes', $answer_titles); |
| 245 | echo '<p>'.implode('</p><p>', $answer_titles).'</p>'; |
| 246 | } |
| 247 | |
| 248 | }elseif ($answer->question_type === 'matching'){ |
| 249 | |
| 250 | $ordering_ids = maybe_unserialize($answer->given_answer); |
| 251 | $original_saved_answers = tutor_utils()->get_answers_by_quiz_question($answer->question_id); |
| 252 | |
| 253 | foreach ($original_saved_answers as $key => $original_saved_answer){ |
| 254 | $provided_answer_order_id = isset($ordering_ids[$key]) ? $ordering_ids[$key] : 0; |
| 255 | $provided_answer_order = tutor_utils()->get_answer_by_id($provided_answer_order_id); |
| 256 | if(tutils()->count($provided_answer_order)){ |
| 257 | foreach ($provided_answer_order as $provided_answer_order); |
| 258 | echo $original_saved_answer->answer_title ." - {$provided_answer_order->answer_two_gap_match} <br />"; |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | }elseif ($answer->question_type === 'image_matching'){ |
| 263 | |
| 264 | $ordering_ids = maybe_unserialize($answer->given_answer); |
| 265 | $original_saved_answers = tutor_utils()->get_answers_by_quiz_question($answer->question_id); |
| 266 | |
| 267 | echo '<div class="answer-image-matched-wrap">'; |
| 268 | foreach ($original_saved_answers as $key => $original_saved_answer){ |
| 269 | $provided_answer_order_id = isset($ordering_ids[$key]) ? $ordering_ids[$key] : 0; |
| 270 | $provided_answer_order = tutor_utils()->get_answer_by_id($provided_answer_order_id); |
| 271 | foreach ($provided_answer_order as $provided_answer_order); |
| 272 | ?> |
| 273 | <div class="image-matching-item"> |
| 274 | <p class="dragged-img-rap"><img src="<?php echo wp_get_attachment_image_url( $original_saved_answer->image_id); ?>" /> </p> |
| 275 | <p class="dragged-caption"><?php echo $provided_answer_order->answer_title; ?></p> |
| 276 | </div> |
| 277 | <?php |
| 278 | } |
| 279 | echo '</div>'; |
| 280 | }elseif ($answer->question_type === 'image_answering'){ |
| 281 | |
| 282 | $ordering_ids = maybe_unserialize($answer->given_answer); |
| 283 | |
| 284 | echo '<div class="answer-image-matched-wrap">'; |
| 285 | foreach ($ordering_ids as $answer_id => $image_answer){ |
| 286 | $db_answers = tutor_utils()->get_answer_by_id($answer_id); |
| 287 | foreach ($db_answers as $db_answer); |
| 288 | ?> |
| 289 | <div class="image-matching-item"> |
| 290 | <p class="dragged-img-rap"><img src="<?php echo wp_get_attachment_image_url( $db_answer->image_id); ?>" /> </p> |
| 291 | <p class="dragged-caption"><?php echo $image_answer; ?></p> |
| 292 | </div> |
| 293 | <?php |
| 294 | } |
| 295 | echo '</div>'; |
| 296 | } |
| 297 | |
| 298 | ?> |
| 299 | </td> |
| 300 | |
| 301 | <td> |
| 302 | <?php |
| 303 | |
| 304 | if ( (bool) isset( $answer->is_correct ) ? $answer->is_correct : '' ) { |
| 305 | echo '<span class="quiz-correct-answer-text"><i class="tutor-icon-mark"></i> '.__('Correct', 'tutor').'</span>'; |
| 306 | } else { |
| 307 | if ($answer->question_type === 'open_ended' || $answer->question_type === 'short_answer'){ |
| 308 | echo '<p style="color: #878A8F;"><span style="color: #ff282a;">*</span> '.__('Review Required', 'tutor').'</p>'; |
| 309 | }else { |
| 310 | echo '<span class="quiz-incorrect-answer-text"><i class="tutor-icon-line-cross"></i> '.__('Incorrect', 'tutor').'</span>'; |
| 311 | } |
| 312 | } |
| 313 | ?> |
| 314 | </td> |
| 315 | |
| 316 | <td style="white-space: nowrap"> |
| 317 | <a href="<?php echo admin_url("admin.php?action=review_quiz_answer&attempt_id={$attempt_id}&attempt_answer_id={$answer->attempt_answer_id}&mark_as=correct"); ?>" title="<?php _e('Mark as correct', 'tutor'); ?>" class="attempt-mark-correct-btn quiz-manual-review-action"><i class="tutor-icon-mark"></i> </a> |
| 318 | <a href="<?php echo admin_url("admin.php?action=review_quiz_answer&attempt_id={$attempt_id}&attempt_answer_id={$answer->attempt_answer_id}&mark_as=incorrect"); ?>" title="<?php _e('Mark as In correct', 'tutor'); ?>" class="attempt-mark-incorrect-btn quiz-manual-review-action"><i class="tutor-icon-line-cross"></i></a> |
| 319 | </td> |
| 320 | </tr> |
| 321 | <?php |
| 322 | } |
| 323 | ?> |
| 324 | </table> |
| 325 | </div> |
| 326 | |
| 327 | <?php |
| 328 | } |
| 329 | ?> |
| 330 | </div> |