ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 
5 require_once "./Services/Object/classes/class.ilObjectGUI.php";
6 require_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php");
7 require_once("Services/User/classes/class.ilObjUser.php");
8 
9 require_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleGUI.php");
10 require_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  //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  // display mode (open)
155  // $options = array(
156  // "0" => $this->lng->txt("cont_open_normal"),
157  // "1" => $this->lng->txt("cont_open_iframe_max"),
158  // "2" => $this->lng->txt("cont_open_iframe_defined"),
159  // "5" => $this->lng->txt("cont_open_window_undefined"),
160  // "6" => $this->lng->txt("cont_open_window_defined")
161  // );
162  // $si = new ilSelectInputGUI($this->lng->txt("cont_open"), "open_mode");
163  // $si->setOptions($options);
164  // $si->setValue($this->object->getOpenMode());
165  // $this->form->addItem($si);
166 
167  // // width
168  // $ni = new ilNumberInputGUI($this->lng->txt("cont_width"), "width");
169  // $ni->setMaxLength(4);
170  // $ni->setSize(4);
171  // $ni->setValue($this->object->getWidth());
172  // $this->form->addItem($ni);
173 
174  // // height
175  // $ni = new ilNumberInputGUI($this->lng->txt("cont_height"), "height");
176  // $ni->setMaxLength(4);
177  // $ni->setSize(4);
178  // $ni->setValue($this->object->getHeight());
179  // $this->form->addItem($ni);
180  $radg = new ilRadioGroupInputGUI($lng->txt("cont_open"), "open_mode");
181  $op0 = new ilRadioOption($this->lng->txt("cont_open_normal"), "0");
182  $radg->addOption($op0);
183  $op1 = new ilRadioOption($this->lng->txt("cont_open_iframe"), "1");
184  $radg->addOption($op1);
185  $op2 = new ilRadioOption($this->lng->txt("cont_open_window"), "5");
186  $radg->addOption($op2);
187  $radg->setValue($this->object->getOpenMode()); //ACHTUNG: DATENBANK
188  // width
189  $ni = new ilNumberInputGUI($this->lng->txt("cont_width"), "width");
190  $ni->setMaxLength(4);
191  $ni->setSize(4);
192  //ACHTUNG: DATENBANKUPDATE
193  $ni->setValue($this->object->getWidth());
194  $op1->addSubItem($ni);
195  $op2->addSubItem($ni);
196  // height
197  $ni = new ilNumberInputGUI($this->lng->txt("cont_height"), "height");
198  $ni->setMaxLength(4);
199  $ni->setSize(4);
200  $ni->setValue($this->object->getHeight());
201  $ni->setInfo($this->lng->txt("cont_width_height_info"));
202  $op1->addSubItem($ni);
203  $op2->addSubItem($ni);
204  $this->form->addItem($radg);
205 
206  // auto navigation to last visited item
207  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_auto_last_visited"), "cobj_auto_last_visited");
208  $cb->setValue("y");
209  $cb->setChecked($this->object->getAuto_last_visited());
210  $cb->setInfo($this->lng->txt("cont_auto_last_visited_info"));
211  $this->form->addItem($cb);
212 
213  // auto continue
214  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sc_auto_continue"), "auto_continue");
215  $cb->setValue("y");
216  $cb->setChecked($this->object->getAutoContinue());
217  $this->form->addItem($cb);
218 
219  //
220  // scorm options
221  //
222  $sh = new ilFormSectionHeaderGUI();
223  $sh->setTitle($this->lng->txt("cont_scorm_options"));
224  $this->form->addItem($sh);
225 
226  // max attempts
227  // $ni = new ilNumberInputGUI($this->lng->txt("cont_sc_max_attempt"), "max_attempt");
228  // $ni->setMaxLength(3);
229  // $ni->setSize(3);
230  // $ni->setValue($this->object->getMaxAttempt());
231  // $this->form->addItem($ni);
232 
233  // lesson mode
234  $options = array("normal" => $this->lng->txt("cont_sc_less_mode_normal"),
235  "browse" => $this->lng->txt("cont_sc_less_mode_browse"));
236  $si = new ilSelectInputGUI($this->lng->txt("cont_def_lesson_mode"), "lesson_mode");
237  $si->setOptions($options);
238  $si->setValue($this->object->getDefaultLessonMode());
239  $this->form->addItem($si);
240 
241  // credit mode
242  $options = array("credit" => $this->lng->txt("cont_credit_on"),
243  "no_credit" => $this->lng->txt("cont_credit_off"));
244  $si = new ilSelectInputGUI($this->lng->txt("cont_credit_mode"), "credit_mode");
245  $si->setOptions($options);
246  $si->setValue($this->object->getCreditMode());
247  $si->setInfo($this->lng->txt("cont_credit_mode_info"));
248  $this->form->addItem($si);
249 
250  // set lesson mode review when completed
251  $options = array(
252  "n" => $this->lng->txt("cont_sc_auto_review_no"),
253 // "r" => $this->lng->txt("cont_sc_auto_review_completed_not_failed_or_passed"),
254 // "p" => $this->lng->txt("cont_sc_auto_review_passed"),
255 // "q" => $this->lng->txt("cont_sc_auto_review_passed_or_failed"),
256 // "c" => $this->lng->txt("cont_sc_auto_review_completed"),
257 // "d" => $this->lng->txt("cont_sc_auto_review_completed_and_passed"),
258  "y" => $this->lng->txt("cont_sc_auto_review_completed_or_passed"),
259  );
260  $si = new ilSelectInputGUI($this->lng->txt("cont_sc_auto_review_2004"), "auto_review");
261  $si->setOptions($options);
262  $si->setValue($this->object->getAutoReviewChar());
263  // $si->setInfo($this->lng->txt("cont_sc_auto_review_info_12"));
264  $this->form->addItem($si);
265 
266  // mastery_score
267  if ($this->object->getMasteryScoreValues() != "") {
268  $ni = new ilNumberInputGUI($this->lng->txt("cont_mastery_score_12"), "mastery_score");
269  $ni->setMaxLength(3);
270  $ni->setSize(3);
271  $ni->setValue($this->object->getMasteryScore());
272  $ni->setInfo($this->lng->txt("cont_mastery_score_12_info").$this->object->getMasteryScoreValues());
273  $this->form->addItem($ni);
274  }
275 
276  //
277  // rte settings
278  //
279  $sh = new ilFormSectionHeaderGUI();
280  $sh->setTitle($this->lng->txt("cont_rte_settings"));
281  $this->form->addItem($sh);
282 
283  // unlimited session timeout
284  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sc_usession"), "cobj_session");
285  $cb->setValue("y");
286  $cb->setChecked($this->object->getSession());
287  $cb->setInfo($this->lng->txt("cont_sc_usession_info"));
288  $this->form->addItem($cb);
289 
290  // storage of interactions
291  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_interactions"), "cobj_interactions");
292  $cb->setValue("y");
293  $cb->setChecked($this->object->getInteractions());
294  $cb->setInfo($this->lng->txt("cont_interactions_info_12"));
295  $this->form->addItem($cb);
296 
297  // objectives
298  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_objectives"), "cobj_objectives");
299  $cb->setValue("y");
300  $cb->setChecked($this->object->getObjectives());
301  $cb->setInfo($this->lng->txt("cont_objectives_info"));
302  $this->form->addItem($cb);
303 
304  // time from lms
305  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_time_from_lms"), "cobj_time_from_lms");
306  $cb->setValue("y");
307  $cb->setChecked($this->object->getTime_from_lms());
308  $cb->setInfo($this->lng->txt("cont_time_from_lms_info"));
309  $this->form->addItem($cb);
310 
311  // check values
312  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_check_values"), "cobj_check_values");
313  $cb->setValue("y");
314  $cb->setChecked($this->object->getCheck_values());
315  $cb->setInfo($this->lng->txt("cont_check_values_info"));
316  $this->form->addItem($cb);
317  // api adapter name
318  // $this->tpl->setVariable("TXT_API_ADAPTER", $this->lng->txt("cont_api_adapter"));
319  // $this->tpl->setVariable("VAL_API_ADAPTER", $this->object->getAPIAdapterName());
320  // api functions prefix
321  // $this->tpl->setVariable("TXT_API_PREFIX", $this->lng->txt("cont_api_func_prefix"));
322  // $this->tpl->setVariable("VAL_API_PREFIX", $this->object->getAPIFunctionsPrefix());
323 
324  //
325  // debugging
326  //
327  $sh = new ilFormSectionHeaderGUI();
328  $sh->setTitle($this->lng->txt("cont_debugging"));
329  $this->form->addItem($sh);
330 
331  // test tool
332  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_debug"), "cobj_debug");
333  $cb->setValue("y");
334  $cb->setChecked($this->object->getDebug());
335  if ($this->object->getDebugActivated() == false)
336  {
337  $cb->setDisabled(true);
338  $cb->setInfo($this->lng->txt("cont_debug_deactivated"));
339  }
340  else
341  {
342  $cb->setInfo($this->lng->txt("cont_debug_deactivate"));
343  }
344  $this->form->addItem($cb);
345  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
346 
347  $tpl->setContent($this->form->getHTML());
348 
349  }
350 
354  function newModuleVersion()
355  {
356  global $ilTabs;
358  $ilTabs->setSubTabActive('cont_sc_new_version');
359 
362 
363  // display import form
364  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scorm_new_version_import.html", "Modules/ScormAicc");
365 
366  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_lm.svg'));
367  $this->tpl->setVariable("ALT_IMG", $this->lng->txt("obj_sahs"));
368 
369  $this->ctrl->setParameter($this, "new_type", "sahs");
370  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
371 
372  $this->tpl->setVariable("BTN_NAME", "newModuleVersionUpload");
373  $this->tpl->setVariable("TARGET", ' target="'.
374  ilFrameTargetInfo::_getFrame("MainContent").'" ');
375 
376  $this->tpl->setVariable("TXT_SELECT_LMTYPE", $this->lng->txt("type"));
377 
378  if ($type == "scorm2004") {
379  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("lm_type_scorm2004"));
380  } else {
381  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("lm_type_scorm"));
382  }
383 
384  include_once 'Services/FileSystem/classes/class.ilUploadFiles.php';
386  {
388  foreach($files as $file)
389  {
390  $file = htmlspecialchars($file, ENT_QUOTES, "utf-8");
391  $this->tpl->setCurrentBlock("option_uploaded_file");
392  $this->tpl->setVariable("UPLOADED_FILENAME", $file);
393  $this->tpl->setVariable("TXT_UPLOADED_FILENAME", $file);
394  $this->tpl->parseCurrentBlock();
395  }
396  $this->tpl->setCurrentBlock("select_uploaded_file");
397  $this->tpl->setVariable("TXT_SELECT_FROM_UPLOAD_DIR", $this->lng->txt("cont_select_from_upload_dir"));
398  $this->tpl->setVariable("TXT_UPLOADED_FILE", $this->lng->txt("cont_uploaded_file"));
399  $this->tpl->parseCurrentBlock();
400  }
401 
402  $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
403  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
404  $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_sahs"));
405  $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
406 
407  // gives out the limit as a little notice
408  $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." ".$this->getMaxFileSize());
409  }
410 
411 
412  function getMaxFileSize()
413  {
414  // get the value for the maximal uploadable filesize from the php.ini (if available)
415  $umf=get_cfg_var("upload_max_filesize");
416  // get the value for the maximal post data from the php.ini (if available)
417  $pms=get_cfg_var("post_max_size");
418 
419  //convert from short-string representation to "real" bytes
420  $multiplier_a=array("K"=>1024, "M"=>1024*1024, "G"=>1024*1024*1024);
421 
422  $umf_parts=preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
423  $pms_parts=preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
424 
425  if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
426  if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
427 
428  // use the smaller one as limit
429  $max_filesize=min($umf, $pms);
430 
431  if (!$max_filesize) $max_filesize=max($umf, $pms);
432 
433  //format for display in mega-bytes
434  return $max_filesize=sprintf("%.1f MB",$max_filesize/1024/1024);
435  }
436 
437 
439  {
440  global $_FILES, $rbacsystem;
441 
442  $unzip = PATH_TO_UNZIP;
443  $tocheck = "imsmanifest.xml";
444 
445  include_once 'Services/FileSystem/classes/class.ilUploadFiles.php';
446 
447  // check create permission before because the uploaded file will be copied
448  if (!$rbacsystem->checkAccess("write", $_GET["ref_id"]))
449  {
450  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
451  }
452  elseif ($_FILES["scormfile"]["name"])
453  {
454  // check if file was uploaded
455  $source = $_FILES["scormfile"]["tmp_name"];
456  if (($source == 'none') || (!$source))
457  {
458  ilUtil::sendInfo($this->lng->txt("upload_error_file_not_found"),true);
459  $this->newModuleVersion();
460  return;
461  }
462  }
463  elseif ($_POST["uploaded_file"])
464  {
465  // check if the file is in the ftp directory and readable
466  if (!ilUploadFiles::_checkUploadFile($_POST["uploaded_file"]))
467  {
468  $this->ilias->raiseError($this->lng->txt("upload_error_file_not_found"),$this->ilias->error_obj->MESSAGE);
469  }
470  // copy the uploaded file to the client web dir to analyze the imsmanifest
471  // the copy will be moved to the lm directory or deleted
472  $source = CLIENT_WEB_DIR . "/" . $_POST["uploaded_file"];
473  ilUploadFiles::_copyUploadFile($_POST["uploaded_file"], $source);
474  $source_is_copy = true;
475  }
476  else
477  {
478  ilUtil::sendInfo($this->lng->txt("upload_error_file_not_found"),true);
479  $this->newModuleVersion();
480  return;
481  }
482  // fim.
483 
484  //unzip the imsmanifest-file from new uploaded file
485  $pathinfo = pathinfo($source);
486  $dir = $pathinfo["dirname"];
487  $file = $pathinfo["basename"];
488  $cdir = getcwd();
489  chdir($dir);
490 
491  //we need more flexible unzip here than ILIAS standard classes allow
492  $unzipcmd = $unzip." -o ".ilUtil::escapeShellArg($source)." ".$tocheck;
493  exec($unzipcmd);
494  chdir($cdir);
495  $tmp_file = $dir."/".$_GET["ref_id"].".".$tocheck;
496  require_once('./Services/Utilities/classes/class.ilFileUtils.php');
497  ilFileUtils::rename($dir."/".$tocheck,$tmp_file);
498  $new_manifest = file_get_contents($tmp_file);
499 
500  //remove temp file
501  unlink($tmp_file);
502 
503  //get old manifest file
504  $old_manifest = file_get_contents($this->object->getDataDirectory()."/".$tocheck);
505 
506  //reload fixed version of file
507  $check ='/xmlns="http:\/\/www.imsglobal.org\/xsd\/imscp_v1p1"/';
508  $replace="xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
509  $reload_manifest = preg_replace($check, $replace, $new_manifest);
510 
511  //do testing for converted versions as well as earlier ILIAS version messed up utf8 conversion
512  if (strcmp($new_manifest,$old_manifest) == 0 || strcmp(utf8_encode($new_manifest),$old_manifest) == 0 ||
513  strcmp ($reload_manifest, $old_manifest) == 0 || strcmp(utf8_encode($reload_manifest),$old_manifest) == 0 ){
514 
515  //get exisiting module version
516  $module_version = $this->object->getModuleVersion();
517 
518  if ($_FILES["scormfile"]["name"])
519  {
520  //build targetdir in lm_data
521  $file_path = $this->object->getDataDirectory()."/".$_FILES["scormfile"]["name"].".".$module_version;
522  $file_path = str_replace(".zip.".$module_version, ".".$module_version.".zip",$file_path);
523  //move to data directory and add subfix for versioning
524  ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"],$_FILES["scormfile"]["name"], $file_path);
525  }
526  else
527  {
528  //build targetdir in lm_data
529  $file_path = $this->object->getDataDirectory()."/".$_POST["uploaded_file"].".".$module_version;
530  $file_path = str_replace(".zip.".$module_version, ".".$module_version.".zip",$file_path);
531  // move the already copied file to the lm_data directory
532  require_once('./Services/Utilities/classes/class.ilFileUtils.php');
533  ilFileUtils::rename($source, $file_path);
534  }
535 
536  //unzip and replace old extracted files
537  ilUtil::unzip($file_path, true);
538  ilUtil::renameExecutables($this->object->getDataDirectory()); //(security)
539 
540  //increase module version
541  $this->object->setModuleVersion($module_version+1);
542  $this->object->update();
543 
544  //redirect to properties and display success
545  ilUtil::sendInfo( $this->lng->txt("cont_new_module_added"), true);
546  ilUtil::redirect("ilias.php?baseClass=ilSAHSEditGUI&ref_id=".$_GET["ref_id"]);
547  exit;
548  }
549  else
550  {
551  if ($source_is_copy)
552  {
553  unlink($source);
554  }
555 
556  ilUtil::sendInfo($this->lng->txt("cont_invalid_new_module"),true);
557  $this->newModuleVersion();
558  }
559  }
560 
564  function saveProperties()
565  {
566  $this->object->setTitle($_POST["Fobject_title"]);
567  $this->object->setDescription($_POST["Fobject_description"]);
568 
569  //check if OfflineMode-Zip has to be created
570  $tmpOfflineMode= ilUtil::yn2tf($_POST["cobj_offline_mode"]);
571  if ($tmpOfflineMode == true) {
572  if ($this->object->getOfflineMode() == false) {
573  $this->object->zipLmForOfflineMode();
574  }
575  }
576  if (isset($_POST["mastery_score"])){
577  $this->object->setMasteryScore($_POST["mastery_score"]);
578  // $this->object->updateMasteryScoreValues();
579  }
580  $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
581  $this->object->setOfflineMode($tmpOfflineMode);
582  $this->object->setOpenMode($_POST["open_mode"]);
583  $this->object->setWidth($_POST["width"]);
584  $this->object->setHeight($_POST["height"]);
585  $this->object->setAuto_last_visited(ilUtil::yn2tf($_POST["cobj_auto_last_visited"]));
586  $this->object->setAutoContinue(ilUtil::yn2tf($_POST["auto_continue"]));
587  $this->object->setMaxAttempt($_POST["max_attempt"]);
588  $this->object->setDefaultLessonMode($_POST["lesson_mode"]);
589  $this->object->setCreditMode($_POST["credit_mode"]);
590  $this->object->setAutoReview(ilUtil::yn2tf($_POST["auto_review"]));
591 // $this->object->setAPIAdapterName($_POST["api_adapter"]);
592 // $this->object->setAPIFunctionsPrefix($_POST["api_func_prefix"]);
593  $this->object->setSession(ilUtil::yn2tf($_POST["cobj_session"]));
594  $this->object->setInteractions(ilUtil::yn2tf($_POST["cobj_interactions"]));
595  $this->object->setObjectives(ilUtil::yn2tf($_POST["cobj_objectives"]));
596  $this->object->setTime_from_lms(ilUtil::yn2tf($_POST["cobj_time_from_lms"]));
597  $this->object->setCheck_values(ilUtil::yn2tf($_POST["cobj_check_values"]));
598  $this->object->setDebug(ilUtil::yn2tf($_POST["cobj_debug"]));
599  $this->object->update();
600  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
601  $this->ctrl->redirect($this, "properties");
602  }
603 
607  protected function showTrackingItemsBySco()
608  {
609  global $ilTabs;
610 
612  $ilTabs->setTabActive("cont_tracking_data");
613  $ilTabs->setSubTabActive("cont_tracking_bysco");
614 
615  $reports = array('exportSelectedCore','exportSelectedInteractions','exportSelectedObjectives','exportSelectedRaw');//,'tracInteractionItem','tracInteractionUser','tracInteractionUserAnswers'
616  $scoSelected = "all";
617  if (isset($_GET["scoSelected"])) $scoSelected = ilUtil::stripSlashes($_GET["scoSelected"]);
618  if (isset($_POST["scoSelected"])) $scoSelected = ilUtil::stripSlashes($_POST["scoSelected"]);
619  $this->ctrl->setParameter($this,'scoSelected',$scoSelected);
620 
621  $report = "choose";
622  if (isset($_GET["report"])) $report = ilUtil::stripSlashes($_GET["report"]);
623  if (isset($_POST["report"])) $report = ilUtil::stripSlashes($_POST["report"]);
624  $this->ctrl->setParameter($this,'report',$report);
625 
626  include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsPerScoFilterGUI.php';
627  $filter = new ilSCORMTrackingItemsPerScoFilterGUI($this, 'showTrackingItemsBySco');
628  $filter->parse($scoSelected,$report,$reports);
629  if($report == "choose") {
630  $this->tpl->setContent($filter->form->getHTML());
631  } else {
632  $scosSelected = array();
633  if ($scoSelected != "all") $scosSelected[] = $scoSelected;
634  else {
635  $scos=$this->object->getTrackedItems();
636  foreach($scos as $row)
637  {
638  $scosSelected[]=(int)$row->getId();
639  }
640  }
641  //with check for course ...
642  include_once "Services/Tracking/classes/class.ilTrQuery.php";
643  $a_users=ilTrQuery::getParticipantsForObject($this->ref_id);
644  // var_dump($this->object->getTrackedUsers(""));
645  include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsTableGUI.php';
646  $tbl = new ilSCORMTrackingItemsTableGUI($this->object->getId(), $this, 'showTrackingItemsBySco', $a_users, $scosSelected, $report);
647  $this->tpl->setContent($filter->form->getHTML().$tbl->getHTML());
648  }
649  return true;
650  }
651 
652 
658  public function showTrackingItems()
659  {
660  global $ilTabs, $ilAccess;
661 
662  $ilTabs->setTabActive('cont_tracking_data');
663 
664  if($ilAccess->checkAccess("read_learning_progress", "", $_GET["ref_id"])) {
665 
667  $ilTabs->setSubTabActive('cont_tracking_byuser');
668 
669  $reports = array('exportSelectedSuccess','exportSelectedCore','exportSelectedInteractions','exportSelectedObjectives','exportSelectedRaw');
670 
671  $userSelected = "all";
672  if (isset($_GET["userSelected"])) $userSelected = ilUtil::stripSlashes($_GET["userSelected"]);
673  if (isset($_POST["userSelected"])) $userSelected = ilUtil::stripSlashes($_POST["userSelected"]);
674  $this->ctrl->setParameter($this,'userSelected',$userSelected);
675 
676  $report = "choose";
677  if (isset($_GET["report"])) $report = ilUtil::stripSlashes($_GET["report"]);
678  if (isset($_POST["report"])) $report = ilUtil::stripSlashes($_POST["report"]);
679  $this->ctrl->setParameter($this,'report',$report);
680 
681  include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsPerUserFilterGUI.php';
682  $filter = new ilSCORMTrackingItemsPerUserFilterGUI($this, 'showTrackingItems');
683  $filter->parse($userSelected,$report,$reports);
684  if($report == "choose") {
685  $this->tpl->setContent($filter->form->getHTML());
686  } else {
687  $usersSelected = array();
688  if ($userSelected != "all") $usersSelected[] = $userSelected;
689  else {
690  include_once "Services/Tracking/classes/class.ilTrQuery.php";
691  $users=ilTrQuery::getParticipantsForObject($this->ref_id);
692  foreach($users as $user) {
693  if(ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') {
694  $usersSelected[] = $user;
695  }
696  }
697  }
698  $scosSelected = array();
699  $scos=$this->object->getTrackedItems();
700  foreach($scos as $row)
701  {
702  $scosSelected[]=(int)$row->getId();
703  }
704 
705  //with check for course ...
706  // include_once "Services/Tracking/classes/class.ilTrQuery.php";
707  // $a_users=ilTrQuery::getParticipantsForObject($this->ref_id);
708  // var_dump($this->object->getTrackedUsers(""));
709  include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsTableGUI.php';
710  $tbl = new ilSCORMTrackingItemsTableGUI($this->object->getId(), $this, 'showTrackingItems', $usersSelected, $scosSelected, $report);
711  $this->tpl->setContent($filter->form->getHTML().$tbl->getHTML());
712  }
713  }
714  else if($ilAccess->checkAccess("edit_learning_progress", "", $_GET["ref_id"])) {
715  $this->modifyTrackingItems();
716  }
717  return true;
718  }
719  protected function modifyTrackingItems()
720  {
721  global $ilAccess;
722  if($ilAccess->checkAccess("edit_learning_progress", "", $_GET["ref_id"])) {
723  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
724  $privacy = ilPrivacySettings::_getInstance();
725  if(!$privacy->enabledSahsProtocolData())
726  {
727  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
728  }
729 
730  global $ilTabs, $ilToolbar;
731 
732  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
733  $ilToolbar->addButton(
734  $this->lng->txt('import'),
735  $this->ctrl->getLinkTarget($this, 'importForm')
736  );
737  $ilToolbar->addButton(
738  $this->lng->txt('cont_export_all'),
739  $this->ctrl->getLinkTarget($this, 'exportAll')
740  );
741 
743  $ilTabs->setTabActive('cont_tracking_data');
744  $ilTabs->setSubTabActive('cont_tracking_modify');
745 
746  include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingUsersTableGUI.php';
747  $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
748  $tbl->parse();
749  $this->tpl->setContent($tbl->getHTML());
750  }
751  }
752 
753 
757  protected function applyUserTableFilter()
758  {
759  include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingUsersTableGUI.php';
760  $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
761  $tbl->writeFilterToSession();
762  $tbl->resetOffset();
763  $this->modifyTrackingItems();
764  }
765 
769  protected function resetUserTableFilter()
770  {
771  include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingUsersTableGUI.php';
772  $tbl = new ilSCORMTrackingUsersTableGUI($this->object->getId(), $this, 'modifytrackingItems');
773  $tbl->resetFilter();
774  $tbl->resetOffset();
775  $this->modifyTrackingItems();
776  }
777 
782  {
783  if(!isset($_POST["user"]))
784  {
785  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
786  }
787 
788  // display confirmation message
789  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
790  $cgui = new ilConfirmationGUI();
791  $cgui->setFormAction($this->ctrl->getFormAction($this));
792  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
793  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteTracking");
794  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDeleteTracking");
795 
796  foreach($_POST["user"] as $id)
797  {
798  if (ilObject::_exists($id) && ilObject::_lookUpType($id)=="usr" )
799  {
800  $user = new ilObjUser($id);
801 
802  $caption = ilUtil::getImageTagByType("sahs", $this->tpl->tplPath).
803  " ".$this->lng->txt("cont_tracking_data").
804  ": ".$user->getLastname().", ".$user->getFirstname();
805 
806 
807  $cgui->addItem("user[]", $id, $caption);
808  }
809  }
810 
811  $this->tpl->setContent($cgui->getHTML());
812  }
813 
818  {
819  ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
820  $this->ctrl->redirect($this, "modifyTrackingItems");
821  }
822 
824  {
825  $this->object->deleteTrackingDataOfUsers($_POST["user"]);
826  $this->ctrl->redirect($this, "modifyTrackingItems");
827  }
828 
832  function cancel()
833  {
834  ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
835  $this->ctrl->redirect($this, "properties");
836  }
837 
841  protected function import()
842  {
843  $form = $this->initImportForm();
844  if($form->checkInput())
845  {
846  $source = $form->getInput('csv');
847  $error = $this->object->importTrackingData($source['tmp_name']);
848  switch($error)
849  {
850  case 0 :
851  ilUtil::sendInfo('Tracking data imported', true);
852  $this->ctrl->redirect($this, "showTrackingItems");
853  break;
854  case -1 :
855  ilUtil::sendInfo($this->lng->txt('err_check_input'));
856  $this->importForm();
857  break;
858  }
859  }
860  ilUtil::sendInfo($this->lng->txt('err_check_input'));
861  $form->setValuesByPost();
862  $this->importForm();
863  }
864 
868  protected function importForm()
869  {
870  global $ilTabs;
871 
872  $ilTabs->clearTargets();
873  $ilTabs->setBackTarget($this->lng->txt('back'),$this->ctrl->getLinkTarget($this,'showTrackingItems'));
874 
875  $form = $this->initImportForm();
876  $this->tpl->setContent($form->getHTML());
877  }
878 
882  protected function initImportForm()
883  {
884  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
885  $form = new ilPropertyFormGUI();
886  $form->setFormAction($this->ctrl->getFormAction($this));
887  $form->setTitle($this->lng->txt('cont_import_tracking'));
888  $form->addCommandButton('import', $this->lng->txt('import'));
889  $form->addCommandButton('showTrackingItems', $this->lng->txt('cancel'));
890 
891  $csv = new ilFileInputGUI($this->lng->txt('select_file'),'csv');
892  $csv->setRequired(true);
893  $csv->setSuffixes(array('csv'));
894  $form->addItem($csv);
895 
896  return $form;
897  }
898 
902  protected function exportAll()
903  {
904  $this->object->exportSelected(1);
905  }
906 
910  protected function exportSelectionUsers()
911  {
912  if(!count((array) $_POST['user']))
913  {
914  //ilUtil::sendFailure($this->lng->txt('select_one'),true);
915  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
916  $this->ctrl->redirect($this,'modifyTrackingItems');
917  } else {
918  $this->object->exportSelected(0,$_POST["user"]);
919  }
920  }
921 
922 
923  function decreaseAttempts()
924  {
925  if (!isset($_POST["user"])) {
926  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
927  }
928  $this->object->decreaseAttemptsForUser($_POST["user"]);
929  $this->ctrl->redirect($this, "modifyTrackingItems");
930  }
931 
932 
936  protected function showTrackingItem()
937  {
938  global $ilTabs;
939 
940  include_once "./Services/Table/classes/class.ilTableGUI.php";
941 
942  $this->setSubTabs();
943  $ilTabs->setTabActive("cont_tracking_data");
944  $ilTabs->setSubTabActive("cont_tracking_byuser");
945 
946  include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsPerUserTableGUI.php';
947  $tbl = new ilSCORMTrackingItemsPerUserTableGUI($this->object->getId(), $this, 'showTrackingItem');
948  $tbl->setUserId((int) $_REQUEST['user_id']);
949  $tbl->parse();
950  $this->tpl->setContent($tbl->getHTML());
951  return true;
952  }
953 
957  protected function showTrackingItemSco()
958  {
959  global $ilTabs;
960 
961  include_once "./Services/Table/classes/class.ilTableGUI.php";
962 
963  $this->setSubTabs();
964  $ilTabs->setTabActive("cont_tracking_data");
965  $ilTabs->setSubTabActive("cont_tracking_bysco");
966 
967  include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsScoTableGUI.php';
968  $tbl = new ilSCORMTrackingItemsScoTableGUI($this->object->getId(), $this, 'showTrackingItemSco');
969  $tbl->setScoId((int) $_GET['obj_id']);
970  $tbl->parse();
971  $this->tpl->setContent($tbl->getHTML());
972  return true;
973  }
974 
978  protected function showTrackingItemPerUser()
979  {
980  global $ilTabs;
981 
982  include_once "./Services/Table/classes/class.ilTableGUI.php";
983 
984  $this->setSubTabs();
985  $ilTabs->setTabActive("cont_tracking_data");
986  $ilTabs->setSubTabActive("cont_tracking_byuser");
987 
988  $this->ctrl->setParameter($this,'obj_id',(int) $_REQUEST['obj_id']);
989  $this->ctrl->setParameter($this,'user_id',(int) $_REQUEST['user_id']);
990 
991  include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemPerUserTableGUI.php';
992  $tbl = new ilSCORMTrackingItemPerUserTableGUI($this->object->getId(), $this, 'showTrackingItemPerUser');
993  $tbl->setUserId((int) $_REQUEST['user_id']);
994  $tbl->setScoId((int) $_REQUEST['obj_id']);
995  $tbl->parse();
996  $this->tpl->setContent($tbl->getHTML());
997  return true;
998  }
999 
1000  //setTabs
1001  function setSubTabs()
1002  {
1003  global $lng, $ilTabs, $ilCtrl, $ilAccess;
1004 
1005  if($ilAccess->checkAccess("read_learning_progress", "", $_GET["ref_id"])) {
1006  $ilTabs->addSubTabTarget("cont_tracking_byuser",
1007  $this->ctrl->getLinkTarget($this, "showTrackingItems"), array("edit", ""),
1008  get_class($this));
1009 
1010  $ilTabs->addSubTabTarget("cont_tracking_bysco",
1011  $this->ctrl->getLinkTarget($this, "showTrackingItemsBySco"), array("edit", ""),
1012  get_class($this));
1013  }
1014  if($ilAccess->checkAccess("edit_learning_progress", "", $_GET["ref_id"])) {
1015  $ilTabs->addSubTabTarget("cont_tracking_modify",
1016  $this->ctrl->getLinkTarget($this, "modifyTrackingItems"), array("edit", ""),
1017  get_class($this));
1018  }
1019  }
1020 
1021 
1027  protected function offlineModeManager()
1028  {
1029  global $rbacsystem, $tree, $tpl, $lng, $ilToolbar, $ilCtrl, $ilSetting;
1030 
1031  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
1032  if(!ilLearningProgressAccess::checkAccess($this->object->getRefId()))
1033  {
1034  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
1035  }
1036 
1037  include_once './Modules/ScormAicc/classes/class.ilSCORMOfflineModeUsersTableGUI.php';
1038  $tbl = new ilSCORMOfflineModeUsersTableGUI($this->object->getId(), $this, 'offlineModeManager');
1039  $tbl->parse();
1040  $this->tpl->setContent($tbl->getHTML());
1041 
1042  }
1046  protected function stopUserOfflineMode()
1047  {
1048  if(!count((array) $_POST['user']))
1049  {
1050  ilUtil::sendFailure($this->lng->txt('select_one'),true);
1051  $this->ctrl->redirect($this,'offlineModeManager');
1052  }
1053  // display confirmation message
1054  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1055  $cgui = new ilConfirmationGUI();
1056  $cgui->setFormAction($this->ctrl->getFormAction($this));
1057  $cgui->setHeaderText($this->lng->txt("info_stop_offline_mode_sure"));
1058  $cgui->setCancel($this->lng->txt("cancel"), "cancelStopUserOfflineMode");
1059  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedStopUserOfflineMode");
1060  foreach($_POST["user"] as $id)
1061  {
1062  if (ilObject::_exists($id) && ilObject::_lookUpType($id)=="usr" )
1063  {
1064  $user = new ilObjUser($id);
1065  $caption = ilUtil::getImageTagByType("sahs_offline", $this->tpl->tplPath).
1066  " ".$this->lng->txt("stop_user_offline_mode_for_user").
1067  ": ".$user->getLastname().", ".$user->getFirstname();
1068  $cgui->addItem("user[]", $id, $caption);
1069  }
1070  }
1071  $this->tpl->setContent($cgui->getHTML());
1072  }
1073 
1075  {
1076  ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
1077  $this->ctrl->redirect($this, "offlineModeManager");
1078  }
1079 
1081  {
1082 
1083  include_once './Modules/ScormAicc/classes/class.ilSCORMOfflineMode.php';
1084  foreach($_POST["user"] as $id)
1085  {
1086  ilSCORMOfflineMode::stopOfflineModeForUser($this->object->getId(),$id);
1087  }
1088 
1089  $this->offlineModeManager();
1090  }
1091 
1092 
1093 }
1094 // END class.ilObjSCORMLearningModule
1095 ?>
Class ilSCORMTrackingItemsTableGUI.
This class represents an option in a radio group.
print $file
showTrackingItems()
Show tracking table ilTabs $ilTabs $global ilToolbar $ilToolbar.
Class ilObjSCORMLearningModuleGUI.
exportAll()
Show export section for all users.
exit
Definition: login.php:54
$_POST['username']
Definition: cron.php:12
cancelDeleteTracking()
cancel deletion of export files
This class represents a selection list property in a property form.
This class represents a property form user interface.
SCORM/AICC/HACP Learning Modules.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
$_GET["client_id"]
$tbl
Definition: example_048.php:81
This class represents a section header in a property form.
This class represents a file property in a property form.
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...
assignObject()
assign scorm object to scorm gui object
setValue($a_value)
Set Value.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
This class represents a checkbox property in a property form.
ilObjectGUI($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Constructor public.
static _getUploadDirectory()
Get the directory with uploaded files.
static _getUploadFiles()
Get a list of readable files in the upload directory.
stopUserOfflineMode()
Stop offline mode for selected users.
static _lookupObjectId($a_ref_id)
lookup object id
global $ilCtrl
Definition: ilias.php:18
exportSelectionUsers()
Export selection for selected users.
static rename($a_source, $a_target)
Rename a file.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
deleteTrackingForUser()
display deletion confirmation screen
This class represents a property in a property form.
setValue($a_value)
Set Value.
if(!is_array($argv)) $options
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a number property in a property form.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
setValue($a_value)
Set Value.
showTrackingItemSco()
show tracking data of item
This class represents a text property in a property form.
_lookupSubType($a_obj_id)
lookup subtype id (scorm, aicc, hacp)
redirection script todo: (a better solution should control the processing via a xml file) ...
setMaxLength($a_maxlength)
Set Max Length.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setOptions($a_options)
Set Options.
offlineModeManager()
Manage offline mode for users ilTabs $ilTabs $global ilToolbar $ilToolbar.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
newModuleVersion()
upload new version of module
ilObjSCORMLearningModuleGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor.
GUI class ilSCORMOfflineModeUsersTableGUI.
setMaxLength($a_maxlength)
Set Max Length.
stopOfflineModeForUser($obj_id, $user_id)
static _getFrame($a_class, $a_type='')
Get content frame name.
static getParticipantsForObject($a_ref_id)
Get participant ids for given object.
This class represents a non editable value in a property form.
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
global $ilSetting
Definition: privfeed.php:40
static escapeShellArg($a_arg)
This class represents a text area property in a property form.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
static _getInstance()
Get instance of ilPrivacySettings.
static _checkUploadFile($a_file)
Check if a file exists in the upload directory and is readable.
static yn2tf($a_yn)
convert "y"/"n" to true/false
showTrackingItem()
show tracking data of item
static redirect($a_script)
http redirect to other script
static _copyUploadFile($a_file, $a_target, $a_raise_errors=true)
copy an uploaded file to the target directory (including virus check)
Class ilObjSCORMLearningModule.
setRequired($a_required)
Set Required.
showTrackingItemPerUser()
show tracking data of item per user
cancel()
overwrite..jump back to trackingdata not parent
Confirmation screen class.