2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Test helper code for the multiple choice question type.
20 * @package qtype_multichoice
21 * @copyright 2013 The Open University
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') || die();
30 * Test helper class for the multiple choice question type.
32 * @copyright 2013 The Open University
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 class qtype_multichoice_test_helper extends question_test_helper {
36 public function get_test_questions() {
37 return array('two_of_four');
41 * Get the question data, as it would be loaded by get_question_options.
44 public static function get_multichoice_question_data_two_of_four() {
47 $qdata = new stdClass();
49 $qdata->createdby = $USER->id;
50 $qdata->modifiedby = $USER->id;
51 $qdata->qtype = 'multichoice';
52 $qdata->name = 'Multiple choice question';
53 $qdata->questiontext = 'Which are the odd numbers?';
54 $qdata->questiontextformat = FORMAT_HTML;
55 $qdata->generalfeedback = 'The odd numbers are One and Three.';
56 $qdata->generalfeedbackformat = FORMAT_HTML;
57 $qdata->defaultmark = 1;
59 $qdata->penalty = 0.3333333;
62 $qdata->options = new stdClass();
63 $qdata->options->shuffleanswers = 1;
64 $qdata->options->answernumbering = '123';
65 $qdata->options->layout = 0;
66 $qdata->options->single = 0;
67 $qdata->options->correctfeedback =
68 test_question_maker::STANDARD_OVERALL_CORRECT_FEEDBACK;
69 $qdata->options->correctfeedbackformat = FORMAT_HTML;
70 $qdata->options->partiallycorrectfeedback =
71 test_question_maker::STANDARD_OVERALL_PARTIALLYCORRECT_FEEDBACK;
72 $qdata->options->partiallycorrectfeedbackformat = FORMAT_HTML;
73 $qdata->options->shownumcorrect = 1;
74 $qdata->options->incorrectfeedback =
75 test_question_maker::STANDARD_OVERALL_INCORRECT_FEEDBACK;
76 $qdata->options->incorrectfeedbackformat = FORMAT_HTML;
78 $qdata->options->answers = array(
82 'answerformat' => FORMAT_PLAIN,
84 'feedback' => 'One is odd.',
85 'feedbackformat' => FORMAT_HTML,
90 'answerformat' => FORMAT_PLAIN,
92 'feedback' => 'Two is even.',
93 'feedbackformat' => FORMAT_HTML,
98 'answerformat' => FORMAT_PLAIN,
100 'feedback' => 'Three is odd.',
101 'feedbackformat' => FORMAT_HTML,
103 16 => (object) array(
106 'answerformat' => FORMAT_PLAIN,
108 'feedback' => 'Four is even.',
109 'feedbackformat' => FORMAT_HTML,
113 $qdata->hints = array(
116 'hintformat' => FORMAT_HTML,
117 'shownumcorrect' => 1,
123 'hintformat' => FORMAT_HTML,
124 'shownumcorrect' => 1,
133 * Get the question data, as it would be loaded by get_question_options.
136 public static function get_multichoice_question_form_data_two_of_four() {
137 $qdata = new stdClass();
139 $qdata->name = 'multiple choice question';
140 $qdata->questiontext = array('text' => 'Which are the odd numbers?', 'format' => FORMAT_HTML);
141 $qdata->generalfeedback = array('text' => 'The odd numbers are One and Three.', 'format' => FORMAT_HTML);
142 $qdata->defaultmark = 1;
143 $qdata->noanswers = 5;
144 $qdata->numhints = 2;
145 $qdata->penalty = 0.3333333;
147 $qdata->shuffleanswers = 1;
148 $qdata->answernumbering = '123';
149 $qdata->single = '0';
150 $qdata->correctfeedback = array('text' => test_question_maker::STANDARD_OVERALL_CORRECT_FEEDBACK,
151 'format' => FORMAT_HTML);
152 $qdata->partiallycorrectfeedback = array('text' => test_question_maker::STANDARD_OVERALL_PARTIALLYCORRECT_FEEDBACK,
153 'format' => FORMAT_HTML);
154 $qdata->shownumcorrect = 1;
155 $qdata->incorrectfeedback = array('text' => test_question_maker::STANDARD_OVERALL_INCORRECT_FEEDBACK,
156 'format' => FORMAT_HTML);
157 $qdata->fraction = array('0.5', '0.0', '0.5', '0.0', '0.0');
158 $qdata->answer = array(
161 'format' => FORMAT_PLAIN
165 'format' => FORMAT_PLAIN
169 'format' => FORMAT_PLAIN
173 'format' => FORMAT_PLAIN
177 'format' => FORMAT_PLAIN
181 $qdata->feedback = array(
183 'text' => 'One is odd.',
184 'format' => FORMAT_HTML
187 'text' => 'Two is even.',
188 'format' => FORMAT_HTML
191 'text' => 'Three is odd.',
192 'format' => FORMAT_HTML
195 'text' => 'Four is even.',
196 'format' => FORMAT_HTML
200 'format' => FORMAT_HTML
204 $qdata->hint = array(
207 'format' => FORMAT_HTML
211 'format' => FORMAT_HTML
214 $qdata->hintclearwrong = array(0, 1);
215 $qdata->hintshownumcorrect = array(1, 1);