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