|
36 | 36 | $reveal_wait_ms = 1000 * (int) tutor_utils()->get_option( 'quiz_answer_display_time' ); |
37 | 37 | $is_linear_layout = in_array( $question_layout_view, array( 'single_question', 'question_pagination' ), true ); |
38 | 38 | $show_previous_button = (bool) tutor_utils()->get_option( 'quiz_previous_button_enabled', true ); |
| 39 | +$attempts_allowed = (int) tutor_utils()->get_quiz_option( $tutor_is_started_quiz->quiz_id, 'attempts_allowed', 0 ); |
| 40 | +$previous_attempts = tutor_utils()->quiz_attempts(); |
| 41 | +$current_attempt_number = ( is_array( $previous_attempts ) ? count( $previous_attempts ) : 0 ) + 1; |
39 | 42 |
|
40 | 43 | $reveal_question_types = array( 'true_false', 'single_choice', 'multiple_choice' ); |
41 | 44 | $quiz_answers = array(); |
@@ -152,6 +155,40 @@ class="tutor-quiz-question-paginate-item" |
152 | 155 | </ul> |
153 | 156 | </div> |
154 | 157 | <?php endif; ?> |
| 158 | + |
| 159 | + <?php if ( $is_linear_layout ) : ?> |
| 160 | + <div class="tutor-quiz-question-meta"> |
| 161 | + <div class="tutor-quiz-question-indicator"> |
| 162 | + <?php |
| 163 | + echo wp_kses( |
| 164 | + sprintf( |
| 165 | + /* translators: %s: question number indicator (e.g. 01/15) */ |
| 166 | + __( 'Question No: %s', 'tutor' ), |
| 167 | + '<strong x-text="String(currentIndex).padStart(2, \'0\') + \'/\' + String(totalQuestions).padStart(2, \'0\')"></strong>' |
| 168 | + ), |
| 169 | + array( |
| 170 | + 'strong' => array( |
| 171 | + 'x-text' => true, |
| 172 | + ), |
| 173 | + ) |
| 174 | + ); |
| 175 | + ?> |
| 176 | + </div> |
| 177 | + <div class="tutor-quiz-attempt-progress"> |
| 178 | + <?php |
| 179 | + echo wp_kses( |
| 180 | + sprintf( |
| 181 | + /* translators: %s: allowed attempts (number or ∞) */ |
| 182 | + __( 'Total Attempt: %s', 'tutor' ), |
| 183 | + '<strong>' . esc_html( $current_attempt_number ) . '/' . ( 0 === $attempts_allowed ? '∞' : esc_html( $attempts_allowed ) ) . '</strong>' |
| 184 | + ), |
| 185 | + array( 'strong' => array() ) |
| 186 | + ); |
| 187 | + ?> |
| 188 | + </div> |
| 189 | + </div> |
| 190 | + <?php endif; ?> |
| 191 | + |
155 | 192 | <?php |
156 | 193 | foreach ( $questions as $index => $question ) { |
157 | 194 | $question_settings = maybe_unserialize( $question->question_settings ); |
|
0 commit comments