PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/mod/workshop/form/accumulative/assessment_form.php

https://bitbucket.org/moodle/moodle
PHP | 93 lines | 37 code | 13 blank | 43 comment | 3 complexity | 89cd7b9a982ccef4370c39fc1f65c452 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 defines an mform to assess a submission by accumulative grading strategy
  18. *
  19. * @package workshopform_accumulative
  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(__DIR__.'/../assessment_form.php'); // parent class definition
  25. /**
  26. * Class representing a form for assessing submissions by accumulative grading strategy
  27. *
  28. * @uses moodleform
  29. */
  30. class workshop_accumulative_assessment_form extends workshop_assessment_form {
  31. /**
  32. * Define the elements to be displayed at the form
  33. *
  34. * Called by the parent::definition()
  35. *
  36. * @return void
  37. */
  38. protected function definition_inner(&$mform) {
  39. $fields = $this->_customdata['fields'];
  40. $current = $this->_customdata['current'];
  41. $nodims = $this->_customdata['nodims']; // number of assessment dimensions
  42. $mform->addElement('hidden', 'nodims', $nodims);
  43. $mform->setType('nodims', PARAM_INT);
  44. // minimal grade value to select - used by the 'compare' rule below
  45. // (just an implementation detail to make the rule work, this element is
  46. // not processed by the server)
  47. $mform->addElement('hidden', 'minusone', -1);
  48. $mform->setType('minusone', PARAM_INT);
  49. for ($i = 0; $i < $nodims; $i++) {
  50. // dimension header
  51. $dimtitle = get_string('dimensionnumber', 'workshopform_accumulative', $i+1);
  52. $mform->addElement('header', 'dimensionhdr__idx_'.$i, $dimtitle);
  53. // dimension id
  54. $mform->addElement('hidden', 'dimensionid__idx_'.$i, $fields->{'dimensionid__idx_'.$i});
  55. $mform->setType('dimensionid__idx_'.$i, PARAM_INT);
  56. // grade id
  57. $mform->addElement('hidden', 'gradeid__idx_'.$i); // value set by set_data() later
  58. $mform->setType('gradeid__idx_'.$i, PARAM_INT);
  59. // dimension description
  60. $desc = '<div id="id_dim_'.$fields->{'dimensionid__idx_'.$i}.'_desc" class="fitem description accumulative">'."\n";
  61. $desc .= format_text($fields->{'description__idx_'.$i}, $fields->{'description__idx_'.$i.'format'});
  62. $desc .= "\n</div>";
  63. $mform->addElement('html', $desc);
  64. // grade for this aspect
  65. $label = get_string('dimensiongradefor', 'workshopform_accumulative', $dimtitle);
  66. if ($fields->{'grade__idx_' . $i}) {
  67. $options = make_grades_menu($fields->{'grade__idx_' . $i});
  68. $options = array('-1' => get_string('choosedots')) + $options;
  69. $mform->addElement('select', 'grade__idx_' . $i, $label, $options);
  70. $mform->addRule(array('grade__idx_' . $i, 'minusone'),
  71. get_string('mustchoosegrade', 'workshopform_accumulative'), 'compare', 'gt');
  72. }
  73. // comment
  74. $label = get_string('dimensioncommentfor', 'workshopform_accumulative', $dimtitle);
  75. //$mform->addElement('editor', 'peercomment__idx_' . $i, $label, null, array('maxfiles' => 0));
  76. $mform->addElement('textarea', 'peercomment__idx_' . $i, $label, array('cols' => 60, 'rows' => 5));
  77. }
  78. $this->set_data($current);
  79. }
  80. }