ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilLearningProgress.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
37{
38 var $db = null;
39
41 {
42 global $ilDB;
43
44 $this->db = $ilDB;
45 }
46
47 // Static
48 static function _tracProgress($a_user_id, $a_obj_id, $a_ref_id, $a_obj_type = '')
49 {
50 global $ilDB;
51
52 require_once('Services/Tracking/classes/class.ilChangeEvent.php');
53 ilChangeEvent::_recordReadEvent($a_obj_type, $a_ref_id, $a_obj_id, $a_user_id);
54
55 require_once 'Services/Tracking/classes/class.ilLPStatus.php';
56 ilLPStatus::setInProgressIfNotAttempted($a_obj_id, $a_user_id);
57
58 return true;
59 }
60
61 function _getProgress($a_user_id,$a_obj_id)
62 {
63 require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
64 $events = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
65
66 include_once './Services/Calendar/classes/class.ilDateTime.php';
67
68 foreach($events as $row)
69 {
70 $tmp_date = new ilDateTime($row['last_access'],IL_CAL_UNIX);
71 $row['last_access'] = $tmp_date->get(IL_CAL_UNIX);
72
73 $tmp_date = new ilDateTime($row['first_access'],IL_CAL_DATETIME);
74 $row['first_access'] = $tmp_date->get(IL_CAL_UNIX);
75
76 if ($progress)
77 {
78 $progress['spent_seconds'] += $row['spent_seconds'];
79 $progress['access_time'] = max($progress['access_time'], $row['last_access']);
80 $progress['access_time_min'] = min($progress['access_time_min'], $row['first_access']);
81 }
82 else
83 {
84 $progress['obj_id'] = $row['obj_id'];
85 $progress['user_id'] = $row['usr_id'];
86 $progress['spent_seconds'] = $row['spent_seconds'];
87 $progress['access_time'] = $row['last_access'];
88 $progress['access_time_min'] = $row['first_access'];
89 $progress['visits'] = $row['read_count'];
90 }
91 }
92 return $progress ? $progress : array();
93 }
94
102 public static function _lookupProgressByObjId($a_obj_id)
103 {
104 include_once('./Services/Tracking/classes/class.ilChangeEvent.php');
105 foreach(ilChangeEvent::_lookupReadEvents($a_obj_id) as $row)
106 {
107 if(isset($progress[$row['usr_id']]))
108 {
109 $progress[$row['usr_id']]['spent_seconds'] += $row['spent_seconds'];
110 $progress[$row['usr_id']]['read_count'] += $row['read_count'];
111 $progress[$row['usr_id']]['ts'] = max($row['last_access'],$progress[$row['usr_id']]['ts']);
112 }
113 else
114 {
115 $progress[$row['usr_id']]['spent_seconds'] = $row['spent_seconds'];
116 $progress[$row['usr_id']]['read_count'] = $row['read_count'];
117 $progress[$row['usr_id']]['ts'] = $row['last_access'];
118
119 }
120 $progress[$row['usr_id']]['usr_id'] = $row['usr_id'];
121 $progress[$row['usr_id']]['obj_id'] = $row['obj_id'];
122 }
123 return $progress ? $progress : array();
124 }
125
126/* deprecated
127 function _updateProgress($data)
128 {
129 require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
130 ilChangeEvent::_recordReadEvent($data['type'], $data['ref_id'],
131 $data['obj_id'], $data['usr_id']);
132 }
133 */
134}
135?>
const IL_CAL_UNIX
const IL_CAL_DATETIME
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 ...
_recordReadEvent($a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
@classDescription Date and time handling
static setInProgressIfNotAttempted($a_obj_id, $a_user_id)
This function shoudl be clalled for normal "read events".
static _tracProgress($a_user_id, $a_obj_id, $a_ref_id, $a_obj_type='')
static _lookupProgressByObjId($a_obj_id)
lookup progress for a specific object
_getProgress($a_user_id, $a_obj_id)
global $ilDB