ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
20 {
21 global $ilDB;
22
23 parent::ilLPStatus($a_obj_id);
24 $this->db =& $ilDB;
25 }
26
27 function _getInProgress($a_obj_id)
28 {
29 global $ilDB;
30
31 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
32 $tlt = $status_info['tlt'];
33
34 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
35 $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
36
37 foreach($all as $event)
38 {
39 if($event['spent_seconds'] < $tlt)
40 {
41 $user_ids[] = $event['usr_id'];
42 }
43 }
44 return $user_ids ? $user_ids : array();
45 }
46
47 function _getCompleted($a_obj_id)
48 {
49 global $ilDB;
50
51 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
52 $tlt = $status_info['tlt'];
53
54 // TODO: move to status info
55 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
56 $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
57
58 foreach($all as $event)
59 {
60 if($event['spent_seconds'] >= $tlt)
61 {
62 $user_ids[] = $event['usr_id'];
63 }
64 }
65 return $user_ids ? $user_ids : array();
66 }
67
68 function _getStatusInfo($a_obj_id)
69 {
70 $status_info['tlt'] = ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
71
72 return $status_info;
73 }
74
83 function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
84 {
85 global $ilObjDataCache, $ilDB;
86
88 switch ($ilObjDataCache->lookupType($a_obj_id))
89 {
90 case 'lm':
91 if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id))
92 {
94
95 // completed?
96 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
97 $tlt = $status_info['tlt'];
98
99 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
100 $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
101 if ($re[0]['spent_seconds'] >= $tlt)
102 {
104 }
105 }
106 break;
107 }
108 return $status;
109 }
110
119 function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
120 {
122 $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
123 $spent = (int) $re[0]["spent_seconds"];
124
125 if ($tlt > 0)
126 {
127 $per = min(100, 100 / $tlt * $spent);
128 }
129 else
130 {
131 $per = 100;
132 }
133
134 return $per;
135 }
136}
137?>
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.
_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
_getTypicalLearningTimeSeconds($a_rbac_id, $a_obj_id=0)
global $ilDB