ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSCORMPresentationGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php");
6 require_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMObjectGUI.php");
7 
19 {
20  public $ilias;
21  public $slm;
22  public $tpl;
23  public $lng;
24 
25  public function __construct()
26  {
27  global $DIC;
28  $ilias = $DIC['ilias'];
29  $tpl = $DIC['tpl'];
30  $lng = $DIC['lng'];
31  $ilCtrl = $DIC['ilCtrl'];
32 
33  $this->ilias = $ilias;
34  $this->tpl = $tpl;
35  $this->lng = $lng;
36  $this->ctrl = $ilCtrl;
37 
38  $this->lng->loadLanguageModule('cert');
39 
40  // Todo: check lm id
41  $this->slm = new ilObjSCORMLearningModule($_GET["ref_id"], true);
42  }
43 
47  public function executeCommand()
48  {
49  global $DIC;
50  $ilAccess = $DIC['ilAccess'];
51  $ilLog = $DIC['ilLog'];
52  $ilias = $DIC['ilias'];
53  $lng = $DIC['lng'];
54 
55  $next_class = $this->ctrl->getNextClass($this);
56  $cmd = $this->ctrl->getCmd("frameset");
57 
58  if (!$ilAccess->checkAccess("write", "", $_GET["ref_id"]) &&
59  (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]) ||
60  $this->slm->getOfflineStatus())) {
61  $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->WARNING);
62  }
63 
64  switch ($next_class) {
65  default:
66  $this->$cmd();
67  }
68  }
69 
70 
71  public function attrib2arr(&$a_attributes)
72  {
73  $attr = array();
74 
75  if (!is_array($a_attributes)) {
76  return $attr;
77  }
78  foreach ($a_attributes as $attribute) {
79  $attr[$attribute->name()] = $attribute->value();
80  }
81 
82  return $attr;
83  }
84 
85 
90  public function frameset()
91  {
92  global $DIC;
93  $lng = $DIC['lng'];
94  $javascriptAPI = true;
95  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMObject.php");
96  $items = ilSCORMObject::_lookupPresentableItems($this->slm->getId());
97 
98  //check for max_attempts and raise error if max_attempts is exceeded
99  if ($this->get_max_attempts() != 0) {
100  if ($this->get_actual_attempts() >= $this->get_max_attempts()) {
101  header('Content-Type: text/html; charset=utf-8');
102  echo($lng->txt("cont_sc_max_attempt_exceed"));
103  exit;
104  }
105  }
106 
108 
109  //WAC
110  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
111  ilWACSignedPath::signFolderOfStartFile($this->slm->getDataDirectory() . '/imsmanifest.xml');
112 
113  $debug = $this->slm->getDebug();
114  if (count($items) > 1) {
115  $this->ctrl->setParameter($this, "expand", "1");
116  $this->ctrl->setParameter($this, "jsApi", "1");
117  $exp_link = $this->ctrl->getLinkTarget($this, "explorer");
118 
119  // should be able to grep templates
120  if ($debug) {
121  $this->tpl = new ilTemplate("tpl.sahs_pres_frameset_js_debug.html", false, false, "Modules/ScormAicc");
122  } else {
123  $this->tpl = new ilTemplate("tpl.sahs_pres_frameset_js.html", false, false, "Modules/ScormAicc");
124  }
125 
126  $this->tpl->setVariable("EXPLORER_LINK", $exp_link);
127  $pres_link = $this->ctrl->getLinkTarget($this, "contentSelect");
128  $this->tpl->setVariable("PRESENTATION_LINK", $pres_link);
129  } else {
130  if ($debug) {
131  $this->tpl = new ilTemplate("tpl.sahs_pres_frameset_js_debug_one_page.html", false, false, "Modules/ScormAicc");
132  } else {
133  $this->tpl = new ilTemplate("tpl.sahs_pres_frameset_js_one_page.html", false, false, "Modules/ScormAicc");
134  }
135 
136  $this->ctrl->setParameter($this, "autolaunch", $items[0]);
137  }
138  $api_link = $this->ctrl->getLinkTarget($this, "apiInitData");
139  $this->tpl->setVariable("API_LINK", $api_link);
140  $this->tpl->show("DEFAULT", false);
141 
142 
143  exit;
144  }
145 
149  public function get_max_attempts()
150  {
151  include_once "./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMInitData.php";
152  return ilObjSCORMInitData::get_max_attempts($this->slm->getId());
153  }
154 
158  public function get_actual_attempts()
159  {
160  global $DIC;
161  $ilDB = $DIC['ilDB'];
162  $ilUser = $DIC['ilUser'];
163  $val_set = $ilDB->queryF(
164  'SELECT package_attempts FROM sahs_user WHERE obj_id = %s AND user_id = %s',
165  array('integer','integer'),
166  array($this->slm->getId(),$ilUser->getId())
167  );
168  $val_rec = $ilDB->fetchAssoc($val_set);
169  $attempts = $val_rec["package_attempts"];
170  if ($attempts == null) {
171  $attempts = 0;
172  }
173  return $attempts;
174  }
175  // function get_actual_attempts() {
176  // global $DIC;
177  // $ilDB = $DIC['ilDB'];
178  // $ilUser = $DIC['ilUser'];
179  // $val_set = $ilDB->queryF('
180  // SELECT * FROM scorm_tracking
181  // WHERE user_id = %s
182  // AND sco_id = %s
183  // AND lvalue= %s
184  // AND obj_id = %s',
185  // array('integer','integer','text','integer'),
186  // array($ilUser->getId(),0,'package_attempts',$this->slm->getId())
187  // );
188  // $val_rec = $ilDB->fetchAssoc($val_set);
189 
190  // $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
191  // if ($val_rec["rvalue"] == null) {
192  // $val_rec["rvalue"]=0;
193  // }
194 
195  // return $val_rec["rvalue"];
196  // }
197 
201  // function increase_attempt() {
202  // global $DIC;
203  // $ilDB = $DIC['ilDB'];
204  // $ilUser = $DIC['ilUser'];
205 
206  // //get existing account - sco id is always 0
207  // $val_set = $ilDB->queryF('
208  // SELECT * FROM scorm_tracking
209  // WHERE user_id = %s
210  // AND sco_id = %s
211  // AND lvalue= %s
212  // AND obj_id = %s',
213  // array('integer','integer','text','integer'),
214  // array($ilUser->getId(),0,'package_attempts',$this->slm->getId())
215  // );
216 
217  // $val_rec = $ilDB->fetchAssoc($val_set);
218 
219  // $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
220  // if ($val_rec["rvalue"] == null) {
221  // $val_rec["rvalue"]=0;
222  // }
223  // $new_rec = $val_rec["rvalue"]+1;
224  // //increase attempt by 1
225  // //TODO: do not set c_timestamp because of last_access
226  // if($ilDB->numRows($val_set) > 0)
227  // {
228  // $ilDB->update('scorm_tracking',
229  // array(
230  // 'rvalue' => array('clob', $new_rec),
231  // 'c_timestamp' => array('timestamp', ilUtil::now())
232  // ),
233  // array(
234  // 'user_id' => array('integer', $ilUser->getId()),
235  // 'sco_id' => array('integer', 0),
236  // 'lvalue' => array('text', 'package_attempts'),
237  // 'obj_id' => array('integer', $this->slm->getId())
238  // )
239  // );
240  // }
241  // else
242  // {
243  // $ilDB->insert('scorm_tracking', array(
244  // 'obj_id' => array('integer', $this->slm->getId()),
245  // 'user_id' => array('integer', $ilUser->getId()),
246  // 'sco_id' => array('integer', 0),
247  // 'lvalue' => array('text', 'package_attempts'),
248  // 'rvalue' => array('clob', $new_rec),
249  // 'c_timestamp' => array('timestamp', ilUtil::now())
250  // ));
251  // }
252 
253  // include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
254  // ilLPStatusWrapper::_updateStatus($this->slm->getId(), $ilUser->getId());
255 
256  // }
261  {
262  global $DIC;
263  $ilDB = $DIC['ilDB'];
264  $ilUser = $DIC['ilUser'];
265  $res = $ilDB->queryF(
266  'SELECT package_attempts,count(*) cnt FROM sahs_user WHERE obj_id = %s AND user_id = %s GROUP BY package_attempts',
267  array('integer','integer'),
268  array($this->slm->getId(),$ilUser->getId())
269  );
270  $val_rec = $ilDB->fetchAssoc($res);
271  if ($val_rec["cnt"] == 0) { //offline_mode could be inserted
272  $attempts = 1;
273  $ilDB->manipulateF(
274  'INSERT INTO sahs_user (obj_id,user_id,package_attempts,module_version,last_access) VALUES(%s,%s,%s,%s,%s)',
275  array('integer', 'integer', 'integer', 'integer', 'timestamp'),
276  array($this->slm->getId(), $ilUser->getId(), $attempts, $this->slm->getModuleVersion(), date('Y-m-d H:i:s'))
277  );
278  } else {
279  $attempts = $val_rec["package_attempts"];
280  if ($attempts == null) {
281  $attempts = 0;
282  }
283  $attempts++;
284  $ilDB->manipulateF(
285  'UPDATE sahs_user SET package_attempts = %s, module_version = %s, last_access=%s WHERE obj_id = %s AND user_id = %s ',
286  array('integer', 'integer', 'timestamp', 'integer', 'integer'),
287  array($attempts, $this->slm->getModuleVersion(), date('Y-m-d H:i:s'), $this->slm->getId(), $ilUser->getId())
288  );
289  }
290  //only SCORM 1.2, not 2004
291  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
292  ilLPStatusWrapper::_updateStatus($this->slm->getId(), $ilUser->getId());
293  }
294 
298  // function save_module_version() {
299  // global $DIC;
300  // $ilDB = $DIC['ilDB'];
301  // $ilUser = $DIC['ilUser'];
302 
303  // $val_set = $ilDB->queryF('
304  // SELECT * FROM scorm_tracking
305  // WHERE user_id = %s
306  // AND sco_id = %s
307  // AND lvalue= %s
308  // AND obj_id = %s',
309  // array('integer','integer','text','integer'),
310  // array($ilUser->getId(),0,'module_version',$this->slm->getId())
311 
312  // );
313 
314  // if($ilDB->numRows($val_set) > 0)
315  // {
316  // $ilDB->update('scorm_tracking',
317  // array(
318  // 'rvalue' => array('clob', $this->slm->getModuleVersion()),
319  // 'c_timestamp' => array('timestamp', ilUtil::now())
320  // ),
321  // array(
322  // 'user_id' => array('integer', $ilUser->getId()),
323  // 'sco_id' => array('integer', 0),
324  // 'lvalue' => array('text', 'module_version'),
325  // 'obj_id' => array('integer', $this->slm->getId())
326  // )
327  // );
328  // }
329  // else
330  // {
331  // $ilDB->insert('scorm_tracking', array(
332  // 'obj_id' => array('integer', $this->slm->getId()),
333  // 'user_id' => array('integer', $ilUser->getId()),
334  // 'sco_id' => array('integer', 0),
335  // 'lvalue' => array('text', 'module_version'),
336  // 'rvalue' => array('clob', $this->slm->getModuleVersion()),
337  // 'c_timestamp' => array('timestamp', ilUtil::now())
338  // ));
339  // }
340 
341  // include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
342  // ilLPStatusWrapper::_updateStatus($this->slm->getId(), $ilUser->getId());
343 
344  // }
345 
349  public function explorer($a_target = "sahs_content")
350  {
351  global $DIC;
352  $ilBench = $DIC['ilBench'];
353  $ilLog = $DIC['ilLog'];
354 
355  $ilBench->start("SCORMExplorer", "initExplorer");
356 
357  $this->tpl = new ilTemplate("tpl.sahs_exp_main.html", true, true, "Modules/ScormAicc");
358 
359  require_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMExplorer.php");
360  $exp = new ilSCORMExplorer($this->ctrl->getLinkTarget($this, "view"), $this->slm);
361  $exp->setTargetGet("obj_id");
362  $exp->setFrameTarget($a_target);
363 
364  //$exp->setFiltered(true);
365  $jsApi = false;
366  if ($_GET["jsApi"] == "1") {
367  $jsApi = true;
368  }
369 
370  if ($_GET["scexpand"] == "") {
371  $mtree = new ilSCORMTree($this->slm->getId());
372  $expanded = $mtree->readRootId();
373  } else {
374  $expanded = $_GET["scexpand"];
375  }
376  $exp->setExpand($expanded);
377 
378  $exp->forceExpandAll(true, false);
379  $ilBench->stop("SCORMExplorer", "initExplorer");
380 
381  // build html-output
382  $ilBench->start("SCORMExplorer", "setOutput");
383  $exp->setOutput(0);
384  $ilBench->stop("SCORMExplorer", "setOutput");
385 
386  $ilBench->start("SCORMExplorer", "getOutput");
387  $output = $exp->getOutput($jsApi);
388  $ilBench->stop("SCORMExplorer", "getOutput");
389 
390  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
391  $this->tpl->addBlockFile("CONTENT", "content", "tpl.sahs_explorer.html", "Modules/ScormAicc");
392  //$this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_content"));
393  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
394  $this->tpl->setVariable("EXPLORER", $output);
395  $this->tpl->setVariable("ACTION", "ilias.php?baseClass=ilSAHSPresentationGUI&cmd=" . $_GET["cmd"] . "&frame=" . $_GET["frame"] .
396  "&ref_id=" . $this->slm->getRefId() . "&scexpand=" . $_GET["scexpand"]);
397  $this->tpl->parseCurrentBlock();
398  //BUG 16794? $this->tpl->show();
399  $this->tpl->show("DEFAULT", false);
400  }
401 
402 
406  public function view()
407  {
408  $sc_gui_object = ilSCORMObjectGUI::getInstance($_GET["obj_id"]);
409 
410  if (is_object($sc_gui_object)) {
411  $sc_gui_object->view();
412  }
413 
414  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
415  $this->tpl->show(false);
416  }
417 
418  public function contentSelect()
419  {
420  global $DIC;
421  $lng = $DIC['lng'];
422  $this->tpl = new ilTemplate("tpl.scorm_content_select.html", true, true, "Modules/ScormAicc");
423  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
424  $this->tpl->setVariable('TXT_SPECIALPAGE', $lng->txt("seq_toc"));
425  $this->tpl->show();
426  }
427 
431  public function apiInitData()
432  {
433  // global $DIC;
434  // $ilias = $DIC['ilias'];
435  // $ilLog = $DIC['ilLog'];
436  // $ilUser = $DIC['ilUser'];
437  // $lng = $DIC['lng'];
438  // $ilDB = $DIC['ilDB'];
439 
440  if ($_GET["ref_id"] == "") {
441  print('alert("no start without ref_id");');
442  die;
443  }
444 
445  header('Content-Type: text/javascript; charset=UTF-8');
446  print("function iliasApi() {\r\n");
447  $js_data = file_get_contents("./Modules/ScormAicc/scripts/basisAPI.js");
448  echo $js_data;
449  $js_data = file_get_contents("./Modules/ScormAicc/scripts/SCORM1_2standard.js");//want to give opportunities to different files (Uwe Kohnle)
450  echo $js_data;
451  print("}\r\n");
452 
453  include_once("./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMInitData.php");
454 
455  print("IliasScormVars=" . ilObjSCORMInitData::getIliasScormVars($this->slm) . ";\r\n");
456 
457  //Resources
458  print("IliasScormResources=" . ilObjSCORMInitData::getIliasScormResources($this->slm->getId()) . ";\r\n");
459 
460  //Tree
461  print("IliasScormTree=" . ilObjSCORMInitData::getIliasScormTree($this->slm->getId()) . ";\r\n");
462 
463  //prevdata
464  print("IliasScormData=" . ilObjSCORMInitData::getIliasScormData($this->slm->getId()) . ";\r\n");
465 
466  // set alternative API name - not necessary for scorm
467  if ($this->slm->getAPIAdapterName() != "API") {
468  print('var ' . $this->slm->getAPIAdapterName() . '=new iliasApi();');
469  } else {
470  print('var API=new iliasApi();');
471  }
472  }
473 
474 
475  public function api()
476  {
477  global $DIC;
478  $ilias = $DIC['ilias'];
479 
480  $slm_obj = new ilObjSCORMLearningModule($_GET["ref_id"]);
481 
482  $this->tpl = new ilTemplate("tpl.sahs_api.html", true, true, "Modules/ScormAicc");
483 
484  // for scorm modules with only one presentable item: launch item
485  if ($_GET["autolaunch"] != "") {
486  $this->tpl->setCurrentBlock("auto_launch");
487  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php");
488  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMResource.php");
489  $sc_object = new ilSCORMItem($_GET["autolaunch"]);
490  $id_ref = $sc_object->getIdentifierRef();
491  $sc_res_id = ilSCORMResource::_lookupIdByIdRef($id_ref, $sc_object->getSLMId());
492  $scormtype = strtolower(ilSCORMResource::_lookupScormType($sc_res_id));
493 
494  if ($scormtype == "asset") {
495  $item_command = "IliasLaunchAsset";
496  } else {
497  $item_command = "IliasLaunchSahs";
498  }
499  $this->tpl->setVariable("AUTO_LAUNCH_ID", $_GET["autolaunch"]);
500  $this->tpl->setVariable("AUTO_LAUNCH_CMD", "this.autoLaunch();");
501  $this->tpl->setVariable("AUTO_LAUNCH_ITEM_CMD", $item_command);
502  $this->tpl->parseCurrentBlock();
503  }
504 
505  //unlimited sessions
506  if ($slm_obj->getSession()) {
507  $session_timeout = (int) ($ilias->ini->readVariable("session", "expire")) / 2;
508  } else {
509  $session_timeout = 0;
510  }
511  $this->tpl->setVariable("PING_SESSION", $session_timeout);
512 
513  $this->tpl->setVariable("USER_ID", $ilias->account->getId());
514  $this->tpl->setVariable("USER_FIRSTNAME", $ilias->account->getFirstname());
515  $this->tpl->setVariable("USER_LASTNAME", $ilias->account->getLastname());
516  $this->tpl->setVariable("USER_LOGIN", $ilias->account->getLogin());
517  $this->tpl->setVariable("USER_OU", $ilias->account->getDepartment());
518  $this->tpl->setVariable("REF_ID", $_GET["ref_id"]);
519  $this->tpl->setVariable("SESSION_ID", session_id());
520  $this->tpl->setVariable("CODE_BASE", "http://" . $_SERVER['SERVER_NAME'] . substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], "/ilias.php")));
521 
522  $this->tpl->parseCurrentBlock();
523  $this->tpl->show(false);
524  exit;
525  }
526 
531  public function launchSahs()
532  {
533  global $DIC;
534  $ilUser = $DIC['ilUser'];
535  $ilDB = $DIC['ilDB'];
536 
537  $sco_id = ($_GET["sahs_id"] == "")
538  ? $_POST["sahs_id"]
539  : $_GET["sahs_id"];
540  $ref_id = ($_GET["ref_id"] == "")
541  ? $_POST["ref_id"]
542  : $_GET["ref_id"];
543 
544  $this->slm = new ilObjSCORMLearningModule($ref_id, true);
545 
546  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php");
547  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMResource.php");
548  $item = new ilSCORMItem($sco_id);
549 
550  $id_ref = $item->getIdentifierRef();
551  $resource = new ilSCORMResource();
552  $resource->readByIdRef($id_ref, $item->getSLMId());
553  //$slm_obj = new ilObjSCORMLearningModule($_GET["ref_id"]);
554  $href = $resource->getHref();
555  $this->tpl = new ilTemplate("tpl.sahs_launch_cbt.html", true, true, "Modules/ScormAicc");
556  $this->tpl->setVariable("HREF", $this->slm->getDataDirectory("output") . "/" . $href);
557 
558  // set item data
559  $this->tpl->setVariable("LAUNCH_DATA", $item->getDataFromLms());
560  $this->tpl->setVariable("MAST_SCORE", $item->getMasteryScore());
561  $this->tpl->setVariable("MAX_TIME", $item->getMaxTimeAllowed());
562  $this->tpl->setVariable("LIMIT_ACT", $item->getTimeLimitAction());
563 
564  // set alternative API name
565  if ($this->slm->getAPIAdapterName() != "API") {
566  $this->tpl->setCurrentBlock("alt_api_ref");
567  $this->tpl->setVariable("API_NAME", $this->slm->getAPIAdapterName());
568  $this->tpl->parseCurrentBlock();
569  }
570 
571  $val_set = $ilDB->queryF(
572  '
573  SELECT * FROM scorm_tracking
574  WHERE user_id = %s
575  AND sco_id = %s
576  AND obj_id = %s',
577  array('integer','integer','integer'),
578  array($ilUser->getId(),$sco_id,$this->slm->getId())
579  );
580  $re_value = array();
581  while ($val_rec = $ilDB->fetchAssoc($val_set)) {
582  $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
583  $val_rec["rvalue"] = str_replace("\r", "\n", $val_rec["rvalue"]);
584  $val_rec["rvalue"] = str_replace("\n", "\\n", $val_rec["rvalue"]);
585  $re_value[$val_rec["lvalue"]] = $val_rec["rvalue"];
586  }
587 
588  foreach ($re_value as $var => $value) {
589  switch ($var) {
590  case "cmi.core.lesson_location":
591  case "cmi.core.lesson_status":
592  case "cmi.core.entry":
593  case "cmi.core.score.raw":
594  case "cmi.core.score.max":
595  case "cmi.core.score.min":
596  case "cmi.core.total_time":
597  case "cmi.core.exit":
598  case "cmi.suspend_data":
599  case "cmi.comments":
600  case "cmi.student_preference.audio":
601  case "cmi.student_preference.language":
602  case "cmi.student_preference.speed":
603  case "cmi.student_preference.text":
604  $this->setSingleVariable($var, $value);
605  break;
606 
607  case "cmi.objectives._count":
608  $this->setSingleVariable($var, $value);
609  $this->setArray("cmi.objectives", $value, "id", $re_value);
610  $this->setArray("cmi.objectives", $value, "score.raw", $re_value);
611  $this->setArray("cmi.objectives", $value, "score.max", $re_value);
612  $this->setArray("cmi.objectives", $value, "score.min", $re_value);
613  $this->setArray("cmi.objectives", $value, "status", $re_value);
614  break;
615 
616  case "cmi.interactions._count":
617  $this->setSingleVariable($var, $value);
618  $this->setArray("cmi.interactions", $value, "id", $re_value);
619  for ($i = 0; $i < $value; $i++) {
620  $var2 = "cmi.interactions." . $i . ".objectives._count";
621  if (isset($v_array[$var2])) {
622  $cnt = $v_array[$var2];
623  $this->setArray(
624  "cmi.interactions." . $i . ".objectives",
625  $cnt,
626  "id",
627  $re_value
628  );
629  /*
630  $this->setArray("cmi.interactions.".$i.".objectives",
631  $cnt, "score.raw", $re_value);
632  $this->setArray("cmi.interactions.".$i.".objectives",
633  $cnt, "score.max", $re_value);
634  $this->setArray("cmi.interactions.".$i.".objectives",
635  $cnt, "score.min", $re_value);
636  $this->setArray("cmi.interactions.".$i.".objectives",
637  $cnt, "status", $re_value);*/
638  }
639  }
640  $this->setArray("cmi.interactions", $value, "time", $re_value);
641  $this->setArray("cmi.interactions", $value, "type", $re_value);
642  for ($i = 0; $i < $value; $i++) {
643  $var2 = "cmi.interactions." . $i . ".correct_responses._count";
644  if (isset($v_array[$var2])) {
645  $cnt = $v_array[$var2];
646  $this->setArray(
647  "cmi.interactions." . $i . ".correct_responses",
648  $cnt,
649  "pattern",
650  $re_value
651  );
652  $this->setArray(
653  "cmi.interactions." . $i . ".correct_responses",
654  $cnt,
655  "weighting",
656  $re_value
657  );
658  }
659  }
660  $this->setArray("cmi.interactions", $value, "student_response", $re_value);
661  $this->setArray("cmi.interactions", $value, "result", $re_value);
662  $this->setArray("cmi.interactions", $value, "latency", $re_value);
663  break;
664  }
665  }
666 
667  global $DIC;
668  $lng = $DIC['lng'];
669  $this->tpl->setCurrentBlock("switch_icon");
670  $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
671  $this->tpl->setVariable("SCO_ICO", ilUtil::getImagePath("scorm/running.svg"));
672  $this->tpl->setVariable(
673  "SCO_ALT",
674  $lng->txt("cont_status") . ": "
675  . $lng->txt("cont_sc_stat_running")
676  );
677  $this->tpl->parseCurrentBlock();
678 
679  // set icon, if more than one SCO/Asset is presented
680  $items = ilSCORMObject::_lookupPresentableItems($this->slm->getId());
681  if (count($items) > 1) {
682  $this->tpl->setVariable("SWITCH_ICON_CMD", "switch_icon();");
683  }
684 
685 
686  // lesson mode
687  $lesson_mode = $this->slm->getDefaultLessonMode();
688  if ($this->slm->getAutoReview()) {
689  if ($re_value["cmi.core.lesson_status"] == "completed" ||
690  $re_value["cmi.core.lesson_status"] == "passed" ||
691  $re_value["cmi.core.lesson_status"] == "failed") {
692  $lesson_mode = "review";
693  }
694  }
695  $this->tpl->setVariable("LESSON_MODE", $lesson_mode);
696 
697  // credit mode
698  if ($lesson_mode == "normal") {
699  $this->tpl->setVariable(
700  "CREDIT_MODE",
701  str_replace("_", "-", $this->slm->getCreditMode())
702  );
703  } else {
704  $this->tpl->setVariable("CREDIT_MODE", "no-credit");
705  }
706 
707  // init cmi.core.total_time, cmi.core.lesson_status and cmi.core.entry
708  $sahs_obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
709  if (!isset($re_value["cmi.core.total_time"])) {
710  $item->insertTrackData("cmi.core.total_time", "0000:00:00", $sahs_obj_id);
711  }
712  if (!isset($re_value["cmi.core.lesson_status"])) {
713  $item->insertTrackData("cmi.core.lesson_status", "not attempted", $sahs_obj_id);
714  }
715  if (!isset($re_value["cmi.core.entry"])) {
716  $item->insertTrackData("cmi.core.entry", "", $sahs_obj_id);
717  }
718 
719  $this->tpl->show();
720  //echo htmlentities($this->tpl->get()); exit;
721  }
722 
723  public function finishSahs()
724  {
725  global $DIC;
726  $lng = $DIC['lng'];
727  $this->tpl = new ilTemplate("tpl.sahs_finish_cbt.html", true, true, "Modules/ScormAicc");
728  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
729 
730  // block not in template
731  // $this->tpl->setCurrentBlock("switch_icon");
732  $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
733  $this->tpl->setVariable(
734  "SCO_ICO",
736  "scorm/" . str_replace(" ", "_", $_GET["status"]) . '.svg'
737  )
738  );
739  $this->tpl->setVariable(
740  "SCO_ALT",
741  $lng->txt("cont_status") . ": "
742  . $lng->txt("cont_sc_stat_" . str_replace(" ", "_", $_GET["status"])) . ", "
743  . $lng->txt("cont_total_time") . ": "
744  . $_GET["totime"]
745  );
746  // BEGIN Partial fix for SCO sequencing:
747  // With this partial fix, ILIAS can now proceed to the next
748  // SCO, if it is a sibling of the current SCO.
749  // This fix doesn't fix the case, if the next SCO has a
750  // different parent item.
751  //$this->tpl->setVariable("SCO_LAUNCH_ID", $_GET["launch"]);
752 
753  $launch_id = $_GET['launch'];
754  if ($launch_id == 'null' || $launch_id == null) {
755  require_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php");
756  $mtree = new ilSCORMTree($this->slm->getId());
757  $node_data = $mtree->fetchSuccessorNode($_GET['sahs_id']);
758  if ($node_data && $node_data[type] == 'sit') {
759  $launch_id = $node_data['child'];
760  }
761  }
762  // END Partial fix for SCO sequencing
763  $this->tpl->setVariable("SCO_LAUNCH_ID", $launch_id);
764  // $this->tpl->parseCurrentBlock();
765  $this->tpl->show();
766  }
767 
768  public function unloadSahs()
769  {
770  $this->tpl = new ilTemplate("tpl.sahs_unload_cbt.html", true, true, "Modules/ScormAicc");
771  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
772  $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
773  $this->tpl->show();
774  }
775 
776 
777  public function launchAsset()
778  {
779  global $DIC;
780  $ilUser = $DIC['ilUser'];
781  $ilDB = $DIC['ilDB'];
782 
783  $sco_id = ($_GET["asset_id"] == "")
784  ? $_POST["asset_id"]
785  : $_GET["asset_id"];
786  $ref_id = ($_GET["ref_id"] == "")
787  ? $_POST["ref_id"]
788  : $_GET["ref_id"];
789 
790  $this->slm = new ilObjSCORMLearningModule($ref_id, true);
791 
792  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php");
793  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMResource.php");
794  $item = new ilSCORMItem($sco_id);
795 
796  $id_ref = $item->getIdentifierRef();
797  $resource = new ilSCORMResource();
798  $resource->readByIdRef($id_ref, $item->getSLMId());
799  $href = $resource->getHref();
800  $this->tpl->setVariable("HREF", $this->slm->getDataDirectory("output") . "/" . $href);
801  $this->tpl = new ilTemplate("tpl.scorm_launch_asset.html", true, true, "Modules/ScormAicc");
802  $this->tpl->setVariable("HREF", $this->slm->getDataDirectory("output") . "/" . $href);
803  $this->tpl->show();
804  }
805 
806  public function pingSession()
807  {
808  //WAC
809  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
810  ilWACSignedPath::signFolderOfStartFile($this->slm->getDataDirectory() . '/imsmanifest.xml');
811  return true;
812  }
813 
814  public function logMessage()
815  {
816  global $DIC;
817  $ilLog = $DIC['ilLog'];
818  $logString = file_get_contents('php://input');
819  $ilLog->write("ScormAicc: ApiLog: Message: " . $logString);
820  }
821 
822  public function logWarning()
823  {
824  global $DIC;
825  $ilLog = $DIC['ilLog'];
826  $logString = file_get_contents('php://input');
827  $ilLog->write("ScormAicc: ApiLog: Warning: " . $logString, 20);
828  }
829 
833  public function setSingleVariable($a_var, $a_value)
834  {
835  $this->tpl->setCurrentBlock("set_value");
836  $this->tpl->setVariable("VAR", $a_var);
837  $this->tpl->setVariable("VALUE", $a_value);
838  $this->tpl->parseCurrentBlock();
839  }
840 
844  public function setArray($a_left, $a_value, $a_name, &$v_array)
845  {
846  for ($i = 0; $i < $a_value; $i++) {
847  $var = $a_left . "." . $i . "." . $a_name;
848  if (isset($v_array[$var])) {
849  $this->tpl->setCurrentBlock("set_value");
850  $this->tpl->setVariable("VAR", $var);
851  $this->tpl->setVariable("VALUE", $v_array[$var]);
852  $this->tpl->parseCurrentBlock();
853  }
854  }
855  }
856 
860  public function downloadCertificate()
861  {
862  global $DIC;
863 
864  $ilUser = $DIC->user();
865  $tree = $DIC['tree'];
866  $ilCtrl = $DIC->ctrl();
867 
868  $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
869 
870  $certValidator = new ilCertificateDownloadValidator();
871  $allowed = $certValidator->isCertificateDownloadable($ilUser->getId(), $obj_id);
872  if ($allowed) {
873  $certificateLogger = $DIC->logger()->cert();
874 
875  $ilUserCertificateRepository = new ilUserCertificateRepository();
876  $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository, $certificateLogger);
877 
878  $pdfAction = new ilCertificatePdfAction(
879  $certificateLogger,
880  $pdfGenerator,
882  $this->lng->txt('error_creating_certificate_pdf')
883  );
884 
885  $pdfAction->downloadPdf($ilUser->getId(), $obj_id);
886  exit;
887  }
888  // redirect to parent category if certificate is not accessible
889  $parent = $tree->getParentId($_GET["ref_id"]);
890  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $parent);
891  $ilCtrl->redirectByClass("ilrepositorygui", "");
892  }
893 }
static getIliasScormData($a_packageId)
launchSahs()
This function is called by the API applet in the content frame when a SCO is started.
Class ilPdfGeneratorConstantsTest.
static getIliasScormResources($a_packageId)
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
setArray($a_left, $a_value, $a_name, &$v_array)
set single value
apiInitData()
SCORM Data for Javascript-API.
setTargetGet($a_target_get)
set the varname in Get-string public
global $DIC
Definition: saml.php:7
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
setSingleVariable($a_var, $a_value)
set single value
static _lookupIdByIdRef($a_id_ref, $a_slm_id)
global $ilCtrl
Definition: ilias.php:18
static _lookupScormType($a_obj_id)
static signFolderOfStartFile($start_file_path)
static getIliasScormVars($slm_obj)
static _lookupPresentableItems($a_slm_id)
Count number of presentable SCOs/Assets of SCORM learning module.
& getInstance($a_id)
get instance of specialized GUI class
foreach($_POST as $key=> $value) $res
static get_max_attempts($a_packageId)
Get max.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
Validates if an active certificate is stored in the database and can be downloaded by the user...
SCORM Item.
$ilUser
Definition: imgupload.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
increase_attemptAndsave_module_version()
Increases attempts by one for this package.
Explorer View for SCORM Learning Modules.
SCORM Object Tree.
Just a wrapper class to create Unit Test for other classes.
Class ilSCORMPresentationGUI.
exit
Definition: backend.php:16
explorer($a_target="sahs_content")
save the active module version to scorm_tracking
global $ilBench
Definition: ilias.php:18
global $ilDB
$i
Definition: disco.tpl.php:19
downloadCertificate()
Download the certificate for the active user.
fetchSuccessorNode($a_node_id, $a_type="")
get node data of successor node
frameset()
Output main frameset.
get_actual_attempts()
Get number of actual attempts for the user.
Class ilObjSCORMLearningModule.
$_POST["username"]
static getIliasScormTree($a_packageId)
downloadPdf(int $userId, int $objectId)
readRootId()
read root id from database