ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjSCORM2004LearningModuleGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once("./Modules/ScormAicc/classes/class.ilObjSCORMLearningModuleGUI.php");
5 require_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
6 require_once("./Modules/Scorm2004/classes/class.ilSCORM2004Export.php");
7 include_once("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
8 include_once("./Services/Style/classes/class.ilPageLayout.php");
9 
24 {
30  function ilObjSCORM2004LearningModuleGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output = true)
31  {
32  global $lng;
33 
34  $lng->loadLanguageModule("content");
35  $lng->loadLanguageModule("sahs");
36  $lng->loadLanguageModule("search");
37  $lng->loadLanguageModule("exp");
38  $this->type = "sahs";
39  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
40  #$this->tabs_gui =& new ilTabsGUI();
41  }
42 
46  function executeCommand()
47  {
48  global $ilAccess, $ilCtrl, $tpl, $ilTabs, $lng;
49 
50  $next_class = $ilCtrl->getNextClass($this);
51  $cmd = $ilCtrl->getCmd();
52 
53  // update expander
54  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
55  $form_gui = new ilSCORM2004OrganizationHFormGUI();
56  $form_gui->setTree($this->getEditTree());
57  $form_gui->updateExpanded();
58  switch($next_class)
59  {
60  // notes
61  case "ilnotegui":
62  $this->getTemplate();
63  $this->setLocator();
64  $this->setTabs();
65  switch($_GET["notes_mode"])
66  {
67  default:
68  $ilTabs->setTabActive("sahs_organization");
69  return $this->showOrganization();
70  }
71  break;
72 
73  // chapters
74  case "ilscorm2004chaptergui":
75  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004ChapterGUI.php");
76  $chap_gui = new ilSCORM2004ChapterGUI($this->object, $_GET["obj_id"]);
77  $chap_gui->setParentGUI($this);
78  return $ilCtrl->forwardCommand($chap_gui);
79 
80  // sequencing chapters
81  case "ilscorm2004seqchaptergui":
82  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004SeqChapterGUI.php");
83  $chap_gui = new ilSCORM2004SeqChapterGUI($this->object, $_GET["obj_id"]);
84  $chap_gui->setParentGUI($this);
85  return $ilCtrl->forwardCommand($chap_gui);
86 
87  // scos
88  case "ilscorm2004scogui":
89  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004ScoGUI.php");
90  $sco_gui = new ilSCORM2004ScoGUI($this->object, $_GET["obj_id"]);
91  $sco_gui->setParentGUI($this);
92  return $ilCtrl->forwardCommand($sco_gui);
93 
94  // assets
95  case "ilscorm2004assetgui":
96  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004AssetGUI.php");
97  $ass_gui = new ilSCORM2004AssetGUI($this->object, $_GET["obj_id"]);
98  $ass_gui->setParentGUI($this);
99  return $ilCtrl->forwardCommand($ass_gui);
100 
101  // pages
102  case "ilscorm2004pagenodegui":
103  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNodeGUI.php");
104  $page_gui = new ilSCORM2004PageNodeGUI($this->object, $_GET["obj_id"]);
105  $page_gui->setParentGUI($this);
106  $ilCtrl->forwardCommand($page_gui);
107  break;
108 
109  default:
111  $this->addHeaderAction();
112  break;
113  }
114  }
115 
122  function editOrganization()
123  {
124  $this->frameset(true);
125  }
126 
132  function frameset($a_to_organization = false)
133  {
134  if ($this->object->getEditable()) // show editing frameset
135  {
136  include_once("./Services/Frameset/classes/class.ilFramesetGUI.php");
137  $fs_gui = new ilFramesetGUI();
138 
139  $fs_gui->setFramesetTitle($this->lng->txt("editor"));
140  $fs_gui->setMainFrameName("content");
141  $fs_gui->setSideFrameName("tree");
142  $this->ctrl->setParameter($this, "active_node", $_GET["obj_id"]);
143  $fs_gui->setSideFrameSource($this->ctrl->getLinkTarget($this, "showTree"));
144  $this->ctrl->setParameter($this, "activeNode", "");
145  if ($_GET["obj_id"] > 0)
146  {
147  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
148  $type = ilSCORM2004Node::_lookupType($_GET["obj_id"]);
149  }
150  if (in_array($type, array("sco", "chap", "seqc", "page")))
151  {
152  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
153  $fs_gui->setMainFrameSource($this->ctrl->getLinkTarget($this, "jumpToNode"));
154  }
155  else
156  {
157  if ($a_to_organization)
158  {
159  $fs_gui->setMainFrameSource($this->ctrl->getLinkTarget($this, "showOrganization"));
160  }
161  else
162  {
163  $fs_gui->setMainFrameSource($this->ctrl->getLinkTarget($this, "properties"));
164  }
165  }
166  $fs_gui->show();
167  exit;
168  }
169  else // otherwise show standard frameset
170  {
171  $this->tpl = new ilTemplate("tpl.sahs_edit_frameset.html", false, false, "Modules/ScormAicc");
172  $this->tpl->setVariable("SRC",
173  $this->ctrl->getLinkTarget($this, "properties"));
174  $this->tpl->show("DEFAULT", false);
175  }
176  exit;
177  }
178 
179  function jumpToNode($a_anchor_node = "", $a_highlight_ids = "")
180  {
181  global $ilCtrl;
182 
183  $anchor = ($a_anchor_node != "")
184  ? "node_".$a_anchor_node
185  : "";
186 
187  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
188  $type = ilSCORM2004Node::_lookupType($_GET["obj_id"]);
189  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
190  switch($type)
191  {
192  case "sco":
193  $ilCtrl->setParameterByClass("ilscorm2004scogui", "highlight", $a_highlight_ids);
194  $ilCtrl->redirectByClass("ilscorm2004scogui", "showOrganization", $anchor);
195  case "ass":
196  $ilCtrl->setParameterByClass("ilscorm2004assetgui", "highlight", $a_highlight_ids);
197  $ilCtrl->redirectByClass("ilscorm2004assetgui", "showOrganization", $anchor);
198  case "chap":
199  $ilCtrl->setParameterByClass("ilscorm2004chaptergui", "highlight", $a_highlight_ids);
200  $ilCtrl->redirectByClass("ilscorm2004chaptergui", "showOrganization", $anchor);
201  case "seqc":
202  $ilCtrl->setParameterByClass("ilscorm2004seqchaptergui", "highlight", $a_highlight_ids);
203  $ilCtrl->redirectByClass("ilscorm2004seqchaptergui", "showOrganization", $anchor);
204  case "page":
205  $ilCtrl->redirectByClass("ilscorm2004pagenodegui", "edit");
206  }
207  }
208 
212  function properties()
213  {
214  global $rbacsystem, $tree, $tpl, $lng, $ilToolbar, $ilCtrl, $ilSetting;
215 
216  $this->setSubTabs("settings", "general_settings");
217 
218  $lng->loadLanguageModule("style");
219 
220  // not editable
221  if ($this->object->editable != 1)
222  {
223  // view
224  $ilToolbar->addButton($this->lng->txt("view"),
225  "ilias.php?baseClass=ilSAHSPresentationGUI&amp;ref_id=".$this->object->getRefID(),
226  "_blank");
227 
228  // upload new version
229  $ilToolbar->addButton($this->lng->txt("cont_sc_new_version"),
230  $this->ctrl->getLinkTarget($this, "newModuleVersion"));
231  }
232  else // editable
233  {
234  // glossary buttons to toolbar
235  $sep = false;
236  if (ilObject::_lookupType($this->object->getAssignedGlossary()) != "glo")
237  {
238  $parent_ref_id = $tree->getParentId((int) $_GET["ref_id"]);
239  if ($rbacsystem->checkAccess("create", $parent_ref_id, "glo"))
240  {
241  $ilToolbar->addButton($this->lng->txt("cont_glo_create"),
242  $ilCtrl->getLinkTarget($this, "createGlossary"));
243  }
244  $ilToolbar->addButton($this->lng->txt("cont_glo_assign"),
245  $ilCtrl->getLinkTarget($this, "assignGlossary"));
246  }
247  else
248  {
249  $ilToolbar->addButton($this->lng->txt("cont_glo_detach"),
250  $ilCtrl->getLinkTarget($this, "detachGlossary"));
251  }
252 
253  // style buttons to toolbar
254  $fixed_style = $ilSetting->get("fixed_content_style_id");
255  $style_id = $this->object->getStyleSheetId();
256 
257  if ($fixed_style == 0)
258  {
259  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
260  $_GET["ref_id"]);
261 
262  $st_styles[0] = $this->lng->txt("default");
263  ksort($st_styles);
264 
265  if ($style_id > 0)
266  {
267  // individual style
268  if (!ilObjStyleSheet::_lookupStandard($style_id))
269  {
270  $ilToolbar->addSeparator();
271 
272  // delete command
273  $ilToolbar->addButton($this->lng->txt("cont_edit_style"),
274  $ilCtrl->getLinkTarget($this, "editStyle"));
275  $ilToolbar->addButton($this->lng->txt("cont_delete_style"),
276  $ilCtrl->getLinkTarget($this, "deleteStyle"));
277  }
278  }
279 
280  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
281  {
282  $ilToolbar->addSeparator();
283 
284  $ilToolbar->addButton($this->lng->txt("sty_create_ind_style"),
285  $ilCtrl->getLinkTarget($this, "createStyle"));
286  }
287  }
288  }
289 
290  // output forms
291  if ($this->object->editable != 1)
292  {
293  $this->initPropertiesForm();
294  $tpl->setContent($this->form->getHTML());
295  }
296  else
297  {
300  $tpl->setContent($this->form->getHTML());
301  }
302  }
303 
311  {
312  global $lng, $ilCtrl;
313 
314  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
315  $this->form = new ilPropertyFormGUI();
316  $this->form->setFormAction($ilCtrl->getFormAction($this));
317  $this->form->setTitle($this->lng->txt("cont_lm_properties"));
318 
319  // version
320  $ne = new ilNonEditableValueGUI($this->lng->txt("cont_sc_version"), "");
321  $ne->setValue($this->object->getModuleVersion());
322  $this->form->addItem($ne);
323 
324  // online
325  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_online"), "cobj_online");
326  $cb->setValue("y");
327  if ($this->object->getOnline())
328  {
329  $cb->setChecked(true);
330  }
331  $this->form->addItem($cb);
332 
333  //
334  // presentation
335  //
336  $sh = new ilFormSectionHeaderGUI();
337  $sh->setTitle($this->lng->txt("cont_presentation"));
338  $this->form->addItem($sh);
339 
340  // display mode (open)
341  $options = array(
342  "0" => $this->lng->txt("cont_open_normal"),
343  "1" => $this->lng->txt("cont_open_iframe_max"),
344  "2" => $this->lng->txt("cont_open_iframe_defined"),
345  "5" => $this->lng->txt("cont_open_window_undefined"),
346  "6" => $this->lng->txt("cont_open_window_defined")
347  );
348  $si = new ilSelectInputGUI($this->lng->txt("cont_open"), "open_mode");
349  $si->setOptions($options);
350  $si->setValue($this->object->getOpenMode());
351  $this->form->addItem($si);
352 
353  // width
354  $ni = new ilNumberInputGUI($this->lng->txt("cont_width"), "width");
355  $ni->setMaxLength(4);
356  $ni->setSize(4);
357  $ni->setValue($this->object->getWidth());
358  $this->form->addItem($ni);
359 
360  // height
361  $ni = new ilNumberInputGUI($this->lng->txt("cont_height"), "height");
362  $ni->setMaxLength(4);
363  $ni->setSize(4);
364  $ni->setValue($this->object->getHeight());
365  $this->form->addItem($ni);
366 
367  // disable top menu
368  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_nomenu"), "cobj_nomenu");
369  $cb->setValue("y");
370  $cb->setChecked($this->object->getNoMenu());
371  $this->form->addItem($cb);
372 
373  // disable left-side navigation
374  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_hidenavig"), "cobj_hidenavig");
375  $cb->setValue("y");
376  $cb->setChecked($this->object->getHideNavig());
377  $this->form->addItem($cb);
378 
379  // auto navigation to last visited item
380  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_auto_last_visited"), "cobj_auto_last_visited");
381  $cb->setValue("y");
382  $cb->setChecked($this->object->getAuto_last_visited());
383  $cb->setInfo($this->lng->txt("cont_auto_last_visited_info"));
384  $this->form->addItem($cb);
385 
386  //
387  // scorm options
388  //
389  $sh = new ilFormSectionHeaderGUI();
390  $sh->setTitle($this->lng->txt("cont_scorm_options"));
391  $this->form->addItem($sh);
392 
393  // max attempts
394  $ni = new ilNumberInputGUI($this->lng->txt("cont_sc_max_attempt"), "max_attempt");
395  $ni->setMaxLength(3);
396  $ni->setSize(3);
397  $ni->setValue($this->object->getMaxAttempt());
398  $this->form->addItem($ni);
399 
400  // lesson mode
401  $options = array("normal" => $this->lng->txt("cont_sc_less_mode_normal"),
402  "browse" => $this->lng->txt("cont_sc_less_mode_browse"));
403  $si = new ilSelectInputGUI($this->lng->txt("cont_def_lesson_mode"), "lesson_mode");
404  $si->setOptions($options);
405  $si->setValue($this->object->getDefaultLessonMode());
406  $this->form->addItem($si);
407 
408  // credit mode
409  $options = array("credit" => $this->lng->txt("cont_credit_on"),
410  "no_credit" => $this->lng->txt("cont_credit_off"));
411  $si = new ilSelectInputGUI($this->lng->txt("cont_credit_mode"), "credit_mode");
412  $si->setOptions($options);
413  $si->setValue($this->object->getCreditMode());
414  $si->setInfo($this->lng->txt("cont_credit_mode_info"));
415  $this->form->addItem($si);
416 
417  // set lesson mode review when completed
418  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sc_auto_review"), "auto_review");
419  $cb->setValue("y");
420  $cb->setChecked($this->object->getAutoReview());
421  $cb->setInfo($this->lng->txt("cont_sc_auto_review_info"));
422  $this->form->addItem($cb);
423 
424  //
425  // rte settings
426  //
427  $sh = new ilFormSectionHeaderGUI();
428  $sh->setTitle($this->lng->txt("cont_rte_settings"));
429  $this->form->addItem($sh);
430 
431  // unlimited session timeout
432  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sc_usession"), "cobj_session");
433  $cb->setValue("y");
434  $cb->setChecked($this->object->getSession());
435  $cb->setInfo($this->lng->txt("cont_sc_usession_info"));
436  $this->form->addItem($cb);
437 
438  // sequencing
439  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_sequencing"), "cobj_sequencing");
440  $cb->setValue("y");
441  $cb->setChecked($this->object->getSequencing());
442  $cb->setInfo($this->lng->txt("cont_sequencing_info"));
443  $this->form->addItem($cb);
444 
445  // storage of interactions
446  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_interactions"), "cobj_interactions");
447  $cb->setValue("y");
448  $cb->setChecked($this->object->getInteractions());
449  $this->form->addItem($cb);
450 
451  // objectives
452  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_objectives"), "cobj_objectives");
453  $cb->setValue("y");
454  $cb->setChecked($this->object->getObjectives());
455  $this->form->addItem($cb);
456 
457  // comments
458  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_comments"), "cobj_comments");
459  $cb->setValue("y");
460  $cb->setChecked($this->object->getComments());
461  $this->form->addItem($cb);
462 
463  // time from lms
464  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_time_from_lms"), "cobj_time_from_lms");
465  $cb->setValue("y");
466  $cb->setChecked($this->object->getTime_from_lms());
467  $cb->setInfo($this->lng->txt("cont_time_from_lms_info"));
468  $this->form->addItem($cb);
469 
470  // check values
471  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_check_values"), "cobj_check_values");
472  $cb->setValue("y");
473  $cb->setChecked($this->object->getCheck_values());
474  $this->form->addItem($cb);
475 
476  //
477  // debugging
478  //
479  $sh = new ilFormSectionHeaderGUI();
480  $sh->setTitle($this->lng->txt("cont_debugging"));
481  $this->form->addItem($sh);
482 
483  // test tool
484  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_debug"), "cobj_debug");
485  $cb->setValue("y");
486  $cb->setChecked($this->object->getDebug());
487  if ($this->object->getDebugActivated() == false)
488  {
489  $cb->setDisabled(true);
490  $cb->setInfo($this->lng->txt("cont_debug_deactivated"));
491  }
492  else
493  {
494  $cb->setInfo($this->lng->txt("cont_debug_deactivate"));
495  }
496  $this->form->addItem($cb);
497  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
498  }
499 
500 
504  public function initPropertiesEditableForm()
505  {
506  global $lng, $ilCtrl, $tree, $rbacsystem, $ilSetting;
507 
508  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
509  $this->form = new ilPropertyFormGUI();
510 
511  // localization
512  $options = array(
513  "" => $lng->txt("please_select"),
514  );
515  $langs = $lng->getInstalledLanguages();
516  $lng->loadLanguageModule("meta");
517  foreach ($langs as $l)
518  {
519  $options[$l] = $lng->txt("meta_l_".$l);
520  }
521  $loc = new ilSelectInputGUI($this->lng->txt("cont_localization"), "localization");
522  $loc->setOptions($options);
523  $loc->setInfo($this->lng->txt("cont_localization_info"));
524  $this->form->addItem($loc);
525 
526  // glossary
527  $ne = new ilNonEditableValueGUI($lng->txt("obj_glo"), "glossary");
528  $this->form->addItem($ne);
529 
530  // style
531  $lng->loadLanguageModule("style");
532  $fixed_style = $ilSetting->get("fixed_content_style_id");
533  $style_id = $this->object->getStyleSheetId();
534 
535  if ($fixed_style > 0)
536  {
537  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
538  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
539  $this->lng->txt("global_fixed").")");
540  $this->form->addItem($st);
541  }
542  else
543  {
544  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
545  $_GET["ref_id"]);
546 
547  $st_styles[0] = $this->lng->txt("default");
548  ksort($st_styles);
549 
550  if ($style_id > 0)
551  {
552  // individual style
553  if (!ilObjStyleSheet::_lookupStandard($style_id))
554  {
555  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
556  $st->setValue(ilObject::_lookupTitle($style_id));
557  $this->form->addItem($st);
558  }
559  }
560 
561  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
562  {
563  $style_sel = ilUtil::formSelect ($style_id, "style_id",
564  $st_styles, false, true);
565  $style_sel = new ilSelectInputGUI($lng->txt("cont_current_style"), "style_id");
566  $style_sel->setOptions($st_styles);
567  $style_sel->setValue($style_id);
568  $this->form->addItem($style_sel);
569  }
570  }
571 
572  // number of tries
573  $ni = new ilNumberInputGUI($lng->txt("cont_qtries"), "q_tries");
574  $ni->setMaxLength(3);
575  $ni->setSize(3);
576  $this->form->addItem($ni);
577 
578 
579  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
580 
581  $this->form->setTitle($lng->txt("cont_scorm_ed_properties"));
582  $this->form->setFormAction($ilCtrl->getFormAction($this));
583  }
584 
588  public function getPropertiesEditableValues()
589  {
590  $values = array();
591 
592  if (ilObject::_lookupType($this->object->getAssignedGlossary()) == "glo")
593  {
594  $values["glossary"] = ilObject::_lookupTitle($this->object->getAssignedGlossary());
595  }
596  else
597  {
598  $values["glossary"] = $this->lng->txt("cont_no_glossary");
599  }
600  $values["q_tries"] = $this->object->getTries();
601  $values["localization"] = $this->object->getLocalization();
602  $values["style_id"] = $this->object->getStyleSheetId();
603 
604  $this->form->setValuesByArray($values);
605  }
606 
610  function saveProperties()
611  {
612  global $ilSetting;
613 
614  if ($this->object->editable != 1)
615  {
616  $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
617  $this->object->setOpenMode($_POST["open_mode"]);
618  $this->object->setWidth($_POST["width"]);
619  $this->object->setHeight($_POST["height"]);
620  $this->object->setCreditMode($_POST["credit_mode"]);
621  $this->object->setMaxAttempt($_POST["max_attempt"]);
622  $this->object->setAutoReview(ilUtil::yn2tf($_POST["auto_review"]));
623  $this->object->setDefaultLessonMode($_POST["lesson_mode"]);
624  $this->object->setSession(ilUtil::yn2tf($_POST["cobj_session"]));
625  $this->object->setNoMenu(ilUtil::yn2tf($_POST["cobj_nomenu"]));
626  $this->object->setHideNavig(ilUtil::yn2tf($_POST["cobj_hidenavig"]));
627  $this->object->setAuto_last_visited(ilUtil::yn2tf($_POST["cobj_auto_last_visited"]));
628  $this->object->setSequencing(ilUtil::yn2tf($_POST["cobj_sequencing"]));
629  $this->object->setInteractions(ilUtil::yn2tf($_POST["cobj_interactions"]));
630  $this->object->setObjectives(ilUtil::yn2tf($_POST["cobj_objectives"]));
631  $this->object->setComments(ilUtil::yn2tf($_POST["cobj_comments"]));
632  $this->object->setTime_from_lms(ilUtil::yn2tf($_POST["cobj_time_from_lms"]));
633  $this->object->setCheck_values(ilUtil::yn2tf($_POST["cobj_check_values"]));
634  $this->object->setDebug(ilUtil::yn2tf($_POST["cobj_debug"]));
635  //$this->object->setDebugPw($_POST["debug_pw"]);
636 
637  }
638  else
639  {
641  if ($this->form->checkInput())
642  {
643  $this->object->setTries($_POST["q_tries"]);
644  $this->object->setLocalization($_POST["localization"]);
645 
646  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
647  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
648  || $this->object->getStyleSheetId() == 0))
649  {
650  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
651  }
652  }
653  }
654  $this->object->update();
655  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
656  $this->ctrl->redirect($this, "properties");
657  }
658 
662  function detachGlossary()
663  {
664  global $ilCtrl;
665 
666  $this->object->setAssignedGlossary(0);
667  $this->object->update();
668  $ilCtrl->redirect($this, "properties");
669  }
670 
674  function createGlossary()
675  {
676  global $tpl;
677 
678  $this->initGlossaryCreationForm();
679  $tpl->setContent($this->form->getHTML());
680  }
681 
685  public function initGlossaryCreationForm()
686  {
687  global $lng, $ilCtrl;
688 
689  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
690  $this->form = new ilPropertyFormGUI();
691 
692  // title
693  $ti = new ilTextInputGUI($lng->txt("title"), "title");
694  $ti->setRequired(true);
695  $this->form->addItem($ti);
696 
697  // description
698  $ta = new ilTextAreaInputGUI($lng->txt("desc"), "description");
699  $this->form->addItem($ta);
700 
701  $this->form->addCommandButton("saveGlossary", $lng->txt("save"));
702  $this->form->addCommandButton("properties", $lng->txt("cancel"));
703 
704  $this->form->setTitle($lng->txt("cont_glo_create"));
705  $this->form->setFormAction($ilCtrl->getFormAction($this));
706  }
707 
711  public function saveGlossary()
712  {
713  global $tpl, $lng, $ilCtrl, $rbacsystem, $tree;
714 
715  $parent_ref_id = $tree->getParentId((int) $_GET["ref_id"]);
716  if (!$rbacsystem->checkAccess("create", $parent_ref_id, "glo"))
717  {
718  ilUtil::sendFailure($lng->txt("no_permission"), true);
719  $ilCtrl->redirect($this, "properties");
720  }
721 
722  $this->initGlossaryCreationForm();
723  if ($this->form->checkInput())
724  {
725  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
726  $newObj = new ilObjGlossary();
727  $newObj->setType("glo");
728  $newObj->setTitle($_POST["title"]);
729  $newObj->setDescription($_POST["description"]);
730  $newObj->setVirtualMode("none");
731  $newObj->create();
732  $newObj->createReference();
733  $newObj->putInTree($parent_ref_id);
734  $newObj->setPermissions($parent_ref_id);
735  $newObj->notify("new",$parent_ref_id,$_GET["parent_non_rbac_id"],$parent_ref_id,$newObj->getRefId());
736 
737  // perform save
738  $this->object->setAssignedGlossary($newObj->getId());
739  $this->object->update();
740 
741  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
742  $ilCtrl->redirect($this, "properties");
743  }
744 
745  $this->form->setValuesByPost();
746  $tpl->setContent($this->form->getHtml());
747  }
748 
752  function assignGlossary()
753  {
754  global $tpl, $ilCtrl, $tree;
755 
756  include_once("./Modules/Scorm2004/classes/class.ilGlossarySelectorGUI.php");
757  $exp = new ilGlossarySelectorGUI(
758  $ilCtrl->getLinkTarget($this, "selectGlossary"), "ilobjscorm2004learningmodulegui");
759  $exp->setSelectableTypes(array("glo"));
760 
761  if ($_GET["expand"] == "")
762  {
763  $expanded = $tree->readRootId();
764  }
765  else
766  {
767  $expanded = $_GET["expand"];
768  }
769  $exp->setExpand($expanded);
770 
771  $exp->setTargetGet("glo_id");
772  //$this->ctrl->setParameter($this, "target_type", $a_type);
773  //$ilCtrl->setParameter($this, "subCmd", "insertFromRepository");
774  $exp->setParamsGet($this->ctrl->getParameterArray($this, "assignGlossary"));
775 
776  // filter
777  $exp->setFiltered(true);
778  $exp->setFilterMode(IL_FM_POSITIVE);
779  $exp->addFilter("root");
780  $exp->addFilter("cat");
781  $exp->addFilter("grp");
782  $exp->addFilter("fold");
783  $exp->addFilter("crs");
784  $exp->addFilter("glo");
785 
786  $exp->setOutput(0);
787 
788  $tpl->setContent($exp->getOutput());
789  }
790 
794  function selectGlossary()
795  {
796  global $ilCtrl;
797 
798  $this->object->setAssignedGlossary(ilObject::_lookupObjId((int) $_GET["glo_ref_id"]));
799  $this->object->update();
800  $ilCtrl->redirect($this, "properties");
801  }
802 
806  function assignObject()
807  {
808  if ($this->id != 0)
809  {
810  if ($this->call_by_reference)
811  {
812  $this->object =& new ilObjSCORM2004LearningModule($this->id, true);
813  }
814  else
815  {
816  $this->object =& new ilObjSCORM2004LearningModule($this->id, false);
817  }
818  }
819  }
820 
825  {
826  global $tpl;
827 
828  $this->initStylePropertiesForm();
829  $tpl->setContent($this->form->getHTML());
830  }
831 
836  {
837  global $ilCtrl, $lng, $ilTabs, $ilSetting;
838 
839  $lng->loadLanguageModule("style");
840  $this->setSubTabs("settings", "style");
841  $ilTabs->setTabActive("settings");
842 
843  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
844  $this->form = new ilPropertyFormGUI();
845 
846  $fixed_style = $ilSetting->get("fixed_content_style_id");
847  $style_id = $this->object->getStyleSheetId();
848 
849  if ($fixed_style > 0)
850  {
851  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
852  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
853  $this->lng->txt("global_fixed").")");
854  $this->form->addItem($st);
855  }
856  else
857  {
858  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
859  $_GET["ref_id"]);
860 
861  $st_styles[0] = $this->lng->txt("default");
862  ksort($st_styles);
863 
864  if ($style_id > 0)
865  {
866  // individual style
867  if (!ilObjStyleSheet::_lookupStandard($style_id))
868  {
869  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
870  $st->setValue(ilObject::_lookupTitle($style_id));
871  $this->form->addItem($st);
872 
873 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
874 
875  // delete command
876  $this->form->addCommandButton("editStyle",
877  $lng->txt("cont_edit_style"));
878  $this->form->addCommandButton("deleteStyle",
879  $lng->txt("cont_delete_style"));
880 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
881  }
882  }
883 
884  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
885  {
886  $style_sel = ilUtil::formSelect ($style_id, "style_id",
887  $st_styles, false, true);
888  $style_sel = new ilSelectInputGUI($lng->txt("cont_current_style"), "style_id");
889  $style_sel->setOptions($st_styles);
890  $style_sel->setValue($style_id);
891  $this->form->addItem($style_sel);
892 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
893  $this->form->addCommandButton("saveStyleSettings",
894  $lng->txt("save"));
895  $this->form->addCommandButton("createStyle",
896  $lng->txt("sty_create_ind_style"));
897  }
898  }
899  $this->form->setTitle($lng->txt("cont_style"));
900  $this->form->setFormAction($ilCtrl->getFormAction($this));
901  }
902 
906  function createStyle()
907  {
908  global $ilCtrl;
909 
910  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
911  }
912 
916  function editStyle()
917  {
918  global $ilCtrl;
919 
920  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
921  }
922 
926  function deleteStyle()
927  {
928  global $ilCtrl;
929 
930  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
931  }
932 
936  function saveStyleSettings()
937  {
938  global $ilSetting;
939 
940  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
941  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
942  || $this->object->getStyleSheetId() == 0))
943  {
944  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
945  $this->object->update();
946  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
947  }
948  $this->ctrl->redirect($this, "editStyleProperties");
949  }
950 
955 {
956  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
957  $privacy = ilPrivacySettings::_getInstance();
958  if (!$privacy->enabledSahsProtocolData())
959  {
960  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
961  }
962 
963  include_once "./Services/Table/classes/class.ilTableGUI.php";
964 
965  //set search
966 
967  if ($_POST["search_string"] != "")
968  {
969  $_SESSION["scorm_search_string"] = trim($_POST["search_string"]);
970  } else if (isset($_POST["search_string"]) && $_POST["search_string"] == "") {
971  unset($_SESSION["scorm_search_string"]);
972  }
973 
974  // load template for search additions
975  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl_scorm_track_items_search.html","Modules/ScormAicc");
976  // load template for table
977  $this->tpl->addBlockfile("USR_TABLE", "usr_table", "tpl.table.html");
978  // load template for table content data
979  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.scorm_track_items.html", "Modules/ScormAicc");
980 
981  $num = 5;
982 
983  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
984 
985  // create table
986  $tbl = new ilTableGUI();
987 
988  // title & header columns
989  if (isset($_SESSION["scorm_search_string"])) {
990  $tbl->setTitle($this->lng->txt("cont_tracking_items").' - Aktive Suche: "'.$_SESSION["scorm_search_string"].'"');
991  } else {
992  $tbl->setTitle($this->lng->txt("cont_tracking_items"));
993  }
994 
995  $tbl->setHeaderNames(array("",$this->lng->txt("name"), $this->lng->txt("last_access"), $this->lng->txt("attempts"), $this->lng->txt("version") ));
996 
997 
998  $header_params = $this->ctrl->getParameterArray($this, "showTrackingItems");
999 
1000  $tbl->setColumnWidth(array("1%", "50%", "29%", "10%","10%"));
1001 
1002  $cols = array("user_id","username","last_access","attempts","version");
1003  $tbl->setHeaderVars($cols, $header_params);
1004 
1005  //set defaults
1006  $_GET["sort_order"] = $_GET["sort_order"] ? $_GET["sort_order"] : "asc";
1007  $_GET["sort_by"] = $_GET["sort_by"] ? $_GET["sort_by"] : "username";
1008 
1009  // control
1010  $tbl->setOrderColumn($_GET["sort_by"]);
1011  $tbl->setOrderDirection($_GET["sort_order"]);
1012  $tbl->setLimit($_GET["limit"]);
1013  $tbl->setOffset($_GET["offset"]);
1014  $tbl->setMaxCount($this->maxcount);
1015 
1016  $this->tpl->setVariable("COLUMN_COUNTS", 5);
1017 
1018  // delete button
1019  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.png"));
1020  $this->tpl->setCurrentBlock("tbl_action_btn");
1021  $this->tpl->setVariable("BTN_NAME", "deleteTrackingForUser");
1022  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
1023  $this->tpl->parseCurrentBlock();
1024 
1025  // decrease attempts
1026  $this->tpl->setCurrentBlock("tbl_action_btn");
1027  $this->tpl->setVariable("BTN_NAME", "decreaseAttempts");
1028  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("decrease_attempts"));
1029  $this->tpl->parseCurrentBlock();
1030 
1031  // export aggregated data for selected users
1032  $this->tpl->setCurrentBlock("tbl_action_btn");
1033  $this->tpl->setVariable("BTN_NAME", "exportSelected");
1034  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("export"));
1035  $this->tpl->parseCurrentBlock();
1036 
1037  // add search and export all
1038  // export aggregated data for all users
1039  $this->tpl->setVariable("EXPORT_ACTION",$this->ctrl->getFormAction($this));
1040 
1041  $this->tpl->setVariable("EXPORT_ALL_VALUE", $this->lng->txt('cont_export_all'));
1042  $this->tpl->setVariable("EXPORT_ALL_NAME", "exportAll");
1043  $this->tpl->setVariable("IMPORT_VALUE", $this->lng->txt('import'));
1044  $this->tpl->setVariable("IMPORT_NAME", "Import");
1045 
1046  $this->tpl->setVariable("SEARCH_TXT_SEARCH",$this->lng->txt('search'));
1047  $this->tpl->setVariable("SEARCH_ACTION",$this->ctrl->getFormAction($this));
1048  $this->tpl->setVariable("SEARCH_NAME",'showTrackingItems');
1049  if (isset($_SESSION["scorm_search_string"])) {
1050  $this->tpl->setVariable("STYLE",'display:inline;');
1051  } else {
1052  $this->tpl->setVariable("STYLE",'display:none;');
1053  }
1054  $this->tpl->setVariable("SEARCH_VAL", $_SESSION["scorm_search_string"]);
1055  $this->tpl->setVariable("SEARCH_VALUE",$this->lng->txt('search_users'));
1056  $this->tpl->parseCurrentBlock();
1057 
1058  // footer
1059  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1060 
1061  $items = $this->object->getTrackedUsers($_SESSION["scorm_search_string"]);
1062 
1063  $tbl->setMaxCount(count($items));
1064  $items = ilUtil::sortArray($items ,$_GET["sort_by"],$_GET["sort_order"]);
1065  $items = array_slice($items, $_GET["offset"], $_GET["limit"]);
1066 
1067  $tbl->render();
1068 
1069  if (count($items) > 0)
1070  {
1071  foreach ($items as $item)
1072  {
1073  if (ilObject::_exists($item["user_id"]) && ilObject::_lookUpType($item["user_id"])=="usr")
1074  {
1075  $user = new ilObjUser($item["user_id"]);
1076  $this->tpl->setCurrentBlock("tbl_content");
1077  $this->tpl->setVariable("VAL_USERNAME", $item["username"]);
1078  $this->tpl->setVariable("VAL_LAST", ilDatePresentation::formatDate(new ilDateTime($item["last_access"],IL_CAL_DATETIME)));
1079  $this->tpl->setVariable("VAL_ATTEMPT", $item["attempts"]);
1080  $this->tpl->setVariable("VAL_VERSION", $item['version']);
1081  $this->ctrl->setParameter($this, "user_id", $item["user_id"]);
1082  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
1083  $this->tpl->setVariable("LINK_ITEM",
1084  $this->ctrl->getLinkTarget($this, "showTrackingItem"));
1085  $this->tpl->setVariable("CHECKBOX_ID", $item["user_id"]);
1086  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
1087  $this->tpl->setVariable("CSS_ROW", $css_row);
1088  $this->tpl->parseCurrentBlock();
1089  }
1090  }
1091  $this->tpl->setCurrentBlock("selectall");
1092  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
1093  $this->tpl->setVariable("CSS_ROW", $css_row);
1094  $this->tpl->parseCurrentBlock();
1095 
1096  } //if is_array
1097  else
1098  {
1099  $this->tpl->setCurrentBlock("notfound");
1100  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1101  $this->tpl->setVariable("NUM_COLS", $num);
1102  $this->tpl->parseCurrentBlock();
1103  }
1104 
1105 }
1106 
1107 
1108 function exportAll(){
1109  $this->object->exportSelected(1);
1110 }
1111 
1112 function exportSelected()
1113 {
1114  if (!isset($_POST["user"]))
1115  {
1116  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
1117  $this->ctrl->redirect($this, "showTrackingItems");
1118  } else {
1119  $this->object->exportSelected(0,$_POST["user"]);
1120  }
1121 }
1122 
1127 {
1128 
1129  include_once "./Services/Table/classes/class.ilTableGUI.php";
1130 
1131  // load template for table
1132  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
1133  // load template for table content data
1134  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.scorm2004_track_item.html", "Modules/Scorm2004");
1135 
1136  $num = 2;
1137 
1138  $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
1139 
1140  // create table
1141  $tbl = new ilTableGUI();
1142 
1143  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php");
1144  $sc_item =& new ilSCORMItem($_GET["obj_id"]);
1145 
1146  // title & header columns
1147  $user = new ilObjUser( $_GET["user_id"]);
1148  $tbl->setTitle($user->getLastname().", ".$user->getFirstname());
1149 
1150  $tbl->setHeaderNames(array($this->lng->txt("title"),
1151  $this->lng->txt("cont_status"), $this->lng->txt("cont_time"),
1152  $this->lng->txt("cont_score")));
1153 
1154  $header_params = array("ref_id" => $this->ref_id, "cmd" => $_GET["cmd"],
1155  "cmdClass" => get_class($this), "obj_id" => $_GET["obj_id"], "baseClass"=>"ilSAHSEditGUI", 'user_id'=>$_GET["user_id"]);
1156 
1157  $cols = array("title", "status", "time", "score");
1158  $tbl->setHeaderVars($cols, $header_params);
1159  //$tbl->setColumnWidth(array("25%",));
1160 
1161  // control
1162  $tbl->setOrderColumn($_GET["sort_by"]);
1163  $tbl->setOrderDirection($_GET["sort_order"]);
1164  $tbl->setLimit($_GET["limit"]);
1165  $tbl->setOffset($_GET["offset"]);
1166  $tbl->setMaxCount($this->maxcount);
1167 
1168  //$this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
1169  //$this->showActions(true);
1170 
1171  // footer
1172  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1173  #$tbl->disable("footer");
1174 
1175  $tr_data = $this->object->getTrackingDataAgg($_GET["user_id"]);
1176 
1177  //$objs = ilUtil::sortArray($objs, $_GET["sort_by"], $_GET["sort_order"]);
1178  $tbl->setMaxCount(count($tr_data));
1179  $tr_data = array_slice($tr_data, $_GET["offset"], $_GET["limit"]);
1180 
1181  $tbl->render();
1182 
1183  if (count($tr_data) > 0)
1184  {
1185  foreach ($tr_data as $data)
1186  {
1187  $this->tpl->setCurrentBlock("tbl_content");
1188  $this->tpl->setVariable("VAL_TITLE", $data["title"]);
1189  $this->ctrl->setParameter($this, "user_id", $_GET["user_id"]);
1190  $this->ctrl->setParameter($this, "obj_id", $data["sco_id"]);
1191 
1192  $this->tpl->setVariable("LINK_SCO",
1193  $this->ctrl->getLinkTarget($this, "showTrackingItemPerUser"));
1194  $this->tpl->setVariable("VAL_TIME", $data["time"]);
1195  $this->tpl->setVariable("VAL_STATUS", $data["status"]);
1196  $this->tpl->setVariable("VAL_SCORE", $data["score"]);
1197 
1198  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
1199  $this->tpl->setVariable("CSS_ROW", $css_row);
1200  $this->tpl->parseCurrentBlock();
1201 
1202  }
1203  } //if is_array
1204  else
1205  {
1206  $this->tpl->setCurrentBlock("notfound");
1207  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1208  $this->tpl->setVariable("NUM_COLS", $num);
1209  $this->tpl->parseCurrentBlock();
1210  }
1211 }
1212 
1213 
1218  {
1219  if(!isset($_POST["user"]))
1220  {
1221  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1222  }
1223 
1224  // display confirmation message
1225  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1226  $cgui = new ilConfirmationGUI();
1227  $cgui->setFormAction($this->ctrl->getFormAction($this));
1228  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
1229  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteTracking");
1230  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDeleteTracking");
1231 
1232  foreach($_POST["user"] as $id)
1233  {
1234  if (ilObject::_exists($id) && ilObject::_lookUpType($id)=="usr" )
1235  {
1236  $user = new ilObjUser($id);
1237 
1238  $caption = ilUtil::getImageTagByType("sahs", $this->tpl->tplPath).
1239  " ".$this->lng->txt("cont_tracking_data").
1240  ": ".$user->getLastname().", ".$user->getFirstname();
1241 
1242 
1243  $cgui->addItem("user[]", $id, $caption);
1244  }
1245  }
1246 
1247  $this->tpl->setContent($cgui->getHTML());
1248  }
1249 
1250  function resetSearch() {
1251  unset($_SESSION["scorm_search_string"]);
1252  $this->ctrl->redirect($this, "showTrackingItems");
1253  }
1254 
1259  {
1260  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
1261  $this->ctrl->redirect($this, "showTrackingItems");
1262  }
1263 
1270  {
1271  foreach ($_POST["user"] as $user)
1272  {
1273  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");
1274  ilSCORM2004DeleteData::removeCMIDataForUserAndPackage($user,$this->object->getId());
1275 
1276  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
1277  ilLPStatusWrapper::_updateStatus($this->object->getId(), $user);
1278  }
1279 
1280  $this->ctrl->redirect($this, "showTrackingItems");
1281  }
1282 
1283  function decreaseAttempts()
1284  {
1285  global $ilDB, $ilUser;
1286 
1287  if (!isset($_POST["user"]) || !is_array($_POST["user"]))
1288  {
1289  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
1290  }
1291 
1292  foreach ($_POST["user"] as $user)
1293  {
1294  //first check if there is a package_attempts entry
1295 
1296  //get existing account - sco id is always 0
1297 
1298  $val_set = $ilDB->queryF('
1299  SELECT * FROM cmi_custom
1300  WHERE user_id = %s
1301  AND sco_id = %s
1302  AND lvalue = %s
1303  AND obj_id = %s',
1304  array('integer','integer','text','integer'),
1305  array($user,0,'package_attempts',$this->object->getID()));
1306 
1307  $val_rec = $ilDB->fetchAssoc($val_set);
1308 
1309  $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
1310  if ($val_rec["rvalue"] != null && $val_rec["rvalue"] != 0)
1311  {
1312  $new_rec = $val_rec["rvalue"]-1;
1313  //decrease attempt by 1
1314  $res = $ilDB->queryF('
1315  SELECT * FROM cmi_custom
1316  WHERE user_id = %s
1317  AND lvalue = %s
1318  AND obj_id = %s
1319  AND sco_id = %s',
1320  array('integer','text','integer','integer'),
1321  array($user, 'package_attempts',$this->object->getID(),0));
1322 
1323 
1324  if($ilDB->numRows($res) > 0)
1325  {
1326  $val_set = $ilDB->manipulateF('
1327  UPDATE cmi_custom
1328  SET rvalue = %s,
1329  c_timestamp = %s
1330  WHERE user_id = %s
1331  AND sco_id = %s
1332  AND obj_id = %s
1333  AND lvalue = %s',
1334  array('text','timestamp','integer','integer','integer','text'),
1335  array($new_rec, date("Y-m-d H:i:s") ,$user,0,$this->object->getID(),'package_attempts'));
1336  }
1337  else
1338  {
1339  $val_set = $ilDB->manipulateF('
1340  INSERT INTO cmi_custom
1341  (rvalue,user_id,sco_id,obj_id,lvalue,c_timestamp)
1342  VALUES(%s,%s,%s,%s,%s,%s)',
1343  array('text','integer','integer','integer','text','timestamp'),
1344  array($new_rec,$user,0,$this->object->getID(),'package_attempts',date("Y-m-d H:i:s")));
1345  }
1346  }
1347  }
1348 
1349  //$this->ctrl->saveParameter($this, "cdir");
1350  $this->ctrl->redirect($this, "showTrackingItems");
1351  }
1352 
1354  {
1355  if (is_array($_POST["id"]))
1356  {
1357  $this->object->deleteTrackingDataOfUsers($_POST["id"]);
1358  }
1359  $this->showTrackingItems();
1360  }
1361 
1365  function showTree()
1366  {
1367  global $ilUser, $ilias, $ilCtrl, $lng;
1368 
1369  $mtree = new ilTree($this->object->getId());
1370  $mtree->setTableNames('sahs_sc13_tree','sahs_sc13_tree_node');
1371  $mtree->setTreeTablePK("slm_id");
1372 
1373  if ($_POST["expandAll"] != "")
1374  {
1375  $_GET["scexpand"] = "";
1376  $stree = $mtree->getSubTree($mtree->getNodeData($mtree->readRootId()));
1377  $n_arr = array();
1378  foreach ($stree as $n)
1379  {
1380  $n_arr[] = $n["child"];
1381  }
1382  $_SESSION["scexpand"] = $n_arr;
1383  }
1384 
1385  if ($_POST["collapseAll"] != "")
1386  {
1387  $_GET["scexpand"] = "";
1388  $_SESSION["scexpand"] = array($mtree->readRootId());
1389  }
1390 
1391  $this->tpl = new ilTemplate("tpl.main.html", true, true);
1392  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1393 
1394  $ilCtrl->setParameter($this, "active_node", $_GET["active_node"]);
1395 
1396  $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
1397  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false));
1398 
1399  $this->tpl->setCurrentBlock("exp2_button");
1400  $this->tpl->setVariable("CMD_EXP2_BTN", "expandAll");
1401  $this->tpl->setVariable("TXT_EXP2_BTN", $lng->txt("expand_all"));
1402  $this->tpl->parseCurrentBlock();
1403 
1404  $this->tpl->setCurrentBlock("exp2_button");
1405  $this->tpl->setVariable("CMD_EXP2_BTN", "collapseAll");
1406  $this->tpl->setVariable("TXT_EXP2_BTN", $lng->txt("collapse_all"));
1407  $this->tpl->parseCurrentBlock();
1408 
1409  require_once ("./Modules/Scorm2004/classes/class.ilSCORM2004EditorExplorer.php");
1410  $exp = new ilSCORM2004EditorExplorer($this->ctrl->getLinkTarget($this, "edit"),
1411  $this->object);
1412  $exp->setFrameUpdater("content", "ilHierarchyFormUpdater");
1413  $exp->setTargetGet("obj_id");
1414  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, "showTree"));
1415 
1416  if ($_GET["scexpand"] == "")
1417  {
1418  $expanded = $mtree->readRootId();
1419  }
1420  else
1421  {
1422  $expanded = $_GET["scexpand"];
1423  }
1424 
1425 //echo "-".$_GET["active_node"]."-";
1426  if ($_GET["active_node"] != "")
1427  {
1428  $path = $mtree->getPathId($_GET["active_node"]);
1429  $exp->setForceOpenPath($path);
1430 
1431  $exp->highlightNode($_GET["active_node"]);
1432  }
1433  $exp->setExpand($expanded);
1434 
1435  // build html-output
1436  $exp->setOutput(0);
1437  $output = $exp->getOutput();
1438 
1439  // asynchronous output
1440  if ($ilCtrl->isAsynch())
1441  {
1442  echo $output; exit;
1443  }
1444 
1445  $this->tpl->setCurrentBlock("content");
1446  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("sahs_organization"));
1447  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
1448  $this->tpl->setVariable("EXPLORER",$output);
1449  $this->ctrl->setParameter($this, "scexpand", $_GET["scexpand"]);
1450  $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, "showTree"));
1451  $this->tpl->parseCurrentBlock();
1452 
1453  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
1454  iljQueryUtil::initjQuery($this->tpl);
1455 
1456  $this->tpl->show(false);
1457 
1458 
1459  exit;
1460  }
1461 
1465  function showSequencing()
1466  {
1467  global $tpl, $lng, $ilTabs, $ilToolbar, $ilCtrl;
1468 
1469  $ilTabs->setTabActive("sahs_sequencing");
1470 
1471  include_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Item.php");
1472 
1473  if (!$this->object->getSequencingExpertMode())
1474  {
1475  $ilToolbar->addButton($lng->txt("sahs_activate_expert_mode"),
1476  $ilCtrl->getLinkTarget($this, "confirmExpertMode"));
1477  }
1478  else
1479  {
1480  include_once("./Services/UIComponent/NestedList/classes/class.ilNestedList.php");
1481  $list = new ilNestedList();
1482  $t = $this->object->getTree();
1483  $root_node = $t->getNodeData($t->getRootId());
1484  $nodes = $this->object->getTree()->getSubtree($root_node);
1485  foreach ($nodes as $node)
1486  {
1487  if (in_array($node["type"], array("", "chap", "sco")))
1488  {
1489  $ntpl = new ilTemplate("tpl.seq_node.html", true, true, "Modules/Scorm2004");
1490  $ntpl->setVariable("NODE_ID", $node["child"]);
1491  if ($node["type"] == "")
1492  {
1493  $ntpl->setVariable("TITLE", $this->object->getTitle());
1494  $item = new ilSCORM2004Item($this->object->getId(), true);
1495  }
1496  else
1497  {
1498  $ntpl->setVariable("TITLE", $node["title"]);
1499  $item = new ilSCORM2004Item($node["child"]);
1500  }
1501  $ntpl->setVariable("SEQ_INFO",
1502  ilUtil::prepareFormOutput($item->exportAsXML(false)));
1503  $list->addListNode($ntpl->get(), $node["child"], $node["parent"]);
1504  }
1505  }
1506 
1507  $tb = new ilToolbarGUI();
1508  $tb->addFormButton($lng->txt("save"), "saveSequencing");
1509  $ftpl = new ilTemplate("tpl.sequencing.html", true, true, "Modules/Scorm2004");
1510  $ftpl->setVariable("CONTENT", $list->getHTML());
1511  $ftpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this));
1512  $ftpl->setVariable("TB", $tb->getHTML());
1513  $tpl->setContent($ftpl->get());
1514  }
1515  }
1516 
1521  {
1522  global $ilCtrl, $tpl, $lng, $ilTabs;
1523 
1524  $ilTabs->setTabActive("sahs_sequencing");
1525 
1526  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1527  $cgui = new ilConfirmationGUI();
1528  $cgui->setFormAction($ilCtrl->getFormAction($this));
1529  $cgui->setHeaderText($lng->txt("sahs_activate_expert_mode_info"));
1530  $cgui->setCancel($lng->txt("cancel"), "showSequencing");
1531  $cgui->setConfirm($lng->txt("sahs_activate_expert_mode"), "activateExpertMode");
1532 
1533  $tpl->setContent($cgui->getHTML());
1534  }
1535 
1543  {
1544  global $ilCtrl, $lng;
1545 
1546  $this->object->setSequencingExpertMode(true);
1547  $this->object->update();
1548  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1549  $ilCtrl->redirect($this, "showSequencing");
1550  }
1551 
1552 
1556  function saveSequencing()
1557  {
1558  global $tpl,$lng, $ilCtrl;
1559 
1560  include_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Item.php");
1561  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1562  $t = $this->object->getTree();
1563  $root_node = $t->getNodeData($t->getRootId());
1564  $nodes = $this->object->getTree()->getSubtree($root_node);
1565  foreach ($nodes as $node)
1566  {
1567  if (in_array($node["type"], array("", "chap", "sco")))
1568  {
1569  if ($node["type"] == "")
1570  {
1571  $item = new ilSCORM2004Item($this->object->getId(), true);
1572  }
1573  else
1574  {
1575  $item = new ilSCORM2004Item($node["child"]);
1576  }
1577  $xml = '<?xml version="1.0"?>'.ilUtil::stripSlashes($_POST["seq"][$node["child"]], false);
1578 
1579  $ob_texts = array();
1580  if ($node["type"] == "sco")
1581  {
1582  $sco = new ilSCORM2004Sco($this->object, $node["child"]);
1583  $objectives = $sco->getObjectives();
1584  foreach ($objectives as $o)
1585  {
1586  $ob_texts[$o->getId()] = $o->getObjectiveId();
1587  }
1588  }
1589 
1590  $item->setSeqXml($xml);
1591  $item->initDom();
1592  $item->update();
1593 
1594  if ($node["type"] == "sco")
1595  {
1596  foreach ($ob_texts as $id => $t)
1597  {
1598  $objective = new ilScorm2004Objective($node["child"], $id);
1599  $objective->setObjectiveId($t);
1600  $objective->updateObjective();
1601  }
1602  }
1603  }
1604  }
1605 
1606  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1607 
1608  $ilCtrl->redirect($this, "showSequencing");
1609  }
1610 
1615  {
1616  global $tpl, $lng, $ilCtrl, $ilToolbar;
1617 
1618  $chaps = $this->object->getTree()->getChilds(
1619  $this->object->getTree()->getRootId());
1620  $s_chaps = array();
1621  foreach($chaps as $chap)
1622  {
1623  if ($chap["type"] == "chap")
1624  {
1625  $s_chaps[$chap["child"]] = $chap["title"];
1626  }
1627  }
1628  $cur_chap = $_SESSION["sahs_cur_chap"]
1629  ? $_SESSION["sahs_cur_chap"]
1630  : 0;
1631 
1632  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1633  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1634  $options = array(
1635  "0" => $lng->txt("all")
1636  );
1637  $options = $options + $s_chaps;
1638  $si = new ilSelectInputGUI($lng->txt("chapter"), "chapter");
1639  $si->setOptions($options);
1640  $si->setValue($cur_chap);
1641  $ilToolbar->addInputItem($si, true);
1642  $ilToolbar->addFormButton($lng->txt("change"), "selectLObjChapter");
1643 
1644  include_once("./Modules/Scorm2004/classes/class.ilObjectivesAlignmentTableGUI.php");
1645  $obj_table = new ilObjectivesAlignmentTableGUI($this, "showLearningObjectivesAlignment",
1646  $this->getEditTree(), $this->object, $cur_chap);
1647  $tpl->setContent($obj_table->getHTML());
1648  }
1649 
1651  {
1652  global $ilCtrl;
1653 
1654  $_SESSION["sahs_cur_chap"] = (int) $_POST["chapter"];
1655  $ilCtrl->redirect($this, "showLearningObjectivesAlignment");
1656  }
1657 
1661  public function selectExport()
1662  {
1663  switch ($_POST['select_export'])
1664  {
1665  case "exportScorm12":
1666  case "exportScorm2004_3rd":
1667  case "exportScorm2004_4th":
1668  case "exportPDF":
1669  case "exportISO":
1670  case "exportHTML":
1671  case "exportHTMLOne":
1672  $this->ctrl->redirect($this, $_POST['select_export']);
1673  break;
1674  default:
1675  $this->ctrl->redirect($this, 'showExportList');
1676  break;
1677  }
1678  }
1679 
1683  function showExportList()
1684  {
1685  global $tpl;
1686 
1687  $template = new ilTemplate("tpl.scorm2004_export_buttons.html", true, true, 'Modules/Scorm2004');
1688 
1689 /* $buttons = array(
1690  "exportScorm2004_3rd" => $this->lng->txt("scorm_create_export_file_scrom2004"),
1691  "exportScorm2004_4th" => $this->lng->txt("scorm_create_export_file_scrom2004_4th"),
1692  "exportScorm12" => $this->lng->txt("scorm_create_export_file_scrom12"),
1693  "exportPDF" => $this->lng->txt("scorm_create_export_file_pdf"),
1694  "exportISO" => $this->lng->txt("scorm_create_export_file_iso"),
1695  "exportHTML" => $this->lng->txt("scorm_create_export_file_html"),
1696  "exportHTMLOne" => $this->lng->txt("scorm_create_export_file_html_one")
1697  );*/
1698  $buttons = array(
1699  "exportScorm2004_3rd" => $this->lng->txt("scorm_create_export_file_scrom2004"),
1700  "exportScorm2004_4th" => $this->lng->txt("scorm_create_export_file_scrom2004_4th"),
1701  "exportScorm12" => $this->lng->txt("scorm_create_export_file_scrom12"),
1702  "exportHTML" => $this->lng->txt("scorm_create_export_file_html"),
1703  "exportHTMLOne" => $this->lng->txt("scorm_create_export_file_html_one")
1704  );
1705  foreach ($buttons as $value => $text)
1706  {
1707  $template->setCurrentBlock('option');
1708  $template->setVariable('OPTION_VALUE', $value);
1709  $template->setVariable('OPTION_TITLE', ilUtil::prepareFormOutput($text));
1710  $template->parseCurrentBlock();
1711  }
1712  $template->setVariable('EXPORT_TITLE', $this->lng->txt('export'));
1713  $template->setVariable('EXPORT_LABEL', $this->lng->txt('type'));
1714  $template->setVariable('FORMACTION', $this->ctrl->getFormAction($this, 'selectExport'));
1715 
1716  $export_files = $this->object->getExportFiles();
1717 
1718  include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ExportTableGUI.php";
1719  $table_gui = new ilSCORM2004ExportTableGUI($this, 'showExportList');
1720  $data = array();
1721  foreach ($export_files as $exp_file)
1722  {
1723  $filetype = $exp_file['type'];
1724  $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($filetype))
1725  ? " <b>(".$this->lng->txt("public").")<b>"
1726  : "";
1727  $file_arr = explode("__", $exp_file["file"]);
1728  array_push($data, array('file' => $exp_file['file'], 'filetype' => $filetype, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => $exp_file['size'], 'type' => $exp_file['type'].$public_str));
1729  }
1730  $table_gui->setData($data);
1731  $this->tpl->setVariable('ADM_CONTENT', $template->get() . "\n" . $table_gui->getHTML());
1732  }
1733 
1739  function getTabs(&$tabs_gui)
1740  {
1741  global $ilAccess, $ilHelp;
1742 
1743  if ($this->ctrl->getCmd() == "delete")
1744  {
1745  return;
1746  }
1747 
1748  if (!$this->object->getEditable())
1749  {
1750  return parent::getTabs($tabs_gui);
1751  }
1752 
1753  $ilHelp->setScreenIdComponent("sahsed");
1754 
1755  // organization
1756  $tabs_gui->addTarget("sahs_organization",
1757  $this->ctrl->getLinkTarget($this, "showOrganization"), "showOrganization",
1758  get_class($this));
1759 
1760  // info screen
1761  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui")
1762  ? true
1763  : false;
1764  $tabs_gui->addTarget("info_short",
1765  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"), "",
1766  "ilinfoscreengui", "", $force_active);
1767 
1768  // settings
1769  $tabs_gui->addTarget("settings",
1770  $this->ctrl->getLinkTarget($this, "properties"), "properties",
1771  get_class($this));
1772 
1773  // tracking data
1774  /* Later, only if tracking data exists
1775  $tabs_gui->addTarget("cont_tracking_data",
1776  $this->ctrl->getLinkTarget($this, "showTrackingItems"), "showTrackingItems",
1777  get_class($this));
1778  */
1779 
1780  // objective alignment
1781  $tabs_gui->addTarget("sahs_objectives_alignment",
1782  $this->ctrl->getLinkTarget($this, "showLearningObjectivesAlignment"), "showLearningObjectivesAlignment",
1783  get_class($this));
1784 
1785  // sequencing
1786  $tabs_gui->addTarget("sahs_sequencing",
1787  $this->ctrl->getLinkTarget($this, "showSequencing"), "showSequencing",
1788  get_class($this));
1789 
1790  // learning progress
1791  /* Later, only if tracking data exists
1792  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
1793  if(ilObjUserTracking::_enabledLearningProgress())
1794  {
1795  $tabs_gui->addTarget('learning_progress',
1796  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
1797  '',
1798  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
1799  }
1800  */
1801 
1802  // edit meta
1803  $tabs_gui->addTarget("meta_data",
1804  $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
1805  "", "ilmdeditorgui");
1806 
1807  // export
1808  $tabs_gui->addTarget("export",
1809  $this->ctrl->getLinkTarget($this, "showExportList"), array("showExportList", 'confirmDeleteExportFile'),
1810  get_class($this));
1811 
1812  // perm
1813  if ($ilAccess->checkAccess('edit_permission', '', $this->object->getRefId()))
1814  {
1815  $tabs_gui->addTarget("perm_settings",
1816  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1817  }
1818 
1819  if ($this->object->editable==1)
1820  {
1821  // preview
1822  $tabs_gui->addNonTabbedLink("preview",
1823  $this->lng->txt("cont_sc_preview"),
1824  $this->ctrl->getLinkTarget($this, "preview"),
1825  "_blank");
1826  }
1827 
1828  }
1829 
1833  function setSubTabs($a_main_tab, $a_active)
1834  {
1835  global $ilTabs, $ilCtrl, $lng;
1836 
1837  if ($a_main_tab == "settings" &&
1838  $this->object->editable == 1)
1839  {
1840 /* // general properties
1841  $ilTabs->addSubTab("general_settings",
1842  $lng->txt("general_settings"),
1843  $ilCtrl->getLinkTarget($this, 'properties'));
1844 
1845  // style properties
1846  $ilTabs->addSubTab("style",
1847  $lng->txt("cont_style"),
1848  $ilCtrl->getLinkTarget($this, 'editStyleProperties'));
1849 */
1850  $ilTabs->activateSubTab($a_active);
1851  }
1852  }
1853 
1854 
1858  function getEditTree()
1859  {
1860  $slm_tree = new ilTree($this->object->getId());
1861  $slm_tree->setTreeTablePK("slm_id");
1862  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
1863  return $slm_tree;
1864  }
1865 
1869  function showOrganization($a_top_node = 0, $a_form_action = "",
1870  $a_title = "", $a_icon = "", $a_gui_obj = null, $a_gui_cmd = "")
1871  {
1872  global $lng, $ilCtrl, $tpl;
1873 
1874  if ($a_form_action == "")
1875  {
1876  $a_form_action = $ilCtrl->getFormAction($this);
1877  }
1878 
1879  if ($a_icon == "")
1880  {
1881  $a_title = $this->object->getTitle();
1882  $a_icon = ilUtil::getImagePath("icon_lm.png");
1883  }
1884 
1885  $slm_tree = $this->getEditTree();
1886 
1887  if ($a_top_node == 0)
1888  {
1889  $a_top_node = $slm_tree->getRootId();
1890  }
1891 
1892  if (is_null($a_gui_obj))
1893  {
1894  $a_gui_obj = $this;
1895  $a_gui_cmd = "showOrganization";
1896  }
1897 
1898  $ilCtrl->setParameter($this, "backcmd", "showOrganization");
1899  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
1900  $form_gui = new ilSCORM2004OrganizationHFormGUI();
1901  $form_gui->setParentCommand($a_gui_obj, $a_gui_cmd);
1902  $form_gui->setFormAction($a_form_action);
1903 // $form_gui->setTitle($a_title);
1904 // $form_gui->setIcon($a_icon);
1905  $form_gui->setTree($slm_tree);
1906  $form_gui->setCurrentTopNodeId($a_top_node);
1907  $form_gui->addMultiCommand($lng->txt("delete"), "deleteNodes");
1908  $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
1909  $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
1910  $form_gui->addCommand($lng->txt("cont_save_all_titles"), "saveAllTitles");
1911  $form_gui->addCommand($lng->txt("expand_all"), "expandAll");
1912  $form_gui->addCommand($lng->txt("collapse_all"), "collapseAll");
1913  $form_gui->setTriggeredUpdateCommand("saveAllTitles");
1914 
1915  // highlighted nodes
1916  if ($_GET["highlight"] != "")
1917  {
1918  $hl = explode(":", $_GET["highlight"]);
1919  $form_gui->setHighlightedNodes($hl);
1920  $form_gui->setFocusId($hl[0]);
1921  }
1922 
1923  $ilCtrl->setParameter($this, "active_node", $_GET["obj_id"]);
1924  $form_gui->setExplorerUpdater("tree", "tree_div",
1925  $ilCtrl->getLinkTarget($this, "showTree", "", true));
1926  $sc_tpl = new ilTemplate("tpl.scormeditor_orga_screen.html", true, true, "Modules/Scorm2004");
1927  $sc_tpl->setVariable("ORGANIZATION", $form_gui->getHTML());
1928  $sc_tpl->setVariable("NOTES", $this->getNotesHTML());
1929 
1930  $tpl->setContent($sc_tpl->get());
1931  }
1932 
1936  function getNotesHTML($a_mode = "")
1937  {
1938  global $ilCtrl;
1939 
1940  // notes
1941  $ilCtrl->setParameter($this, "nodes_mode", $a_mode);
1942  include_once("Services/Notes/classes/class.ilNoteGUI.php");
1943  $node_id = $_GET["obj_id"];
1944  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1945  $node_type = ($node_id > 0)
1946  ? ilSCORM2004Node::_lookupType($node_id)
1947  : "sahs";
1948 
1949  $notes_gui = new ilNoteGUI($this->object->getId(),
1950  (int) $node_id, $node_type);
1951 // if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1952 // {
1953 // $notes_gui->enablePublicNotesDeletion(true);
1954 // }
1955  $notes_gui->enablePrivateNotes();
1956  $notes_gui->enablePublicNotes();
1957 
1958  $next_class = $ilCtrl->getNextClass($this);
1959  if ($next_class == "ilnotegui")
1960  {
1961  $html = $this->ctrl->forwardCommand($notes_gui);
1962  }
1963  else
1964  {
1965  $html = $notes_gui->getNotesHTML();
1966  }
1967  return $html;
1968  }
1969 
1973  function insertChapter($a_redirect = true)
1974  {
1975  global $ilCtrl, $lng;
1976 
1977  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
1978 
1979  $slm_tree =& new ilTree($this->object->getId());
1980  $slm_tree->setTreeTablePK("slm_id");
1981  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
1982 
1985 
1986  if (!ilSCORM2004OrganizationHFormGUI::getPostFirstChild()) // insert after node id
1987  {
1988  $parent_id = $slm_tree->getParentId($node_id);
1989  $target = $node_id;
1990  }
1991  else // insert as first child
1992  {
1993  $parent_id = $node_id;
1994  $target = IL_FIRST_NODE;
1995  }
1996  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php");
1997  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1998 
1999  $chap_ids = array();
2000  for ($i = 1; $i <= $num; $i++)
2001  {
2002  $chap = new ilSCORM2004Chapter($this->object);
2003  $chap->setTitle($lng->txt("sahs_new_chapter"));
2004  $chap->setSLMId($this->object->getId());
2005  $chap->create();
2006  ilSCORM2004Node::putInTree($chap, $parent_id, $target);
2007  $chap_ids[] = $chap->getId();
2008  }
2009  $chap_ids = array_reverse($chap_ids);
2010  $chap_ids = implode($chap_ids, ":");
2011 
2012  if ($a_redirect)
2013  {
2014  $ilCtrl->setParameter($this, "highlight", $chap_ids);
2015  $ilCtrl->redirect($this, "showOrganization", "node_".$node_id);
2016  }
2017  return array("node_id" => $node_id, "items" => $chap_ids);
2018  }
2019 
2023  function insertSco($a_redirect = true)
2024  {
2025  global $ilCtrl, $lng;
2026 
2027  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
2028 
2029  $slm_tree =& new ilTree($this->object->getId());
2030  $slm_tree->setTreeTablePK("slm_id");
2031  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
2032 
2035 
2036  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
2037  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2038 
2039  if (!ilSCORM2004OrganizationHFormGUI::getPostFirstChild()) // insert after node id
2040  {
2041  $parent_id = $slm_tree->getParentId($node_id);
2042  $target = $node_id;
2043  }
2044  else // insert as first child
2045  {
2046  $parent_id = $node_id;
2047  $target = IL_FIRST_NODE;
2048  }
2049 
2050  $sco_ids = array();
2051  for ($i = 1; $i <= $num; $i++)
2052  {
2053  $sco = new ilSCORM2004Sco($this->object);
2054  $sco->setTitle($lng->txt("sahs_new_sco"));
2055  $sco->setSLMId($this->object->getId());
2056  $sco->create();
2057  ilSCORM2004Node::putInTree($sco, $parent_id, $target);
2058  $sco_ids[] = $sco->getId();
2059  }
2060  $sco_ids = array_reverse($sco_ids);
2061  $sco_ids = implode($sco_ids, ":");
2062 
2063  if ($a_redirect)
2064  {
2065  $ilCtrl->setParameter($this, "highlight", $sco_ids);
2066  $ilCtrl->redirect($this, "showOrganization", "node_".$node_id);
2067  }
2068  return array("node_id" => $node_id, "items" => $sco_ids);
2069  }
2070 
2074  function insertAsset($a_redirect = true)
2075  {
2076  global $ilCtrl, $lng;
2077 
2078  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
2079 
2080  $slm_tree =& new ilTree($this->object->getId());
2081  $slm_tree->setTreeTablePK("slm_id");
2082  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
2083 
2086 
2087  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php");
2088  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2089 
2090  if (!ilSCORM2004OrganizationHFormGUI::getPostFirstChild()) // insert after node id
2091  {
2092  $parent_id = $slm_tree->getParentId($node_id);
2093  $target = $node_id;
2094  }
2095  else // insert as first child
2096  {
2097  $parent_id = $node_id;
2098  $target = IL_FIRST_NODE;
2099  }
2100 
2101  $ass_ids = array();
2102  for ($i = 1; $i <= $num; $i++)
2103  {
2104  $ass = new ilSCORM2004Asset($this->object);
2105  $ass->setTitle($lng->txt("sahs_new_asset"));
2106  $ass->setSLMId($this->object->getId());
2107  $ass->create();
2108  ilSCORM2004Node::putInTree($ass, $parent_id, $target);
2109  $ass_ids[] = $ass->getId();
2110  }
2111  $ass_ids = array_reverse($ass_ids);
2112  $ass_ids = implode($ass_ids, ":");
2113 
2114  if ($a_redirect)
2115  {
2116  $ilCtrl->setParameter($this, "highlight", $ass_ids);
2117  $ilCtrl->redirect($this, "showOrganization", "node_".$node_id);
2118  }
2119  return array("node_id" => $node_id, "items" => $ass_ids);
2120  }
2121 
2125  function insertPage($a_redirect = true)
2126  {
2127  global $ilCtrl, $lng;
2128 
2129  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
2130 
2131  $slm_tree =& new ilTree($this->object->getId());
2132  $slm_tree->setTreeTablePK("slm_id");
2133  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
2134 
2137 
2138  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
2139  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2140  if (!ilSCORM2004OrganizationHFormGUI::getPostFirstChild()) // insert after node id
2141  {
2142  $parent_id = $slm_tree->getParentId($node_id);
2143  $target = $node_id;
2144  }
2145  else // insert as first child
2146  {
2147  $parent_id = $node_id;
2148  $target = IL_FIRST_NODE;
2149  }
2150 
2151  $page_ids = array();
2152  for ($i = 1; $i <= $num; $i++)
2153  {
2154  $page = new ilSCORM2004PageNode($this->object);
2155  $page->setTitle($lng->txt("sahs_new_page"));
2156  $page->setSLMId($this->object->getId());
2157  $page->create();
2158  ilSCORM2004Node::putInTree($page, $parent_id, $target);
2159  $page_ids[] = $page->getId();
2160  }
2161  $page_ids = array_reverse($page_ids);
2162  $page_ids = implode($page_ids, ":");
2163 
2164  if ($a_redirect)
2165  {
2166  $ilCtrl->setParameter($this, "highlight", $page_ids);
2167  $ilCtrl->redirect($this, "showOrganization", "node_".$node_id);
2168  }
2169  return array("node_id" => $node_id, "items" => $page_ids);
2170  }
2171 
2172 
2177  {
2178 
2179  global $ilCtrl,$lng, $tpl;
2180 
2181  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
2182  include_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004SeqTemplate.php");
2183 
2184  $templates = array();
2185  $description = null;
2186  $image = null;
2187 
2188  $default_identifier = $_POST["identifier"];
2189 
2190  //get available templates
2191  $arr_templates = ilSCORM2004SeqTemplate::availableTemplates();
2192 
2193  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scormeditor_seq_chooser.html", "Modules/Scorm2004");
2194 
2195  $this->tpl->setCurrentBlock("option_item");
2196 
2197  $active = null;
2198  foreach ($arr_templates as $templ)
2199  {
2200  $sel= "";
2201  $item_data = $templ->getMetadataProperties();
2202  $item_data['identifier'] = $templ->getIdentifier();
2203  array_push($templates,$item_data);
2204  if ($default_identifier == $item_data['identifier']) {$sel = 'selected'; $active = $item_data;}
2205  $this->tpl->setVariable("VAL_SELECTED",$sel );
2206  $this->tpl->setVariable("VAL_IDENTIFIER",$item_data['identifier'] );
2207  $this->tpl->setVariable("VAL_TITLE",$item_data['title'] );
2208  $this->tpl->parseCurrentBlock();
2209  }
2210 
2211  //default
2212  if ($active == null )
2213  {
2214  $this->saveAllTitles(false);
2215  $description = $templates[0]['description'];
2216  $image = $templates[0]['thumbnail'];
2217  } else {
2218  $description = $active['description'];
2219  $image = $active['thumbnail'];
2220  }
2221 
2222  $this->tpl->setVariable("VAL_DESCRIPTION",$description);
2223  $this->tpl->setVariable("VAL_IMAGE",ilSCORM2004SeqTemplate::SEQ_TEMPLATE_DIR."/images/".$image);
2224 
2225  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2226  $this->tpl->setVariable("BTN_NAME", "insertScenario");
2227  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
2228  $this->tpl->setVariable("TXT_INSERT", $this->lng->txt("insert"));
2229  $this->tpl->setVariable("TXT_CHANGE", $this->lng->txt("change"));
2230 
2231  $this->tpl->setVariable("TXT_TITLE", "Choose Sequencing Template");
2232 
2233  $node_id = $_POST["node_id"];
2234  $first_child = $_POST["first_child"];
2235 
2236  if (!$node_id) {$node_id = ilSCORM2004OrganizationHFormGUI::getPostNodeId();}
2237  if (!$first_child) {$first_child = ilSCORM2004OrganizationHFormGUI::getPostFirstChild();}
2238 
2239  $this->tpl->setVariable("VAL_NODE_ID", $node_id);
2240  $this->tpl->setVariable("VAL_FIRST_CHILD", $first_child);
2241 
2242  }
2243 
2244 
2248  function insertScenario()
2249  {
2250  global $ilCtrl;
2251 
2252  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
2253 
2254  $slm_tree =& new ilTree($this->object->getId());
2255  $slm_tree->setTreeTablePK("slm_id");
2256  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
2257 
2258  $node_id = $_POST["node_id"];
2259 
2260  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
2261  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2262  include_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004SeqTemplate.php");
2263 
2264  if (!$_POST["first_child"]) // insert after node id
2265  {
2266  $parent_id = $slm_tree->getParentId($node_id);
2267  $target = $node_id;
2268  }
2269  else // insert as first child
2270  {
2271  $parent_id = $node_id;
2272  $target = IL_FIRST_NODE;
2273  }
2274 
2275  $template = new ilSCORM2004SeqTemplate($_POST["identifier"]);
2276  $id = $template->insertTemplateForObjectAtParent($this->object,$parent_id,$target);
2277  $ilCtrl->setParameter($this, "highlight", $id);
2278  $ilCtrl->redirect($this, "showOrganization", "node_".$node_id);
2279 
2280  }
2281 
2285  function insertSpecialPage($a_redirect = true)
2286  {
2287  $this->insertTemplateGUI($a_redirect, true);
2288  }
2289 
2290 
2294  function insertTemplateGUI($a_redirect = true, $a_special_page = false)
2295  {
2296  global $ilCtrl,$lng, $tpl;
2297 
2298  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
2299 
2300  $arr_templates = ilPageLayout::activeLayouts($a_special_page, ilPageLayout::MODULE_SCORM);
2301 
2302  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scormeditor_page_layout_chooser.html", "Modules/Scorm2004");
2303 
2304  $this->tpl->setCurrentBlock("option_item");
2305 
2306  $count = 0;
2307  foreach ($arr_templates as $templ)
2308  {
2309  $count++;
2310  $sel= "";
2311  $templ->readObject();
2312  $this->tpl->setVariable("VAL_LAYOUT_TITLE",$templ->getTitle());
2313  $this->tpl->setVariable("VAL_LAYOUT_IMAGE",$templ->getPreview());
2314  $this->tpl->setVariable("VAL_LAYOUT_ID",$templ->getId());
2315  $this->tpl->setVariable("VAL_DISPLAY","inline");
2316  if ($count==1) {
2317  $this->tpl->setVariable("VAL_CHECKED","checked");
2318  }
2319  if ($count%4 == 0) {
2320  $this->tpl->setVariable("END_ROW","</tr>");
2321  }
2322  if ($count == 1 || ($count-1)%4 == 0) {
2323  $this->tpl->setVariable("BEGIN_ROW","<tr>");
2324  }
2325  $this->tpl->parseCurrentBlock();
2326  }
2327 
2328  //matrix table
2329  if ($count%4!=0) {
2330  $rest = 4-($count%4);
2331  } else {
2332  $rest=0;
2333  }
2334 
2335  for ($i=1;$i<=$rest;$i++) {
2336  $this->tpl->setVariable("VAL_DISPLAY","none");
2337  $this->tpl->setVariable("VAL_LAYOUT_ID",$templ->getId());
2338 
2339  if ($i == $rest) {
2340  $this->tpl->setVariable("END_ROW","</tr>");
2341  }
2342  $this->tpl->parseCurrentBlock();
2343  }
2344 
2345  //empty cells and closing <tr>
2346 
2347  $this->tpl->setVariable("VAL_NODE_ID",ilSCORM2004OrganizationHFormGUI::getPostNodeId());
2348  $this->tpl->setVariable("VAL_MULTI", ilSCORM2004OrganizationHFormGUI::getPostMulti());
2349  $this->tpl->setVariable("VAL_FIRST_CHILD", ilSCORM2004OrganizationHFormGUI::getPostFirstChild());
2350  $this->tpl->setVariable("VAL_OBJ_ID", ilSCORM2004OrganizationHFormGUI::getPostFirstChild());
2351 
2352  $ilCtrl->saveParameter($this,"obj_id");
2353 
2354  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2355 
2356  $this->tpl->setVariable("BTN_NAME", "insertTemplate");
2357  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
2358  $this->tpl->setVariable("TXT_INSERT", $this->lng->txt("create"));
2359  $this->tpl->setVariable("CMD_CANCEL", "showOrganization");
2360 
2361  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
2362  $this->tpl->setVariable("TXT_INSERT", $this->lng->txt("insert"));
2363  $this->tpl->setVariable("TXT_CHANGE", $this->lng->txt("change"));
2364  if ($a_special_page)
2365  {
2366  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("sahs_choose_special_page"));
2367  }
2368  else
2369  {
2370  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("sahs_choose_page_template"));
2371  }
2372  }
2373 
2374 
2375 
2379  function insertTemplate($a_redirect = true)
2380  {
2381  global $ilCtrl, $lng;
2382 
2383  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
2384 
2385  $slm_tree =& new ilTree($this->object->getId());
2386  $slm_tree->setTreeTablePK("slm_id");
2387  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
2388 
2389  $num = $_POST["multi"];
2390  $node_id = $_POST["node_id"];
2391  $layout_id = $_POST["layout_id"];
2392 
2393 
2394  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
2395  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2396 
2397  if (!$_POST["first_child"]) // insert after node id
2398  {
2399  $parent_id = $slm_tree->getParentId($node_id);
2400  $target = $node_id;
2401  }
2402  else // insert as first child
2403  {
2404  $parent_id = $node_id;
2405  $target = IL_FIRST_NODE;
2406  }
2407 
2408  $page_ids = array();
2409  for ($i = 1; $i <= $num; $i++)
2410  {
2411  $page = new ilSCORM2004PageNode($this->object);
2412  $page->setTitle($lng->txt("sahs_new_page"));
2413  $page->setSLMId($this->object->getId());
2414  $page->create(false,$layout_id);
2415  ilSCORM2004Node::putInTree($page, $parent_id, $target);
2416  $page_ids[] = $page->getId();
2417  }
2418  $page_ids = array_reverse($page_ids);
2419  $page_ids = implode($page_ids, ":");
2420 
2421  if ($a_redirect)
2422  {
2423  if ($_GET["obj_id"] != "")
2424  {
2425  $this->jumpToNode($node_id, $page_ids);
2426  }
2427  else
2428  {
2429  $ilCtrl->setParameter($this, "highlight", $page_ids);
2430  $ilCtrl->redirect($this, "showOrganization", "node_".$node_id);
2431  }
2432  }
2433  }
2434 
2438  function expandAll($a_redirect = true)
2439  {
2440  $_GET["scexpand"] = "";
2441  $mtree = $this->object->getTree();
2442  $n_id = ($_GET["obj_id"] > 0)
2443  ? $_GET["obj_id"]
2444  : $mtree->readRootId();
2445  $stree = $mtree->getSubTree($mtree->getNodeData($n_id));
2446  $n_arr = array();
2447  foreach ($stree as $n)
2448  {
2449  $n_arr[] = $n["child"];
2450  $_SESSION["scexpand"] = $n_arr;
2451  }
2452  $this->saveAllTitles($a_redirect);
2453  }
2454 
2458  function collapseAll($a_redirect = true)
2459  {
2460  $_GET["scexpand"] = "";
2461  $mtree = $this->object->getTree();
2462  $n_id = ($_GET["obj_id"] > 0)
2463  ? $_GET["obj_id"]
2464  : $mtree->readRootId();
2465  $stree = $mtree->getSubTree($mtree->getNodeData($n_id));
2466  $old = $_SESSION["scexpand"];
2467  foreach ($stree as $n)
2468  {
2469  if (in_array($n["child"], $old) && $n["child"] != $n_id)
2470  {
2471  $k = array_search($n["child"], $old);
2472  unset($old[$k]);
2473  }
2474  }
2475  $_SESSION["scexpand"] = $old;
2476  $this->saveAllTitles($a_redirect);
2477  }
2478 
2482  function saveAllTitles($a_redirect = true)
2483  {
2484  global $ilCtrl;
2485 
2486  if (is_array($_POST["title"]))
2487  {
2488  include_once("./Services/MetaData/classes/class.ilMD.php");
2489  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
2490  foreach($_POST["title"] as $id => $title)
2491  {
2492  $node_obj = ilSCORM2004NodeFactory::getInstance($this->object, $id, false);
2493  if (is_object($node_obj))
2494  {
2495  // Update Title and description
2496  $md = new ilMD($this->object->getId(), $id, $node_obj->getType());
2497  $md_gen = $md->getGeneral();
2498  $md_gen->setTitle(ilUtil::stripSlashes($title));
2499  $md_gen->update();
2500  $md->update();
2502  }
2503  }
2504  }
2505  if ($a_redirect)
2506  {
2507  $ilCtrl->redirect($this, "showOrganization");
2508  }
2509  }
2510 
2516  function deleteNodes($a_form_action = "")
2517  {
2518  global $lng, $tpl;
2519 
2520  if(!isset($_POST["id"]))
2521  {
2522  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2523  }
2524 
2525  // SAVE POST VALUES
2526  $_SESSION["saved_post"] = $_POST["id"];
2527 
2528  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2529  $confirmation_gui = new ilConfirmationGUI();
2530 
2531  if ($a_form_action == "")
2532  {
2533  $cmd = ($_GET["backcmd"] == "")
2534  ? "showOrganization"
2535  : $_GET["backcmd"];
2536  $this->ctrl->setParameter($this, "backcmd", $cmd);
2537  $a_form_action = $this->ctrl->getFormAction($this);
2538  }
2539  $confirmation_gui->setFormAction($a_form_action);
2540  $confirmation_gui->setHeaderText($this->lng->txt("info_delete_sure"));
2541 
2542  // Add items to delete
2543  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
2544  foreach($_POST["id"] as $id)
2545  {
2546  if ($id != IL_FIRST_NODE)
2547  {
2548  $node_obj = ilSCORM2004NodeFactory::getInstance($this->object, $id, false);
2549  $confirmation_gui->addItem("id[]", $node_obj->getId(),
2550  $node_obj->getTitle(), ilUtil::getImagePath("icon_".$node_obj->getType().".png"));
2551  }
2552  }
2553 
2554  $confirmation_gui->setCancel($lng->txt("cancel"), "cancelDelete");
2555  $confirmation_gui->setConfirm($lng->txt("confirm"), "confirmedDelete");
2556 
2557  $tpl->setContent($confirmation_gui->getHTML());
2558  }
2559 
2563  function cancelDelete()
2564  {
2565  $this->ctrl->redirect($this, $_GET["backcmd"]);
2566  }
2567 
2571  function confirmedDelete($a_redirect = true)
2572  {
2573  global $ilCtrl;
2574 
2575  $tree = new ilTree($this->object->getId());
2576  $tree->setTableNames('sahs_sc13_tree','sahs_sc13_tree_node');
2577  $tree->setTreeTablePK("slm_id");
2578 
2579  // delete all selected objects
2580  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
2581  foreach ($_POST["id"] as $id)
2582  {
2583  if ($id != IL_FIRST_NODE)
2584  {
2585  $obj = ilSCORM2004NodeFactory::getInstance($this->object, $id, false);
2586  $node_data = $tree->getNodeData($id);
2587  if (is_object($obj))
2588  {
2589  $obj->setSLMId($this->object->getId());
2590 
2591  /*include_once("./Services/History/classes/class.ilHistory.php");
2592  ilHistory::_createEntry($this->object->getId(), "delete_".$obj->getType(),
2593  array(ilLMObject::_lookupTitle($id), $id),
2594  $this->object->getType());*/
2595 
2596  $obj->delete();
2597  }
2598  if($tree->isInTree($id))
2599  {
2600  $tree->deleteTree($node_data);
2601  }
2602  }
2603  }
2604 
2605  // check the tree
2606  // $this->object->checkTree();
2607 
2608  // feedback
2609  ilUtil::sendInfo($this->lng->txt("info_deleted"),true);
2610 
2611  if ($a_redirect)
2612  {
2613  $ilCtrl->redirect($this, "showOrganization");
2614  }
2615  }
2616 
2620  function proceedDragDrop()
2621  {
2622  global $ilCtrl;
2623 
2624  $this->object->executeDragDrop($_POST["il_hform_source_id"], $_POST["il_hform_target_id"],
2625  $_POST["il_hform_fc"], $_POST["il_hform_as_subitem"]);
2626  $ilCtrl->redirect($this, "showOrganization");
2627  }
2628 
2632  function copyItems($a_return = "showOrganization")
2633  {
2634  global $ilCtrl, $lng;
2635 
2636  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2637 
2638  $items = ilUtil::stripSlashesArray($_POST["id"]);
2639  $todel = array(); // delete IDs < 0 (needed for non-js editing)
2640  foreach($items as $k => $item)
2641  {
2642  if ($item < 0)
2643  {
2644  $todel[] = $k;
2645  }
2646  }
2647  foreach($todel as $k)
2648  {
2649  unset($items[$k]);
2650  }
2651  if (!ilSCORM2004Node::uniqueTypesCheck($items))
2652  {
2653  ilUtil::sendFailure($lng->txt("sahs_choose_pages_chap_scos_ass_only"), true);
2654  $ilCtrl->redirect($this, $a_return);
2655  }
2656  ilSCORM2004Node::clipboardCopy($this->object->getId(), $items);
2657 
2658  // @todo: move this to a service since it can be used here, too
2659  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
2661  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
2662 
2663  $ilCtrl->redirect($this, $a_return);
2664  }
2665 
2669  function cutItems($a_return = "showOrganization")
2670  {
2671  global $ilCtrl, $lng;
2672 
2673  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2674 
2675  $items = ilUtil::stripSlashesArray($_POST["id"]);
2676  $todel = array(); // delete IDs < 0 (needed for non-js editing)
2677  foreach($items as $k => $item)
2678  {
2679  if ($item < 0)
2680  {
2681  $todel[] = $k;
2682  }
2683  }
2684  foreach($todel as $k)
2685  {
2686  unset($items[$k]);
2687  }
2688 
2689  if (!ilSCORM2004Node::uniqueTypesCheck($items))
2690  {
2691  ilUtil::sendFailure($lng->txt("sahs_choose_pages_chap_scos_ass_only"), true);
2692  $ilCtrl->redirect($this, $a_return);
2693  }
2694 
2695  ilSCORM2004Node::clipboardCut($this->object->getId(), $items);
2696 
2697  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
2699 
2700  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
2701 
2702  $ilCtrl->redirect($this, $a_return);
2703  }
2704 
2708  function insertPageClip()
2709  {
2710  global $ilCtrl, $ilUser;
2711 
2712  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2713  ilSCORM2004Node::insertPageClip($this->object);
2714 
2715  $ilCtrl->redirect($this, "showOrganization",
2717  }
2718 
2722  function insertScoClip()
2723  {
2724  global $ilCtrl, $ilUser;
2725 
2726  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2727  ilSCORM2004Node::insertScoClip($this->object);
2728 
2729  $ilCtrl->redirect($this, "showOrganization",
2731  }
2732 
2736  function insertAssetClip()
2737  {
2738  global $ilCtrl, $ilUser;
2739 
2740  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2741  ilSCORM2004Node::insertAssetClip($this->object);
2742 
2743  $ilCtrl->redirect($this, "showOrganization",
2745  }
2746 
2751  {
2752  global $ilCtrl, $ilUser;
2753 
2754  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2755  ilSCORM2004Node::insertChapterClip($this->object);
2756 
2757  $ilCtrl->redirect($this, "showOrganization",
2759  }
2760 
2761 
2763  {
2764  $export = new ilScorm2004Export($this->object,'SCORM 2004 4th');
2765  $export->buildExportFile();
2766  ilUtil::sendSuccess($this->lng->txt("exp_file_created"), true);
2767  $this->ctrl->redirect($this, "showExportList");
2768  }
2769 
2771  {
2772  $export = new ilScorm2004Export($this->object,'SCORM 2004 3rd');
2773  $export->buildExportFile();
2774  ilUtil::sendSuccess($this->lng->txt("exp_file_created"), true);
2775  $this->ctrl->redirect($this, "showExportList");
2776  }
2777 
2778  function exportScorm12()
2779  {
2780  $export = new ilScorm2004Export($this->object,'SCORM 1.2');
2781  $export->buildExportFile();
2782  ilUtil::sendSuccess($this->lng->txt("exp_file_created"), true);
2783  $this->ctrl->redirect($this, "showExportList");
2784  }
2785 
2786  function exportHTML()
2787  {
2788  $export = new ilScorm2004Export($this->object,'HTML');
2789  $export->buildExportFile();
2790  ilUtil::sendSuccess($this->lng->txt("exp_file_created"), true);
2791  $this->ctrl->redirect($this, "showExportList");
2792  }
2793 
2794  function exportHTMLOne()
2795  {
2796  $export = new ilScorm2004Export($this->object,'HTMLOne');
2797  $export->buildExportFile();
2798  ilUtil::sendSuccess($this->lng->txt("exp_file_created"), true);
2799  $this->ctrl->redirect($this, "showExportList");
2800  }
2801 
2802  function exportISO()
2803  {
2804  $export = new ilScorm2004Export($this->object,'ISO');
2805  if(!$export->buildExportFile())
2806  {
2807  if(!PATH_TO_MKISOFS)
2808  $this->ilias->raiseError($this->lng->txt("no_mkisofs_configured"),$this->ilias->error_obj->MESSAGE);
2809  }
2810  $this->ctrl->redirect($this, "showExportList");
2811  }
2812 
2813  function exportPDF()
2814  {
2815  $export = new ilScorm2004Export($this->object,'PDF');
2816  $export->buildExportFile();
2817  $this->ctrl->redirect($this, "showExportList");
2818  }
2819 
2821  {
2822  if(!isset($_POST["file"]))
2823  {
2824  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2825  }
2826 
2827  if (count($_POST["file"]) > 1)
2828  {
2829  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2830  }
2831  $export = new ilSCORM2004Export($this->object);
2832  $export_dir = $export->getExportDirectoryForType($_POST['type'][$_POST['file'][0]]);
2833  ilUtil::deliverFile($export_dir."/".$_POST['file'][0], $_POST['file'][0]);
2834  }
2835 
2840  {
2841  if(!isset($_POST["file"]))
2842  {
2843  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
2844  $this->ctrl->redirect($this, "showExportList");
2845  }
2846 
2847  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
2848  $export_files = $this->object->getExportFiles();
2849 
2850  include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ExportTableGUI.php";
2851  $table_gui = new ilSCORM2004ExportTableGUI($this, 'showExportList', true);
2852  $data = array();
2853  foreach ($export_files as $exp_file)
2854  {
2855  foreach ($_POST['file'] as $delete_file)
2856  {
2857  if (strcmp($delete_file, $exp_file['file']) == 0)
2858  {
2859  $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($exp_file["type"]))
2860  ? " <b>(".$this->lng->txt("public").")<b>"
2861  : "";
2862  $file_arr = explode("__", $exp_file["file"]);
2863  array_push($data, array('file' => $exp_file['file'], 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => $exp_file['size'], 'type' => $exp_file['type'].$public_str));
2864  }
2865  }
2866  }
2867  $table_gui->setData($data);
2868  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2869  }
2870 
2875  {
2876  ilSession::clear("ilExportFiles");
2877  $this->ctrl->redirect($this, "showExportList");
2878  }
2879 
2880 
2884  function deleteExportFile()
2885  {
2886  include_once "./Services/Utilities/classes/class.ilUtil.php";
2887  $export = new ilSCORM2004Export($this->object);
2888  foreach($_POST['file'] as $idx => $file)
2889  {
2890  $export_dir = $export->getExportDirectoryForType($_POST['type'][$idx]);
2891  $exp_file = $export_dir."/".$file;
2892  if (@is_file($exp_file))
2893  {
2894  unlink($exp_file);
2895  }
2896  }
2897  ilUtil::sendSuccess($this->lng->txt('msg_deleted_export_files'), true);
2898  $this->ctrl->redirect($this, "showExportList");
2899  }
2900 
2901  /*
2902  * download export file
2903  */
2905  {
2906  if(!isset($_POST["file"]))
2907  {
2908  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2909  }
2910  if (count($_POST["file"]) > 1)
2911  {
2912  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2913  }
2914 
2915  $export = new ilSCORM2004Export($this->object);
2916  $file = $_POST['file'][0];
2917  $type = $_POST['type'][$_POST['file'][0]];
2918 
2919  if ($this->object->getPublicExportFile($type) == $file)
2920  {
2921  $this->object->setPublicExportFile($type, "");
2922  }
2923  else
2924  {
2925  $this->object->setPublicExportFile($type, $file);
2926  }
2927  $this->object->update();
2928  $this->ctrl->redirect($this, "showExportList");
2929  }
2930 
2931  /*
2932  * perform silent scorm 2004 export and import for view player
2933  */
2934  function preview()
2935  {
2936  global $ilias;
2937 
2938  $export = new ilScorm2004Export($this->object,'SCORM 2004 3rd');
2939  $zipfile = $export->buildExportFile();
2940  $zipPathinfo = pathinfo($zipfile);
2941  $file_path = $this->object->getDataDirectory()."/".($zipPathinfo["basename"]);
2942  copy($zipfile,$file_path);
2943  unlink($zipfile);
2944 
2945  ilUtil::unzip($file_path,true);
2946  ilUtil::renameExecutables($this->object->getDataDirectory());
2947  unlink($file_path);
2948 
2949  include_once ("./Modules/Scorm2004/classes/ilSCORM13Package.php");
2950  $rte_pkg = new ilSCORM13Package();
2951  $rte_pkg->il_import($this->object->getDataDirectory(),$this->object->getId(),$ilias,false,true);
2952 
2953  //increase module version is it necessary?
2954  //$this->object->setModuleVersion($module_version+1);
2955  //$this->object->update();
2956 
2957  //redirect to view player
2958  ilUtil::redirect("ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=".$this->object->getRefID()."&envEditor=1");
2959  }
2960 
2961 
2962 }
2963 ?>