weekly release 4.0dev
[moodle.git] / question / type / missingtype / questiontype.php
CommitLineData
aeb15530 1<?php
d1b7e03d
TH
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/>.
4eda4eec 16
4eda4eec 17/**
d1b7e03d 18 * Question type class for the 'missingtype' type.
4eda4eec 19 *
7764183a
TH
20 * @package qtype
21 * @subpackage missingtype
22 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4eda4eec 24 */
4eda4eec 25
71534002 26
a17b297d
TH
27defined('MOODLE_INTERNAL') || die();
28
97562c4d 29require_once($CFG->dirroot . '/question/type/questiontypebase.php');
a17b297d 30
d1b7e03d
TH
31/**
32 * Missing question type class
33 *
34 * When we encounter a question of a type that is not currently installed, then
35 * we use this question type class instead so that some of the information about
36 * this question can be seen, and the rest of the system keeps working.
37 *
7764183a
TH
38 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
d1b7e03d
TH
40 */
41class qtype_missingtype extends question_type {
42 public function menu_name() {
a2156789 43 return false;
44 }
71534002 45
d1b7e03d 46 public function is_usable_by_random() {
a2156789 47 return false;
48 }
4eda4eec 49
d1b7e03d
TH
50 public function can_analyse_responses() {
51 return false;
52 }
71534002 53
d1b7e03d
TH
54 public function make_question($questiondata) {
55 $question = parent::make_question($questiondata);
56 $question->questiontext = html_writer::tag('div',
57 get_string('missingqtypewarning', 'qtype_missingtype'),
58 array('class' => 'warning missingqtypewarning')) .
59 $question->questiontext;
60 return $question;
4eda4eec 61 }
62
d1b7e03d
TH
63 public function make_deleted_instance($questionid, $maxmark) {
64 question_bank::load_question_definition_classes('missingtype');
65 $question = new qtype_missingtype_question();
66 $question->id = $questionid;
67 $question->category = null;
68 $question->parent = 0;
69 $question->qtype = question_bank::get_qtype('missingtype');
70 $question->name = get_string('deletedquestion', 'qtype_missingtype');
71 $question->questiontext = get_string('deletedquestiontext', 'qtype_missingtype');
72 $question->questiontextformat = FORMAT_HTML;
73 $question->generalfeedback = '';
74 $question->defaultmark = $maxmark;
75 $question->length = 1;
76 $question->penalty = 0;
77 $question->stamp = '';
78 $question->version = 0;
79 $question->hidden = 0;
80 $question->timecreated = null;
81 $question->timemodified = null;
82 $question->createdby = null;
83 $question->modifiedby = null;
84 return $question;
4eda4eec 85 }
71534002 86
d1b7e03d
TH
87 public function get_random_guess_score($questiondata) {
88 return null;
89 }
71534002 90
72553162 91 public function display_question_editing_page($mform, $question, $wizardnow) {
94814340
TH
92 global $OUTPUT;
93 echo $OUTPUT->heading(get_string('warningmissingtype', 'qtype_missingtype'));
94
71534002 95 $mform->display();
71534002 96 }
4eda4eec 97}