ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

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

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  }
+ Here is the call graph for this function:

Member Function Documentation

◆ determineStatus()

ilLMNavigationStatus::determineStatus ( )
protected

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

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

Referenced by __construct().

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

◆ getBackPageId()

ilLMNavigationStatus::getBackPageId ( )

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

References $current_page_id, and $requested_back_page.

191  : int
192  {
193  $page_id = $this->current_page_id;
194 
195  if (empty($page_id)) {
196  return 0;
197  }
198 
199  $back_pg = $this->requested_back_page;
200 
201  // process navigation for free page
202  return $back_pg;
203  }

◆ getCurrentPage()

ilLMNavigationStatus::getCurrentPage ( )

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

References $current_page_id.

76  : int
77  {
79  }

◆ getPredecessorPageId()

ilLMNavigationStatus::getPredecessorPageId ( )

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

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

266  : int
267  {
268  $page_id = $this->current_page_id;
269  $user_id = $this->user->getId();
270  $pre_node = null;
271 
272  // determine predecessor page id
273  $found = false;
274  if ($this->deactivated_page) {
275  $c_id = $this->requested_obj_id;
276  } else {
277  $c_id = $page_id;
278  }
279  while (!$found) {
280  $pre_node = null;
281  if ($this->lm_tree->isInTree($c_id)) {
282  $pre_node = $this->lm_tree->fetchPredecessorNode($c_id, "pg");
283  }
284  if (is_array($pre_node)) {
285  $c_id = $pre_node["obj_id"];
286  $active = ilLMPage::_lookupActive(
287  $c_id,
288  $this->lm->getType(),
289  (bool) $this->lm_set->get("time_scheduled_page_activation")
290  );
291  }
292  if (is_array($pre_node) && $pre_node["obj_id"] > 0 &&
293  $user_id == ANONYMOUS_USER_ID &&
294  ($this->lm->getPublicAccessMode() == "selected" &&
295  !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
296  $found = false;
297  } else {
298  if (is_array($pre_node) && $pre_node["obj_id"] > 0 && !$active) {
299  // look, whether activation data should be shown
300  $act_data = ilLMPage::_lookupActivationData((int) $pre_node["obj_id"], $this->lm->getType());
301  if ($act_data["show_activation_info"] &&
302  (ilUtil::now() < $act_data["activation_start"])) {
303  $found = true;
304  } else {
305  $found = false;
306  }
307  } else {
308  $found = true;
309  }
310  }
311  }
312  if (is_array($pre_node)) {
313  return (int) $pre_node["obj_id"];
314  }
315 
316  return 0;
317  }
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
static _isPagePublic(int $a_node_id, bool $a_check_public_mode=false)
const ANONYMOUS_USER_ID
Definition: constants.php:27
static _lookupActivationData(int $a_id, string $a_parent_type, string $a_lang="-")
Lookup activation data.
static now()
Return current timestamp in Y-m-d H:i:s format.
+ Here is the call graph for this function:

◆ getSuccessorPageId()

ilLMNavigationStatus::getSuccessorPageId ( )

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

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

205  : int
206  {
207  $page_id = $this->current_page_id;
208  $user_id = $this->user->getId();
209  $succ_node = null;
210 
211  // determine successor page_id
212  $found = false;
213 
214  // empty chapter
215  if ($this->chapter_has_no_active_page &&
216  ilLMObject::_lookupType($this->requested_obj_id) == "st") {
217  $c_id = $this->requested_obj_id;
218  } else {
219  if ($this->deactivated_page) {
220  $c_id = $this->requested_obj_id;
221  } else {
222  $c_id = $page_id;
223  }
224  }
225  while (!$found) {
226  $succ_node = null;
227  if ($this->lm_tree->isInTree($c_id)) {
228  $succ_node = $this->lm_tree->fetchSuccessorNode($c_id, "pg");
229  }
230  if (is_array($succ_node)) {
231  $c_id = $succ_node["obj_id"];
232 
233  $active = ilLMPage::_lookupActive(
234  $c_id,
235  $this->lm->getType(),
236  (bool) $this->lm_set->get("time_scheduled_page_activation")
237  );
238  }
239  if (is_array($succ_node) && $succ_node["obj_id"] > 0 &&
240  $user_id == ANONYMOUS_USER_ID &&
241  ($this->lm->getPublicAccessMode() == "selected" &&
242  !ilLMObject::_isPagePublic($succ_node["obj_id"]))) {
243  $found = false;
244  } else {
245  if (is_array($succ_node) && $succ_node["obj_id"] > 0 && !$active) {
246  // look, whether activation data should be shown
247  $act_data = ilLMPage::_lookupActivationData((int) $succ_node["obj_id"], $this->lm->getType());
248  if ($act_data["show_activation_info"] &&
249  (ilUtil::now() < $act_data["activation_start"])) {
250  $found = true;
251  } else {
252  $found = false;
253  }
254  } else {
255  $found = true;
256  }
257  }
258  }
259  if (is_array($succ_node)) {
260  return (int) $succ_node["obj_id"];
261  }
262 
263  return 0;
264  }
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
static _isPagePublic(int $a_node_id, bool $a_check_public_mode=false)
const ANONYMOUS_USER_ID
Definition: constants.php:27
static _lookupActivationData(int $a_id, string $a_parent_type, string $a_lang="-")
Lookup activation data.
static now()
Return current timestamp in Y-m-d H:i:s format.
static _lookupType(int $a_obj_id, int $a_lm_id=0)
+ 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.

References $chapter_has_no_active_page.

66  : bool
67  {
69  }

◆ isDeactivatedPage()

ilLMNavigationStatus::isDeactivatedPage ( )

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

References $deactivated_page.

71  : bool
72  {
74  }

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 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: