*
* @param \stdClass $grade
* @param \stdClass $user
- * @return int
+ * @return int|null
*/
-function grade_get_date_for_user_grade(\stdClass $grade, \stdClass $user): int {
+function grade_get_date_for_user_grade(\stdClass $grade, \stdClass $user): ?int {
// The `datesubmitted` is the time that the grade was created.
// The `dategraded` is the time that it was modified or overwritten.
// If the grade was last modified by the user themselves use the date graded.
* @param stdClass $user
* @param int $expected
*/
- public function test_grade_get_date_for_user_grade(stdClass $grade, stdClass $user, int $expected): void {
+ public function test_grade_get_date_for_user_grade(stdClass $grade, stdClass $user, ?int $expected): void {
$this->assertEquals($expected, grade_get_date_for_user_grade($grade, $user));
}
'datesubmitted' => 0,
];
+ $g3 = (object) [
+ 'usermodified' => $u1->id,
+ 'dategraded' => null,
+ 'datesubmitted' => $d2,
+ ];
+
return [
'If the user is the last person to have modified the grade_item then show the date that it was graded' => [
$g1,
$u1,
$d1,
],
+ 'If there is no grade and there is no feedback, then show graded date as null' => [
+ $g3,
+ $u1,
+ null,
+ ],
'If the user is not the last person to have modified the grade_item, ' .
'and there is no submission date, then show the date that it was submitted' => [
$g1,