aboutsummaryrefslogtreecommitdiff
path: root/lib/models/Courseware
diff options
context:
space:
mode:
authorViktoria Wiebe <vwiebe@uni-osnabrueck.de>2024-10-09 10:41:13 +0000
committerRon Lucke <lucke@elan-ev.de>2024-10-09 10:41:13 +0000
commita658d7100bb68871ec5b30850b4285152a738494 (patch)
tree0027ea29f4d703260ed7df97eea01129636992da /lib/models/Courseware
parent5df90ba506e2ca8f58d5632d1ec102d99bc385f9 (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')
-rw-r--r--lib/models/Courseware/BlockTypes/Link.json3
-rw-r--r--lib/models/Courseware/BlockTypes/Link.php21
-rw-r--r--lib/models/Courseware/Instance.php33
3 files changed, 53 insertions, 4 deletions
diff --git a/lib/models/Courseware/BlockTypes/Link.json b/lib/models/Courseware/BlockTypes/Link.json
index a6b6db2..351983f 100644
--- a/lib/models/Courseware/BlockTypes/Link.json
+++ b/lib/models/Courseware/BlockTypes/Link.json
@@ -8,6 +8,9 @@
"target": {
"type": "string"
},
+ "unit-target": {
+ "type": "string"
+ },
"url": {
"type": "string"
},
diff --git a/lib/models/Courseware/BlockTypes/Link.php b/lib/models/Courseware/BlockTypes/Link.php
index 3282e2c..8e14079 100644
--- a/lib/models/Courseware/BlockTypes/Link.php
+++ b/lib/models/Courseware/BlockTypes/Link.php
@@ -30,8 +30,9 @@ class Link extends BlockType
public function initialPayload(): array
{
return [
- 'type' => '',
+ 'type' => 'external',
'target' => '',
+ 'unit-target' => '',
'url' => '',
'title' => '',
];
@@ -61,9 +62,21 @@ class Link extends BlockType
public static function getTags(): array
{
return [
- _('URL'), _('Verlinkung'), _('Webseite'), _('extern'), _('weiterleiten'),
- _('Material'), _('Zusatz'), _('Weiterleitung'), _('intern'), _('Verweis'),
- _('Index'), _('Hyperlink'), _('Quellenangabe'), _('Linkliste'), _('Linksammlung')
+ _('URL'),
+ _('Verlinkung'),
+ _('Webseite'),
+ _('extern'),
+ _('weiterleiten'),
+ _('Material'),
+ _('Zusatz'),
+ _('Weiterleitung'),
+ _('intern'),
+ _('Verweis'),
+ _('Index'),
+ _('Hyperlink'),
+ _('Quellenangabe'),
+ _('Linkliste'),
+ _('Linksammlung')
];
}
}
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.');
+ }
+ }
+
}