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.2 3.2.3 3.3.0 3.3.1 3.4.0 3.4.1 3.4.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 / dashboard / quiz-attempts / quiz-reviews.php
tutor / templates / dashboard / quiz-attempts Last commit date
quiz-attempts-feedback.php 1 month ago quiz-reviews.php 1 month ago
quiz-reviews.php
132 lines
1 <?php
2 /**
3 * Frontend Student's Quiz Review
4 *
5 * @package Tutor\Templates
6 * @subpackage Dashboard\Quiz_Attempts
7 * @author Themeum <support@themeum.com>
8 * @link https://themeum.com
9 * @since 1.4.0
10 */
11
12 defined( 'ABSPATH' ) || exit;
13
14 use TUTOR\Input;
15 use Tutor\Components\EmptyState;
16 use Tutor\Models\QuizModel;
17
18 $attempt_id = Input::get( 'attempt_id', 0, Input::TYPE_INT );
19 $attempt_data = tutor_utils()->get_attempt( $attempt_id );
20 $user_id = tutor_utils()->avalue_dot( 'user_id', $attempt_data );
21 $quiz_id = (int) tutor_utils()->avalue_dot( 'quiz_id', $attempt_data );
22 $back_url = remove_query_arg( 'attempt_id' );
23 $attempt_info = isset( $attempt_data->attempt_info ) ? maybe_unserialize( $attempt_data->attempt_info ) : array();
24 $can_review = $attempt_id > 0 && tutor_utils()->can_user_manage( 'attempt', $attempt_id );
25
26 if ( ! $attempt_data || ! $can_review ) {
27 EmptyState::make()
28 ->title( __( 'Attempt not found or access permission denied', 'tutor' ) )
29 ->icon( tutor_utils()->get_themed_svg( 'images/illustrations/quiz-empty.svg' ) )
30 ->render();
31 return;
32 }
33
34 $form_id = 'quiz-attempt-review-form';
35 $form_default_values = array(
36 'feedback' => tutor_utils()->count( $attempt_info ) && isset( $attempt_info['instructor_feedback'] ) ? $attempt_info['instructor_feedback'] : '',
37 );
38
39 $attempt_answers_map = array();
40 $questions = QuizModel::get_quiz_answers_by_attempt_id( $attempt_id );
41
42 if ( is_array( $questions ) ) {
43 foreach ( $questions as $question ) {
44 $question_id = (int) ( $question->question_id ?? 0 );
45
46 if ( $question_id > 0 ) {
47 $attempt_answers_map[ $question_id ] = $question;
48 $answer_status = QuizModel::get_attempt_answer_status( $question );
49 $form_default_values[ "review_statuses[{$question_id}]" ] = $answer_status;
50 }
51 }
52 }
53 ?>
54
55 <div class="wrap">
56
57 <?php if ( ! is_admin() ) : ?>
58 <form
59 id="<?php echo esc_attr( $form_id ); ?>"
60 x-data='(() => {
61 const form = tutorForm({
62 id: "<?php echo esc_attr( $form_id ); ?>",
63 mode: "onSubmit",
64 defaultValues: <?php echo wp_json_encode( $form_default_values, JSON_HEX_APOS ); ?>
65 });
66 const feedback = tutorQuizAttemptFeedback({
67 attemptId: <?php echo esc_attr( $attempt_id ); ?>,
68 formId: "<?php echo esc_attr( $form_id ); ?>"
69 });
70
71 return {
72 ...form,
73 ...feedback,
74 init() {
75 form.init?.call(this);
76 feedback.init?.call(this);
77 },
78 };
79 })()'
80 x-bind="getFormBindings()"
81 @submit.prevent="handleSubmit((data) => handleSaveFeedback(data))($event)"
82 >
83 <?php endif; ?>
84
85 <div class="tutor-quiz-attempt-details-wrapper ">
86 <?php
87 if ( is_admin() ) {
88 tutor_load_template_from_custom_path(
89 tutor()->path . '/views/quiz/attempt-details.php',
90 array(
91 'attempt_id' => $attempt_id,
92 'attempt_data' => $attempt_data,
93 'user_id' => (int) $user_id,
94 'context' => 'frontend-dashboard-students-attempts',
95 )
96 );
97 } else {
98 tutor_load_template(
99 'shared.components.quiz.attempt-details',
100 array(
101 'attempt_id' => $attempt_id,
102 'attempt_data' => $attempt_data,
103 'quiz_id' => $quiz_id,
104 'user_id' => (int) $user_id,
105 'back_url' => $back_url,
106 'is_instructor_review' => true,
107 'context' => 'frontend-dashboard-students-attempts',
108 )
109 );
110 }
111 ?>
112 </div>
113
114 <?php
115 if ( is_admin() ) {
116 tutor_load_template_from_custom_path(
117 tutor()->path . 'views/quiz/instructor-feedback.php',
118 array( 'attempt_data' => $attempt_data )
119 );
120 } else {
121 tutor_load_template(
122 'dashboard.quiz-attempts.quiz-attempts-feedback',
123 array( 'attempt_data' => $attempt_data )
124 );
125 }
126 ?>
127
128 <?php if ( ! is_admin() ) : ?>
129 </form>
130 <?php endif; ?>
131 </div>
132