ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilSCORMPresentationGUI Class Reference

Class ilSCORMPresentationGUI. More...

+ Collaboration diagram for ilSCORMPresentationGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 execute command More...
 
 attrib2arr (?array $a_attributes)
 
 frameset ()
 Output main frameset. More...
 
 get_actual_attempts ()
 Get number of actual attempts for the user. More...
 
 increase_attemptAndsave_module_version ()
 Increases attempts by one for this package. More...
 
 explorer (string $a_target="sahs_content")
 save the active module version to scorm_tracking More...
 
 view ()
 SCORM content screen. More...
 
 contentSelect ()
 
 apiInitData ()
 SCORM Data for Javascript-API. More...
 
 pingSession ()
 
 logMessage ()
 
 logWarning ()
 
 downloadCertificate ()
 Download the certificate for the active user. More...
 

Data Fields

ilObjSCORMLearningModule $slm
 
ilGlobalTemplate $tpl
 
ilLanguage $lng
 

Protected Attributes

ilLogger $logger
 
int $refId
 
ilCtrlInterface $ctrl
 

Private Member Functions

 getApiLogPayload ()
 

Detailed Description

Class ilSCORMPresentationGUI.

GUI class for scorm learning module presentation

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

\

Definition at line 31 of file class.ilSCORMPresentationGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSCORMPresentationGUI::__construct ( )

Definition at line 40 of file class.ilSCORMPresentationGUI.php.

