PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/mod/workshop/form/numerrors/assessment_form.php

https://bitbucket.org/synergylearning/campusconnect
PHP | 85 lines | 33 code | 13 blank | 39 comment | 2 complexity | ab3035694e618883241e08967b230a14 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 assess a submission by numerrors grading strategy
  18. *
  19. * @package workshopform_numerrors
  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__)).'/assessment_form.php'); // parent class definition
  25. /**
  26. * Class representing a form for assessing submissions by numerrors grading strategy
  27. *
  28. * @uses moodleform
  29. */
  30. class workshop_numerrors_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. for ($i = 0; $i < $nodims; $i++) {
  45. // dimension header
  46. $dimtitle = get_string('dimensionnumber', 'workshopform_numerrors', $i+1);
  47. $mform->addElement('header', "dimensionhdr__idx_$i", $dimtitle);
  48. // dimension id
  49. $mform->addElement('hidden', 'dimensionid__idx_'.$i, $fields->{'dimensionid__idx_'.$i});
  50. $mform->setType('dimensionid__idx_'.$i, PARAM_INT);
  51. // grade id
  52. $mform->addElement('hidden', 'gradeid__idx_'.$i); // value set by set_data() later
  53. $mform->setType('gradeid__idx_'.$i, PARAM_INT);
  54. // dimension description
  55. $desc = '<div id="id_dim_'.$fields->{'dimensionid__idx_'.$i}.'_desc" class="fitem description numerrors">'."\n";
  56. $desc .= format_text($fields->{'description__idx_'.$i}, $fields->{'description__idx_'.$i.'format'});
  57. $desc .= "\n</div>";
  58. $mform->addElement('html', $desc);
  59. // evaluation of the assertion
  60. $label = get_string('dimensiongrade', 'workshopform_numerrors');
  61. $mform->addGroup(array(
  62. $mform->createElement('radio', 'grade__idx_' . $i, '', $fields->{'grade0__idx_'.$i}, -1),
  63. $mform->createElement('radio', 'grade__idx_' . $i, '', $fields->{'grade1__idx_'.$i}, 1),
  64. ), 'group_grade__idx_' . $i, get_string('yourassessment', 'workshop'), '<br />', false);
  65. $mform->addRule('group_grade__idx_' . $i, get_string('required'), 'required');
  66. // comment
  67. $label = get_string('dimensioncomment', 'workshopform_numerrors');
  68. $mform->addElement('textarea', 'peercomment__idx_' . $i, $label, array('cols' => 60, 'rows' => 5));
  69. }
  70. $this->set_data($current);
  71. }
  72. }