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.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 3 years ago attempt-details.php 3 years ago attempt-table.php 3 years ago contexts.php 3 years ago header.php 3 years ago instructor-feedback.php 4 years ago
attempt-table.php
191 lines
1 <?php
2 extract( $data ); // $attempt_list, $context;
3
4 $page_key = 'attempt-table';
5 $table_columns = include __DIR__ . '/contexts.php';
6 $enabled_hide_quiz_details = tutor_utils()->get_option( 'hide_quiz_details' );
7
8 if ( $context == 'course-single-previous-attempts' && is_array( $attempt_list ) && count( $attempt_list ) ) {
9 // Provide the attempt data from the first attempt
10 // For now now attempt specific data is shown, that's why no problem if we take meta data from any attempt.
11 $attempt_data = $attempt_list[0];
12 include __DIR__ . '/header.php';
13 }
14 ?>
15
16 <?php if ( is_array( $attempt_list ) && count( $attempt_list ) ) : ?>
17 <div class="tutor-table-responsive tutor-my-24">
18 <table class="tutor-table tutor-table-quiz-attempts">
19 <thead>
20 <tr>
21 <?php foreach ( $table_columns as $key => $column ) : ?>
22 <?php
23 /**
24 * Pro feature: Only for frontend
25 *
26 * @since 2.07
27 */
28 if ( $key === 'details' && ! is_admin() && ! current_user_can( 'tutor_instructor' ) && true === $enabled_hide_quiz_details ) {
29 continue;
30 }
31 ?>
32
33 <th><?php echo $column; ?></th>
34 <?php endforeach; ?>
35 </tr>
36 </thead>
37
38 <?php
39 $attempt_ids = array_column( $attempt_list, 'attempt_id' );
40 $answers_array = \Tutor\Models\QuizModel::get_quiz_answers_by_attempt_id( $attempt_ids, true );
41 ?>
42
43 <tbody>
44 <?php foreach ( $attempt_list as $attempt ) : ?>
45 <?php
46 $earned_percentage = $attempt->earned_marks > 0 ? ( number_format( ( $attempt->earned_marks * 100 ) / $attempt->total_marks ) ) : 0;
47 $answers = isset( $answers_array[ $attempt->attempt_id ] ) ? $answers_array[ $attempt->attempt_id ] : array();
48 $attempt_info = @unserialize( $attempt->attempt_info );
49 $attempt_info = ! is_array( $attempt_info ) ? array() : $attempt_info;
50 $passing_grade = isset( $attempt_info['passing_grade'] ) ? (int) $attempt_info['passing_grade'] : 0;
51 $ans_array = is_array( $answers ) ? $answers : array();
52
53 $has_pending = count(
54 array_filter(
55 $ans_array,
56 function( $ans ) {
57 return $ans->is_correct === null;
58 }
59 )
60 );
61
62 $correct = 0;
63 $incorrect = 0;
64 $attempt_id = $attempt->attempt_id;
65
66 if ( is_array( $answers ) && count( $answers ) > 0 ) {
67 foreach ( $answers as $answer ) {
68 if ( (bool) $answer->is_correct ) {
69 $correct++;
70 } elseif ( ! ( $answer->is_correct === null ) ) {
71 $incorrect++;
72 }
73 }
74 }
75 ?>
76 <tr>
77 <?php foreach ( $table_columns as $key => $column ) : ?>
78 <?php
79 /**
80 * Pro feature: Only for frontend
81 *
82 * @since 2.07
83 */
84 if ( $key === 'details' && ! is_admin() && ! current_user_can( 'tutor_instructor' ) && true === $enabled_hide_quiz_details ) {
85 continue;
86 }
87 ?>
88 <td>
89 <?php if ( $key == 'checkbox' ) : ?>
90 <div class="tutor-d-flex">
91 <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; ?>" />
92 </div>
93 <?php elseif ( $key == 'date' ) : ?>
94 <?php echo date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $attempt->attempt_ended_at ) ); ?>
95 <?php elseif ( $key == 'quiz_info' ) : ?>
96 <div>
97 <div class="tutor-fs-7 tutor-fw-normal">
98 <?php echo date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $attempt->attempt_ended_at ) ); ?>
99 </div>
100 <div class="tutor-mt-4">
101 <?php
102 // For admin panel
103 if ( is_admin() ) {
104 esc_html_e( get_the_title( $attempt->quiz_id ) );
105 } else {
106 // For frontend
107 esc_html_e( get_the_title( $attempt->quiz_id ) );
108 ?>
109 <div class="tooltip-wrap tooltip-icon-custom" >
110 <i class="tutor-icon-circle-info-o tutor-color-muted tutor-ml-4 tutor-fs-7"></i>
111 <span class="tooltip-txt tooltip-right">
112 <?php esc_html_e( get_the_title( $attempt->course_id ) ); ?>
113 </span>
114 </div>
115 <?php
116 }
117 ?>
118 </div>
119 <!-- <div class="tutor-fs-7 tutor-mt-8">
120 <?php
121 $attempt_user = get_userdata( $attempt->user_id );
122 $user_name = $attempt_user ? $attempt_user->display_name : '';
123 ?>
124 <span class="tutor-color-secondary"><?php _e( 'Student:', 'tutor' ); ?></span>
125 <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>
126 </div> -->
127 <?php do_action( 'tutor_quiz/table/after/course_title', $attempt, $context ); ?>
128 </div>
129 <?php elseif ( $key == 'course' ) : ?>
130 <?php esc_html_e( get_the_title( $attempt->course_id ) ); ?>
131 <?php elseif ( $key == 'question' ) : ?>
132 <?php echo count( $answers ); ?>
133 <?php elseif ( $key == 'total_marks' ) : ?>
134 <?php echo round( $attempt->total_marks ); ?>
135 <?php elseif ( $key == 'correct_answer' ) : ?>
136 <?php echo $correct; ?>
137 <?php elseif ( $key == 'incorrect_answer' ) : ?>
138 <?php echo $incorrect; ?>
139 <?php elseif ( $key == 'earned_marks' ) : ?>
140 <?php echo round( $attempt->earned_marks ) . ' (' . $earned_percentage . '%)'; ?>
141 <?php elseif ( $key == 'result' ) : ?>
142 <?php
143 if ( $has_pending ) {
144 echo '<span class="tutor-badge-label label-warning">' . __( 'Pending', 'tutor' ) . '</span>';
145 } else {
146 echo $earned_percentage >= $passing_grade ?
147 '<span class="tutor-badge-label label-success">' . __( 'Pass', 'tutor' ) . '</span>' :
148 '<span class="tutor-badge-label label-danger">' . __( 'Fail', 'tutor' ) . '</span>';
149 }
150 ?>
151 <?php elseif ( $key == 'details' ) : ?>
152 <?php
153 $url = add_query_arg( array( 'view_quiz_attempt_id' => $attempt->attempt_id ), tutor()->current_url );
154 $style = '';
155 ?>
156 <div class="tutor-d-inline-flex tutor-align-center" style="<?php echo esc_attr( ! is_admin() ? $style : '' ); ?>">
157 <a href="<?php echo esc_url( $url ); ?>" class="tutor-btn tutor-btn-outline-primary tutor-btn-sm">
158 <?php
159 if ( $has_pending && ( $context == 'frontend-dashboard-students-attempts' || $context == 'backend-dashboard-students-attempts' ) ) {
160 esc_html_e( 'Review', 'tutor' );
161 } else {
162 esc_html_e( 'Details', 'tutor-pro' );
163 }
164 ?>
165 </a>
166 <?php if ( ! is_admin() && current_user_can( tutor()->instructor_role ) ) : ?>
167 <a href="#" class="tutor-quiz-attempt-delete tutor-iconic-btn tutor-flex-shrink-0 tutor-ml-4" data-quiz-id="<?php echo esc_attr( $attempt_id ); ?>" data-tutor-modal-target="tutor-common-confirmation-modal">
168 <i class="tutor-icon-trash-can-line" data-quiz-id="<?php echo esc_attr( $attempt_id ); ?>"></i>
169 </a>
170 <?php endif; ?>
171 </div>
172 <?php endif; ?>
173 </td>
174 <?php endforeach; ?>
175 </tr>
176 <?php endforeach; ?>
177 </tbody>
178 </table>
179 </div>
180 <?php else : ?>
181 <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?>
182 <?php endif; ?>
183 <?php
184 // Load delete modal.
185 tutor_load_template_from_custom_path(
186 tutor()->path . 'views/elements/common-confirm-popup.php',
187 array(
188 'message' => __( 'Would you like to delete Quiz Attempt permanently? We suggest you proceed with caution.', 'tutor' ),
189 )
190 );
191