PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/mod/quiz/report/grading/gradingsettings_form.php

https://bitbucket.org/synergylearning/campusconnect
PHP | 102 lines | 61 code | 14 blank | 27 comment | 10 complexity | f4518111386a088dae103c8c6ec14bec MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, LGPL-2.1, Apache-2.0, BSD-3-Clause, AGPL-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 defines the setting form for the quiz grading report.
  18. *
  19. * @package quiz_grading
  20. * @copyright 2010 Tim Hunt
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. defined('MOODLE_INTERNAL') || die();
  24. require_once($CFG->libdir . '/formslib.php');
  25. /**
  26. * Quiz grading report settings form.
  27. *
  28. * @copyright 2010 Tim Hunt
  29. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  30. */
  31. class quiz_grading_settings_form extends moodleform {
  32. protected $includeauto;
  33. protected $hidden = array();
  34. protected $counts;
  35. protected $shownames;
  36. protected $showidnumbers;
  37. public function __construct($hidden, $counts, $shownames, $showidnumbers) {
  38. global $CFG;
  39. $this->includeauto = !empty($hidden['includeauto']);
  40. $this->hidden = $hidden;
  41. $this->counts = $counts;
  42. $this->shownames = $shownames;
  43. $this->showidnumbers = $showidnumbers;
  44. parent::__construct($CFG->wwwroot . '/mod/quiz/report.php', null, 'get');
  45. }
  46. protected function definition() {
  47. $mform = $this->_form;
  48. $mform->addElement('header', 'options', get_string('options', 'quiz_grading'));
  49. $gradeoptions = array();
  50. foreach (array('needsgrading', 'manuallygraded', 'autograded', 'all') as $type) {
  51. if (empty($this->counts->$type)) {
  52. continue;
  53. }
  54. if ($type == 'autograded' && !$this->includeauto) {
  55. continue;
  56. }
  57. $gradeoptions[$type] = get_string('gradeattempts' . $type, 'quiz_grading',
  58. $this->counts->$type);
  59. }
  60. $mform->addElement('select', 'grade', get_string('attemptstograde', 'quiz_grading'),
  61. $gradeoptions);
  62. $mform->addElement('text', 'pagesize', get_string('questionsperpage', 'quiz_grading'),
  63. array('size' => 3));
  64. $mform->setType('pagesize', PARAM_INT);
  65. $orderoptions = array(
  66. 'random' => get_string('randomly', 'quiz_grading'),
  67. 'date' => get_string('bydate', 'quiz_grading'),
  68. );
  69. if ($this->shownames) {
  70. $orderoptions['studentfirstname'] = get_string('bystudentfirstname', 'quiz_grading');
  71. $orderoptions['studentlastname'] = get_string('bystudentlastname', 'quiz_grading');
  72. }
  73. if ($this->showidnumbers) {
  74. $orderoptions['idnumber'] = get_string('bystudentidnumber', 'quiz_grading');
  75. }
  76. $mform->addElement('select', 'order', get_string('orderattempts', 'quiz_grading'),
  77. $orderoptions);
  78. foreach ($this->hidden as $name => $value) {
  79. $mform->addElement('hidden', $name, $value);
  80. if ($name == 'mode') {
  81. $mform->setType($name, PARAM_ALPHA);
  82. } else {
  83. $mform->setType($name, PARAM_INT);
  84. }
  85. }
  86. $mform->addElement('submit', 'submitbutton', get_string('changeoptions', 'quiz_grading'));
  87. }
  88. }