Permalink
Browse files

MDL-52838 workshop: Each criterion > 0 levels

Add validation to the edit assessment form so each criterion in a rubric requires at least one level.
  • Loading branch information...
damyon committed Nov 10, 2017
1 parent 5992720 commit 2fa0109fbf29bca1c846fea3e01a49a068141658
@@ -126,11 +126,13 @@ protected function validation_inner($data, $files) {
}
// Make sure the levels grades are unique within the criterion.
$atleastonelevel = false;
for ($j = 0; isset($data['levelid__idx_'.$i.'__idy_'.$j]); $j++) {
if (0 == strlen(trim($data['definition__idx_'.$i.'__idy_'.$j]))) {
// The level definition is empty and will not be saved.
continue;
}
$atleastonelevel = true;
$levelgrade = $data['grade__idx_'.$i.'__idy_'.$j];
@@ -143,6 +145,9 @@ protected function validation_inner($data, $files) {
$dimgrades[$levelgrade] = $j;
}
}
if (!$atleastonelevel) {
$errors['level__idx_'.$i.'__idy_0'] = get_string('mustdefinelevel', 'workshopform_rubric');
}
}
return $errors;
@@ -34,5 +34,6 @@
$string['levelgroup'] = 'Level grade and definition';
$string['levels'] = 'Levels';
$string['mustbeunique'] = 'Level grades must be unique within a criterion';
$string['mustdefinelevel'] = 'At least one level is required';
$string['mustchooseone'] = 'You have to select one of these items';
$string['pluginname'] = 'Rubric';

0 comments on commit 2fa0109

Please sign in to comment.