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

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

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