ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCourseLMHistory.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 
24 
35 {
36  var $db;
37 
39  var $user_id;
40 
41  function ilCourseLMHistory($crs_id,$user_id)
42  {
43  global $ilDB;
44 
45  $this->db =& $ilDB;
46 
47  $this->course_id = $crs_id;
48  $this->user_id = $user_id;
49  }
50 
51  function getUserId()
52  {
53  return $this->user_id;
54  }
55  function getCourseRefId()
56  {
57  return $this->course_id;
58  }
59 
60  function _updateLastAccess($a_user_id,$a_lm_ref_id,$a_page_id)
61  {
62  global $tree,$ilDB;
63 
64  if(!$crs_ref_id = $tree->checkForParentType($a_lm_ref_id,'crs'))
65  {
66  return true;
67  }
68 
69  // Delete old entries
70  $query = "DELETE FROM crs_lm_history ".
71  "WHERE lm_ref_id = ".$ilDB->quote($a_lm_ref_id,'integer')." ".
72  "AND usr_id = ".$ilDB->quote($a_user_id,'integer')."";
73  $res = $ilDB->manipulate($query);
74 
75  // Add new entry
76  $query = "INSERT INTO crs_lm_history ".
77  "SET usr_id = ".$ilDB->quote($a_user_id,'integer').", ".
78  "crs_ref_id = ".$ilDB->quote($crs_ref_id,'integer').", ".
79  "lm_ref_id = ".$ilDB->quote($a_lm_ref_id,'integer').", ".
80  "lm_page_id = ".$ilDB->quote($a_page_id,'integer').", ".
81  "last_access = ".$ilDB->quote(time(),'integer')."";
82  $res = $ilDB->manipulate($query);
83  return true;
84  }
85 
86  function getLastLM()
87  {
88  global $ilDB;
89 
90  $query = "SELECT * FROM crs_lm_history ".
91  "WHERE usr_id = ".$ilDB->quote($this->getUserId(),'integer')." ".
92  "AND crs_ref_id = ".$ilDB->quote($this->getCourseRefId(),'integer')." ".
93  "ORDER BY last_access ";
94 
95  $res = $this->db->query($query);
96  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
97  {
98  return $row->lm_ref_id;
99  }
100  return false;
101  }
102 
103  function getLMHistory()
104  {
105  global $ilDB;
106 
107  $query = "SELECT * FROM crs_lm_history ".
108  "WHERE usr_id = ".$ilDB->quote($this->getUserId(),'integer')." ".
109  "AND crs_ref_id = ".$ilDB->quote($this->getCourseRefId(),'integer')."";
110 
111  $res = $this->db->query($query);
112  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
113  {
114  $lm[$row->lm_ref_id]['lm_ref_id'] = $row->lm_ref_id;
115  $lm[$row->lm_ref_id]['lm_page_id'] = $row->lm_page_id;
116  $lm[$row->lm_ref_id]['last_access'] = $row->last_access;
117  }
118  return $lm ? $lm : array();
119  }
120 
121  function _deleteUser($a_usr_id)
122  {
123  global $ilDB;
124 
125  $query = "DELETE FROM crs_lm_history WHERE usr_id = ".$ilDB->quote($a_usr_id,'integer')." ";
126  $res = $ilDB->manipulate($query);
127 
128  return true;
129  }
130 
131 }
132 ?>