Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/tutor/templates/single/quiz/parts/question.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + /**
3 + * Question
4 + *
5 + * @package Tutor\Templates
6 + * @subpackage Single\Quiz\Parts
7 + * @author Themeum <support@themeum.com>
8 + * @link https://themeum.com
9 + * @version 1.0.0
10 + */
11 +
12 + ?>
13 +
14 + <div id="tutor-quiz-attempt-questions-wrap" data-question-layout-view="<?php echo esc_attr( $question_layout_view ); ?>">
15 +
16 + <?php
17 + $choice_contexts = array(
18 + 'true_false' => 'radio',
19 + 'single_choice' => 'radio',
20 + 'multiple_choice' => 'checkbox',
21 + );
22 + $show_previous_button = (bool) tutor_utils()->get_option( 'quiz_previous_button_enabled', true );
23 +
24 + if ( 'question_pagination' === $question_layout_view ) {
25 + $question_i = 0;
26 + ?>
27 + <div class="tutor-quiz-questions-pagination">
28 + <ul>
29 + <?php
30 + foreach ( $questions as $question ) {
31 + $question_i++;
32 + $markup = "<li><a href='#quiz-attempt-single-question-{$question->question_id}' class='tutor-quiz-question-paginate-item'>{$question_i}</a> </li>";
33 + echo wp_kses(
34 + $markup,
35 + array(
36 + 'li' => array(),
37 + 'a' => array(
38 + 'href' => true,
39 + 'class' => true,
40 + ),
41 + )
42 + );
43 + }
44 + ?>
45 + </ul>
46 + </div>
47 + <?php
48 + }
49 + ?>
50 +
51 + <form id="tutor-answering-quiz" method="post">
52 + <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce, false ); ?>
53 + <input type="hidden" value="<?php echo esc_attr( $is_started_quiz->attempt_id ); ?>" name="attempt_id"/>
54 + <input type="hidden" value="tutor_answering_quiz_question" name="tutor_action"/>
55 + <?php
56 + $question_i = 0;
57 + foreach ( $questions as $question ) {
58 + $question_i++;
59 + $question_settings = maybe_unserialize( $question->question_settings );
60 + $style_display = ( 'question_below_each_other' !== $question_layout_view && 1 == $question_i ) ? 'block' : 'none';
61 + if ( 'question_below_each_other' === $question_layout_view ) {
62 + $style_display = 'block';
63 + }
64 +
65 + $next_question = isset( $questions[ $question_i ] ) ? $questions[ $question_i ] : false;
66 + $previous_question = $question_i > 1 ? $questions[ $question_i - 1 ] : false;
67 + ?>
68 + <div id="quiz-attempt-single-question-<?php echo esc_attr( $question->question_id ); ?>"
69 + class="quiz-attempt-single-question quiz-attempt-single-question-<?php echo esc_attr( $question_i ); ?>"
70 + style="display: <?php echo esc_attr( $style_display ); ?> ;"
71 + <?php echo $next_question ? "data-next-question-id='#quiz-attempt-single-question-" . esc_attr( $next_question->question_id ) . "'" : ''; ?>
72 + <?php echo 'h5p' === $question->question_type ? 'data-h5p-quiz-content-id=' . esc_attr( $question->question_description ) : ''; ?>
73 + data-quiz-feedback-mode="<?php echo esc_attr( $feedback_mode ); ?>"
74 + data-question_index="<?php echo esc_attr( $question_i ); ?>"
75 + data-question-type="<?php echo esc_attr( $question->question_type ); ?>">
76 +
77 + <div class="quiz-question tutor-mt-44 tutor-mr-md-100">
78 + <?php
79 + $input_markup = "<input type='hidden' name='attempt[{$is_started_quiz->attempt_id}][quiz_question_ids][]' value='{$question->question_id}' />";
80 + echo wp_kses(
81 + $input_markup,
82 + array(
83 + 'input' => array(
84 + 'type' => true,
85 + 'name' => true,
86 + 'value' => true,
87 + ),
88 + )
89 + );
90 +
91 + $question_type = $question->question_type;
92 +
93 + $rand_choice = false;
94 + if ( 'matching' !== $question_type && 'image_matching' !== $question_type ) { // Note: Randomize will be done in specific template.
95 + if ( 'ordering' === $question_type ) {
96 + $rand_choice = true;
97 + } else {
98 + $question_settings = maybe_unserialize( $question->question_settings );
99 + $rand_choice = ( isset( $question_settings['randomize_question'] ) && '1' === $question_settings['randomize_question'] );
100 + }
101 + }
102 +
103 + $answers = \Tutor\Models\QuizModel::get_answers_by_quiz_question( $question->question_id, $rand_choice );
104 + $show_question_mark = (bool) tutor_utils()->avalue_dot( 'show_question_mark', $question_settings );
105 + $answer_required = (bool) tutor_utils()->array_get( 'answer_required', $question_settings );
106 + echo wp_kses(
107 + '<div class="quiz-question-title tutor-fs-4 tutor-fw-medium tutor-color-black tutor-mb-20">',
108 + array(
109 + 'div' => array( 'class' => true ),
110 + )
111 + );
112 +
113 + if ( ! $hide_question_number_overview ) {
114 + echo esc_html( $question_i . '. ' );
115 + }
116 + echo esc_html( stripslashes( $question->question_title ) );
117 + echo '</div>';
118 +
119 + if ( $show_question_mark ) {
120 + echo wp_kses(
121 + '<p class="question-marks"> ' . __( 'Marks : ', 'tutor' ) . $question->question_mark . ' </p>',
122 + array(
123 + 'p' => array( 'class' => true ),
124 + )
125 + );
126 + }
127 +
128 +
129 + $question_description = apply_filters( 'tutor_filter_quiz_question_description', wp_unslash( $question->question_description ) );
130 + if ( $question_description ) {
131 + $markup = "<div class='matching-quiz-question-desc'><span class='tutor-fs-7 tutor-color-secondary'>{$question_description}</span></div>";
132 + if ( tutor()->has_pro ) {
133 + do_action( 'tutor_quiz_question_desc_render', $markup, $question );
134 + } else {
135 + echo wp_kses_post( $markup );
136 + }
137 + }
138 +
139 + ?>
140 + </div>
141 + <!-- Quiz Answer -->
142 + <?php
143 + if ( array_key_exists( $question_type, $choice_contexts ) ) {
144 + // Only checkbox and radio type content will be loaded here.
145 + $choice_type = $choice_contexts[ $question_type ];
146 + require 'choice-box.php';
147 + }
148 +
149 + // Fill In The Blank.
150 + if ( 'fill_in_the_blank' === $question_type ) {
151 + require 'fill-in-the-blank.php';
152 + }
153 +
154 + // Ordering.
155 + if ( 'ordering' === $question_type ) {
156 + require 'ordering.php';
157 + }
158 +
159 +
160 + // Matching.
161 + if ( 'matching' === $question_type ) {
162 + $is_image_matching = isset( $question_settings['is_image_matching'] ) && '1' === $question_settings['is_image_matching'];
163 + if ( $is_image_matching ) {
164 + require 'image-matching.php';
165 + } else {
166 + require 'matching.php';
167 + }
168 + }
169 +
170 + // Image Matching.
171 + if ( 'image_matching' === $question_type ) {
172 + require 'image-matching.php';
173 + }
174 +
175 + // Image Answer.
176 + if ( 'image_answering' === $question_type ) {
177 + require 'image-answer.php';
178 + }
179 +
180 + // Open Ended.
181 + if ( 'open_ended' === $question_type ) {
182 + require 'open-ended.php';
183 + }
184 +
185 + // Short Answer.
186 + if ( 'short_answer' === $question_type ) {
187 + require 'short-answer.php';
188 + }
189 +
190 + do_action( 'tutor_require_question_answer_file', $question_type, $is_started_quiz, $question );
191 + ?>
192 +
193 + <div class="answer-help-block tutor-mt-24"></div>
194 +
195 + <?php do_action( 'tutor_quiz_question_after_answers', $post, $quiz_details, $question ); ?>
196 +
197 + <?php if ( 'question_below_each_other' !== $question_layout_view ) : ?>
198 + <div class="tutor-quiz-btn-group tutor-mt-60 tutor-d-flex">
199 + <?php
200 + if ( $show_previous_button && $previous_question ) {
201 + ?>
202 + <button type="button" class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-quiz-answer-previous-btn tutor-mr-20">
203 + <span class="tutor-icon-previous tutor-mr-8" area-hidden="true"></span> <?php esc_html_e( 'Back', 'tutor' ); ?>
204 + </button>
205 + <?php
206 + }
207 + ?>
208 + <button disabled="disabled" type="submit" class="tutor-btn tutor-btn-primary tutor-btn-md start-quiz-btn tutor-quiz-next-btn-all <?php echo $next_question ? 'tutor-quiz-answer-next-btn' : 'tutor-quiz-submit-btn'; ?>">
209 + <?php $next_question ? esc_html_e( 'Submit &amp; Next', 'tutor' ) : esc_html_e( 'Submit Quiz', 'tutor' ); ?>
210 + </button>
211 + <?php if ( ! isset( $question_settings['answer_required'] ) || '0' === $question_settings['answer_required'] ) : ?>
212 + <span class="tutor-ml-32 tutor-btn tutor-btn-ghost tutor-btn-md tutor-next-btn <?php echo $next_question ? 'tutor-quiz-answer-next-btn' : 'tutor-quiz-submit-btn'; ?> tutor-ml-auto">
213 + <?php esc_html_e( 'Skip Question', 'tutor' ); ?>
214 + </span>
215 + <?php endif; ?>
216 + </div>
217 + <?php endif; ?>
218 + </div>
219 + <?php
220 + }
221 +
222 + if ( 'question_below_each_other' === $question_layout_view ) {
223 + ?>
224 + <div class="quiz-answer-footer-bar tutor-mt-60">
225 + <div class="quiz-footer-button">
226 + <button type="submit" name="quiz_answer_submit_btn" value="quiz_answer_submit" class="tutor-btn tutor-btn-primary">
227 + <?php esc_html_e( 'Submit Quiz', 'tutor' ); ?>
228 + </button>
229 + </div>
230 + </div>
231 + <?php
232 + }
233 + ?>
234 + </form>
235 + </div>
236 +