ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
5 include_once './Services/Tracking/classes/class.ilLPStatus.php';
6 
16 {
17 
18  function ilLPStatusTypicalLearningTime($a_obj_id)
19  {
20  global $ilDB;
21 
22  parent::ilLPStatus($a_obj_id);
23  $this->db =& $ilDB;
24  }
25 
26  function _getInProgress($a_obj_id)
27  {
28  global $ilDB;
29 
30  include_once './Services/MetaData/classes/class.ilMDEducational.php';
31 
32  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
33  $tlt = $status_info['tlt'];
34 
35  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
36  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
37 
38  foreach($all as $event)
39  {
40  if($event['spent_seconds'] < $tlt)
41  {
42  $user_ids[] = $event['usr_id'];
43  }
44  }
45  return $user_ids ? $user_ids : array();
46  }
47 
48  function _getCompleted($a_obj_id)
49  {
50  global $ilDB;
51 
52  include_once './Services/MetaData/classes/class.ilMDEducational.php';
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  {
63  if($event['spent_seconds'] >= $tlt)
64  {
65  $user_ids[] = $event['usr_id'];
66  }
67  }
68  return $user_ids ? $user_ids : array();
69  }
70 
71  function _getStatusInfo($a_obj_id)
72  {
73  include_once './Services/MetaData/classes/class.ilMDEducational.php';
74  $status_info['tlt'] = ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
75 
76  return $status_info;
77  }
78 
87  function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
88  {
89  global $ilObjDataCache, $ilDB;
90 
92  switch ($ilObjDataCache->lookupType($a_obj_id))
93  {
94  case 'lm':
95  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id))
96  {
97  $status = LP_STATUS_IN_PROGRESS_NUM;
98 
99  // completed?
100  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
101  $tlt = $status_info['tlt'];
102 
103  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
104  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
105  if ($re[0]['spent_seconds'] >= $tlt)
106  {
107  $status = LP_STATUS_COMPLETED_NUM;
108  }
109  }
110  break;
111  }
112  return $status;
113  }
114 
123  function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
124  {
125  $tlt = (int) ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
126  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
127  $spent = (int) $re[0]["spent_seconds"];
128 
129  if ($tlt > 0)
130  {
131  $per = min(100, 100 / $tlt * $spent);
132  }
133  else
134  {
135  $per = 100;
136  }
137 
138  return $per;
139  }
140 }
141 ?>