ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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('general');//cont_settings
90
91 // view
92 $ilToolbar->addComponent($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 $ti->setCols(40);
120 $ti->setRows(2);
121 $this->form->addItem($ti);
122
123 // SCORM-type
124 $ne = new ilNonEditableValueGUI($this->lng->txt("type"), "");
125 $ne->setValue($this->lng->txt("lm_type_" . ilObjSAHSLearningModule::_lookupSubType($this->object->getID())));
126 $this->form->addItem($ne);
127
128 // version
129 $ne = new ilNonEditableValueGUI($this->lng->txt("cont_sc_version"), "");
130 $ne->setValue($this->object->getModuleVersion());
131 $ne->setInfo($this->lng->txt("cont_sc_version_info"));
132 $this->form->addItem($ne);
133
134 //
135 // activation
136 //
137 $sh = new ilFormSectionHeaderGUI();
138 $sh->setTitle($this->lng->txt("activation"));
139 $this->form->addItem($sh);
140
141 // online
142 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_online"), "cobj_online");
143 $cb->setInfo($this->lng->txt("cont_online_info"));
144 $this->form->addItem($cb);
145
146
147 //
148 // presentation
149 //
150 $sh = new ilFormSectionHeaderGUI();
151 $sh->setTitle($this->lng->txt("cont_presentation"));
152 $this->form->addItem($sh);
153
154 $radg = new ilRadioGroupInputGUI($this->lng->txt("cont_open"), "open_mode");
155 $op0 = new ilRadioOption($this->lng->txt("cont_open_normal"), "0");
156 $op0->setInfo($this->lng->txt("cont_open_normal_info"));
157 $radg->addOption($op0);
158 $op1 = new ilRadioOption($this->lng->txt("cont_open_iframe"), "1");
159 $op1->setInfo($this->lng->txt("cont_open_iframe_info"));
160 $radg->addOption($op1);
161 $op2 = new ilRadioOption($this->lng->txt("cont_open_window"), "5");
162 $op2->setInfo($this->lng->txt("cont_open_window_info"));
163 $radg->addOption($op2);
164
165 // width
166 $ni = new ilNumberInputGUI($this->lng->txt("cont_width"), "width_0");
167 $ni->setMaxLength(4);
168 $ni->setSize(4);
169 $op1->addSubItem($ni);
170 $ni = new ilNumberInputGUI($this->lng->txt("cont_width"), "width_1");
171 $ni->setMaxLength(4);
172 $ni->setSize(4);
173 $op2->addSubItem($ni);
174 // height
175 $ni = new ilNumberInputGUI($this->lng->txt("cont_height"), "height_0");
176 $ni->setMaxLength(4);
177 $ni->setSize(4);
178 $ni->setInfo($this->lng->txt("cont_width_height_info"));
179 $op1->addSubItem($ni);
180 $ni = new ilNumberInputGUI($this->lng->txt("cont_height"), "height_1");
181 $ni->setMaxLength(4);
182 $ni->setSize(4);
183 $ni->setInfo($this->lng->txt("cont_width_height_info"));
184 $op2->addSubItem($ni);
185
186 $this->form->addItem($radg);
187
188 // auto navigation to last visited item
189 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_auto_last_visited"), "cobj_auto_last_visited");
190 $cb->setValue("y");
191 $cb->setInfo($this->lng->txt("cont_auto_last_visited_info"));
192 $this->form->addItem($cb);
193
194 // auto continue
195 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sc_auto_continue"), "auto_continue");
196 $cb->setValue("y");
197 $cb->setInfo($this->lng->txt("cont_sc_auto_continue_info"));
198 $this->form->addItem($cb);
199
200 // tile image
201 $obj_service->commonSettings()->legacyForm($this->form, $this->object)->addTileImage();
202
203 //
204 // scorm options
205 //
206 $sh = new ilFormSectionHeaderGUI();
207 $sh->setTitle($this->lng->txt("cont_scorm_options"));
208 $this->form->addItem($sh);
209
210 // lesson mode
211 $radg = new ilRadioGroupInputGUI($this->lng->txt("cont_def_lesson_mode"), "lesson_mode");
212 $op0 = new ilRadioOption($this->lng->txt("cont_sc_less_mode_normal"), "normal");
213 $op0->setInfo($this->lng->txt("cont_sc_less_mode_normal_info"));
214 $radg->addOption($op0);
215 $op1 = new ilRadioOption($this->lng->txt("cont_sc_less_mode_browse"), "browse");
216 $op1->setInfo($this->lng->txt("cont_sc_less_mode_browse_info"));
217 $radg->addOption($op1);
218
219
220 // set lesson mode review when completed
221 $options = array(
222 "n" => $this->lng->txt("cont_sc_auto_review_no"),
223 "y" => $this->lng->txt("cont_sc_auto_review_completed_or_passed"),
224 );
225 $si = new ilSelectInputGUI($this->lng->txt("cont_sc_auto_review_2004"), "auto_review");
226 $si->setOptions($options);
227 // $si->setInfo($this->lng->txt("cont_sc_auto_review_info_12"));
228 $op0->addSubItem($si);
229 // end lesson mode
230 $this->form->addItem($radg);
231
232 // mastery_score
233 if ($this->object->getMasteryScoreValues() != "") {
234 $ni = new ilNumberInputGUI($this->lng->txt("cont_mastery_score_12"), "mastery_score");
235 $ni->setMaxLength(3);
236 $ni->setSize(3);
237 $ni->setInfo($this->lng->txt("cont_mastery_score_12_info") . ' ' . $this->object->getMasteryScoreValues());
238 $this->form->addItem($ni);
239 }
240
241 //
242 // rte settings
243 //
244 $sh = new ilFormSectionHeaderGUI();
245 $sh->setTitle($this->lng->txt("cont_rte_settings"));
246 $this->form->addItem($sh);
247
248 // unlimited session timeout
249 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sc_usession"), "cobj_session");
250 $cb->setValue("y");
251 $cb->setInfo($this->lng->txt("cont_sc_usession_info"));
252 $this->form->addItem($cb);
253
254 // storage of interactions
255 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_interactions"), "cobj_interactions");
256 $cb->setValue("y");
257 $cb->setInfo($this->lng->txt("cont_interactions_info_12"));
258 $this->form->addItem($cb);
259
260 // objectives
261 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_objectives"), "cobj_objectives");
262 $cb->setValue("y");
263 $cb->setInfo($this->lng->txt("cont_objectives_info"));
264 $this->form->addItem($cb);
265
266 // time from lms
267 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_time_from_lms"), "cobj_time_from_lms");
268 $cb->setValue("y");
269 $cb->setInfo($this->lng->txt("cont_time_from_lms_info"));
270 $this->form->addItem($cb);
271
272 // check values
273 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_check_values"), "cobj_check_values");
274 $cb->setValue("y");
275 $cb->setInfo($this->lng->txt("cont_check_values_info"));
276 $this->form->addItem($cb);
277
278 // auto cmi.core.exit to suspend
279 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_auto_suspend"), "cobj_auto_suspend");
280 $cb->setValue("y");
281 $cb->setInfo($this->lng->txt("cont_auto_suspend_info"));
282 $this->form->addItem($cb);
283
284 // settings for student_id
285 $options = array(
286 0 => $this->lng->txt("cont_sc_id_setting_user_id"),
287 1 => $this->lng->txt("cont_sc_id_setting_user_login"),
288 2 => $this->lng->txt("cont_sc_id_setting_user_id_plus_ref_id"),
289 3 => $this->lng->txt("cont_sc_id_setting_user_login_plus_ref_id"),
290 4 => $this->lng->txt("cont_sc_id_setting_user_id_plus_obj_id"),
291 5 => $this->lng->txt("cont_sc_id_setting_user_login_plus_obj_id")
292 );
293 $si = new ilSelectInputGUI($this->lng->txt("cont_sc_id_setting"), "id_setting");
294 $si->setOptions($options);
295 $si->setInfo($this->lng->txt("cont_sc_id_setting_info"));
296 $this->form->addItem($si);
297
298 // settings for student_name
299 $options = array(
300 0 => $this->lng->txt("cont_sc_name_setting_last_firstname"),
301 1 => $this->lng->txt("cont_sc_name_setting_first_lastname"),
302 2 => $this->lng->txt("cont_sc_name_setting_fullname"),
303 3 => $this->lng->txt("cont_sc_name_setting_salutation_lastname"),
304 4 => $this->lng->txt("cont_sc_name_setting_first_name"),
305 9 => $this->lng->txt("cont_sc_name_setting_no_name")
306 );
307 $si = new ilSelectInputGUI($this->lng->txt("cont_sc_name_setting"), "name_setting");
308 $si->setOptions($options);
309 $si->setInfo($this->lng->txt("cont_sc_name_setting_info"));
310 $this->form->addItem($si);
311
312 //
313 // debugging
314 //
315 $sh = new ilFormSectionHeaderGUI();
316 $sh->setTitle($this->lng->txt("cont_debugging"));
317 $this->form->addItem($sh);
318
319 // test tool
320 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_debug"), "cobj_debug");
321 $cb->setValue("y");
322 if ($this->object->getDebugActivated() == false) {
323 $cb->setDisabled(true);
324 $cb->setInfo($this->lng->txt("cont_debug_deactivated"));
325 } else {
326 $cb->setInfo($this->lng->txt("cont_debug_deactivate12"));
327 }
328 $this->form->addItem($cb);
329 $this->form->addCommandButton("saveProperties", $this->lng->txt("save"));
330 $this->form->setFormAction($this->ctrl->getFormAction($this));
331 }
332
333
337 public function getPropertiesFormValues(): void
338 {
339 $values = array();
340 $values["Fobject_title"] = $this->object->getTitle();
341 $values["Fobject_description"] = $this->object->getLongDescription();
342 if (!$this->object->getOfflineStatus()) {
343 $values["cobj_online"] = true;
344 }
345 // $values["cobj_offline_mode"] = $this->object->getOfflineMode();
346 $values["open_mode"] = $this->object->getOpenMode();
347 $values["width_0"] = $this->object->getWidth();
348 $values["width_1"] = $this->object->getWidth();
349 $values["height_0"] = $this->object->getHeight();
350 $values["height_1"] = $this->object->getHeight();
351 $values["cobj_auto_last_visited"] = $this->object->getAuto_last_visited();
352 $values["auto_continue"] = $this->object->getAutoContinue();
353 $values["lesson_mode"] = $this->object->getDefaultLessonMode();
354 $values["auto_review"] = $this->object->getAutoReviewChar();
355 $values["mastery_score"] = $this->object->getMasteryScore();
356 $values["cobj_session"] = $this->object->getSession();
357 $values["cobj_interactions"] = $this->object->getInteractions();
358 $values["cobj_objectives"] = $this->object->getObjectives();
359 $values["cobj_time_from_lms"] = $this->object->getTime_from_lms();
360 $values["cobj_check_values"] = $this->object->getCheck_values();
361 $values["cobj_auto_suspend"] = $this->object->getAutoSuspend();
362 $values["id_setting"] = $this->object->getIdSetting();
363 $values["name_setting"] = $this->object->getNameSetting();
364 $values["cobj_debug"] = $this->object->getDebug();
365 $this->form->setValuesByArray($values);
366 }
367
371 public function newModuleVersion(): void
372 {
373 global $DIC;
374 $ilTabs = $DIC->tabs();
375 $this->setSettingsSubTabs();
376 $ilTabs->setSubTabActive('cont_sc_new_version');
377
378 $obj_id = ilObject::_lookupObjectId($this->refId);
380 $this->form = new ilPropertyFormGUI();
381 //title
382 $this->form->setTitle($this->lng->txt("import_sahs_new"));
383
384 $this->form->setDescription($this->lng->txt("import_sahs_info"));
385
386 // SCORM-type
387 $ne = new ilNonEditableValueGUI($this->lng->txt("type"), "");
388 $ne->setValue($this->lng->txt("lm_type_" . ilObjSAHSLearningModule::_lookupSubType($this->object->getID())));
389 $this->form->addItem($ne);
390
391 $options = array();
393 $options[""] = $this->lng->txt("cont_select_from_upload_dir");
395 foreach ($files as $file) {
396 $file = htmlspecialchars($file, ENT_QUOTES, "utf-8");
397 $options[$file] = $file;
398 }
399 }
400 if (count($options) > 1) {
401 // choose upload directory
402 $radg = new ilRadioGroupInputGUI($this->lng->txt("cont_choose_file_source"), "file_source");
403 $op0 = new ilRadioOption($this->lng->txt("cont_choose_local"), "local");
404 $radg->addOption($op0);
405 $op1 = new ilRadioOption($this->lng->txt("cont_choose_upload_dir"), "upload_dir");
406 $radg->addOption($op1);
407 $radg->setValue("local");
408
409 $fi = new ilFileInputGUI($this->lng->txt("select_file"), "scormfile");
410 $fi->setRequired(true);
411 $op0->addSubItem($fi);
412
413 $si = new ilSelectInputGUI($this->lng->txt("cont_uploaded_file"), "uploaded_file");
414 $si->setOptions($options);
415 $op1->addSubItem($si);
416
417 $this->form->addItem($radg);
418 } else {
419 $fi = new ilFileInputGUI($this->lng->txt("select_file"), "scormfile");
420 $fi->setRequired(true);
421 $this->form->addItem($fi);
422 }
423 $this->form->addCommandButton("newModuleVersionUpload", $this->lng->txt("upload"));
424 $this->form->addCommandButton("cancel", $this->lng->txt("cancel"));
425 $this->form->setFormAction($DIC->ctrl()->getFormAction($this, "newModuleVersionUpload"));
426 $DIC['tpl']->setContent($this->form->getHTML());
427 }
428
429 public function getMaxFileSize(): string
430 {
431 // get the value for the maximal uploadable filesize from the php.ini (if available)
432 $umf = get_cfg_var("upload_max_filesize");
433 // get the value for the maximal post data from the php.ini (if available)
434 $pms = get_cfg_var("post_max_size");
435
436 //convert from short-string representation to "real" bytes
437 $multiplier_a = array("K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024);
438
439 $umf_parts = preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
440 $pms_parts = preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
441
442 if (count($umf_parts) == 2) {
443 $umf = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
444 }
445 if (count($pms_parts) == 2) {
446 $pms = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
447 }
448
449 // use the smaller one as limit
450 $max_filesize = min($umf, $pms);
451
452 if (!$max_filesize) {
453 $max_filesize = max($umf, $pms);
454 }
455
456 //format for display in mega-bytes
457 return $max_filesize = sprintf("%.1f MB", $max_filesize / 1024 / 1024);
458 }
459
464 public function newModuleVersionUpload(): void
465 {
466 global $DIC;
467 $rbacsystem = $DIC->access();
468 $ilErr = $DIC["ilErr"];
469
470 $unzip = PATH_TO_UNZIP;
471 $tocheck = "imsmanifest.xml";
472
473 // check create permission before because the uploaded file will be copied
474 if (!$rbacsystem->checkAccess("write", "", $this->refId)) {
475 $ilErr->raiseError($this->lng->txt("no_create_permission"), $ilErr->WARNING);
476 } elseif ($_FILES["scormfile"]["name"]) {
477 // check if file was uploaded
478 $source = $_FILES["scormfile"]["tmp_name"];
479 if (($source === 'none') || (!$source)) {
480 $this->tpl->setOnScreenMessage('info', $this->lng->txt("upload_error_file_not_found"), true);
481 $this->newModuleVersion();
482 return;
483 }
484 } elseif ($DIC->http()->wrapper()->post()->has('uploaded_file')) {
485 $uploadedFile = $DIC->http()->wrapper()->post()->retrieve('uploaded_file', $DIC->refinery()->kindlyTo()->string());
486 // check if the file is in the ftp directory and readable
487 if (!ilUploadFiles::_checkUploadFile($uploadedFile)) {
488 $ilErr->raiseError($this->lng->txt("upload_error_file_not_found"), $ilErr->MESSAGE);
489 }
490 // copy the uploaded file to the client web dir to analyze the imsmanifest
491 // the copy will be moved to the lm directory or deleted
492 $source = CLIENT_WEB_DIR . "/" . $uploadedFile;
493 ilUploadFiles::_copyUploadFile($uploadedFile, $source);
494 $source_is_copy = true;
495 } else {
496 $this->tpl->setOnScreenMessage('info', $this->lng->txt("upload_error_file_not_found"), true);
497 $this->newModuleVersion();
498 return;
499 }
500 // fim.
501
502 //unzip the imsmanifest-file from new uploaded file
503 $pathinfo = pathinfo($source);
504 $dir = $pathinfo["dirname"];
505 $file = $pathinfo["basename"];
506 $cdir = getcwd();
507 chdir($dir);
508
509 //we need more flexible unzip here than ILIAS standard classes allow
510 $unzipcmd = $unzip . " -o " . ilShellUtil::escapeShellArg($source) . " " . $tocheck;
511 exec($unzipcmd);
512 chdir($cdir);
513 $tmp_file = $dir . "/" . $this->refId . "." . $tocheck;
514
515 ilFileUtils::rename($dir . "/" . $tocheck, $tmp_file);
516 $new_manifest = file_get_contents($tmp_file);
517
518 //remove temp file
519 unlink($tmp_file);
520
521 //get old manifest file
522 $old_manifest = file_get_contents($this->object->getDataDirectory() . "/" . $tocheck);
523
524 //reload fixed version of file
525 $check = '/xmlns="http:\/\/www.imsglobal.org\/xsd\/imscp_v1p1"/';
526 $replace = "xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
527 $reload_manifest = preg_replace($check, $replace, $new_manifest);
528
529 //do testing for converted versions as well as earlier ILIAS version messed up utf8 conversion
530 if (strcmp($new_manifest, $old_manifest) == 0 || strcmp(mb_convert_encoding($new_manifest, "UTF-8", mb_detect_encoding($new_manifest)), $old_manifest) == 0 ||
531 strcmp($reload_manifest, $old_manifest) == 0 || strcmp(mb_convert_encoding($reload_manifest, "UTF-8", mb_detect_encoding($reload_manifest)), $old_manifest) == 0) {
532
533 //get exisiting module version
534 $module_version = $this->object->getModuleVersion() + 1;
535
536 if ($_FILES["scormfile"]["name"]) {
537 //build targetdir in lm_data
538 $file_path = $this->object->getDataDirectory() . "/" . $_FILES["scormfile"]["name"] . "." . $module_version;
539 $file_path = str_replace(".zip." . $module_version, "." . $module_version . ".zip", $file_path);
540 //move to data directory and add subfix for versioning
542 $_FILES["scormfile"]["tmp_name"],
543 $_FILES["scormfile"]["name"],
544 $file_path
545 );
546 } else {
547 //build targetdir in lm_data
548 $uploadedFile = $DIC->http()->wrapper()->post()->retrieve('uploaded_file', $DIC->refinery()->kindlyTo()->string());
549 $file_path = $this->object->getDataDirectory() . "/" . $uploadedFile . "." . $module_version;
550 $file_path = str_replace(".zip." . $module_version, "." . $module_version . ".zip", $file_path);
551 // move the already copied file to the lm_data directory
552 ilFileUtils::rename($source, $file_path);
553 }
554
555 //unzip and replace old extracted files
556 $DIC->legacyArchives()->unzip($file_path, null, true);
557 ilFileUtils::renameExecutables($this->object->getDataDirectory()); //(security)
558
559 //increase module version
560 $this->object->setModuleVersion($module_version);
561 $this->object->update();
562
563 //redirect to properties and display success
564 $this->tpl->setOnScreenMessage('info', $this->lng->txt("cont_new_module_added"), true);
565 ilUtil::redirect("ilias.php?baseClass=ilSAHSEditGUI&ref_id=" . $this->refId);
566 exit;
567 }
568
569 if (isset($source_is_copy)) {
570 unlink($source);
571 }
572
573 $this->tpl->setOnScreenMessage('info', $this->lng->txt("cont_invalid_new_module"), true);
574 $this->newModuleVersion();
575 }
576
580 public function saveProperties(): void
581 {
582 $obj_service = $this->object_service;
583 $this->initPropertiesForm();
584 if ($this->form->checkInput()) {
585 $this->object->setTitle($this->dic->http()->wrapper()->post()->retrieve('Fobject_title', $this->dic->refinery()->kindlyTo()->string()));
586 $this->object->setDescription($this->dic->http()->wrapper()->post()->retrieve('Fobject_description', $this->dic->refinery()->kindlyTo()->string()));
587
588 if ($this->dic->http()->wrapper()->post()->has('mastery_score')) {
589 $sMasteryScore = $this->dic->http()->wrapper()->post()->retrieve('mastery_score', $this->dic->refinery()->kindlyTo()->string());
590 if ($sMasteryScore !== "") {
591 $this->object->setMasteryScore((int) $sMasteryScore);
592 } else {
593 $this->object->setMasteryScore(null);
594 }
595 }
596
597 $t_height = $this->object->getHeight();
598 if ($this->dic->http()->wrapper()->post()->retrieve('height_0', $this->dic->refinery()->kindlyTo()->int()) != $this->object->getHeight()) {
599 $t_height = $this->dic->http()->wrapper()->post()->retrieve('height_0', $this->dic->refinery()->kindlyTo()->int());
600 }
601 if ($this->dic->http()->wrapper()->post()->retrieve('height_1', $this->dic->refinery()->kindlyTo()->int()) != $this->object->getHeight()) {
602 $t_height = $this->dic->http()->wrapper()->post()->retrieve('height_1', $this->dic->refinery()->kindlyTo()->int());
603 }
604
605 $t_width = $this->object->getWidth();
606 if ($this->dic->http()->wrapper()->post()->retrieve('width_0', $this->dic->refinery()->kindlyTo()->int()) != $this->object->getWidth()) {
607 $t_width = $this->dic->http()->wrapper()->post()->retrieve('width_0', $this->dic->refinery()->kindlyTo()->int());
608 }
609 if ($this->dic->http()->wrapper()->post()->retrieve('width_1', $this->dic->refinery()->kindlyTo()->int()) != $this->object->getWidth()) {
610 $t_width = $this->dic->http()->wrapper()->post()->retrieve('width_1', $this->dic->refinery()->kindlyTo()->int());
611 }
612
613 $this->object->setOfflineStatus(!($this->dic->http()->wrapper()->post()->has('cobj_online')));
614 // $this->object->setOfflineMode($tmpOfflineMode);
615 $this->object->setOpenMode($this->dic->http()->wrapper()->post()->retrieve('open_mode', $this->dic->refinery()->kindlyTo()->int()));
616 $this->object->setWidth($t_width);
617 $this->object->setHeight($t_height);
618 $this->object->setAuto_last_visited($this->dic->http()->wrapper()->post()->has('cobj_auto_last_visited'));
619 $this->object->setAutoContinue($this->dic->http()->wrapper()->post()->has('auto_continue'));
620 // $this->object->setMaxAttempt((int) $_POST["max_attempt"]);
621 $this->object->setDefaultLessonMode($this->dic->http()->wrapper()->post()->retrieve('lesson_mode', $this->dic->refinery()->kindlyTo()->string()));
622 $this->object->setAutoReview(ilUtil::yn2tf($this->dic->http()->wrapper()->post()->retrieve('auto_review', $this->dic->refinery()->kindlyTo()->string())));
623 $this->object->setSession($this->dic->http()->wrapper()->post()->has('cobj_session'));
624 $this->object->setInteractions($this->dic->http()->wrapper()->post()->has('cobj_interactions'));
625 $this->object->setObjectives($this->dic->http()->wrapper()->post()->has('cobj_objectives'));
626 $this->object->setTime_from_lms($this->dic->http()->wrapper()->post()->has('cobj_time_from_lms'));
627 $this->object->setCheck_values($this->dic->http()->wrapper()->post()->has('cobj_check_values'));
628 $this->object->setAutoSuspend($this->dic->http()->wrapper()->post()->has('cobj_auto_suspend'));
629 $this->object->setDebug($this->dic->http()->wrapper()->post()->has('cobj_debug'));
630 $this->object->setIdSetting($this->dic->http()->wrapper()->post()->retrieve('id_setting', $this->dic->refinery()->kindlyTo()->int()));
631 $this->object->setNameSetting($this->dic->http()->wrapper()->post()->retrieve('name_setting', $this->dic->refinery()->kindlyTo()->int()));
632 $this->object->update();
633
634 // tile image
635 $obj_service->commonSettings()->legacyForm($this->form, $this->object)->saveTileImage();
636 }
637 $this->tpl->setOnScreenMessage('info', $this->lng->txt("msg_obj_modified"), true);
638 $this->ctrl->redirect($this, "properties");
639 }
640
644 protected function showTrackingItemsBySco(): bool
645 {
646 global $DIC;
647 $ilTabs = $DIC->tabs();
648
649 $this->setSubTabs();
650 $ilTabs->setTabActive("cont_tracking_data");
651 $ilTabs->setSubTabActive("cont_tracking_bysco");
652
653 $reports = array('exportSelectedCore','exportSelectedInteractions','exportSelectedObjectives','exportSelectedRaw');//,'tracInteractionItem','tracInteractionUser','tracInteractionUserAnswers'
654 $scoSelected = "all";
655 if ($this->dic->http()->wrapper()->query()->has('scoSelected')) {
656 $scoSelected = ilUtil::stripSlashes($this->dic->http()->wrapper()->query()->retrieve('scoSelected', $this->dic->refinery()->kindlyTo()->string()));
657 }
658 if ($this->dic->http()->wrapper()->post()->has('scoSelected')) {
659 $scoSelected = ilUtil::stripSlashes($this->dic->http()->wrapper()->post()->retrieve('scoSelected', $this->dic->refinery()->kindlyTo()->string()));
660 }
661 $this->ctrl->setParameter($this, 'scoSelected', $scoSelected);
662
663 $report = "choose";
664 if ($this->dic->http()->wrapper()->query()->has('report')) {
665 $report = ilUtil::stripSlashes($this->dic->http()->wrapper()->query()->retrieve('report', $this->dic->refinery()->kindlyTo()->string()));
666 }
667 if ($this->dic->http()->wrapper()->post()->has('report')) {
668 $report = ilUtil::stripSlashes($this->dic->http()->wrapper()->post()->retrieve('report', $this->dic->refinery()->kindlyTo()->string()));
669 }
670 $this->ctrl->setParameter($this, 'report', $report);
671 $filter = new ilSCORMTrackingItemsPerScoFilterGUI($this, 'showTrackingItemsBySco');
672 $filter->parse($scoSelected, $report, $reports);
673 if ($report === "choose") {
674 $this->tpl->setContent($filter->form->getHTML());
675 } else {
676 $scosSelected = array();
677 if ($scoSelected !== "all") {
678 $scosSelected[] = $scoSelected;
679 } else {
680 $scos = $this->object->getTrackedItems();
681 foreach ($scos as $row) {
682 $scosSelected[] = (int) $row->getId();
683 }
684 }
685 $a_users = ilTrQuery::getParticipantsForObject($this->ref_id);
686 $tbl = new ilSCORMTrackingItemsTableGUI($this->object->getId(), $this, 'showTrackingItemsBySco', $a_users, $scosSelected, $report);
687 $this->tpl->setContent($filter->form->getHTML() . $tbl->getHTML());
688 }
689 return true;
690 }
691
696 public function showTrackingItems(): bool
697 {
698 global $DIC;
699 $ilTabs = $DIC->tabs();
700 $ilAccess = $DIC->access();
701
702 $ilTabs->setTabActive('cont_tracking_data');
703
704 if ($ilAccess->checkAccess("read_learning_progress", "", $this->refId)) {
705 $this->setSubTabs();
706 $ilTabs->setSubTabActive('cont_tracking_byuser');
707
708 $reports = array('exportSelectedSuccess','exportSelectedCore','exportSelectedInteractions','exportSelectedObjectives','exportSelectedRaw');
709
710 $userSelected = "all";
711 if ($this->dic->http()->wrapper()->query()->has('userSelected')) {
712 $userSelected = ilUtil::stripSlashes($this->dic->http()->wrapper()->query()->retrieve('userSelected', $this->dic->refinery()->kindlyTo()->string()));
713 }
714 if ($this->dic->http()->wrapper()->post()->has('userSelected')) {
715 $userSelected = ilUtil::stripSlashes($this->dic->http()->wrapper()->post()->retrieve('userSelected', $this->dic->refinery()->kindlyTo()->string()));
716 }
717 $this->ctrl->setParameter($this, 'userSelected', $userSelected);
718
719 $report = "choose";
720 if ($this->dic->http()->wrapper()->query()->has('report')) {
721 $report = ilUtil::stripSlashes($this->dic->http()->wrapper()->query()->retrieve('report', $this->dic->refinery()->kindlyTo()->string()));
722 }
723 if ($this->dic->http()->wrapper()->post()->has('report')) {
724 $report = ilUtil::stripSlashes($this->dic->http()->wrapper()->post()->retrieve('report', $this->dic->refinery()->kindlyTo()->string()));
725 }
726 $this->ctrl->setParameter($this, 'report', $report);
727 $filter = new ilSCORMTrackingItemsPerUserFilterGUI($this, 'showTrackingItems');
728 $filter->parse($userSelected, $report, $reports);
729 if ($report === "choose") {
730 $this->tpl->setContent($filter->form->getHTML());
731 } else {
732 $usersSelected = array();
733 if ($userSelected !== "all") {
734 $usersSelected[] = $userSelected;
735 } else {
736 $users = ilTrQuery::getParticipantsForObject($this->ref_id);
737 foreach ($users as $user) {
738 if (ilObject::_exists((int) $user) && ilObject::_lookUpType((int) $user) === 'usr') {
739 $usersSelected[] = (int) $user;
740 }
741 }
742 }
743 $scosSelected = array();
744 $scos = $this->object->getTrackedItems();
745 foreach ($scos as $row) {
746 $scosSelected[] = (int) $row->getId();
747 }
748 $tbl = new ilSCORMTrackingItemsTableGUI($this->object->getId(), $this, 'showTrackingItems', $usersSelected, $scosSelected, $report);
749 $this->tpl->setContent($filter->form->getHTML() . $tbl->getHTML());
750 }
751 } elseif ($ilAccess->checkAccess("edit_learning_progress", "", $this->refId)) {
752 $this->modifyTrackingItems();
753 }
754 return true;
755 }
756
760 protected function modifyTrackingItems(): void
761 {
762 global $DIC;
763 $ilAccess = $DIC->access();
764 $ilErr = $DIC["ilErr"];
765 if ($ilAccess->checkAccess("edit_learning_progress", "", $this->refId)) {
767 if (!$privacy->enabledSahsProtocolData()) {
768 $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
769 }
770
771 global $DIC;
772 $ilTabs = $DIC->tabs();
773 $ilToolbar = $DIC->toolbar();
774 $ilToolbar->addButton(
775 $this->lng->txt('import'),
776 $this->ctrl->getLinkTarget($this, 'trackingImportForm')
777 );
778 $ilToolbar->addButton(
779 $this->lng->txt('cont_export_all'),
780 $this->ctrl->getLinkTarget($this, 'exportAll')
781 );
782
783 $this->setSubTabs();
784 $ilTabs->setTabActive('cont_tracking_data');
785 $ilTabs->setSubTabActive('cont_tracking_modify');
786 $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
787 $tbl->parse();
788 $this->tpl->setContent($tbl->getHTML());
789 }
790 }
791
795 protected function applyUserTableFilter(): void
796 {
797 $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
798 $tbl->writeFilterToSession();
799 $tbl->resetOffset();
800 $this->modifyTrackingItems();
801 }
802
807 protected function resetUserTableFilter(): void
808 {
809 $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
810 $tbl->resetFilter();
811 $tbl->resetOffset();
812 $this->modifyTrackingItems();
813 }
814
819 public function deleteTrackingForUser(): void
820 {
821 global $DIC;
822 $ilErr = $DIC["ilErr"];
823
824 if (!$DIC->http()->wrapper()->post()->has('user')) {
825 $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
826 }
827
828 // display confirmation message
829 $cgui = new ilConfirmationGUI();
830 $cgui->setFormAction($this->ctrl->getFormAction($this));
831 $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
832 $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteTracking");
833 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDeleteTracking");
834 foreach ($DIC->http()->wrapper()->post()->retrieve('user', $DIC->refinery()->kindlyTo()->listOf($DIC->refinery()->kindlyTo()->int())) as $id) {
835 if (ilObject::_exists((int) $id) && ilObject::_lookUpType((int) $id) === "usr") {
836 $user = new ilObjUser((int) $id);
837
838 //was ilUtil::getImageTagByType("sahs", (string) $this->tpl->getValue("TPLPATH")) .
839 $caption = $this->lng->txt("cont_tracking_data") . ": " . $user->getLastname() . ", " . $user->getFirstname();
840
841 $cgui->addItem("user[]", (string) $id, $caption);
842 }
843 }
844
845 $this->tpl->setContent($cgui->getHTML());
846 }
847
852 public function cancelDeleteTracking(): void
853 {
854 $this->tpl->setOnScreenMessage('info', $this->lng->txt("msg_cancel"), true);
855 $this->ctrl->redirect($this, "modifyTrackingItems");
856 }
857
861 public function confirmedDeleteTracking(): void
862 {
863 $this->object->deleteTrackingDataOfUsers($this->post_wrapper->retrieve('user', $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())));
864 $this->ctrl->redirect($this, "modifyTrackingItems");
865 }
866
871 public function cancel(): void
872 {
873 $this->tpl->setOnScreenMessage('info', $this->lng->txt("msg_cancel"), true);
874 $this->ctrl->redirect($this, "properties");
875 }
876
881 protected function importTracking(): void
882 {
883 $form = $this->initTrackingImportForm("");
884 if ($form->checkInput()) {
885 $source = $form->getInput('csv');
886 $success = $this->object->importTrackingData($source['tmp_name']);
887 switch ($success) {
888 case true:
889 $this->tpl->setOnScreenMessage('info', 'Tracking data imported', true);
890 $this->ctrl->redirect($this, "showTrackingItems");
891 break;
892 case false:
893 $this->tpl->setOnScreenMessage('info', $this->lng->txt('err_check_input'));
894 $this->trackingImportForm();
895 break;
896 }
897 }
898 $this->tpl->setOnScreenMessage('info', $this->lng->txt('err_check_input'));
899 $form->setValuesByPost();
900 $this->trackingImportForm();
901 }
902
907 protected function trackingImportForm(): void
908 {
909 global $DIC;
910 $ilTabs = $DIC->tabs();
911
912 $ilTabs->clearTargets();
913 $ilTabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'showTrackingItems'));
914
915 $form = $this->initTrackingImportForm();
916 $this->tpl->setContent($form->getHTML());
917 }
918
924 {
925 $form = new ilPropertyFormGUI();
926 $form->setFormAction($this->ctrl->getFormAction($this));
927 $form->setTitle($this->lng->txt('cont_import_tracking'));
928 $form->addCommandButton('importTracking', $this->lng->txt('import'));
929 $form->addCommandButton('showTrackingItems', $this->lng->txt('cancel'));
930
931 $csv = new ilFileInputGUI($this->lng->txt('select_file'), 'csv');
932 $csv->setRequired(true);
933 $csv->setSuffixes(array('csv'));
934 $form->addItem($csv);
935
936 return $form;
937 }
938
942 protected function exportAll(): void
943 {
944 $this->object->exportSelected(true);
945 }
946
951 protected function exportSelectionUsers(): void
952 {
953 if (!$this->post_wrapper->has('user')) {
954 //was if (!count((array) $_POST['user'])) {
955 //ilUtil::sendFailure($this->lng->txt('select_one'),true);
956 $this->tpl->setOnScreenMessage('info', $this->lng->txt("no_checkbox"), true);
957 $this->ctrl->redirect($this, 'modifyTrackingItems');
958 } else {
959 $this->object->exportSelected(false, $this->post_wrapper->retrieve('user', $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())));
960 }
961 }
962
963
967 public function setSubTabs(): void
968 {
969 global $DIC;
970 $lng = $DIC->language();
971 $ilTabs = $DIC->tabs();
972 $ilCtrl = $DIC->ctrl();
973 $ilAccess = $DIC->access();
974
975 if ($ilAccess->checkAccess("read_learning_progress", "", $this->refId)) {
976 $ilTabs->addSubTabTarget(
977 "cont_tracking_byuser",
978 $this->ctrl->getLinkTarget($this, "showTrackingItems"),
979 array("edit", ""),
980 get_class($this)
981 );
982
983 $ilTabs->addSubTabTarget(
984 "cont_tracking_bysco",
985 $this->ctrl->getLinkTarget($this, "showTrackingItemsBySco"),
986 array("edit", ""),
987 get_class($this)
988 );
989 }
990 if ($ilAccess->checkAccess("edit_learning_progress", "", $this->refId)) {
991 $ilTabs->addSubTabTarget(
992 "cont_tracking_modify",
993 $this->ctrl->getLinkTarget($this, "modifyTrackingItems"),
994 array("edit", ""),
995 get_class($this)
996 );
997 }
998 }
999}
1000// 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 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 class represents a section header in a property form.
This class represents a non editable value in a property form.
This class represents a number property in a property form.
static _lookupSubType(int $a_obj_id)
lookup subtype id (scorm, )
Class ilObjSCORMLearningModuleGUI.
__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
importTracking()
gui functions for GUI export
cancelDeleteTracking()
cancel deletion of export files
getPropertiesFormValues()
Get values for properties form.
Class ilObjSCORMLearningModule.
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 class represents an option in a radio group.
Class ilSCORMTrackingItemsTableGUI.
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
exit
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form(?array $class_path, string $cmd, string $submit_caption="")
$ilErr
Definition: raiseError.php:33
global $DIC
Definition: shib_login.php:26
PREG_SPLIT_NO_EMPTY PREG_SPLIT_DELIM_CAPTURE