Esempio n. 1
0
    public function test_adaptive_shortanswer_try_to_submit_blank() {

        // Create a short answer question with correct answer true.
        $sa = test_question_maker::make_a_shortanswer_question();
        $this->start_attempt_at_question($sa, 'adaptive');

        // Check the initial state.
        $this->check_current_state(question_state::$todo);
        $this->check_current_mark(null);
        $this->check_current_output(
                $this->get_contains_marked_out_of_summary(),
                $this->get_contains_submit_button_expectation(true),
                $this->get_does_not_contain_feedback_expectation());

        // Submit with blank answer.
        $this->process_submission(array('-submit' => 1, 'answer' => ''));

        // Verify.
        $this->check_current_state(question_state::$invalid);
        $this->check_current_mark(null);
        $this->check_current_output(
                $this->get_contains_marked_out_of_summary(),
                $this->get_contains_submit_button_expectation(true),
                $this->get_does_not_contain_correctness_expectation(),
                $this->get_contains_validation_error_expectation());
        $this->assertNull($this->quba->get_response_summary($this->slot));

        // Now get it wrong.
        $this->process_submission(array('-submit' => 1, 'answer' => 'toad'));

        // Verify.
        $this->check_current_state(question_state::$todo);
        $this->check_current_mark(0.8);
        $this->check_current_output(
                $this->get_contains_mark_summary(0.8),
                $this->get_contains_submit_button_expectation(true),
                $this->get_contains_partcorrect_expectation(),
                $this->get_does_not_contain_validation_error_expectation());

        // Now submit blank again.
        $this->process_submission(array('-submit' => 1, 'answer' => ''));

        // Verify.
        $this->check_current_state(question_state::$invalid);
        $this->check_current_mark(0.8);
        $this->check_current_output(
                $this->get_contains_mark_summary(0.8),
                $this->get_contains_submit_button_expectation(true),
                $this->get_contains_partcorrect_expectation(),
                $this->get_contains_validation_error_expectation());
    }
 public function test_immediatecbm_feedback_shortanswer_try_to_submit_no_certainty()
 {
     // Create a short answer question with correct answer true.
     $sa = test_question_maker::make_a_shortanswer_question();
     $this->start_attempt_at_question($sa, 'immediatecbm');
     // Check the initial state.
     $this->check_current_state(question_state::$todo);
     $this->check_current_mark(null);
     $this->check_current_output($this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation());
     // Submit with certainty missing.
     $this->process_submission(array('-submit' => 1, 'answer' => 'frog'));
     // Verify.
     $this->check_current_state(question_state::$invalid);
     $this->check_current_mark(null);
     $this->check_current_output($this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), $this->get_contains_validation_error_expectation());
     // Now get it right.
     $this->process_submission(array('-submit' => 1, 'answer' => 'frog', '-certainty' => 3));
     // Verify.
     $this->check_current_state(question_state::$gradedright);
     $this->check_current_mark(1);
     $this->check_current_output($this->get_does_not_contain_validation_error_expectation());
 }
 public function test_classify_response()
 {
     $sa = test_question_maker::make_a_shortanswer_question();
     $sa->start_attempt(new question_attempt_step(), 1);
     $this->assertEqual(array(new question_classified_response(13, 'frog', 1.0)), $sa->classify_response(array('answer' => 'frog')));
     $this->assertEqual(array(new question_classified_response(14, 'toad', 0.8)), $sa->classify_response(array('answer' => 'toad')));
     $this->assertEqual(array(new question_classified_response(15, 'cat', 0.0)), $sa->classify_response(array('answer' => 'cat')));
     $this->assertEqual(array(question_classified_response::no_response()), $sa->classify_response(array('answer' => '')));
 }
 public function test_interactive_regrade_changing_num_tries_finished()
 {
     // Create a multichoice multiple question.
     $q = test_question_maker::make_a_shortanswer_question();
     $q->hints = array(new question_hint_with_parts(0, 'This is the first hint.', FORMAT_HTML, true, true), new question_hint_with_parts(0, 'This is the second hint.', FORMAT_HTML, true, true));
     $this->start_attempt_at_question($q, 'interactive', 3);
     // Check the initial state.
     $this->check_current_state(question_state::$todo);
     $this->check_current_mark(null);
     $this->check_current_output($this->get_tries_remaining_expectation(3));
     // Submit the right answer.
     $this->process_submission(array('answer' => 'frog', '-submit' => 1));
     // Verify.
     $this->check_current_state(question_state::$gradedright);
     $this->check_current_mark(3);
     // Now change the quiestion so that answer is only partially right, and regrade.
     $q->answers[13]->fraction = 0.6666666999999999;
     $q->answers[14]->fraction = 1;
     $this->quba->regrade_all_questions(true);
     // Verify.
     $this->check_current_state(question_state::$gradedpartial);
     // TODO I don't think 1 is the right fraction here. However, it is what
     // you get attempting a question like this without regrading being involved,
     // and I am currently interested in testing regrading here.
     $this->check_current_mark(1);
 }