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.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

   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  /**
  18   * This file contains the forms to create and edit an instance of this module
  19   *
  20   * @package   mod_assign
  21   * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
  26  
  27  
  28  require_once($CFG->libdir.'/formslib.php');
  29  require_once($CFG->dirroot . '/mod/assign/locallib.php');
  30  
  31  /**
  32   * Assignment grading options form
  33   *
  34   * @package   mod_assign
  35   * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  36   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  37   */
  38  class mod_assign_grading_options_form extends moodleform {
  39      /**
  40       * Define this form - called from the parent constructor.
  41       */
  42      public function definition() {
  43          $mform = $this->_form;
  44          $instance = $this->_customdata;
  45          $dirtyclass = array('class' => 'ignoredirty');
  46  
  47          $mform->addElement('header', 'general', get_string('gradingoptions', 'assign'));
  48          // Visible elements.
  49          $options = array(10 => '10', 20 => '20', 50 => '50', 100 => '100', -1 => get_string('all'));
  50          $maxperpage = get_config('assign', 'maxperpage');
  51          if (isset($maxperpage) && $maxperpage != -1) {
  52              unset($options[-1]);
  53              foreach ($options as $val) {
  54                  if ($val > $maxperpage) {
  55                      unset($options[$val]);
  56                  }
  57              }
  58          }
  59          $mform->addElement('select', 'perpage', get_string('assignmentsperpage', 'assign'), $options, $dirtyclass);
  60          $options = array('' => get_string('filternone', 'assign'),
  61                           ASSIGN_FILTER_NOT_SUBMITTED => get_string('filternotsubmitted', 'assign'),
  62                           ASSIGN_FILTER_DRAFT => get_string('filterdraft', 'assign'),
  63                           ASSIGN_FILTER_SUBMITTED => get_string('filtersubmitted', 'assign'),
  64                           ASSIGN_FILTER_REQUIRE_GRADING => get_string('filterrequiregrading', 'assign'),
  65                           ASSIGN_FILTER_GRANTED_EXTENSION => get_string('filtergrantedextension', 'assign'));
  66          if ($instance['submissionsenabled']) {
  67              $mform->addElement('select', 'filter', get_string('filter', 'assign'), $options, $dirtyclass);
  68          }
  69          if (!empty($instance['markingallocationopt'])) {
  70              $markingfilter = get_string('markerfilter', 'assign');
  71              $mform->addElement('select', 'markerfilter', $markingfilter, $instance['markingallocationopt'], $dirtyclass);
  72          }
  73          if (!empty($instance['markingworkflowopt'])) {
  74              $workflowfilter = get_string('workflowfilter', 'assign');
  75              $mform->addElement('select', 'workflowfilter', $workflowfilter, $instance['markingworkflowopt'], $dirtyclass);
  76          }
  77          // Quickgrading.
  78          if ($instance['showquickgrading']) {
  79              $mform->addElement('checkbox', 'quickgrading', get_string('quickgrading', 'assign'), '', $dirtyclass);
  80              $mform->addHelpButton('quickgrading', 'quickgrading', 'assign');
  81              $mform->setDefault('quickgrading', $instance['quickgrading']);
  82          }
  83  
  84          // Show active/suspended user option.
  85          if ($instance['showonlyactiveenrolopt']) {
  86              $mform->addElement('checkbox', 'showonlyactiveenrol', get_string('showonlyactiveenrol', 'grades'), '', $dirtyclass);
  87              $mform->addHelpButton('showonlyactiveenrol', 'showonlyactiveenrol', 'grades');
  88              $mform->setDefault('showonlyactiveenrol', $instance['showonlyactiveenrol']);
  89          }
  90  
  91          // Place student downloads in seperate folders.
  92          if ($instance['submissionsenabled']) {
  93              $mform->addElement('checkbox', 'downloadasfolders', get_string('downloadasfolders', 'assign'), '', $dirtyclass);
  94              $mform->addHelpButton('downloadasfolders', 'downloadasfolders', 'assign');
  95              $mform->setDefault('downloadasfolders', $instance['downloadasfolders']);
  96          }
  97  
  98          // Hidden params.
  99          $mform->addElement('hidden', 'contextid', $instance['contextid']);
 100          $mform->setType('contextid', PARAM_INT);
 101          $mform->addElement('hidden', 'id', $instance['cm']);
 102          $mform->setType('id', PARAM_INT);
 103          $mform->addElement('hidden', 'userid', $instance['userid']);
 104          $mform->setType('userid', PARAM_INT);
 105          $mform->addElement('hidden', 'action', 'saveoptions');
 106          $mform->setType('action', PARAM_ALPHA);
 107  
 108          // Buttons.
 109          $this->add_action_buttons(false, get_string('updatetable', 'assign'));
 110      }
 111  }
 112