ILIAS  Release_3_10_x_branch Revision 61812
 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  foreach($events as $row)
63  {
64  if ($progress)
65  {
66  $progress['spent_seconds'] += $row['spent_seconds'];
67  $progress['access_time'] = max($progress['access_time'], $row['last_access']);
68  }
69  else
70  {
71  $progress['obj_id'] = $row['obj_id'];
72  $progress['user_id'] = $row['usr_id'];
73  $progress['spent_seconds'] = $row['spent_seconds'];
74  $progress['access_time'] = $row['last_access'];
75  $progress['visits'] = $row['read_count'];
76  }
77  }
78  return $progress ? $progress : array();
79  }
80 
88  public static function _lookupProgressByObjId($a_obj_id)
89  {
90  include_once('./Services/Tracking/classes/class.ilChangeEvent.php');
91  foreach(ilChangeEvent::_lookupReadEvents($a_obj_id) as $row)
92  {
93  if(isset($progress[$row['usr_id']]))
94  {
95  $progress[$row['usr_id']]['spent_seconds'] += $row['spent_seconds'];
96  $progress[$row['usr_id']]['read_count'] += $row['read_count'];
97  $progress[$row['usr_id']]['ts'] = max($row['last_access'],$progress[$row['usr_id']]['ts']);
98  }
99  else
100  {
101  $progress[$row['usr_id']]['spent_seconds'] = $row['spent_seconds'];
102  $progress[$row['usr_id']]['read_count'] = $row['read_count'];
103  $progress[$row['usr_id']]['ts'] = $row['last_access'];
104 
105  }
106  $progress[$row['usr_id']]['usr_id'] = $row['usr_id'];
107  $progress[$row['usr_id']]['obj_id'] = $row['obj_id'];
108  }
109  return $progress ? $progress : array();
110  }
111 
113  {
114  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
115  ilChangeEvent::_recordReadEvent($data['obj_id'], $data['usr_id']);
116  }
117 }
118 ?>