Merge branch 'MDL-30006-workshop-grades' of git://github.com/mudrd8mz/moodle

This commit is contained in:
Sam Hemelryk 2011-10-31 13:06:10 +13:00
commit cdf30a11a8
4 changed files with 16 additions and 5 deletions

View File

@ -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');

View File

@ -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';

View File

@ -71,9 +71,11 @@ class workshop_numerrors_assessment_form extends workshop_assessment_form {
// evaluation of the assertion
$label = get_string('dimensiongrade', 'workshopform_numerrors');
$mform->addElement('radio', 'grade__idx_' . $i, get_string('yourassessment', 'workshop'), $fields->{'grade0__idx_'.$i}, 0);
$mform->addElement('radio', 'grade__idx_' . $i, '', $fields->{'grade1__idx_'.$i}, 1);
$mform->setDefault('grade__idx_' . $i, 0);
$mform->addGroup(array(
$mform->createElement('radio', 'grade__idx_' . $i, '', $fields->{'grade0__idx_'.$i}, -1),
$mform->createElement('radio', 'grade__idx_' . $i, '', $fields->{'grade1__idx_'.$i}, 1),
), 'group_grade__idx_' . $i, get_string('yourassessment', 'workshop'), '<br />', false);
$mform->addRule('group_grade__idx_' . $i, get_string('required'), 'required');
// comment
$label = get_string('dimensioncomment', 'workshopform_numerrors');

View File

@ -252,7 +252,7 @@ class workshop_numerrors_strategy implements workshop_strategy {
$dimid = $fields->{'dimensionid__idx_'.$i};
if (isset($grades[$dimid])) {
$current->{'gradeid__idx_'.$i} = $grades[$dimid]->id;
$current->{'grade__idx_'.$i} = $grades[$dimid]->grade;
$current->{'grade__idx_'.$i} = ($grades[$dimid]->grade == 0 ? -1 : 1);
$current->{'peercomment__idx_'.$i} = $grades[$dimid]->peercomment;
}
}
@ -294,7 +294,7 @@ class workshop_numerrors_strategy implements workshop_strategy {
$grade->assessmentid = $assessment->id;
$grade->strategy = 'numerrors';
$grade->dimensionid = $data->{'dimensionid__idx_' . $i};
$grade->grade = $data->{'grade__idx_' . $i};
$grade->grade = ($data->{'grade__idx_' . $i} <= 0 ? 0 : 1);
$grade->peercomment = $data->{'peercomment__idx_' . $i};
$grade->peercommentformat = FORMAT_HTML;
if (empty($grade->id)) {