41 {
42 global $DIC;
43 $ilCtrl = $DIC->ctrl();
44 // $this->tpl = $DIC['tpl'];
45 $this->lng = $DIC->language();
46 $this->ctrl = $ilCtrl;
47 $this->logger = ilLoggerFactory::getLogger('sahs');
48
49 $this->lng->loadLanguageModule('cert');
50
51 // Todo: check lm id
52 $this->refId = $DIC->http()->wrapper()->query()->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
53 $this->slm = new ilObjSCORMLearningModule($this->refId, true);
54 }
static getLogger(string $a_component_id)
Get component logger.
Class ilObjSCORMLearningModule.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), ilLoggerFactory\getLogger(), ILIAS\Repository\lng(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Member Function Documentation

◆ apiInitData()

ilSCORMPresentationGUI::apiInitData ( )

SCORM Data for Javascript-API.

Definition at line 454 of file class.ilSCORMPresentationGUI.php.

454 : void
455 {
456 global $DIC;
457
458 if (!($DIC->http()->wrapper()->query()->has('ref_id'))) {
459 print('alert("no start without ref_id");');
460 die;
461 }
462
463 header('Content-Type: text/javascript; charset=UTF-8');
464 print("function iliasApi() {\r\n");
465 $js_data = file_get_contents("../components/ILIAS/ScormAicc/scripts/basisAPI.js");
466 echo $js_data;
467 $js_data = file_get_contents("../components/ILIAS/ScormAicc/scripts/SCORM1_2standard.js");//want to give opportunities to different files (Uwe Kohnle)
468 echo $js_data;
469 print("}\r\n");
470
471 print("IliasScormVars=" . ilObjSCORMInitData::getIliasScormVars($this->slm) . ";\r\n");
472
473 //Resources
474 print("IliasScormResources=" . ilObjSCORMInitData::getIliasScormResources($this->slm->getId()) . ";\r\n");
475
476 //Tree
477 print("IliasScormTree=" . ilObjSCORMInitData::getIliasScormTree($this->slm->getId()) . ";\r\n");
478
479 //prevdata
480 print("IliasScormData=" . ilObjSCORMInitData::getIliasScormData($this->slm->getId()) . ";\r\n");
481
482 // set alternative API name - not necessary for scorm
483 if ($this->slm->getAPIAdapterName() !== "API") {
484 print('var ' . $this->slm->getAPIAdapterName() . '=new iliasApi();');
485 } else {
486 print('var API=new iliasApi();');
487 }
488 }
static getIliasScormResources(int $a_packageId)
static getIliasScormTree(int $a_packageId)
static getIliasScormVars(ilObjSCORMLearningModule $slm_obj)
static getIliasScormData(int $a_packageId)

References $DIC, ilObjSCORMInitData\getIliasScormData(), ilObjSCORMInitData\getIliasScormResources(), ilObjSCORMInitData\getIliasScormTree(), ilObjSCORMInitData\getIliasScormVars(), and ILIAS\UI\examples\Symbol\Glyph\Header\header().

+ Here is the call graph for this function:

◆ attrib2arr()

ilSCORMPresentationGUI::attrib2arr ( ?array  $a_attributes)
Returns
mixed[]

Definition at line 85 of file class.ilSCORMPresentationGUI.php.

85 : array
86 {
87 $attr = array();
88
89 if (!is_array($a_attributes)) {
90 return $attr;
91 }
92 foreach ($a_attributes as $attribute) {
93 $attr[$attribute->name()] = $attribute->value();
94 }
95
96 return $attr;
97 }

◆ contentSelect()

ilSCORMPresentationGUI::contentSelect ( )

Definition at line 441 of file class.ilSCORMPresentationGUI.php.

441 : void
442 {
443 global $DIC;
444 $lng = $DIC->language();
445 $this->tpl = new ilGlobalTemplate("tpl.scorm_content_select.html", true, true, "components/ILIAS/ScormAicc");
446 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
447 $this->tpl->setVariable('TXT_SPECIALPAGE', $lng->txt("seq_toc"));
448 $this->tpl->printToStdout("DEFAULT", false);
449 }
special template class to simplify handling of ITX/PEAR
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user

References $DIC, $lng, ilUtil\getStyleSheetLocation(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ downloadCertificate()

ilSCORMPresentationGUI::downloadCertificate ( )

Download the certificate for the active user.

Exceptions
ilCtrlException

Definition at line 518 of file class.ilSCORMPresentationGUI.php.

518 : void
519 {
520 global $DIC;
521
522 $ilUser = $DIC->user();
523 $tree = $DIC['tree'];
524 $ilCtrl = $DIC->ctrl();
525 $refId = $DIC->http()->wrapper()->query()->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
527
528 $certValidator = new ilCertificateDownloadValidator();
529 $allowed = $certValidator->isCertificateDownloadable($ilUser->getId(), $obj_id);
530 if ($allowed) {
531 $certificateLogger = $DIC->logger()->forComponent('sahs');
532
533 $ilUserCertificateRepository = new ilUserCertificateRepository();
534 $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository);
535 $pdfAction = new ilCertificatePdfAction(
536 $pdfGenerator,
538 $this->lng->txt('error_creating_certificate_pdf')
539 );
540
541 $pdfAction->downloadPdf($ilUser->getId(), $obj_id);
542 exit;
543 }
544 // redirect to parent category if certificate is not accessible
545 $parent = $tree->getParentId($refId);
546 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $parent);
547 $ilCtrl->redirectByClass("ilrepositorygui", "");
548 }
Validates if an active certificate is stored in the database and can be downloaded by the user.
Just a wrapper class to create Unit Test for other classes.
static _lookupObjId(int $ref_id)
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $DIC, $refId, ilObject\_lookupObjId(), exit, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ executeCommand()

ilSCORMPresentationGUI::executeCommand ( )

execute command

Exceptions
ilCtrlException

Definition at line 60 of file class.ilSCORMPresentationGUI.php.

60 : void
61 {
62 global $DIC;
63 $ilAccess = $DIC->access();
64 $lng = $DIC->language();
65 $ilErr = $DIC["ilErr"];
66
67 $next_class = $this->ctrl->getNextClass($this);
68 $cmd = $this->ctrl->getCmd("frameset");
69
70 if (!$ilAccess->checkAccess("write", "", $this->refId) &&
71 (!$ilAccess->checkAccess("read", "", $this->refId) ||
72 $this->slm->getOfflineStatus())) {
73 $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->WARNING);
74 }
75
76 // switch ($next_class) {
77 // default:
78 $this->$cmd();
79 // }
80 }

