ILIAS  release_4-4 Revision
class.ilObjHACPTracking.php
Go to the documentation of this file.
1 <?
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 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 require_once("./Modules/ScormAicc/classes/AICC/class.ilObjAICCTracking.php");
25 require_once("./Modules/ScormAicc/classes/HACP/class.ilHACPResponse.php");
26 
27 
32 
37  function ilObjHACPTracking($ref_id, $obj_id)
38  {
39  global $ilias, $ilDB, $ilUser;
40 
41 
42  //just to make sure to extract only this parameter
43  $mainKeys=array("command", "version", "session_id", "aicc_data");
44  $postVars=array_change_key_case($_POST, CASE_LOWER);
45  foreach($mainKeys as $key) {
46  $$key=$postVars[$key];
47  }
48 
49  //only allowed commands
50  $command=strtolower($command);
51  $allowedCommands=array("getparam", "putparam", "exitau");
52  if (!in_array($command, $allowedCommands)) {
53  exit;
54  }
55 /*
56  $fp=fopen("././Modules/ScormAicc/log/hacp.log", "a+");
57  fputs($fp, "$command ref_id=$ref_id, obj_id=$obj_id\n");
58  fclose($fp);
59 */
60  $this->$command($ref_id, $obj_id, $version, $aicc_data);
61 
62  }
63 
64  function getparam($ref_id, $obj_id, $version, $aicc_data) {
65  //if (empty($aicc_data)) {
66  // $this->startau($ref_id, $obj_id, $version, $aicc_data);
67  // return;
68  //}
69 
70  $response=new ilHACPResponse($ref_id, $obj_id);
71  $response->sendParam();
72 
73 /*
74  $fp=fopen("././Modules/ScormAicc/log/hacp.log", "a+");
75  fputs($fp, "getparam ref_id=$ref_id, obj_id=$obj_id, aicc_data=$aicc_data\n");
76  fclose($fp);
77 */
78  }
79 
80  function putparam($ref_id, $obj_id, $version, $aicc_data) {
81  //aiccdata is a non standard ini format
82  //$data=parse_ini_file($tmpFilename, TRUE);
83  $data=$this->parseAICCData($aicc_data);
84 
85  $hacp_id = ilObject::_lookupObjId($ref_id);
86 
87  //choose either insert or update to be able to inherit superclass
88  global $ilDB, $ilUser, $ilLog;
89  $this->update=array();
90  $this->insert=array();
91  if (is_object($ilUser)) {
92  $user_id = $ilUser->getId();
93  foreach ($data as $key=>$value)
94  {
95 
96  $set = $ilDB->queryF('
97  SELECT * FROM scorm_tracking WHERE user_id = %s
98  AND sco_id = %s
99  AND lvalue = %s
100  AND obj_id = %s',
101  array('integer','integer','text','integer'),
102  array($user_id,$obj_id,$key,$hacp_id));
103 
104  if ($rec = $ilDB->fetchAssoc($set))
105  $this->update[] = array("left" => $key, "right" => $value);
106  else
107  $this->insert[] = array("left" => $key, "right" => $value);
108  }
109  }
110 
111  //store
112  $this->store($hacp_id, $obj_id, 0);
113 
114  $response=new ilHACPResponse($ref_id, $obj_id);
115  $response->sendOk();
116  }
117 
118  function exitau($ref_id, $obj_id, $version, $aicc_data) {
119  $response=new ilHACPResponse($ref_id, $obj_id);
120  $response->sendOk();
121  }
122 
123  function startau($ref_id, $obj_id, $version, $aicc_data) {
124  $response=new ilHACPResponse($ref_id, $obj_id);
125  $response->sendParam();
126  }
127 
128  function parseAICCData($string) {
129  $data=array();
130  if (!empty($string)) {
131  $lines=explode("\n", $string);
132  for($i=0;$i<count($lines);$i++) {
133  $line=trim($lines[$i]);
134  if (empty($line) || substr($line,0,1)==";" || substr($line,0,1)=="#"){
135  continue;
136  }
137  if (substr($line,0,1)=="[") {
138  $block=substr($line,1,-1);
139  continue;
140  }
141  if (empty($block))
142  continue;
143 
144  if (substr_count($line, "=")==0)
145  $data[strtolower("cmi.".$block)]=$line;
146  else if (substr_count($line, "=")==1) {
147  $line=explode("=", $line);
148  $data[strtolower("cmi.".$block.".".$line[0])]=$line[1];
149  }
150  }
151  }
152  return $data;
153  }
154 
155 }
156 
157 ?>
ilObjHACPTracking($ref_id, $obj_id)
Constructor public.
exit
Definition: login.php:54
$_POST['username']
Definition: cron.php:12
exitau($ref_id, $obj_id, $version, $aicc_data)
putparam($ref_id, $obj_id, $version, $aicc_data)
getparam($ref_id, $obj_id, $version, $aicc_data)
static _lookupObjId($a_id)
startau($ref_id, $obj_id, $version, $aicc_data)
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
global $ilUser
Definition: imgupload.php:15
$ref_id
Definition: sahs_server.php:39
store($obj_id=0, $sahs_id=0, $extractData=1)