From cf3e83945877b654724eb146e8a2f627245c41c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kruli=C5=A1?= Date: Fri, 11 Oct 2024 23:57:43 +0200 Subject: [PATCH] Adding actual point limit into group-user stats. --- app/model/view/GroupViewFactory.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/model/view/GroupViewFactory.php b/app/model/view/GroupViewFactory.php index ed72b5b9..6acd99ed 100644 --- a/app/model/view/GroupViewFactory.php +++ b/app/model/view/GroupViewFactory.php @@ -159,17 +159,21 @@ private function getStudentStatsInternal( } $passesLimit = null; // null = no limit + $limit = null; if ($group->getPointsLimit() !== null && $group->getPointsLimit() > 0) { - $passesLimit = $gainedPoints >= $group->getPointsLimit(); + $limit = $group->getPointsLimit(); + $passesLimit = $gainedPoints >= $limit; } elseif ($group->getThreshold() !== null && $group->getThreshold() > 0) { - $passesLimit = $gainedPoints >= $maxPoints * $group->getThreshold(); + $limit = $maxPoints * $group->getThreshold(); + $passesLimit = $gainedPoints >= $limit; } return [ "userId" => $student->getId(), "groupId" => $group->getId(), "points" => [ "total" => $maxPoints, - "gained" => $gainedPoints + "limit" => $limit, + "gained" => $gainedPoints, ], "hasLimit" => $passesLimit !== null, "passesLimit" => $passesLimit ?? true,