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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 / views / quiz / attempt-table.php
tutor / views / quiz Last commit date
header-context 4 years ago attempt-details.php 4 years ago attempt-table.php 4 years ago contexts.php 4 years ago header.php 4 years ago instructor-feedback.php 4 years ago
attempt-table.php
130 lines
1 <?php
2 extract( $data ); // $attempt_list, $context;
3
4 $page_key = 'attempt-table';
5 $table_columns = include __DIR__ . '/contexts.php';
6
7 if ( $context == 'course-single-previous-attempts' && is_array( $attempt_list ) && count( $attempt_list ) ) {
8 // Provide the attempt data from the first attempt
9 // For now now attempt specific data is shown, that's why no problem if we take meta data from any attempt.
10 $attempt_data = $attempt_list[0];
11 include __DIR__ . '/header.php';
12 }
13 ?>
14
15 <?php if ( is_array( $attempt_list ) && count( $attempt_list ) ): ?>
16 <div class="tutor-table-responsive tutor-mt-24">
17 <table class="tutor-table tutor-table-quiz-attempts">
18 <thead>
19 <tr>
20 <?php foreach ( $table_columns as $key => $column ) : ?>
21 <th style="<?php echo $key == 'quiz_info' ? 'width: 30%;' : ''; ?>"><?php echo $column; ?></th>
22 <?php endforeach; ?>
23 </tr>
24 </thead>
25
26 <?php
27 $attempt_ids = array_column($attempt_list, 'attempt_id');
28 $answers_array = tutor_utils()->get_quiz_answers_by_attempt_id($attempt_ids, true);
29 ?>
30
31 <tbody>
32 <?php foreach ( $attempt_list as $attempt ) : ?>
33 <?php
34 $earned_percentage = $attempt->earned_marks > 0 ? ( number_format( ( $attempt->earned_marks * 100 ) / $attempt->total_marks ) ) : 0;
35 $answers = isset($answers_array[$attempt->attempt_id]) ? $answers_array[$attempt->attempt_id] : array();
36 $attempt_info = @unserialize($attempt->attempt_info);
37 $attempt_info = !is_array($attempt_info) ? array() : $attempt_info;
38 $passing_grade = isset($attempt_info['passing_grade']) ? (int)$attempt_info['passing_grade'] : 0;
39 $ans_array = is_array($answers) ? $answers : array();
40
41 $has_pending = count( array_filter( $ans_array, function( $ans ) {
42 return $ans->is_correct === null;
43 }));
44
45 $correct = 0;
46 $incorrect = 0;
47
48 if ( is_array( $answers ) && count( $answers ) > 0 ) {
49 foreach ( $answers as $answer ) {
50 if ( (bool) $answer->is_correct ) {
51 $correct++;
52 } else if(!($answer->is_correct===null)) {
53 $incorrect++;
54 }
55 }
56 }
57 ?>
58 <tr>
59 <?php foreach ( $table_columns as $key => $column ) : ?>
60 <td>
61 <?php if ( $key == "checkbox" ) : ?>
62 <div class="tutor-d-flex">
63 <input id="tutor-admin-list-<?php echo $attempt->attempt_id; ?>" type="checkbox" class="tutor-form-check-input tutor-bulk-checkbox" name="tutor-bulk-checkbox-all" value="<?php echo $attempt->attempt_id; ?>" />
64 </div>
65 <?php elseif ( $key == "date" ) : ?>
66 <?php echo date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $attempt->attempt_ended_at ) ); ?>
67 <?php elseif ( $key == "quiz_info" ) : ?>
68 <div>
69 <div class="tutor-fs-7 tutor-fw-normal tutor-color-muted">
70 <?php echo date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $attempt->attempt_ended_at ) ); ?>
71 </div>
72 <div class="tutor-mt-8">
73 <?php echo get_the_title( $attempt->course_id ); ?>
74 </div>
75 <div class="tutor-fs-7 tutor-mt-8">
76 <?php
77 $attempt_user = get_userdata( $attempt->user_id );
78 $user_name = $attempt_user ? $attempt_user->display_name : '';
79 ?>
80 <span class="tutor-color-secondary"><?php _e( 'Student:', 'tutor' ); ?></span>
81 <span class="tutor-fw-normal tutor-color-muted"><?php echo $context == 'backend-dashboard-students-attempts' ? $user_name : esc_attr( isset($attempt->display_name) ? $attempt->display_name : $user_name ); ?></span>
82 </div>
83 <?php do_action( 'tutor_quiz/table/after/course_title', $attempt, $context ); ?>
84 </div>
85 <?php elseif ( $key == "course" ) : ?>
86 <?php echo get_the_title( $attempt->course_id ); ?>
87 <?php elseif ( $key == "question" ) : ?>
88 <?php echo count( $answers ); ?>
89 <?php elseif ( $key == "total_marks" ) : ?>
90 <?php echo round($attempt->total_marks); ?>
91 <?php elseif ( $key == "correct_answer" ) : ?>
92 <?php echo $correct; ?>
93 <?php elseif ( $key == "incorrect_answer" ) : ?>
94 <?php echo $incorrect; ?>
95 <?php elseif ( $key == "earned_marks" ) : ?>
96 <?php echo round($attempt->earned_marks) . ' ( ' . $earned_percentage . '% )'; ?>
97 <?php elseif ( $key == "result" ) : ?>
98 <?php
99 if ( $has_pending ) {
100 echo '<span class="tutor-badge-label label-warning">'.__('Pending', 'tutor').'</span>';
101 } else {
102 echo $earned_percentage >= $passing_grade ?
103 '<span class="tutor-badge-label label-success">' . __( 'Pass', 'tutor' ) . '</span>' :
104 '<span class="tutor-badge-label label-danger">' . __( 'Fail', 'tutor' ) . '</span>';
105 }
106 ?>
107 <?php elseif ( $key == "details" ) : ?>
108 <?php $url = add_query_arg( array( 'view_quiz_attempt_id' => $attempt->attempt_id ), tutor()->current_url ); ?>
109 <div class="tutor-d-inline-flex tutor-align-center td-action-btns">
110 <a href="<?php echo $url; ?>" class="tutor-btn tutor-btn-outline-primary tutor-btn-sm">
111 <?php
112 if ( $has_pending && ( $context == 'frontend-dashboard-students-attempts' || $context == 'backend-dashboard-students-attempts' ) ) {
113 esc_html_e( 'Review', 'tutor' );
114 } else {
115 esc_html_e( 'Details', 'tutor-pro' );
116 }
117 ?>
118 </a>
119 </div>
120 <?php endif; ?>
121 </td>
122 <?php endforeach; ?>
123 </tr>
124 <?php endforeach; ?>
125 </tbody>
126 </table>
127 </div>
128 <?php else : ?>
129 <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?>
130 <?php endif; ?>