ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilHACPResponse.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.ilAICCUnit.php";
25 
30 
31  var $unit;
32  var $ref_id;
33  var $obj_id;
34 
35  function ilHACPResponse($ref_id=0, $obj_id=0) {
36 
37  if (!empty($ref_id) && !empty($obj_id)) {
38  $this->ref_id=$ref_id;
39  $this->obj_id=$obj_id;
40 
41  $this->unit=new ilAICCUnit($obj_id);
42  $this->unit->read();
43  }
44 
45  }
46 
47  function sendOk() {
48  echo "error=0\n";
49  echo "error_txt=Successful\n";
50  echo "version=3.0\n";
51  }
52 
53  function getStudentId() {
54  global $ilUser;
55  return $ilUser->getId();
56  }
57 
58  function getStudentName() {
59  global $ilUser;
60  return $ilUser->getFullname();
61  }
62 
63  function sendParam() {
64  global $ilUser, $ilDB, $ilLog;
65 
66  echo "error=0\n";
67  echo "error_txt=Successful\n";
68  echo "version=3.0\n";
69  echo "aicc_data=\n";
70 
71  $data["core"]["student_id"]=$this->getStudentId();
72  $data["core"]["student_name"]=$this->getStudentName();
73  $data["core"]["time"]="00:00:00";
74 
75  $data["core_vendor"]=$this->unit->getCoreVendor();
76 
77  $data["student_data"]["mastery_score"]=$this->unit->getMasteryScore();
78  $data["student_data"]["max_time_allowed"]=$this->unit->getMaxTimeAllowed();
79  $data["student_data"]["time_limit_action"]=$this->unit->getTimeLimitAction();
80 
81  $data["student_preferences"]["audio"]="-1";
82  $data["student_preferences"]["text"]="1";
83 
84  $data["core_lesson"]="";
85  $data["core"]["output_file"]="";
86  $data["core"]["credit"]="c";
87  $data["core"]["lesson_location"]="";
88  $data["core"]["lesson_status"]="n,a";
89  $data["core"]["path"]="";
90  $data["core"]["score"]="";
91 
92 //$ilLog->write("Read Trackingdata A");
93 
94  $slm_id = ilObject::_lookupObjId($this->ref_id);
95  //Read Trackingdata
96  if (is_object($ilUser)) {
97  $user_id = $ilUser->getId();
98  $stmt = "SELECT * FROM scorm_tracking WHERE user_id = ".$ilDB->quote($user_id).
99  " AND sco_id = ".$ilDB->quote($this->obj_id).
100  " AND obj_id = ".$ilDB->quote($slm_id);
101 //$ilLog->write("Read Trackingdata: ".$stmt);
102  $set = $ilDB->query($stmt);
103  $rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
104  while ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC)) {
105  $key=$rec["lvalue"];
106  $value=$rec["rvalue"];
107  $arr=explode(".", $key);
108  //delete useless prefix
109  array_shift($arr);
110  //analyse key and add it to the data array
111  if (count($arr)==1)
112  $data[$arr[0]]=$value;
113  else if (count($arr)==2)
114  $data[$arr[0]][$arr[1]]=$value;
115  }
116  }
117 
118  foreach ($data as $block=>$paar) {
119  echo "[$block]\n";
120  if (!is_array($paar)) {
121  $paar=str_replace("<CR>", "\n", $paar);
122  $paar=str_replace("<cr>", "\n", $paar);
123  echo $paar."\n";
124  continue;
125  }
126 
127  foreach ($paar as $key=>$value)
128  echo "$key=$value\n";
129  }
130 
131  //echo "[evaluation]";
132 
133  }
134 
135 
136 }
137 
138 ?>
139