diff options
| author | Viktoria Wiebe <vwiebe@uni-osnabrueck.de> | 2024-10-01 14:07:24 +0000 |
|---|---|---|
| committer | Ron Lucke <lucke@elan-ev.de> | 2024-10-01 14:07:24 +0000 |
| commit | 332f5ef297815502adbc79df6aa4962688a9aebc (patch) | |
| tree | f869d6ef1666f5a43e5ead85b19c8804dcff5d80 /lib/models/Courseware/Task.php | |
| parent | 7a924cef24ce44013e6da5295651d02c9f88ec38 (diff) | |
Tic 2807 - add toggling task visibility functionality to student task dashboard
Closes #2807
Merge request studip/studip!3096
Diffstat (limited to 'lib/models/Courseware/Task.php')
| -rw-r--r-- | lib/models/Courseware/Task.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/models/Courseware/Task.php b/lib/models/Courseware/Task.php index d409676..2a1a28d 100644 --- a/lib/models/Courseware/Task.php +++ b/lib/models/Courseware/Task.php @@ -21,6 +21,7 @@ use User; * @property int $submitted database column * @property string|null $renewal database column * @property int $renewal_date database column + * @property int $visible database column * @property int|null $feedback_id database column * @property int $mkdate database column * @property int $chdate database column @@ -90,6 +91,11 @@ class Task extends \SimpleORMap parent::configure($config); } + public function getTaskGroup(): TaskGroup + { + return $this->task_group; + } + /** * Returns the structural element of this task. * This structural element and all its children are part of the task. @@ -130,6 +136,16 @@ class Task extends \SimpleORMap if ($this->solver_id === $user->id) { return true; } + + if ($this->visible) { + $solvers = $this->getTaskGroup()->getSolvers(); + foreach ($solvers as $solver) { + if ($solver->id === $user->id) { + return true; + } + } + } + break; case 'group': @@ -235,6 +251,12 @@ class Task extends \SimpleORMap $this->store(); } + public function setVisibility(bool $visibility): void + { + $this->visible = (int) $visibility; + $this->store(); + } + private function getStructuralElementProgress(StructuralElement $structural_element): float { $containers = Container::findBySQL('structural_element_id = ?', [intval($structural_element->id)]); |
