weekly release 2.4dev
[moodle.git] / question / type / multianswer / tests / walkthrough_test.php
CommitLineData
603bd001
PS
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * This file contains overall tests of multianswer questions.
19 *
20 * @package qtype
21 * @subpackage multianswer
22 * @copyright 2011 The Open University
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26
27defined('MOODLE_INTERNAL') || die();
28
29global $CFG;
30require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
31
32
33/**
34 * Unit tests for the multianswer question type.
35 *
36 * @copyright 2011 The Open University
37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 */
39class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_base {
be1d8ed1 40 public function test_deferred_feedback() {
603bd001
PS
41
42 // Create a gapselect question.
be1d8ed1
TH
43 $q = test_question_maker::make_question('multianswer', 'fourmc');
44 $this->start_attempt_at_question($q, 'deferredfeedback', 4);
603bd001
PS
45
46 // Check the initial state.
47 $this->check_current_state(question_state::$todo);
48 $this->check_current_mark(null);
49 $this->check_current_output(
50 $this->get_contains_marked_out_of_summary(),
603bd001 51 $this->get_does_not_contain_feedback_expectation(),
be1d8ed1 52 $this->get_does_not_contain_validation_error_expectation());
603bd001 53
be1d8ed1
TH
54 // Save in incomplete answer.
55 $this->process_submission(array('sub1_answer' => '1', 'sub2_answer' => '',
56 'sub3_answer' => '', 'sub4_answer' => ''));
603bd001
PS
57
58 // Verify.
59 $this->check_current_state(question_state::$invalid);
60 $this->check_current_mark(null);
61 $this->check_current_output(
62 $this->get_contains_marked_out_of_summary(),
603bd001 63 $this->get_does_not_contain_feedback_expectation(),
be1d8ed1 64 $this->get_does_not_contain_validation_error_expectation()); // TODO, really, it should. See MDL-32049.
603bd001 65
be1d8ed1
TH
66 // Save a partially correct answer.
67 $this->process_submission(array('sub1_answer' => '1', 'sub2_answer' => '1',
68 'sub3_answer' => '1', 'sub4_answer' => '1'));
603bd001
PS
69
70 // Verify.
be1d8ed1 71 $this->check_current_state(question_state::$complete);
603bd001
PS
72 $this->check_current_mark(null);
73 $this->check_current_output(
74 $this->get_contains_marked_out_of_summary(),
603bd001 75 $this->get_does_not_contain_feedback_expectation(),
be1d8ed1 76 $this->get_does_not_contain_validation_error_expectation());
603bd001 77
be1d8ed1
TH
78 // Now submit all and finish.
79 $this->process_submission(array('-finish' => 1));
603bd001
PS
80
81 // Verify.
be1d8ed1
TH
82 $this->check_current_state(question_state::$gradedpartial);
83 $this->check_current_mark(2);
603bd001 84 $this->check_current_output(
be1d8ed1
TH
85 $this->get_contains_mark_summary(2),
86 $this->get_contains_partcorrect_expectation(),
87 $this->get_does_not_contain_validation_error_expectation());
603bd001
PS
88 }
89}