00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once("./Modules/ScormAicc/classes/AICC/class.ilObjAICCTracking.php");
00025 require_once("./Modules/ScormAicc/classes/HACP/class.ilHACPResponse.php");
00026
00027
00031 class ilObjHACPTracking extends ilObjAICCTracking {
00032
00037 function ilObjHACPTracking($ref_id, $obj_id)
00038 {
00039 global $ilias, $HTTP_POST_VARS;
00040 global $ilDB, $ilUser;
00041
00042
00043
00044 $mainKeys=array("command", "version", "session_id", "aicc_data");
00045 $postVars=array_change_key_case($HTTP_POST_VARS, CASE_LOWER);
00046 foreach($mainKeys as $key) {
00047 $$key=$postVars[$key];
00048 }
00049
00050
00051 $command=strtolower($command);
00052 $allowedCommands=array("getparam", "putparam", "exitau");
00053 if (!in_array($command, $allowedCommands)) {
00054 exit;
00055 }
00056
00057
00058
00059
00060
00061 $this->$command($ref_id, $obj_id, $version, $aicc_data);
00062
00063 }
00064
00065 function getparam($ref_id, $obj_id, $version, $aicc_data) {
00066
00067
00068
00069
00070
00071 $response=new ilHACPResponse($ref_id, $obj_id);
00072 $response->sendParam();
00073
00074
00075
00076
00077
00078
00079 }
00080
00081 function putparam($ref_id, $obj_id, $version, $aicc_data) {
00082
00083
00084 $data=$this->parseAICCData($aicc_data);
00085
00086 $hacp_id = ilObject::_lookupObjId($ref_id);
00087
00088
00089 global $ilDB, $ilUser, $ilLog;
00090 $this->update=array();
00091 $this->insert=array();
00092 if (is_object($ilUser)) {
00093 $user_id = $ilUser->getId();
00094 foreach ($data as $key=>$value) {
00095 $stmt = "SELECT * FROM scorm_tracking WHERE user_id = ".$ilDB->quote($user_id).
00096 " AND sco_id = ".$ilDB->quote($obj_id)." AND lvalue = ".$ilDB->quote($key).
00097 " AND obj_id = ".$ilDB->quote($hacp_id);
00098 $set = $ilDB->query($stmt);
00099 if ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
00100 $this->update[] = array("left" => $key, "right" => $value);
00101 else
00102 $this->insert[] = array("left" => $key, "right" => $value);
00103 }
00104 }
00105
00106
00107 $this->store($hacp_id, $obj_id, 0);
00108
00109 $response=new ilHACPResponse($ref_id, $obj_id);
00110 $response->sendOk();
00111 }
00112
00113 function exitau($ref_id, $obj_id, $version, $aicc_data) {
00114 $response=new ilHACPResponse($ref_id, $obj_id);
00115 $response->sendOk();
00116 }
00117
00118 function startau($ref_id, $obj_id, $version, $aicc_data) {
00119 $response=new ilHACPResponse($ref_id, $obj_id);
00120 $response->sendParam();
00121 }
00122
00123 function parseAICCData($string) {
00124 $data=array();
00125 if (!empty($string)) {
00126 $lines=explode("\n", $string);
00127 for($i=0;$i<count($lines);$i++) {
00128 $line=trim($lines[$i]);
00129 if (empty($line) || substr($line,0,1)==";" || substr($line,0,1)=="#"){
00130 continue;
00131 }
00132 if (substr($line,0,1)=="[") {
00133 $block=substr($line,1,-1);
00134 continue;
00135 }
00136 if (empty($block))
00137 continue;
00138
00139 if (substr_count($line, "=")==0)
00140 $data[strtolower("cmi.".$block)]=$line;
00141 else if (substr_count($line, "=")==1) {
00142 $line=explode("=", $line);
00143 $data[strtolower("cmi.".$block.".".$line[0])]=$line[1];
00144 }
00145 }
00146 }
00147 return $data;
00148 }
00149
00150 }
00151
00152 ?>