Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MDL-42494 Fix workshop coding exception if all assessments have zero …
…weight

If all assessments for the given submission have zero weight, the grading
evaluation plugin "Comparison with the best assessment" is unable to decide on
the average assessment as it ignores those with zero weight. In such rare case,
it makes sense to set the grading grade to null and prevent the coding
exception.
  • Loading branch information
mudrd8mz committed Oct 23, 2013
1 parent 34fb354 commit e01d4a2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mod/workshop/eval/best/lib.php
Expand Up @@ -163,6 +163,16 @@ protected function process_assessments(array $assessments, array $diminfo, stdcl
// get a hypothetical average assessment
$average = $this->average_assessment($assessments);

// if unable to calculate the average assessment, set the grading grades to null
if (is_null($average)) {
foreach ($assessments as $asid => $assessment) {
if (!is_null($assessment->gradinggrade)) {
$DB->set_field('workshop_assessments', 'gradinggrade', null, array('id' => $asid));
}
}
return;
}

// calculate variance of dimension grades
$variances = $this->weighted_variance($assessments);
foreach ($variances as $dimid => $variance) {
Expand Down Expand Up @@ -272,6 +282,8 @@ protected function normalize_grades(array $assessments, array $diminfo) {
* Given a set of a submission's assessments, returns a hypothetical average assessment
*
* The passed structure must be array of assessments objects with ->weight and ->dimgrades properties.
* Returns null if all passed assessments have zero weight as there is nothing to choose
* from then.
*
* @param array $assessments as prepared by {@link self::prepare_data_from_recordset()}
* @return null|stdClass
Expand Down

0 comments on commit e01d4a2

Please sign in to comment.