ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
21 
22  $ilDB = $DIC['ilDB'];
23 
24  parent::__construct($a_obj_id);
25  $this->db = $ilDB;
26  }
27 
28  public static function _getInProgress($a_obj_id)
29  {
30  global $DIC;
31 
32  $ilDB = $DIC['ilDB'];
33 
34  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
35  $required_visits = $status_info['visits'];
36 
37  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
38  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
39  foreach ($all as $event) {
40  if ($event['read_count'] < $required_visits) {
41  $user_ids[] = $event['usr_id'];
42  }
43  }
44  return $user_ids ? $user_ids : array();
45  }
46 
47  public static function _getCompleted($a_obj_id)
48  {
49  global $DIC;
50 
51  $ilDB = $DIC['ilDB'];
52 
53  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
54  $required_visits = $status_info['visits'];
55 
56  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
57  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
58  foreach ($all as $event) {
59  if ($event['read_count'] >= $required_visits) {
60  $user_ids[] = $event['usr_id'];
61  }
62  }
63  return $user_ids ? $user_ids : array();
64  }
65 
66  public static 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  public function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
83  {
84  global $DIC;
85 
86  $ilObjDataCache = $DIC['ilObjDataCache'];
87  $ilDB = $DIC['ilDB'];
88 
89  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
90  switch ($ilObjDataCache->lookupType($a_obj_id)) {
91  case 'lm':
92  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
93  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
94  $status = self::LP_STATUS_IN_PROGRESS_NUM;
95 
96  // completed?
97  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
98  $required_visits = $status_info['visits'];
99 
100  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
101  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
102  if ($re[0]['read_count'] >= $required_visits) {
103  $status = self::LP_STATUS_COMPLETED_NUM;
104  }
105  }
106  break;
107  }
108  return $status;
109  }
110 
119  public 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  $per = min(100, 100 / $reqv * $rc);
129  } else {
130  $per = 100;
131  }
132 
133  return $per;
134  }
135 }
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
static _getInProgress($a_obj_id)
global $DIC
Definition: saml.php:7
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 ...
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.