Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.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 numerrors grading strategy
  20   *
  21   * @package    workshopform_numerrors
  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 numerrors grading strategy
  32   *
  33   * @uses moodleform
  34   */
  35  class workshop_numerrors_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_numerrors', $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 numerrors">'."\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              // evaluation of the assertion
  72              $label = get_string('dimensiongrade', 'workshopform_numerrors');
  73              $mform->addGroup(array(
  74                  $mform->createElement('radio', 'grade__idx_' . $i, '', $fields->{'grade0__idx_'.$i}, -1),
  75                  $mform->createElement('radio', 'grade__idx_' . $i, '', $fields->{'grade1__idx_'.$i}, 1),
  76              ), 'group_grade__idx_' . $i, get_string('yourassessmentfor', 'workshop', $dimtitle), '<br />', false);
  77              $mform->addRule('group_grade__idx_' . $i, get_string('required'), 'required');
  78  
  79              // comment
  80              $label = get_string('dimensioncommentfor', 'workshopform_numerrors', $dimtitle);
  81              $mform->addElement('textarea', 'peercomment__idx_' . $i, $label, array('cols' => 60, 'rows' => 5));
  82          }
  83          $this->set_data($current);
  84      }
  85  }