See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 39 and 401]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace qtype_calculatedsimple; 18 19 use question_hint; 20 use question_state; 21 22 defined('MOODLE_INTERNAL') || die(); 23 24 global $CFG; 25 require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); 26 27 28 /** 29 * Unit tests for the simple calculated question type. 30 * 31 * @package qtype_calculatedsimple 32 * @copyright 2011 The Open University 33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 34 */ 35 class walkthrough_test extends \qbehaviour_walkthrough_test_base { 36 public function test_interactive() { 37 38 // Create a gapselect question. 39 $q = \test_question_maker::make_question('calculatedsimple'); 40 $q->hints = array( 41 new question_hint(1, 'This is the first hint.', FORMAT_HTML), 42 new question_hint(2, 'This is the second hint.', FORMAT_HTML), 43 ); 44 $this->start_attempt_at_question($q, 'interactive', 3); 45 $values = $q->vs->get_values(); 46 47 // Check the initial state. 48 $this->check_current_state(question_state::$todo); 49 $this->check_current_mark(null); 50 $this->check_current_output( 51 $this->get_contains_marked_out_of_summary(), 52 $this->get_contains_submit_button_expectation(true), 53 $this->get_does_not_contain_feedback_expectation(), 54 $this->get_does_not_contain_validation_error_expectation(), 55 $this->get_does_not_contain_try_again_button_expectation(), 56 $this->get_no_hint_visible_expectation()); 57 58 // Submit blank. 59 $this->process_submission(array('-submit' => 1, 'answer' => '')); 60 61 // Verify. 62 $this->check_current_state(question_state::$invalid); 63 $this->check_current_mark(null); 64 $this->check_current_output( 65 $this->get_contains_marked_out_of_summary(), 66 $this->get_contains_submit_button_expectation(true), 67 $this->get_does_not_contain_feedback_expectation(), 68 $this->get_contains_validation_error_expectation(), 69 $this->get_does_not_contain_try_again_button_expectation(), 70 $this->get_no_hint_visible_expectation()); 71 72 // Sumit something that does not look like a number. 73 $this->process_submission(array('-submit' => 1, 'answer' => 'newt')); 74 75 // Verify. 76 $this->check_current_state(question_state::$invalid); 77 $this->check_current_mark(null); 78 $this->check_current_output( 79 $this->get_contains_marked_out_of_summary(), 80 $this->get_contains_submit_button_expectation(true), 81 $this->get_does_not_contain_feedback_expectation(), 82 $this->get_contains_validation_error_expectation(), 83 new \question_pattern_expectation('/' . 84 preg_quote(get_string('invalidnumber', 'qtype_numerical'), '/') . '/'), 85 $this->get_does_not_contain_try_again_button_expectation(), 86 $this->get_no_hint_visible_expectation()); 87 88 // Now get it right. 89 $this->process_submission(array('-submit' => 1, 'answer' => $values['a'] + $values['b'])); 90 91 // Verify. 92 $this->check_current_state(question_state::$gradedright); 93 $this->check_current_mark(3); 94 $this->check_current_output( 95 $this->get_contains_mark_summary(3), 96 $this->get_does_not_contain_submit_button_expectation(), 97 $this->get_contains_correct_expectation(), 98 $this->get_does_not_contain_validation_error_expectation(), 99 $this->get_no_hint_visible_expectation()); 100 } 101 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body