ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLPStatusTypicalLearningTime.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
26{
27 public static function _getInProgress(int $a_obj_id): array
28 {
29 global $DIC;
30
31 $ilDB = $DIC['ilDB'];
32
33 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
34 $tlt = $status_info['tlt'];
35
36 $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
37
38 $user_ids = [];
39 foreach ($all as $event) {
40 if ($event['spent_seconds'] < $tlt) {
41 $user_ids[] = (int) $event['usr_id'];
42 }
43 }
44 return $user_ids;
45 }
46
47 public static function _getCompleted(int $a_obj_id): array
48 {
49 global $DIC;
50
51 $ilDB = $DIC['ilDB'];
52
53 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
54 $tlt = $status_info['tlt'];
55 // TODO: move to status info
56 $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
57
58 $user_ids = [];
59 foreach ($all as $event) {
60 if ($event['spent_seconds'] >= $tlt) {
61 $user_ids[] = (int) $event['usr_id'];
62 }
63 }
64 return $user_ids;
65 }
66
67 public static function _getStatusInfo(int $a_obj_id): array
68 {
69 global $DIC;
70
72 $ilObjDataCache = $DIC['ilObjDataCache'];
73
74 $status_info['tlt'] = parent::_getTypicalLearningTime(
75 $ilObjDataCache->lookupType($a_obj_id),
76 $a_obj_id
77 );
78 return $status_info;
79 }
80
81 public function determineStatus(
82 int $a_obj_id,
83 int $a_usr_id,
84 ?object $a_obj = null
85 ): int {
86 $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
87 switch ($this->ilObjDataCache->lookupType($a_obj_id)) {
88 case 'lm':
89 if (ilChangeEvent::hasAccessed($a_obj_id, $a_usr_id)) {
91
92 // completed?
93 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
94 $tlt = $status_info['tlt'];
95
97 $a_obj_id,
98 $a_usr_id
99 );
100 if ($re[0]['spent_seconds'] >= $tlt) {
102 }
103 }
104 break;
105 }
106 return $status;
107 }
108
109 public function determinePercentage(
110 int $a_obj_id,
111 int $a_usr_id,
112 ?object $a_obj = null
113 ): int {
114 $tlt = parent::_getTypicalLearningTime(
115 $this->ilObjDataCache->lookupType($a_obj_id),
116 $a_obj_id
117 );
118 $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_usr_id);
119 $spent = (int) ($re[0]["spent_seconds"] ?? 0);
120
121 if ($tlt > 0) {
122 $per = (int) min(100, 100 / $tlt * $spent);
123 } else {
124 $per = 100;
125 }
126 return $per;
127 }
128}
static _lookupReadEvents($obj_id, $usr_id=null)
Reads all read events which occured on the object.
static hasAccessed(int $a_obj_id, int $a_usr_id)
Has accessed.
determineStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
determinePercentage(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
static _getStatusInfo(int $a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
ilObjectDataCache $ilObjDataCache
static _getStatusInfo(int $a_obj_id)
global $DIC
Definition: shib_login.php:26