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

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