Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/type/multichoice/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 
00031 defined('MOODLE_INTERNAL') || die();
00032 
00033 require_once($CFG->dirroot . '/question/engine/lib.php');
00034 require_once($CFG->dirroot . '/question/engine/simpletest/helpers.php');
00035 
00036 
00043 class qtype_multichoice_walkthrough_test extends qbehaviour_walkthrough_test_base {
00044     public function test_deferredfeedback_feedback_multichoice_single() {
00045 
00046         // Create a multichoice, single question.
00047         $mc = test_question_maker::make_a_multichoice_single_question();
00048         $mc->shuffleanswers = false;
00049         $mc->answers[14]->fraction = 0.1; // Make one of the choices partially right.
00050         $rightindex = 0;
00051 
00052         $this->start_attempt_at_question($mc, 'deferredfeedback', 3);
00053         $this->process_submission(array('answer' => $rightindex));
00054 
00055         // Verify.
00056         $this->check_current_state(question_state::$complete);
00057         $this->check_current_mark(null);
00058         $this->check_current_output(
00059                 $this->get_contains_mc_radio_expectation($rightindex, true, true),
00060                 $this->get_contains_mc_radio_expectation($rightindex + 1, true, false),
00061                 $this->get_contains_mc_radio_expectation($rightindex + 2, true, false),
00062                 $this->get_does_not_contain_correctness_expectation(),
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::$gradedright);
00070         $this->check_current_mark(3);
00071         $this->check_current_output(
00072                 $this->get_contains_mc_radio_expectation($rightindex, false, true),
00073                 $this->get_contains_correct_expectation(),
00074                 new PatternExpectation('/class="r0 correct"/'),
00075                 new PatternExpectation('/class="r1"/'));
00076     }
00077 
00078     public function test_deferredfeedback_feedback_multichoice_multi() {
00079         // Create a multichoice, multi question.
00080         $mc = test_question_maker::make_a_multichoice_multi_question();
00081         $mc->shuffleanswers = false;
00082 
00083         $this->start_attempt_at_question($mc, 'deferredfeedback', 2);
00084         $this->process_submission($mc->get_correct_response());
00085         $this->quba->finish_all_questions();
00086 
00087         // Verify.
00088         $this->check_current_state(question_state::$gradedright);
00089         $this->check_current_mark(2);
00090         $this->check_current_output(
00091                 $this->get_contains_mc_checkbox_expectation('choice0', false, true),
00092                 $this->get_contains_mc_checkbox_expectation('choice1', false, false),
00093                 $this->get_contains_mc_checkbox_expectation('choice2', false, true),
00094                 $this->get_contains_mc_checkbox_expectation('choice3', false, false),
00095                 $this->get_contains_correct_expectation(),
00096                 new PatternExpectation('/class="r0 correct"/'),
00097                 new PatternExpectation('/class="r1"/'));
00098     }
00099 }
 All Data Structures Namespaces Files Functions Variables Enumerations