public function test_is_same_response() { $question = qtype_gapfill_test_helper::make_question('gapfill'); $prevresponse = array(); $newresponse = array('p1' => 'cat', 'p2' => 'mat'); $this->assertFalse($question->is_same_response($prevresponse, $newresponse)); $prevresponse = array('p1' => 'cat', 'p2' => 'mat'); $newresponse = array('p1' => 'cat', 'p2' => 'mat'); $this->assertTrue($question->is_same_response($prevresponse, $newresponse)); }
public function test_immediatefeedback_with_correct() { // Create a gapfill question. $gapfill = qtype_gapfill_test_helper::make_question('gapfill'); $maxmark = 2; $gapfill->showanswers = true; $this->start_attempt_at_question($gapfill, 'immediatefeedback', $maxmark); // Check the initial state. $this->check_current_state(question_state::$todo); $this->check_step_count(1); // Save a correct response. $this->process_submission(array('p0' => 'cat', 'p1' => 'cat')); $this->check_step_count(2); $this->check_current_state(question_state::$todo); // Submit saved response. $this->process_submission(array('-submit' => 1, 'p1' => 'cat', 'p2' => 'mat')); $this->check_step_count(3); // Verify. $this->quba->finish_all_questions(); $this->check_current_state(question_state::$gradedright); $this->check_current_mark(2); // Finish the attempt. }