ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLMNavigationStatus Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilLMNavigationStatus:

Public Member Functions

 __construct (ilObjUser $user, int $request_obj_id, ilLMTree $lm_tree, ilObjLearningModule $lm, ilSetting $lm_set, string $requested_back_page, string $cmd, int $focus_id)
 
 isChapterWithoutActivePage ()
 Has current chapter no active page? More...
 
 isDeactivatedPage ()
 
 getCurrentPage ()
 
 getBackPageId ()
 
 getSuccessorPageId ()
 
 getPredecessorPageId ()
 

Protected Member Functions

 determineStatus ()
 

Protected Attributes

int $current_page_id = null
 
bool $chapter_has_no_active_page = false
 
bool $deactivated_page = false
 
ilObjLearningModule $lm
 
ilLMTree $lm_tree
 
ilObjUser $user
 
ilSetting $lm_set
 
int $requested_back_page
 
string $cmd
 
int $focus_id
 
int $requested_obj_id
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Checks current navigation request status

  • determines the current page (request may e.g. pass a chapter id, in this case the next page is searched)
  • determines if all pages of a chapter are deactivated
  • determines if the current page is deactivated
Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 27 of file class.ilLMNavigationStatus.php.

Constructor & Destructor Documentation

◆ __construct()

ilLMNavigationStatus::__construct ( ilObjUser  $user,
int  $request_obj_id,
ilLMTree  $lm_tree,
ilObjLearningModule  $lm,
ilSetting  $lm_set,
string  $requested_back_page,
string  $cmd,
int  $focus_id 
)

Definition at line 41 of file class.ilLMNavigationStatus.php.

50 {
51 $this->user = $user;
52 $this->requested_obj_id = $request_obj_id;
53 $this->lm_tree = $lm_tree;
54 $this->lm = $lm;
55 $this->lm_set = $lm_set;
56 $this->requested_back_page = (int) $requested_back_page;
57 $this->cmd = $cmd;
58 $this->focus_id = $focus_id;
59
60 $this->determineStatus();
61 }

References $cmd, $focus_id, $lm, $lm_set, $lm_tree, $requested_back_page, $user, determineStatus(), ILIAS\Repository\int(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ determineStatus()

ilLMNavigationStatus::determineStatus ( )
protected

Definition at line 81 of file class.ilLMNavigationStatus.php.

81 : void
82 {
84
85 $this->chapter_has_no_active_page = false;
86 $this->deactivated_page = false;
87
89 if ($requested_obj_id > 0 && ilLMObject::_lookupContObjID($requested_obj_id) !== $this->lm->getId()) {
91 }
92
93 // determine object id
94 if ($requested_obj_id == 0) {
95 $obj_id = $this->lm_tree->getRootId();
96 if ($this->cmd == "resume") {
97 if ($user->getId() != ANONYMOUS_USER_ID && ($this->focus_id == 0)) {
98 $last_accessed_page = ilObjLearningModuleAccess::_getLastAccessedPage($this->lm->getRefId(), $user->getId());
99 // if last accessed page was final page do nothing, start over
100 if ($last_accessed_page &&
101 $last_accessed_page != $this->lm_tree->getLastActivePage()) {
102 $obj_id = $last_accessed_page;
103 }
104 }
105 }
106 } else {
107 $obj_id = $requested_obj_id;
108 $active = ilLMPage::_lookupActive(
109 $obj_id,
110 $this->lm->getType(),
111 $this->lm_set->get("time_scheduled_page_activation")
112 );
113
114 if (!$active &&
115 ilLMPageObject::_lookupType($obj_id) == "pg") {
116 $this->deactivated_page = true;
117 }
118 }
119 // obj_id not in tree -> it is a unassigned page -> return page id
120 if (!$this->lm_tree->isInTree($obj_id)) {
121 $this->current_page_id = $obj_id;
122 return;
123 }
124 $curr_node = $this->lm_tree->getNodeData($obj_id);
125 $active = ilLMPage::_lookupActive(
126 $obj_id,
127 $this->lm->getType(),
128 (bool) $this->lm_set->get("time_scheduled_page_activation")
129 );
130 $show = $active;
131
132 // look, whether activation data should be shown
133 $act_data = ilLMPage::_lookupActivationData((int) $curr_node["obj_id"], $this->lm->getType());
134 if ($act_data["show_activation_info"] ?? false) {
135 $show = true;
136 }
137
138 if ($curr_node["type"] == "pg" &&
139 $show) { // page in tree -> return page id
140 $page_id = $curr_node["obj_id"];
141 } else { // no page -> search for next page and return its id
142 $succ_node = true;
143 $active = false;
144 $page_id = $obj_id;
145 while ($succ_node && !$active) {
146 $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, "pg");
147 if (!is_null($succ_node)) {
148 $page_id = $succ_node["obj_id"];
149 $active = ilLMPage::_lookupActive(
150 $page_id,
151 $this->lm->getType(),
152 $this->lm_set->get("time_scheduled_page_activation")
153 );
154 if (!$active) {
155 // look, whether activation data should be shown
156 $act_data = ilLMPage::_lookupActivationData((int) $page_id, $this->lm->getType());
157 if ($act_data["show_activation_info"] ?? false) {
158 $active = true;
159 if (ilLMPageObject::_lookupType($page_id) == "pg") {
160 $this->deactivated_page = true;
161 }
162 }
163 }
164 }
165 }
166
167 if (is_null($succ_node) || $succ_node["type"] != "pg") {
168 $this->chapter_has_no_active_page = true;
169 $this->current_page_id = 0;
170 return;
171 }
172
173 // check whether page found is within "clicked" chapter
174 if ($this->lm_tree->isInTree($page_id)) {
175 $path = $this->lm_tree->getPathId($page_id);
176 if (!in_array($requested_obj_id, $path)) {
177 $this->chapter_has_no_active_page = true;
178 }
179 }
180 }
181
182 $this->current_page_id = $page_id;
183 }
static _lookupContObjID(int $a_id)
get learning module id for lm object
static _lookupType(int $a_obj_id, int $a_lm_id=0)
static _getLastAccessedPage(int $a_ref_id, int $a_user_id=0)
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
static _lookupActivationData(int $a_id, string $a_parent_type, string $a_lang="-")
Lookup activation data.
const ANONYMOUS_USER_ID
Definition: constants.php:27
$path
Definition: ltiservices.php:30

