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 helpers for the match question type.
20 * @package qtype_match
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();
29 require_once($CFG->dirroot . '/question/type/match/question.php');
33 * Test helper class for the match question type.
35 * @copyright 2013 The Open University
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 class qtype_match_test_helper extends question_test_helper {
39 public function get_test_questions() {
40 return array('foursubq');
45 * Makes a match question about completing two blanks in some text.
46 * @return object the question definition data, as it might be returned from
47 * get_question_options.
49 public function get_match_question_data_foursubq() {
52 test_question_maker::initialise_question_data($q);
53 $q->name = 'Matching question';
56 $q->questiontext = 'Classify the animals.';
57 $q->questiontextformat = FORMAT_HTML;
58 $q->generalfeedback = 'General feedback.';
59 $q->generalfeedbackformat = FORMAT_HTML;
61 $q->penalty = 0.3333333;
64 $q->createdby = $USER->id;
65 $q->modifiedby = $USER->id;
67 $q->options = new stdClass();
68 $q->options->shuffleanswers = 0;
69 test_question_maker::set_standard_combined_feedback_fields($q->options);
71 $q->options->subquestions = array(
74 'questiontext' => 'frog',
75 'questiontextformat' => FORMAT_HTML,
76 'answertext' => 'amphibian'),
79 'questiontext' => 'cat',
80 'questiontextformat' => FORMAT_HTML,
81 'answertext' => 'mammal'),
84 'questiontext' => 'newt',
85 'questiontextformat' => FORMAT_HTML,
86 'answertext' => 'amphibian'),
90 'questiontextformat' => FORMAT_HTML,
91 'answertext' => 'insect'),
98 * Makes a match question about completing two blanks in some text.
99 * @return object the question definition data, as it might be returned from
100 * the question editing form.
102 public function get_match_question_form_data_foursubq() {
104 $q->name = 'Matching question';
105 $q->questiontext = array('text' => 'Classify the animals.', 'format' => FORMAT_HTML);
106 $q->generalfeedback = array('text' => 'General feedback.', 'format' => FORMAT_HTML);
108 $q->penalty = 0.3333333;
110 $q->shuffleanswers = 0;
111 test_question_maker::set_standard_combined_feedback_form_data($q);
113 $q->subquestions = array(
114 0 => array('text' => 'frog', 'format' => FORMAT_HTML),
115 1 => array('text' => 'cat', 'format' => FORMAT_HTML),
116 2 => array('text' => 'newt', 'format' => FORMAT_HTML),
117 3 => array('text' => '', 'format' => FORMAT_HTML));
119 $q->subanswers = array(