ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
40  function ilLearningProgress()
41  {
42  global $ilDB;
43 
44  $this->db = $ilDB;
45  }
46 
47  // Static
48  function _tracProgress($a_user_id,$a_obj_id, $a_obj_type = '')
49  {
50  global $ilDB;
51 
52  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
53  ilChangeEvent::_recordReadEvent($a_obj_id, $a_user_id);
54  return true;
55  }
56 
57  function _getProgress($a_user_id,$a_obj_id)
58  {
59  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
60  $events = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
61 
62  include_once './Services/Calendar/classes/class.ilDateTime.php';
63 
64  foreach($events as $row)
65  {
66  $tmp_date = new ilDateTime($row['last_access'],IL_CAL_UNIX);
67  $row['last_access'] = $tmp_date->get(IL_CAL_TIMESTAMP);
68 
69  if ($progress)
70  {
71  $progress['spent_seconds'] += $row['spent_seconds'];
72  $progress['access_time'] = max($progress['access_time'], $row['last_access']);
73  }
74  else
75  {
76  $progress['obj_id'] = $row['obj_id'];
77  $progress['user_id'] = $row['usr_id'];
78  $progress['spent_seconds'] = $row['spent_seconds'];
79  $progress['access_time'] = $row['last_access'];
80  $progress['visits'] = $row['read_count'];
81  }
82  }
83  return $progress ? $progress : array();
84  }
85 
93  public static function _lookupProgressByObjId($a_obj_id)
94  {
95  include_once('./Services/Tracking/classes/class.ilChangeEvent.php');
96  foreach(ilChangeEvent::_lookupReadEvents($a_obj_id) as $row)
97  {
98  if(isset($progress[$row['usr_id']]))
99  {
100  $progress[$row['usr_id']]['spent_seconds'] += $row['spent_seconds'];
101  $progress[$row['usr_id']]['read_count'] += $row['read_count'];
102  $progress[$row['usr_id']]['ts'] = max($row['last_access'],$progress[$row['usr_id']]['ts']);
103  }
104  else
105  {
106  $progress[$row['usr_id']]['spent_seconds'] = $row['spent_seconds'];
107  $progress[$row['usr_id']]['read_count'] = $row['read_count'];
108  $progress[$row['usr_id']]['ts'] = $row['last_access'];
109 
110  }
111  $progress[$row['usr_id']]['usr_id'] = $row['usr_id'];
112  $progress[$row['usr_id']]['obj_id'] = $row['obj_id'];
113  }
114  return $progress ? $progress : array();
115  }
116 
118  {
119  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
120  ilChangeEvent::_recordReadEvent($data['obj_id'], $data['usr_id']);
121  }
122 }
123 ?>