Skip to content
Snippets Groups Projects
Commit 6a50c2e1 authored by Marcus Eibrink-Lunzenauer's avatar Marcus Eibrink-Lunzenauer
Browse files

Hide not yet active task groups for solvers.

parent 011e2d51
No related branches found
No related tags found
No related merge requests found
...@@ -77,9 +77,10 @@ class TasksIndex extends JsonApiController ...@@ -77,9 +77,10 @@ class TasksIndex extends JsonApiController
} }
} }
private function findTasksByCourse(\Course $course): \SimpleCollection private function findTasksByCourse(\Course $course, bool $showNotYetActive = true): \SimpleCollection
{ {
$taskGroups = TaskGroup::findBySQL('seminar_id = ?', [$course->getId()]); $whereClause = $showNotYetActive ? 'seminar_id = ?' : 'start_date <= UNIX_TIMESTAMP() AND seminar_id = ?';
$taskGroups = TaskGroup::findBySQL($whereClause, [$course->getId()]);
$tasks = []; $tasks = [];
foreach ($taskGroups as $taskGroup) { foreach ($taskGroups as $taskGroup) {
...@@ -98,7 +99,7 @@ class TasksIndex extends JsonApiController ...@@ -98,7 +99,7 @@ class TasksIndex extends JsonApiController
}) })
->pluck('id'); ->pluck('id');
return $this->findTasksByCourse($course)->filter(function ($task) use ($user, $groupIds) { return $this->findTasksByCourse($course, false)->filter(function ($task) use ($user, $groupIds) {
return ('autor' === $task['solver_type'] && $task['solver_id'] === $user->getId()) || return ('autor' === $task['solver_type'] && $task['solver_id'] === $user->getId()) ||
('group' === $task['solver_type'] && in_array($task['solver_id'], $groupIds)); ('group' === $task['solver_type'] && in_array($task['solver_id'], $groupIds));
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment