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