PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/mod/workshop/form/rubric/edit_form.php

https://bitbucket.org/synergylearning/campusconnect
PHP | 106 lines | 59 code | 13 blank | 34 comment | 8 complexity | 89e98b885c18d36a2cbd6a7e016fc85d 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 an mform to edit rubric grading strategy forms.
  18. *
  19. * @package workshopform_rubric
  20. * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. defined('MOODLE_INTERNAL') || die();
  24. require_once(dirname(dirname(__FILE__)).'/edit_form.php'); // parent class definition
  25. /**
  26. * Class for editing rubric grading strategy forms.
  27. *
  28. * @uses moodleform
  29. */
  30. class workshop_edit_rubric_strategy_form extends workshop_edit_strategy_form {
  31. const MINLEVELS = 4;
  32. const ADDLEVELS = 2;
  33. /**
  34. * Define the elements to be displayed at the form
  35. *
  36. * Called by the parent::definition()
  37. *
  38. * @return void
  39. */
  40. protected function definition_inner(&$mform) {
  41. $norepeats = $this->_customdata['norepeats']; // number of dimensions to display
  42. $descriptionopts = $this->_customdata['descriptionopts']; // wysiwyg fields options
  43. $current = $this->_customdata['current']; // current data to be set
  44. $mform->addElement('hidden', 'norepeats', $norepeats);
  45. $mform->setType('norepeats', PARAM_INT);
  46. // value not to be overridden by submitted value
  47. $mform->setConstants(array('norepeats' => $norepeats));
  48. $levelgrades = array();
  49. for ($i = 100; $i >= 0; $i--) {
  50. $levelgrades[$i] = $i;
  51. }
  52. for ($i = 0; $i < $norepeats; $i++) {
  53. $mform->addElement('header', 'dimension'.$i, get_string('dimensionnumber', 'workshopform_rubric', $i+1));
  54. $mform->addElement('hidden', 'dimensionid__idx_'.$i);
  55. $mform->setType('dimensionid__idx_'.$i, PARAM_INT);
  56. $mform->addElement('editor', 'description__idx_'.$i.'_editor',
  57. get_string('dimensiondescription', 'workshopform_rubric'), '', $descriptionopts);
  58. if (isset($current->{'numoflevels__idx_' . $i})) {
  59. $numoflevels = max($current->{'numoflevels__idx_' . $i} + self::ADDLEVELS, self::MINLEVELS);
  60. } else {
  61. $numoflevels = self::MINLEVELS;
  62. }
  63. $prevlevel = -1;
  64. for ($j = 0; $j < $numoflevels; $j++) {
  65. $mform->addElement('hidden', 'levelid__idx_' . $i . '__idy_' . $j);
  66. $mform->setType('levelid__idx_' . $i . '__idy_' . $j, PARAM_INT);
  67. $levelgrp = array();
  68. $levelgrp[] = $mform->createElement('select', 'grade__idx_'.$i.'__idy_'.$j,'', $levelgrades);
  69. $levelgrp[] = $mform->createElement('textarea', 'definition__idx_'.$i.'__idy_'.$j, '', array('cols' => 60, 'rows' => 3));
  70. $mform->addGroup($levelgrp, 'level__idx_'.$i.'__idy_'.$j, get_string('levelgroup', 'workshopform_rubric'), array(' '), false);
  71. $mform->setDefault('grade__idx_'.$i.'__idy_'.$j, $prevlevel + 1);
  72. if (isset($current->{'grade__idx_'.$i.'__idy_'.$j})) {
  73. $prevlevel = $current->{'grade__idx_'.$i.'__idy_'.$j};
  74. } else {
  75. $prevlevel++;
  76. }
  77. }
  78. }
  79. $mform->registerNoSubmitButton('adddims');
  80. $mform->addElement('submit', 'adddims', get_string('addmoredimensions', 'workshopform_rubric',
  81. workshop_rubric_strategy::ADDDIMS));
  82. $mform->closeHeaderBefore('adddims');
  83. $mform->addElement('header', 'configheader', get_string('configuration', 'workshopform_rubric'));
  84. $layoutgrp = array();
  85. $layoutgrp[] = $mform->createElement('radio', 'config_layout', '',
  86. get_string('layoutlist', 'workshopform_rubric'), 'list');
  87. $layoutgrp[] = $mform->createElement('radio', 'config_layout', '',
  88. get_string('layoutgrid', 'workshopform_rubric'), 'grid');
  89. $mform->addGroup($layoutgrp, 'layoutgrp', get_string('layout', 'workshopform_rubric'), array('<br />'), false);
  90. $mform->setDefault('config_layout', 'list');
  91. $this->set_data($current);
  92. }
  93. }