add_quiz.php
4 years ago
edit-lesson.php
4 years ago
edit_quiz.php
4 years ago
question_answer_edit_form.php
4 years ago
question_answer_form.php
4 years ago
question_form.php
4 years ago
review.php
4 years ago
question_form.php
216 lines
| 1 | <?php |
| 2 | global $wpdb; |
| 3 | $settings = maybe_unserialize( $question->question_settings ); |
| 4 | ?> |
| 5 | |
| 6 | <div class="quiz-questions-form"> |
| 7 | |
| 8 | |
| 9 | <div class="question-form-header"> |
| 10 | <a href="javascript:;" class="back-to-quiz-questions-btn open-tutor-quiz-modal" data-quiz-id="<?php echo esc_attr( $quiz_id ); ?>" data-back-to-tab="#quiz-builder-tab-questions"><i class="tutor-icon-next-2"></i> <?php _e( 'Back', 'tutor' ); ?></a> |
| 11 | </div> |
| 12 | |
| 13 | |
| 14 | <div class="quiz-question-form-body"> |
| 15 | |
| 16 | |
| 17 | <div class="quiz_question_form"> |
| 18 | |
| 19 | <div class="tutor-quiz-builder-group"> |
| 20 | <h4><?php _e( 'Write your question here', 'tutor' ); ?></h4> |
| 21 | <div class="tutor-quiz-builder-row"> |
| 22 | <div class="tutor-quiz-builder-col"> |
| 23 | <input type="text" name="tutor_quiz_question[<?php echo esc_attr( $question_id ); ?>][question_title]" placeholder="<?php esc_attr_e( 'Type your question here', 'tutor' ); ?>" value="<?php echo htmlspecialchars( stripslashes( $question->question_title ) ); ?>"> |
| 24 | </div> |
| 25 | </div> |
| 26 | </div> |
| 27 | |
| 28 | <div class="tutor-quiz-builder-group"> |
| 29 | <h4><?php _e( 'Question Type', 'tutor' ); ?></h4> |
| 30 | <div class="tutor-quiz-builder-row"> |
| 31 | <div class="tutor-quiz-builder-col"> |
| 32 | <div class="tutor-select"> |
| 33 | <div class="select-header"> |
| 34 | <span class="lead-option"> <i class="tutor-icon-yes-no"></i> <?php _e( 'True or False', 'tutor' ); ?> </span> |
| 35 | <span class="select-dropdown"><i class="tutor-icon-light-down"></i> </span> |
| 36 | <input type="hidden" class="tutor_select_value_holder" name="tutor_quiz_question[<?php echo esc_attr( $question_id ); ?>][question_type]" value="" > |
| 37 | </div> |
| 38 | |
| 39 | <?php $question_types = tutor_utils()->get_question_types(); ?> |
| 40 | |
| 41 | <div class="tutor-select-options" style="display: none;"> |
| 42 | <?php |
| 43 | $has_tutor_pro = tutor()->has_pro; |
| 44 | |
| 45 | foreach ( $question_types as $type => $question_type ) { |
| 46 | ?> |
| 47 | <p class="tutor-select-option" data-value="<?php echo esc_attr( $type ); ?>" <?php echo $question->question_type === $type ? ' data-selected="selected"' : ''; ?> data-is-pro="<?php echo esc_attr( ( ! $has_tutor_pro && $question_type['is_pro'] ) ? 'true' : 'false' ); ?>" > |
| 48 | <?php echo $question_type['icon'] . ' ' . $question_type['name']; |
| 49 | |
| 50 | if ( ! $has_tutor_pro && $question_type['is_pro'] ) { |
| 51 | $svg_lock = '<svg width="12" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M11.667 6h-1V4.667A4.672 4.672 0 0 0 6 0a4.672 4.672 0 0 0-4.667 4.667V6h-1A.333.333 0 0 0 0 6.333v8.334C0 15.402.598 16 1.333 16h9.334c.735 0 1.333-.598 1.333-1.333V6.333A.333.333 0 0 0 11.667 6zm-4.669 6.963a.334.334 0 0 1-.331.37H5.333a.333.333 0 0 1-.331-.37l.21-1.89A1.319 1.319 0 0 1 4.667 10c0-.735.598-1.333 1.333-1.333S7.333 9.265 7.333 10c0 .431-.204.824-.545 1.072l.21 1.891zM8.667 6H3.333V4.667A2.67 2.67 0 0 1 6 2a2.67 2.67 0 0 1 2.667 2.667V6z" fill="#E2E2E2" fill-rule="nonzero"/></svg>'; |
| 52 | printf( "<span class='question-type-pro' title='%s'>%s</span>", __( 'Pro version required', 'tutor' ), $svg_lock ); |
| 53 | } |
| 54 | ?> |
| 55 | </p> |
| 56 | <?php |
| 57 | } |
| 58 | ?> |
| 59 | |
| 60 | </div> |
| 61 | </div> |
| 62 | </div> |
| 63 | </div> |
| 64 | </div> |
| 65 | |
| 66 | <div class="tutor-quiz-builder-group"> |
| 67 | <div class="tutor-quiz-builder-row"> |
| 68 | <div class="tutor-quiz-builder-col auto-width"> |
| 69 | <label class="btn-switch"> |
| 70 | <input type="checkbox" value="1" name="tutor_quiz_question[<?php echo esc_attr( $question_id ); ?>][answer_required]" <?php checked( '1', tutor_utils()->avalue_dot( 'answer_required', $settings ) ); ?> /> |
| 71 | <div class="btn-slider btn-round"></div> |
| 72 | </label> |
| 73 | <span><?php _e( 'Answer Required', 'tutor' ); ?></span> |
| 74 | </div> |
| 75 | <div class="tutor-quiz-builder-col auto-width"> |
| 76 | <label class="btn-switch"> |
| 77 | <input type="checkbox" value="1" name="tutor_quiz_question[<?php echo esc_attr( $question_id ); ?>][randomize_question]" <?php checked( '1', tutor_utils()->avalue_dot( 'randomize_question', $settings ) ); ?> /> |
| 78 | <div class="btn-slider btn-round"></div> |
| 79 | </label> |
| 80 | <span><?php _e( 'Randomize', 'tutor' ); ?></span> |
| 81 | </div> |
| 82 | </div> |
| 83 | </div> |
| 84 | |
| 85 | <div class="tutor-quiz-builder-group"> |
| 86 | <h4><?php _e( 'Point(s) for this answer', 'tutor' ); ?></h4> |
| 87 | <div class="tutor-quiz-builder-row"> |
| 88 | <div class="tutor-quiz-builder-col"> |
| 89 | <input type="text" name="tutor_quiz_question[<?php echo esc_attr( $question_id ); ?>][question_mark]" placeholder="<?php esc_attr_e( 'set the mark ex. 10', 'tutor' ); ?>" value="<?php echo esc_attr( $question->question_mark ); ?>"> |
| 90 | </div> |
| 91 | </div> |
| 92 | </div> |
| 93 | |
| 94 | <div class="tutor-quiz-builder-group"> |
| 95 | <div class="tutor-quiz-builder-row"> |
| 96 | <div class="tutor-quiz-builder-col auto-width"> |
| 97 | <label class="btn-switch"> |
| 98 | <input type="checkbox" value="1" name="tutor_quiz_question[<?php echo esc_attr( $question_id ); ?>][show_question_mark]" <?php checked( '1', tutor_utils()->avalue_dot( 'show_question_mark', $settings ) ); ?> /> |
| 99 | <div class="btn-slider btn-round"></div> |
| 100 | </label> |
| 101 | <span><?php _e( 'Display Points', 'tutor' ); ?></span> |
| 102 | </div> |
| 103 | </div> |
| 104 | </div> |
| 105 | |
| 106 | <div class="tutor-quiz-builder-group"> |
| 107 | <h4><?php _e( 'Description', 'tutor' ); ?> <span>(<?php _e( 'Optional', 'tutor' ); ?>)</span></h4> |
| 108 | <div class="tutor-quiz-builder-row"> |
| 109 | <div class="tutor-quiz-builder-col"> |
| 110 | <textarea name="tutor_quiz_question[<?php echo esc_attr( $question_id ); ?>][question_description]"><?php echo esc_textarea( stripslashes( $question->question_description ) ); ?></textarea> |
| 111 | </div> |
| 112 | </div> |
| 113 | </div> |
| 114 | |
| 115 | <div class="tutor-quiz-builder-group"> |
| 116 | <h4> |
| 117 | <?php |
| 118 | switch ( $question->question_type ) { |
| 119 | case 'true_false': |
| 120 | echo __( 'Input options for the question and select the correct answer.', 'tutor' ); |
| 121 | break; |
| 122 | case 'ordering': |
| 123 | echo __( 'Make sure you’re saving the answers in the right order. Students will have to match this order.', 'tutor' ); |
| 124 | break; |
| 125 | } |
| 126 | ?> |
| 127 | </h4> |
| 128 | <div class="tutor-quiz-builder-row"> |
| 129 | <div class="tutor-quiz-builder-col"> |
| 130 | <div id="tuotr_question_options_for_quiz" class="quiz-modal-field-wrap"> |
| 131 | <div id="tutor_quiz_question_answers" data-question-id="<?php echo $question_id; ?>"><?php |
| 132 | $answers = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}tutor_quiz_question_answers where belongs_question_id = %d AND belongs_question_type = %s order by answer_order asc ;", $question_id, $question->question_type ) ); |
| 133 | if ( is_array( $answers ) && count( $answers ) ) { |
| 134 | foreach ( $answers as $answer ) { |
| 135 | ?> |
| 136 | <div class="tutor-quiz-answer-wrap" data-answer-id="<?php echo esc_attr( $answer->answer_id ); ?>"> |
| 137 | <div class="tutor-quiz-answer"> |
| 138 | <span class="tutor-quiz-answer-title"> |
| 139 | <?php |
| 140 | echo esc_attr( stripslashes( $answer->answer_title ) ); |
| 141 | if ( $answer->belongs_question_type === 'fill_in_the_blank' ) { |
| 142 | echo ' (' . __( 'Answer', 'tutor' ) . ' : <strong>' . esc_attr( stripslashes( $answer->answer_two_gap_match ) ) . '</strong>)'; |
| 143 | } |
| 144 | if ( $answer->belongs_question_type === 'matching' ) { |
| 145 | echo esc_attr( ' - ' . stripslashes( $answer->answer_two_gap_match ) ); |
| 146 | } |
| 147 | ?> |
| 148 | </span> |
| 149 | <?php |
| 150 | if ( $answer->image_id ) { |
| 151 | echo '<span class="tutor-question-answer-image"> |
| 152 | <img src="' . esc_url( wp_get_attachment_image_url( $answer->image_id ) ) . '"/> |
| 153 | </span>'; |
| 154 | } |
| 155 | if ( $question->question_type === 'true_false' || $question->question_type === 'single_choice' ) { |
| 156 | ?> |
| 157 | <span class="tutor-quiz-answers-mark-correct-wrap"> |
| 158 | <input type="radio" name="mark_as_correct[<?php echo esc_attr( $answer->belongs_question_id ); ?>]" value="<?php echo esc_attr( $answer->answer_id ); ?>" title="<?php esc_attr_e( 'Mark as correct', 'tutor' ); ?>" <?php checked( 1, $answer->is_correct ); ?> > |
| 159 | </span> |
| 160 | <?php |
| 161 | } elseif ( $question->question_type === 'multiple_choice' ) { |
| 162 | ?> |
| 163 | <span class="tutor-quiz-answers-mark-correct-wrap"> |
| 164 | <input type="checkbox" name="mark_as_correct[<?php echo esc_attr( $answer->belongs_question_id ); ?>]" value="<?php echo esc_attr( $answer->answer_id ); ?>" title="<?php esc_attr_e( 'Mark as correct', 'tutor' ); ?>" <?php checked( 1, $answer->is_correct ); ?> > |
| 165 | </span> |
| 166 | <?php |
| 167 | } |
| 168 | ?> |
| 169 | <span class="tutor-quiz-answer-edit"> |
| 170 | <?php if ( $question->question_type !== 'true_false' ) { ?> |
| 171 | <a href="javascript:;"><i class="tutor-icon-pencil"></i> </a> |
| 172 | <?php } ?> |
| 173 | </span> |
| 174 | <span class="tutor-quiz-answer-sort-icon"><i class="tutor-icon-menu-2"></i> </span> |
| 175 | </div> |
| 176 | <?php if ( $question->question_type !== 'true_false' ) { ?> |
| 177 | <div class="tutor-quiz-answer-trash-wrap"> |
| 178 | <a href="javascript:;" class="answer-trash-btn" data-answer-id="<?php echo esc_attr( $answer->answer_id ); ?>"><i class="tutor-icon-garbage"></i> </a> |
| 179 | </div> |
| 180 | <?php } ?> |
| 181 | </div> |
| 182 | <?php |
| 183 | } |
| 184 | } |
| 185 | ?></div> |
| 186 | |
| 187 | <div id="tutor_quiz_question_answer_form"></div> |
| 188 | |
| 189 | <a href="javascript:;" class="add_question_answers_option" data-question-id="<?php echo $question_id; ?>"> |
| 190 | <i class="tutor-icon-block tutor-icon-plus"></i> |
| 191 | <?php _e( 'Add An Option', 'tutor' ); ?> |
| 192 | </a> |
| 193 | </div> |
| 194 | |
| 195 | <div id="quiz_validation_msg_wrap"></div> |
| 196 | |
| 197 | </div> |
| 198 | </div> |
| 199 | </div> |
| 200 | |
| 201 | </div> |
| 202 | |
| 203 | </div> |
| 204 | |
| 205 | </div> |
| 206 | |
| 207 | |
| 208 | <div class="tutor-quiz-builder-modal-control-btn-group question_form_inner"> |
| 209 | <div class="quiz-builder-btn-group-left"> |
| 210 | <a href="javascript:;" class="quiz-modal-tab-navigation-btn quiz-modal-question-save-btn"><?php _e( 'Save & Continue', 'tutor' ); ?></a> |
| 211 | </div> |
| 212 | <div class="quiz-builder-btn-group-right"> |
| 213 | <a href="javascript:;" class="quiz-modal-tab-navigation-btn quiz-modal-btn-cancel"><?php _e( 'Cancel', 'tutor' ); ?></a> |
| 214 | </div> |
| 215 | </div> |
| 216 |