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
 * Question type class for the 'missingtype' type.
19
 *
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
24
 */
25
 
26
 
27
defined('MOODLE_INTERNAL') || die();
28
 
29
require_once($CFG->dirroot . '/question/type/questiontypebase.php');
30
 
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
 *
38
 * @copyright  1999 onwards Martin Dougiamas  {@link http://moodle.com}
39
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40
 */
41
class qtype_missingtype extends question_type {
42
    public function menu_name() {
43
        return false;
44
    }
45
 
46
    public function is_usable_by_random() {
47
        return false;
48
    }
49
 
50
    public function can_analyse_responses() {
51
        return false;
52
    }
53
 
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;
61
    }
62
 
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->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
79
        $question->timecreated = null;
80
        $question->timemodified = null;
81
        $question->createdby = null;
82
        $question->modifiedby = null;
83
        return $question;
84
    }
85
 
86
    public function get_random_guess_score($questiondata) {
87
        return null;
88
    }
89
 
90
    public function display_question_editing_page($mform, $question, $wizardnow) {
91
        global $OUTPUT;
92
        echo $OUTPUT->heading(get_string('warningmissingtype', 'qtype_missingtype'));
93
 
94
        $mform->display();
95
    }
96
}