[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 /** 18 * This file contains tests that walk mutichoice questions through various behaviours. 19 * 20 * Note, there are already lots of tests of the multichoice type in the behaviour 21 * tests. (Search for test_question_maker::make_a_multichoice.) This file only 22 * contains a few additional tests for problems that were found during testing. 23 * 24 * @package qtype 25 * @subpackage multichoice 26 * @copyright 2010 The Open University 27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 28 */ 29 30 31 defined('MOODLE_INTERNAL') || die(); 32 33 global $CFG; 34 require_once($CFG->dirroot . '/question/engine/lib.php'); 35 require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); 36 37 38 /** 39 * Unit tests for the mutiple choice question type. 40 * 41 * @copyright 2010 The Open University 42 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 43 */ 44 class qtype_multichoice_walkthrough_test extends qbehaviour_walkthrough_test_base { 45 public function test_deferredfeedback_feedback_multichoice_single() { 46 47 // Create a multichoice, single question. 48 $mc = test_question_maker::make_a_multichoice_single_question(); 49 $mc->shuffleanswers = false; 50 $mc->answers[14]->fraction = 0.1; // Make one of the choices partially right. 51 $rightindex = 0; 52 53 $this->start_attempt_at_question($mc, 'deferredfeedback', 3); 54 $this->process_submission(array('answer' => $rightindex)); 55 56 // Verify. 57 $this->check_current_state(question_state::$complete); 58 $this->check_current_mark(null); 59 $this->check_current_output( 60 $this->get_contains_mc_radio_expectation($rightindex, true, true), 61 $this->get_contains_mc_radio_expectation($rightindex + 1, true, false), 62 $this->get_contains_mc_radio_expectation($rightindex + 2, true, false), 63 $this->get_does_not_contain_correctness_expectation(), 64 $this->get_does_not_contain_feedback_expectation()); 65 66 // Finish the attempt. 67 $this->quba->finish_all_questions(); 68 69 // Verify. 70 $this->check_current_state(question_state::$gradedright); 71 $this->check_current_mark(3); 72 $this->check_current_output( 73 $this->get_contains_mc_radio_expectation($rightindex, false, true), 74 $this->get_contains_correct_expectation(), 75 new question_pattern_expectation('/class="r0 correct"/'), 76 new question_pattern_expectation('/class="r1"/')); 77 } 78 79 public function test_deferredfeedback_feedback_multichoice_multi() { 80 // Create a multichoice, multi question. 81 $mc = test_question_maker::make_a_multichoice_multi_question(); 82 $mc->shuffleanswers = false; 83 84 $this->start_attempt_at_question($mc, 'deferredfeedback', 2); 85 $this->process_submission($mc->get_correct_response()); 86 $this->quba->finish_all_questions(); 87 88 // Verify. 89 $this->check_current_state(question_state::$gradedright); 90 $this->check_current_mark(2); 91 $this->check_current_output( 92 $this->get_contains_mc_checkbox_expectation('choice0', false, true), 93 $this->get_contains_mc_checkbox_expectation('choice1', false, false), 94 $this->get_contains_mc_checkbox_expectation('choice2', false, true), 95 $this->get_contains_mc_checkbox_expectation('choice3', false, false), 96 $this->get_contains_correct_expectation(), 97 new question_pattern_expectation('/class="r0 correct"/'), 98 new question_pattern_expectation('/class="r1"/')); 99 } 100 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |