ILIAS  Release_4_2_x_branch Revision 61807
 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.ilLPObjSettings.php';
7 include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
8 
18 {
19 
20  function ilLPStatusVisits($a_obj_id)
21  {
22  global $ilDB;
23 
24  parent::ilLPStatus($a_obj_id);
25  $this->db =& $ilDB;
26  }
27 
28  function _getInProgress($a_obj_id)
29  {
30  global $ilDB;
31 
32  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
33  $required_visits = $status_info['visits'];
34 
35  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
36  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
37  foreach($all as $event)
38  {
39  if($event['read_count'] < $required_visits)
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  $required_visits = $status_info['visits'];
53 
54  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
55  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
56  foreach($all as $event)
57  {
58  if($event['read_count'] >= $required_visits)
59  {
60  $user_ids[] = $event['usr_id'];
61  }
62  }
63  return $user_ids ? $user_ids : array();
64  }
65 
66  function _getStatusInfo($a_obj_id)
67  {
68  include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
69  $status_info['visits'] = ilLPObjSettings::_lookupVisits($a_obj_id);
70 
71  return $status_info;
72  }
73 
82  function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
83  {
84  global $ilObjDataCache, $ilDB;
85 
87  switch ($ilObjDataCache->lookupType($a_obj_id))
88  {
89  case 'lm':
90  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
91  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id))
92  {
93  $status = LP_STATUS_IN_PROGRESS_NUM;
94 
95  // completed?
96  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
97  $required_visits = $status_info['visits'];
98 
99  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
100  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
101  if ($re[0]['read_count'] >= $required_visits)
102  {
103  $status = LP_STATUS_COMPLETED_NUM;
104  }
105  }
106  break;
107  }
108  return $status;
109  }
110 
119  function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
120  {
121  include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
122  $reqv = ilLPObjSettings::_lookupVisits($a_obj_id);
123 
124  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
125  $rc = (int) $re[0]["read_count"];
126 
127  if ($reqv > 0)
128  {
129  $per = min(100, 100 / $reqv * $rc);
130  }
131  else
132  {
133  $per = 100;
134  }
135 
136  return $per;
137  }
138 
139 }
140 ?>