public function test_grading_rounding_three_right() { question_bank::load_question_definition_classes('turmultiplechoice'); $mc = new qtype_turmultiplechoice_multi_question(); test_turmultiplechoice_question_maker::initialise_a_question($mc); $mc->name = 'Odd numbers'; $mc->questiontext = 'Which are the odd numbers?'; $mc->generalfeedback = '1, 3 and 5 are the odd numbers.'; $mc->qtype = question_bank::get_qtype('turmultiplechoice'); $mc->shuffleanswers = 0; $mc->qdifficulty = '0'; test_turmultiplechoice_question_maker::set_standard_combined_feedback_fields($mc); $mc->answers = array(11 => new question_answer(11, '1', 0.3333333, '', FORMAT_HTML), 12 => new question_answer(12, '2', -1, '', FORMAT_HTML), 13 => new question_answer(13, '3', 0.3333333, '', FORMAT_HTML), 14 => new question_answer(14, '4', -1, '', FORMAT_HTML), 15 => new question_answer(15, '5', 0.3333333, '', FORMAT_HTML), 16 => new question_answer(16, '6', -1, '', FORMAT_HTML)); $mc->start_attempt(new question_attempt_step(), 1); list($grade, $state) = $mc->grade_response(array('choice0' => 1, 'choice2' => 1, 'choice4' => 1)); $this->assertWithinMargin(1, $grade, 1.0E-6); $this->assertEqual(question_state::$gradedright, $state); }