Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 *
20
 * @package    qtype_description
21
 * @copyright  2013 The Open University
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
28
 
29
/**
30
 * Test helper class for the description question type.
31
 *
32
 * @copyright  2013 The Open University
33
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 */
35
class 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
    /**
61
     * Get the question data, as it would be loaded by get_question_options.
62
     * @return object
63
     */
64
    public static function get_description_question_data_info() {
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->timecreated = time();
74
        $qdata->timemodified = time();
75
        $qdata->createdby = $USER->id;
76
        $qdata->modifiedby = $USER->id;
77
        $qdata->qtype = 'description';
78
        $qdata->name = 'Description';
79
        $qdata->questiontext = 'Here is some information about the questions you are about to attempt.';
80
        $qdata->questiontextformat = FORMAT_HTML;
81
        $qdata->generalfeedback = 'And here is some more text shown only on the review page.';
82
        $qdata->generalfeedbackformat = FORMAT_HTML;
83
        $qdata->defaultmark = 0;
84
        $qdata->length = 0;
85
        $qdata->penalty = 0;
86
        $qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
87
        $qdata->hints = array();
88
        $qdata->options = new stdClass();
89
        $qdata->options->answers = array();
90
 
91
        return $qdata;
92
    }
93
 
94
 
95
    /**
96
     * Get the question form data.
97
     * @return object
98
     */
99
    public static function get_description_question_form_data_info() {
100
        $form = new stdClass();
101
 
102
        $form->name = 'Description';
103
        $form->questiontext = array('text' => 'Here is some information about the questions you are about to attempt.',
104
                                    'format' => FORMAT_HTML);
105
        $form->generalfeedback = array('text' => 'And here is some more text shown only on the review page.',
106
                                       'format' => FORMAT_HTML);
107
        $form->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
108
 
109
        return $form;
110
    }
111
 
112
}