|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00028 defined('MOODLE_INTERNAL') || die(); 00029 00030 require_once(dirname(__FILE__) . '/../../../engine/lib.php'); 00031 require_once(dirname(__FILE__) . '/../../../engine/simpletest/helpers.php'); 00032 00033 00040 class qbehaviour_informationitem_walkthrough_test extends qbehaviour_walkthrough_test_base { 00041 public function test_informationitem_feedback_description() { 00042 00043 // Create a true-false question with correct answer true. 00044 $description = test_question_maker::make_question('description'); 00045 $this->start_attempt_at_question($description, 'deferredfeedback'); 00046 00047 // Check the initial state. 00048 $this->check_current_state(question_state::$todo); 00049 $this->check_current_mark(null); 00050 $this->check_current_output($this->get_contains_question_text_expectation($description), 00051 new ContainsTagWithAttributes('input', array('type' => 'hidden', 00052 'name' => $this->quba->get_field_prefix($this->slot) . '-seen', 'value' => 1)), 00053 $this->get_does_not_contain_feedback_expectation()); 00054 00055 // Process a submission indicating this question has been seen. 00056 $this->process_submission(array('-seen' => 1)); 00057 00058 $this->check_current_state(question_state::$complete); 00059 $this->check_current_mark(null); 00060 $this->check_current_output($this->get_does_not_contain_correctness_expectation(), 00061 new NoPatternExpectation( 00062 '/type=\"hidden\"[^>]*name=\"[^"]*seen\"|name=\"[^"]*seen\"[^>]*type=\"hidden\"/'), 00063 $this->get_does_not_contain_feedback_expectation()); 00064 00065 // Finish the attempt. 00066 $this->quba->finish_all_questions(); 00067 00068 // Verify. 00069 $this->check_current_state(question_state::$finished); 00070 $this->check_current_mark(null); 00071 $this->check_current_output( 00072 $this->get_contains_question_text_expectation($description), 00073 $this->get_contains_general_feedback_expectation($description)); 00074 00075 // Process a manual comment. 00076 $this->manual_grade('Not good enough!', null); 00077 00078 $this->check_current_state(question_state::$manfinished); 00079 $this->check_current_mark(null); 00080 $this->check_current_output( 00081 new PatternExpectation('/' . preg_quote('Not good enough!') . '/')); 00082 00083 // Check that trying to process a manual comment with a grade causes an exception. 00084 $this->expectException(); 00085 $this->manual_grade('Not good enough!', 1); 00086 } 00087 }