• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

content/classes/HACP/class.ilObjHACPTracking.php

Go to the documentation of this file.
00001 <?
00002 
00003 require_once("content/classes/AICC/class.ilObjAICCTracking.php");
00004 require_once("content/classes/HACP/class.ilHACPResponse.php");
00005 
00006 
00007 class ilObjHACPTracking extends ilObjAICCTracking {
00008 
00013         function ilObjHACPTracking($ref_id, $obj_id)
00014         {
00015                 global $ilias, $HTTP_POST_VARS;
00016                 global $ilDB, $ilUser;
00017                 
00018         
00019                 //just to make sure to extract only this parameter 
00020                 $mainKeys=array("command", "version", "session_id", "aicc_data");
00021                 $postVars=array_change_key_case($HTTP_POST_VARS, CASE_LOWER);
00022                 foreach($mainKeys as $key) {
00023                         $$key=$postVars[$key];
00024                 }
00025                 
00026                 //only allowed commands
00027                 $command=strtolower($command);
00028                 $allowedCommands=array("getparam", "putparam", "exitau");
00029                 if (!in_array($command, $allowedCommands)) {
00030                         exit;
00031                 }
00032 /*                      
00033                 $fp=fopen("./content/hacp.log", "a+");
00034                 fputs($fp, "$command ref_id=$ref_id, obj_id=$obj_id\n");        
00035                 fclose($fp);                    
00036 */              
00037                 $this->$command($ref_id, $obj_id, $version, $aicc_data);
00038                 
00039         }
00040         
00041         function getparam($ref_id, $obj_id, $version, $aicc_data) {
00042                 //if (empty($aicc_data)) {
00043                 //      $this->startau($ref_id, $obj_id, $version, $aicc_data);
00044                 //      return;
00045                 //}
00046                 
00047                 $response=new ilHACPResponse($ref_id, $obj_id);
00048                 $response->sendParam(); 
00049                 
00050 /*              
00051                 $fp=fopen("./content/hacp.log", "a+");
00052                 fputs($fp, "getparam ref_id=$ref_id, obj_id=$obj_id, aicc_data=$aicc_data\n");  
00053                 fclose($fp);    
00054 */
00055         }
00056         
00057         function putparam($ref_id, $obj_id, $version, $aicc_data) {
00058                 //aiccdata is a non standard ini format
00059                 //$data=parse_ini_file($tmpFilename, TRUE);
00060                 $data=$this->parseAICCData($aicc_data);
00061 
00062                 //choose either insert or update to be able to inherit superclass
00063                 global $ilDB, $ilUser;
00064                 $this->update=array();
00065                 $this->insert=array();
00066                 if (is_object($ilUser)) {
00067                         $user_id = $ilUser->getId();
00068                         foreach ($data as $key=>$value) {
00069                                 $stmt = "SELECT * FROM scorm_tracking WHERE user_id = ".$ilDB->quote($user_id).
00070                                         " AND sco_id = ".$ilDB->quote($obj_id)." AND lvalue = ".$ilDB->quote($key);
00071                                 $set = $ilDB->query($stmt);
00072                                 if ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
00073                                         $this->update[] = array("left" => $key, "right" => $value);
00074                                 else
00075                                         $this->insert[] = array("left" => $key, "right" => $value);
00076                         }
00077                 }
00078                 
00079                 //store
00080                 $this->store($ref_id, $obj_id, 0);
00081                 
00082                 $response=new ilHACPResponse($ref_id, $obj_id);
00083                 $response->sendOk();
00084         }
00085 
00086         function exitau($ref_id, $obj_id, $version, $aicc_data) {
00087                 $response=new ilHACPResponse($ref_id, $obj_id);
00088                 $response->sendOk();
00089         }
00090         
00091         function startau($ref_id, $obj_id, $version, $aicc_data) {
00092                 $response=new ilHACPResponse($ref_id, $obj_id);
00093                 $response->sendParam(); 
00094         }
00095 
00096         function parseAICCData($string) {
00097                 $data=array();
00098                 if (!empty($string)) {
00099                         $lines=explode("\n", $string);
00100                         for($i=0;$i<count($lines);$i++) {
00101                                 $line=trim($lines[$i]);
00102                                 if (empty($line) || substr($line,0,1)==";" || substr($line,0,1)=="#"){
00103                                         continue;
00104                                 }
00105                                 if (substr($line,0,1)=="[") {
00106                                         $block=substr($line,1,-1);
00107                                         continue;
00108                                 }
00109                                 if (empty($block))
00110                                         continue;
00111                                 
00112                                 if (substr_count($line, "=")==0)
00113                                         $data[strtolower("cmi.".$block)]=$line;
00114                                 else if (substr_count($line, "=")==1) {
00115                                         $line=explode("=", $line);
00116                                         $data[strtolower("cmi.".$block.".".$line[0])]=$line[1];
00117                                 }
00118                         }
00119                 }
00120                 return $data;
00121         }
00122         
00123 }
00124 
00125 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1