public function test_deferredfeedback_resume_multichoiceset_right_right() { // Create a multichoiceset question. $mc = qtype_multichoiceset_test_helper::make_a_multichoiceset_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"/')); // Save the old attempt. $oldqa = $this->quba->get_question_attempt($this->slot); // Reinitialise. $this->setUp(); $this->quba->set_preferred_behaviour('deferredfeedback'); $this->slot = $this->quba->add_question($mc, 2); $this->quba->start_question_based_on($this->slot, $oldqa); // Verify. $this->check_current_state(question_state::$complete); $this->check_output_contains_lang_string('notchanged', 'question'); $this->check_current_mark(null); $this->check_current_output($this->get_contains_mc_checkbox_expectation('choice0', true, true), $this->get_contains_mc_checkbox_expectation('choice1', true, false), $this->get_contains_mc_checkbox_expectation('choice2', true, true), $this->get_contains_mc_checkbox_expectation('choice3', true, false)); // Now resubmit. $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"/')); }
public function test_classify_response() { $mc = qtype_multichoiceset_test_helper::make_a_multichoiceset_question(); $mc->shuffleanswers = false; $mc->start_attempt(new question_attempt_step(), 1); $this->assertEquals(array(13 => new question_classified_response(13, 'A', 0.5), 14 => new question_classified_response(14, 'B', 0.0)), $mc->classify_response(array('choice0' => 1, 'choice1' => 1))); $this->assertEquals(array(), $mc->classify_response(array())); }