fill-in-the-blank.php
1 month ago
image-answering.php
1 month ago
matching.php
1 month ago
multiple-choice.php
1 month ago
open-ended.php
1 month ago
ordering.php
1 month ago
true-false.php
1 month ago
image-answering.php
46 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Tutor quiz image answering. |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://themeum.com |
| 8 | * @since 4.0.0 |
| 9 | */ |
| 10 | |
| 11 | defined( 'ABSPATH' ) || exit; |
| 12 | |
| 13 | use Tutor\Components\InputField; |
| 14 | |
| 15 | $field_name = ''; |
| 16 | $register_rules = ''; |
| 17 | if ( $answer_is_required ) { |
| 18 | $register_rules = ", { required: '" . esc_js( $required_message ) . "' }"; |
| 19 | } |
| 20 | |
| 21 | ?> |
| 22 | |
| 23 | <div class="tutor-quiz-question-options"> |
| 24 | <?php foreach ( $question['question_answers'] as $index => $answer ) : ?> |
| 25 | <div class="tutor-quiz-question-option"> |
| 26 | <img src="<?php echo esc_url( wp_get_attachment_image_url( $answer['image_id'], 'full' ) ); ?>" alt="<?php echo esc_attr( $answer['answer_title'] ); ?>"> |
| 27 | <?php |
| 28 | $input_name = sprintf( '%s[answer_id][%d]', $question_field_name_base ?? '', (int) $answer['answer_id'] ); |
| 29 | $rules_suffix = $register_rules; |
| 30 | $register_attr = "register('{$input_name}'{$rules_suffix})"; |
| 31 | |
| 32 | if ( 0 === $index ) { |
| 33 | $field_name = $input_name; |
| 34 | } |
| 35 | |
| 36 | InputField::make() |
| 37 | ->name( $input_name ) |
| 38 | ->clearable() |
| 39 | ->attr( 'x-bind', $register_attr ) |
| 40 | ->placeholder( __( 'Write your answer here', 'tutor' ) ) |
| 41 | ->render(); |
| 42 | ?> |
| 43 | </div> |
| 44 | <?php endforeach; ?> |
| 45 | </div> |
| 46 |