diff options
| author | Viktoria Wiebe <vwiebe@uni-osnabrueck.de> | 2024-10-09 10:41:13 +0000 |
|---|---|---|
| committer | Ron Lucke <lucke@elan-ev.de> | 2024-10-09 10:41:13 +0000 |
| commit | a658d7100bb68871ec5b30850b4285152a738494 (patch) | |
| tree | 0027ea29f4d703260ed7df97eea01129636992da /lib/models/Courseware/Instance.php | |
| parent | 5df90ba506e2ca8f58d5632d1ec102d99bc385f9 (diff) | |
TIC 3265 - option to add links to coursewares in link block and table of contents
Closes #3265
Merge request studip/studip!2646
Diffstat (limited to 'lib/models/Courseware/Instance.php')
| -rw-r--r-- | lib/models/Courseware/Instance.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/models/Courseware/Instance.php b/lib/models/Courseware/Instance.php index 2676a41..c9005de 100644 --- a/lib/models/Courseware/Instance.php +++ b/lib/models/Courseware/Instance.php @@ -585,4 +585,37 @@ class Instance return $data; } + /* + * + * LINKED UNITS + * + */ + public function getLinkedUnits(): array + { + $config = $this->unit->config->getArrayCopy(); + if (array_key_exists('linked_units', $config)) { + return $config['linked_units']; + } + + return []; + } + + public function setLinkedUnits(array $units): void + { + $this->validateLinkedUnits($units); + $this->unit->config['linked_units'] = $units; + } + + public function isValidLinkedUnits($units): bool + { + return is_array($units); + } + + private function validateLinkedUnits($units): void + { + if (!$this->isValidLinkedUnits($units)) { + throw new \InvalidArgumentException('Invalid linked units for courseware.'); + } + } + } |
