芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/question/type/multichoice/tests/walkthrough_test.php
. /** * This file contains tests that walk mutichoice questions through various behaviours. * * Note, there are already lots of tests of the multichoice type in the behaviour * tests. (Search for test_question_maker::make_a_multichoice.) This file only * contains a few additional tests for problems that were found during testing. * * @package qtype * @subpackage multichoice * @copyright 2010 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot . '/question/engine/lib.php'); require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); /** * Unit tests for the mutiple choice question type. * * @copyright 2010 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qtype_multichoice_walkthrough_test extends qbehaviour_walkthrough_test_base { public function test_deferredfeedback_feedback_multichoice_single() { // Create a multichoice, single question. $mc = test_question_maker::make_a_multichoice_single_question(); $mc->shuffleanswers = false; $mc->answers[14]->fraction = 0.1; // Make one of the choices partially right. $rightindex = 0; $this->start_attempt_at_question($mc, 'deferredfeedback', 3); $this->process_submission(array('answer' => $rightindex)); // Verify. $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output( $this->get_contains_mc_radio_expectation($rightindex, true, true), $this->get_contains_mc_radio_expectation($rightindex + 1, true, false), $this->get_contains_mc_radio_expectation($rightindex + 2, true, false), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); // Finish the attempt. $this->quba->finish_all_questions(); // Verify. $this->check_current_state(question_state::$gradedright); $this->check_current_mark(3); $this->check_current_output( $this->get_contains_mc_radio_expectation($rightindex, false, true), $this->get_contains_correct_expectation(), new question_pattern_expectation('/class="r0 correct"/'), new question_pattern_expectation('/class="r1"/')); } public function test_deferredfeedback_feedback_multichoice_multi() { // Create a multichoice, multi question. $mc = test_question_maker::make_a_multichoice_multi_question(); $mc->shuffleanswers = false; $this->start_attempt_at_question($mc, 'deferredfeedback', 2); $this->process_submission($mc->get_correct_response()); $this->quba->finish_all_questions(); // Verify. $this->check_current_state(question_state::$gradedright); $this->check_current_mark(2); $this->check_current_output( $this->get_contains_mc_checkbox_expectation('choice0', false, true), $this->get_contains_mc_checkbox_expectation('choice1', false, false), $this->get_contains_mc_checkbox_expectation('choice2', false, true), $this->get_contains_mc_checkbox_expectation('choice3', false, false), $this->get_contains_correct_expectation(), new question_pattern_expectation('/class="r0 correct"/'), new question_pattern_expectation('/class="r1"/')); } }