ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjSCORMLearningModuleGUI.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 "./Services/Object/classes/class.ilObjectGUI.php";
6require_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php");
7require_once("Services/User/classes/class.ilObjUser.php");
8
9require_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleGUI.php");
10require_once("./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php");
11
28{
29 const EXPORT_UNDEF = 0;
30 const EXPORT_ALL = 1;
31 const EXPORT_SELECTED = 2;
32
33 const EXPORT_TYPE_RAW = 1;
35
41 function __construct($a_data,$a_id,$a_call_by_reference, $a_prepare_output = true)
42 {
43 global $lng;
44
45 $lng->loadLanguageModule("content");
46 $lng->loadLanguageModule("search");
47
48 $this->type = "sahs";
49 parent::__construct($a_data,$a_id,$a_call_by_reference,false);
50 }
51
55 function assignObject()
56 {
57 if ($this->id != 0)
58 {
59 if ($this->call_by_reference)
60 {
61 $this->object = new ilObjSCORMLearningModule($this->id, true);
62 }
63 else
64 {
65 $this->object = new ilObjSCORMLearningModule($this->id, false);
66 }
67 }
68 }
69
73 function properties()
74 {
75 global $rbacsystem, $tree, $tpl, $lng, $ilToolbar, $ilCtrl, $ilSetting, $ilTabs;
76
77 $lng->loadLanguageModule("style");
78
80 $ilTabs->setSubTabActive('cont_settings');
81
82 // view
83 $ilToolbar->addButton($this->lng->txt("view"),
84 "ilias.php?baseClass=ilSAHSPresentationGUI&amp;ref_id=".$this->object->getRefID(),
85 "_blank");
86
87 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
88 $this->form = new ilPropertyFormGUI();
89 $this->form->setFormAction($ilCtrl->getFormAction($this));
90 $this->form->setTitle($this->lng->txt("cont_lm_properties"));
91
92 //check/select only once
93 $this->object->checkMasteryScoreValues();
94
95 //title
96 $ti = new ilTextInputGUI($this->lng->txt("title"), "Fobject_title");
97 $ti->setMaxLength(200);
98 $ti->setValue($this->object->getTitle());
99 $this->form->addItem($ti);
100
101 //description
102 $ti = new ilTextAreaInputGUI($this->lng->txt("description"), "Fobject_description");
103 $ti->setValue($this->object->getDescription());
104 $this->form->addItem($ti);
105
106 // SCORM-type
107 $ne = new ilNonEditableValueGUI($this->lng->txt("type"), "");
108 $ne->setValue($this->lng->txt( "lm_type_" . ilObjSAHSLearningModule::_lookupSubType( $this->object->getID() ) ) );
109 $this->form->addItem($ne);
110
111 // version
112 $ne = new ilNonEditableValueGUI($this->lng->txt("cont_sc_version"), "");
113 $ne->setValue($this->object->getModuleVersion());
114 $ne->setInfo($this->lng->txt("cont_sc_version_info"));
115 $this->form->addItem($ne);
116
117 //
118 // activation
119 //
120 $sh = new ilFormSectionHeaderGUI();
121 $sh->setTitle($this->lng->txt("activation"));
122 $this->form->addItem($sh);
123
124 // online
125 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_online"), "cobj_online");
126 $cb->setValue("y");
127 if ($this->object->getOnline())
128 {
129 $cb->setChecked(true);
130 }
131 $cb->setInfo($this->lng->txt("cont_online_info"));
132 $this->form->addItem($cb);
133
134 // offline Mode
135 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_offline_mode_allow"), "cobj_offline_mode");
136 $cb->setValue("y");
137 $cb->setChecked($this->object->getOfflineMode());
138 include_once("./Modules/ScormAicc/classes/class.ilSCORMOfflineMode.php");
139 if ($this->object->getOfflineMode()== true && ilSCORMOfflineMode::checkIfAnyoneIsInOfflineMode($this->object->getID()) == true) {
140 $cb->setDisabled(true);
141 $cb->setInfo($this->lng->txt("cont_offline_mode_disable_not_allowed_info"));
142 } else {
143 $cb->setInfo($this->lng->txt("cont_offline_mode_allow_info"));
144 }
145 $this->form->addItem($cb);
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($lng->txt("cont_open"), "open_mode");
155 $op0 = new ilRadioOption($this->lng->txt("cont_open_normal"), "0");
156 $radg->addOption($op0);
157 $op1 = new ilRadioOption($this->lng->txt("cont_open_iframe"), "1");
158 $radg->addOption($op1);
159 $op2 = new ilRadioOption($this->lng->txt("cont_open_window"), "5");
160 $radg->addOption($op2);
161 $radg->setValue($this->object->getOpenMode());
162
163 // width
164 $ni = new ilNumberInputGUI($this->lng->txt("cont_width"), "width_0");
165 $ni->setMaxLength(4);
166 $ni->setSize(4);
167 $ni->setValue($this->object->getWidth());
168 $op1->addSubItem($ni);
169 $ni = new ilNumberInputGUI($this->lng->txt("cont_width"), "width_1");
170 $ni->setMaxLength(4);
171 $ni->setSize(4);
172 $ni->setValue($this->object->getWidth());
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->setValue($this->object->getHeight());
179 $ni->setInfo($this->lng->txt("cont_width_height_info"));
180 $op1->addSubItem($ni);
181 $ni = new ilNumberInputGUI($this->lng->txt("cont_height"), "height_1");
182 $ni->setMaxLength(4);
183 $ni->setSize(4);
184 $ni->setValue($this->object->getHeight());
185 $ni->setInfo($this->lng->txt("cont_width_height_info"));
186 $op2->addSubItem($ni);
187
188 $this->form->addItem($radg);
189
190 // auto navigation to last visited item
191 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_auto_last_visited"), "cobj_auto_last_visited");
192 $cb->setValue("y");
193 $cb->setChecked($this->object->getAuto_last_visited());
194 $cb->setInfo($this->lng->txt("cont_auto_last_visited_info"));
195 $this->form->addItem($cb);
196
197 // auto continue
198 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sc_auto_continue"), "auto_continue");
199 $cb->setValue("y");
200 $cb->setChecked($this->object->getAutoContinue());
201 $this->form->addItem($cb);
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 // max attempts
211 // $ni = new ilNumberInputGUI($this->lng->txt("cont_sc_max_attempt"), "max_attempt");
212 // $ni->setMaxLength(3);
213 // $ni->setSize(3);
214 // $ni->setValue($this->object->getMaxAttempt());
215 // $this->form->addItem($ni);
216
217 // lesson mode
218 $options = array("normal" => $this->lng->txt("cont_sc_less_mode_normal"),
219 "browse" => $this->lng->txt("cont_sc_less_mode_browse"));
220 $si = new ilSelectInputGUI($this->lng->txt("cont_def_lesson_mode"), "lesson_mode");
221 $si->setOptions($options);
222 $si->setValue($this->object->getDefaultLessonMode());
223 $this->form->addItem($si);
224
225 // credit mode
226 $options = array("credit" => $this->lng->txt("cont_credit_on"),
227 "no_credit" => $this->lng->txt("cont_credit_off"));
228 $si = new ilSelectInputGUI($this->lng->txt("cont_credit_mode"), "credit_mode");
229 $si->setOptions($options);
230 $si->setValue($this->object->getCreditMode());
231 $si->setInfo($this->lng->txt("cont_credit_mode_info"));
232 $this->form->addItem($si);
233
234 // set lesson mode review when completed
235 $options = array(
236 "n" => $this->lng->txt("cont_sc_auto_review_no"),
237// "r" => $this->lng->txt("cont_sc_auto_review_completed_not_failed_or_passed"),
238// "p" => $this->lng->txt("cont_sc_auto_review_passed"),
239// "q" => $this->lng->txt("cont_sc_auto_review_passed_or_failed"),
240// "c" => $this->lng->txt("cont_sc_auto_review_completed"),
241// "d" => $this->lng->txt("cont_sc_auto_review_completed_and_passed"),
242 "y" => $this->lng->txt("cont_sc_auto_review_completed_or_passed"),
243 );
244 $si = new ilSelectInputGUI($this->lng->txt("cont_sc_auto_review_2004"), "auto_review");
245 $si->setOptions($options);
246 $si->setValue($this->object->getAutoReviewChar());
247 // $si->setInfo($this->lng->txt("cont_sc_auto_review_info_12"));
248 $this->form->addItem($si);
249
250 // mastery_score
251 if ($this->object->getMasteryScoreValues() != "") {
252 $ni = new ilNumberInputGUI($this->lng->txt("cont_mastery_score_12"), "mastery_score");
253 $ni->setMaxLength(3);
254 $ni->setSize(3);
255 $ni->setValue($this->object->getMasteryScore());
256 $ni->setInfo($this->lng->txt("cont_mastery_score_12_info").$this->object->getMasteryScoreValues());
257 $this->form->addItem($ni);
258 }
259
260 //
261 // rte settings
262 //
263 $sh = new ilFormSectionHeaderGUI();
264 $sh->setTitle($this->lng->txt("cont_rte_settings"));
265 $this->form->addItem($sh);
266
267 // unlimited session timeout
268 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sc_usession"), "cobj_session");
269 $cb->setValue("y");
270 $cb->setChecked($this->object->getSession());
271 $cb->setInfo($this->lng->txt("cont_sc_usession_info"));
272 $this->form->addItem($cb);
273
274 // storage of interactions
275 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_interactions"), "cobj_interactions");
276 $cb->setValue("y");
277 $cb->setChecked($this->object->getInteractions());
278 $cb->setInfo($this->lng->txt("cont_interactions_info_12"));
279 $this->form->addItem($cb);
280
281 // objectives
282 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_objectives"), "cobj_objectives");
283 $cb->setValue("y");
284 $cb->setChecked($this->object->getObjectives());
285 $cb->setInfo($this->lng->txt("cont_objectives_info"));
286 $this->form->addItem($cb);
287
288 // time from lms
289 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_time_from_lms"), "cobj_time_from_lms");
290 $cb->setValue("y");
291 $cb->setChecked($this->object->getTime_from_lms());
292 $cb->setInfo($this->lng->txt("cont_time_from_lms_info"));
293 $this->form->addItem($cb);
294
295 // check values
296 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_check_values"), "cobj_check_values");
297 $cb->setValue("y");
298 $cb->setChecked($this->object->getCheck_values());
299 $cb->setInfo($this->lng->txt("cont_check_values_info"));
300 $this->form->addItem($cb);
301
302 //
303 // debugging
304 //
305 $sh = new ilFormSectionHeaderGUI();
306 $sh->setTitle($this->lng->txt("cont_debugging"));
307 $this->form->addItem($sh);
308
309 // test tool
310 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_debug"), "cobj_debug");
311 $cb->setValue("y");
312 $cb->setChecked($this->object->getDebug());
313 if ($this->object->getDebugActivated() == false)
314 {
315 $cb->setDisabled(true);
316 $cb->setInfo($this->lng->txt("cont_debug_deactivated"));
317 }
318 else
319 {
320 $cb->setInfo($this->lng->txt("cont_debug_deactivate"));
321 }
322 $this->form->addItem($cb);
323 $this->form->addCommandButton("saveProperties", $lng->txt("save"));
324
325 $tpl->setContent($this->form->getHTML());
326
327 }
328
333 {
334 global $ilTabs;
336 $ilTabs->setSubTabActive('cont_sc_new_version');
337
340
341 // display import form
342 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scorm_new_version_import.html", "Modules/ScormAicc");
343
344 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_lm.svg'));
345 $this->tpl->setVariable("ALT_IMG", $this->lng->txt("obj_sahs"));
346
347 $this->ctrl->setParameter($this, "new_type", "sahs");
348 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
349
350 $this->tpl->setVariable("BTN_NAME", "newModuleVersionUpload");
351 $this->tpl->setVariable("TARGET", ' target="'.
352 ilFrameTargetInfo::_getFrame("MainContent").'" ');
353
354 $this->tpl->setVariable("TXT_SELECT_LMTYPE", $this->lng->txt("type"));
355
356 if ($type == "scorm2004") {
357 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("lm_type_scorm2004"));
358 } else {
359 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("lm_type_scorm"));
360 }
361
362 include_once 'Services/FileSystem/classes/class.ilUploadFiles.php';
364 {
366 foreach($files as $file)
367 {
368 $file = htmlspecialchars($file, ENT_QUOTES, "utf-8");
369 $this->tpl->setCurrentBlock("option_uploaded_file");
370 $this->tpl->setVariable("UPLOADED_FILENAME", $file);
371 $this->tpl->setVariable("TXT_UPLOADED_FILENAME", $file);
372 $this->tpl->parseCurrentBlock();
373 }
374 $this->tpl->setCurrentBlock("select_uploaded_file");
375 $this->tpl->setVariable("TXT_SELECT_FROM_UPLOAD_DIR", $this->lng->txt("cont_select_from_upload_dir"));
376 $this->tpl->setVariable("TXT_UPLOADED_FILE", $this->lng->txt("cont_uploaded_file"));
377 $this->tpl->parseCurrentBlock();
378 }
379
380 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
381 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
382 $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_sahs"));
383 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
384
385 // gives out the limit as a little notice
386 $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." ".$this->getMaxFileSize());
387 }
388
389
390 function getMaxFileSize()
391 {
392 // get the value for the maximal uploadable filesize from the php.ini (if available)
393 $umf=get_cfg_var("upload_max_filesize");
394 // get the value for the maximal post data from the php.ini (if available)
395 $pms=get_cfg_var("post_max_size");
396
397 //convert from short-string representation to "real" bytes
398 $multiplier_a=array("K"=>1024, "M"=>1024*1024, "G"=>1024*1024*1024);
399
400 $umf_parts=preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
401 $pms_parts=preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
402
403 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
404 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
405
406 // use the smaller one as limit
407 $max_filesize=min($umf, $pms);
408
409 if (!$max_filesize) $max_filesize=max($umf, $pms);
410
411 //format for display in mega-bytes
412 return $max_filesize=sprintf("%.1f MB",$max_filesize/1024/1024);
413 }
414
415
417 {
418 global $_FILES, $rbacsystem;
419
420 $unzip = PATH_TO_UNZIP;
421 $tocheck = "imsmanifest.xml";
422
423 include_once 'Services/FileSystem/classes/class.ilUploadFiles.php';
424
425 // check create permission before because the uploaded file will be copied
426 if (!$rbacsystem->checkAccess("write", $_GET["ref_id"]))
427 {
428 $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
429 }
430 elseif ($_FILES["scormfile"]["name"])
431 {
432 // check if file was uploaded
433 $source = $_FILES["scormfile"]["tmp_name"];
434 if (($source == 'none') || (!$source))
435 {
436 ilUtil::sendInfo($this->lng->txt("upload_error_file_not_found"),true);
437 $this->newModuleVersion();
438 return;
439 }
440 }
441 elseif ($_POST["uploaded_file"])
442 {
443 // check if the file is in the ftp directory and readable
444 if (!ilUploadFiles::_checkUploadFile($_POST["uploaded_file"]))
445 {
446 $this->ilias->raiseError($this->lng->txt("upload_error_file_not_found"),$this->ilias->error_obj->MESSAGE);
447 }
448 // copy the uploaded file to the client web dir to analyze the imsmanifest
449 // the copy will be moved to the lm directory or deleted
450 $source = CLIENT_WEB_DIR . "/" . $_POST["uploaded_file"];
451 ilUploadFiles::_copyUploadFile($_POST["uploaded_file"], $source);
452 $source_is_copy = true;
453 }
454 else
455 {
456 ilUtil::sendInfo($this->lng->txt("upload_error_file_not_found"),true);
457 $this->newModuleVersion();
458 return;
459 }
460 // fim.
461
462 //unzip the imsmanifest-file from new uploaded file
463 $pathinfo = pathinfo($source);
464 $dir = $pathinfo["dirname"];
465 $file = $pathinfo["basename"];
466 $cdir = getcwd();
467 chdir($dir);
468
469 //we need more flexible unzip here than ILIAS standard classes allow
470 $unzipcmd = $unzip." -o ".ilUtil::escapeShellArg($source)." ".$tocheck;
471 exec($unzipcmd);
472 chdir($cdir);
473 $tmp_file = $dir."/".$_GET["ref_id"].".".$tocheck;
474 require_once('./Services/Utilities/classes/class.ilFileUtils.php');
475 ilFileUtils::rename($dir."/".$tocheck,$tmp_file);
476 $new_manifest = file_get_contents($tmp_file);
477
478 //remove temp file
479 unlink($tmp_file);
480
481 //get old manifest file
482 $old_manifest = file_get_contents($this->object->getDataDirectory()."/".$tocheck);
483
484 //reload fixed version of file
485 $check ='/xmlns="http:\/\/www.imsglobal.org\/xsd\/imscp_v1p1"/';
486 $replace="xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
487 $reload_manifest = preg_replace($check, $replace, $new_manifest);
488
489 //do testing for converted versions as well as earlier ILIAS version messed up utf8 conversion
490 if (strcmp($new_manifest,$old_manifest) == 0 || strcmp(utf8_encode($new_manifest),$old_manifest) == 0 ||
491 strcmp ($reload_manifest, $old_manifest) == 0 || strcmp(utf8_encode($reload_manifest),$old_manifest) == 0 ){
492
493 //get exisiting module version
494 $module_version = $this->object->getModuleVersion();
495
496 if ($_FILES["scormfile"]["name"])
497 {
498 //build targetdir in lm_data
499 $file_path = $this->object->getDataDirectory()."/".$_FILES["scormfile"]["name"].".".$module_version;
500 $file_path = str_replace(".zip.".$module_version, ".".$module_version.".zip",$file_path);
501 //move to data directory and add subfix for versioning
502 ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"],$_FILES["scormfile"]["name"], $file_path);
503 }
504 else
505 {
506 //build targetdir in lm_data
507 $file_path = $this->object->getDataDirectory()."/".$_POST["uploaded_file"].".".$module_version;
508 $file_path = str_replace(".zip.".$module_version, ".".$module_version.".zip",$file_path);
509 // move the already copied file to the lm_data directory
510 require_once('./Services/Utilities/classes/class.ilFileUtils.php');
511 ilFileUtils::rename($source, $file_path);
512 }
513
514 //unzip and replace old extracted files
515 ilUtil::unzip($file_path, true);
516 ilUtil::renameExecutables($this->object->getDataDirectory()); //(security)
517
518 //increase module version
519 $this->object->setModuleVersion($module_version+1);
520 $this->object->update();
521
522 //redirect to properties and display success
523 ilUtil::sendInfo( $this->lng->txt("cont_new_module_added"), true);
524 ilUtil::redirect("ilias.php?baseClass=ilSAHSEditGUI&ref_id=".$_GET["ref_id"]);
525 exit;
526 }
527 else
528 {
529 if ($source_is_copy)
530 {
531 unlink($source);
532 }
533
534 ilUtil::sendInfo($this->lng->txt("cont_invalid_new_module"),true);
535 $this->newModuleVersion();
536 }
537 }
538
542 function saveProperties()
543 {
544 $this->object->setTitle($_POST["Fobject_title"]);
545 $this->object->setDescription($_POST["Fobject_description"]);
546
547 //check if OfflineMode-Zip has to be created
548 $tmpOfflineMode= ilUtil::yn2tf($_POST["cobj_offline_mode"]);
549 if ($tmpOfflineMode == true) {
550 if ($this->object->getOfflineMode() == false) {
551 $this->object->zipLmForOfflineMode();
552 }
553 }
554 if (isset($_POST["mastery_score"])){
555 $this->object->setMasteryScore($_POST["mastery_score"]);
556 // $this->object->updateMasteryScoreValues();
557 }
558
559 $t_height = $this->object->getHeight();
560 if ($_POST["height_0"] != $this->object->getHeight()) $t_height = $_POST["height_0"];
561 if ($_POST["height_1"] != $this->object->getHeight()) $t_height = $_POST["height_1"];
562
563 $t_width = $this->object->getWidth();
564 if ($_POST["width_0"] != $this->object->getWidth()) $t_width = $_POST["width_0"];
565 if ($_POST["width_1"] != $this->object->getWidth()) $t_width = $_POST["width_1"];
566
567 $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
568 $this->object->setOfflineMode($tmpOfflineMode);
569 $this->object->setOpenMode($_POST["open_mode"]);
570 $this->object->setWidth($t_width);
571 $this->object->setHeight($t_height);
572 $this->object->setAuto_last_visited(ilUtil::yn2tf($_POST["cobj_auto_last_visited"]));
573 $this->object->setAutoContinue(ilUtil::yn2tf($_POST["auto_continue"]));
574 $this->object->setMaxAttempt($_POST["max_attempt"]);
575 $this->object->setDefaultLessonMode($_POST["lesson_mode"]);
576 $this->object->setCreditMode($_POST["credit_mode"]);
577 $this->object->setAutoReview(ilUtil::yn2tf($_POST["auto_review"]));
578 $this->object->setSession(ilUtil::yn2tf($_POST["cobj_session"]));
579 $this->object->setInteractions(ilUtil::yn2tf($_POST["cobj_interactions"]));
580 $this->object->setObjectives(ilUtil::yn2tf($_POST["cobj_objectives"]));
581 $this->object->setTime_from_lms(ilUtil::yn2tf($_POST["cobj_time_from_lms"]));
582 $this->object->setCheck_values(ilUtil::yn2tf($_POST["cobj_check_values"]));
583 $this->object->setDebug(ilUtil::yn2tf($_POST["cobj_debug"]));
584 $this->object->update();
585 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
586 $this->ctrl->redirect($this, "properties");
587 }
588
592 protected function showTrackingItemsBySco()
593 {
594 global $ilTabs;
595
597 $ilTabs->setTabActive("cont_tracking_data");
598 $ilTabs->setSubTabActive("cont_tracking_bysco");
599
600 $reports = array('exportSelectedCore','exportSelectedInteractions','exportSelectedObjectives','exportSelectedRaw');//,'tracInteractionItem','tracInteractionUser','tracInteractionUserAnswers'
601 $scoSelected = "all";
602 if (isset($_GET["scoSelected"])) $scoSelected = ilUtil::stripSlashes($_GET["scoSelected"]);
603 if (isset($_POST["scoSelected"])) $scoSelected = ilUtil::stripSlashes($_POST["scoSelected"]);
604 $this->ctrl->setParameter($this,'scoSelected',$scoSelected);
605
606 $report = "choose";
607 if (isset($_GET["report"])) $report = ilUtil::stripSlashes($_GET["report"]);
608 if (isset($_POST["report"])) $report = ilUtil::stripSlashes($_POST["report"]);
609 $this->ctrl->setParameter($this,'report',$report);
610
611 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsPerScoFilterGUI.php';
612 $filter = new ilSCORMTrackingItemsPerScoFilterGUI($this, 'showTrackingItemsBySco');
613 $filter->parse($scoSelected,$report,$reports);
614 if($report == "choose") {
615 $this->tpl->setContent($filter->form->getHTML());
616 } else {
617 $scosSelected = array();
618 if ($scoSelected != "all") $scosSelected[] = $scoSelected;
619 else {
620 $scos=$this->object->getTrackedItems();
621 foreach($scos as $row)
622 {
623 $scosSelected[]=(int)$row->getId();
624 }
625 }
626 //with check for course ...
627 include_once "Services/Tracking/classes/class.ilTrQuery.php";
628 $a_users=ilTrQuery::getParticipantsForObject($this->ref_id);
629 // var_dump($this->object->getTrackedUsers(""));
630 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsTableGUI.php';
631 $tbl = new ilSCORMTrackingItemsTableGUI($this->object->getId(), $this, 'showTrackingItemsBySco', $a_users, $scosSelected, $report);
632 $this->tpl->setContent($filter->form->getHTML().$tbl->getHTML());
633 }
634 return true;
635 }
636
637
643 public function showTrackingItems()
644 {
645 global $ilTabs, $ilAccess;
646
647 $ilTabs->setTabActive('cont_tracking_data');
648
649 if($ilAccess->checkAccess("read_learning_progress", "", $_GET["ref_id"])) {
650
652 $ilTabs->setSubTabActive('cont_tracking_byuser');
653
654 $reports = array('exportSelectedSuccess','exportSelectedCore','exportSelectedInteractions','exportSelectedObjectives','exportSelectedRaw');
655
656 $userSelected = "all";
657 if (isset($_GET["userSelected"])) $userSelected = ilUtil::stripSlashes($_GET["userSelected"]);
658 if (isset($_POST["userSelected"])) $userSelected = ilUtil::stripSlashes($_POST["userSelected"]);
659 $this->ctrl->setParameter($this,'userSelected',$userSelected);
660
661 $report = "choose";
662 if (isset($_GET["report"])) $report = ilUtil::stripSlashes($_GET["report"]);
663 if (isset($_POST["report"])) $report = ilUtil::stripSlashes($_POST["report"]);
664 $this->ctrl->setParameter($this,'report',$report);
665
666 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsPerUserFilterGUI.php';
667 $filter = new ilSCORMTrackingItemsPerUserFilterGUI($this, 'showTrackingItems');
668 $filter->parse($userSelected,$report,$reports);
669 if($report == "choose") {
670 $this->tpl->setContent($filter->form->getHTML());
671 } else {
672 $usersSelected = array();
673 if ($userSelected != "all") $usersSelected[] = $userSelected;
674 else {
675 include_once "Services/Tracking/classes/class.ilTrQuery.php";
676 $users=ilTrQuery::getParticipantsForObject($this->ref_id);
677 foreach($users as $user) {
678 if(ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') {
679 $usersSelected[] = $user;
680 }
681 }
682 }
683 $scosSelected = array();
684 $scos=$this->object->getTrackedItems();
685 foreach($scos as $row)
686 {
687 $scosSelected[]=(int)$row->getId();
688 }
689
690 //with check for course ...
691 // include_once "Services/Tracking/classes/class.ilTrQuery.php";
692 // $a_users=ilTrQuery::getParticipantsForObject($this->ref_id);
693 // var_dump($this->object->getTrackedUsers(""));
694 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsTableGUI.php';
695 $tbl = new ilSCORMTrackingItemsTableGUI($this->object->getId(), $this, 'showTrackingItems', $usersSelected, $scosSelected, $report);
696 $this->tpl->setContent($filter->form->getHTML().$tbl->getHTML());
697 }
698 }
699 else if($ilAccess->checkAccess("edit_learning_progress", "", $_GET["ref_id"])) {
700 $this->modifyTrackingItems();
701 }
702 return true;
703 }
704 protected function modifyTrackingItems()
705 {
706 global $ilAccess;
707 if($ilAccess->checkAccess("edit_learning_progress", "", $_GET["ref_id"])) {
708 include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
710 if(!$privacy->enabledSahsProtocolData())
711 {
712 $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
713 }
714
715 global $ilTabs, $ilToolbar;
716
717 include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
718 $ilToolbar->addButton(
719 $this->lng->txt('import'),
720 $this->ctrl->getLinkTarget($this, 'importForm')
721 );
722 $ilToolbar->addButton(
723 $this->lng->txt('cont_export_all'),
724 $this->ctrl->getLinkTarget($this, 'exportAll')
725 );
726
728 $ilTabs->setTabActive('cont_tracking_data');
729 $ilTabs->setSubTabActive('cont_tracking_modify');
730
731 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingUsersTableGUI.php';
732 $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
733 $tbl->parse();
734 $this->tpl->setContent($tbl->getHTML());
735 }
736 }
737
738
742 protected function applyUserTableFilter()
743 {
744 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingUsersTableGUI.php';
745 $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
746 $tbl->writeFilterToSession();
747 $tbl->resetOffset();
748 $this->modifyTrackingItems();
749 }
750
754 protected function resetUserTableFilter()
755 {
756 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingUsersTableGUI.php';
757 $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
758 $tbl->resetFilter();
759 $tbl->resetOffset();
760 $this->modifyTrackingItems();
761 }
762
767 {
768 if(!isset($_POST["user"]))
769 {
770 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
771 }
772
773 // display confirmation message
774 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
775 $cgui = new ilConfirmationGUI();
776 $cgui->setFormAction($this->ctrl->getFormAction($this));
777 $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
778 $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteTracking");
779 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDeleteTracking");
780
781 foreach($_POST["user"] as $id)
782 {
783 if (ilObject::_exists($id) && ilObject::_lookUpType($id)=="usr" )
784 {
785 $user = new ilObjUser($id);
786
787 $caption = ilUtil::getImageTagByType("sahs", $this->tpl->tplPath).
788 " ".$this->lng->txt("cont_tracking_data").
789 ": ".$user->getLastname().", ".$user->getFirstname();
790
791
792 $cgui->addItem("user[]", $id, $caption);
793 }
794 }
795
796 $this->tpl->setContent($cgui->getHTML());
797 }
798
803 {
804 ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
805 $this->ctrl->redirect($this, "modifyTrackingItems");
806 }
807
809 {
810 $this->object->deleteTrackingDataOfUsers($_POST["user"]);
811 $this->ctrl->redirect($this, "modifyTrackingItems");
812 }
813
817 function cancel()
818 {
819 ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
820 $this->ctrl->redirect($this, "properties");
821 }
822
826 protected function import()
827 {
828 $form = $this->initImportForm("");
829 if($form->checkInput())
830 {
831 $source = $form->getInput('csv');
832 $error = $this->object->importTrackingData($source['tmp_name']);
833 switch($error)
834 {
835 case 0 :
836 ilUtil::sendInfo('Tracking data imported', true);
837 $this->ctrl->redirect($this, "showTrackingItems");
838 break;
839 case -1 :
840 ilUtil::sendInfo($this->lng->txt('err_check_input'));
841 $this->importForm();
842 break;
843 }
844 }
845 ilUtil::sendInfo($this->lng->txt('err_check_input'));
846 $form->setValuesByPost();
847 $this->importForm();
848 }
849
853 protected function importForm()
854 {
855 global $ilTabs;
856
857 $ilTabs->clearTargets();
858 $ilTabs->setBackTarget($this->lng->txt('back'),$this->ctrl->getLinkTarget($this,'showTrackingItems'));
859
860 $form = $this->initImportForm("");
861 $this->tpl->setContent($form->getHTML());
862 }
863
867 protected function initImportForm($a_new_type)
868 {
869 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
870 $form = new ilPropertyFormGUI();
871 $form->setFormAction($this->ctrl->getFormAction($this));
872 $form->setTitle($this->lng->txt('cont_import_tracking'));
873 $form->addCommandButton('import', $this->lng->txt('import'));
874 $form->addCommandButton('showTrackingItems', $this->lng->txt('cancel'));
875
876 $csv = new ilFileInputGUI($this->lng->txt('select_file'),'csv');
877 $csv->setRequired(true);
878 $csv->setSuffixes(array('csv'));
879 $form->addItem($csv);
880
881 return $form;
882 }
883
887 protected function exportAll()
888 {
889 $this->object->exportSelected(1);
890 }
891
895 protected function exportSelectionUsers()
896 {
897 if(!count((array) $_POST['user']))
898 {
899 //ilUtil::sendFailure($this->lng->txt('select_one'),true);
900 ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
901 $this->ctrl->redirect($this,'modifyTrackingItems');
902 } else {
903 $this->object->exportSelected(0,$_POST["user"]);
904 }
905 }
906
907
909 {
910 if (!isset($_POST["user"])) {
911 ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
912 }
913 $this->object->decreaseAttemptsForUser($_POST["user"]);
914 $this->ctrl->redirect($this, "modifyTrackingItems");
915 }
916
917
921 protected function showTrackingItem()
922 {
923 global $ilTabs;
924
925 include_once "./Services/Table/classes/class.ilTableGUI.php";
926
927 $this->setSubTabs();
928 $ilTabs->setTabActive("cont_tracking_data");
929 $ilTabs->setSubTabActive("cont_tracking_byuser");
930
931 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsPerUserTableGUI.php';
932 $tbl = new ilSCORMTrackingItemsPerUserTableGUI($this->object->getId(), $this, 'showTrackingItem');
933 $tbl->setUserId((int) $_REQUEST['user_id']);
934 $tbl->parse();
935 $this->tpl->setContent($tbl->getHTML());
936 return true;
937 }
938
942 protected function showTrackingItemSco()
943 {
944 global $ilTabs;
945
946 include_once "./Services/Table/classes/class.ilTableGUI.php";
947
948 $this->setSubTabs();
949 $ilTabs->setTabActive("cont_tracking_data");
950 $ilTabs->setSubTabActive("cont_tracking_bysco");
951
952 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsScoTableGUI.php';
953 $tbl = new ilSCORMTrackingItemsScoTableGUI($this->object->getId(), $this, 'showTrackingItemSco');
954 $tbl->setScoId((int) $_GET['obj_id']);
955 $tbl->parse();
956 $this->tpl->setContent($tbl->getHTML());
957 return true;
958 }
959
963 protected function showTrackingItemPerUser()
964 {
965 global $ilTabs;
966
967 include_once "./Services/Table/classes/class.ilTableGUI.php";
968
969 $this->setSubTabs();
970 $ilTabs->setTabActive("cont_tracking_data");
971 $ilTabs->setSubTabActive("cont_tracking_byuser");
972
973 $this->ctrl->setParameter($this,'obj_id',(int) $_REQUEST['obj_id']);
974 $this->ctrl->setParameter($this,'user_id',(int) $_REQUEST['user_id']);
975
976 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemPerUserTableGUI.php';
977 $tbl = new ilSCORMTrackingItemPerUserTableGUI($this->object->getId(), $this, 'showTrackingItemPerUser');
978 $tbl->setUserId((int) $_REQUEST['user_id']);
979 $tbl->setScoId((int) $_REQUEST['obj_id']);
980 $tbl->parse();
981 $this->tpl->setContent($tbl->getHTML());
982 return true;
983 }
984
985 //setTabs
986 function setSubTabs()
987 {
988 global $lng, $ilTabs, $ilCtrl, $ilAccess;
989
990 if($ilAccess->checkAccess("read_learning_progress", "", $_GET["ref_id"])) {
991 $ilTabs->addSubTabTarget("cont_tracking_byuser",
992 $this->ctrl->getLinkTarget($this, "showTrackingItems"), array("edit", ""),
993 get_class($this));
994
995 $ilTabs->addSubTabTarget("cont_tracking_bysco",
996 $this->ctrl->getLinkTarget($this, "showTrackingItemsBySco"), array("edit", ""),
997 get_class($this));
998 }
999 if($ilAccess->checkAccess("edit_learning_progress", "", $_GET["ref_id"])) {
1000 $ilTabs->addSubTabTarget("cont_tracking_modify",
1001 $this->ctrl->getLinkTarget($this, "modifyTrackingItems"), array("edit", ""),
1002 get_class($this));
1003 }
1004 }
1005
1006
1012 protected function offlineModeManager()
1013 {
1014 global $rbacsystem, $tree, $tpl, $lng, $ilToolbar, $ilCtrl, $ilSetting;
1015
1016 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
1017 if(!ilLearningProgressAccess::checkAccess($this->object->getRefId()))
1018 {
1019 $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
1020 }
1021
1022 include_once './Modules/ScormAicc/classes/class.ilSCORMOfflineModeUsersTableGUI.php';
1023 $tbl = new ilSCORMOfflineModeUsersTableGUI($this->object->getId(), $this, 'offlineModeManager');
1024 $tbl->parse();
1025 $this->tpl->setContent($tbl->getHTML());
1026
1027 }
1031 protected function stopUserOfflineMode()
1032 {
1033 if(!count((array) $_POST['user']))
1034 {
1035 ilUtil::sendFailure($this->lng->txt('select_one'),true);
1036 $this->ctrl->redirect($this,'offlineModeManager');
1037 }
1038 // display confirmation message
1039 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1040 $cgui = new ilConfirmationGUI();
1041 $cgui->setFormAction($this->ctrl->getFormAction($this));
1042 $cgui->setHeaderText($this->lng->txt("info_stop_offline_mode_sure"));
1043 $cgui->setCancel($this->lng->txt("cancel"), "cancelStopUserOfflineMode");
1044 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedStopUserOfflineMode");
1045 foreach($_POST["user"] as $id)
1046 {
1047 if (ilObject::_exists($id) && ilObject::_lookUpType($id)=="usr" )
1048 {
1049 $user = new ilObjUser($id);
1050 $caption = ilUtil::getImageTagByType("sahs_offline", $this->tpl->tplPath).
1051 " ".$this->lng->txt("stop_user_offline_mode_for_user").
1052 ": ".$user->getLastname().", ".$user->getFirstname();
1053 $cgui->addItem("user[]", $id, $caption);
1054 }
1055 }
1056 $this->tpl->setContent($cgui->getHTML());
1057 }
1058
1060 {
1061 ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
1062 $this->ctrl->redirect($this, "offlineModeManager");
1063 }
1064
1066 {
1067
1068 include_once './Modules/ScormAicc/classes/class.ilSCORMOfflineMode.php';
1069 foreach($_POST["user"] as $id)
1070 {
1071 ilSCORMOfflineMode::stopOfflineModeForUser($this->object->getId(),$id);
1072 }
1073
1074 $this->offlineModeManager();
1075 }
1076
1077
1078}
1079// END class.ilObjSCORMLearningModule
1080?>
sprintf('%.4f', $callTime)
$error
Definition: Error.php:17
$files
Definition: add-vimline.php:18
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
Confirmation screen class.
This class represents a file property in a property form.
static rename($a_source, $a_target)
Rename a file.
This class represents a section header in a property form.
static _getFrame($a_class, $a_type='')
Get content frame name.
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
This class represents a non editable value in a property form.
This class represents a number property in a property form.
SCORM/AICC/HACP Learning Modules.
static _lookupSubType($a_obj_id)
lookup subtype id (scorm, aicc, hacp)
Class ilObjSCORMLearningModuleGUI.
offlineModeManager()
Manage offline mode for users @global ilTabs $ilTabs $global ilToolbar $ilToolbar.
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor.
exportAll()
Show export section for all users.
initImportForm($a_new_type)
Init import form.
stopUserOfflineMode()
Stop offline mode for selected users.
exportSelectionUsers()
Export selection for selected users.
assignObject()
assign scorm object to scorm gui object
showTrackingItemSco()
show tracking data of item
deleteTrackingForUser()
display deletion confirmation screen
showTrackingItemPerUser()
show tracking data of item per user
cancel()
overwrite..jump back to trackingdata not parent
newModuleVersion()
upload new version of module
showTrackingItems()
Show tracking table @global ilTabs $ilTabs $global ilToolbar $ilToolbar.
cancelDeleteTracking()
cancel deletion of export files
Class ilObjSCORMLearningModule.
static _lookupObjectId($a_ref_id)
lookup object id
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _getInstance()
Get instance of ilPrivacySettings.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
GUI class ilSCORMOfflineModeUsersTableGUI.
static stopOfflineModeForUser($obj_id, $user_id)
static checkIfAnyoneIsInOfflineMode($obj_id)
Class ilSCORMTrackingItemsTableGUI.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static getParticipantsForObject($a_ref_id)
Get participant ids for given object.
static _getUploadFiles()
Get a list of readable files in the upload directory.
static _copyUploadFile($a_file, $a_target, $a_raise_errors=true)
copy an uploaded file to the target directory (including virus check)
static _checkUploadFile($a_file)
Check if a file exists in the upload directory and is readable.
static _getUploadDirectory()
Get the directory with uploaded files.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static escapeShellArg($a_arg)
static getImageTagByType($a_type, $a_path, $a_big=false)
Builds an html image tag TODO: function still in use, but in future use getImagePath and move HTML-Co...
static redirect($a_script)
http redirect to other script
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static yn2tf($a_yn)
convert "y"/"n" to true/false
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
$tbl
Definition: example_048.php:81
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:17
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
echo;exit;}function LogoutNotification($SessionID) { global $ilDB; $q="SELECT session_id, data FROM usr_session WHERE expires > (\w+)\|/" PREG_SPLIT_NO_EMPTY PREG_SPLIT_DELIM_CAPTURE
if(!is_array($argv)) $options