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

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

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 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/class.ilObjHACPLearningModule.php");
00025 require_once("./Modules/ScormAicc/classes/AICC/class.ilAICCObjectGUI.php");
00026 require_once("./Modules/ScormAicc/classes/AICC/class.ilAICCPresentationGUI.php");
00027 
00028 
00039 class ilHACPPresentationGUI extends ilAICCPresentationGUI
00040 {
00041         var $ilias;
00042         var $slm;
00043         var $tpl;
00044         var $lng;
00045 
00046         function ilHACPPresentationGUI()
00047         {
00048                 global $ilias, $tpl, $lng, $ilCtrl;;
00049 
00050                 $this->ilias =& $ilias;
00051                 $this->tpl =& $tpl;
00052                 $this->lng =& $lng;
00053                 $this->ctrl =& $ilCtrl;
00054 
00055                 $cmd = (!empty($_GET["cmd"])) ? $_GET["cmd"] : "frameset";
00056 
00057                 // Todo: check lm id
00058                 $this->slm =& new ilObjHACPLearningModule($_GET["ref_id"], true);
00059         }
00060         
00064         function &executeCommand()
00065         {
00066                 global $ilAccess, $ilLog;
00067 
00068                 $next_class = $this->ctrl->getNextClass($this);
00069                 $cmd = $this->ctrl->getCmd("frameset");
00070 
00071                 if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
00072                 {
00073                         $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->WARNING);
00074                 }
00075 
00076                 switch($next_class)
00077                 {
00078                         default:
00079                                 $this->$cmd();
00080                 }
00081         }
00082 
00086         function explorer($a_target = "sahs_content")
00087         {
00088                 $this->tpl = new ilTemplate("tpl.sahs_exp_main.html", true, true, "Modules/ScormAicc");
00089                 
00090                 require_once("./Modules/ScormAicc/classes/HACP/class.ilHACPExplorer.php");
00091                 $exp = new ilHACPExplorer($this->ctrl->getLinkTarget($this, "view"), $this->slm);
00092                 $exp->setTargetGet("obj_id");
00093                 $exp->setFrameTarget($a_target);
00094                 //$exp->setFiltered(true);
00095 
00096                 if ($_GET["scexpand"] == "")
00097                 {
00098                         $mtree = new ilSCORMTree($this->slm->getId());
00099                         $expanded = $mtree->readRootId();
00100                 }
00101                 else
00102                 {
00103                         $expanded = $_GET["scexpand"];
00104                 }
00105                 $exp->setExpand($expanded);
00106                 
00107                 $exp->forceExpandAll(true, false);
00108 
00109                 // build html-output
00110                 //666$exp->setOutput(0);
00111                 $exp->setOutput(0);
00112 
00113                 $output = $exp->getOutput();
00114 
00115                 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00116                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
00117                 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_content"));
00118                 $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
00119                 $this->tpl->setVariable("EXPLORER",$output);
00120                 $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, $_GET["cmd"])."&frame=".$_GET["frame"].
00121                         "&ref_id=".$this->slm->getRefId()."&scexpand=".$_GET["scexpand"]);
00122                 $this->tpl->parseCurrentBlock();
00123                 $this->tpl->show();
00124         }
00125 
00126         function launchSahs()
00127         {
00128                 echo "launchSahs";
00129                 exit;
00130                 
00131                 global $ilUser, $ilDB;
00132 
00133                 $sahs_id = ($_GET["sahs_id"] == "")
00134                         ? $_POST["sahs_id"]
00135                         : $_GET["sahs_id"];
00136                 $ref_id = ($_GET["ref_id"] == "")
00137                         ? $_POST["ref_id"]
00138                         : $_GET["ref_id"];
00139 
00140                 $this->slm =& new ilObjAICCLearningModule($ref_id, true);
00141 
00142                 include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
00143                 $unit =& new ilAICCUnit($sahs_id);
00144                 
00145                 //guess the url to be able to launch most contents
00146                 $url=$unit->getCommand_line();
00147                 if (strlen($url)==0)
00148                         $url=$unit->getFilename();
00149                 if (strcasecmp(substr($unit->getFilename(),0,4),"http")!=0)
00150                         $url=$unit->slm->getDataDirectory("output")."/".$url;
00151                 if (strlen($unit->getWebLaunch())>0)
00152                         $url.="?".$unit->getWebLaunch();
00153                         
00154 /*              
00155                 if (strcasecmp(substr($unit->getFilename(),0,4),"http")==0)
00156                         $href=$unit->getFilename();
00157                 else
00158                         $href=$this->slm->getDataDirectory("output")."/".$unit->getFilename();
00159 */              
00160                 $this->tpl = new ilTemplate("tpl.sahs_launch_cbt.html", true, true, "Modules/ScormAicc");
00161                 $this->tpl->setVariable("HREF", $url);
00162 //              $this->tpl->setVariable("LAUNCH_DATA", $unit->getDataFromLms());
00163                 $this->tpl->setVariable("MAST_SCORE", $unit->getMasteryScore());
00164                 $this->tpl->setVariable("MAX_TIME", $unit->getMaxTimeAllowed());
00165                 $this->tpl->setVariable("LIMIT_ACT", $unit->getTimeLimitAction());
00166                 if($ilUser->getFirstName() == "Joe")    // for test purpose
00167                 {
00168                         $this->tpl->setCurrentBlock("credit");
00169                         $this->tpl->setVariable("CREDIT_MODE", "normal");
00170                         $this->tpl->parseCurrentBlock();
00171                 }
00172                 $query = "SELECT * FROM scorm_tracking WHERE".
00173                         " user_id = ".$ilDB->quote($ilUser->getId()).
00174                         " AND sco_id = ".$ilDB->quote($sahs_id).
00175                         " AND obj_id = ".$ilDB->quote($this->slm->getId());
00176                         
00177 
00178                 $val_set = $ilDB->query($query);
00179                 $re_value = array();
00180                 while($val_rec = $val_set->fetchRow(DB_FETCHMODE_ASSOC))
00181                 {
00182                         $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
00183                         $val_rec["rvalue"] = str_replace("\r", "\n", $val_rec["rvalue"]);
00184                         $val_rec["rvalue"] = str_replace("\n", "%n%", $val_rec["rvalue"]);
00185                         $re_value[$val_rec["lvalue"]] = $val_rec["rvalue"];
00186                 }
00187 
00188                 foreach($re_value as $var => $value)
00189                 {
00190                         switch ($var)
00191                         {
00192                                 case "cmi.core.lesson_location":
00193                                 case "cmi.core.lesson_status":
00194                                 case "cmi.core.entry":
00195                                 case "cmi.core.score.raw":
00196                                 case "cmi.core.score.max":
00197                                 case "cmi.core.score.min":
00198                                 case "cmi.core.total_time":
00199                                 case "cmi.core.exit":
00200                                 case "cmi.suspend_data":
00201                                 case "cmi.comments":
00202                                 case "cmi.student_preference.audio":
00203                                 case "cmi.student_preference.language":
00204                                 case "cmi.student_preference.speed":
00205                                 case "cmi.student_preference.text":
00206                                         $this->setSingleVariable($var, $value);
00207                                         break;
00208 
00209                                 case "cmi.objectives._count":
00210                                         $this->setSingleVariable($var, $value);
00211                                         $this->setArray("cmi.objectives", $value, "id", $re_value);
00212                                         $this->setArray("cmi.objectives", $value, "score.raw", $re_value);
00213                                         $this->setArray("cmi.objectives", $value, "score.max", $re_value);
00214                                         $this->setArray("cmi.objectives", $value, "score.min", $re_value);
00215                                         $this->setArray("cmi.objectives", $value, "status", $re_value);
00216                                         break;
00217 
00218                                 case "cmi.interactions._count":
00219                                         $this->setSingleVariable($var, $value);
00220                                         $this->setArray("cmi.interactions", $value, "id", $re_value);
00221                                         for($i=0; $i<$value; $i++)
00222                                         {
00223                                                 $var2 = "cmi.interactions.".$i.".objectives._count";
00224                                                 if (isset($v_array[$var2]))
00225                                                 {
00226                                                         $cnt = $v_array[$var2];
00227                                                         $this->setArray("cmi.interactions.".$i.".objectives",
00228                                                                 $cnt, "id", $re_value);
00229                                                         /*
00230                                                         $this->setArray("cmi.interactions.".$i.".objectives",
00231                                                                 $cnt, "score.raw", $re_value);
00232                                                         $this->setArray("cmi.interactions.".$i.".objectives",
00233                                                                 $cnt, "score.max", $re_value);
00234                                                         $this->setArray("cmi.interactions.".$i.".objectives",
00235                                                                 $cnt, "score.min", $re_value);
00236                                                         $this->setArray("cmi.interactions.".$i.".objectives",
00237                                                                 $cnt, "status", $re_value);*/
00238                                                 }
00239                                         }
00240                                         $this->setArray("cmi.interactions", $value, "time", $re_value);
00241                                         $this->setArray("cmi.interactions", $value, "type", $re_value);
00242                                         for($i=0; $i<$value; $i++)
00243                                         {
00244                                                 $var2 = "cmi.interactions.".$i.".correct_responses._count";
00245                                                 if (isset($v_array[$var2]))
00246                                                 {
00247                                                         $cnt = $v_array[$var2];
00248                                                         $this->setArray("cmi.interactions.".$i.".correct_responses",
00249                                                                 $cnt, "pattern", $re_value);
00250                                                         $this->setArray("cmi.interactions.".$i.".correct_responses",
00251                                                                 $cnt, "weighting", $re_value);
00252                                                 }
00253                                         }
00254                                         $this->setArray("cmi.interactions", $value, "student_response", $re_value);
00255                                         $this->setArray("cmi.interactions", $value, "result", $re_value);
00256                                         $this->setArray("cmi.interactions", $value, "latency", $re_value);
00257                                         break;
00258                         }
00259                 }
00260 
00261                 global $lng;
00262                 $this->tpl->setCurrentBlock("switch_icon");
00263                 $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
00264                 $this->tpl->setVariable("SCO_ICO", ilUtil::getImagePath("scorm/running.gif"));
00265                 $this->tpl->setVariable("SCO_ALT",
00266                          $lng->txt("cont_status").": "
00267                         .$lng->txt("cont_sc_stat_running")
00268                 );
00269                 $this->tpl->parseCurrentBlock();
00270 
00271                 // lesson mode
00272                 $lesson_mode = $this->slm->getDefaultLessonMode();
00273                 if ($this->slm->getAutoReview())
00274                 {
00275                         if ($re_value["cmi.core.lesson_status"] == "completed" ||
00276                                 $re_value["cmi.core.lesson_status"] == "passed" ||
00277                                 $re_value["cmi.core.lesson_status"] == "failed")
00278                         {
00279                                 $lesson_mode = "review";
00280                         }
00281                 }
00282                 $this->tpl->setVariable("LESSON_MODE", $lesson_mode);
00283 
00284                 // credit mode
00285                 if ($lesson_mode == "normal")
00286                 {
00287                         $this->tpl->setVariable("CREDIT_MODE",
00288                                 str_replace("_", " ", $this->slm->getCreditMode()));
00289                 }
00290                 else
00291                 {
00292                         $this->tpl->setVariable("CREDIT_MODE", "no-credit");
00293                 }
00294 
00295                 // init cmi.core.total_time, cmi.core.lesson_status and cmi.core.entry
00296                 $sahs_obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
00297                 if (!isset($re_value["cmi.core.total_time"]))
00298                 {
00299                         $unit->insertTrackData("cmi.core.total_time", "0000:00:00", $sahs_obj_id);
00300                 }
00301                 if (!isset($re_value["cmi.core.lesson_status"]))
00302                 {
00303                         $unit->insertTrackData("cmi.core.lesson_status", "not attempted", $sahs_obj_id);
00304                 }
00305                 if (!isset($re_value["cmi.core.entry"]))
00306                 {
00307                         $unit->insertTrackData("cmi.core.entry", "", $sahs_obj_id);
00308                 }
00309 
00310                 $this->tpl->show();
00311         }
00312 
00313 
00314 }
00315 ?>

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