ILIAS  eassessment Revision 61809
 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  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id))
91  {
92  $status = LP_STATUS_IN_PROGRESS_NUM;
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  {
102  $status = LP_STATUS_COMPLETED_NUM;
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 ?>