diff options
| author | Marcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de> | 2024-01-23 07:41:52 +0000 |
|---|---|---|
| committer | Marcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de> | 2024-01-23 07:41:52 +0000 |
| commit | 1728bc517691b3d0dde5ccdf0c0631ff1b855b6d (patch) | |
| tree | f3ad972dc584dc70c4817405d616558cc1a55061 /lib/models/Courseware/Task.php | |
| parent | 9750421a650a4e4980a1286212661a87eb92905b (diff) | |
Courseware Aufgaben erweitern (StEP3286)
Merge request studip/studip!2445
Diffstat (limited to 'lib/models/Courseware/Task.php')
| -rw-r--r-- | lib/models/Courseware/Task.php | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/lib/models/Courseware/Task.php b/lib/models/Courseware/Task.php index 3a68d3e..d409676 100644 --- a/lib/models/Courseware/Task.php +++ b/lib/models/Courseware/Task.php @@ -31,7 +31,9 @@ use User; * @property \Statusgruppen $group belongs_to \Statusgruppen * @property \Course $course belongs_to \Course * @property TaskFeedback|null $task_feedback belongs_to TaskFeedback - * @property mixed $solver additional field + * @property-read \User|\Statusgruppen|null $solver additional field + * + * @SuppressWarnings(PHPMD.StaticAccess) */ class Task extends \SimpleORMap { @@ -80,6 +82,10 @@ class Task extends \SimpleORMap 'get' => 'getSolver', 'set' => false, ]; + $config['additional_fields']['submission_date'] = [ + 'get' => 'getSubmissionDate', + 'set' => false, + ]; parent::configure($config); } @@ -171,6 +177,11 @@ class Task extends \SimpleORMap return null; } + public function getSubmissionDate(): int + { + return $this->task_group['end_date']; + } + public function getTaskProgress(): float { $children = $this->structural_element->findDescendants(); @@ -185,6 +196,45 @@ class Task extends \SimpleORMap return $progress * 100; } + public function canSubmit(): bool + { + return !$this->submitted + && time() <= ('granted' === $this->renewal ? $this->renewal_date : $this->submission_date); + } + + public function submitTask(): void + { + $this->submitted = 1; + if ('pending' === $this->renewal) { + $this->renewal = ''; + } + $this->store(); + } + + public function isRenewed(): bool + { + return $this->renewal === 'granted'; + } + + public function requestRenewal(): void + { + $this->renewal = 'pending'; + $this->store(); + } + + public function declineRenewalRequest(): void + { + $this->renewal = 'declined'; + $this->store(); + } + + public function grantRenewalRequest(\DateTime $renewalDate): void + { + $this->renewal = 'granted'; + $this->renewal_date = $renewalDate->getTimestamp(); + $this->store(); + } + private function getStructuralElementProgress(StructuralElement $structural_element): float { $containers = Container::findBySQL('structural_element_id = ?', [intval($structural_element->id)]); |
