ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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)
 
 getLearningSequenceRefId ()
 
 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.

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 }

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

Member Function Documentation

◆ getCurrentItemPosition()

ilLSLearnerItemsQueries::getCurrentItemPosition ( )

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

70 : int
71 {
72 $current_position = 0;
73 $items = $this->getItems();
74 foreach ($items as $index => $item) {
75 if ($item->getRefId() === $this->getCurrentItemRefId()) {
76 $current_position = $index;
77 }
78 }
79 return $current_position;
80 }

References getItems().

+ Here is the call graph for this function:

◆ getCurrentItemRefId()

ilLSLearnerItemsQueries::getCurrentItemRefId ( )

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

64 : int
65 {
66 $current = $this->states_db->getCurrentItemsFor($this->ls_ref_id, [$this->usr_id]); //0 or greater
67 return max(0, $current[$this->usr_id]);
68 }

◆ getFirstAccess()

ilLSLearnerItemsQueries::getFirstAccess ( )

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

109 : string
110 {
111 $first_access = $this->states_db->getFirstAccessFor($this->ls_ref_id, [$this->usr_id]);
112 return $first_access[$this->usr_id];
113 }

◆ getItems()

ilLSLearnerItemsQueries::getItems ( )
Returns
LSLearnerItem[]

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

59 : array
60 {
61 return $this->progress_db->getLearnerItems($this->usr_id, $this->ls_ref_id);
62 }

Referenced by getCurrentItemPosition(), and hasItems().

+ Here is the caller graph for this function:

◆ getLearningSequenceRefId()

ilLSLearnerItemsQueries::getLearningSequenceRefId ( )

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

46 : int
47 {
48 return $this->ls_ref_id;
49 }

References $ls_ref_id.

◆ getStateFor()

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

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

83 {
84 $states = $this->states_db->getStatesFor($this->ls_ref_id, [$this->usr_id]);
85 $states = $states[$this->usr_id];
86
87 if (array_key_exists($ls_item->getRefId(), $states)) {
88 return $states[$ls_item->getRefId()];
89 }
90 return $view->buildInitialState(
91 new ILIAS\KioskMode\State()
92 );
93 }
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:27
getRefId()
Definition: LSItem.php:93
buildInitialState(State $empty_state)
Build an initial state based on the Provided empty state.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

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

+ Here is the call graph for this function:

◆ hasItems()

ilLSLearnerItemsQueries::hasItems ( )

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

51 : bool
52 {
53 return count($this->getItems()) > 0;
54 }

References getItems().

+ 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 95 of file class.ilLSLearnerItemsQueries.php.

99 : void {
100 $this->states_db->updateState(
101 $this->ls_ref_id,
102 $this->usr_id,
103 $state_item_ref_id,
104 $state,
105 $current_item_ref_id
106 );
107 }

Field Documentation

◆ $ls_ref_id

int ilLSLearnerItemsQueries::$ls_ref_id
protected

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

Referenced by __construct(), and getLearningSequenceRefId().

◆ $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(), and getStateFor().


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