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.
   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 comments grading strategy forms.
  20   *
  21   * @package    workshopform_comments
  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 comments grading strategy forms.
  33   *
  34   * @uses moodleform
  35   */
  36  class workshop_edit_comments_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_comments', $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_comments'), '', $descriptionopts);
  62          }
  63  
  64          $mform->registerNoSubmitButton('noadddims');
  65          $mform->addElement('submit', 'noadddims', get_string('addmoredimensions', 'workshopform_comments',
  66                  workshop_comments_strategy::ADDDIMS));
  67          $mform->closeHeaderBefore('noadddims');
  68          $this->set_data($current);
  69      }
  70  }