Added question type that is used if a question of unknown type is encountered.
[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 }
21
22 function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) {
23 global $CFG;
24
25 $answers = &$question->options->answers;
26
27 $formatoptions = new stdClass;
28 $formatoptions->noclean = true;
29 $formatoptions->para = false;
30
31 // Print formulation
32 $questiontext = format_text($question->questiontext,
33 $question->questiontextformat,
34 $formatoptions, $cmoptions->course);
35 $image = get_question_image($question, $cmoptions->course);
36
37 // Print each answer in a separate row
38 foreach ($answers as $answer) {
39 $a->text = format_text("$answer->answer", FORMAT_MOODLE, $formatoptions, $cmoptions->course);
40
41 $anss[] = clone($a);
42 }
43 include("$CFG->dirroot/question/type/missingtype/display.html");
44 }
45
46 function grade_responses(&$question, &$state, $cmoptions) {
47 return true;
48 }
49}
50//// END OF CLASS ////
51
52//////////////////////////////////////////////////////////////////////////
53//// INITIATION - Without this line the question type is not in use... ///
54//////////////////////////////////////////////////////////////////////////
55$QTYPES['missingtype']= new question_missingtype_qtype();
56
57?>