00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00039 class ilSAHSPresentationGUI
00040 {
00041 var $ilias;
00042 var $tpl;
00043 var $lng;
00044
00045 function ilSAHSPresentationGUI()
00046 {
00047 global $ilias, $tpl, $lng, $ilCtrl;
00048
00049 $this->ilias =& $ilias;
00050 $this->tpl =& $tpl;
00051 $this->lng =& $lng;
00052 $this->ctrl =& $ilCtrl;
00053
00054 $this->ctrl->saveParameter($this, "ref_id");
00055 }
00056
00060 function &executeCommand()
00061 {
00062 global $lng,$ilAccess, $ilNavigationHistory, $ilCtrl;
00063
00064 include_once "./classes/class.ilObjectGUI.php";
00065 include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
00066
00067 $lng->loadLanguageModule("content");
00068
00069
00070 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
00071 {
00072 $ilNavigationHistory->addItem($_GET["ref_id"],
00073 "ilias.php?cmd=infoScreen&baseClass=ilSAHSPresentationGUI&ref_id=".$_GET["ref_id"], "lm");
00074 }
00075
00076
00077 include_once './payment/classes/class.ilPaymentObject.php';
00078 include_once './classes/class.ilSearch.php';
00079 if(!ilPaymentObject::_hasAccess($_GET['ref_id']))
00080 {
00081 ilUtil::redirect('./payment.php?view=start_purchase&ref_id='.$_GET['ref_id']);
00082 }
00083
00084 $next_class = $this->ctrl->getNextClass($this);
00085 $cmd = $this->ctrl->getCmd();
00086
00087 $obj_id = ilObject::_lookupObjectId($_GET['ref_id']);
00088 $type = ilObjSAHSLearningModule::_lookupSubType($obj_id);
00089
00090 switch($type)
00091 {
00092
00093 case "scorm2004":
00094 include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModuleGUI.php");
00095 $this->slm_gui = new ilObjSCORMLearningModuleGUI("", $_GET["ref_id"],true,false);
00096 break;
00097
00098 case "scorm":
00099 include_once("./Modules/ScormAicc/classes/class.ilObjSCORMLearningModuleGUI.php");
00100 $this->slm_gui = new ilObjSCORMLearningModuleGUI("", $_GET["ref_id"],true,false);
00101 break;
00102
00103 case "aicc":
00104 include_once("./Modules/ScormAicc/classes/class.ilObjAICCLearningModuleGUI.php");
00105 $this->slm_gui = new ilObjAICCLearningModuleGUI("", $_GET["ref_id"],true,false);
00106 break;
00107
00108 case "hacp":
00109 include_once("./Modules/ScormAicc/classes/class.ilObjHACPLearningModuleGUI.php");
00110 $this->slm_gui = new ilObjHACPLearningModuleGUI("", $_GET["ref_id"],true,false);
00111 break;
00112 }
00113
00114 if ($next_class != "ilinfoscreengui" &&
00115 $cmd != "infoScreen")
00116 {
00117 switch($type)
00118 {
00119
00120 case "scorm2004":
00121 $this->ctrl->setCmdClass("ilscorm13player");
00122 $this->slm_gui = new ilObjSCORMLearningModuleGUI("", $_GET["ref_id"],true,false);
00123 break;
00124
00125 case "scorm":
00126 $this->ctrl->setCmdClass("ilscormpresentationgui");
00127 $this->slm_gui = new ilObjSCORMLearningModuleGUI("", $_GET["ref_id"],true,false);
00128 break;
00129
00130 case "aicc":
00131 $this->ctrl->setCmdClass("ilaiccpresentationgui");
00132 break;
00133
00134 case "hacp":
00135 $this->ctrl->setCmdClass("ilhacppresentationgui");
00136 break;
00137 }
00138 $next_class = $this->ctrl->getNextClass($this);
00139 }
00140
00141 switch($next_class)
00142 {
00143 case "ilinfoscreengui":
00144 $ret =& $this->outputInfoScreen();
00145 break;
00146
00147 case "ilscorm13player":
00148 require_once "./Modules/Scorm2004/classes/ilSCORM13Player.php";
00149 $scorm_gui = new ilSCORM13Player();
00150 $ret =& $this->ctrl->forwardCommand($scorm_gui);
00151 break;
00152
00153 case "ilscormpresentationgui":
00154 require_once "./Modules/ScormAicc/classes/SCORM/class.ilSCORMPresentationGUI.php";
00155 $scorm_gui = new ilSCORMPresentationGUI();
00156 $ret =& $this->ctrl->forwardCommand($scorm_gui);
00157 break;
00158
00159 case "ilaiccpresentationgui":
00160 require_once "./Modules/ScormAicc/classes/AICC/class.ilAICCPresentationGUI.php";
00161 $aicc_gui = new ilAICCPresentationGUI();
00162 $ret =& $this->ctrl->forwardCommand($aicc_gui);
00163 break;
00164
00165 case "ilhacppresentationgui":
00166 require_once "./Modules/ScormAicc/classes/HACP/class.ilHACPPresentationGUI.php";
00167 $hacp_gui = new ilHACPPresentationGUI();
00168 $ret =& $this->ctrl->forwardCommand($hacp_gui);
00169 break;
00170
00171 default:
00172 $this->$cmd();
00173 }
00174 }
00175
00176
00177 function attrib2arr(&$a_attributes)
00178 {
00179 $attr = array();
00180 if(!is_array($a_attributes))
00181 {
00182 return $attr;
00183 }
00184 foreach ($a_attributes as $attribute)
00185 {
00186 $attr[$attribute->name()] = $attribute->value();
00187 }
00188 return $attr;
00189 }
00190
00191
00195 function frameset()
00196 {
00197 $this->tpl = new ilTemplate("tpl.sahs_pres_frameset.html", false, false, "Modules/ScormAicc");
00198 $this->tpl->setVariable("REF_ID",$this->slm->getRefId());
00199 $this->tpl->show("DEFAULT", false);
00200 exit;
00201 }
00202
00203
00207 function explorer($a_target = "sahs_content")
00208 {
00209 global $ilBench;
00210
00211 $ilBench->start("SAHSExplorer", "initExplorer");
00212
00213 $this->tpl = new ilTemplate("tpl.sahs_exp_main.html", true, true, "Modules/ScormAicc");
00214
00215 require_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMExplorer.php");
00216 $exp = new ilSCORMExplorer("ilias.php?baseClass=ilSAHSPresentationGUI&cmd=view&ref_id=".$this->slm->getRefId(), $this->slm);
00217 $exp->setTargetGet("obj_id");
00218 $exp->setFrameTarget($a_target);
00219
00220
00221
00222 if ($_GET["scexpand"] == "")
00223 {
00224 $mtree = new ilSCORMTree($this->slm->getId());
00225 $expanded = $mtree->readRootId();
00226 }
00227 else
00228 {
00229 $expanded = $_GET["scexpand"];
00230 }
00231 $exp->setExpand($expanded);
00232
00233 $exp->forceExpandAll(true, false);
00234
00235
00236
00237 $ilBench->stop("SAHSExplorer", "initExplorer");
00238
00239
00240 $ilBench->start("SAHSExplorer", "setOutput");
00241 $exp->setOutput(0);
00242 $ilBench->stop("SAHSExplorer", "setOutput");
00243
00244 $ilBench->start("SAHSExplorer", "getOutput");
00245 $output = $exp->getOutput();
00246 $ilBench->stop("SAHSExplorer", "getOutput");
00247
00248 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00249 $this->tpl->addBlockFile("CONTENT", "content", "tpl.sahs_explorer.html", "Modules/ScormAicc");
00250
00251 $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
00252 $this->tpl->setVariable("EXPLORER",$output);
00253 $this->tpl->setVariable("ACTION", "ilias.php?baseClass=ilSAHSPresentationGUI&cmd=".$_GET["cmd"]."&frame=".$_GET["frame"].
00254 "&ref_id=".$this->slm->getRefId()."&scexpand=".$_GET["scexpand"]);
00255 $this->tpl->parseCurrentBlock();
00256 $this->tpl->show();
00257 }
00258
00259
00260 function view()
00261 {
00262 $sc_gui_object =& ilSCORMObjectGUI::getInstance($_GET["obj_id"]);
00263
00264 if(is_object($sc_gui_object))
00265 {
00266 $sc_gui_object->view();
00267 }
00268
00269 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00270 $this->tpl->show();
00271 }
00272
00273 function api()
00274 {
00275 global $ilias;
00276
00277 $slm_obj =& new ilObjSCORMLearningModule($_GET["ref_id"]);
00278
00279 $this->tpl = new ilTemplate("tpl.sahs_api.html", true, true, "Modules/ScormAicc");
00280 $this->tpl->setVariable("USER_ID",$ilias->account->getId());
00281 $this->tpl->setVariable("USER_FIRSTNAME",$ilias->account->getFirstname());
00282 $this->tpl->setVariable("USER_LASTNAME",$ilias->account->getLastname());
00283 $this->tpl->setVariable("REF_ID",$_GET["ref_id"]);
00284 $this->tpl->setVariable("SESSION_ID",session_id());
00285
00286 $this->tpl->setVariable("CODE_BASE", "http://".$_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'], 0, strpos ($_SERVER['PHP_SELF'], "/ilias.php")));
00287 $this->tpl->parseCurrentBlock();
00288
00289 $this->tpl->show(false);
00290 exit;
00291 }
00292
00293 function launchSahs()
00294 {
00295 global $ilUser, $ilDB;
00296
00297 $sco_id = ($_GET["sahs_id"] == "")
00298 ? $_POST["sahs_id"]
00299 : $_GET["sahs_id"];
00300 $ref_id = ($_GET["ref_id"] == "")
00301 ? $_POST["ref_id"]
00302 : $_GET["ref_id"];
00303
00304 $this->slm =& new ilObjSCORMLearningModule($ref_id, true);
00305
00306 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php");
00307 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMResource.php");
00308 $item =& new ilSCORMItem($sco_id);
00309
00310 $id_ref = $item->getIdentifierRef();
00311 $resource =& new ilSCORMResource();
00312 $resource->readByIdRef($id_ref, $item->getSLMId());
00313
00314 $href = $resource->getHref();
00315 $this->tpl = new ilTemplate("tpl.sahs_launch_cbt.html", true, true, "Modules/ScormAicc");
00316 $this->tpl->setVariable("HREF", $this->slm->getDataDirectory("output")."/".$href);
00317
00318
00319 $this->tpl->setVariable("LAUNCH_DATA", $item->getDataFromLms());
00320 $this->tpl->setVariable("MAST_SCORE", $item->getMasteryScore());
00321 $this->tpl->setVariable("MAX_TIME", $item->getMaxTimeAllowed());
00322 $this->tpl->setVariable("LIMIT_ACT", $item->getTimeLimitAction());
00323
00324
00325 if ($this->slm->getAPIAdapterName() != "API")
00326 {
00327 $this->tpl->setCurrentBlock("alt_api_ref");
00328 $this->tpl->setVariable("API_NAME", $this->slm->getAPIAdapterName());
00329 $this->tpl->parseCurrentBlock();
00330 }
00331
00332 $query = "SELECT * FROM scorm_tracking WHERE".
00333 " user_id = ".$ilDB->quote($ilUser->getId()).
00334 " AND sco_id = ".$ilDB->quote($sco_id).
00335 " AND obj_id = ".$ilDB->quote($this->slm->getId());
00336
00337
00338 $val_set = $ilDB->query($query);
00339 $re_value = array();
00340 while($val_rec = $val_set->fetchRow(DB_FETCHMODE_ASSOC))
00341 {
00342 $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
00343 $val_rec["rvalue"] = str_replace("\r", "\n", $val_rec["rvalue"]);
00344 $val_rec["rvalue"] = str_replace("\n", "\\n", $val_rec["rvalue"]);
00345 $re_value[$val_rec["lvalue"]] = $val_rec["rvalue"];
00346 }
00347
00348 foreach($re_value as $var => $value)
00349 {
00350 switch ($var)
00351 {
00352 case "cmi.core.lesson_location":
00353 case "cmi.core.lesson_status":
00354 case "cmi.core.entry":
00355 case "cmi.core.score.raw":
00356 case "cmi.core.score.max":
00357 case "cmi.core.score.min":
00358 case "cmi.core.total_time":
00359 case "cmi.core.exit":
00360 case "cmi.suspend_data":
00361 case "cmi.comments":
00362 case "cmi.student_preference.audio":
00363 case "cmi.student_preference.language":
00364 case "cmi.student_preference.speed":
00365 case "cmi.student_preference.text":
00366 $this->setSingleVariable($var, $value);
00367 break;
00368
00369 case "cmi.objectives._count":
00370 $this->setSingleVariable($var, $value);
00371 $this->setArray("cmi.objectives", $value, "id", $re_value);
00372 $this->setArray("cmi.objectives", $value, "score.raw", $re_value);
00373 $this->setArray("cmi.objectives", $value, "score.max", $re_value);
00374 $this->setArray("cmi.objectives", $value, "score.min", $re_value);
00375 $this->setArray("cmi.objectives", $value, "status", $re_value);
00376 break;
00377
00378 case "cmi.interactions._count":
00379 $this->setSingleVariable($var, $value);
00380 $this->setArray("cmi.interactions", $value, "id", $re_value);
00381 for($i=0; $i<$value; $i++)
00382 {
00383 $var2 = "cmi.interactions.".$i.".objectives._count";
00384 if (isset($v_array[$var2]))
00385 {
00386 $cnt = $v_array[$var2];
00387 $this->setArray("cmi.interactions.".$i.".objectives",
00388 $cnt, "id", $re_value);
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398 }
00399 }
00400 $this->setArray("cmi.interactions", $value, "time", $re_value);
00401 $this->setArray("cmi.interactions", $value, "type", $re_value);
00402 for($i=0; $i<$value; $i++)
00403 {
00404 $var2 = "cmi.interactions.".$i.".correct_responses._count";
00405 if (isset($v_array[$var2]))
00406 {
00407 $cnt = $v_array[$var2];
00408 $this->setArray("cmi.interactions.".$i.".correct_responses",
00409 $cnt, "pattern", $re_value);
00410 $this->setArray("cmi.interactions.".$i.".correct_responses",
00411 $cnt, "weighting", $re_value);
00412 }
00413 }
00414 $this->setArray("cmi.interactions", $value, "student_response", $re_value);
00415 $this->setArray("cmi.interactions", $value, "result", $re_value);
00416 $this->setArray("cmi.interactions", $value, "latency", $re_value);
00417 break;
00418 }
00419 }
00420
00421 global $lng;
00422 $this->tpl->setCurrentBlock("switch_icon");
00423 $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
00424 $this->tpl->setVariable("SCO_ICO", ilUtil::getImagePath("scorm/running.gif"));
00425 $this->tpl->setVariable("SCO_ALT",
00426 $lng->txt("cont_status").": "
00427 .$lng->txt("cont_sc_stat_running")
00428 );
00429 $this->tpl->parseCurrentBlock();
00430
00431
00432 $lesson_mode = $this->slm->getDefaultLessonMode();
00433 if ($this->slm->getAutoReview())
00434 {
00435 if ($re_value["cmi.core.lesson_status"] == "completed" ||
00436 $re_value["cmi.core.lesson_status"] == "passed" ||
00437 $re_value["cmi.core.lesson_status"] == "failed")
00438 {
00439 $lesson_mode = "review";
00440 }
00441 }
00442 $this->tpl->setVariable("LESSON_MODE", $lesson_mode);
00443
00444
00445 if ($lesson_mode == "normal")
00446 {
00447 $this->tpl->setVariable("CREDIT_MODE",
00448 str_replace("_", "-", $this->slm->getCreditMode()));
00449 }
00450 else
00451 {
00452 $this->tpl->setVariable("CREDIT_MODE", "no-credit");
00453 }
00454
00455
00456 $sahs_obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
00457 if (!isset($re_value["cmi.core.total_time"]))
00458 {
00459 $item->insertTrackData("cmi.core.total_time", "0000:00:00", $sahs_obj_id);
00460 }
00461 if (!isset($re_value["cmi.core.lesson_status"]))
00462 {
00463 $item->insertTrackData("cmi.core.lesson_status", "not attempted", $sahs_obj_id);
00464 }
00465 if (!isset($re_value["cmi.core.entry"]))
00466 {
00467 $item->insertTrackData("cmi.core.entry", "", $sahs_obj_id);
00468 }
00469
00470 $this->tpl->show();
00471 }
00472
00473 function finishSahs ()
00474 {
00475 global $lng;
00476 $this->tpl = new ilTemplate("tpl.sahs_finish_cbt.html", true, true, "Modules/ScormAicc");
00477 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00478
00479 $this->tpl->setCurrentBlock("switch_icon");
00480 $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
00481 $this->tpl->setVariable("SCO_ICO", ilUtil::getImagePath(
00482 "scorm/".str_replace(" ", "_", $_GET["status"]).'.gif')
00483 );
00484 $this->tpl->setVariable("SCO_ALT",
00485 $lng->txt("cont_status").": "
00486 .$lng->txt("cont_sc_stat_".str_replace(" ", "_", $_GET["status"])).", "
00487 .$lng->txt("cont_total_time"). ": "
00488 .$_GET["totime"]
00489 );
00490 $this->tpl->setVariable("SCO_LAUNCH_ID", $_GET["launch"]);
00491 $this->tpl->parseCurrentBlock();
00492 $this->tpl->show();
00493 }
00494
00495 function unloadSahs ()
00496 {
00497 $this->tpl = new ilTemplate("tpl.sahs_unload_cbt.html", true, true, "Modules/ScormAicc");
00498 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00499 $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
00500 $this->tpl->show();
00501 }
00502
00503
00504 function launchAsset()
00505 {
00506 global $ilUser, $ilDB;
00507
00508 $sco_id = ($_GET["asset_id"] == "")
00509 ? $_POST["asset_id"]
00510 : $_GET["asset_id"];
00511 $ref_id = ($_GET["ref_id"] == "")
00512 ? $_POST["ref_id"]
00513 : $_GET["ref_id"];
00514
00515 $this->slm =& new ilObjSCORMLearningModule($ref_id, true);
00516
00517 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php");
00518 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMResource.php");
00519 $item =& new ilSCORMItem($sco_id);
00520
00521 $id_ref = $item->getIdentifierRef();
00522 $resource =& new ilSCORMResource();
00523 $resource->readByIdRef($id_ref, $item->getSLMId());
00524 $href = $resource->getHref();
00525 $this->tpl->setVariable("HREF", $this->slm->getDataDirectory("output")."/".$href);
00526 $this->tpl = new ilTemplate("tpl.scorm_launch_asset.html", true, true, "Modules/ScormAicc");
00527 $this->tpl->setVariable("HREF", $this->slm->getDataDirectory("output")."/".$href);
00528 $this->tpl->show();
00529 }
00530
00531
00535 function setSingleVariable($a_var, $a_value)
00536 {
00537 $this->tpl->setCurrentBlock("set_value");
00538 $this->tpl->setVariable("VAR", $a_var);
00539 $this->tpl->setVariable("VALUE", $a_value);
00540 $this->tpl->parseCurrentBlock();
00541 }
00542
00546 function setArray($a_left, $a_value, $a_name, &$v_array)
00547 {
00548 for($i=0; $i<$a_value; $i++)
00549 {
00550 $var = $a_left.".".$i.".".$a_name;
00551 if (isset($v_array[$var]))
00552 {
00553 $this->tpl->setCurrentBlock("set_value");
00554 $this->tpl->setVariable("VAR", $var);
00555 $this->tpl->setVariable("VALUE", $v_array[$var]);
00556 $this->tpl->parseCurrentBlock();
00557 }
00558 }
00559 }
00560
00566 function infoScreen()
00567 {
00568 $this->ctrl->setCmd("showSummary");
00569 $this->ctrl->setCmdClass("ilinfoscreengui");
00570 $this->outputInfoScreen();
00571 }
00572
00576 function outputInfoScreen($a_standard_locator = false)
00577 {
00578 global $ilBench, $ilLocator, $ilAccess, $tpl;
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594 $this->tpl->getStandardTemplate();
00595 $this->tpl->setTitle($this->slm_gui->object->getTitle());
00596 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_slm_b.gif"));
00597
00598 $ilLocator->addRepositoryItems();
00599 $ilLocator->addItem($this->slm_gui->object->getTitle(),
00600 $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
00601
00602 $this->tpl->setLocator();
00603
00604 $this->lng->loadLanguageModule("meta");
00605
00606 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
00607
00608 $info = new ilInfoScreenGUI($this->slm_gui);
00609 $info->enablePrivateNotes();
00610
00611
00612 $info->enableNews();
00613 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
00614 {
00615 $info->enableNewsEditing();
00616 $news_set = new ilSetting("news");
00617 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
00618 if ($enable_internal_rss)
00619 {
00620 $info->setBlockProperty("news", "settings", true);
00621 }
00622 }
00623
00624
00625 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
00626 {
00627 $info->addButton($this->lng->txt("view"),
00628 $this->ctrl->getLinkTarget($this, ""),
00629 ' target="ilContObj'.$this->slm_gui->object->getId().'" ');
00630 }
00631
00632
00633 $info->addMetaDataSections($this->slm_gui->object->getId(),0,
00634 $this->slm_gui->object->getType());
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645 $this->ctrl->forwardCommand($info);
00646
00647 $this->tpl->show();
00648
00649 }
00650
00651
00652 }
00653 ?>