mirrored from git://git.moodle.org/moodle.git
/
questiontype.php
78 lines (59 loc) · 2.19 KB
/
questiontype.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
///////////////////
/// missingtype ///
///////////////////
/// QUESTION TYPE CLASS //////////////////
/**
* Missing question type class
*
* When a question is encountered with a type that is not installed then its
* type is changed to 'missingtype'. This questiontype just makes sure that the
* necessary information is printed about the question.
* @package questionbank
* @subpackage questiontypes
*/
class question_missingtype_qtype extends default_questiontype {
function name() {
return 'missingtype';
}
function menu_name() {
return false;
}
function is_usable_by_random() {
return false;
}
function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) {
global $CFG;
$answers = &$question->options->answers;
$formatoptions = new stdClass;
$formatoptions->noclean = true;
$formatoptions->para = false;
// Print formulation
$questiontext = format_text($question->questiontext,
$question->questiontextformat,
$formatoptions, $cmoptions->course);
// Print each answer in a separate row if there are any
$anss = array();
if ($answers) {
foreach ($answers as $answer) {
$a = new stdClass;
$a->text = format_text($answer->answer, $answer->answerformat, $formatoptions, $cmoptions->course);
$anss[] = clone($a);
}
}
include("$CFG->dirroot/question/type/missingtype/display.html");
}
function grade_responses(&$question, &$state, $cmoptions) {
return true;
}
function display_question_editing_page(&$mform, $question, $wizardnow){
global $OUTPUT;
echo $OUTPUT->heading(get_string('warningmissingtype', 'qtype_missingtype'));
$mform->display();
}
}
//// END OF CLASS ////
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
question_register_questiontype(new question_missingtype_qtype());