ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilLSLearnerItemsQueries Class Reference

This combines calls to ProgressDB and StateDB to handle learner-items in the context of a specific LSObject and a specific user. More...

+ Collaboration diagram for ilLSLearnerItemsQueries:

Public Member Functions

 __construct (ilLearnerProgressDB $progress_db, ilLSStateDB $states_db, int $ls_ref_id, int $usr_id)
 
 getItems ()
 
 getCurrentItemRefId ()
 
 getCurrentItemPosition ()
 
 getStateFor (LSItem $ls_item, \ILIAS\KioskMode\View $view)
 
 storeState (ILIAS\KioskMode\State $state, int $state_item_ref_id, int $current_item_ref_id)
 
 getFirstAccess ()
 

Detailed Description

This combines calls to ProgressDB and StateDB to handle learner-items in the context of a specific LSObject and a specific user.

Author
Nils Haagen nils..nosp@m.haag.nosp@m.en@co.nosp@m.ncep.nosp@m.ts-an.nosp@m.d-tr.nosp@m.ainin.nosp@m.g.de

Definition at line 9 of file class.ilLSItemsQueries.php.

Constructor & Destructor Documentation

◆ __construct()

ilLSLearnerItemsQueries::__construct ( ilLearnerProgressDB  $progress_db,
ilLSStateDB  $states_db,
int  $ls_ref_id,
int  $usr_id 
)

Definition at line 11 of file class.ilLSItemsQueries.php.

16  {
17  $this->progress_db = $progress_db;
18  $this->states_db = $states_db;
19  $this->ls_ref_id = $ls_ref_id;
20  $this->usr_id = $usr_id;
21  }

Member Function Documentation

◆ getCurrentItemPosition()

ilLSLearnerItemsQueries::getCurrentItemPosition ( )

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

References $index, getCurrentItemRefId(), and getItems().

38  : int
39  {
40  $current_position = 0;
41  $items = $this->getItems();
42  foreach ($items as $index => $item) {
43  if ($item->getRefId() === $this->getCurrentItemRefId()) {
44  $current_position = $index;
45  }
46  }
47  return $current_position;
48  }
$index
Definition: metadata.php:128
+ Here is the call graph for this function:

◆ getCurrentItemRefId()

ilLSLearnerItemsQueries::getCurrentItemRefId ( )

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

Referenced by getCurrentItemPosition().

31  : int
32  {
33  $current = $this->states_db->getCurrentItemsFor($this->ls_ref_id, [$this->usr_id]);
34  $ref_id = max(0, $current[$this->usr_id]); //0 or greater
35  return $ref_id;
36  }
+ Here is the caller graph for this function:

◆ getFirstAccess()

ilLSLearnerItemsQueries::getFirstAccess ( )

Definition at line 77 of file class.ilLSItemsQueries.php.

78  {
79  $first_access = $this->states_db->getFirstAccessFor($this->ls_ref_id, [$this->usr_id]);
80  return $first_access[$this->usr_id];
81  }

◆ getItems()

ilLSLearnerItemsQueries::getItems ( )
Returns
LSLearnerItem[]

Definition at line 26 of file class.ilLSItemsQueries.php.

Referenced by getCurrentItemPosition().

26  : array
27  {
28  return $this->progress_db->getLearnerItems($this->usr_id, $this->ls_ref_id);
29  }
+ Here is the caller graph for this function:

◆ getStateFor()

ilLSLearnerItemsQueries::getStateFor ( LSItem  $ls_item,
\ILIAS\KioskMode\View  $view 
)

Definition at line 50 of file class.ilLSItemsQueries.php.

References LSItem\getRefId().

51  {
52  $states = $this->states_db->getStatesFor($this->ls_ref_id, [$this->usr_id]);
53  $states = $states[$this->usr_id];
54 
55  if (array_key_exists($ls_item->getRefId(), $states)) {
56  return $states[$ls_item->getRefId()];
57  }
58  return $view->buildInitialState(
59  new ILIAS\KioskMode\State()
60  );
61  }
Class ChatMainBarProvider .
getRefId()
Definition: LSItem.php:129
+ Here is the call graph for this function:

◆ storeState()

ilLSLearnerItemsQueries::storeState ( ILIAS\KioskMode\State  $state,
int  $state_item_ref_id,
int  $current_item_ref_id 
)

Definition at line 63 of file class.ilLSItemsQueries.php.

67  {
68  $this->states_db->updateState(
69  $this->ls_ref_id,
70  $this->usr_id,
71  $state_item_ref_id,
72  $state,
73  $current_item_ref_id
74  );
75  }

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