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

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

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