Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

   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->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;
  85      }
  86  
  87      public function get_random_guess_score($questiondata) {
  88          return null;
  89      }
  90  
  91      public function display_question_editing_page($mform, $question, $wizardnow) {
  92          global $OUTPUT;
  93          echo $OUTPUT->heading(get_string('warningmissingtype', 'qtype_missingtype'));
  94  
  95          $mform->display();
  96      }
  97  }