Skip to content

Commit 48524fe

Browse files
committed
CTP-3560 avoid PHPUnit errors 3
1 parent e830d64 commit 48524fe

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

classes/grade_judge.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ public function get_grade_capped_by_submission_time($submission) {
6565
}
6666

6767
/**
68-
* @param $grade
68+
* @param int|float $grade
6969
* @return float
7070
*/
7171
private function round_grade_decimals($grade) {
72-
if ($grade !== null) {
73-
return round($grade, 2);
72+
if ($grade === '' || $grade === null) {
73+
// Avoid PHPUnit exception passing null or empty string to round().
74+
return null;
7475
}
76+
return round($grade, 2);
7577
}
7678

7779
/**

0 commit comments

Comments
 (0)