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

Modules/ScormAicc/classes/HACP/class.ilObjHACPTracking.php

Go to the documentation of this file.
00001 <?
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                 //just to make sure to extract only this parameter 
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                 //only allowed commands
00051                 $command=strtolower($command);
00052                 $allowedCommands=array("getparam", "putparam", "exitau");
00053                 if (!in_array($command, $allowedCommands)) {
00054                         exit;
00055                 }
00056 /*                      
00057                 $fp=fopen("././Modules/ScormAicc/log/hacp.log", "a+");
00058                 fputs($fp, "$command ref_id=$ref_id, obj_id=$obj_id\n");        
00059                 fclose($fp);                    
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                 //if (empty($aicc_data)) {
00067                 //      $this->startau($ref_id, $obj_id, $version, $aicc_data);
00068                 //      return;
00069                 //}
00070                 
00071                 $response=new ilHACPResponse($ref_id, $obj_id);
00072                 $response->sendParam(); 
00073                 
00074 /*              
00075                 $fp=fopen("././Modules/ScormAicc/log/hacp.log", "a+");
00076                 fputs($fp, "getparam ref_id=$ref_id, obj_id=$obj_id, aicc_data=$aicc_data\n");  
00077                 fclose($fp);    
00078 */
00079         }
00080         
00081         function putparam($ref_id, $obj_id, $version, $aicc_data) {
00082                 //aiccdata is a non standard ini format
00083                 //$data=parse_ini_file($tmpFilename, TRUE);
00084                 $data=$this->parseAICCData($aicc_data);
00085 
00086                 $hacp_id = ilObject::_lookupObjId($ref_id);
00087                 
00088                 //choose either insert or update to be able to inherit superclass
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                 //store
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 ?>

Generated on Fri Dec 13 2013 17:56:52 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1