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