parts
3 days ago
body.php
3 days ago
content.php
3 years ago
no_course_belongs.php
3 years ago
previous-attempts.php
3 days ago
single_quiz_contents.php
3 years ago
top.php
3 days ago
top.php
159 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Quiz top part |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Single\Quiz |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @version 1.4.3 |
| 10 | */ |
| 11 | |
| 12 | use Tutor\Models\CourseModel; |
| 13 | use TUTOR\Quiz; |
| 14 | |
| 15 | global $post; |
| 16 | global $next_id; |
| 17 | |
| 18 | $course_content_id = get_the_ID(); |
| 19 | $course_id = tutor_utils()->get_course_id_by_subcontent( $course_content_id ); |
| 20 | |
| 21 | $content_id = tutor_utils()->get_post_id( $course_content_id ); |
| 22 | $contents = tutor_utils()->get_course_prev_next_contents_by_id( $content_id ); |
| 23 | $previous_id = $contents->previous_id; |
| 24 | $next_id = $contents->next_id; |
| 25 | |
| 26 | $currentPost = $post; //phpcs:ignore |
| 27 | $quiz_id = get_the_ID(); |
| 28 | $is_started_quiz = tutor_utils()->is_started_quiz(); |
| 29 | $course = CourseModel::get_course_by_quiz( get_the_ID() ); |
| 30 | $previous_attempts = tutor_utils()->quiz_attempts(); |
| 31 | $attempted_count = is_array( $previous_attempts ) ? count( $previous_attempts ) : 0; |
| 32 | $quiz_options = tutor_utils()->get_quiz_option( $quiz_id ); |
| 33 | $limit_attempts_allowed = '1' === (string) ( $quiz_options['limit_attempts_allowed'] ?? '0' ); |
| 34 | $configured_attempts_allowed = (int) ( $quiz_options['attempts_allowed'] ?? 0 ); |
| 35 | $attempts_allowed = Quiz::get_effective_attempts_allowed( $limit_attempts_allowed, $configured_attempts_allowed ); |
| 36 | $passing_grade = (int) ( $quiz_options['passing_grade'] ?? 0 ); |
| 37 | $attempt_remaining = (int) $attempts_allowed - (int) $attempted_count; |
| 38 | $can_retry_quiz = Quiz::can_retry_quiz( $limit_attempts_allowed, $configured_attempts_allowed, $attempted_count ); |
| 39 | |
| 40 | do_action( 'tutor_quiz/single/before/top' ); |
| 41 | ?> |
| 42 | <?php if ( ! $is_started_quiz && 0 == $attempted_count ) : ?> |
| 43 | <div class="tutor-start-quiz-wrapper tutor-p-md-48 tutor-p-28"> |
| 44 | <div class="tutor-start-quiz-title tutor-pb-28"> |
| 45 | <div class="tutor-fs-6 tutor-color-black tutor-pb-8"> |
| 46 | <?php esc_html_e( 'Quiz', 'tutor' ); ?> |
| 47 | </div> |
| 48 | <div class="tutor-fs-4 tutor-fw-medium tutor-color-black"> |
| 49 | <?php echo esc_html( get_the_title() ); ?> |
| 50 | </div> |
| 51 | <div> |
| 52 | <?php the_content(); // Quiz summary. ?> |
| 53 | </div> |
| 54 | </div> |
| 55 | |
| 56 | <div class="tutor-quiz-info-area tutor-mb-60 tutor-mt-24"> |
| 57 | <?php |
| 58 | // Show total question count. |
| 59 | $total_questions = tutor_utils()->total_questions_for_student_by_quiz( get_the_ID() ); |
| 60 | if ( $total_questions ) : |
| 61 | ?> |
| 62 | <div class="tutor-quiz-info"> |
| 63 | <span class="tutor-fs-6 tutor-color-muted"><?php esc_html_e( 'Questions', 'tutor' ); ?>:</span> |
| 64 | <span class="tutor-fs-6 tutor-color-black"> |
| 65 | <?php echo esc_html( $total_questions ); ?> |
| 66 | </span> |
| 67 | </div> |
| 68 | <?php endif; ?> |
| 69 | |
| 70 | <?php |
| 71 | // Show time limit. |
| 72 | $time_limit = tutor_utils()->get_quiz_option( get_the_ID(), 'time_limit.time_value' ); |
| 73 | if ( $time_limit ) : |
| 74 | $time_type = tutor_utils()->get_quiz_option( get_the_ID(), 'time_limit.time_type' ); |
| 75 | $available_time_type = array( |
| 76 | 'seconds' => $time_limit > 1 ? __( 'Seconds', 'tutor' ) : __( 'Second', 'tutor' ), |
| 77 | 'minutes' => $time_limit > 1 ? __( 'Minutes', 'tutor' ) : __( 'Minute', 'tutor' ), |
| 78 | 'hours' => $time_limit > 1 ? __( 'Hours', 'tutor' ) : __( 'Hour', 'tutor' ), |
| 79 | 'days' => $time_limit > 1 ? __( 'Days', 'tutor' ) : __( 'Day', 'tutor' ), |
| 80 | 'weeks' => $time_limit > 1 ? __( 'Weeks', 'tutor' ) : __( 'Week', 'tutor' ), |
| 81 | ); |
| 82 | ?> |
| 83 | <div class="tutor-quiz-info"> |
| 84 | <span class="tutor-fs-6 tutor-color-muted"><?php esc_html_e( 'Quiz Time', 'tutor' ); ?>:</span> |
| 85 | <span class="tutor-fs-6 tutor-color-black"> |
| 86 | <?php |
| 87 | echo esc_html( |
| 88 | sprintf( |
| 89 | /* translators: %d: count, %s: time unit. */ |
| 90 | __( '%1$s %2$s', 'tutor' ), |
| 91 | $time_limit, |
| 92 | isset( $available_time_type[ $time_type ] ) ? $available_time_type[ $time_type ] : $time_type |
| 93 | ) |
| 94 | ); |
| 95 | ?> |
| 96 | </span> |
| 97 | </div> |
| 98 | <?php endif; ?> |
| 99 | |
| 100 | <!-- Show Total attempt count --> |
| 101 | <div class="tutor-quiz-info"> |
| 102 | <span class="tutor-fs-6 tutor-color-muted"> |
| 103 | <?php esc_html_e( 'Total Attempted', 'tutor' ); ?>: |
| 104 | </span> |
| 105 | <span class="tutor-fs-6 tutor-color-black"> |
| 106 | <?php echo esc_html( $attempted_count . '/' . ( 0 == $attempts_allowed ? '∞' : $attempts_allowed ) ); ?> |
| 107 | </span> |
| 108 | </div> |
| 109 | |
| 110 | <!-- Show Passing grade --> |
| 111 | <?php if ( $passing_grade ) : ?> |
| 112 | <div class="tutor-quiz-info"> |
| 113 | <span class="tutor-fs-6 tutor-color-muted"><?php esc_html_e( 'Passing Grade', 'tutor' ); ?></span> |
| 114 | <span class="tutor-fs-6 tutor-color-black">(<?php echo esc_html( $passing_grade . '%' ); ?>)</span> |
| 115 | </div> |
| 116 | <?php endif; ?> |
| 117 | </div> |
| 118 | |
| 119 | <?php |
| 120 | if ( 0 === $attempted_count || $can_retry_quiz ) : |
| 121 | do_action( 'tutor_quiz/start_form/before', $quiz_id ); |
| 122 | $skip_url = get_the_permalink( $next_id ? $next_id : $course_id ); |
| 123 | ?> |
| 124 | <div class="tutor-quiz-btn-group"> |
| 125 | <form id="tutor-start-quiz" method="post"> |
| 126 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 127 | |
| 128 | <input type="hidden" value="<?php echo esc_attr( $quiz_id ); ?>" name="quiz_id"/> |
| 129 | <input type="hidden" value="tutor_start_quiz" name="tutor_action"/> |
| 130 | |
| 131 | <button type="submit" class="tutor-btn tutor-btn-primary tutor-btn-md start-quiz-btn" name="start_quiz_btn" value="start_quiz"> |
| 132 | <?php esc_html_e( 'Start Quiz', 'tutor' ); ?> |
| 133 | </button> |
| 134 | </form> |
| 135 | |
| 136 | <button class="tutor-btn tutor-btn-ghost tutor-btn-md skip-quiz-btn tutor-ml-24" data-tutor-modal-target="tutor-quiz-skip-to-next"> |
| 137 | <?php esc_html_e( 'Skip Quiz', 'tutor' ); ?> |
| 138 | </button> |
| 139 | </div> |
| 140 | |
| 141 | <?php |
| 142 | tutor_load_template( |
| 143 | 'modal.confirm', |
| 144 | array( |
| 145 | 'id' => 'tutor-quiz-skip-to-next', |
| 146 | 'title' => __( 'Do You Want to Skip This Quiz?', 'tutor' ), |
| 147 | 'content' => __( 'Are you sure you want to skip this quiz? Please confirm your choice.', 'tutor' ), |
| 148 | 'yes' => array( |
| 149 | 'text' => __( 'Yes, Skip This', 'tutor' ), |
| 150 | 'attr' => array( 'onclick="window.location=\'' . $skip_url . '\';"' ), |
| 151 | ), |
| 152 | ) |
| 153 | ); |
| 154 | ?> |
| 155 | <?php endif; ?> |
| 156 | </div> |
| 157 | <?php endif; ?> |
| 158 | <?php do_action( 'tutor_quiz/single/after/top' ); ?> |
| 159 |