ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLPStatusTypicalLearningTime.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once './Services/Tracking/classes/class.ilLPStatus.php';
6include_once './Services/MetaData/classes/class.ilMDEducational.php'; // #15556
7
17{
18 public function __construct($a_obj_id)
19 {
20 global $DIC;
21
22 $ilDB = $DIC['ilDB'];
23
24 parent::__construct($a_obj_id);
25 $this->db = $ilDB;
26 }
27
28 public static function _getInProgress($a_obj_id)
29 {
30 global $DIC;
31
32 $ilDB = $DIC['ilDB'];
33
34 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
35 $tlt = $status_info['tlt'];
36
37 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
38 $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
39
40 foreach ($all as $event) {
41 if ($event['spent_seconds'] < $tlt) {
42 $user_ids[] = $event['usr_id'];
43 }
44 }
45 return $user_ids ? $user_ids : array();
46 }
47
48 public static function _getCompleted($a_obj_id)
49 {
50 global $DIC;
51
52 $ilDB = $DIC['ilDB'];
53
54 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
55 $tlt = $status_info['tlt'];
56
57 // TODO: move to status info
58 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
59 $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
60
61 foreach ($all as $event) {
62 if ($event['spent_seconds'] >= $tlt) {
63 $user_ids[] = $event['usr_id'];
64 }
65 }
66 return $user_ids ? $user_ids : array();
67 }
68
69 public static function _getStatusInfo($a_obj_id)
70 {
71 $status_info['tlt'] = ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
72
73 return $status_info;
74 }
75
84 public function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
85 {
86 global $DIC;
87
88 $ilObjDataCache = $DIC['ilObjDataCache'];
89 $ilDB = $DIC['ilDB'];
90
92 switch ($ilObjDataCache->lookupType($a_obj_id)) {
93 case 'lm':
94 if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
96
97 // completed?
98 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
99 $tlt = $status_info['tlt'];
100
101 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
102 $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
103 if ($re[0]['spent_seconds'] >= $tlt) {
105 }
106 }
107 break;
108 }
109 return $status;
110 }
111
120 public function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
121 {
123 $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
124 $spent = (int) $re[0]["spent_seconds"];
125
126 if ($tlt > 0) {
127 $per = min(100, 100 / $tlt * $spent);
128 } else {
129 $per = 100;
130 }
131
132 return $per;
133 }
134}
An exception for terminatinating execution or to throw for unit testing.
static _lookupReadEvents($obj_id, $usr_id=null)
Reads all read events which occured on the object which happened after the last time the user caught ...
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
determinePercentage($a_obj_id, $a_user_id, $a_obj=null)
Determine percentage.
determineStatus($a_obj_id, $a_user_id, $a_obj=null)
Determine status.
static _getStatusInfo($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
static _getTypicalLearningTimeSeconds($a_rbac_id, $a_obj_id=0)
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilDB