Skip to content

Commit

Permalink
MDL-30006 Workshop / Accumulative grading: force graders to actually …
Browse files Browse the repository at this point in the history
…pick a grade

This patch introduces a new hidden field with the value "-1". The grade
selectors are compared with this values and must be greater than it.
This should fit well for numerical grades with the range 0..x and scale
items with the range 1..x.
  • Loading branch information
mudrd8mz committed Oct 30, 2011
1 parent 38e9a1c commit 60a3e80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mod/workshop/form/accumulative/assessment_form.php
Expand Up @@ -50,6 +50,12 @@ protected function definition_inner(&$mform) {
$mform->addElement('hidden', 'nodims', $nodims);
$mform->setType('nodims', PARAM_INT);

// minimal grade value to select - used by the 'compare' rule below
// (just an implementation detail to make the rule work, this element is
// not processed by the server)
$mform->addElement('hidden', 'minusone', -1);
$mform->setType('minusone', PARAM_INT);

for ($i = 0; $i < $nodims; $i++) {
// dimension header
$dimtitle = get_string('dimensionnumber', 'workshopform_accumulative', $i+1);
Expand All @@ -72,7 +78,9 @@ protected function definition_inner(&$mform) {
// grade for this aspect
$label = get_string('dimensiongrade', 'workshopform_accumulative');
$options = make_grades_menu($fields->{'grade__idx_' . $i});
$options = array('-1' => get_string('choosedots')) + $options;
$mform->addElement('select', 'grade__idx_' . $i, $label, $options);
$mform->addRule(array('grade__idx_' . $i, 'minusone') , get_string('mustchoosegrade', 'workshopform_accumulative'), 'compare', 'gt');

// comment
$label = get_string('dimensioncomment', 'workshopform_accumulative');
Expand Down
Expand Up @@ -36,6 +36,7 @@
$string['excellent'] = 'Excellent';
$string['good'] = 'Good';
$string['incorrect'] = 'Incorrect';
$string['mustchoosegrade'] = 'You have to select a grade for this aspect';
$string['pluginname'] = 'Accumulative grading';
$string['poor'] = 'Poor';
$string['present'] = 'Present';
Expand Down

0 comments on commit 60a3e80

Please sign in to comment.