ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 ilObjSCORMLearningModuleGUI($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 $this->ilObjectGUI($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 // SCORM-type
93 $ne = new ilNonEditableValueGUI($this->lng->txt("type"), "");
94 $ne->setValue($this->lng->txt( "lm_type_" . ilObjSAHSLearningModule::_lookupSubType( $this->object->getID() ) ) );
95 $this->form->addItem($ne);
96
97 // version
98 $ne = new ilNonEditableValueGUI($this->lng->txt("cont_sc_version"), "");
99 $ne->setValue($this->object->getModuleVersion());
100 $this->form->addItem($ne);
101
102 // online
103 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_online"), "cobj_online");
104 $cb->setValue("y");
105 if ($this->object->getOnline())
106 {
107 $cb->setChecked(true);
108 }
109 $this->form->addItem($cb);
110
111 // offline Mode
112 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_offline_mode_allow"), "cobj_offline_mode");
113 $cb->setValue("y");
114 $cb->setChecked($this->object->getOfflineMode());
115 include_once("./Modules/ScormAicc/classes/class.ilSCORMOfflineMode.php");
116 if ($this->object->getOfflineMode()== true && ilSCORMOfflineMode::checkIfAnyoneIsInOfflineMode($this->object->getID()) == true) {
117 $cb->setDisabled(true);
118 $cb->setInfo($this->lng->txt("cont_offline_mode_disable_not_allowed_info"));
119 } else {
120 $cb->setInfo($this->lng->txt("cont_offline_mode_allow_info"));
121 }
122 $this->form->addItem($cb);
123
124 //
125 // presentation
126 //
127 $sh = new ilFormSectionHeaderGUI();
128 $sh->setTitle($this->lng->txt("cont_presentation"));
129 $this->form->addItem($sh);
130
131 // display mode (open)
132 $options = array(
133 "0" => $this->lng->txt("cont_open_normal"),
134 "1" => $this->lng->txt("cont_open_iframe_max"),
135 "2" => $this->lng->txt("cont_open_iframe_defined"),
136 "5" => $this->lng->txt("cont_open_window_undefined"),
137 "6" => $this->lng->txt("cont_open_window_defined")
138 );
139 $si = new ilSelectInputGUI($this->lng->txt("cont_open"), "open_mode");
140 $si->setOptions($options);
141 $si->setValue($this->object->getOpenMode());
142 $this->form->addItem($si);
143
144 // width
145 $ni = new ilNumberInputGUI($this->lng->txt("cont_width"), "width");
146 $ni->setMaxLength(4);
147 $ni->setSize(4);
148 $ni->setValue($this->object->getWidth());
149 $this->form->addItem($ni);
150
151 // height
152 $ni = new ilNumberInputGUI($this->lng->txt("cont_height"), "height");
153 $ni->setMaxLength(4);
154 $ni->setSize(4);
155 $ni->setValue($this->object->getHeight());
156 $this->form->addItem($ni);
157
158 // auto navigation to last visited item
159 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_auto_last_visited"), "cobj_auto_last_visited");
160 $cb->setValue("y");
161 $cb->setChecked($this->object->getAuto_last_visited());
162 $cb->setInfo($this->lng->txt("cont_auto_last_visited_info"));
163 $this->form->addItem($cb);
164
165 // auto continue
166 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sc_auto_continue"), "auto_continue");
167 $cb->setValue("y");
168 $cb->setChecked($this->object->getAutoContinue());
169 $this->form->addItem($cb);
170
171 //
172 // scorm options
173 //
174 $sh = new ilFormSectionHeaderGUI();
175 $sh->setTitle($this->lng->txt("cont_scorm_options"));
176 $this->form->addItem($sh);
177
178 // max attempts
179 $ni = new ilNumberInputGUI($this->lng->txt("cont_sc_max_attempt"), "max_attempt");
180 $ni->setMaxLength(3);
181 $ni->setSize(3);
182 $ni->setValue($this->object->getMaxAttempt());
183 $this->form->addItem($ni);
184
185 // lesson mode
186 $options = array("normal" => $this->lng->txt("cont_sc_less_mode_normal"),
187 "browse" => $this->lng->txt("cont_sc_less_mode_browse"));
188 $si = new ilSelectInputGUI($this->lng->txt("cont_def_lesson_mode"), "lesson_mode");
189 $si->setOptions($options);
190 $si->setValue($this->object->getDefaultLessonMode());
191 $this->form->addItem($si);
192
193 // credit mode
194 $options = array("credit" => $this->lng->txt("cont_credit_on"),
195 "no_credit" => $this->lng->txt("cont_credit_off"));
196 $si = new ilSelectInputGUI($this->lng->txt("cont_credit_mode"), "credit_mode");
197 $si->setOptions($options);
198 $si->setValue($this->object->getCreditMode());
199 $si->setInfo($this->lng->txt("cont_credit_mode_info"));
200 $this->form->addItem($si);
201
202 // set lesson mode review when completed
203 $options = array(
204 "n" => $this->lng->txt("cont_sc_auto_review_no"),
205// "r" => $this->lng->txt("cont_sc_auto_review_completed_not_failed_or_passed"),
206// "p" => $this->lng->txt("cont_sc_auto_review_passed"),
207// "q" => $this->lng->txt("cont_sc_auto_review_passed_or_failed"),
208// "c" => $this->lng->txt("cont_sc_auto_review_completed"),
209// "d" => $this->lng->txt("cont_sc_auto_review_completed_and_passed"),
210 "y" => $this->lng->txt("cont_sc_auto_review_completed_or_passed"),
211 );
212 $si = new ilSelectInputGUI($this->lng->txt("cont_sc_auto_review_2004"), "auto_review");
213 $si->setOptions($options);
214 $si->setValue($this->object->getAutoReviewChar());
215 $si->setInfo($this->lng->txt("cont_sc_auto_review_info_12"));
216 $this->form->addItem($si);
217
218 //
219 // rte settings
220 //
221 $sh = new ilFormSectionHeaderGUI();
222 $sh->setTitle($this->lng->txt("cont_rte_settings"));
223 $this->form->addItem($sh);
224
225 // unlimited session timeout
226 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sc_usession"), "cobj_session");
227 $cb->setValue("y");
228 $cb->setChecked($this->object->getSession());
229 $cb->setInfo($this->lng->txt("cont_sc_usession_info"));
230 $this->form->addItem($cb);
231
232 // storage of interactions
233 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_interactions"), "cobj_interactions");
234 $cb->setValue("y");
235 $cb->setChecked($this->object->getInteractions());
236 $this->form->addItem($cb);
237
238 // objectives
239 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_objectives"), "cobj_objectives");
240 $cb->setValue("y");
241 $cb->setChecked($this->object->getObjectives());
242 $this->form->addItem($cb);
243
244 // time from lms
245 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_time_from_lms"), "cobj_time_from_lms");
246 $cb->setValue("y");
247 $cb->setChecked($this->object->getTime_from_lms());
248 $cb->setInfo($this->lng->txt("cont_time_from_lms_info"));
249 $this->form->addItem($cb);
250
251 // check values
252 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_check_values"), "cobj_check_values");
253 $cb->setValue("y");
254 $cb->setChecked($this->object->getCheck_values());
255 $this->form->addItem($cb);
256 // api adapter name
257 // $this->tpl->setVariable("TXT_API_ADAPTER", $this->lng->txt("cont_api_adapter"));
258 // $this->tpl->setVariable("VAL_API_ADAPTER", $this->object->getAPIAdapterName());
259 // api functions prefix
260 // $this->tpl->setVariable("TXT_API_PREFIX", $this->lng->txt("cont_api_func_prefix"));
261 // $this->tpl->setVariable("VAL_API_PREFIX", $this->object->getAPIFunctionsPrefix());
262
263 //
264 // debugging
265 //
266 $sh = new ilFormSectionHeaderGUI();
267 $sh->setTitle($this->lng->txt("cont_debugging"));
268 $this->form->addItem($sh);
269
270 // test tool
271 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_debug"), "cobj_debug");
272 $cb->setValue("y");
273 $cb->setChecked($this->object->getDebug());
274 if ($this->object->getDebugActivated() == false)
275 {
276 $cb->setDisabled(true);
277 $cb->setInfo($this->lng->txt("cont_debug_deactivated"));
278 }
279 else
280 {
281 $cb->setInfo($this->lng->txt("cont_debug_deactivate"));
282 }
283 $this->form->addItem($cb);
284 $this->form->addCommandButton("saveProperties", $lng->txt("save"));
285
286 $tpl->setContent($this->form->getHTML());
287
288 }
289
294 {
295 global $ilTabs;
297 $ilTabs->setSubTabActive('cont_sc_new_version');
298
301
302 // display import form
303 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scorm_new_version_import.html", "Modules/ScormAicc");
304
305 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_lm.svg'));
306 $this->tpl->setVariable("ALT_IMG", $this->lng->txt("obj_sahs"));
307
308 $this->ctrl->setParameter($this, "new_type", "sahs");
309 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
310
311 $this->tpl->setVariable("BTN_NAME", "newModuleVersionUpload");
312 $this->tpl->setVariable("TARGET", ' target="'.
313 ilFrameTargetInfo::_getFrame("MainContent").'" ');
314
315 $this->tpl->setVariable("TXT_SELECT_LMTYPE", $this->lng->txt("type"));
316
317 if ($type == "scorm2004") {
318 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("lm_type_scorm2004"));
319 } else {
320 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("lm_type_scorm"));
321 }
322
323 include_once 'Services/FileSystem/classes/class.ilUploadFiles.php';
325 {
327 foreach($files as $file)
328 {
329 $file = htmlspecialchars($file, ENT_QUOTES, "utf-8");
330 $this->tpl->setCurrentBlock("option_uploaded_file");
331 $this->tpl->setVariable("UPLOADED_FILENAME", $file);
332 $this->tpl->setVariable("TXT_UPLOADED_FILENAME", $file);
333 $this->tpl->parseCurrentBlock();
334 }
335 $this->tpl->setCurrentBlock("select_uploaded_file");
336 $this->tpl->setVariable("TXT_SELECT_FROM_UPLOAD_DIR", $this->lng->txt("cont_select_from_upload_dir"));
337 $this->tpl->setVariable("TXT_UPLOADED_FILE", $this->lng->txt("cont_uploaded_file"));
338 $this->tpl->parseCurrentBlock();
339 }
340
341 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
342 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
343 $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_sahs"));
344 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
345
346 // gives out the limit as a little notice
347 $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." ".$this->getMaxFileSize());
348 }
349
350
351 function getMaxFileSize()
352 {
353 // get the value for the maximal uploadable filesize from the php.ini (if available)
354 $umf=get_cfg_var("upload_max_filesize");
355 // get the value for the maximal post data from the php.ini (if available)
356 $pms=get_cfg_var("post_max_size");
357
358 //convert from short-string representation to "real" bytes
359 $multiplier_a=array("K"=>1024, "M"=>1024*1024, "G"=>1024*1024*1024);
360
361 $umf_parts=preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
362 $pms_parts=preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
363
364 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
365 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
366
367 // use the smaller one as limit
368 $max_filesize=min($umf, $pms);
369
370 if (!$max_filesize) $max_filesize=max($umf, $pms);
371
372 //format for display in mega-bytes
373 return $max_filesize=sprintf("%.1f MB",$max_filesize/1024/1024);
374 }
375
376
378 {
379 global $_FILES, $rbacsystem;
380
381 $unzip = PATH_TO_UNZIP;
382 $tocheck = "imsmanifest.xml";
383
384 include_once 'Services/FileSystem/classes/class.ilUploadFiles.php';
385
386 // check create permission before because the uploaded file will be copied
387 if (!$rbacsystem->checkAccess("write", $_GET["ref_id"]))
388 {
389 $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
390 }
391 elseif ($_FILES["scormfile"]["name"])
392 {
393 // check if file was uploaded
394 $source = $_FILES["scormfile"]["tmp_name"];
395 if (($source == 'none') || (!$source))
396 {
397 ilUtil::sendInfo($this->lng->txt("upload_error_file_not_found"),true);
398 $this->newModuleVersion();
399 return;
400 }
401 }
402 elseif ($_POST["uploaded_file"])
403 {
404 // check if the file is in the ftp directory and readable
405 if (!ilUploadFiles::_checkUploadFile($_POST["uploaded_file"]))
406 {
407 $this->ilias->raiseError($this->lng->txt("upload_error_file_not_found"),$this->ilias->error_obj->MESSAGE);
408 }
409 // copy the uploaded file to the client web dir to analyze the imsmanifest
410 // the copy will be moved to the lm directory or deleted
411 $source = CLIENT_WEB_DIR . "/" . $_POST["uploaded_file"];
412 ilUploadFiles::_copyUploadFile($_POST["uploaded_file"], $source);
413 $source_is_copy = true;
414 }
415 else
416 {
417 ilUtil::sendInfo($this->lng->txt("upload_error_file_not_found"),true);
418 $this->newModuleVersion();
419 return;
420 }
421 // fim.
422
423 //unzip the imsmanifest-file from new uploaded file
424 $pathinfo = pathinfo($source);
425 $dir = $pathinfo["dirname"];
426 $file = $pathinfo["basename"];
427 $cdir = getcwd();
428 chdir($dir);
429
430 //we need more flexible unzip here than ILIAS standard classes allow
431 $unzipcmd = $unzip." -o ".ilUtil::escapeShellArg($source)." ".$tocheck;
432 exec($unzipcmd);
433 chdir($cdir);
434 $tmp_file = $dir."/".$tocheck.".".$_GET["ref_id"];
435
436 rename($dir."/".$tocheck,$tmp_file);
437 $new_manifest = file_get_contents($tmp_file);
438
439 //remove temp file
440 unlink($tmp_file);
441
442 //get old manifest file
443 $old_manifest = file_get_contents($this->object->getDataDirectory()."/".$tocheck);
444
445 //reload fixed version of file
446 $check ='/xmlns="http:\/\/www.imsglobal.org\/xsd\/imscp_v1p1"/';
447 $replace="xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
448 $reload_manifest = preg_replace($check, $replace, $new_manifest);
449
450 //do testing for converted versions as well as earlier ILIAS version messed up utf8 conversion
451 if (strcmp($new_manifest,$old_manifest) == 0 || strcmp(utf8_encode($new_manifest),$old_manifest) == 0 ||
452 strcmp ($reload_manifest, $old_manifest) == 0 || strcmp(utf8_encode($reload_manifest),$old_manifest) == 0 ){
453
454 //get exisiting module version
455 $module_version = $this->object->getModuleVersion();
456
457 if ($_FILES["scormfile"]["name"])
458 {
459 //build targetdir in lm_data
460 $file_path = $this->object->getDataDirectory()."/".$_FILES["scormfile"]["name"].".".$module_version;
461
462 //move to data directory and add subfix for versioning
463 ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"],$_FILES["scormfile"]["name"], $file_path);
464 }
465 else
466 {
467 //build targetdir in lm_data
468 $file_path = $this->object->getDataDirectory()."/".$_POST["uploaded_file"].".".$module_version;
469 // move the already copied file to the lm_data directory
470 rename($source, $file_path);
471 }
472
473 //unzip and replace old extracted files
474 ilUtil::unzip($file_path, true);
475 ilUtil::renameExecutables($this->object->getDataDirectory()); //(security)
476
477 //increase module version
478 $this->object->setModuleVersion($module_version+1);
479 $this->object->update();
480
481 //redirect to properties and display success
482 ilUtil::sendInfo( $this->lng->txt("cont_new_module_added"), true);
483 ilUtil::redirect("ilias.php?baseClass=ilSAHSEditGUI&ref_id=".$_GET["ref_id"]);
484 exit;
485 }
486 else
487 {
488 if ($source_is_copy)
489 {
490 unlink($source);
491 }
492
493 ilUtil::sendInfo($this->lng->txt("cont_invalid_new_module"),true);
494 $this->newModuleVersion();
495 }
496 }
497
501 function saveProperties()
502 {
503 //check if OfflineMode-Zip has to be created
504 $tmpOfflineMode= ilUtil::yn2tf($_POST["cobj_offline_mode"]);
505 if ($tmpOfflineMode == true) {
506 if ($this->object->getOfflineMode() == false) {
507 $this->object->zipLmForOfflineMode();
508 }
509 }
510 $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
511 $this->object->setOfflineMode($tmpOfflineMode);
512 $this->object->setOpenMode($_POST["open_mode"]);
513 $this->object->setWidth($_POST["width"]);
514 $this->object->setHeight($_POST["height"]);
515 $this->object->setAuto_last_visited(ilUtil::yn2tf($_POST["cobj_auto_last_visited"]));
516 $this->object->setAutoContinue(ilUtil::yn2tf($_POST["auto_continue"]));
517 $this->object->setMaxAttempt($_POST["max_attempt"]);
518 $this->object->setDefaultLessonMode($_POST["lesson_mode"]);
519 $this->object->setCreditMode($_POST["credit_mode"]);
520 $this->object->setAutoReview(ilUtil::yn2tf($_POST["auto_review"]));
521// $this->object->setAPIAdapterName($_POST["api_adapter"]);
522// $this->object->setAPIFunctionsPrefix($_POST["api_func_prefix"]);
523 $this->object->setSession(ilUtil::yn2tf($_POST["cobj_session"]));
524 $this->object->setInteractions(ilUtil::yn2tf($_POST["cobj_interactions"]));
525 $this->object->setObjectives(ilUtil::yn2tf($_POST["cobj_objectives"]));
526 $this->object->setTime_from_lms(ilUtil::yn2tf($_POST["cobj_time_from_lms"]));
527 $this->object->setCheck_values(ilUtil::yn2tf($_POST["cobj_check_values"]));
528 $this->object->setDebug(ilUtil::yn2tf($_POST["cobj_debug"]));
529 $this->object->update();
530 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
531 $this->ctrl->redirect($this, "properties");
532 }
533
537 protected function showTrackingItemsBySco()
538 {
539 global $ilTabs;
540
542 $ilTabs->setTabActive("cont_tracking_data");
543 $ilTabs->setSubTabActive("cont_tracking_bysco");
544
545 $reports = array('exportSelectedCore','exportSelectedInteractions','exportSelectedObjectives','exportSelectedRaw');//,'tracInteractionItem','tracInteractionUser','tracInteractionUserAnswers'
546 $scoSelected = "all";
547 if (isset($_GET["scoSelected"])) $scoSelected = ilUtil::stripSlashes($_GET["scoSelected"]);
548 if (isset($_POST["scoSelected"])) $scoSelected = ilUtil::stripSlashes($_POST["scoSelected"]);
549 $this->ctrl->setParameter($this,'scoSelected',$scoSelected);
550
551 $report = "choose";
552 if (isset($_GET["report"])) $report = ilUtil::stripSlashes($_GET["report"]);
553 if (isset($_POST["report"])) $report = ilUtil::stripSlashes($_POST["report"]);
554 $this->ctrl->setParameter($this,'report',$report);
555
556 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsPerScoFilterGUI.php';
557 $filter = new ilSCORMTrackingItemsPerScoFilterGUI($this, 'showTrackingItemsBySco');
558 $filter->parse($scoSelected,$report,$reports);
559 if($report == "choose") {
560 $this->tpl->setContent($filter->form->getHTML());
561 } else {
562 $scosSelected = array();
563 if ($scoSelected != "all") $scosSelected[] = $scoSelected;
564 else {
565 $scos=$this->object->getTrackedItems();
566 foreach($scos as $row)
567 {
568 $scosSelected[]=(int)$row->getId();
569 }
570 }
571 //with check for course ...
572 include_once "Services/Tracking/classes/class.ilTrQuery.php";
573 $a_users=ilTrQuery::getParticipantsForObject($this->ref_id);
574 // var_dump($this->object->getTrackedUsers(""));
575 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsTableGUI.php';
576 $tbl = new ilSCORMTrackingItemsTableGUI($this->object->getId(), $this, 'showTrackingItemsBySco', $a_users, $scosSelected, $report);
577 $this->tpl->setContent($filter->form->getHTML().$tbl->getHTML());
578 }
579 return true;
580 }
581
582
588 public function showTrackingItems()
589 {
590 global $ilTabs, $ilAccess;
591
592 $ilTabs->setTabActive('cont_tracking_data');
593
594 if($ilAccess->checkAccess("read_learning_progress", "", $_GET["ref_id"])) {
595
597 $ilTabs->setSubTabActive('cont_tracking_byuser');
598
599 $reports = array('exportSelectedSuccess','exportSelectedCore','exportSelectedInteractions','exportSelectedObjectives','exportSelectedRaw');
600
601 $userSelected = "all";
602 if (isset($_GET["userSelected"])) $userSelected = ilUtil::stripSlashes($_GET["userSelected"]);
603 if (isset($_POST["userSelected"])) $userSelected = ilUtil::stripSlashes($_POST["userSelected"]);
604 $this->ctrl->setParameter($this,'userSelected',$userSelected);
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.ilSCORMTrackingItemsPerUserFilterGUI.php';
612 $filter = new ilSCORMTrackingItemsPerUserFilterGUI($this, 'showTrackingItems');
613 $filter->parse($userSelected,$report,$reports);
614 if($report == "choose") {
615 $this->tpl->setContent($filter->form->getHTML());
616 } else {
617 $usersSelected = array();
618 if ($userSelected != "all") $usersSelected[] = $userSelected;
619 else {
620 include_once "Services/Tracking/classes/class.ilTrQuery.php";
621 $users=ilTrQuery::getParticipantsForObject($this->ref_id);
622 foreach($users as $user) {
623 if(ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') {
624 $usersSelected[] = $user;
625 }
626 }
627 }
628 $scosSelected = array();
629 $scos=$this->object->getTrackedItems();
630 foreach($scos as $row)
631 {
632 $scosSelected[]=(int)$row->getId();
633 }
634
635 //with check for course ...
636 // include_once "Services/Tracking/classes/class.ilTrQuery.php";
637 // $a_users=ilTrQuery::getParticipantsForObject($this->ref_id);
638 // var_dump($this->object->getTrackedUsers(""));
639 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsTableGUI.php';
640 $tbl = new ilSCORMTrackingItemsTableGUI($this->object->getId(), $this, 'showTrackingItems', $usersSelected, $scosSelected, $report);
641 $this->tpl->setContent($filter->form->getHTML().$tbl->getHTML());
642 }
643 }
644 else if($ilAccess->checkAccess("edit_learning_progress", "", $_GET["ref_id"])) {
645 $this->modifyTrackingItems();
646 }
647 return true;
648 }
649 protected function modifyTrackingItems()
650 {
651 global $ilAccess;
652 if($ilAccess->checkAccess("edit_learning_progress", "", $_GET["ref_id"])) {
653 include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
655 if(!$privacy->enabledSahsProtocolData())
656 {
657 $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
658 }
659
660 global $ilTabs, $ilToolbar;
661
662 include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
663 $ilToolbar->addButton(
664 $this->lng->txt('import'),
665 $this->ctrl->getLinkTarget($this, 'importForm')
666 );
667 $ilToolbar->addButton(
668 $this->lng->txt('cont_export_all'),
669 $this->ctrl->getLinkTarget($this, 'exportAll')
670 );
671
673 $ilTabs->setTabActive('cont_tracking_data');
674 $ilTabs->setSubTabActive('cont_tracking_modify');
675
676 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingUsersTableGUI.php';
677 $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
678 $tbl->parse();
679 $this->tpl->setContent($tbl->getHTML());
680 }
681 }
682
683
687 protected function applyUserTableFilter()
688 {
689 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingUsersTableGUI.php';
690 $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
691 $tbl->writeFilterToSession();
692 $tbl->resetOffset();
693 $this->modifyTrackingItems();
694 }
695
699 protected function resetUserTableFilter()
700 {
701 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingUsersTableGUI.php';
702 $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
703 $tbl->resetFilter();
704 $tbl->resetOffset();
705 $this->modifyTrackingItems();
706 }
707
712 {
713 if(!isset($_POST["user"]))
714 {
715 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
716 }
717
718 // display confirmation message
719 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
720 $cgui = new ilConfirmationGUI();
721 $cgui->setFormAction($this->ctrl->getFormAction($this));
722 $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
723 $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteTracking");
724 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDeleteTracking");
725
726 foreach($_POST["user"] as $id)
727 {
728 if (ilObject::_exists($id) && ilObject::_lookUpType($id)=="usr" )
729 {
730 $user = new ilObjUser($id);
731
732 $caption = ilUtil::getImageTagByType("sahs", $this->tpl->tplPath).
733 " ".$this->lng->txt("cont_tracking_data").
734 ": ".$user->getLastname().", ".$user->getFirstname();
735
736
737 $cgui->addItem("user[]", $id, $caption);
738 }
739 }
740
741 $this->tpl->setContent($cgui->getHTML());
742 }
743
748 {
749 ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
750 $this->ctrl->redirect($this, "modifyTrackingItems");
751 }
752
754 {
755 $this->object->deleteTrackingDataOfUsers($_POST["user"]);
756 $this->ctrl->redirect($this, "modifyTrackingItems");
757 }
758
762 function cancel()
763 {
764 ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
765 $this->ctrl->redirect($this, "properties");
766 }
767
771 protected function import()
772 {
773 $form = $this->initImportForm();
774 if($form->checkInput())
775 {
776 $source = $form->getInput('csv');
777 $error = $this->object->importTrackingData($source['tmp_name']);
778 switch($error)
779 {
780 case 0 :
781 ilUtil::sendInfo('Tracking data imported', true);
782 $this->ctrl->redirect($this, "showTrackingItems");
783 break;
784 case -1 :
785 ilUtil::sendInfo($this->lng->txt('err_check_input'));
786 $this->importForm();
787 break;
788 }
789 }
790 ilUtil::sendInfo($this->lng->txt('err_check_input'));
791 $form->setValuesByPost();
792 $this->importForm();
793 }
794
798 protected function importForm()
799 {
800 global $ilTabs;
801
802 $ilTabs->clearTargets();
803 $ilTabs->setBackTarget($this->lng->txt('back'),$this->ctrl->getLinkTarget($this,'showTrackingItems'));
804
805 $form = $this->initImportForm();
806 $this->tpl->setContent($form->getHTML());
807 }
808
812 protected function initImportForm()
813 {
814 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
815 $form = new ilPropertyFormGUI();
816 $form->setFormAction($this->ctrl->getFormAction($this));
817 $form->setTitle($this->lng->txt('cont_import_tracking'));
818 $form->addCommandButton('import', $this->lng->txt('import'));
819 $form->addCommandButton('showTrackingItems', $this->lng->txt('cancel'));
820
821 $csv = new ilFileInputGUI($this->lng->txt('select_file'),'csv');
822 $csv->setRequired(true);
823 $csv->setSuffixes(array('csv'));
824 $form->addItem($csv);
825
826 return $form;
827 }
828
832 protected function exportAll()
833 {
834 $this->object->exportSelected(1);
835 }
836
840 protected function exportSelectionUsers()
841 {
842 if(!count((array) $_POST['user']))
843 {
844 //ilUtil::sendFailure($this->lng->txt('select_one'),true);
845 ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
846 $this->ctrl->redirect($this,'modifyTrackingItems');
847 } else {
848 $this->object->exportSelected(0,$_POST["user"]);
849 }
850 }
851
852
854 {
855 if (!isset($_POST["user"])) {
856 ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
857 }
858 $this->object->decreaseAttemptsForUser($_POST["user"]);
859 $this->ctrl->redirect($this, "modifyTrackingItems");
860 }
861
862
866 protected function showTrackingItem()
867 {
868 global $ilTabs;
869
870 include_once "./Services/Table/classes/class.ilTableGUI.php";
871
872 $this->setSubTabs();
873 $ilTabs->setTabActive("cont_tracking_data");
874 $ilTabs->setSubTabActive("cont_tracking_byuser");
875
876 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsPerUserTableGUI.php';
877 $tbl = new ilSCORMTrackingItemsPerUserTableGUI($this->object->getId(), $this, 'showTrackingItem');
878 $tbl->setUserId((int) $_REQUEST['user_id']);
879 $tbl->parse();
880 $this->tpl->setContent($tbl->getHTML());
881 return true;
882 }
883
887 protected function showTrackingItemSco()
888 {
889 global $ilTabs;
890
891 include_once "./Services/Table/classes/class.ilTableGUI.php";
892
893 $this->setSubTabs();
894 $ilTabs->setTabActive("cont_tracking_data");
895 $ilTabs->setSubTabActive("cont_tracking_bysco");
896
897 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsScoTableGUI.php';
898 $tbl = new ilSCORMTrackingItemsScoTableGUI($this->object->getId(), $this, 'showTrackingItemSco');
899 $tbl->setScoId((int) $_GET['obj_id']);
900 $tbl->parse();
901 $this->tpl->setContent($tbl->getHTML());
902 return true;
903 }
904
908 protected function showTrackingItemPerUser()
909 {
910 global $ilTabs;
911
912 include_once "./Services/Table/classes/class.ilTableGUI.php";
913
914 $this->setSubTabs();
915 $ilTabs->setTabActive("cont_tracking_data");
916 $ilTabs->setSubTabActive("cont_tracking_byuser");
917
918 $this->ctrl->setParameter($this,'obj_id',(int) $_REQUEST['obj_id']);
919 $this->ctrl->setParameter($this,'user_id',(int) $_REQUEST['user_id']);
920
921 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemPerUserTableGUI.php';
922 $tbl = new ilSCORMTrackingItemPerUserTableGUI($this->object->getId(), $this, 'showTrackingItemPerUser');
923 $tbl->setUserId((int) $_REQUEST['user_id']);
924 $tbl->setScoId((int) $_REQUEST['obj_id']);
925 $tbl->parse();
926 $this->tpl->setContent($tbl->getHTML());
927 return true;
928 }
929
930 //setTabs
931 function setSubTabs()
932 {
933 global $lng, $ilTabs, $ilCtrl, $ilAccess;
934
935 if($ilAccess->checkAccess("read_learning_progress", "", $_GET["ref_id"])) {
936 $ilTabs->addSubTabTarget("cont_tracking_byuser",
937 $this->ctrl->getLinkTarget($this, "showTrackingItems"), array("edit", ""),
938 get_class($this));
939
940 $ilTabs->addSubTabTarget("cont_tracking_bysco",
941 $this->ctrl->getLinkTarget($this, "showTrackingItemsBySco"), array("edit", ""),
942 get_class($this));
943 }
944 if($ilAccess->checkAccess("edit_learning_progress", "", $_GET["ref_id"])) {
945 $ilTabs->addSubTabTarget("cont_tracking_modify",
946 $this->ctrl->getLinkTarget($this, "modifyTrackingItems"), array("edit", ""),
947 get_class($this));
948 }
949 }
950
951
957 protected function offlineModeManager()
958 {
959 global $rbacsystem, $tree, $tpl, $lng, $ilToolbar, $ilCtrl, $ilSetting;
960
961 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
962 if(!ilLearningProgressAccess::checkAccess($this->object->getRefId()))
963 {
964 $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
965 }
966
967 include_once './Modules/ScormAicc/classes/class.ilSCORMOfflineModeUsersTableGUI.php';
968 $tbl = new ilSCORMOfflineModeUsersTableGUI($this->object->getId(), $this, 'offlineModeManager');
969 $tbl->parse();
970 $this->tpl->setContent($tbl->getHTML());
971
972 }
976 protected function stopUserOfflineMode()
977 {
978 if(!count((array) $_POST['user']))
979 {
980 ilUtil::sendFailure($this->lng->txt('select_one'),true);
981 $this->ctrl->redirect($this,'offlineModeManager');
982 }
983 // display confirmation message
984 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
985 $cgui = new ilConfirmationGUI();
986 $cgui->setFormAction($this->ctrl->getFormAction($this));
987 $cgui->setHeaderText($this->lng->txt("info_stop_offline_mode_sure"));
988 $cgui->setCancel($this->lng->txt("cancel"), "cancelStopUserOfflineMode");
989 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedStopUserOfflineMode");
990 foreach($_POST["user"] as $id)
991 {
992 if (ilObject::_exists($id) && ilObject::_lookUpType($id)=="usr" )
993 {
994 $user = new ilObjUser($id);
995 $caption = ilUtil::getImageTagByType("sahs_offline", $this->tpl->tplPath).
996 " ".$this->lng->txt("stop_user_offline_mode_for_user").
997 ": ".$user->getLastname().", ".$user->getFirstname();
998 $cgui->addItem("user[]", $id, $caption);
999 }
1000 }
1001 $this->tpl->setContent($cgui->getHTML());
1002 }
1003
1005 {
1006 ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
1007 $this->ctrl->redirect($this, "offlineModeManager");
1008 }
1009
1011 {
1012
1013 include_once './Modules/ScormAicc/classes/class.ilSCORMOfflineMode.php';
1014 foreach($_POST["user"] as $id)
1015 {
1016 ilSCORMOfflineMode::stopOfflineModeForUser($this->object->getId(),$id);
1017 }
1018
1019 $this->offlineModeManager();
1020 }
1021
1022
1023}
1024// END class.ilObjSCORMLearningModule
1025?>
print $file
$_GET["client_id"]
This class represents a checkbox property in a property form.
Confirmation screen class.
This class represents a file property in a property form.
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.
_lookupSubType($a_obj_id)
lookup subtype id (scorm, aicc, hacp)
Class ilObjSCORMLearningModuleGUI.
offlineModeManager()
Manage offline mode for users @global ilTabs $ilTabs $global ilToolbar $ilToolbar.
exportAll()
Show export section for all users.
stopUserOfflineMode()
Stop offline mode for selected users.
exportSelectionUsers()
Export selection for selected users.
assignObject()
assign scorm object to scorm gui object
ilObjSCORMLearningModuleGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor.
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.
ilObjectGUI($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Constructor @access public.
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.
GUI class ilSCORMOfflineModeUsersTableGUI.
stopOfflineModeForUser($obj_id, $user_id)
Class ilSCORMTrackingItemsTableGUI.
This class represents a selection list 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.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:40
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($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
if(!is_array($argv)) $options