References $DIC, $lng, ILIAS\Repository\ctrl(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ explorer()

ilSCORMPresentationGUI::explorer ( string  $a_target = "sahs_content")

save the active module version to scorm_tracking

output table of content

Exceptions
ilCtrlException
ilTemplateException

Definition at line 363 of file class.ilSCORMPresentationGUI.php.

363 : void
364 {
365 global $DIC;
366 $ilBench = $DIC['ilBench'];
367
368 $ilBench->start("SCORMExplorer", "initExplorer");
369
370 $this->tpl = new ilGlobalTemplate("tpl.sahs_exp_main.html", true, true, "components/ILIAS/ScormAicc");
371 // $this->tpl = new ilTemplate("tpl.sahs_exp_main.html", true, true, "components/ILIAS/ScormAicc");
372 $exp = new ilSCORMExplorer($this->ctrl->getLinkTarget($this, "view"), $this->slm);
373 $exp->setTargetGet("obj_id");
374 $exp->setFrameTarget($a_target);
375
376 //$exp->setFiltered(true);
377 $jsApi = true;
378
379 $expanded = "";
380 if ($DIC->http()->wrapper()->query()->has('scexpand')) {
381 $expanded = $DIC->http()->wrapper()->query()->retrieve('scexpand', $DIC->refinery()->kindlyTo()->string());
382 }
383 if ($expanded == "") {
384 $mtree = new ilSCORMTree($this->slm->getId());
385 $expanded = $mtree->readRootId();
386 }
387 $exp->setExpand($expanded);
388
389 $exp->forceExpandAll(true, false);
390 $ilBench->stop("SCORMExplorer", "initExplorer");
391
392 // build html-output
393 $ilBench->start("SCORMExplorer", "setOutput");
394 $exp->setOutput(0);
395 $ilBench->stop("SCORMExplorer", "setOutput");
396
397 $ilBench->start("SCORMExplorer", "getOutput");
398 $output = $exp->getOutput($jsApi);
399 $ilBench->stop("SCORMExplorer", "getOutput");
400
401 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
402 $this->tpl->addBlockFile("CONTENT", "content", "tpl.sahs_explorer.html", "components/ILIAS/ScormAicc");
403 //$this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_content"));
404 $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
405 $this->tpl->setVariable("EXPLORER", $output);
406
407 $cmd = "";
408 if ($DIC->http()->wrapper()->query()->has('cmd')) {
409 $cmd = $DIC->http()->wrapper()->query()->retrieve('cmd', $DIC->refinery()->kindlyTo()->string());
410 }
411 $frame = "";
412 if ($DIC->http()->wrapper()->query()->has('frame')) {
413 $frame = $DIC->http()->wrapper()->query()->retrieve('frame', $DIC->refinery()->kindlyTo()->string());
414 }
415 $this->tpl->setVariable("ACTION", "ilias.php?baseClass=ilSAHSPresentationGUI&cmd=" . $cmd . "&frame=" . $frame .
416 "&ref_id=" . $this->slm->getRefId() . "&scexpand=" . $expanded);
417 $this->tpl->parseCurrentBlock();
418 //BUG 16794? $this->tpl->show();
419 // $this->tpl->show();
420 $this->tpl->printToStdout("DEFAULT", false);
421 }
SCORM Object Tree.

References $DIC, ILIAS\Repository\ctrl(), ilUtil\getStyleSheetLocation(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ frameset()

ilSCORMPresentationGUI::frameset ( )

Output main frameset.

If only one SCO/Asset is given, it is displayed without the table of contents explorer frame on the left.

Exceptions
ilCtrlException

Definition at line 104 of file class.ilSCORMPresentationGUI.php.

104 : void
105 {
106 global $DIC;
107 $lng = $DIC->language();
108 $javascriptAPI = true;
109 $items = ilSCORMObject::_lookupPresentableItems($this->slm->getId());
110
111 //check for max_attempts and raise error if max_attempts is exceeded
112 // if ($this->get_max_attempts() != 0) {
113 // if ($this->get_actual_attempts() >= $this->get_max_attempts()) {
114 // header('Content-Type: text/html; charset=utf-8');
115 // echo($lng->txt("cont_sc_max_attempt_exceed"));
116 // exit;
117 // }
118 // }
119
121 if (!$this->slm->hasContainerResource()) {
122 ilWACSignedPath::signFolderOfStartFile($this->slm->getDataDirectory() . '/imsmanifest.xml');
123 }
124
125 $debug = $this->slm->getDebug();
126 if (count($items) > 1) {
127 $this->ctrl->setParameter($this, "expand", "1");
128 $this->ctrl->setParameter($this, "jsApi", "1");
129 $exp_link = $this->ctrl->getLinkTarget($this, "explorer");
130
131 // should be able to grep templates
132 if ($debug) {
133 $this->tpl = new ilGlobalTemplate("tpl.sahs_pres_frameset_js_debug.html", false, false, "components/ILIAS/ScormAicc");
134 } else {
135 $this->tpl = new ilGlobalTemplate("tpl.sahs_pres_frameset_js.html", false, false, "components/ILIAS/ScormAicc");
136 }
137
138 $this->tpl->setVariable("EXPLORER_LINK", $exp_link);
139 $pres_link = $this->ctrl->getLinkTarget($this, "contentSelect");
140 $this->tpl->setVariable("PRESENTATION_LINK", $pres_link);
141 } else {
142 if ($debug) {
143 $this->tpl = new ilGlobalTemplate("tpl.sahs_pres_frameset_js_debug_one_page.html", false, false, "components/ILIAS/ScormAicc");
144 } else {
145 $this->tpl = new ilGlobalTemplate("tpl.sahs_pres_frameset_js_one_page.html", false, false, "components/ILIAS/ScormAicc");
146 }
147
148 $this->ctrl->setParameter($this, "autolaunch", $items[0] ?? "");
149 }
150 $api_link = $this->ctrl->getLinkTarget($this, "apiInitData");
151 $this->tpl->setVariable("TITLE", $this->slm->getTitle());
152 $this->tpl->setVariable("ICON", ilUtil::getImagePath("favicon.ico", ""));
153 $this->tpl->setVariable("API_LINK", $api_link);
154 $this->tpl->printToStdout("DEFAULT", false, true);
155
156
157 exit;
158 }
static _lookupPresentableItems(int $a_slm_id)
Count number of presentable SCOs/Assets of SCORM learning module.
increase_attemptAndsave_module_version()
Increases attempts by one for this package.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static signFolderOfStartFile(string $start_file_path)

References $DIC, $lng, ilSCORMObject\_lookupPresentableItems(), ILIAS\Repository\ctrl(), exit, ilUtil\getImagePath(), increase_attemptAndsave_module_version(), and ilWACSignedPath\signFolderOfStartFile().

+ Here is the call graph for this function:

◆ get_actual_attempts()

ilSCORMPresentationGUI::get_actual_attempts ( )

Get number of actual attempts for the user.

Definition at line 171 of file class.ilSCORMPresentationGUI.php.

171 : int
172 {
173 global $DIC;
174 $ilDB = $DIC->database();
175 $ilUser = $DIC->user();
176 $val_set = $ilDB->queryF(
177 'SELECT package_attempts FROM sahs_user WHERE obj_id = %s AND user_id = %s',
178 array('integer','integer'),
179 array($this->slm->getId(),$ilUser->getId())
180 );
181 $val_rec = $ilDB->fetchAssoc($val_set);
182 $attempts = $val_rec["package_attempts"];
183 if ($attempts == null) {
184 $attempts = 0;
185 }
186 return $attempts;
187 }

References $DIC, and $ilDB.

◆ getApiLogPayload()

ilSCORMPresentationGUI::getApiLogPayload ( )
private

Definition at line 508 of file class.ilSCORMPresentationGUI.php.

508 : string
509 {
510 $payload = (string) file_get_contents('php://input');
511 return substr(str_replace(["\r", "\n"], ["\\r", "\\n"], $payload), 0, 4096);
512 }

Referenced by logMessage(), and logWarning().

+ Here is the caller graph for this function:

◆ increase_attemptAndsave_module_version()

ilSCORMPresentationGUI::increase_attemptAndsave_module_version ( )

Increases attempts by one for this package.

Increases attempts by one and saves module_version for this package

Definition at line 274 of file class.ilSCORMPresentationGUI.php.

274 : void
275 {
276 global $DIC;
277 $ilDB = $DIC->database();
278 $ilUser = $DIC->user();
279 $res = $ilDB->queryF(
280 'SELECT package_attempts,count(*) cnt FROM sahs_user WHERE obj_id = %s AND user_id = %s GROUP BY package_attempts',
281 array('integer','integer'),
282 array($this->slm->getId(),$ilUser->getId())
283 );
284 $val_rec = $ilDB->fetchAssoc($res);
285 if (!is_array($val_rec)) {
286 $attempts = 1;
287 $ilDB->manipulateF(
288 'INSERT INTO sahs_user (obj_id,user_id,package_attempts,module_version,last_access) VALUES(%s,%s,%s,%s,%s)',
289 array('integer', 'integer', 'integer', 'integer', 'timestamp'),
290 array($this->slm->getId(), $ilUser->getId(), $attempts, $this->slm->getModuleVersion(), date('Y-m-d H:i:s'))
291 );
292 } else {
293 $attempts = $val_rec["package_attempts"];
294 if ($attempts == null) {
295 $attempts = 0;
296 }
297 $attempts++;
298 $ilDB->manipulateF(
299 'UPDATE sahs_user SET package_attempts = %s, module_version = %s, last_access=%s WHERE obj_id = %s AND user_id = %s ',
300 array('integer', 'integer', 'timestamp', 'integer', 'integer'),
301 array($attempts, $this->slm->getModuleVersion(), date('Y-m-d H:i:s'), $this->slm->getId(), $ilUser->getId())
302 );
303 }
304 ilLPStatusWrapper::_updateStatus($this->slm->getId(), $ilUser->getId());
305 }
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, $res, ilLPStatusWrapper\_updateStatus(), and ILIAS\UI\examples\Symbol\Glyph\Date\date().

Referenced by frameset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ logMessage()

ilSCORMPresentationGUI::logMessage ( )

Definition at line 498 of file class.ilSCORMPresentationGUI.php.

498 : void
499 {
500 $this->logger->info("ScormAicc: ApiLog: Message: " . $this->getApiLogPayload());
501 }

References getApiLogPayload(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ logWarning()

ilSCORMPresentationGUI::logWarning ( )

Definition at line 503 of file class.ilSCORMPresentationGUI.php.

503 : void
504 {
505 $this->logger->warning("ScormAicc: ApiLog: Warning: " . $this->getApiLogPayload());
506 }

References getApiLogPayload(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ pingSession()

ilSCORMPresentationGUI::pingSession ( )

Definition at line 490 of file class.ilSCORMPresentationGUI.php.

490 : bool
491 {
492 if (!$this->slm->hasContainerResource()) {
493 ilWACSignedPath::signFolderOfStartFile($this->slm->getDataDirectory() . '/imsmanifest.xml');
494 }
495 return true;
496 }

References ilWACSignedPath\signFolderOfStartFile().

+ Here is the call graph for this function:

◆ view()

ilSCORMPresentationGUI::view ( )

SCORM content screen.

Definition at line 427 of file class.ilSCORMPresentationGUI.php.

427 : void
428 {
429 global $DIC;
430 $objId = $DIC->http()->wrapper()->query()->retrieve('obj_id', $DIC->refinery()->kindlyTo()->int());
431 $sc_gui_object = ilSCORMObjectGUI::getInstance($objId);
432
433 if (is_object($sc_gui_object)) {
434 $sc_gui_object->view();
435 }
436
437 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
438 $this->tpl->printToStdout('DEFAULT', false);
439 }
$objId
Definition: xapitoken.php:57

References $DIC, $objId, ilSCORMObjectGUI\getInstance(), and ilUtil\getStyleSheetLocation().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrlInterface ilSCORMPresentationGUI::$ctrl
protected

Definition at line 38 of file class.ilSCORMPresentationGUI.php.

◆ $lng

ilLanguage ilSCORMPresentationGUI::$lng

Definition at line 35 of file class.ilSCORMPresentationGUI.php.

Referenced by contentSelect(), executeCommand(), and frameset().

◆ $logger

ilLogger ilSCORMPresentationGUI::$logger
protected

Definition at line 36 of file class.ilSCORMPresentationGUI.php.

◆ $refId

int ilSCORMPresentationGUI::$refId
protected

Definition at line 37 of file class.ilSCORMPresentationGUI.php.

Referenced by downloadCertificate().

◆ $slm

ilObjSCORMLearningModule ilSCORMPresentationGUI::$slm

Definition at line 33 of file class.ilSCORMPresentationGUI.php.

◆ $tpl

ilGlobalTemplate ilSCORMPresentationGUI::$tpl

Definition at line 34 of file class.ilSCORMPresentationGUI.php.


The documentation for this class was generated from the following file: