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