PageRenderTime 40ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/mod/assign/gradingoptionsform.php

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