Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]
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 qbehaviour_informationitem; 18 19 use question_state; 20 21 defined('MOODLE_INTERNAL') || die(); 22 23 global $CFG; 24 require_once (__DIR__ . '/../../../engine/lib.php'); 25 require_once (__DIR__ . '/../../../engine/tests/helpers.php'); 26 27 28 /** 29 * Unit tests for the information item behaviour. 30 * 31 * @package qbehaviour_informationitem 32 * @category test 33 * @copyright 2009 The Open University 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 * @covers \qbehaviour_informationitem 36 */ 37 class walkthrough_test extends \qbehaviour_walkthrough_test_base { 38 public function test_informationitem_feedback_description() { 39 40 // Create a true-false question with correct answer true. 41 $description = \test_question_maker::make_question('description'); 42 $this->start_attempt_at_question($description, 'deferredfeedback'); 43 44 // Check the initial state. 45 $this->check_current_state(question_state::$todo); 46 $this->check_current_mark(null); 47 $this->check_current_output($this->get_contains_question_text_expectation($description), 48 $this->get_contains_hidden_expectation( 49 $this->quba->get_field_prefix($this->slot) . '-seen', 1), 50 $this->get_does_not_contain_feedback_expectation()); 51 52 // Check no hidden input when read-only. 53 $this->displayoptions->readonly = true; 54 $this->check_current_output($this->get_contains_question_text_expectation($description), 55 $this->get_does_not_contain_hidden_expectation( 56 $this->quba->get_field_prefix($this->slot) . '-seen', 1)); 57 $this->displayoptions->readonly = false; 58 59 // Process a submission indicating this question has been seen. 60 $this->process_submission(['-seen' => 1]); 61 62 $this->check_current_state(question_state::$complete); 63 $this->check_current_mark(null); 64 $this->check_current_output($this->get_does_not_contain_correctness_expectation(), 65 new \question_no_pattern_expectation( 66 '/type=\"hidden\"[^>]*name=\"[^"]*seen\"|name=\"[^"]*seen\"[^>]*type=\"hidden\"/'), 67 $this->get_does_not_contain_feedback_expectation()); 68 69 // Finish the attempt. 70 $this->quba->finish_all_questions(); 71 72 // Verify. 73 $this->check_current_state(question_state::$finished); 74 $this->check_current_mark(null); 75 $this->check_current_output( 76 $this->get_contains_question_text_expectation($description), 77 $this->get_contains_general_feedback_expectation($description)); 78 79 // Process a manual comment. 80 $this->manual_grade('Not good enough!', null, FORMAT_HTML); 81 82 $this->check_current_state(question_state::$manfinished); 83 $this->check_current_mark(null); 84 $this->check_current_output( 85 new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); 86 87 // Check that trying to process a manual comment with a grade causes an exception. 88 $this->expectException('moodle_exception'); 89 $this->manual_grade('Not good enough!', 1, FORMAT_HTML); 90 } 91 92 public function test_informationitem_regrade() { 93 94 // Create a true-false question with correct answer true. 95 $description = \test_question_maker::make_question('description'); 96 $this->start_attempt_at_question($description, 'deferredfeedback'); 97 98 // Check the initial state. 99 $this->check_current_state(question_state::$todo); 100 $this->check_current_mark(null); 101 $this->check_current_output($this->get_contains_question_text_expectation($description), 102 $this->get_contains_hidden_expectation( 103 $this->quba->get_field_prefix($this->slot) . '-seen', 1), 104 $this->get_does_not_contain_feedback_expectation()); 105 106 // Process a submission indicating this question has been seen. 107 $this->process_submission(['-seen' => 1]); 108 109 $this->check_current_state(question_state::$complete); 110 $this->check_current_mark(null); 111 $this->check_current_output($this->get_does_not_contain_correctness_expectation(), 112 new \question_no_pattern_expectation( 113 '/type=\"hidden\"[^>]*name=\"[^"]*seen\"|name=\"[^"]*seen\"[^>]*type=\"hidden\"/'), 114 $this->get_does_not_contain_feedback_expectation()); 115 116 // Finish the attempt. 117 $this->quba->finish_all_questions(); 118 119 // Verify. 120 $this->check_current_state(question_state::$finished); 121 $this->check_current_mark(null); 122 $this->check_step_count(3); 123 $this->check_current_output( 124 $this->get_contains_question_text_expectation($description), 125 $this->get_contains_general_feedback_expectation($description)); 126 127 // Regrade the attempt. 128 $this->quba->regrade_all_questions(true); 129 130 // Verify. 131 $this->check_current_mark(null); 132 $this->check_step_count(3); 133 $this->check_current_output( 134 $this->get_contains_question_text_expectation($description), 135 $this->get_contains_general_feedback_expectation($description)); 136 } 137 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body