ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPStatusVisits.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 include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
7 
17 {
18 
19  function ilLPStatusVisits($a_obj_id)
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  $required_visits = $status_info['visits'];
33 
34  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
35  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
36  foreach($all as $event)
37  {
38  if($event['read_count'] < $required_visits)
39  {
40  $user_ids[] = $event['usr_id'];
41  }
42  }
43  return $user_ids ? $user_ids : array();
44  }
45 
46  function _getCompleted($a_obj_id)
47  {
48  global $ilDB;
49 
50  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
51  $required_visits = $status_info['visits'];
52 
53  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
54  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
55  foreach($all as $event)
56  {
57  if($event['read_count'] >= $required_visits)
58  {
59  $user_ids[] = $event['usr_id'];
60  }
61  }
62  return $user_ids ? $user_ids : array();
63  }
64 
65  function _getStatusInfo($a_obj_id)
66  {
67  include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
68  $status_info['visits'] = ilLPObjSettings::_lookupVisits($a_obj_id);
69 
70  return $status_info;
71  }
72 
81  function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
82  {
83  global $ilObjDataCache, $ilDB;
84 
86  switch ($ilObjDataCache->lookupType($a_obj_id))
87  {
88  case 'lm':
89  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
90  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id))
91  {
93 
94  // completed?
95  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
96  $required_visits = $status_info['visits'];
97 
98  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
99  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
100  if ($re[0]['read_count'] >= $required_visits)
101  {
103  }
104  }
105  break;
106  }
107  return $status;
108  }
109 
118  function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
119  {
120  include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
121  $reqv = ilLPObjSettings::_lookupVisits($a_obj_id);
122 
123  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
124  $rc = (int) $re[0]["read_count"];
125 
126  if ($reqv > 0)
127  {
128  $per = min(100, 100 / $reqv * $rc);
129  }
130  else
131  {
132  $per = 100;
133  }
134 
135  return $per;
136  }
137 
138 }
139 ?>