Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 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  namespace qbank_previewquestion\form;
  18  
  19  defined('MOODLE_INTERNAL') || die();
  20  
  21  require_once($CFG->libdir . '/formslib.php');
  22  
  23  use moodleform;
  24  use question_display_options;
  25  use question_engine;
  26  use qbank_previewquestion\question_preview_options;
  27  
  28  /**
  29   * Settings form for the preview options.
  30   *
  31   * @package    qbank_previewquestion
  32   * @copyright  2009 The Open University
  33   * @author     2021 Safat Shahin <safatshahin@catalyst-au.net>
  34   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  35   */
  36  class preview_options_form extends moodleform {
  37  
  38      public function definition() {
  39          $mform = $this->_form;
  40  
  41          $hiddenorvisible = [
  42                  question_display_options::HIDDEN => get_string('notshown', 'question'),
  43                  question_display_options::VISIBLE => get_string('shown', 'question'),
  44          ];
  45  
  46          $mform->addElement('header', 'attemptoptionsheader', get_string('previewoptions', 'qbank_previewquestion'));
  47          $mform->setExpanded('attemptoptionsheader', false);
  48          $versions = $this->_customdata['versions'];
  49          $versions[question_preview_options::ALWAYS_LATEST] = get_string('alwayslatest', 'qbank_previewquestion');
  50          $currentversion = $this->_customdata['restartversion'];
  51          $select = $mform->addElement('select', 'restartversion', get_string('questionversion', 'qbank_previewquestion'), $versions);
  52          $select->setSelected($currentversion);
  53          $behaviours = question_engine::get_behaviour_options(
  54                  $this->_customdata['quba']->get_preferred_behaviour());
  55          $mform->addElement('select', 'behaviour',
  56                  get_string('howquestionsbehave', 'question'), $behaviours);
  57          $mform->addHelpButton('behaviour', 'howquestionsbehave', 'question');
  58  
  59          $mform->addElement('float', 'maxmark', get_string('markedoutof', 'question'), ['size' => '5']);
  60  
  61          if ($this->_customdata['maxvariant'] > 1) {
  62              $variants = range(1, $this->_customdata['maxvariant']);
  63              $mform->addElement('select', 'variant', get_string('questionvariant', 'question'),
  64                      array_combine($variants, $variants));
  65          }
  66          $mform->setType('variant', PARAM_INT);
  67  
  68          $mform->addElement('submit', 'saverestart',
  69                  get_string('restartwiththeseoptions', 'question'));
  70  
  71          $mform->addElement('header', 'displayoptionsheader', get_string('displayoptions', 'question'));
  72          $mform->setExpanded('displayoptionsheader', false);
  73  
  74          $mform->addElement('select', 'correctness', get_string('whethercorrect', 'question'),
  75                  $hiddenorvisible);
  76  
  77          $marksoptions = [
  78                  question_display_options::HIDDEN => get_string('notshown', 'question'),
  79                  question_display_options::MAX_ONLY => get_string('showmaxmarkonly', 'question'),
  80                  question_display_options::MARK_AND_MAX => get_string('showmarkandmax', 'question'),
  81          ];
  82          $mform->addElement('select', 'marks', get_string('marks', 'question'), $marksoptions);
  83  
  84          $mform->addElement('select', 'markdp', get_string('decimalplacesingrades', 'question'),
  85                  question_engine::get_dp_options());
  86  
  87          $mform->addElement('select', 'feedback',
  88                  get_string('specificfeedback', 'question'), $hiddenorvisible);
  89  
  90          $mform->addElement('select', 'generalfeedback',
  91                  get_string('generalfeedback', 'question'), $hiddenorvisible);
  92  
  93          $mform->addElement('select', 'rightanswer',
  94                  get_string('rightanswer', 'question'), $hiddenorvisible);
  95  
  96          $mform->addElement('select', 'history',
  97                  get_string('responsehistory', 'question'), $hiddenorvisible);
  98  
  99          $mform->addElement('submit', 'saveupdate',
 100                  get_string('updatedisplayoptions', 'question'));
 101      }
 102  
 103  }