ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 
 hasItems ()
 
 getItems ()
 
 getCurrentItemRefId ()
 
 getCurrentItemPosition ()
 
 getStateFor (LSItem $ls_item, View $view)
 
 storeState (ILIAS\KioskMode\State $state, int $state_item_ref_id, int $current_item_ref_id)
 
 getFirstAccess ()
 

Protected Attributes

ilLearnerProgressDB $progress_db
 
ilLSStateDB $states_db
 
int $ls_ref_id
 
int $usr_id
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $ls_ref_id, $progress_db, $states_db, and $usr_id.

39  {
40  $this->progress_db = $progress_db;
41  $this->states_db = $states_db;
42  $this->ls_ref_id = $ls_ref_id;
43  $this->usr_id = $usr_id;
44  }

Member Function Documentation

◆ getCurrentItemPosition()

ilLSLearnerItemsQueries::getCurrentItemPosition ( )

Definition at line 65 of file class.ilLSLearnerItemsQueries.php.

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

65  : int
66  {
67  $current_position = 0;
68  $items = $this->getItems();
69  foreach ($items as $index => $item) {
70  if ($item->getRefId() === $this->getCurrentItemRefId()) {
71  $current_position = $index;
72  }
73  }
74  return $current_position;
75  }
$index
Definition: metadata.php:145
+ Here is the call graph for this function:

◆ getCurrentItemRefId()

ilLSLearnerItemsQueries::getCurrentItemRefId ( )

Definition at line 59 of file class.ilLSLearnerItemsQueries.php.

Referenced by getCurrentItemPosition().

59  : int
60  {
61  $current = $this->states_db->getCurrentItemsFor($this->ls_ref_id, [$this->usr_id]); //0 or greater
62  return max(0, $current[$this->usr_id]);
63  }
+ Here is the caller graph for this function:

◆ getFirstAccess()

ilLSLearnerItemsQueries::getFirstAccess ( )

Definition at line 104 of file class.ilLSLearnerItemsQueries.php.

References $usr_id.

104  : string
105  {
106  $first_access = $this->states_db->getFirstAccessFor($this->ls_ref_id, [$this->usr_id]);
107  return $first_access[$this->usr_id];
108  }

◆ getItems()

ilLSLearnerItemsQueries::getItems ( )
Returns
LSLearnerItem[]

Definition at line 54 of file class.ilLSLearnerItemsQueries.php.

Referenced by getCurrentItemPosition(), and hasItems().

54  : array
55  {
56  return $this->progress_db->getLearnerItems($this->usr_id, $this->ls_ref_id);
57  }
+ Here is the caller graph for this function:

◆ getStateFor()

ilLSLearnerItemsQueries::getStateFor ( LSItem  $ls_item,
View  $view 
)

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

References $usr_id, ILIAS\KioskMode\View\buildInitialState(), and LSItem\getRefId().

78  {
79  $states = $this->states_db->getStatesFor($this->ls_ref_id, [$this->usr_id]);
80  $states = $states[$this->usr_id];
81 
82  if (array_key_exists($ls_item->getRefId(), $states)) {
83  return $states[$ls_item->getRefId()];
84  }
85  return $view->buildInitialState(
86  new ILIAS\KioskMode\State()
87  );
88  }
buildInitialState(State $empty_state)
Build an initial state based on the Provided empty state.
Class ChatMainBarProvider .
getRefId()
Definition: LSItem.php:90
+ Here is the call graph for this function:

◆ hasItems()

ilLSLearnerItemsQueries::hasItems ( )

Definition at line 46 of file class.ilLSLearnerItemsQueries.php.

References getItems().

46  : bool
47  {
48  return count($this->getItems()) > 0;
49  }
+ 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 90 of file class.ilLSLearnerItemsQueries.php.

94  : void {
95  $this->states_db->updateState(
96  $this->ls_ref_id,
97  $this->usr_id,
98  $state_item_ref_id,
99  $state,
100  $current_item_ref_id
101  );
102  }

Field Documentation

◆ $ls_ref_id

int ilLSLearnerItemsQueries::$ls_ref_id
protected

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

Referenced by __construct().

◆ $progress_db

ilLearnerProgressDB ilLSLearnerItemsQueries::$progress_db
protected

Definition at line 29 of file class.ilLSLearnerItemsQueries.php.

Referenced by __construct().

◆ $states_db

ilLSStateDB ilLSLearnerItemsQueries::$states_db
protected

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

Referenced by __construct().

◆ $usr_id

int ilLSLearnerItemsQueries::$usr_id
protected

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

Referenced by __construct(), getFirstAccess(), and getStateFor().


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