aboutsummaryrefslogtreecommitdiff
path: root/lib/models/Courseware/Instance.php
diff options
context:
space:
mode:
authorRon Lucke <lucke@elan-ev.de>2023-12-11 10:37:55 +0000
committerRon Lucke <lucke@elan-ev.de>2023-12-11 10:37:55 +0000
commitf2767008ffcf723bc73a4ea8781b31f23c2b68e5 (patch)
tree55d6c4b96b65f42545d9a624263089f5f5cb06a4 /lib/models/Courseware/Instance.php
parent47e23c2e78b4cc099dc6217fa0827a033ef0dc9f (diff)
TIC #3111
Closes #3111 Merge request studip/studip!2295
Diffstat (limited to 'lib/models/Courseware/Instance.php')
-rw-r--r--lib/models/Courseware/Instance.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/models/Courseware/Instance.php b/lib/models/Courseware/Instance.php
index b2308b9..1084ed5 100644
--- a/lib/models/Courseware/Instance.php
+++ b/lib/models/Courseware/Instance.php
@@ -175,6 +175,45 @@ class Instance
}
/**
+ * Returns which layout is set for root node of this coursware instance
+ *
+ * @return string name of the layout
+ */
+ public function getRootLayout(): string
+ {
+ $rootLayout = $this->unit->config['root_layout'];
+ if ($rootLayout) {
+ $this->validateRootLayout($rootLayout);
+ return $rootLayout;
+ }
+
+ return 'default';
+ }
+
+ /**
+ * Sets layout of the root node page of this courseware
+ *
+ * @param string name of the layout
+ */
+ public function setRootLayout(string $rootLayout): void
+ {
+ $this->validateRootLayout($rootLayout);
+ $this->unit->config['root_layout'] = $rootLayout;
+ }
+
+ public function isValidRootLayout(string $rootLayout): bool
+ {
+ return in_array($rootLayout, ['default', 'toc', 'classic', 'none']);
+ }
+
+ private function validateRootLayout(string $rootLayout): void
+ {
+ if (!$this->isValidRootLayout($rootLayout)) {
+ throw new \InvalidArgumentException('Invalid root layout for courseware.');
+ }
+ }
+
+ /**
* Returns whether this courseware instance uses a sequential progression through the structural elements.
*
* @return bool true if this courseware instance uses a sequential progression, false otherwise