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

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