References $path, $requested_obj_id, $user, ilObjContentObjectAccess\_getLastAccessedPage(), ilPageObject\_lookupActivationData(), ilPageObject\_lookupActive(), ilLMObject\_lookupContObjID(), ilLMObject\_lookupType(), ANONYMOUS_USER_ID, and ilObject\getId().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBackPageId()

ilLMNavigationStatus::getBackPageId ( )

Definition at line 185 of file class.ilLMNavigationStatus.php.

185 : int
186 {
187 $page_id = $this->current_page_id;
188
189 if (empty($page_id)) {
190 return 0;
191 }
192
194
195 // process navigation for free page
196 return $back_pg;
197 }

References $current_page_id, and $requested_back_page.

◆ getCurrentPage()

ilLMNavigationStatus::getCurrentPage ( )

Definition at line 76 of file class.ilLMNavigationStatus.php.

76 : int
77 {
79 }

References $current_page_id.

◆ getPredecessorPageId()

ilLMNavigationStatus::getPredecessorPageId ( )

Definition at line 253 of file class.ilLMNavigationStatus.php.

253 : int
254 {
255 $page_id = $this->current_page_id;
256 $user_id = $this->user->getId();
257 $pre_node = null;
258
259 // determine predecessor page id
260 $found = false;
261 if ($this->deactivated_page) {
263 } else {
264 $c_id = $page_id;
265 }
266 while (!$found) {
267 $pre_node = null;
268 if ($this->lm_tree->isInTree($c_id)) {
269 $pre_node = $this->lm_tree->fetchPredecessorNode($c_id, "pg");
270 }
271 if (is_array($pre_node)) {
272 $c_id = $pre_node["obj_id"];
273 $active = ilLMPage::_lookupActive(
274 $c_id,
275 $this->lm->getType(),
276 (bool) $this->lm_set->get("time_scheduled_page_activation")
277 );
278 }
279 if (is_array($pre_node) && $pre_node["obj_id"] > 0 && !$active) {
280 // look, whether activation data should be shown
281 $act_data = ilLMPage::_lookupActivationData((int) $pre_node["obj_id"], $this->lm->getType());
282 if ($act_data["show_activation_info"] &&
283 (ilUtil::now() < $act_data["activation_start"])) {
284 $found = true;
285 } else {
286 $found = false;
287 }
288 } else {
289 $found = true;
290 }
291 }
292 if (is_array($pre_node)) {
293 return (int) $pre_node["obj_id"];
294 }
295
296 return 0;
297 }
static now()
Return current timestamp in Y-m-d H:i:s format.

