mirror of
https://github.com/moodle/moodle.git
synced 2025-06-01 21:55:12 +02:00
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.
This commit is contained in:
parent
34fb3545ea
commit
e01d4a2236
@ -163,6 +163,16 @@ class workshop_best_evaluation extends workshop_evaluation {
|
||||
// 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 @@ class workshop_best_evaluation extends workshop_evaluation {
|
||||
* 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user