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

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

Generated on Fri Dec 13 2013 08:00:16 for ILIAS Release_3_3_x_branch .rev 46803 by  doxygen 1.7.1