Fix for MDL-8175 (void summary)
[moodle.git] / question / type / missingtype / questiontype.php
CommitLineData
4eda4eec 1<?php // $Id$
2
3///////////////////
4/// missingtype ///
5///////////////////
6
7/// QUESTION TYPE CLASS //////////////////
8
9/**
10 * Missing question type class
11 *
12 * When a question is encountered with a type that is not installed then its
13 * type is changed to 'missingtype'. This questiontype just makes sure that the
14 * necessary information is printed about the question.
15 */
16class question_missingtype_qtype extends default_questiontype {
17
18 function name() {
19 return 'missingtype';
20 }
a2156789 21
22 function menu_name() {
23 return false;
24 }
25
26 function is_usable_by_random() {
27 return false;
28 }
4eda4eec 29
30 function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) {
31 global $CFG;
32
33 $answers = &$question->options->answers;
34
35 $formatoptions = new stdClass;
36 $formatoptions->noclean = true;
37 $formatoptions->para = false;
38
39 // Print formulation
40 $questiontext = format_text($question->questiontext,
41 $question->questiontextformat,
42 $formatoptions, $cmoptions->course);
43 $image = get_question_image($question, $cmoptions->course);
44
2be604b6 45 // Print each answer in a separate row if there are any
46 $anss = array();
47 if ($answers) {
48 foreach ($answers as $answer) {
d7444d44 49 $a = new stdClass;
2be604b6 50 $a->text = format_text("$answer->answer", FORMAT_MOODLE, $formatoptions, $cmoptions->course);
51
52 $anss[] = clone($a);
53 }
4eda4eec 54 }
55 include("$CFG->dirroot/question/type/missingtype/display.html");
56 }
57
58 function grade_responses(&$question, &$state, $cmoptions) {
59 return true;
60 }
61}
62//// END OF CLASS ////
63
64//////////////////////////////////////////////////////////////////////////
65//// INITIATION - Without this line the question type is not in use... ///
66//////////////////////////////////////////////////////////////////////////
a2156789 67question_register_questiontype(new question_missingtype_qtype());
4eda4eec 68
69?>