ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 max. 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 ()
 
 downloadCertificate ()
 Download the certificate for the active user. More...
 

Data Fields

ilObjSCORMLearningModule $slm
 
ilGlobalTemplate $tpl
 
ilLanguage $lng
 

Protected Attributes

int $refId
 
ilCtrlInterface $ctrl
 

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 39 of file class.ilSCORMPresentationGUI.php.

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

40  {
41  global $DIC;
42  $ilCtrl = $DIC->ctrl();
43  // $this->tpl = $DIC['tpl'];
44  $this->lng = $DIC->language();
45  $this->ctrl = $ilCtrl;
46 
47  $this->lng->loadLanguageModule('cert');
48 
49  // Todo: check lm id
50  $this->refId = $DIC->http()->wrapper()->query()->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
51  $this->slm = new ilObjSCORMLearningModule($this->refId, true);
52  }
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

Member Function Documentation

◆ apiInitData()

ilSCORMPresentationGUI::apiInitData ( )

SCORM Data for Javascript-API.

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

References $DIC, ilObjSCORMInitData\getIliasScormData(), ilObjSCORMInitData\getIliasScormResources(), ilObjSCORMInitData\getIliasScormTree(), and ilObjSCORMInitData\getIliasScormVars().

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

◆ attrib2arr()

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

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

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

◆ contentSelect()

ilSCORMPresentationGUI::contentSelect ( )

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

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

439  : void
440  {
441  global $DIC;
442  $lng = $DIC->language();
443  $this->tpl = new ilGlobalTemplate("tpl.scorm_content_select.html", true, true, "Modules/ScormAicc");
444  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
445  $this->tpl->setVariable('TXT_SPECIALPAGE', $lng->txt("seq_toc"));
446  $this->tpl->printToStdout("DEFAULT", false);
447  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
special template class to simplify handling of ITX/PEAR
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ downloadCertificate()

ilSCORMPresentationGUI::downloadCertificate ( )

Download the certificate for the active user.

Exceptions
ilCtrlException

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

References $DIC, $ilUser, ilObject\_lookupObjId(), ilCertificatePdfAction\downloadPdf(), exit, and ILIAS\Repository\lng().

498  : void
499  {
500  global $DIC;
501 
502  $ilUser = $DIC->user();
503  $tree = $DIC['tree'];
504  $ilCtrl = $DIC->ctrl();
505  $refId = $DIC->http()->wrapper()->query()->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
506  $obj_id = ilObject::_lookupObjId($refId);
507 
508  $certValidator = new ilCertificateDownloadValidator();
509  $allowed = $certValidator->isCertificateDownloadable($ilUser->getId(), $obj_id);
510  if ($allowed) {
511  $certificateLogger = $DIC->logger()->root();
512 
513  $ilUserCertificateRepository = new ilUserCertificateRepository();
514  $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository, $certificateLogger);
515 
516  $pdfAction = new ilCertificatePdfAction(
517  $certificateLogger,
518  $pdfGenerator,
520  $this->lng->txt('error_creating_certificate_pdf')
521  );
522 
523  $pdfAction->downloadPdf($ilUser->getId(), $obj_id);
524  exit;
525  }
526  // redirect to parent category if certificate is not accessible
527  $parent = $tree->getParentId($refId);
528  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $parent);
529  $ilCtrl->redirectByClass("ilrepositorygui", "");
530  }
Class ilPdfGeneratorConstantsTest.
exit
Definition: login.php:28
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
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.
$ilUser
Definition: imgupload.php:34
downloadPdf(int $userId, int $objectId)
+ Here is the call graph for this function:

◆ executeCommand()

ilSCORMPresentationGUI::executeCommand ( )

execute command

Exceptions
ilCtrlException

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

References $DIC, $ilErr, ILIAS\Repository\ctrl(), ilLoggerFactory\getLogger(), and ilLanguage\txt().

58  : void
59  {
60  global $DIC;
61  $ilAccess = $DIC->access();
62  $ilLog = ilLoggerFactory::getLogger('sahs');
63  $lng = $DIC->language();
64  $ilErr = $DIC["ilErr"];
65 
66  $next_class = $this->ctrl->getNextClass($this);
67  $cmd = $this->ctrl->getCmd("frameset");
68 
69  if (!$ilAccess->checkAccess("write", "", $this->refId) &&
70  (!$ilAccess->checkAccess("read", "", $this->refId) ||
71  $this->slm->getOfflineStatus())) {
72  $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->WARNING);
73  }
74 
75  // switch ($next_class) {
76  // default:
77  $this->$cmd();
78  // }
79  }
static getLogger(string $a_component_id)
Get component logger.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
$ilErr
Definition: raiseError.php:17
global $DIC
Definition: feed.php:28
+ 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 360 of file class.ilSCORMPresentationGUI.php.

References $DIC, $slm, ILIAS\Repository\ctrl(), ilLoggerFactory\getLogger(), ilUtil\getStyleSheetLocation(), ILIAS\Repository\lng(), ilTree\readRootId(), and ilExplorer\setTargetGet().

