weekly release 3.7dev
[moodle.git] / question / type / gapselect / tests / helper.php
CommitLineData
0d24b17a 1<?php
0d24b17a
TH
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
0d24b17a
TH
17/**
18 * Contains the helper class for the select missing words question type tests.
19 *
bbe27b2d
TH
20 * @package qtype_gapselect
21 * @copyright 2011 The Open University
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
0d24b17a
TH
23 */
24
25
b28ad86a
TH
26defined('MOODLE_INTERNAL') || die();
27
28
0d24b17a
TH
29/**
30 * Test helper class for the select missing words question type.
31 *
bbe27b2d
TH
32 * @copyright 2011 The Open University
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
0d24b17a
TH
34 */
35class qtype_gapselect_test_helper {
36 /**
647d9373 37 * Get an example gapselect question to use for testing. This examples has one of each item.
0d24b17a
TH
38 * @return qtype_gapselect_question
39 */
40 public static function make_a_gapselect_question() {
41 question_bank::load_question_definition_classes('gapselect');
42 $gapselect = new qtype_gapselect_question();
43
44 test_question_maker::initialise_a_question($gapselect);
45
46 $gapselect->name = 'Selection from drop down list question';
47 $gapselect->questiontext = 'The [[1]] brown [[2]] jumped over the [[3]] dog.';
48 $gapselect->generalfeedback = 'This sentence uses each letter of the alphabet.';
49 $gapselect->qtype = question_bank::get_qtype('gapselect');
50
51 $gapselect->shufflechoices = true;
52
53 test_question_maker::set_standard_combined_feedback_fields($gapselect);
54
55 $gapselect->choices = array(
56 1 => array(
57 1 => new qtype_gapselect_choice('quick', 1),
58 2 => new qtype_gapselect_choice('slow', 1)),
59 2 => array(
60 1 => new qtype_gapselect_choice('fox', 2),
61 2 => new qtype_gapselect_choice('dog', 2)),
62 3 => array(
63 1 => new qtype_gapselect_choice('lazy', 3),
64 2 => new qtype_gapselect_choice('assiduous', 3)),
65 );
66
67 $gapselect->places = array(1 => 1, 2 => 2, 3 => 3);
68 $gapselect->rightchoices = array(1 => 1, 2 => 1, 3 => 1);
69 $gapselect->textfragments = array('The ', ' brown ', ' jumped over the ', ' dog.');
70
71 return $gapselect;
72 }
73
74 /**
647d9373 75 * Get an example gapselect question to use for testing. This exmples had unlimited items.
0d24b17a
TH
76 * @return qtype_gapselect_question
77 */
78 public static function make_a_maths_gapselect_question() {
79 question_bank::load_question_definition_classes('gapselect');
80 $gapselect = new qtype_gapselect_question();
81
82 test_question_maker::initialise_a_question($gapselect);
83
84 $gapselect->name = 'Selection from drop down list question';
85 $gapselect->questiontext = 'Fill in the operators to make this equation work: ' .
86 '7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3';
87 $gapselect->generalfeedback = 'This sentence uses each letter of the alphabet.';
88 $gapselect->qtype = question_bank::get_qtype('gapselect');
89
90 $gapselect->shufflechoices = true;
91
92 test_question_maker::set_standard_combined_feedback_fields($gapselect);
93
94 $gapselect->choices = array(
95 1 => array(
96 1 => new qtype_gapselect_choice('+', 1, true),
97 2 => new qtype_gapselect_choice('-', 1, true),
98 3 => new qtype_gapselect_choice('*', 1, true),
99 4 => new qtype_gapselect_choice('/', 1, true),
100 ));
101
102 $gapselect->places = array(1 => 1, 2 => 1, 3 => 1, 4 => 1);
103 $gapselect->rightchoices = array(1 => 1, 2 => 2, 3 => 1, 4 => 2);
104 $gapselect->textfragments = array('7 ', ' 11 ', ' 13 ', ' 17 ', ' 19 = 3');
105
106 return $gapselect;
107 }
adb21080
LB
108
109 /**
110 * Get an example gapselect question with multilang entries to use for testing.
111 * @return qtype_gapselect_question
112 */
113 public static function make_a_multilang_gapselect_question() {
114 question_bank::load_question_definition_classes('gapselect');
115 $gapselect = new qtype_gapselect_question();
116
117 test_question_maker::initialise_a_question($gapselect);
118
119 $gapselect->name = 'Multilang select missing words question';
120 $gapselect->questiontext = '<span lang="en" class="multilang">The </span><span lang="ru" class="multilang"></span>[[1]] ' .
121 '<span lang="en" class="multilang">sat on the</span><span lang="ru" class="multilang">сидела на</span> [[2]].';
122 $gapselect->generalfeedback = 'This sentence uses each letter of the alphabet.';
123 $gapselect->qtype = question_bank::get_qtype('gapselect');
124
125 $gapselect->shufflechoices = true;
126
127 test_question_maker::set_standard_combined_feedback_fields($gapselect);
128
129 $gapselect->choices = array(
130 1 => array(
131 1 => new qtype_gapselect_choice('<span lang="en" class="multilang">cat</span><span lang="ru" ' .
132 'class="multilang">кошка</span>', 1, true),
133 2 => new qtype_gapselect_choice('<span lang="en" class="multilang">dog</span><span lang="ru" ' .
134 'class="multilang">пес</span>', 1, true)),
135 2 => array(
136 1 => new qtype_gapselect_choice('<span lang="en" class="multilang">mat</span><span lang="ru" ' .
137 'class="multilang">коврике</span>', 2, true),
138 2 => new qtype_gapselect_choice('<span lang="en" class="multilang">bat</span><span lang="ru" ' .
139 'class="multilang">бита</span>', 2, true))
140 );
141
142 $gapselect->places = array(1 => 1, 2 => 2);
143 $gapselect->rightchoices = array(1 => 1, 2 => 1);
144 $gapselect->textfragments = array('<span lang="en" class="multilang">The </span><span lang="ru" class="multilang"></span>',
145 ' <span lang="en" class="multilang">sat on the</span><span lang="ru" class="multilang">сидела на</span> ', '.');
146
147 return $gapselect;
148 }
0d24b17a 149}