Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/type/truefalse/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 
00028 defined('MOODLE_INTERNAL') || die();
00029 
00030 require_once($CFG->dirroot . '/question/engine/simpletest/helpers.php');
00031 
00032 
00039 class qtype_truefalse_walkthrough_test extends qbehaviour_walkthrough_test_base {
00040     public function test_false_right_does_not_show_feedback_when_not_answered() {
00041 
00042         // Create a true-false question with correct answer false.
00043         $tf = test_question_maker::make_question('truefalse', 'false');
00044         $this->start_attempt_at_question($tf, 'deferredfeedback', 1);
00045 
00046         // Check the initial state.
00047         $this->check_current_state(question_state::$todo);
00048         $this->check_current_mark(null);
00049         $this->check_current_output(
00050                 $this->get_contains_question_text_expectation($tf),
00051                 $this->get_does_not_contain_feedback_expectation(),
00052                 new ContainsTagWithContents('h3',
00053                         get_string('questiontext', 'question')));
00054         $this->assertEqual(get_string('false', 'qtype_truefalse'),
00055                 $this->quba->get_right_answer_summary($this->slot));
00056         $this->assertPattern('/' . preg_quote($tf->questiontext) . '/',
00057                 $this->quba->get_question_summary($this->slot));
00058         $this->assertNull($this->quba->get_response_summary($this->slot));
00059 
00060         // Finish the attempt without answering.
00061         $this->quba->finish_all_questions();
00062 
00063         // Verify.
00064         $this->check_current_state(question_state::$gaveup);
00065         $this->check_current_mark(null);
00066         $this->check_current_output(
00067                 $this->get_contains_tf_true_radio_expectation(false, false),
00068                 $this->get_contains_tf_false_radio_expectation(false, false),
00069 
00070                 // In particular, check that the false feedback is not displayed.
00071                 new NoPatternExpectation('/' . preg_quote($tf->falsefeedback) . '/'));
00072 
00073     }
00074 }
 All Data Structures Namespaces Files Functions Variables Enumerations