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