Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * This file defines an mform to edit accumulative grading strategy forms.
  20   *
  21   * @package    workshopform_accumulative
  22   * @copyright  2009 David Mudrak <david.mudrak@gmail.com>
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  defined('MOODLE_INTERNAL') || die();
  27  
  28  require_once (__DIR__.'/../../lib.php');   // module library
  29  require_once (__DIR__.'/../edit_form.php');    // parent class definition
  30  
  31  /**
  32   * Class for editing accumulative grading strategy forms.
  33   *
  34   * @uses moodleform
  35   */
  36  class workshop_edit_accumulative_strategy_form extends workshop_edit_strategy_form {
  37  
  38      /**
  39       * Define the elements to be displayed at the form
  40       *
  41       * Called by the parent::definition()
  42       *
  43       * @return void
  44       */
  45      protected function definition_inner(&$mform) {
  46  
  47          $norepeats          = $this->_customdata['norepeats'];          // number of dimensions to display
  48          $descriptionopts    = $this->_customdata['descriptionopts'];    // wysiwyg fields options
  49          $current            = $this->_customdata['current'];            // current data to be set
  50  
  51          $mform->addElement('hidden', 'norepeats', $norepeats);
  52          $mform->setType('norepeats', PARAM_INT);
  53          // value not to be overridden by submitted value
  54          $mform->setConstants(array('norepeats' => $norepeats));
  55  
  56          for ($i = 0; $i < $norepeats; $i++) {
  57              $mform->addElement('header', 'dimension'.$i, get_string('dimensionnumber', 'workshopform_accumulative', $i+1));
  58              $mform->addElement('hidden', 'dimensionid__idx_'.$i);
  59              $mform->setType('dimensionid__idx_'.$i, PARAM_INT);
  60              $mform->addElement('editor', 'description__idx_'.$i.'_editor',
  61                      get_string('dimensiondescription', 'workshopform_accumulative'), '', $descriptionopts);
  62              // todo replace modgrade with an advanced element (usability issue discussed with Olli)
  63              $mform->addElement('modgrade', 'grade__idx_'.$i,
  64                      get_string('dimensionmaxgrade','workshopform_accumulative'), null, true);
  65              $mform->setDefault('grade__idx_'.$i, 10);
  66              $mform->addElement('select', 'weight__idx_'.$i,
  67                      get_string('dimensionweight', 'workshopform_accumulative'), workshop::available_dimension_weights_list());
  68              $mform->setDefault('weight__idx_'.$i, 1);
  69          }
  70  
  71          $mform->registerNoSubmitButton('noadddims');
  72          $mform->addElement('submit', 'noadddims', get_string('addmoredimensions', 'workshopform_accumulative',
  73                  workshop_accumulative_strategy::ADDDIMS));
  74          $mform->closeHeaderBefore('noadddims');
  75          $this->set_data($current);
  76      }
  77  }