ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
33{
34 var $db = null;
35
36 function __construct()
37 {
38 global $ilDB;
39
40 $this->db = $ilDB;
41 }
42
43 // Static
44 static function _tracProgress($a_user_id, $a_obj_id, $a_ref_id, $a_obj_type = '')
45 {
46 require_once('Services/Tracking/classes/class.ilChangeEvent.php');
47 ilChangeEvent::_recordReadEvent($a_obj_type, $a_ref_id, $a_obj_id, $a_user_id);
48
49 require_once 'Services/Tracking/classes/class.ilLPStatus.php';
50 ilLPStatus::setInProgressIfNotAttempted($a_obj_id, $a_user_id);
51
52 return true;
53 }
54
55 static function _getProgress($a_user_id,$a_obj_id)
56 {
57 require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
58 $events = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
59
60 include_once './Services/Calendar/classes/class.ilDateTime.php';
61
62 foreach($events as $row)
63 {
64 $tmp_date = new ilDateTime($row['last_access'],IL_CAL_UNIX);
65 $row['last_access'] = $tmp_date->get(IL_CAL_UNIX);
66
67 $tmp_date = new ilDateTime($row['first_access'],IL_CAL_DATETIME);
68 $row['first_access'] = $tmp_date->get(IL_CAL_UNIX);
69
70 if ($progress)
71 {
72 $progress['spent_seconds'] += $row['spent_seconds'];
73 $progress['access_time'] = max($progress['access_time'], $row['last_access']);
74 $progress['access_time_min'] = min($progress['access_time_min'], $row['first_access']);
75 }
76 else
77 {
78 $progress['obj_id'] = $row['obj_id'];
79 $progress['user_id'] = $row['usr_id'];
80 $progress['spent_seconds'] = $row['spent_seconds'];
81 $progress['access_time'] = $row['last_access'];
82 $progress['access_time_min'] = $row['first_access'];
83 $progress['visits'] = $row['read_count'];
84 }
85 }
86 return $progress ? $progress : array();
87 }
88
96 public static function _lookupProgressByObjId($a_obj_id)
97 {
98 include_once('./Services/Tracking/classes/class.ilChangeEvent.php');
99 foreach(ilChangeEvent::_lookupReadEvents($a_obj_id) as $row)
100 {
101 if(isset($progress[$row['usr_id']]))
102 {
103 $progress[$row['usr_id']]['spent_seconds'] += $row['spent_seconds'];
104 $progress[$row['usr_id']]['read_count'] += $row['read_count'];
105 $progress[$row['usr_id']]['ts'] = max($row['last_access'],$progress[$row['usr_id']]['ts']);
106 }
107 else
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'] = $row['last_access'];
112
113 }
114 $progress[$row['usr_id']]['usr_id'] = $row['usr_id'];
115 $progress[$row['usr_id']]['obj_id'] = $row['obj_id'];
116 }
117 return $progress ? $progress : array();
118 }
119
120/* deprecated
121 function _updateProgress($data)
122 {
123 require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
124 ilChangeEvent::_recordReadEvent($data['type'], $data['ref_id'],
125 $data['obj_id'], $data['usr_id']);
126 }
127 */
128}
129?>
An exception for terminatinating execution or to throw for unit testing.
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 ...
static _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
static _getProgress($a_user_id, $a_obj_id)
global $ilDB