ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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_TIMESTAMP);
72
73 if ($progress)
74 {
75 $progress['spent_seconds'] += $row['spent_seconds'];
76 $progress['access_time'] = max($progress['access_time'], $row['last_access']);
77 }
78 else
79 {
80 $progress['obj_id'] = $row['obj_id'];
81 $progress['user_id'] = $row['usr_id'];
82 $progress['spent_seconds'] = $row['spent_seconds'];
83 $progress['access_time'] = $row['last_access'];
84 $progress['visits'] = $row['read_count'];
85 }
86 }
87 return $progress ? $progress : array();
88 }
89
97 public static function _lookupProgressByObjId($a_obj_id)
98 {
99 include_once('./Services/Tracking/classes/class.ilChangeEvent.php');
100 foreach(ilChangeEvent::_lookupReadEvents($a_obj_id) as $row)
101 {
102 if(isset($progress[$row['usr_id']]))
103 {
104 $progress[$row['usr_id']]['spent_seconds'] += $row['spent_seconds'];
105 $progress[$row['usr_id']]['read_count'] += $row['read_count'];
106 $progress[$row['usr_id']]['ts'] = max($row['last_access'],$progress[$row['usr_id']]['ts']);
107 }
108 else
109 {
110 $progress[$row['usr_id']]['spent_seconds'] = $row['spent_seconds'];
111 $progress[$row['usr_id']]['read_count'] = $row['read_count'];
112 $progress[$row['usr_id']]['ts'] = $row['last_access'];
113
114 }
115 $progress[$row['usr_id']]['usr_id'] = $row['usr_id'];
116 $progress[$row['usr_id']]['obj_id'] = $row['obj_id'];
117 }
118 return $progress ? $progress : array();
119 }
120
121/* deprecated
122 function _updateProgress($data)
123 {
124 require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
125 ilChangeEvent::_recordReadEvent($data['type'], $data['ref_id'],
126 $data['obj_id'], $data['usr_id']);
127 }
128 */
129}
130?>
const IL_CAL_TIMESTAMP
const IL_CAL_UNIX
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