MDL-47494 gapselect: work-in-progress converting the ddwtos and gapselect qtypes.
[moodle.git] / question / type / gapselect / simpletest / helper.php
CommitLineData
0d24b17a
TH
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18
19/**
20 * Contains the helper class for the select missing words question type tests.
21 *
22 * @package qtype
23 * @subpackage gapselect
24 * @copyright 2011 The Open University
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 */
27
28
29/**
30 * Test helper class for the select missing words question type.
31 *
32 * @copyright 2011 The Open University
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34 */
35class qtype_gapselect_test_helper {
36 /**
37 * @return qtype_gapselect_question
38 */
39 public static function make_a_gapselect_question() {
40 question_bank::load_question_definition_classes('gapselect');
41 $gapselect = new qtype_gapselect_question();
42
43 test_question_maker::initialise_a_question($gapselect);
44
45 $gapselect->name = 'Selection from drop down list question';
46 $gapselect->questiontext = 'The [[1]] brown [[2]] jumped over the [[3]] dog.';
47 $gapselect->generalfeedback = 'This sentence uses each letter of the alphabet.';
48 $gapselect->qtype = question_bank::get_qtype('gapselect');
49
50 $gapselect->shufflechoices = true;
51
52 test_question_maker::set_standard_combined_feedback_fields($gapselect);
53
54 $gapselect->choices = array(
55 1 => array(
56 1 => new qtype_gapselect_choice('quick', 1),
57 2 => new qtype_gapselect_choice('slow', 1)),
58 2 => array(
59 1 => new qtype_gapselect_choice('fox', 2),
60 2 => new qtype_gapselect_choice('dog', 2)),
61 3 => array(
62 1 => new qtype_gapselect_choice('lazy', 3),
63 2 => new qtype_gapselect_choice('assiduous', 3)),
64 );
65
66 $gapselect->places = array(1 => 1, 2 => 2, 3 => 3);
67 $gapselect->rightchoices = array(1 => 1, 2 => 1, 3 => 1);
68 $gapselect->textfragments = array('The ', ' brown ', ' jumped over the ', ' dog.');
69
70 return $gapselect;
71 }
72
73 /**
74 * @return qtype_gapselect_question
75 */
76 public static function make_a_maths_gapselect_question() {
77 question_bank::load_question_definition_classes('gapselect');
78 $gapselect = new qtype_gapselect_question();
79
80 test_question_maker::initialise_a_question($gapselect);
81
82 $gapselect->name = 'Selection from drop down list question';
83 $gapselect->questiontext = 'Fill in the operators to make this equation work: ' .
84 '7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3';
85 $gapselect->generalfeedback = 'This sentence uses each letter of the alphabet.';
86 $gapselect->qtype = question_bank::get_qtype('gapselect');
87
88 $gapselect->shufflechoices = true;
89
90 test_question_maker::set_standard_combined_feedback_fields($gapselect);
91
92 $gapselect->choices = array(
93 1 => array(
94 1 => new qtype_gapselect_choice('+', 1, true),
95 2 => new qtype_gapselect_choice('-', 1, true),
96 3 => new qtype_gapselect_choice('*', 1, true),
97 4 => new qtype_gapselect_choice('/', 1, true),
98 ));
99
100 $gapselect->places = array(1 => 1, 2 => 1, 3 => 1, 4 => 1);
101 $gapselect->rightchoices = array(1 => 1, 2 => 2, 3 => 1, 4 => 2);
102 $gapselect->textfragments = array('7 ', ' 11 ', ' 13 ', ' 17 ', ' 19 = 3');
103
104 return $gapselect;
105 }
106}