Merge branch 'MDL-70242-310' of git://github.com/marinaglancy/moodle into MOODLE_310_...
[moodle.git] / question / type / description / tests / helper.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 * Test helper code for the description question type.
19 *
01c898ec
JP
20 * @package qtype_description
21 * @copyright 2013 The Open University
603bd001
PS
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25
26defined('MOODLE_INTERNAL') || die();
27
28
29/**
30 * Test helper class for the description question type.
31 *
01c898ec 32 * @copyright 2013 The Open University
603bd001
PS
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34 */
35class qtype_description_test_helper extends question_test_helper {
36 public function get_test_questions() {
37 return array('info');
38 }
39
40 /**
41 * @return qtype_description_question
42 */
43 public static function make_description_question_info() {
44 question_bank::load_question_definition_classes('description');
45 $q = new qtype_description_question();
46
47 test_question_maker::initialise_a_question($q);
48 $q->defaultmark = 0;
49 $q->penalty = 0;
50 $q->length = 0;
51
52 $q->name = 'Description';
53 $q->questiontext = 'Here is some information about the questions you are about to attempt.';
54 $q->generalfeedback = 'And here is some more text shown only on the review page.';
55 $q->qtype = question_bank::get_qtype('description');
56
57 return $q;
58 }
59
60 /**
01c898ec 61 * Get the question data, as it would be loaded by get_question_options.
603bd001
PS
62 * @return object
63 */
01c898ec 64 public static function get_description_question_data_info() {
603bd001
PS
65 global $USER;
66
67 $qdata = new stdClass();
68 $qdata->id = 0;
69 $qdata->contextid = 0;
70 $qdata->category = 0;
71 $qdata->parent = 0;
72 $qdata->stamp = make_unique_id_code();
73 $qdata->version = make_unique_id_code();
74 $qdata->timecreated = time();
75 $qdata->timemodified = time();
76 $qdata->createdby = $USER->id;
77 $qdata->modifiedby = $USER->id;
78 $qdata->qtype = 'description';
79 $qdata->name = 'Description';
80 $qdata->questiontext = 'Here is some information about the questions you are about to attempt.';
81 $qdata->questiontextformat = FORMAT_HTML;
82 $qdata->generalfeedback = 'And here is some more text shown only on the review page.';
83 $qdata->generalfeedbackformat = FORMAT_HTML;
84 $qdata->defaultmark = 0;
85 $qdata->length = 0;
86 $qdata->penalty = 0;
87 $qdata->hidden = 0;
01c898ec
JP
88 $qdata->hints = array();
89 $qdata->options = new stdClass();
90 $qdata->options->answers = array();
603bd001
PS
91
92 return $qdata;
93 }
01c898ec
JP
94
95
96 /**
97 * Get the question form data.
98 * @return object
99 */
100 public static function get_description_question_form_data_info() {
101 $form = new stdClass();
102
103 $form->name = 'Description';
104 $form->questiontext = array('text' => 'Here is some information about the questions you are about to attempt.',
105 'format' => FORMAT_HTML);
106 $form->generalfeedback = array('text' => 'And here is some more text shown only on the review page.',
107 'format' => FORMAT_HTML);
108
109 return $form;
110 }
111
603bd001 112}