References $current_page_id, $requested_obj_id, $user_id, ilPageObject\_lookupActivationData(), ilPageObject\_lookupActive(), ilUtil\now(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ getSuccessorPageId()

ilLMNavigationStatus::getSuccessorPageId ( )

Definition at line 199 of file class.ilLMNavigationStatus.php.

199 : int
200 {
201 $page_id = $this->current_page_id;
202 $user_id = $this->user->getId();
203 $succ_node = null;
204
205 // determine successor page_id
206 $found = false;
207
208 // empty chapter
209 if ($this->chapter_has_no_active_page &&
210 ilLMObject::_lookupType($this->requested_obj_id) == "st") {
212 } else {
213 if ($this->deactivated_page) {
215 } else {
216 $c_id = $page_id;
217 }
218 }
219 while (!$found) {
220 $succ_node = null;
221 if ($this->lm_tree->isInTree($c_id)) {
222 $succ_node = $this->lm_tree->fetchSuccessorNode($c_id, "pg");
223 }
224 if (is_array($succ_node)) {
225 $c_id = $succ_node["obj_id"];
226
227 $active = ilLMPage::_lookupActive(
228 $c_id,
229 $this->lm->getType(),
230 $this->lm_set->get("time_scheduled_page_activation")
231 );
232 }
233 if (is_array($succ_node) && $succ_node["obj_id"] > 0 && !$active) {
234 // look, whether activation data should be shown
235 $act_data = ilLMPage::_lookupActivationData((int) $succ_node["obj_id"], $this->lm->getType());
236 if ($act_data["show_activation_info"] &&
237 (ilUtil::now() < $act_data["activation_start"])) {
238 $found = true;
239 } else {
240 $found = false;
241 }
242 } else {
243 $found = true;
244 }
245 }
246 if (is_array($succ_node)) {
247 return (int) $succ_node["obj_id"];
248 }
249
250 return 0;
251 }

References $current_page_id, $requested_obj_id, $user_id, ilPageObject\_lookupActivationData(), ilPageObject\_lookupActive(), ilLMObject\_lookupType(), ilUtil\now(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ isChapterWithoutActivePage()

ilLMNavigationStatus::isChapterWithoutActivePage ( )

Has current chapter no active page?

Definition at line 66 of file class.ilLMNavigationStatus.php.

66 : bool
67 {
69 }

References $chapter_has_no_active_page.

◆ isDeactivatedPage()

ilLMNavigationStatus::isDeactivatedPage ( )

Definition at line 71 of file class.ilLMNavigationStatus.php.

71 : bool
72 {
74 }

References $deactivated_page.

Field Documentation

◆ $chapter_has_no_active_page

bool ilLMNavigationStatus::$chapter_has_no_active_page = false
protected

Definition at line 30 of file class.ilLMNavigationStatus.php.

Referenced by isChapterWithoutActivePage().

◆ $cmd

string ilLMNavigationStatus::$cmd
protected

Definition at line 37 of file class.ilLMNavigationStatus.php.

Referenced by __construct().

◆ $current_page_id

int ilLMNavigationStatus::$current_page_id = null
protected

◆ $deactivated_page

bool ilLMNavigationStatus::$deactivated_page = false
protected

Definition at line 31 of file class.ilLMNavigationStatus.php.

Referenced by isDeactivatedPage().

◆ $focus_id

int ilLMNavigationStatus::$focus_id
protected

Definition at line 38 of file class.ilLMNavigationStatus.php.

Referenced by __construct().

◆ $lm

ilObjLearningModule ilLMNavigationStatus::$lm
protected

Definition at line 32 of file class.ilLMNavigationStatus.php.

Referenced by __construct().

◆ $lm_set

ilSetting ilLMNavigationStatus::$lm_set
protected

Definition at line 35 of file class.ilLMNavigationStatus.php.

Referenced by __construct().

◆ $lm_tree

ilLMTree ilLMNavigationStatus::$lm_tree
protected

Definition at line 33 of file class.ilLMNavigationStatus.php.

Referenced by __construct().

◆ $requested_back_page

int ilLMNavigationStatus::$requested_back_page
protected

Definition at line 36 of file class.ilLMNavigationStatus.php.

Referenced by __construct(), and getBackPageId().

◆ $requested_obj_id

int ilLMNavigationStatus::$requested_obj_id
protected

◆ $user

ilObjUser ilLMNavigationStatus::$user
protected

Definition at line 34 of file class.ilLMNavigationStatus.php.

Referenced by __construct(), and determineStatus().


The documentation for this class was generated from the following file: