ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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: shib_login.php:22
Class ilObjSCORMLearningModule.
+ Here is the call graph for this function:

Member Function Documentation

◆ apiInitData()

ilSCORMPresentationGUI::apiInitData ( )

SCORM Data for Javascript-API.

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

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

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

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

438  : void
439  {
440  global $DIC;
441  $lng = $DIC->language();
442  $this->tpl = new ilGlobalTemplate("tpl.scorm_content_select.html", true, true, "components/ILIAS/ScormAicc");
443  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
444  $this->tpl->setVariable('TXT_SPECIALPAGE', $lng->txt("seq_toc"));
445  $this->tpl->printToStdout("DEFAULT", false);
446  }
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
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
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ downloadCertificate()

ilSCORMPresentationGUI::downloadCertificate ( )

Download the certificate for the active user.

Exceptions
ilCtrlException

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

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

497  : void
498  {
499  global $DIC;
500 
501  $ilUser = $DIC->user();
502  $tree = $DIC['tree'];
503  $ilCtrl = $DIC->ctrl();
504  $refId = $DIC->http()->wrapper()->query()->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
505  $obj_id = ilObject::_lookupObjId($refId);
506 
507  $certValidator = new ilCertificateDownloadValidator();
508  $allowed = $certValidator->isCertificateDownloadable($ilUser->getId(), $obj_id);
509  if ($allowed) {
510  $certificateLogger = $DIC->logger()->root();
511 
512  $ilUserCertificateRepository = new ilUserCertificateRepository();
513  $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository);
514  $pdfAction = new ilCertificatePdfAction(
515  $pdfGenerator,
517  $this->lng->txt('error_creating_certificate_pdf')
518  );
519 
520  $pdfAction->downloadPdf($ilUser->getId(), $obj_id);
521  exit;
522  }
523  // redirect to parent category if certificate is not accessible
524  $parent = $tree->getParentId($refId);
525  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $parent);
526  $ilCtrl->redirectByClass("ilrepositorygui", "");
527  }
static _lookupObjId(int $ref_id)
Validates if an active certificate is stored in the database and can be downloaded by the user...
global $DIC
Definition: shib_login.php:22
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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:33
global $DIC
Definition: shib_login.php:22
+ 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 359 of file class.ilSCORMPresentationGUI.php.

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

359  : void
360  {
361  global $DIC;
362  $ilBench = $DIC['ilBench'];
363  $ilLog = ilLoggerFactory::getLogger('sahs');
364 
365  $ilBench->start("SCORMExplorer", "initExplorer");
366 
367  $this->tpl = new ilGlobalTemplate("tpl.sahs_exp_main.html", true, true, "components/ILIAS/ScormAicc");
368  // $this->tpl = new ilTemplate("tpl.sahs_exp_main.html", true, true, "components/ILIAS/ScormAicc");
369  $exp = new ilSCORMExplorer($this->ctrl->getLinkTarget($this, "view"), $this->slm);
370  $exp->setTargetGet("obj_id");
371  $exp->setFrameTarget($a_target);
372 
373  //$exp->setFiltered(true);
374  $jsApi = true;
375 
376  $expanded = "";
377  if ($DIC->http()->wrapper()->query()->has('scexpand')) {
378  $expanded = $DIC->http()->wrapper()->query()->retrieve('scexpand', $DIC->refinery()->kindlyTo()->string());
379  }
380  if ($expanded == "") {
381  $mtree = new ilSCORMTree($this->slm->getId());
382  $expanded = $mtree->readRootId();
383  }
384  $exp->setExpand($expanded);
385 
386  $exp->forceExpandAll(true, false);
387  $ilBench->stop("SCORMExplorer", "initExplorer");
388 
389  // build html-output
390  $ilBench->start("SCORMExplorer", "setOutput");
391  $exp->setOutput(0);
392  $ilBench->stop("SCORMExplorer", "setOutput");
393 
394  $ilBench->start("SCORMExplorer", "getOutput");
395  $output = $exp->getOutput($jsApi);
396  $ilBench->stop("SCORMExplorer", "getOutput");
397 
398  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
399  $this->tpl->addBlockFile("CONTENT", "content", "tpl.sahs_explorer.html", "components/ILIAS/ScormAicc");
400  //$this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_content"));
401  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
402  $this->tpl->setVariable("EXPLORER", $output);
403 
404  $cmd = "";
405  if ($DIC->http()->wrapper()->query()->has('cmd')) {
406  $cmd = $DIC->http()->wrapper()->query()->retrieve('cmd', $DIC->refinery()->kindlyTo()->string());
407  }
408  $frame = "";
409  if ($DIC->http()->wrapper()->query()->has('frame')) {
410  $frame = $DIC->http()->wrapper()->query()->retrieve('frame', $DIC->refinery()->kindlyTo()->string());
411  }
412  $this->tpl->setVariable("ACTION", "ilias.php?baseClass=ilSAHSPresentationGUI&cmd=" . $cmd . "&frame=" . $frame .
413  "&ref_id=" . $this->slm->getRefId() . "&scexpand=" . $expanded);
414  $this->tpl->parseCurrentBlock();
415  //BUG 16794? $this->tpl->show();
416  // $this->tpl->show();
417  $this->tpl->printToStdout("DEFAULT", false);
418  }
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
static getLogger(string $a_component_id)
Get component logger.
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: shib_login.php:22
SCORM Object Tree.
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, 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, "components/ILIAS/ScormAicc");
131  } else {
132  $this->tpl = new ilGlobalTemplate("tpl.sahs_pres_frameset_js.html", false, false, "components/ILIAS/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, "components/ILIAS/ScormAicc");
141  } else {
142  $this->tpl = new ilGlobalTemplate("tpl.sahs_pres_frameset_js_one_page.html", false, false, "components/ILIAS/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("API_LINK", $api_link);
150  $this->tpl->printToStdout("DEFAULT", false, true);
151 
152 
153  exit;
154  }
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 signFolderOfStartFile(string $start_file_path)
global $DIC
Definition: shib_login.php:22
increase_attemptAndsave_module_version()
Increases attempts by one for this package.
exit
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:

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

References $DIC, $ilDB, and null.

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

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

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

Referenced by frameset().

270  : void
271  {
272  global $DIC;
273  $ilDB = $DIC->database();
274  $ilUser = $DIC->user();
275  $res = $ilDB->queryF(
276  'SELECT package_attempts,count(*) cnt FROM sahs_user WHERE obj_id = %s AND user_id = %s GROUP BY package_attempts',
277  array('integer','integer'),
278  array($this->slm->getId(),$ilUser->getId())
279  );
280  $val_rec = $ilDB->fetchAssoc($res);
281  if (!is_array($val_rec)) {
282  $attempts = 1;
283  $ilDB->manipulateF(
284  'INSERT INTO sahs_user (obj_id,user_id,package_attempts,module_version,last_access) VALUES(%s,%s,%s,%s,%s)',
285  array('integer', 'integer', 'integer', 'integer', 'timestamp'),
286  array($this->slm->getId(), $ilUser->getId(), $attempts, $this->slm->getModuleVersion(), date('Y-m-d H:i:s'))
287  );
288  } else {
289  $attempts = $val_rec["package_attempts"];
290  if ($attempts == null) {
291  $attempts = 0;
292  }
293  $attempts++;
294  $ilDB->manipulateF(
295  'UPDATE sahs_user SET package_attempts = %s, module_version = %s, last_access=%s WHERE obj_id = %s AND user_id = %s ',
296  array('integer', 'integer', 'timestamp', 'integer', 'integer'),
297  array($attempts, $this->slm->getModuleVersion(), date('Y-m-d H:i:s'), $this->slm->getId(), $ilUser->getId())
298  );
299  }
300  ilLPStatusWrapper::_updateStatus($this->slm->getId(), $ilUser->getId());
301  }
$res
Definition: ltiservices.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
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 487 of file class.ilSCORMPresentationGUI.php.

References ilWACSignedPath\signFolderOfStartFile().

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

◆ view()

ilSCORMPresentationGUI::view ( )

SCORM content screen.

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

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

424  : void
425  {
426  global $DIC;
427  $objId = $DIC->http()->wrapper()->query()->retrieve('obj_id', $DIC->refinery()->kindlyTo()->int());
428  $sc_gui_object = ilSCORMObjectGUI::getInstance($objId);
429 
430  if (is_object($sc_gui_object)) {
431  $sc_gui_object->view();
432  }
433 
434  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
435  $this->tpl->printToStdout('DEFAULT', false);
436  }
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
$objId
Definition: xapitoken.php:57
global $DIC
Definition: shib_login.php:22
+ 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: