Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/type/multianswer/simpletest/testwalkthrough.php
Go to the documentation of this file.
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 
00027 defined('MOODLE_INTERNAL') || die();
00028 
00029 require_once($CFG->dirroot . '/question/engine/simpletest/helpers.php');
00030 
00031 
00038 class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_base {
00039     public function test_interactive() {
00040         return; // TODO
00041 
00042         // Create a gapselect question.
00043         $q = test_question_maker::make_question('calculated');
00044         $q->hints = array(
00045             new question_hint(1, 'This is the first hint.', FORMAT_HTML),
00046             new question_hint(2, 'This is the second hint.', FORMAT_HTML),
00047         );
00048         $this->start_attempt_at_question($q, 'interactive', 3);
00049         $values = $q->vs->get_values();
00050 
00051         // Check the initial state.
00052         $this->check_current_state(question_state::$todo);
00053         $this->check_current_mark(null);
00054         $this->check_current_output(
00055                 $this->get_contains_marked_out_of_summary(),
00056                 $this->get_contains_submit_button_expectation(true),
00057                 $this->get_does_not_contain_feedback_expectation(),
00058                 $this->get_does_not_contain_validation_error_expectation(),
00059                 $this->get_does_not_contain_try_again_button_expectation(),
00060                 $this->get_no_hint_visible_expectation());
00061 
00062         // Submit blank.
00063         $this->process_submission(array('-submit' => 1, 'answer' => ''));
00064 
00065         // Verify.
00066         $this->check_current_state(question_state::$invalid);
00067         $this->check_current_mark(null);
00068         $this->check_current_output(
00069                 $this->get_contains_marked_out_of_summary(),
00070                 $this->get_contains_submit_button_expectation(true),
00071                 $this->get_does_not_contain_feedback_expectation(),
00072                 $this->get_contains_validation_error_expectation(),
00073                 $this->get_does_not_contain_try_again_button_expectation(),
00074                 $this->get_no_hint_visible_expectation());
00075 
00076         // Sumit something that does not look like a number.
00077         $this->process_submission(array('-submit' => 1, 'answer' => 'newt'));
00078 
00079         // Verify.
00080         $this->check_current_state(question_state::$invalid);
00081         $this->check_current_mark(null);
00082         $this->check_current_output(
00083                 $this->get_contains_marked_out_of_summary(),
00084                 $this->get_contains_submit_button_expectation(true),
00085                 $this->get_does_not_contain_feedback_expectation(),
00086                 $this->get_contains_validation_error_expectation(),
00087                 new PatternExpectation('/' .
00088                         preg_quote(get_string('invalidnumber', 'qtype_numerical') . '/')),
00089                 $this->get_does_not_contain_try_again_button_expectation(),
00090                 $this->get_no_hint_visible_expectation());
00091 
00092         // Now get it right.
00093         $this->process_submission(array('-submit' => 1, 'answer' => $values['a'] + $values['b']));
00094 
00095         // Verify.
00096         $this->check_current_state(question_state::$gradedright);
00097         $this->check_current_mark(3);
00098         $this->check_current_output(
00099                 $this->get_contains_mark_summary(3),
00100                 $this->get_contains_submit_button_expectation(false),
00101                 $this->get_contains_correct_expectation(),
00102                 $this->get_does_not_contain_validation_error_expectation(),
00103                 $this->get_no_hint_visible_expectation());
00104     }
00105 }
 All Data Structures Namespaces Files Functions Variables Enumerations