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.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 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-table.php
166 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 * @since 2.07
26 */
27 if ( $key === 'details' && ! is_admin() && ! current_user_can( 'tutor_instructor') && true === $enabled_hide_quiz_details ) {
28 continue;
29 }
30 ?>
31
32 <th style="<?php echo $key == 'quiz_info' ? 'width: 30%;' : ''; ?>"><?php echo $column; ?></th>
33 <?php endforeach; ?>
34 </tr>
35 </thead>
36
37 <?php
38 $attempt_ids = array_column($attempt_list, 'attempt_id');
39 $answers_array = tutor_utils()->get_quiz_answers_by_attempt_id($attempt_ids, true);
40 ?>
41
42 <tbody>
43 <?php foreach ( $attempt_list as $attempt ) : ?>
44 <?php
45 $earned_percentage = $attempt->earned_marks > 0 ? ( number_format( ( $attempt->earned_marks * 100 ) / $attempt->total_marks ) ) : 0;
46 $answers = isset($answers_array[$attempt->attempt_id]) ? $answers_array[$attempt->attempt_id] : array();
47 $attempt_info = @unserialize($attempt->attempt_info);
48 $attempt_info = !is_array($attempt_info) ? array() : $attempt_info;
49 $passing_grade = isset($attempt_info['passing_grade']) ? (int)$attempt_info['passing_grade'] : 0;
50 $ans_array = is_array($answers) ? $answers : array();
51
52 $has_pending = count( array_filter( $ans_array, function( $ans ) {
53 return $ans->is_correct === null;
54 }));
55
56 $correct = 0;
57 $incorrect = 0;
58
59 if ( is_array( $answers ) && count( $answers ) > 0 ) {
60 foreach ( $answers as $answer ) {
61 if ( (bool) $answer->is_correct ) {
62 $correct++;
63 } else if(!($answer->is_correct===null)) {
64 $incorrect++;
65 }
66 }
67 }
68 ?>
69 <tr>
70 <?php foreach ( $table_columns as $key => $column ) : ?>
71 <?php
72 /**
73 * Pro feature: Only for frontend
74 * @since 2.07
75 */
76 if ( $key === 'details' && ! is_admin() && ! current_user_can( 'tutor_instructor') && true === $enabled_hide_quiz_details ) {
77 continue;
78 }
79 ?>
80 <td>
81 <?php if ( $key == "checkbox" ) : ?>
82 <div class="tutor-d-flex">
83 <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; ?>" />
84 </div>
85 <?php elseif ( $key == "date" ) : ?>
86 <?php echo date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $attempt->attempt_ended_at ) ); ?>
87 <?php elseif ( $key == "quiz_info" ) : ?>
88 <div>
89 <div class="tutor-fs-7 tutor-fw-normal tutor-color-muted">
90 <?php echo date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $attempt->attempt_ended_at ) ); ?>
91 </div>
92 <div class="tutor-mt-8">
93 <?php
94 // For admin panel
95 if ( is_admin() ) {
96 esc_html_e( get_the_title( $attempt->quiz_id ) );
97 } else {
98 // For frontend
99 esc_html_e( get_the_title( $attempt->quiz_id ) );
100 ?>
101 <div class="tooltip-wrap tooltip-icon-custom" >
102 <i class="tutor-icon-circle-info-o tutor-color-muted tutor-ml-4 tutor-fs-7"></i>
103 <span class="tooltip-txt tooltip-right">
104 <?php esc_html_e( get_the_title( $attempt->course_id ) ) ?>
105 </span>
106 </div>
107 <?php
108 }
109 ?>
110 </div>
111 <div class="tutor-fs-7 tutor-mt-8">
112 <?php
113 $attempt_user = get_userdata( $attempt->user_id );
114 $user_name = $attempt_user ? $attempt_user->display_name : '';
115 ?>
116 <span class="tutor-color-secondary"><?php _e( 'Student:', 'tutor' ); ?></span>
117 <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>
118 </div>
119 <?php do_action( 'tutor_quiz/table/after/course_title', $attempt, $context ); ?>
120 </div>
121 <?php elseif ( $key == "course" ) : ?>
122 <?php esc_html_e( get_the_title( $attempt->course_id ) ); ?>
123 <?php elseif ( $key == "question" ) : ?>
124 <?php echo count( $answers ); ?>
125 <?php elseif ( $key == "total_marks" ) : ?>
126 <?php echo round($attempt->total_marks); ?>
127 <?php elseif ( $key == "correct_answer" ) : ?>
128 <?php echo $correct; ?>
129 <?php elseif ( $key == "incorrect_answer" ) : ?>
130 <?php echo $incorrect; ?>
131 <?php elseif ( $key == "earned_marks" ) : ?>
132 <?php echo round($attempt->earned_marks) . ' ( ' . $earned_percentage . '% )'; ?>
133 <?php elseif ( $key == "result" ) : ?>
134 <?php
135 if ( $has_pending ) {
136 echo '<span class="tutor-badge-label label-warning">'.__('Pending', 'tutor').'</span>';
137 } else {
138 echo $earned_percentage >= $passing_grade ?
139 '<span class="tutor-badge-label label-success">' . __( 'Pass', 'tutor' ) . '</span>' :
140 '<span class="tutor-badge-label label-danger">' . __( 'Fail', 'tutor' ) . '</span>';
141 }
142 ?>
143 <?php elseif ( $key == "details" ) : ?>
144 <?php $url = add_query_arg( array( 'view_quiz_attempt_id' => $attempt->attempt_id ), tutor()->current_url ); ?>
145 <div class="tutor-d-inline-flex tutor-align-center td-action-btns">
146 <a href="<?php echo $url; ?>" class="tutor-btn tutor-btn-outline-primary tutor-btn-sm">
147 <?php
148 if ( $has_pending && ( $context == 'frontend-dashboard-students-attempts' || $context == 'backend-dashboard-students-attempts' ) ) {
149 esc_html_e( 'Review', 'tutor' );
150 } else {
151 esc_html_e( 'Details', 'tutor-pro' );
152 }
153 ?>
154 </a>
155 </div>
156 <?php endif; ?>
157 </td>
158 <?php endforeach; ?>
159 </tr>
160 <?php endforeach; ?>
161 </tbody>
162 </table>
163 </div>
164 <?php else : ?>
165 <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?>
166 <?php endif; ?>