From 112f7d41eaed73924716f5a19de79310f2367775 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Sun, 30 Oct 2011 18:57:57 +0100 Subject: [PATCH] MDL-30006 Workshop / Accumulative grading: force graders to actually 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. --- mod/workshop/form/accumulative/assessment_form.php | 8 ++++++++ .../accumulative/lang/en/workshopform_accumulative.php | 1 + 2 files changed, 9 insertions(+) diff --git a/mod/workshop/form/accumulative/assessment_form.php b/mod/workshop/form/accumulative/assessment_form.php index 375057e98b9..242690d5ab7 100644 --- a/mod/workshop/form/accumulative/assessment_form.php +++ b/mod/workshop/form/accumulative/assessment_form.php @@ -50,6 +50,12 @@ class workshop_accumulative_assessment_form extends workshop_assessment_form { $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); @@ -72,7 +78,9 @@ class workshop_accumulative_assessment_form extends workshop_assessment_form { // 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'); diff --git a/mod/workshop/form/accumulative/lang/en/workshopform_accumulative.php b/mod/workshop/form/accumulative/lang/en/workshopform_accumulative.php index 2ad7ca92fda..2ad796a9356 100644 --- a/mod/workshop/form/accumulative/lang/en/workshopform_accumulative.php +++ b/mod/workshop/form/accumulative/lang/en/workshopform_accumulative.php @@ -36,6 +36,7 @@ $string['dimensionweight'] = 'Weight'; $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';