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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 / templates / shared / components / quiz / attempt-details.php
tutor / templates / shared / components / quiz Last commit date
attempt-details 1 day ago attempt-details.php 4 days ago
attempt-details.php
166 lines
1 <?php
2 /**
3 * Shared quiz attempt details summary view.
4 *
5 * @package Tutor\Templates
6 * @subpackage Shared
7 * @author Themeum <support@themeum.com>
8 * @link https://themeum.com
9 * @since 4.0.0
10 */
11
12 defined( 'ABSPATH' ) || exit;
13
14 use TUTOR\Icon;
15 use TUTOR\Quiz_Attempts_List;
16 use TUTOR\Input;
17 use Tutor\Components\EmptyState;
18 use Tutor\Models\QuizModel;
19 use Tutor\Components\Button;
20 use Tutor\Components\Constants\Size;
21 use Tutor\Components\Constants\Variant;
22
23 global $tutor_current_post;
24
25 $is_quiz_details_hidden = Quiz_Attempts_List::is_attempt_details_hidden();
26
27 if ( $is_quiz_details_hidden ) {
28 return;
29 }
30
31 $quiz_id = (int) ( $quiz_id ?? ( $tutor_current_post->ID ?? 0 ) );
32 $user_id = (int) ( $user_id ?? get_current_user_id() );
33 $attempt_id = (int) ( $attempt_id ?? Input::get( 'attempt_id', 0, Input::TYPE_INT ) );
34 $attempt_data = $attempt_data ?? null;
35 $back_url = $back_url ?? get_permalink( $quiz_id );
36 $context = (string) ( $context ?? '' );
37 $is_instructor_review = ! empty( $is_instructor_review );
38
39 if ( $attempt_id > 0 && ! $attempt_data ) {
40 $attempt_data = tutor_utils()->get_attempt( $attempt_id );
41 }
42
43 $render_attempt_not_found = static function ( string $title ) {
44 EmptyState::make()
45 ->title( $title )
46 ->icon( tutor_utils()->get_themed_svg( 'images/illustrations/quiz-empty.svg' ) )
47 ->render();
48 };
49
50 if ( ! $attempt_data || empty( $attempt_data->attempt_id ) ) {
51 $render_attempt_not_found( __( 'Attempt not found', 'tutor' ) );
52 return;
53 }
54
55 if ( $is_instructor_review ) {
56 if ( ! tutor_utils()->can_user_manage( 'attempt', (int) $attempt_data->attempt_id ) ) {
57 $render_attempt_not_found( __( 'Attempt not found or access permission denied', 'tutor' ) );
58 return;
59 }
60 } elseif ( $user_id > 0 && (int) $attempt_data->user_id !== $user_id ) {
61 $render_attempt_not_found( __( 'Attempt not found or access permission denied', 'tutor' ) );
62 return;
63 }
64
65 if ( ! $quiz_id ) {
66 $quiz_id = (int) ( $attempt_data->quiz_id ?? 0 );
67 }
68
69 $questions = QuizModel::get_quiz_answers_by_attempt_id( (int) $attempt_data->attempt_id );
70 $questions = QuizModel::filter_attempt_answers_for_details( $questions, $is_instructor_review );
71
72 $course_contents = tutor_utils()->get_course_prev_next_contents_by_id( $quiz_id );
73 ?>
74 <div class="tutor-quiz-summary-page">
75 <div class="tutor-quiz-summary-header">
76 <div class="tutor-quiz-summary-header-inner">
77 <div class="tutor-flex tutor-items-center tutor-gap-4">
78 <?php
79 Button::make()
80 ->icon( Icon::ARROW_LEFT_2 )
81 ->flip_rtl()
82 ->tag( 'a' )
83 ->attr( 'href', $back_url )
84 ->variant( Variant::GHOST )
85 ->size( Size::X_SMALL )
86 ->icon_only()
87 ->render();
88 ?>
89 <h5 class="tutor-h5 tutor-font-semibold"><?php esc_html_e( 'Quiz Summary', 'tutor' ); ?></h5>
90 </div>
91
92 <?php
93 Button::make()
94 ->icon( Icon::CROSS )
95 ->tag( 'a' )
96 ->attr( 'href', $back_url )
97 ->attr( 'type', 'button' )
98 ->variant( Variant::GHOST )
99 ->size( Size::X_SMALL )
100 ->icon_only()
101 ->render();
102 ?>
103 </div>
104 </div>
105
106 <div class="tutor-surface-l1">
107 <?php
108 tutor_load_template(
109 'shared.components.quiz.attempt-details.summary',
110 array(
111 'attempt_data' => $attempt_data,
112 'answers' => $questions, // $questions holds quiz answers data, mapped to 'answers' key for summary template
113 'is_instructor_review' => $is_instructor_review,
114 )
115 );
116 ?>
117 </div>
118 <?php if ( tutor_utils()->count( $questions ) ) : ?>
119 <div class="tutor-quiz-summary-body">
120 <?php
121 tutor_load_template(
122 'shared.components.quiz.attempt-details.questions-sidebar',
123 array(
124 'quiz_id' => $quiz_id,
125 'attempt_data' => $attempt_data,
126 'questions' => $questions,
127 'is_instructor_review' => $is_instructor_review,
128 )
129 );
130 ?>
131 <div class="tutor-quiz-summary-content">
132 <h3 class="tutor-h3 tutor-sm-text-h5 tutor-text-subdued tutor-mb-10 tutor-sm-mb-5">
133 <?php esc_html_e( 'Review your answers', 'tutor' ); ?>
134 </h3>
135 <?php
136 tutor_load_template(
137 'shared.components.quiz.attempt-details.review-answers',
138 array(
139 'questions' => is_array( $questions ) ? $questions : array(),
140 'attempt_data' => $attempt_data,
141 'back_url' => $back_url,
142 'context' => $context,
143 'is_instructor_review' => $is_instructor_review,
144 )
145 );
146 ?>
147 </div>
148 </div>
149 <?php endif; ?>
150 <?php if ( ! empty( $is_learning_area ) && $course_contents->next_id ) : ?>
151 <div class="tutor-quiz-summary-footer">
152 <div class="tutor-quiz-summary-footer-inner">
153 <?php
154 Button::make()
155 ->tag( 'a' )
156 ->label( __( 'Continue Lesson', 'tutor' ) )
157 ->variant( Variant::PRIMARY )
158 ->size( Size::LARGE )
159 ->attr( 'href', esc_url( get_the_permalink( $course_contents->next_id ) ) )
160 ->render();
161 ?>
162 </div>
163 </div>
164 <?php endif; ?>
165 </div>
166