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