ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilLPStatusCollectionManual Class Reference
+ Inheritance diagram for ilLPStatusCollectionManual:
+ Collaboration diagram for ilLPStatusCollectionManual:

Public Member Functions

 determineStatus (int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
 
 init (Container $DIC)
 
 getLPStatusId ()
 
 getLabel ()
 
 getInfo ()
 
- Public Member Functions inherited from ilLPStatus
 __construct (int $a_obj_id)
 
 _updateStatus (int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
 New status handling (st: status, nr: accesses, p: percentage, t: time spent, m: mark) Learning progress: More...
 
 determinePercentage (int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
 
 determineStatus (int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
 
 refreshStatus (int $a_obj_id, ?array $a_users=null)
 Refresh status. More...
 
 init (\ILIAS\DI\Container $DIC)
 
 getCustomLPSettingsExportXML (int $object_id)
 
 importCustomLPSettingsExportXML (int $new_object_id, ilImportMapping $a_mapping, SimpleXMLElement $additional_xml_root)
 
 getLPStatusId ()
 
 getLabel ()
 
 getInfo ()
 
 init (Container $DIC)
 
 getCustomLPSettingsExportXML (int $object_id)
 
 importCustomLPSettingsExportXML (int $new_object_id, ilImportMapping $a_mapping, SimpleXMLElement $additional_xml_root)
 
 getLPStatusId ()
 
 getLabel ()
 
 getInfo ()
 

Static Public Member Functions

static _getInProgress (int $a_obj_id)
 
static _getCompleted (int $a_obj_id)
 
static _getStatusInfo (int $a_obj_id)
 
static _getObjectStatus ( $a_obj_id, $a_user_id=null)
 
static _setObjectStatus (int $a_obj_id, int $a_user_id, ?array $a_completed=null)
 
- Static Public Member Functions inherited from ilLPStatus
static _getCountNotAttempted (int $a_obj_id)
 
static _getNotAttempted (int $a_obj_id)
 
static _getCountInProgress (int $a_obj_id)
 
static _getInProgress (int $a_obj_id)
 
static _getCountCompleted (int $a_obj_id)
 
static _getCompleted (int $a_obj_id)
 
static _getFailed (int $a_obj_id)
 
static _getCountFailed (int $a_obj_id)
 
static _getStatusInfo (int $a_obj_id)
 
static _getTypicalLearningTime (string $type, int $obj_id, int $sub_id=0)
 
static checkStatusForObject (int $a_obj_id, ?array $a_users=null)
 This function checks whether the status for a given number of users is dirty and must be recalculated. More...
 
static writeStatus (int $a_obj_id, int $a_user_id, int $a_status, int $a_percentage=0, bool $a_force_per=false, ?int &$a_old_status=self::LP_STATUS_NOT_ATTEMPTED_NUM)
 Write status for user and object. More...
 
static setInProgressIfNotAttempted (int $a_obj_id, int $a_user_id)
 This function shoudl be clalled for normal "read events". More...
 
static setAllDirty ()
 Sets all status to dirty. More...
 
static setDirty (int $a_obj_id)
 Sets status of an object to dirty. More...
 
static _lookupStatus (int $a_obj_id, int $a_user_id, bool $a_create=true)
 Lookup status. More...
 
static _lookupPercentage (int $a_obj_id, int $a_user_id)
 Lookup percentage. More...
 
static _hasUserCompleted (int $a_obj_id, int $a_user_id)
 Lookup user object completion. More...
 
static _lookupStatusChanged (int $a_obj_id, int $a_user_id)
 Lookup status changed. More...
 
static _lookupCompletedForObject (int $a_obj_id, ?array $a_user_ids=null)
 Get completed users for object. More...
 
static _lookupFailedForObject (int $a_obj_id, ?array $a_user_ids=null)
 Get failed users for object. More...
 
static _lookupInProgressForObject (int $a_obj_id, ?array $a_user_ids=null)
 Get in progress users for object. More...
 
static preloadListGUIData (array $a_obj_ids)
 
static getListGUIStatus (int $a_obj_id, bool $a_image_only=true)
 
static hasListGUIStatus (int $a_obj_id)
 

Protected Attributes

const string LNG_TEXT = 'trac_mode_collection_manual'
 
const string LNG_TEXT_INFO = 'trac_mode_collection_manual_info'
 
ilLanguage $lng
 
- Protected Attributes inherited from ilLPStatus
int $obj_id
 
ilDBInterface $db
 
ilObjectDataCache $ilObjDataCache
 

Additional Inherited Members

- Data Fields inherited from ilLPStatus
const string LP_STATUS_NOT_ATTEMPTED = 'trac_no_attempted'
 
const string LP_STATUS_IN_PROGRESS = 'trac_in_progress'
 
const string LP_STATUS_COMPLETED = 'trac_completed'
 
const string LP_STATUS_FAILED = 'trac_failed'
 
const int LP_STATUS_NOT_ATTEMPTED_NUM = 0
 
const int LP_STATUS_IN_PROGRESS_NUM = 1
 
const int LP_STATUS_COMPLETED_NUM = 2
 
const int LP_STATUS_FAILED_NUM = 3
 
const string LP_STATUS_REGISTERED = 'trac_registered'
 
const string LP_STATUS_NOT_REGISTERED = 'trac_not_registered'
 
const string LP_ut_lp_markSTATUS_PARTICIPATED = 'trac_participated'
 
const string LP_STATUS_NOT_PARTICIPATED = 'trac_not_participated'
 
- Static Public Attributes inherited from ilLPStatus
static array $list_gui_cache
 
- Static Protected Member Functions inherited from ilLPStatus
static raiseEvent (int $a_obj_id, int $a_usr_id, int $a_status, int $a_old_status, int $a_percentage)
 
static _lookupStatusForObject (int $a_obj_id, int $a_status, ?array $a_user_ids=null)
 Get users with given status for object. More...
 
static validateLPForObjects (int $a_user_id, array $a_obj_ids, int $a_parent_ref_id)
 Process given objects for lp-relevance. More...
 
static checkLPModesForObjects (array $a_obj_ids, array &$a_coll_obj_ids)
 implements Process lp modes for given objects More...
 
static getLPStatusForObjects (int $a_user_id, array $a_obj_ids)
 Get LP status for given objects (and user) More...
 

Detailed Description

Definition at line 24 of file class.ilLPStatusCollectionManual.php.

Member Function Documentation

◆ _getCompleted()

static ilLPStatusCollectionManual::_getCompleted ( int  $a_obj_id)
static
Returns
int[]

Reimplemented from ilLPStatus.

Definition at line 45 of file class.ilLPStatusCollectionManual.php.

45 : array
46 {
47 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
48 $counter = 0;
49 $users = [];
50 foreach ($status_info['items'] as $item_id) {
51 $tmp_users = $status_info['completed'][$item_id];
52
53 if (!$counter++) {
54 $users = $tmp_users;
55 } else {
56 $users = array_intersect($users, $tmp_users);
57 }
58 }
59 return array_unique($users);
60 }
static _getStatusInfo(int $a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.

References ilLPStatusWrapper\_getStatusInfo().

+ Here is the call graph for this function:

◆ _getInProgress()

static ilLPStatusCollectionManual::_getInProgress ( int  $a_obj_id)
static

Reimplemented from ilLPStatus.

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

30 : array
31 {
32 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
33 // find any completed item
34 $users = [];
35 if (isset($status_info['completed'])) {
36 foreach ($status_info['completed'] as $in_progress) {
37 $users = array_merge($users, $in_progress);
38 }
39 $users = array_unique($users);
40 }
41 // remove all users which have completed ALL items
42 return array_diff($users, ilLPStatusWrapper::_getCompleted($a_obj_id));
43 }
static _getCompleted(int $a_obj_id)
Static function to read the users who have the status 'completed'.

References ilLPStatusWrapper\_getCompleted(), and ilLPStatusWrapper\_getStatusInfo().

+ Here is the call graph for this function:

◆ _getObjectStatus()

static ilLPStatusCollectionManual::_getObjectStatus (   $a_obj_id,
  $a_user_id = null 
)
static

Definition at line 130 of file class.ilLPStatusCollectionManual.php.

133 : array {
134 global $DIC;
135 $res = [];
136 $collection = (new TrackingDBFactory($DIC->database()))->lpCollectionManual()->repository()->readEntriesOfObject($a_obj_id);
137 foreach ($collection as $entry) {
138 if (!$a_user_id) {
139 $res[$entry->getSubitemId()][$entry->getUserId()] = (int) $entry->isCompleted();
140 } else {
141 $res[$entry->getSubitemId()] = [(int) $entry->isCompleted(), $entry->getLastChanged()];
142 }
143 }
144 return $res;
145 }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: shib_login.php:26

References $res, and ILIAS\Repository\int().

Referenced by _getStatusInfo().

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

◆ _getStatusInfo()

static ilLPStatusCollectionManual::_getStatusInfo ( int  $a_obj_id)
static

Reimplemented from ilLPStatus.

Definition at line 62 of file class.ilLPStatusCollectionManual.php.

62 : array
63 {
64 $status_info = [];
65 $olp = ilObjectLP::getInstance($a_obj_id);
66 $collection = $olp->getCollectionInstance();
67 if ($collection) {
68 // @todo check if obj_id can be removed
69 $status_info["items"] = $collection->getItems($a_obj_id);
70 foreach ($status_info["items"] as $item_id) {
71 $status_info["completed"][$item_id] = [];
72 }
73 $ref_ids = ilObject::_getAllReferences($a_obj_id);
74 $ref_id = end($ref_ids);
75 $possible_items = $collection->getPossibleItems($ref_id);
76 $chapter_ids = array_intersect(
77 array_keys($possible_items),
78 $status_info["items"]
79 );
80 // fix order (adapt from possible items)
81 $status_info["items"] = $chapter_ids;
82 if ($chapter_ids) {
83 $status = self::_getObjectStatus($a_obj_id);
84
85 foreach ($chapter_ids as $item_id) {
86 $status_info["item_titles"][$item_id] = $possible_items[$item_id]["title"];
87
88 if (isset($status[$item_id])) {
89 foreach ($status[$item_id] as $user_id => $user_status) {
90 if ($user_status) {
91 $status_info["completed"][$item_id][] = $user_id;
92 }
93 }
94 }
95 }
96 }
97 }
98 return $status_info;
99 }
static _getObjectStatus( $a_obj_id, $a_user_id=null)
static getInstance(int $obj_id)
static _getAllReferences(int $id)
get all reference ids for object ID

References $user_id, ilObject\_getAllReferences(), _getObjectStatus(), and ilObjectLP\getInstance().

+ Here is the call graph for this function:

◆ _setObjectStatus()

static ilLPStatusCollectionManual::_setObjectStatus ( int  $a_obj_id,
int  $a_user_id,
?array  $a_completed = null 
)
static

Definition at line 147 of file class.ilLPStatusCollectionManual.php.

151 : void {
152 global $DIC;
153 $a_completed = is_null($a_completed) ? [] : $a_completed;
154 $olp = ilObjectLP::getInstance($a_obj_id);
155 $collection = $olp->getCollectionInstance();
156 $db_factory = (new TrackingDBFactory($DIC->database()))->lpCollectionManual();
157 if ($collection) {
158 $existing = self::_getObjectStatus($a_obj_id, $a_user_id);
159 foreach ($collection->getItems() as $item_id) {
160 // value changed
161 $completed = in_array($item_id, $a_completed);
162 if (
163 isset($existing[$item_id]) &&
164 (!$existing[$item_id][0] && $completed) ||
165 ($existing[$item_id][0] && !$completed)
166 ) {
167 $entry = $db_factory->repository()->readEntryForUserOfSubitemOfObject(
168 $a_obj_id,
169 $a_user_id,
170 $item_id
171 )
172 ->withCompletedStatus($completed)
173 ->withLastChanged(time());
174 $db_factory->repository()->write($entry);
175 } elseif ($completed) {
176 $entry = $db_factory->element()->lpCollectionManualEntry()
177 ->withObjectId($a_obj_id)
178 ->withUserId($a_user_id)
179 ->withSubitemId($item_id)
180 ->withCompletedStatus($completed)
181 ->withLastChanged(time());
182 $db_factory->repository()->write($entry);
183 }
184 }
185 }
186 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
187 }
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)

◆ determineStatus()

ilLPStatusCollectionManual::determineStatus ( int  $a_obj_id,
int  $a_usr_id,
?object  $a_obj = null 
)

Reimplemented from ilLPStatus.

Definition at line 101 of file class.ilLPStatusCollectionManual.php.

105 : int {
106 $info = self::_getStatusInfo($a_obj_id);
107 if (isset($info["completed"])) {
108 $completed = true;
109 $in_progress = false;
110 foreach ($info["completed"] as $user_ids) {
111 // has completed at least 1 item
112 if (in_array($a_usr_id, $user_ids)) {
113 $in_progress = true;
114 } // must have completed all items to complete collection
115 else {
116 $completed = false;
117 }
118 }
119 if ($completed) {
121 }
122 if ($in_progress) {
124 }
125 }
126
128 }
const int LP_STATUS_COMPLETED_NUM
const int LP_STATUS_IN_PROGRESS_NUM
const int LP_STATUS_NOT_ATTEMPTED_NUM
$info
Definition: entry_point.php:21

References $info, ilLPStatus\LP_STATUS_COMPLETED_NUM, and ilLPStatus\LP_STATUS_IN_PROGRESS_NUM.

◆ getInfo()

ilLPStatusCollectionManual::getInfo ( )

Reimplemented from ilLPStatus.

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

205 : string
206 {
207 return $this->lng->txt(self::LNG_TEXT_INFO);
208 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getLabel()

ilLPStatusCollectionManual::getLabel ( )

Reimplemented from ilLPStatus.

Definition at line 200 of file class.ilLPStatusCollectionManual.php.

200 : string
201 {
202 return $this->lng->txt(self::LNG_TEXT);
203 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getLPStatusId()

ilLPStatusCollectionManual::getLPStatusId ( )

Reimplemented from ilLPStatus.

Definition at line 195 of file class.ilLPStatusCollectionManual.php.

195 : string
196 {
198 }
const int LP_MODE_COLLECTION_MANUAL

References ilLPObjSettings\LP_MODE_COLLECTION_MANUAL.

◆ init()

ilLPStatusCollectionManual::init ( Container  $DIC)

Implements ILIAS\Tracking\Status\LPStatusInterface.

Definition at line 189 of file class.ilLPStatusCollectionManual.php.

191 : void {
192 $this->lng = $DIC->language();
193 }
language()
Get interface to the i18n service.
Definition: Container.php:95

Field Documentation

◆ $lng

ilLanguage ilLPStatusCollectionManual::$lng
protected

Definition at line 28 of file class.ilLPStatusCollectionManual.php.

◆ LNG_TEXT

const string ilLPStatusCollectionManual::LNG_TEXT = 'trac_mode_collection_manual'
protected

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

◆ LNG_TEXT_INFO

const string ilLPStatusCollectionManual::LNG_TEXT_INFO = 'trac_mode_collection_manual_info'
protected

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


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