360  : void
361  {
362  global $DIC;
363  $ilBench = $DIC['ilBench'];
364  $ilLog = ilLoggerFactory::getLogger('sahs');
365 
366  $ilBench->start("SCORMExplorer", "initExplorer");
367 
368  $this->tpl = new ilGlobalTemplate("tpl.sahs_exp_main.html", true, true, "Modules/ScormAicc");
369  // $this->tpl = new ilTemplate("tpl.sahs_exp_main.html", true, true, "Modules/ScormAicc");
370  $exp = new ilSCORMExplorer($this->ctrl->getLinkTarget($this, "view"), $this->slm);
371  $exp->setTargetGet("obj_id");
372  $exp->setFrameTarget($a_target);
373 
374  //$exp->setFiltered(true);
375  $jsApi = true;
376 
377  $expanded = "";
378  if ($DIC->http()->wrapper()->query()->has('scexpand')) {
379  $expanded = $DIC->http()->wrapper()->query()->retrieve('scexpand', $DIC->refinery()->kindlyTo()->string());
380  }
381  if ($expanded == "") {
382  $mtree = new ilSCORMTree($this->slm->getId());
383  $expanded = $mtree->readRootId();
384  }
385  $exp->setExpand($expanded);
386 
387  $exp->forceExpandAll(true, false);
388  $ilBench->stop("SCORMExplorer", "initExplorer");
389 
390  // build html-output
391  $ilBench->start("SCORMExplorer", "setOutput");
392  $exp->setOutput(0);
393  $ilBench->stop("SCORMExplorer", "setOutput");
394 
395  $ilBench->start("SCORMExplorer", "getOutput");
396  $output = $exp->getOutput($jsApi);
397  $ilBench->stop("SCORMExplorer", "getOutput");
398 
399  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
400  $this->tpl->addBlockFile("CONTENT", "content", "tpl.sahs_explorer.html", "Modules/ScormAicc");
401  //$this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_content"));
402  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
403  $this->tpl->setVariable("EXPLORER", $output);
404 
405  $cmd = "";
406  if ($DIC->http()->wrapper()->query()->has('cmd')) {
407  $cmd = $DIC->http()->wrapper()->query()->retrieve('cmd', $DIC->refinery()->kindlyTo()->string());
408  }
409  $frame = "";
410  if ($DIC->http()->wrapper()->query()->has('frame')) {
411  $frame = $DIC->http()->wrapper()->query()->retrieve('frame', $DIC->refinery()->kindlyTo()->string());
412  }
413  $this->tpl->setVariable("ACTION", "ilias.php?baseClass=ilSAHSPresentationGUI&cmd=" . $cmd . "&frame=" . $frame .
414  "&ref_id=" . $this->slm->getRefId() . "&scexpand=" . $expanded);
415  $this->tpl->parseCurrentBlock();
416  //BUG 16794? $this->tpl->show();
417  // $this->tpl->show();
418  $this->tpl->printToStdout("DEFAULT", false);
419  }
static getLogger(string $a_component_id)
Get component logger.
special template class to simplify handling of ITX/PEAR
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTargetGet(string $a_target_get)
+ 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 103 of file class.ilSCORMPresentationGUI.php.

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

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

◆ get_actual_attempts()

ilSCORMPresentationGUI::get_actual_attempts ( )

Get max.

number of attempts allowed for this package Get number of actual attempts for the user

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

References $DIC, $ilDB, and $ilUser.

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

◆ 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 271 of file class.ilSCORMPresentationGUI.php.

References $DIC, $ilDB, $ilUser, $res, and ilLPStatusWrapper\_updateStatus().

Referenced by frameset().

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

◆ pingSession()

ilSCORMPresentationGUI::pingSession ( )

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

References ilWACSignedPath\signFolderOfStartFile().

488  : bool
489  {
490  ilWACSignedPath::signFolderOfStartFile($this->slm->getDataDirectory() . '/imsmanifest.xml');
491  return true;
492  }
static signFolderOfStartFile(string $start_file_path)
+ Here is the call graph for this function:

◆ view()

ilSCORMPresentationGUI::view ( )

SCORM content screen.

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

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

425  : void
426  {
427  global $DIC;
428  $objId = $DIC->http()->wrapper()->query()->retrieve('obj_id', $DIC->refinery()->kindlyTo()->int());
429  $sc_gui_object = ilSCORMObjectGUI::getInstance($objId);
430 
431  if (is_object($sc_gui_object)) {
432  $sc_gui_object->view();
433  }
434 
435  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
436  $this->tpl->printToStdout('DEFAULT', false);
437  }
$objId
Definition: xapitoken.php:57
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrlInterface ilSCORMPresentationGUI::$ctrl
protected

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

◆ $lng

ilLanguage ilSCORMPresentationGUI::$lng

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

◆ $refId

int ilSCORMPresentationGUI::$refId
protected

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

◆ $slm

ilObjSCORMLearningModule ilSCORMPresentationGUI::$slm

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

Referenced by explorer().

◆ $tpl

ilGlobalTemplate ilSCORMPresentationGUI::$tpl

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


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