PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/grade/edit/letter/edit_form.php

https://bitbucket.org/synergylearning/campusconnect
PHP | 92 lines | 48 code | 19 blank | 25 comment | 10 complexity | d87a4b25543b51493bd77f02a0f75da1 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. * A moodleform for editing grade letters
  18. *
  19. * @package core_grades
  20. * @copyright 2007 Petr Skoda
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. if (!defined('MOODLE_INTERNAL')) {
  24. die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
  25. }
  26. require_once $CFG->libdir.'/formslib.php';
  27. class edit_letter_form extends moodleform {
  28. public function definition() {
  29. $mform =& $this->_form;
  30. $num = $this->_customdata['num'];
  31. $admin = $this->_customdata['admin'];
  32. $mform->addElement('header', 'gradeletters', get_string('gradeletters', 'grades'));
  33. // Only show "override site defaults" checkbox if editing the course grade letters
  34. if (!$admin) {
  35. $mform->addElement('checkbox', 'override', get_string('overridesitedefaultgradedisplaytype', 'grades'));
  36. $mform->addHelpButton('override', 'overridesitedefaultgradedisplaytype', 'grades');
  37. }
  38. $gradeletter = get_string('gradeletter', 'grades');
  39. $gradeboundary = get_string('gradeboundary', 'grades');
  40. $percentages = array(-1 => get_string('unused', 'grades'));
  41. for ($i=100; $i > -1; $i--) {
  42. $percentages[$i] = "$i %";
  43. }
  44. for($i=1; $i<$num+1; $i++) {
  45. $gradelettername = 'gradeletter'.$i;
  46. $gradeboundaryname = 'gradeboundary'.$i;
  47. $mform->addElement('text', $gradelettername, $gradeletter." $i");
  48. if ($i == 1) {
  49. $mform->addHelpButton($gradelettername, 'gradeletter', 'grades');
  50. }
  51. $mform->setType($gradelettername, PARAM_TEXT);
  52. if (!$admin) {
  53. $mform->disabledIf($gradelettername, 'override', 'notchecked');
  54. $mform->disabledIf($gradelettername, $gradeboundaryname, 'eq', -1);
  55. }
  56. $mform->addElement('select', $gradeboundaryname, $gradeboundary." $i", $percentages);
  57. if ($i == 1) {
  58. $mform->addHelpButton($gradeboundaryname, 'gradeboundary', 'grades');
  59. }
  60. $mform->setDefault($gradeboundaryname, -1);
  61. $mform->setType($gradeboundaryname, PARAM_INT);
  62. if (!$admin) {
  63. $mform->disabledIf($gradeboundaryname, 'override', 'notchecked');
  64. }
  65. }
  66. // hidden params
  67. $mform->addElement('hidden', 'id');
  68. $mform->setType('id', PARAM_INT);
  69. //-------------------------------------------------------------------------------
  70. // buttons
  71. $this->add_action_buttons(!$admin);
  72. }
  73. }