ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLPStatusTypicalLearningTime.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/MetaData/classes/class.ilMDEducational.php'; // #15556
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  $tlt = $status_info['tlt'];
32 
33  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
34  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
35 
36  foreach ($all as $event) {
37  if ($event['spent_seconds'] < $tlt) {
38  $user_ids[] = $event['usr_id'];
39  }
40  }
41  return $user_ids ? $user_ids : array();
42  }
43 
44  public static function _getCompleted($a_obj_id)
45  {
46  global $ilDB;
47 
48  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
49  $tlt = $status_info['tlt'];
50 
51  // TODO: move to status info
52  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
53  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
54 
55  foreach ($all as $event) {
56  if ($event['spent_seconds'] >= $tlt) {
57  $user_ids[] = $event['usr_id'];
58  }
59  }
60  return $user_ids ? $user_ids : array();
61  }
62 
63  public static function _getStatusInfo($a_obj_id)
64  {
65  $status_info['tlt'] = ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
66 
67  return $status_info;
68  }
69 
78  public function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
79  {
80  global $ilObjDataCache, $ilDB;
81 
82  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
83  switch ($ilObjDataCache->lookupType($a_obj_id)) {
84  case 'lm':
85  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
86  $status = self::LP_STATUS_IN_PROGRESS_NUM;
87 
88  // completed?
89  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
90  $tlt = $status_info['tlt'];
91 
92  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
93  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
94  if ($re[0]['spent_seconds'] >= $tlt) {
95  $status = self::LP_STATUS_COMPLETED_NUM;
96  }
97  }
98  break;
99  }
100  return $status;
101  }
102 
111  public function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
112  {
113  $tlt = (int) ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
114  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
115  $spent = (int) $re[0]["spent_seconds"];
116 
117  if ($tlt > 0) {
118  $per = min(100, 100 / $tlt * $spent);
119  } else {
120  $per = 100;
121  }
122 
123  return $per;
124  }
125 }
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
static _getTypicalLearningTimeSeconds($a_rbac_id, $a_obj_id=0)
determinePercentage($a_obj_id, $a_user_id, $a_obj=null)
Determine percentage.
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.
determineStatus($a_obj_id, $a_user_id, $a_obj=null)
Determine status.
global $ilDB
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...