Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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...
commit 30f8726bed467d47f14544befb0473f853ae3bce 1 parent 1115bb3
@mudrd8mz mudrd8mz authored
Showing with 12 additions and 0 deletions.
  1. +12 −0 mod/workshop/eval/best/lib.php
View
12 mod/workshop/eval/best/lib.php
@@ -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) {
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.