aboutsummaryrefslogtreecommitdiff
path: root/lib/models/Courseware/Instance.php
diff options
context:
space:
mode:
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