ILIAS  release_8 Revision v8.24
class.ilObjSCORMLearningModuleGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
36{
38 protected \ILIAS\DI\Container $dic;
39
40 protected int $refId;
41 protected ilCtrl $ctrl;
42
46 public function __construct($data, int $id, bool $call_by_reference, bool $prepare_output = true) //missing typehint because mixed
47 {
48 global $DIC;
49 $this->dic = $DIC;
50 $this->lng = $DIC->language();
51 $this->ctrl = $DIC->ctrl();
52 $this->tpl = $DIC["tpl"];
53
54 $this->lng->loadLanguageModule("content");
55 $this->lng->loadLanguageModule("search");
56
57 $this->refId = $DIC->http()->wrapper()->query()->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
58
59 $this->type = "sahs";
61 }
62
66 protected function assignObject(): void
67 {
68 if ($this->id != 0) {
69 if ($this->call_by_reference) {
70 $this->object = new ilObjSCORMLearningModule((int) $this->id, true);
71 } else {
72 $this->object = new ilObjSCORMLearningModule((int) $this->id, false);
73 }
74 }
75 }
76
80 public function properties(): void
81 {
82 global $DIC;
83 $ilToolbar = $DIC->toolbar();
84 $ilTabs = $DIC->tabs();
85
86 // $lng->loadLanguageModule("style");
87
88 $this->setSettingsSubTabs();
89 $ilTabs->setSubTabActive('cont_settings');
90
91 // view
92 $ilToolbar->addButtonInstance($this->object->getViewButton());
93
94 // lm properties
95 $this->initPropertiesForm();
97 $this->tpl->setContent($this->form->getHTML());
98 }
99
103 public function initPropertiesForm(): void
104 {
105 $obj_service = $this->object_service;
106 $this->form = new ilPropertyFormGUI();
107 $this->form->setTitle($this->lng->txt("cont_lm_properties"));
108
109 //check/select only once
110 $this->object->checkMasteryScoreValues();
111
112 //title
113 $ti = new ilTextInputGUI($this->lng->txt("title"), "Fobject_title");
114 $ti->setMaxLength(200);
115 $this->form->addItem($ti);
116
117 //description
118 $ti = new ilTextAreaInputGUI($this->lng->txt("description"), "Fobject_description");
119 $this->form->addItem($ti);
120
121 // SCORM-type
122 $ne = new ilNonEditableValueGUI($this->lng->txt("type"), "");
123 $ne->setValue($this->lng->txt("lm_type_" . ilObjSAHSLearningModule::_lookupSubType($this->object->getID())));
124 $this->form->addItem($ne);
125
126 // version
127 $ne = new ilNonEditableValueGUI($this->lng->txt("cont_sc_version"), "");
128 $ne->setValue($this->object->getModuleVersion());
129 $ne->setInfo($this->lng->txt("cont_sc_version_info"));
130 $this->form->addItem($ne);
131
132 //
133 // activation
134 //
135 $sh = new ilFormSectionHeaderGUI();
136 $sh->setTitle($this->lng->txt("activation"));
137 $this->form->addItem($sh);
138
139 // online
140 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_online"), "cobj_online");
141 $cb->setInfo($this->lng->txt("cont_online_info"));
142 $this->form->addItem($cb);
143
144
145 //
146 // presentation
147 //
148 $sh = new ilFormSectionHeaderGUI();
149 $sh->setTitle($this->lng->txt("cont_presentation"));
150 $this->form->addItem($sh);
151
152 $radg = new ilRadioGroupInputGUI($this->lng->txt("cont_open"), "open_mode");
153 $op0 = new ilRadioOption($this->lng->txt("cont_open_normal"), "0");
154 $radg->addOption($op0);
155 $op1 = new ilRadioOption($this->lng->txt("cont_open_iframe"), "1");
156 $radg->addOption($op1);
157 $op2 = new ilRadioOption($this->lng->txt("cont_open_window"), "5");
158 $radg->addOption($op2);
159
160 // width
161 $ni = new ilNumberInputGUI($this->lng->txt("cont_width"), "width_0");
162 $ni->setMaxLength(4);
163 $ni->setSize(4);
164 $op1->addSubItem($ni);
165 $ni = new ilNumberInputGUI($this->lng->txt("cont_width"), "width_1");
166 $ni->setMaxLength(4);
167 $ni->setSize(4);
168 $op2->addSubItem($ni);
169 // height
170 $ni = new ilNumberInputGUI($this->lng->txt("cont_height"), "height_0");
171 $ni->setMaxLength(4);
172 $ni->setSize(4);
173 $ni->setInfo($this->lng->txt("cont_width_height_info"));
174 $op1->addSubItem($ni);
175 $ni = new ilNumberInputGUI($this->lng->txt("cont_height"), "height_1");
176 $ni->setMaxLength(4);
177 $ni->setSize(4);
178 $ni->setInfo($this->lng->txt("cont_width_height_info"));
179 $op2->addSubItem($ni);
180
181 $this->form->addItem($radg);
182
183 // auto navigation to last visited item
184 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_auto_last_visited"), "cobj_auto_last_visited");
185 $cb->setValue("y");
186 $cb->setInfo($this->lng->txt("cont_auto_last_visited_info"));
187 $this->form->addItem($cb);
188
189 // auto continue
190 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sc_auto_continue"), "auto_continue");
191 $cb->setValue("y");
192 $cb->setInfo($this->lng->txt("cont_sc_auto_continue_info"));
193 $this->form->addItem($cb);
194
195 // tile image
196 $obj_service->commonSettings()->legacyForm($this->form, $this->object)->addTileImage();
197
198 //
199 // scorm options
200 //
201 $sh = new ilFormSectionHeaderGUI();
202 $sh->setTitle($this->lng->txt("cont_scorm_options"));
203 $this->form->addItem($sh);
204
205 // lesson mode
206 $options = array("normal" => $this->lng->txt("cont_sc_less_mode_normal"),
207 "browse" => $this->lng->txt("cont_sc_less_mode_browse"));
208 $si = new ilSelectInputGUI($this->lng->txt("cont_def_lesson_mode"), "lesson_mode");
209 $si->setOptions($options);
210 $this->form->addItem($si);
211
212 // credit mode
213 $options = array("credit" => $this->lng->txt("cont_credit_on"),
214 "no_credit" => $this->lng->txt("cont_credit_off"));
215 $si = new ilSelectInputGUI($this->lng->txt("cont_credit_mode"), "credit_mode");
216 $si->setOptions($options);
217 $si->setInfo($this->lng->txt("cont_credit_mode_info"));
218 $this->form->addItem($si);
219
220 // set lesson mode review when completed
221 $options = array(
222 "n" => $this->lng->txt("cont_sc_auto_review_no"),
223// "r" => $this->lng->txt("cont_sc_auto_review_completed_not_failed_or_passed"),
224// "p" => $this->lng->txt("cont_sc_auto_review_passed"),
225// "q" => $this->lng->txt("cont_sc_auto_review_passed_or_failed"),
226// "c" => $this->lng->txt("cont_sc_auto_review_completed"),
227// "d" => $this->lng->txt("cont_sc_auto_review_completed_and_passed"),
228 "y" => $this->lng->txt("cont_sc_auto_review_completed_or_passed"),
229 );
230 $si = new ilSelectInputGUI($this->lng->txt("cont_sc_auto_review_2004"), "auto_review");
231 $si->setOptions($options);
232 // $si->setInfo($this->lng->txt("cont_sc_auto_review_info_12"));
233 $this->form->addItem($si);
234
235 // mastery_score
236 if ($this->object->getMasteryScoreValues() != "") {
237 $ni = new ilNumberInputGUI($this->lng->txt("cont_mastery_score_12"), "mastery_score");
238 $ni->setMaxLength(3);
239 $ni->setSize(3);
240 $ni->setInfo($this->lng->txt("cont_mastery_score_12_info") . ' ' . $this->object->getMasteryScoreValues());
241 $this->form->addItem($ni);
242 }
243
244 //
245 // rte settings
246 //
247 $sh = new ilFormSectionHeaderGUI();
248 $sh->setTitle($this->lng->txt("cont_rte_settings"));
249 $this->form->addItem($sh);
250
251 // unlimited session timeout
252 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sc_usession"), "cobj_session");
253 $cb->setValue("y");
254 $cb->setInfo($this->lng->txt("cont_sc_usession_info"));
255 $this->form->addItem($cb);
256
257 // storage of interactions
258 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_interactions"), "cobj_interactions");
259 $cb->setValue("y");
260 $cb->setInfo($this->lng->txt("cont_interactions_info_12"));
261 $this->form->addItem($cb);
262
263 // objectives
264 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_objectives"), "cobj_objectives");
265 $cb->setValue("y");
266 $cb->setInfo($this->lng->txt("cont_objectives_info"));
267 $this->form->addItem($cb);
268
269 // time from lms
270 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_time_from_lms"), "cobj_time_from_lms");
271 $cb->setValue("y");
272 $cb->setInfo($this->lng->txt("cont_time_from_lms_info"));
273 $this->form->addItem($cb);
274
275 // check values
276 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_check_values"), "cobj_check_values");
277 $cb->setValue("y");
278 $cb->setInfo($this->lng->txt("cont_check_values_info"));
279 $this->form->addItem($cb);
280
281 // auto cmi.core.exit to suspend
282 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_auto_suspend"), "cobj_auto_suspend");
283 $cb->setValue("y");
284 $cb->setInfo($this->lng->txt("cont_auto_suspend_info"));
285 $this->form->addItem($cb);
286
287 // settings for student_id
288 $options = array(
289 0 => $this->lng->txt("cont_sc_id_setting_user_id"),
290 1 => $this->lng->txt("cont_sc_id_setting_user_login"),
291 2 => $this->lng->txt("cont_sc_id_setting_user_id_plus_ref_id"),
292 3 => $this->lng->txt("cont_sc_id_setting_user_login_plus_ref_id"),
293 4 => $this->lng->txt("cont_sc_id_setting_user_id_plus_obj_id"),
294 5 => $this->lng->txt("cont_sc_id_setting_user_login_plus_obj_id")
295 );
296 $si = new ilSelectInputGUI($this->lng->txt("cont_sc_id_setting"), "id_setting");
297 $si->setOptions($options);
298 $si->setInfo($this->lng->txt("cont_sc_id_setting_info"));
299 $this->form->addItem($si);
300
301 // settings for student_name
302 $options = array(
303 0 => $this->lng->txt("cont_sc_name_setting_last_firstname"),
304 1 => $this->lng->txt("cont_sc_name_setting_first_lastname"),
305 2 => $this->lng->txt("cont_sc_name_setting_fullname"),
306 3 => $this->lng->txt("cont_sc_name_setting_salutation_lastname"),
307 4 => $this->lng->txt("cont_sc_name_setting_first_name"),
308 9 => $this->lng->txt("cont_sc_name_setting_no_name")
309 );
310 $si = new ilSelectInputGUI($this->lng->txt("cont_sc_name_setting"), "name_setting");
311 $si->setOptions($options);
312 $si->setInfo($this->lng->txt("cont_sc_name_setting_info"));
313 $this->form->addItem($si);
314
315 //
316 // debugging
317 //
318 $sh = new ilFormSectionHeaderGUI();
319 $sh->setTitle($this->lng->txt("cont_debugging"));
320 $this->form->addItem($sh);
321
322 // test tool
323 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_debug"), "cobj_debug");
324 $cb->setValue("y");
325 if ($this->object->getDebugActivated() == false) {
326 $cb->setDisabled(true);
327 $cb->setInfo($this->lng->txt("cont_debug_deactivated"));
328 } else {
329 $cb->setInfo($this->lng->txt("cont_debug_deactivate12"));
330 }
331 $this->form->addItem($cb);
332 $this->form->addCommandButton("saveProperties", $this->lng->txt("save"));
333 $this->form->setFormAction($this->ctrl->getFormAction($this));
334 }
335
336
340 public function getPropertiesFormValues(): void
341 {
342 $values = array();
343 $values["Fobject_title"] = $this->object->getTitle();
344 $values["Fobject_description"] = $this->object->getLongDescription();
345 if (!$this->object->getOfflineStatus()) {
346 $values["cobj_online"] = true;
347 }
348 // $values["cobj_offline_mode"] = $this->object->getOfflineMode();
349 $values["open_mode"] = $this->object->getOpenMode();
350 $values["width_0"] = $this->object->getWidth();
351 $values["width_1"] = $this->object->getWidth();
352 $values["height_0"] = $this->object->getHeight();
353 $values["height_1"] = $this->object->getHeight();
354 $values["cobj_auto_last_visited"] = $this->object->getAuto_last_visited();
355 $values["auto_continue"] = $this->object->getAutoContinue();
356 $values["lesson_mode"] = $this->object->getDefaultLessonMode();
357 $values["credit_mode"] = $this->object->getCreditMode();
358 $values["auto_review"] = $this->object->getAutoReviewChar();
359 $values["mastery_score"] = $this->object->getMasteryScore();
360 $values["cobj_session"] = $this->object->getSession();
361 $values["cobj_interactions"] = $this->object->getInteractions();
362 $values["cobj_objectives"] = $this->object->getObjectives();
363 $values["cobj_time_from_lms"] = $this->object->getTime_from_lms();
364 $values["cobj_check_values"] = $this->object->getCheck_values();
365 $values["cobj_auto_suspend"] = $this->object->getAutoSuspend();
366 $values["id_setting"] = $this->object->getIdSetting();
367 $values["name_setting"] = $this->object->getNameSetting();
368 $values["cobj_debug"] = $this->object->getDebug();
369 $this->form->setValuesByArray($values);
370 }
371
375 public function newModuleVersion(): void
376 {
377 global $DIC;
378 $ilTabs = $DIC->tabs();
379 $this->setSettingsSubTabs();
380 $ilTabs->setSubTabActive('cont_sc_new_version');
381
382 $obj_id = ilObject::_lookupObjectId($this->refId);
384 $this->form = new ilPropertyFormGUI();
385 //title
386 $this->form->setTitle($this->lng->txt("import_sahs"));
387
388 // SCORM-type
389 $ne = new ilNonEditableValueGUI($this->lng->txt("type"), "");
390 $ne->setValue($this->lng->txt("lm_type_" . ilObjSAHSLearningModule::_lookupSubType($this->object->getID())));
391 $this->form->addItem($ne);
392
393 $options = array();
395 $options[""] = $this->lng->txt("cont_select_from_upload_dir");
397 foreach ($files as $file) {
398 $file = htmlspecialchars($file, ENT_QUOTES, "utf-8");
399 $options[$file] = $file;
400 }
401 }
402 if (count($options) > 1) {
403 // choose upload directory
404 $radg = new ilRadioGroupInputGUI($this->lng->txt("cont_choose_file_source"), "file_source");
405 $op0 = new ilRadioOption($this->lng->txt("cont_choose_local"), "local");
406 $radg->addOption($op0);
407 $op1 = new ilRadioOption($this->lng->txt("cont_choose_upload_dir"), "upload_dir");
408 $radg->addOption($op1);
409 $radg->setValue("local");
410
411 $fi = new ilFileInputGUI($this->lng->txt("select_file"), "scormfile");
412 $fi->setRequired(true);
413 $op0->addSubItem($fi);
414
415 $si = new ilSelectInputGUI($this->lng->txt("cont_uploaded_file"), "uploaded_file");
416 $si->setOptions($options);
417 $op1->addSubItem($si);
418
419 $this->form->addItem($radg);
420 } else {
421 $fi = new ilFileInputGUI($this->lng->txt("select_file"), "scormfile");
422 $fi->setRequired(true);
423 $this->form->addItem($fi);
424 }
425 $this->form->addCommandButton("newModuleVersionUpload", $this->lng->txt("upload"));
426 $this->form->addCommandButton("cancel", $this->lng->txt("cancel"));
427 $this->form->setFormAction($DIC->ctrl()->getFormAction($this, "newModuleVersionUpload"));
428 $DIC['tpl']->setContent($this->form->getHTML());
429 }
430
431 public function getMaxFileSize(): string
432 {
433 // get the value for the maximal uploadable filesize from the php.ini (if available)
434 $umf = get_cfg_var("upload_max_filesize");
435 // get the value for the maximal post data from the php.ini (if available)
436 $pms = get_cfg_var("post_max_size");
437
438 //convert from short-string representation to "real" bytes
439 $multiplier_a = array("K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024);
440
441 $umf_parts = preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
442 $pms_parts = preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
443
444 if (count($umf_parts) == 2) {
445 $umf = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
446 }
447 if (count($pms_parts) == 2) {
448 $pms = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
449 }
450
451 // use the smaller one as limit
452 $max_filesize = min($umf, $pms);
453
454 if (!$max_filesize) {
455 $max_filesize = max($umf, $pms);
456 }
457
458 //format for display in mega-bytes
459 return $max_filesize = sprintf("%.1f MB", $max_filesize / 1024 / 1024);
460 }
461
466 public function newModuleVersionUpload(): void
467 {
468 global $DIC;
469 $rbacsystem = $DIC->access();
470 $ilErr = $DIC["ilErr"];
471
472 $unzip = PATH_TO_UNZIP;
473 $tocheck = "imsmanifest.xml";
474
475 // check create permission before because the uploaded file will be copied
476 if (!$rbacsystem->checkAccess("write", "", $this->refId)) {
477 $ilErr->raiseError($this->lng->txt("no_create_permission"), $ilErr->WARNING);
478 } elseif ($_FILES["scormfile"]["name"]) {
479 // check if file was uploaded
480 $source = $_FILES["scormfile"]["tmp_name"];
481 if (($source === 'none') || (!$source)) {
482 $this->tpl->setOnScreenMessage('info', $this->lng->txt("upload_error_file_not_found"), true);
483 $this->newModuleVersion();
484 return;
485 }
486 } elseif ($DIC->http()->wrapper()->post()->has('uploaded_file')) {
487 $uploadedFile = $DIC->http()->wrapper()->post()->retrieve('uploaded_file', $DIC->refinery()->kindlyTo()->string());
488 // check if the file is in the ftp directory and readable
490 $ilErr->raiseError($this->lng->txt("upload_error_file_not_found"), $ilErr->MESSAGE);
491 }
492 // copy the uploaded file to the client web dir to analyze the imsmanifest
493 // the copy will be moved to the lm directory or deleted
496 $source_is_copy = true;
497 } else {
498 $this->tpl->setOnScreenMessage('info', $this->lng->txt("upload_error_file_not_found"), true);
499 $this->newModuleVersion();
500 return;
501 }
502 // fim.
503
504 //unzip the imsmanifest-file from new uploaded file
505 $pathinfo = pathinfo($source);
506 $dir = $pathinfo["dirname"];
507 $file = $pathinfo["basename"];
508 $cdir = getcwd();
509 chdir($dir);
510
511 //we need more flexible unzip here than ILIAS standard classes allow
512 $unzipcmd = $unzip . " -o " . ilShellUtil::escapeShellArg($source) . " " . $tocheck;
513 exec($unzipcmd);
514 chdir($cdir);
515 $tmp_file = $dir . "/" . $this->refId . "." . $tocheck;
516
517 ilFileUtils::rename($dir . "/" . $tocheck, $tmp_file);
518 $new_manifest = file_get_contents($tmp_file);
519
520 //remove temp file
521 unlink($tmp_file);
522
523 //get old manifest file
524 $old_manifest = file_get_contents($this->object->getDataDirectory() . "/" . $tocheck);
525
526 //reload fixed version of file
527 $check = '/xmlns="http:\/\/www.imsglobal.org\/xsd\/imscp_v1p1"/';
528 $replace = "xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
529 $reload_manifest = preg_replace($check, $replace, $new_manifest);
530
531 //do testing for converted versions as well as earlier ILIAS version messed up utf8 conversion
532 if (strcmp($new_manifest, $old_manifest) == 0 || strcmp(utf8_encode($new_manifest), $old_manifest) == 0 ||
533 strcmp($reload_manifest, $old_manifest) == 0 || strcmp(utf8_encode($reload_manifest), $old_manifest) == 0) {
534
535 //get exisiting module version
536 $module_version = $this->object->getModuleVersion() + 1;
537
538 if ($_FILES["scormfile"]["name"]) {
539 //build targetdir in lm_data
540 $file_path = $this->object->getDataDirectory() . "/" . $_FILES["scormfile"]["name"] . "." . $module_version;
541 $file_path = str_replace(".zip." . $module_version, "." . $module_version . ".zip", $file_path);
542 //move to data directory and add subfix for versioning
544 $_FILES["scormfile"]["tmp_name"],
545 $_FILES["scormfile"]["name"],
546 $file_path
547 );
548 } else {
549 //build targetdir in lm_data
550 $uploadedFile = $DIC->http()->wrapper()->post()->retrieve('uploaded_file', $DIC->refinery()->kindlyTo()->string());
551 $file_path = $this->object->getDataDirectory() . "/" . $uploadedFile . "." . $module_version;
552 $file_path = str_replace(".zip." . $module_version, "." . $module_version . ".zip", $file_path);
553 // move the already copied file to the lm_data directory
554 ilFileUtils::rename($source, $file_path);
555 }
556
557 //unzip and replace old extracted files
558 ilFileUtils::unzip($file_path, true);
559 ilFileUtils::renameExecutables($this->object->getDataDirectory()); //(security)
560
561 //increase module version
562 $this->object->setModuleVersion($module_version);
563 $this->object->update();
564
565 //redirect to properties and display success
566 $this->tpl->setOnScreenMessage('info', $this->lng->txt("cont_new_module_added"), true);
567 ilUtil::redirect("ilias.php?baseClass=ilSAHSEditGUI&ref_id=" . $this->refId);
568 exit;
569 }
570
571 if (isset($source_is_copy)) {
572 unlink($source);
573 }
574
575 $this->tpl->setOnScreenMessage('info', $this->lng->txt("cont_invalid_new_module"), true);
576 $this->newModuleVersion();
577 }
578
582 public function saveProperties(): void
583 {
584 $obj_service = $this->object_service;
585 $this->initPropertiesForm();
586 if ($this->form->checkInput()) {
587 $this->object->setTitle($this->dic->http()->wrapper()->post()->retrieve('Fobject_title', $this->dic->refinery()->kindlyTo()->string()));
588 $this->object->setDescription($this->dic->http()->wrapper()->post()->retrieve('Fobject_description', $this->dic->refinery()->kindlyTo()->string()));
589
590 if ($this->dic->http()->wrapper()->post()->has('mastery_score')) {
591 $sMasteryScore = $this->dic->http()->wrapper()->post()->retrieve('mastery_score', $this->dic->refinery()->kindlyTo()->string());
592 if ($sMasteryScore !== "") {
593 $this->object->setMasteryScore((int) $sMasteryScore);
594 } else {
595 $this->object->setMasteryScore(null);
596 }
597 }
598
599 $t_height = $this->object->getHeight();
600 if ($this->dic->http()->wrapper()->post()->retrieve('height_0', $this->dic->refinery()->kindlyTo()->int()) != $this->object->getHeight()) {
601 $t_height = $this->dic->http()->wrapper()->post()->retrieve('height_0', $this->dic->refinery()->kindlyTo()->int());
602 }
603 if ($this->dic->http()->wrapper()->post()->retrieve('height_1', $this->dic->refinery()->kindlyTo()->int()) != $this->object->getHeight()) {
604 $t_height = $this->dic->http()->wrapper()->post()->retrieve('height_1', $this->dic->refinery()->kindlyTo()->int());
605 }
606
607 $t_width = $this->object->getWidth();
608 if ($this->dic->http()->wrapper()->post()->retrieve('width_0', $this->dic->refinery()->kindlyTo()->int()) != $this->object->getWidth()) {
609 $t_width = $this->dic->http()->wrapper()->post()->retrieve('width_0', $this->dic->refinery()->kindlyTo()->int());
610 }
611 if ($this->dic->http()->wrapper()->post()->retrieve('width_1', $this->dic->refinery()->kindlyTo()->int()) != $this->object->getWidth()) {
612 $t_width = $this->dic->http()->wrapper()->post()->retrieve('width_1', $this->dic->refinery()->kindlyTo()->int());
613 }
614
615 $this->object->setOfflineStatus(!($this->dic->http()->wrapper()->post()->has('cobj_online')));
616 // $this->object->setOfflineMode($tmpOfflineMode);
617 $this->object->setOpenMode($this->dic->http()->wrapper()->post()->retrieve('open_mode', $this->dic->refinery()->kindlyTo()->int()));
618 $this->object->setWidth($t_width);
619 $this->object->setHeight($t_height);
620 $this->object->setAuto_last_visited($this->dic->http()->wrapper()->post()->has('cobj_auto_last_visited'));
621 $this->object->setAutoContinue($this->dic->http()->wrapper()->post()->has('auto_continue'));
622 // $this->object->setMaxAttempt((int) $_POST["max_attempt"]);
623 $this->object->setDefaultLessonMode($this->dic->http()->wrapper()->post()->retrieve('lesson_mode', $this->dic->refinery()->kindlyTo()->string()));
624 $this->object->setCreditMode($this->dic->http()->wrapper()->post()->retrieve('credit_mode', $this->dic->refinery()->kindlyTo()->string()));
625 $this->object->setAutoReview(ilUtil::yn2tf($this->dic->http()->wrapper()->post()->retrieve('auto_review', $this->dic->refinery()->kindlyTo()->string())));
626 $this->object->setSession($this->dic->http()->wrapper()->post()->has('cobj_session'));
627 $this->object->setInteractions($this->dic->http()->wrapper()->post()->has('cobj_interactions'));
628 $this->object->setObjectives($this->dic->http()->wrapper()->post()->has('cobj_objectives'));
629 $this->object->setTime_from_lms($this->dic->http()->wrapper()->post()->has('cobj_time_from_lms'));
630 $this->object->setCheck_values($this->dic->http()->wrapper()->post()->has('cobj_check_values'));
631 $this->object->setAutoSuspend($this->dic->http()->wrapper()->post()->has('cobj_auto_suspend'));
632 $this->object->setDebug($this->dic->http()->wrapper()->post()->has('cobj_debug'));
633 $this->object->setIdSetting($this->dic->http()->wrapper()->post()->retrieve('id_setting', $this->dic->refinery()->kindlyTo()->int()));
634 $this->object->setNameSetting($this->dic->http()->wrapper()->post()->retrieve('name_setting', $this->dic->refinery()->kindlyTo()->int()));
635 $this->object->update();
636
637 // tile image
638 $obj_service->commonSettings()->legacyForm($this->form, $this->object)->saveTileImage();
639 }
640 $this->tpl->setOnScreenMessage('info', $this->lng->txt("msg_obj_modified"), true);
641 $this->ctrl->redirect($this, "properties");
642 }
643
647 protected function showTrackingItemsBySco(): bool
648 {
649 global $DIC;
650 $ilTabs = $DIC->tabs();
651
652 $this->setSubTabs();
653 $ilTabs->setTabActive("cont_tracking_data");
654 $ilTabs->setSubTabActive("cont_tracking_bysco");
655
656 $reports = array('exportSelectedCore','exportSelectedInteractions','exportSelectedObjectives','exportSelectedRaw');//,'tracInteractionItem','tracInteractionUser','tracInteractionUserAnswers'
657 $scoSelected = "all";
658 if ($this->dic->http()->wrapper()->query()->has('scoSelected')) {
659 $scoSelected = ilUtil::stripSlashes($this->dic->http()->wrapper()->query()->retrieve('scoSelected', $this->dic->refinery()->kindlyTo()->string()));
660 }
661 if ($this->dic->http()->wrapper()->post()->has('scoSelected')) {
662 $scoSelected = ilUtil::stripSlashes($this->dic->http()->wrapper()->post()->retrieve('scoSelected', $this->dic->refinery()->kindlyTo()->string()));
663 }
664 $this->ctrl->setParameter($this, 'scoSelected', $scoSelected);
665
666 $report = "choose";
667 if ($this->dic->http()->wrapper()->query()->has('report')) {
668 $report = ilUtil::stripSlashes($this->dic->http()->wrapper()->query()->retrieve('report', $this->dic->refinery()->kindlyTo()->string()));
669 }
670 if ($this->dic->http()->wrapper()->post()->has('report')) {
671 $report = ilUtil::stripSlashes($this->dic->http()->wrapper()->post()->retrieve('report', $this->dic->refinery()->kindlyTo()->string()));
672 }
673 $this->ctrl->setParameter($this, 'report', $report);
674 $filter = new ilSCORMTrackingItemsPerScoFilterGUI($this, 'showTrackingItemsBySco');
675 $filter->parse($scoSelected, $report, $reports);
676 if ($report === "choose") {
677 $this->tpl->setContent($filter->form->getHTML());
678 } else {
679 $scosSelected = array();
680 if ($scoSelected !== "all") {
681 $scosSelected[] = $scoSelected;
682 } else {
683 $scos = $this->object->getTrackedItems();
684 foreach ($scos as $row) {
685 $scosSelected[] = (int) $row->getId();
686 }
687 }
688 $a_users = ilTrQuery::getParticipantsForObject($this->ref_id);
689 $tbl = new ilSCORMTrackingItemsTableGUI($this->object->getId(), $this, 'showTrackingItemsBySco', $a_users, $scosSelected, $report);
690 $this->tpl->setContent($filter->form->getHTML() . $tbl->getHTML());
691 }
692 return true;
693 }
694
699 public function showTrackingItems(): bool
700 {
701 global $DIC;
702 $ilTabs = $DIC->tabs();
703 $ilAccess = $DIC->access();
704
705 $ilTabs->setTabActive('cont_tracking_data');
706
707 if ($ilAccess->checkAccess("read_learning_progress", "", $this->refId)) {
708 $this->setSubTabs();
709 $ilTabs->setSubTabActive('cont_tracking_byuser');
710
711 $reports = array('exportSelectedSuccess','exportSelectedCore','exportSelectedInteractions','exportSelectedObjectives','exportSelectedRaw');
712
713 $userSelected = "all";
714 if ($this->dic->http()->wrapper()->query()->has('userSelected')) {
715 $userSelected = ilUtil::stripSlashes($this->dic->http()->wrapper()->query()->retrieve('userSelected', $this->dic->refinery()->kindlyTo()->string()));
716 }
717 if ($this->dic->http()->wrapper()->post()->has('userSelected')) {
718 $userSelected = ilUtil::stripSlashes($this->dic->http()->wrapper()->post()->retrieve('userSelected', $this->dic->refinery()->kindlyTo()->string()));
719 }
720 $this->ctrl->setParameter($this, 'userSelected', $userSelected);
721
722 $report = "choose";
723 if ($this->dic->http()->wrapper()->query()->has('report')) {
724 $report = ilUtil::stripSlashes($this->dic->http()->wrapper()->query()->retrieve('report', $this->dic->refinery()->kindlyTo()->string()));
725 }
726 if ($this->dic->http()->wrapper()->post()->has('report')) {
727 $report = ilUtil::stripSlashes($this->dic->http()->wrapper()->post()->retrieve('report', $this->dic->refinery()->kindlyTo()->string()));
728 }
729 $this->ctrl->setParameter($this, 'report', $report);
730 $filter = new ilSCORMTrackingItemsPerUserFilterGUI($this, 'showTrackingItems');
731 $filter->parse($userSelected, $report, $reports);
732 if ($report === "choose") {
733 $this->tpl->setContent($filter->form->getHTML());
734 } else {
735 $usersSelected = array();
736 if ($userSelected !== "all") {
737 $usersSelected[] = $userSelected;
738 } else {
739 $users = ilTrQuery::getParticipantsForObject($this->ref_id);
740 foreach ($users as $user) {
741 if (ilObject::_exists((int) $user) && ilObject::_lookUpType((int) $user) === 'usr') {
742 $usersSelected[] = (int) $user;
743 }
744 }
745 }
746 $scosSelected = array();
747 $scos = $this->object->getTrackedItems();
748 foreach ($scos as $row) {
749 $scosSelected[] = (int) $row->getId();
750 }
751 $tbl = new ilSCORMTrackingItemsTableGUI($this->object->getId(), $this, 'showTrackingItems', $usersSelected, $scosSelected, $report);
752 $this->tpl->setContent($filter->form->getHTML() . $tbl->getHTML());
753 }
754 } elseif ($ilAccess->checkAccess("edit_learning_progress", "", $this->refId)) {
755 $this->modifyTrackingItems();
756 }
757 return true;
758 }
759
763 protected function modifyTrackingItems(): void
764 {
765 global $DIC;
766 $ilAccess = $DIC->access();
767 $ilErr = $DIC["ilErr"];
768 if ($ilAccess->checkAccess("edit_learning_progress", "", $this->refId)) {
770 if (!$privacy->enabledSahsProtocolData()) {
771 $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
772 }
773
774 global $DIC;
775 $ilTabs = $DIC->tabs();
776 $ilToolbar = $DIC->toolbar();
777 $ilToolbar->addButton(
778 $this->lng->txt('import'),
779 $this->ctrl->getLinkTarget($this, 'importForm')
780 );
781 $ilToolbar->addButton(
782 $this->lng->txt('cont_export_all'),
783 $this->ctrl->getLinkTarget($this, 'exportAll')
784 );
785
786 $this->setSubTabs();
787 $ilTabs->setTabActive('cont_tracking_data');
788 $ilTabs->setSubTabActive('cont_tracking_modify');
789 $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
790 $tbl->parse();
791 $this->tpl->setContent($tbl->getHTML());
792 }
793 }
794
798 protected function applyUserTableFilter(): void
799 {
800 $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
801 $tbl->writeFilterToSession();
802 $tbl->resetOffset();
803 $this->modifyTrackingItems();
804 }
805
810 protected function resetUserTableFilter(): void
811 {
812 $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
813 $tbl->resetFilter();
814 $tbl->resetOffset();
815 $this->modifyTrackingItems();
816 }
817
822 public function deleteTrackingForUser(): void
823 {
824 global $DIC;
825 $ilErr = $DIC["ilErr"];
826
827 if (!$DIC->http()->wrapper()->post()->has('user')) {
828 $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
829 }
830
831 // display confirmation message
832 $cgui = new ilConfirmationGUI();
833 $cgui->setFormAction($this->ctrl->getFormAction($this));
834 $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
835 $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteTracking");
836 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDeleteTracking");
837 foreach ($DIC->http()->wrapper()->post()->retrieve('user', $DIC->refinery()->kindlyTo()->listOf($DIC->refinery()->kindlyTo()->int())) as $id) {
838 if (ilObject::_exists((int) $id) && ilObject::_lookUpType((int) $id) === "usr") {
839 $user = new ilObjUser((int) $id);
840
841 //was ilUtil::getImageTagByType("sahs", (string) $this->tpl->getValue("TPLPATH")) .
842 $caption = $this->lng->txt("cont_tracking_data") . ": " . $user->getLastname() . ", " . $user->getFirstname();
843
844 $cgui->addItem("user[]", (string) $id, $caption);
845 }
846 }
847
848 $this->tpl->setContent($cgui->getHTML());
849 }
850
855 public function cancelDeleteTracking(): void
856 {
857 $this->tpl->setOnScreenMessage('info', $this->lng->txt("msg_cancel"), true);
858 $this->ctrl->redirect($this, "modifyTrackingItems");
859 }
860
864 public function confirmedDeleteTracking(): void
865 {
866 $this->object->deleteTrackingDataOfUsers($this->post_wrapper->retrieve('user', $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())));
867 $this->ctrl->redirect($this, "modifyTrackingItems");
868 }
869
874 public function cancel(): void
875 {
876 $this->tpl->setOnScreenMessage('info', $this->lng->txt("msg_cancel"), true);
877 $this->ctrl->redirect($this, "properties");
878 }
879
884 protected function import(): void
885 {
886 $form = $this->initImportForm("");
887 if ($form->checkInput()) {
888 $source = $form->getInput('csv');
889 $success = $this->object->importTrackingData($source['tmp_name']);
890 switch ($success) {
891 case true:
892 $this->tpl->setOnScreenMessage('info', 'Tracking data imported', true);
893 $this->ctrl->redirect($this, "showTrackingItems");
894 break;
895 case false:
896 $this->tpl->setOnScreenMessage('info', $this->lng->txt('err_check_input'));
897 $this->importForm();
898 break;
899 }
900 }
901 $this->tpl->setOnScreenMessage('info', $this->lng->txt('err_check_input'));
902 $form->setValuesByPost();
903 $this->importForm();
904 }
905
910 protected function importForm(): void
911 {
912 global $DIC;
913 $ilTabs = $DIC->tabs();
914
915 $ilTabs->clearTargets();
916 $ilTabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'showTrackingItems'));
917
918 $form = $this->initImportForm("");
919 $this->tpl->setContent($form->getHTML());
920 }
921
926 protected function initImportForm(string $new_type): ilPropertyFormGUI
927 {
928 $form = new ilPropertyFormGUI();
929 $form->setFormAction($this->ctrl->getFormAction($this));
930 $form->setTitle($this->lng->txt('cont_import_tracking'));
931 $form->addCommandButton('import', $this->lng->txt('import'));
932 $form->addCommandButton('showTrackingItems', $this->lng->txt('cancel'));
933
934 $csv = new ilFileInputGUI($this->lng->txt('select_file'), 'csv');
935 $csv->setRequired(true);
936 $csv->setSuffixes(array('csv'));
937 $form->addItem($csv);
938
939 return $form;
940 }
941
945 protected function exportAll(): void
946 {
947 $this->object->exportSelected(true);
948 }
949
954 protected function exportSelectionUsers(): void
955 {
956 if (!$this->post_wrapper->has('user')) {
957 //was if (!count((array) $_POST['user'])) {
958 //ilUtil::sendFailure($this->lng->txt('select_one'),true);
959 $this->tpl->setOnScreenMessage('info', $this->lng->txt("no_checkbox"), true);
960 $this->ctrl->redirect($this, 'modifyTrackingItems');
961 } else {
962 $this->object->exportSelected(false, $this->post_wrapper->retrieve('user', $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())));
963 }
964 }
965
966
970 public function setSubTabs(): void
971 {
972 global $DIC;
973 $lng = $DIC->language();
974 $ilTabs = $DIC->tabs();
975 $ilCtrl = $DIC->ctrl();
976 $ilAccess = $DIC->access();
977
978 if ($ilAccess->checkAccess("read_learning_progress", "", $this->refId)) {
979 $ilTabs->addSubTabTarget(
980 "cont_tracking_byuser",
981 $this->ctrl->getLinkTarget($this, "showTrackingItems"),
982 array("edit", ""),
983 get_class($this)
984 );
985
986 $ilTabs->addSubTabTarget(
987 "cont_tracking_bysco",
988 $this->ctrl->getLinkTarget($this, "showTrackingItemsBySco"),
989 array("edit", ""),
990 get_class($this)
991 );
992 }
993 if ($ilAccess->checkAccess("edit_learning_progress", "", $this->refId)) {
994 $ilTabs->addSubTabTarget(
995 "cont_tracking_modify",
996 $this->ctrl->getLinkTarget($this, "modifyTrackingItems"),
997 array("edit", ""),
998 get_class($this)
999 );
1000 }
1001 }
1002}
1003// END class.ilObjSCORMLearningModule
$check
Definition: buildRTE.php:81
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
This class represents a file property in a property form.
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static rename(string $a_source, string $a_target)
static renameExecutables(string $a_dir)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
setFormAction(string $a_formaction)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a number property in a property form.
static _lookupSubType(int $a_obj_id)
lookup subtype id (scorm, )
Class ilObjSCORMLearningModuleGUI.
initImportForm(string $new_type)
Init import form.
__construct($data, int $id, bool $call_by_reference, bool $prepare_output=true)
Constructor.
exportAll()
Show export section for all users.
exportSelectionUsers()
Export selection for selected users.
assignObject()
assign scorm object to scorm gui object
deleteTrackingForUser()
display deletion confirmation screen
cancel()
overwrite..jump back to trackingdata not parent
newModuleVersion()
upload new version of module
cancelDeleteTracking()
cancel deletion of export files
getPropertiesFormValues()
Get values for properties form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
ilObjectService $object_service
ilLanguage $lng
static _lookupObjectId(int $ref_id)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
This class represents a property form user interface.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
static escapeShellArg(string $a_arg)
This class represents a text area property in a property form.
This class represents a text property in a property form.
static getParticipantsForObject(int $a_ref_id)
Get participant ids for given object.
static _copyUploadFile(string $a_file, string $a_target, bool $a_raise_errors=true)
static _checkUploadFile(string $a_file)
static _getUploadDirectory()
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static yn2tf(string $a_yn)
static redirect(string $a_script)
const CLIENT_WEB_DIR
Definition: constants.php:47
global $DIC
Definition: feed.php:28
if($DIC->http() ->wrapper() ->query() ->has('update')) $uploadedFile
Definition: imgupload.php:101
exit
Definition: login.php:28
$source
Definition: metadata.php:93
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd)
$ilErr
Definition: raiseError.php:17