add_quiz.php
7 years ago
edit-lesson.php
7 years ago
edit_quiz.php
7 years ago
question_answer_edit_form.php
7 years ago
question_answer_form.php
7 years ago
question_form.php
7 years ago
edit_quiz.php
383 lines
| 1 | <?php |
| 2 | $quiz = null; |
| 3 | if ( ! empty($_POST['tutor_quiz_builder_quiz_id'])){ |
| 4 | $quiz_id = sanitize_text_field($_POST['tutor_quiz_builder_quiz_id']); |
| 5 | $quiz = get_post($quiz_id); |
| 6 | |
| 7 | echo '<input type="hidden" id="tutor_quiz_builder_quiz_id" value="'.$quiz_id.'" />'; |
| 8 | }elseif( ! empty($quiz_id)){ |
| 9 | $quiz = get_post($quiz_id); |
| 10 | |
| 11 | echo '<input type="hidden" id="tutor_quiz_builder_quiz_id" value="'.$quiz_id.'" />'; |
| 12 | } |
| 13 | |
| 14 | if ( ! $quiz){ |
| 15 | die('No quiz found'); |
| 16 | } |
| 17 | |
| 18 | ?> |
| 19 | |
| 20 | <div class="tutor-quiz-builder-modal-contents"> |
| 21 | |
| 22 | <div id="tutor-quiz-modal-tab-items-wrap" class="tutor-quiz-modal-tab-items-wrap"> |
| 23 | |
| 24 | <a href="#quiz-builder-tab-quiz-info" class="tutor-quiz-modal-tab-item active"> |
| 25 | <i class="tutor-icon-list"></i> <?php _e('Quiz Info', 'tutor'); ?> |
| 26 | </a> |
| 27 | <a href="#quiz-builder-tab-questions" class="tutor-quiz-modal-tab-item"> |
| 28 | <i class="tutor-icon-doubt"></i> <?php _e('Questions', 'tutor'); ?> |
| 29 | </a> |
| 30 | <a href="#quiz-builder-tab-settings" class="tutor-quiz-modal-tab-item"> |
| 31 | <i class="tutor-icon-settings-1"></i> <?php _e('Settings', 'tutor'); ?> |
| 32 | </a> |
| 33 | <a href="#quiz-builder-tab-advanced-options" class="tutor-quiz-modal-tab-item"> |
| 34 | <i class="tutor-icon-filter-tool-black-shape"></i> <?php _e('Advanced Options', 'tutor'); ?> |
| 35 | </a> |
| 36 | |
| 37 | </div> |
| 38 | |
| 39 | |
| 40 | |
| 41 | <div id="tutor-quiz-builder-modal-tabs-container" class="tutor-quiz-builder-modal-tabs-container"> |
| 42 | |
| 43 | <div id="quiz-builder-tab-quiz-info" class="quiz-builder-tab-container"> |
| 44 | |
| 45 | <div class="quiz-builder-tab-body"> |
| 46 | <div class="tutor-quiz-builder-form-row"> |
| 47 | <input type="text" name="quiz_title" placeholder="<?php _e('Type your quiz title here', 'tutor'); ?>" value="<?php echo |
| 48 | $quiz->post_title; ?>"> |
| 49 | |
| 50 | <div class="quiz_form_msg"></div> |
| 51 | </div> |
| 52 | |
| 53 | <div class="tutor-quiz-builder-form-row"> |
| 54 | <textarea name="quiz_description" rows="5"><?php echo $quiz->post_content; ?></textarea> |
| 55 | </div> |
| 56 | </div> |
| 57 | |
| 58 | |
| 59 | <div class="tutor-quiz-builder-modal-control-btn-group"> |
| 60 | <div class="quiz-builder-btn-group-left"> |
| 61 | <a href="#quiz-builder-tab-questions" class="quiz-modal-tab-navigation-btn quiz-modal-btn-first-step"><?php _e('Save & Next', 'tutor'); ?></a> |
| 62 | </div> |
| 63 | <div class="quiz-builder-btn-group-right"> |
| 64 | <a href="#quiz-builder-tab-questions" class="quiz-modal-tab-navigation-btn quiz-modal-btn-cancel"><?php _e('Cancel', 'tutor'); |
| 65 | ?></a> |
| 66 | </div> |
| 67 | </div> |
| 68 | |
| 69 | |
| 70 | </div> |
| 71 | |
| 72 | <div id="quiz-builder-tab-questions" class="quiz-builder-tab-container" style="display: none;"> |
| 73 | <div class="quiz-builder-tab-body"> |
| 74 | <div class="quiz-builder-questions-wrap"> |
| 75 | |
| 76 | <?php |
| 77 | $questions = tutor_utils()->get_questions_by_quiz($quiz_id); |
| 78 | if ($questions){ |
| 79 | foreach ($questions as $question){ |
| 80 | ?> |
| 81 | <div class="quiz-builder-question-wrap"> |
| 82 | <div class="quiz-builder-question"> |
| 83 | <span class="question-sorting"> |
| 84 | <i class="tutor-icon-move"></i> |
| 85 | </span> |
| 86 | |
| 87 | <span class="question-title"><?php echo $question->question_title; ?></span> |
| 88 | |
| 89 | <span class="question-icon"> |
| 90 | <?php |
| 91 | $type = tutor_utils()->get_question_types($question->question_type); |
| 92 | echo $type['icon'].' '.$type['name']; |
| 93 | ?> |
| 94 | </span> |
| 95 | |
| 96 | <span class="question-edit-icon"> |
| 97 | <a href="javascript:;" class="tutor-quiz-open-question-form" data-question-id="<?php echo $question->question_id; ?>"><i class="tutor-icon-pencil"></i> </a> |
| 98 | </span> |
| 99 | </div> |
| 100 | |
| 101 | <div class="quiz-builder-qustion-trash"> |
| 102 | <a href="javascript:;" class="tutor-quiz-question-trash" data-question-id="<?php echo $question->question_id; ?>"><i class="tutor-icon-garbage"></i> </a> |
| 103 | </div> |
| 104 | </div> |
| 105 | <?php |
| 106 | } |
| 107 | } |
| 108 | ?> |
| 109 | </div> |
| 110 | |
| 111 | <div class="tutor-quiz-builder-form-row"> |
| 112 | <a href="javascript:;" class="tutor-quiz-add-question-btn tutor-quiz-open-question-form"> |
| 113 | <i class="tutor-icon-add-line"></i> |
| 114 | <?php _e('Add Question', 'tutor'); ?> |
| 115 | </a> |
| 116 | </div> |
| 117 | |
| 118 | |
| 119 | |
| 120 | </div> |
| 121 | |
| 122 | <div class="tutor-quiz-builder-modal-control-btn-group"> |
| 123 | <div class="quiz-builder-btn-group-left"> |
| 124 | <a href="#quiz-builder-tab-quiz-info" class="quiz-modal-tab-navigation-btn quiz-modal-btn-back"><?php _e('Back', 'tutor'); ?></a> |
| 125 | <a href="#quiz-builder-tab-settings" class="quiz-modal-tab-navigation-btn quiz-modal-btn-next"><?php _e('Next', 'tutor'); ?></a> |
| 126 | </div> |
| 127 | <div class="quiz-builder-btn-group-right"> |
| 128 | <a href="#quiz-builder-tab-questions" class="quiz-modal-tab-navigation-btn quiz-modal-btn-cancel"><?php _e('Cancel', 'tutor'); ?></a> |
| 129 | </div> |
| 130 | </div> |
| 131 | |
| 132 | </div> |
| 133 | |
| 134 | <div id="quiz-builder-tab-settings" class="quiz-builder-tab-container" style="display: none;"> |
| 135 | <div class="quiz-builder-tab-body"> |
| 136 | |
| 137 | <div class="quiz-builder-modal-settins"> |
| 138 | |
| 139 | <div class="tutor-quiz-builder-form-row"> |
| 140 | <div class="tutor-quiz-builder-form-cols-row"> |
| 141 | <div class="quiz-form-field-col"> |
| 142 | <label><?php _e('Time Limit', 'tutor'); ?></label> |
| 143 | <input type="text" name="quiz_option[time_limit][time_value]" value="<?php echo tutor_utils()->get_quiz_option($quiz_id, 'time_limit.time_value', 0) ?>"> |
| 144 | </div> |
| 145 | |
| 146 | <div class="quiz-form-field-col"> |
| 147 | <label> </label> |
| 148 | |
| 149 | <?php $limit_time_type = tutor_utils()->get_quiz_option($quiz_id, 'time_limit.time_type', 'minutes') ?> |
| 150 | |
| 151 | <select name="quiz_option[time_limit][time_type]"> |
| 152 | <option value="seconds" <?php selected('seconds', $limit_time_type); ?> ><?php _e('Seconds', 'tutor'); ?></option> |
| 153 | <option value="minutes" <?php selected('minutes', $limit_time_type); ?> ><?php _e('Minutes', 'tutor'); ?></option> |
| 154 | <option value="hours" <?php selected('hours', $limit_time_type); ?> ><?php _e('Hours', 'tutor'); ?></option> |
| 155 | <option value="days" <?php selected('days', $limit_time_type); ?> ><?php _e('Days', 'tutor'); ?></option> |
| 156 | <option value="weeks" <?php selected('weeks', $limit_time_type); ?> ><?php _e('Weeks', 'tutor'); ?></option> |
| 157 | </select> |
| 158 | </div> |
| 159 | |
| 160 | <div class="quiz-form-field-col"> |
| 161 | <label> </label> |
| 162 | |
| 163 | <div class="quiz-form-field-col"> |
| 164 | <label class="btn-switch"> |
| 165 | <input type="checkbox" value="1" name="quiz_option[hide_quiz_time_display]" <?php checked('1', tutor_utils()->get_quiz_option($quiz_id, 'hide_quiz_time_display')); ?> /> |
| 166 | <div class="btn-slider btn-round"></div> |
| 167 | </label> |
| 168 | <label><?php _e('Hide quiz time - display', 'tutor'); ?></label> |
| 169 | </div> |
| 170 | </div> |
| 171 | </div> |
| 172 | |
| 173 | <p class="quiz-modal-form-help"><?php _e('Time limit for this quiz. 0 means no time limit.', 'tutor'); ?></p> |
| 174 | </div> |
| 175 | |
| 176 | |
| 177 | <div class="tutor-quiz-builder-form-row"> |
| 178 | <label><?php _e('Attempts Allowed', 'tutor'); ?> <span>(<?php _e('Optional', 'tutor'); ?>)</span> </label> |
| 179 | <div class="quiz-modal-field-wrap"> |
| 180 | |
| 181 | <?php |
| 182 | $default_attempts_allowed = tutor_utils()->get_option('quiz_attempts_allowed'); |
| 183 | $attempts_allowed = tutor_utils()->get_quiz_option($quiz_id, 'attempts_allowed', $default_attempts_allowed); |
| 184 | ?> |
| 185 | |
| 186 | <div class="tutor-field-type-slider" data-min="0" data-max="20"> |
| 187 | <p class="tutor-field-type-slider-value"><?php echo $attempts_allowed; ?></p> |
| 188 | <div class="tutor-field-slider"></div> |
| 189 | <input type="hidden" value="<?php echo $attempts_allowed; ?>" name="quiz_option[attempts_allowed]" /> |
| 190 | </div> |
| 191 | |
| 192 | <p class="quiz-modal-form-help"><?php _e('Restriction on the number of attempts a student is allowed to take for this quiz. 0 for no limit', 'tutor'); ?></p> |
| 193 | </div> |
| 194 | </div> |
| 195 | |
| 196 | <div class="tutor-quiz-builder-form-row"> |
| 197 | <label><?php _e('Passing Grade', 'tutor'); ?> </label> |
| 198 | <div class="tutor-quiz-builder-form-cols-row"> |
| 199 | <div class="quiz-form-field-col"> |
| 200 | <input type="number" name="quiz_option[passing_grade]" value="<?php echo tutor_utils()->get_quiz_option($quiz_id, 'passing_grade', 80) ?>" size="10"> |
| 201 | </div> |
| 202 | |
| 203 | <div class="quiz-form-field-col"> |
| 204 | % |
| 205 | </div> |
| 206 | </div> |
| 207 | <p class="quiz-modal-form-help"><?php _e('Set the passing percentage for this quiz', 'tutor'); ?></p> |
| 208 | </div> |
| 209 | |
| 210 | <div class="tutor-quiz-builder-form-row"> |
| 211 | <label for=""><?php _e('Max questions allowed to answer', 'tutor'); ?></label> |
| 212 | <div class="quiz-modal-field-wrap"> |
| 213 | <input type="number" name="quiz_option[max_questions_for_answer]" value="<?php echo tutor_utils()->get_quiz_option($quiz_id, 'max_questions_for_answer', 10) ?>"> |
| 214 | </div> |
| 215 | <p class="quiz-modal-form-help"><?php _e('This amount of question will be available for students to answer, and question will comes randomly from all available questions belongs with a quiz, if this amount greater then available question, then all questions will be available for a student to answer.', 'tutor'); ?></p> |
| 216 | </div> |
| 217 | |
| 218 | </div> |
| 219 | |
| 220 | |
| 221 | |
| 222 | </div> |
| 223 | |
| 224 | <div class="tutor-quiz-builder-modal-control-btn-group"> |
| 225 | <div class="quiz-builder-btn-group-left"> |
| 226 | <a href="#quiz-builder-tab-questions" class="quiz-modal-tab-navigation-btn quiz-modal-btn-back"><?php _e('Back', 'tutor'); ?></a> |
| 227 | <a href="#quiz-builder-tab-advanced-options" class="quiz-modal-tab-navigation-btn quiz-modal-settings-save-btn"><?php _e('Save & Update', 'tutor'); ?></a> |
| 228 | </div> |
| 229 | <div class="quiz-builder-btn-group-right"> |
| 230 | <a href="#quiz-builder-tab-questions" class="quiz-modal-tab-navigation-btn quiz-modal-btn-cancel"><?php _e('Cancel', 'tutor'); ?></a> |
| 231 | </div> |
| 232 | </div> |
| 233 | </div> |
| 234 | |
| 235 | <div id="quiz-builder-tab-advanced-options" class="quiz-builder-tab-container" style="display: none;"> |
| 236 | |
| 237 | <div class="tutor-quiz-builder-form-row"> |
| 238 | <div class="tutor-quiz-builder-form-cols-row"> |
| 239 | <div class="quiz-form-field-col"> |
| 240 | <label><?php _e('Quiz Auto Start', 'tutor'); ?></label> |
| 241 | </div> |
| 242 | |
| 243 | <div class="quiz-form-field-col"> |
| 244 | <label class="btn-switch"> |
| 245 | <input type="checkbox" value="1" name="quiz_option[quiz_auto_start]" <?php checked('1', tutor_utils()->get_quiz_option($quiz_id, 'quiz_auto_start')); ?> /> |
| 246 | <div class="btn-slider btn-round"></div> |
| 247 | </label> |
| 248 | <p class="quiz-modal-form-help"><?php _e('If you enable this option, the quiz will start automatically after the page is loaded.', 'tutor'); ?></p> |
| 249 | </div> |
| 250 | </div> |
| 251 | </div> |
| 252 | |
| 253 | <div class="tutor-quiz-builder-form-row"> |
| 254 | <div class="tutor-quiz-builder-form-cols-row"> |
| 255 | <div class="quiz-form-field-col"> |
| 256 | <label><?php _e('Question Layout', 'tutor'); ?></label> |
| 257 | </div> |
| 258 | |
| 259 | <div class="quiz-form-field-col"> |
| 260 | |
| 261 | <select name="quiz_option[question_layout_view]"> |
| 262 | <option value=""><?php _e('Set question layout view', 'tutor'); ?></option> |
| 263 | <option value="single_question" <?php selected('single_question', tutor_utils()->get_quiz_option($quiz_id, 'question_layout_view')); ?>> <?php _e('Single Question', 'tutor'); ?> </option> |
| 264 | <option value="question_pagination" <?php selected('question_pagination', tutor_utils()->get_quiz_option($quiz_id, 'question_layout_view') ); ?>> <?php _e('Question Pagination', 'tutor'); ?> </option> |
| 265 | <option value="question_below_each_other" <?php selected('question_below_each_other', tutor_utils()->get_quiz_option($quiz_id, 'question_layout_view') ); ?>> <?php _e('Question below each other', 'tutor'); ?> </option> |
| 266 | </select> |
| 267 | |
| 268 | </div> |
| 269 | </div> |
| 270 | </div> |
| 271 | |
| 272 | <!-- <div class="tutor-quiz-builder-form-row"> |
| 273 | <div class="tutor-quiz-builder-form-cols-row"> |
| 274 | <div class="quiz-form-field-col"> |
| 275 | <label><?php /*_e('Show correct questions - display', 'tutor'); */?></label> |
| 276 | </div> |
| 277 | |
| 278 | <div class="quiz-form-field-col"> |
| 279 | <label class="btn-switch"> |
| 280 | <input type="checkbox" value="1" name="quiz_option[show_correct_questions]" <?php /*checked('1', tutor_utils()->get_quiz_option($quiz_id, 'show_correct_questions')); */?> /> |
| 281 | <div class="btn-slider btn-round"></div> |
| 282 | </label> |
| 283 | <p class="quiz-modal-form-help"><?php /*_e('If this option is activated, all answers are displayed below each other, i.e. all questions are on a single page.', 'tutor'); */?></p> |
| 284 | </div> |
| 285 | </div> |
| 286 | </div>--> |
| 287 | |
| 288 | <div class="tutor-quiz-builder-form-row"> |
| 289 | <div class="tutor-quiz-builder-form-cols-row"> |
| 290 | <div class="quiz-form-field-col"> |
| 291 | <label><?php _e('Hide question number', 'tutor'); ?></label> |
| 292 | </div> |
| 293 | |
| 294 | <div class="quiz-form-field-col"> |
| 295 | <label class="btn-switch"> |
| 296 | <input type="checkbox" value="1" name="quiz_option[hide_question_number_overview]" <?php checked('1', tutor_utils()->get_quiz_option($quiz_id, 'hide_question_number_overview')); ?> /> |
| 297 | <div class="btn-slider btn-round"></div> |
| 298 | </label> |
| 299 | <p class="quiz-modal-form-help"><?php _e('Show/hide question number during attempt.', 'tutor'); ?></p> |
| 300 | </div> |
| 301 | </div> |
| 302 | </div> |
| 303 | |
| 304 | |
| 305 | <div class="tutor-quiz-builder-form-row"> |
| 306 | <div class="tutor-quiz-builder-form-cols-row"> |
| 307 | <div class="quiz-form-field-col"> |
| 308 | <label><?php _e('Short answer characters limit', 'tutor'); ?></label> |
| 309 | </div> |
| 310 | |
| 311 | <div class="quiz-form-field-col"> |
| 312 | <input type="number" name="quiz_option[short_answer_characters_limit]" value="<?php echo tutor_utils()->get_quiz_option |
| 313 | ($quiz_id, 'short_answer_characters_limit', 200); ?>" > |
| 314 | <p class="quiz-modal-form-help"><?php _e('Student will place answer in short answer question type within this characters limit.', 'tutor'); |
| 315 | ?></p> |
| 316 | </div> |
| 317 | </div> |
| 318 | </div> |
| 319 | |
| 320 | <!--<div class="tutor-quiz-builder-form-row"> |
| 321 | <div class="tutor-quiz-builder-form-cols-row"> |
| 322 | <div class="quiz-form-field-col"> |
| 323 | <label><?php /*_e('Question overview', 'tutor'); */?></label> |
| 324 | </div> |
| 325 | |
| 326 | <div class="quiz-form-field-col"> |
| 327 | <label class="btn-switch"> |
| 328 | <input type="checkbox" value="1" name="quiz_option[question_overview]" <?php /*checked('1', tutor_utils()->get_quiz_option($quiz_id, 'question_overview')); */?> /> |
| 329 | <div class="btn-slider btn-round"></div> |
| 330 | </label> |
| 331 | </div> |
| 332 | </div> |
| 333 | </div> |
| 334 | |
| 335 | <div class="tutor-quiz-builder-form-row"> |
| 336 | <div class="tutor-quiz-builder-form-cols-row"> |
| 337 | <div class="quiz-form-field-col"> |
| 338 | <label><?php _e('Hide "Skip Question"', 'tutor'); ?></label> |
| 339 | </div> |
| 340 | |
| 341 | <div class="quiz-form-field-col"> |
| 342 | <label class="btn-switch"> |
| 343 | <input type="checkbox" value="1" name="quiz_option[hide_skip_question]" <?php checked('1', tutor_utils()->get_quiz_option($quiz_id, 'hide_skip_question')); ?> /> |
| 344 | <div class="btn-slider btn-round"></div> |
| 345 | </label> |
| 346 | </div> |
| 347 | </div> |
| 348 | </div> |
| 349 | |
| 350 | <div class="tutor-quiz-builder-form-row"> |
| 351 | <div class="tutor-quiz-builder-form-cols-row"> |
| 352 | <div class="quiz-form-field-col"> |
| 353 | <label><?php _e('Hide "Retry Quiz"', 'tutor'); ?></label> |
| 354 | </div> |
| 355 | |
| 356 | <div class="quiz-form-field-col"> |
| 357 | <label class="btn-switch"> |
| 358 | <input type="checkbox" value="1" name="quiz_option[hide_retry_quiz]" <?php checked('1', tutor_utils()->get_quiz_option($quiz_id, 'hide_retry_quiz')); ?> /> |
| 359 | <div class="btn-slider btn-round"></div> |
| 360 | </label> |
| 361 | </div> |
| 362 | </div> |
| 363 | </div>--> |
| 364 | |
| 365 | |
| 366 | <div class="tutor-quiz-builder-modal-control-btn-group"> |
| 367 | <div class="quiz-builder-btn-group-left"> |
| 368 | <a href="#quiz-builder-tab-settings" class="quiz-modal-tab-navigation-btn quiz-modal-btn-back"><?php _e('Back', 'tutor'); ?></a> |
| 369 | <a href="#quiz-builder-tab-advanced-options" class="quiz-modal-tab-navigation-btn quiz-modal-settings-save-btn"><?php _e('Save & Update', 'tutor'); ?></a> |
| 370 | </div> |
| 371 | <div class="quiz-builder-btn-group-right"> |
| 372 | <a href="#quiz-builder-tab-questions" class="quiz-modal-tab-navigation-btn quiz-modal-btn-cancel"><?php _e('Cancel', 'tutor'); ?></a> |
| 373 | </div> |
| 374 | </div> |
| 375 | |
| 376 | |
| 377 | </div> |
| 378 | |
| 379 | |
| 380 | |
| 381 | </div> |
| 382 | |
| 383 | </div> |