ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  public function __construct($a_obj_id)
19  {
20  global $ilDB;
21 
22  parent::__construct($a_obj_id);
23  $this->db = $ilDB;
24  }
25 
26  public static function _getInProgress($a_obj_id)
27  {
28  global $ilDB;
29 
30  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
31  $required_visits = $status_info['visits'];
32 
33  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
34  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
35  foreach ($all as $event) {
36  if ($event['read_count'] < $required_visits) {
37  $user_ids[] = $event['usr_id'];
38  }
39  }
40  return $user_ids ? $user_ids : array();
41  }
42 
43  public static function _getCompleted($a_obj_id)
44  {
45  global $ilDB;
46 
47  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
48  $required_visits = $status_info['visits'];
49 
50  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
51  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
52  foreach ($all as $event) {
53  if ($event['read_count'] >= $required_visits) {
54  $user_ids[] = $event['usr_id'];
55  }
56  }
57  return $user_ids ? $user_ids : array();
58  }
59 
60  public static function _getStatusInfo($a_obj_id)
61  {
62  include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
63  $status_info['visits'] = ilLPObjSettings::_lookupVisits($a_obj_id);
64 
65  return $status_info;
66  }
67 
76  public function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
77  {
78  global $ilObjDataCache, $ilDB;
79 
80  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
81  switch ($ilObjDataCache->lookupType($a_obj_id)) {
82  case 'lm':
83  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
84  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
85  $status = self::LP_STATUS_IN_PROGRESS_NUM;
86 
87  // completed?
88  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
89  $required_visits = $status_info['visits'];
90 
91  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
92  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
93  if ($re[0]['read_count'] >= $required_visits) {
94  $status = self::LP_STATUS_COMPLETED_NUM;
95  }
96  }
97  break;
98  }
99  return $status;
100  }
101 
110  public function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
111  {
112  include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
113  $reqv = ilLPObjSettings::_lookupVisits($a_obj_id);
114 
115  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
116  $rc = (int) $re[0]["read_count"];
117 
118  if ($reqv > 0) {
119  $per = min(100, 100 / $reqv * $rc);
120  } else {
121  $per = 100;
122  }
123 
124  return $per;
125  }
126 }
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
static _getInProgress($a_obj_id)
determineStatus($a_obj_id, $a_user_id, $a_obj=null)
Determine status.
static _getCompleted($a_obj_id)
static _getStatusInfo($a_obj_id)
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 ...
Create styles array
The data for the language used.
static _getStatusInfo($a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
static _lookupVisits($a_obj_id)
global $ilDB
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
determinePercentage($a_obj_id, $a_user_id, $a_obj=null)
Determine percentage.