Skip to content

Commit

Permalink
Adding actual point limit into group-user stats.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed Oct 11, 2024
1 parent 983f8ad commit cf3e839
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/model/view/GroupViewFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit cf3e839

Please sign in to comment.