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 assess a submission by comments grading strategy
  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__ . '/../assessment_form.php');    // Parent class definition.
  29  
  30  /**
  31   * Class representing a form for assessing submissions by comments grading strategy
  32   *
  33   * @uses moodleform
  34   */
  35  class workshop_comments_assessment_form extends workshop_assessment_form {
  36  
  37      /**
  38       * Define the elements to be displayed at the form
  39       *
  40       * Called by the parent::definition()
  41       *
  42       * @return void
  43       */
  44      protected function definition_inner(&$mform) {
  45          $fields     = $this->_customdata['fields'];
  46          $current    = $this->_customdata['current'];
  47          $nodims     = $this->_customdata['nodims'];     // number of assessment dimensions
  48  
  49          $mform->addElement('hidden', 'nodims', $nodims);
  50          $mform->setType('nodims', PARAM_INT);
  51  
  52          for ($i = 0; $i < $nodims; $i++) {
  53              // dimension header
  54              $dimtitle = get_string('dimensionnumber', 'workshopform_comments', $i+1);
  55              $mform->addElement('header', 'dimensionhdr__idx_'.$i, $dimtitle);
  56  
  57              // dimension id
  58              $mform->addElement('hidden', 'dimensionid__idx_'.$i, $fields->{'dimensionid__idx_'.$i});
  59              $mform->setType('dimensionid__idx_'.$i, PARAM_INT);
  60  
  61              // grade id
  62              $mform->addElement('hidden', 'gradeid__idx_'.$i);   // value set by set_data() later
  63              $mform->setType('gradeid__idx_'.$i, PARAM_INT);
  64  
  65              // dimension description
  66              $desc = '<div id="id_dim_'.$fields->{'dimensionid__idx_'.$i}.'_desc" class="fitem description comments">'."\n";
  67              $desc .= format_text($fields->{'description__idx_'.$i}, $fields->{'description__idx_'.$i.'format'});
  68              $desc .= "\n</div>";
  69              $mform->addElement('html', $desc);
  70  
  71              // comment
  72              $label = get_string('dimensioncommentfor', 'workshopform_comments', $dimtitle);
  73              //$mform->addElement('editor', 'peercomment__idx_' . $i, $label, null, array('maxfiles' => 0));
  74              $mform->addElement('textarea', 'peercomment__idx_' . $i, $label, array('cols' => 60, 'rows' => 10));
  75              $mform->addRule('peercomment__idx_' . $i, null, 'required', null, 'client');
  76          }
  77          $this->set_data($current);
  78      }
  79  }