ILIAS  eassessment Revision 61809
 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  $this->type = "sahs";
38  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
39  #$this->tabs_gui =& new ilTabsGUI();
40  }
41 
45  function executeCommand()
46  {
47  global $ilAccess, $ilCtrl, $tpl, $ilTabs;
48 
49  $next_class = $ilCtrl->getNextClass($this);
50  $cmd = $ilCtrl->getCmd();
51 
52  // update expander
53  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
54  $form_gui = new ilSCORM2004OrganizationHFormGUI();
55  $form_gui->setTree($this->getEditTree());
56  $form_gui->updateExpanded();
57 
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  break;
80 
81  // sequencing chapters
82  case "ilscorm2004seqchaptergui":
83  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004SeqChapterGUI.php");
84  $chap_gui = new ilSCORM2004SeqChapterGUI($this->object, $_GET["obj_id"]);
85  $chap_gui->setParentGUI($this);
86  return $ilCtrl->forwardCommand($chap_gui);
87  break;
88 
89  // scos
90  case "ilscorm2004scogui":
91  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004ScoGUI.php");
92  $sco_gui = new ilSCORM2004ScoGUI($this->object, $_GET["obj_id"]);
93  $sco_gui->setParentGUI($this);
94  return $ilCtrl->forwardCommand($sco_gui);
95  break;
96 
97  // pages
98  case "ilscorm2004pagenodegui":
99  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNodeGUI.php");
100  $page_gui = new ilSCORM2004PageNodeGUI($this->object, $_GET["obj_id"]);
101  $page_gui->setParentGUI($this);
102  $html = $ilCtrl->forwardCommand($page_gui);
103  break;
104 
105  default:
106  return parent::executeCommand();
107  break;
108  }
109  }
110 
116  function frameset()
117  {
118  if ($this->object->getEditable()) // show editing frameset
119  {
120  include_once("./Services/Frameset/classes/class.ilFramesetGUI.php");
121  $fs_gui = new ilFramesetGUI();
122 
123  $fs_gui->setFramesetTitle($this->lng->txt("editor"));
124  $fs_gui->setMainFrameName("content");
125  $fs_gui->setSideFrameName("tree");
126  $this->ctrl->setParameter($this, "active_node", $_GET["obj_id"]);
127  $fs_gui->setSideFrameSource($this->ctrl->getLinkTarget($this, "showTree"));
128  $this->ctrl->setParameter($this, "activeNode", "");
129  if ($_GET["obj_id"] > 0)
130  {
131  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
133  }
134  if (in_array($type, array("sco", "chap", "seqc", "page")))
135  {
136  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
137  $fs_gui->setMainFrameSource($this->ctrl->getLinkTarget($this, "jumpToNode"));
138  }
139  else
140  {
141  $fs_gui->setMainFrameSource($this->ctrl->getLinkTarget($this, "properties"));
142  }
143  $fs_gui->show();
144  exit;
145  }
146  else // otherwise show standard frameset
147  {
148  $this->tpl = new ilTemplate("tpl.sahs_edit_frameset.html", false, false, "Modules/ScormAicc");
149  $this->tpl->setVariable("SRC",
150  $this->ctrl->getLinkTarget($this, "properties"));
151  $this->tpl->show("DEFAULT", false);
152  }
153  exit;
154  }
155 
156  function jumpToNode($a_anchor_node = "", $a_highlight_ids = "")
157  {
158  global $ilCtrl;
159 
160  $anchor = ($a_anchor_node != "")
161  ? "node_".$a_anchor_node
162  : "";
163 
164  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
166  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
167  switch($type)
168  {
169  case "sco":
170  $ilCtrl->setParameterByClass("ilscorm2004scogui", "highlight", $a_highlight_ids);
171  $ilCtrl->redirectByClass("ilscorm2004scogui", "showOrganization", $anchor);
172  case "chap":
173  $ilCtrl->setParameterByClass("ilscorm2004chaptergui", "highlight", $a_highlight_ids);
174  $ilCtrl->redirectByClass("ilscorm2004chaptergui", "showOrganization", $anchor);
175  case "seqc":
176  $ilCtrl->setParameterByClass("ilscorm2004seqchaptergui", "highlight", $a_highlight_ids);
177  $ilCtrl->redirectByClass("ilscorm2004seqchaptergui", "showOrganization", $anchor);
178  case "page":
179  $ilCtrl->redirectByClass("ilscorm2004pagenodegui", "edit");
180  }
181  }
182 
186  function properties()
187  {
188  global $rbacsystem, $tree, $tpl, $lng, $ilToolbar;;
189 
190  $this->setSubTabs("settings", "general_settings");
191 
192  $lng->loadLanguageModule("style");
193 
194  if ($this->object->editable!=1)
195  {
196  // view
197  $ilToolbar->addButton($this->lng->txt("view"),
198  "ilias.php?baseClass=ilSAHSPresentationGUI&amp;ref_id=".$this->object->getRefID(),
199  "_blank");
200 
201  // upload new version
202  $ilToolbar->addButton($this->lng->txt("cont_sc_new_version"),
203  $this->ctrl->getLinkTarget($this, "newModuleVersion"));
204  }
205  else
206  {
207  // preview
208 /* $ilToolbar->addButton($this->lng->txt("cont_sc_preview"),
209  $this->ctrl->getLinkTarget($this, "preview"),
210  "_blank");*/
211  }
212 
213 
214 
215  if ($this->object->editable!=1)
216  {
217  // scorm lm properties
218  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scorm2004_properties.html", "Modules/Scorm2004");
219  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
220  $this->tpl->setVariable("TXT_PROPERTIES", $this->lng->txt("cont_lm_properties"));
221 
222  // version
223  $this->tpl->setVariable("TXT_VERSION", $this->lng->txt("cont_sc_version").":");
224  $this->tpl->setVariable("VAL_VERSION", $this->object->getModuleVersion());
225 
226  $this->tpl->setCurrentBlock("editable");
227  // online
228  $this->tpl->setVariable("TXT_ONLINE", $this->lng->txt("cont_online"));
229  $this->tpl->setVariable("CBOX_ONLINE", "cobj_online");
230  $this->tpl->setVariable("VAL_ONLINE", "y");
231  if ($this->object->getOnline())
232  {
233  $this->tpl->setVariable("CHK_ONLINE", "checked");
234  }
235 
236  // default lesson mode
237  $this->tpl->setVariable("TXT_LESSON_MODE", $this->lng->txt("cont_def_lesson_mode"));
238  $lesson_modes = array("normal" => $this->lng->txt("cont_sc_less_mode_normal"),
239  "browse" => $this->lng->txt("cont_sc_less_mode_browse"));
240  $sel_lesson = ilUtil::formSelect($this->object->getDefaultLessonMode(),
241  "lesson_mode", $lesson_modes, false, true);
242  $this->tpl->setVariable("SEL_LESSON_MODE", $sel_lesson);
243 
244  // credit mode
245  $this->tpl->setVariable("TXT_CREDIT_MODE", $this->lng->txt("cont_credit_mode"));
246  $credit_modes = array("credit" => $this->lng->txt("cont_credit_on"),
247  "no_credit" => $this->lng->txt("cont_credit_off"));
248  $sel_credit = ilUtil::formSelect($this->object->getCreditMode(),
249  "credit_mode", $credit_modes, false, true);
250  $this->tpl->setVariable("SEL_CREDIT_MODE", $sel_credit);
251 
252  // auto review mode
253  $this->tpl->setVariable("TXT_AUTO_REVIEW", $this->lng->txt("cont_sc_auto_review"));
254  $this->tpl->setVariable("CBOX_AUTO_REVIEW", "auto_review");
255  $this->tpl->setVariable("VAL_AUTO_REVIEW", "y");
256  if ($this->object->getAutoReview())
257  {
258  $this->tpl->setVariable("CHK_AUTO_REVIEW", "checked");
259  }
260 
261  // max attempts
262  $this->tpl->setVariable("MAX_ATTEMPTS", $this->lng->txt("cont_sc_max_attempt"));
263  $this->tpl->setVariable("VAL_MAX_ATTEMPT", $this->object->getMaxAttempt());
264 
265  //unlimited session
266  $this->tpl->setVariable("TXT_SESSION", $this->lng->txt("cont_sc_usession"));
267  $this->tpl->setVariable("CBOX_SESSION", "cobj_session");
268  $this->tpl->setVariable("VAL_SESSION", "y");
269  if ($this->object->getSession())
270  {
271  $this->tpl->setVariable("CHK_SESSION", "checked");
272  }
273 
274 
275  // disable top menu
276  $this->tpl->setVariable("TXT_NOMENU", $this->lng->txt("cont_nomenu"));
277  $this->tpl->setVariable("CBOX_NOMENU", "cobj_nomenu");
278  $this->tpl->setVariable("VAL_NOMENU", "y");
279  if ($this->object->getNoMenu())
280  {
281  $this->tpl->setVariable("CHK_NOMENU", "checked");
282  }
283 
284  //disable left-side navigation
285  $this->tpl->setVariable("TXT_HIDENAVIG", $this->lng->txt("cont_hidenavig"));
286  $this->tpl->setVariable("CBOX_HIDENAVIG", "cobj_hidenavig");
287  $this->tpl->setVariable("VAL_HIDENAVIG", "y");
288  if ($this->object->getHideNavig())
289  {
290  $this->tpl->setVariable("CHK_HIDENAVIG", "checked");
291  }
292 
293  $this->tpl->setCurrentBlock("commands");
294  $this->tpl->setVariable("BTN_NAME", "saveProperties");
295  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
296  $this->tpl->parseCurrentBlock();
297  }
298 
299  if ($this->object->editable==1)
300  {
303  $tpl->setContent($this->form->getHTML());
304  }
305  }
306 
310  public function initPropertiesEditableForm()
311  {
312  global $lng, $ilCtrl, $tree, $rbacsystem;
313 
314  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
315  $this->form = new ilPropertyFormGUI();
316 
317  // glossary
318  $ne = new ilNonEditableValueGUI($lng->txt("obj_glo"), "glossary");
319  $this->form->addItem($ne);
320 
321  // number of tries
322  $ni = new ilNumberInputGUI($lng->txt("cont_qtries"), "q_tries");
323  $ni->setMaxLength(3);
324  $ni->setSize(3);
325  $this->form->addItem($ni);
326 
327  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
328  $parent_ref_id = $tree->getParentId((int) $_GET["ref_id"]);
329 
330  if (ilObject::_lookupType($this->object->getAssignedGlossary()) != "glo")
331  {
332  if ($rbacsystem->checkAccess("create", $parent_ref_id, "glo"))
333  {
334  $this->form->addCommandButton("createGlossary", $lng->txt("cont_glo_create"));
335  }
336  $this->form->addCommandButton("assignGlossary", $lng->txt("cont_glo_assign"));
337  }
338  else
339  {
340  $this->form->addCommandButton("detachGlossary", $lng->txt("cont_glo_detach"));
341  }
342 
343  $this->form->setTitle($lng->txt("cont_lm_properties"));
344  $this->form->setFormAction($ilCtrl->getFormAction($this));
345  }
346 
350  public function getPropertiesEditableValues()
351  {
352  $values = array();
353 
354  if (ilObject::_lookupType($this->object->getAssignedGlossary()) == "glo")
355  {
356  $values["glossary"] = ilObject::_lookupTitle($this->object->getAssignedGlossary());
357  }
358  else
359  {
360  $values["glossary"] = $this->lng->txt("cont_no_glossary");
361  }
362  $values["q_tries"] = $this->object->getTries();
363 
364  $this->form->setValuesByArray($values);
365  }
366 
370  function saveProperties()
371  {
372  global $ilSetting;
373 
374  if ($this->object->editable!=1) {
375  $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
376  $this->object->setCreditMode($_POST["credit_mode"]);
377  $this->object->setMaxAttempt($_POST["max_attempt"]);
378  $this->object->setAutoReview(ilUtil::yn2tf($_POST["auto_review"]));
379  $this->object->setDefaultLessonMode($_POST["lesson_mode"]);
380  $this->object->setSession(ilUtil::yn2tf($_POST["cobj_session"]));
381  $this->object->setNoMenu(ilUtil::yn2tf($_POST["cobj_nomenu"]));
382  $this->object->setHideNavig(ilUtil::yn2tf($_POST["cobj_hidenavig"]));
383  //$this->object->setDebug(ilUtil::yn2tf($_POST["cobj_debug"]));
384  //$this->object->setDebugPw($_POST["debug_pw"]);
385 
386  }
387  else
388  {
390  if ($this->form->checkInput())
391  {
392  $this->object->setTries($_POST["q_tries"]);
393  }
394  }
395  $this->object->update();
396  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
397  $this->ctrl->redirect($this, "properties");
398  }
399 
403  function detachGlossary()
404  {
405  global $ilCtrl;
406 
407  $this->object->setAssignedGlossary(0);
408  $this->object->update();
409  $ilCtrl->redirect($this, "properties");
410  }
411 
415  function createGlossary()
416  {
417  global $tpl;
418 
419  $this->initGlossaryCreationForm();
420  $tpl->setContent($this->form->getHTML());
421  }
422 
426  public function initGlossaryCreationForm()
427  {
428  global $lng, $ilCtrl;
429 
430  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
431  $this->form = new ilPropertyFormGUI();
432 
433  // title
434  $ti = new ilTextInputGUI($lng->txt("title"), "title");
435  $ti->setRequired(true);
436  $this->form->addItem($ti);
437 
438  // description
439  $ta = new ilTextAreaInputGUI($lng->txt("desc"), "description");
440  $this->form->addItem($ta);
441 
442  $this->form->addCommandButton("saveGlossary", $lng->txt("save"));
443  $this->form->addCommandButton("properties", $lng->txt("cancel"));
444 
445  $this->form->setTitle($lng->txt("cont_glo_create"));
446  $this->form->setFormAction($ilCtrl->getFormAction($this));
447  }
448 
452  public function saveGlossary()
453  {
454  global $tpl, $lng, $ilCtrl, $rbacsystem, $tree;
455 
456  $parent_ref_id = $tree->getParentId((int) $_GET["ref_id"]);
457  if (!$rbacsystem->checkAccess("create", $parent_ref_id, "glo"))
458  {
459  ilUtil::sendFailure($lng->txt("no_permission"), true);
460  $ilCtrl->redirect($this, "properties");
461  }
462 
463  $this->initGlossaryCreationForm();
464  if ($this->form->checkInput())
465  {
466  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
467  $newObj = new ilObjGlossary();
468  $newObj->setType("glo");
469  $newObj->setTitle($_POST["title"]);
470  $newObj->setDescription($_POST["description"]);
471  $newObj->setVirtualMode("none");
472  $newObj->create();
473  $newObj->createReference();
474  $newObj->putInTree($parent_ref_id);
475  $newObj->setPermissions($parent_ref_id);
476  $newObj->notify("new",$parent_ref_id,$_GET["parent_non_rbac_id"],$parent_ref_id,$newObj->getRefId());
477 
478  // perform save
479  $this->object->setAssignedGlossary($newObj->getId());
480  $this->object->update();
481 
482  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
483  $ilCtrl->redirect($this, "properties");
484  }
485 
486  $this->form->setValuesByPost();
487  $tpl->setContent($this->form->getHtml());
488  }
489 
493  function assignGlossary()
494  {
495  global $tpl, $ilCtrl, $tree;
496 
497  include_once("./Modules/Scorm2004/classes/class.ilGlossarySelectorGUI.php");
498  $exp = new ilGlossarySelectorGUI(
499  $ilCtrl->getLinkTarget($this, "selectGlossary"), "ilobjscorm2004learningmodulegui");
500  $exp->setSelectableTypes(array("glo"));
501 
502  if ($_GET["expand"] == "")
503  {
504  $expanded = $tree->readRootId();
505  }
506  else
507  {
508  $expanded = $_GET["expand"];
509  }
510  $exp->setExpand($expanded);
511 
512  $exp->setTargetGet("glo_id");
513  //$this->ctrl->setParameter($this, "target_type", $a_type);
514  //$ilCtrl->setParameter($this, "subCmd", "insertFromRepository");
515  $exp->setParamsGet($this->ctrl->getParameterArray($this, "assignGlossary"));
516 
517  // filter
518  $exp->setFiltered(true);
519  $exp->setFilterMode(IL_FM_POSITIVE);
520  $exp->addFilter("root");
521  $exp->addFilter("cat");
522  $exp->addFilter("grp");
523  $exp->addFilter("fold");
524  $exp->addFilter("crs");
525  $exp->addFilter("glo");
526 
527  $exp->setOutput(0);
528 
529  $tpl->setContent($exp->getOutput());
530  }
531 
535  function selectGlossary()
536  {
537  global $ilCtrl;
538 
539  $this->object->setAssignedGlossary(ilObject::_lookupObjId((int) $_GET["glo_ref_id"]));
540  $this->object->update();
541  $ilCtrl->redirect($this, "properties");
542  }
543 
547  function assignObject()
548  {
549  if ($this->id != 0)
550  {
551  if ($this->call_by_reference)
552  {
553  $this->object =& new ilObjSCORM2004LearningModule($this->id, true);
554  }
555  else
556  {
557  $this->object =& new ilObjSCORM2004LearningModule($this->id, false);
558  }
559  }
560  }
561 
566  {
567  global $tpl;
568 
569  $this->initStylePropertiesForm();
570  $tpl->setContent($this->form->getHTML());
571  }
572 
577  {
578  global $ilCtrl, $lng, $ilTabs, $ilSetting;
579 
580  $lng->loadLanguageModule("style");
581  $this->setSubTabs("settings", "style");
582  $ilTabs->setTabActive("settings");
583 
584  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
585  $this->form = new ilPropertyFormGUI();
586 
587  $fixed_style = $ilSetting->get("fixed_content_style_id");
588  $style_id = $this->object->getStyleSheetId();
589 
590  if ($fixed_style > 0)
591  {
592  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
593  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
594  $this->lng->txt("global_fixed").")");
595  $this->form->addItem($st);
596  }
597  else
598  {
599  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
600  $_GET["ref_id"]);
601 
602  $st_styles[0] = $this->lng->txt("default");
603  ksort($st_styles);
604 
605  if ($style_id > 0)
606  {
607  // individual style
608  if (!ilObjStyleSheet::_lookupStandard($style_id))
609  {
610  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
611  $st->setValue(ilObject::_lookupTitle($style_id));
612  $this->form->addItem($st);
613 
614 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
615 
616  // delete command
617  $this->form->addCommandButton("editStyle",
618  $lng->txt("cont_edit_style"));
619  $this->form->addCommandButton("deleteStyle",
620  $lng->txt("cont_delete_style"));
621 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
622  }
623  }
624 
625  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
626  {
627  $style_sel = ilUtil::formSelect ($style_id, "style_id",
628  $st_styles, false, true);
629  $style_sel = new ilSelectInputGUI($lng->txt("cont_current_style"), "style_id");
630  $style_sel->setOptions($st_styles);
631  $style_sel->setValue($style_id);
632  $this->form->addItem($style_sel);
633 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
634  $this->form->addCommandButton("saveStyleSettings",
635  $lng->txt("save"));
636  $this->form->addCommandButton("createStyle",
637  $lng->txt("sty_create_ind_style"));
638  }
639  }
640  $this->form->setTitle($lng->txt("cont_style"));
641  $this->form->setFormAction($ilCtrl->getFormAction($this));
642  }
643 
647  function createStyle()
648  {
649  global $ilCtrl;
650 
651  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
652  }
653 
657  function editStyle()
658  {
659  global $ilCtrl;
660 
661  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
662  }
663 
667  function deleteStyle()
668  {
669  global $ilCtrl;
670 
671  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
672  }
673 
677  function saveStyleSettings()
678  {
679  global $ilSetting;
680 
681  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
682  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
683  || $this->object->getStyleSheetId() == 0))
684  {
685  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
686  $this->object->update();
687  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
688  }
689  $this->ctrl->redirect($this, "editStyleProperties");
690  }
691 
696 {
697 
698  include_once "./Services/Table/classes/class.ilTableGUI.php";
699 
700  //set search
701 
702  if ($_POST["search_string"] != "")
703  {
704  $_SESSION["scorm_search_string"] = trim($_POST["search_string"]);
705  } else if (isset($_POST["search_string"]) && $_POST["search_string"] == "") {
706  unset($_SESSION["scorm_search_string"]);
707  }
708 
709  // load template for search additions
710  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl_scorm_track_items_search.html","Modules/ScormAicc");
711  // load template for table
712  $this->tpl->addBlockfile("USR_TABLE", "usr_table", "tpl.table.html");
713  // load template for table content data
714  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.scorm_track_items.html", "Modules/ScormAicc");
715 
716  $num = 5;
717 
718  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
719 
720  // create table
721  $tbl = new ilTableGUI();
722 
723  // title & header columns
724  if (isset($_SESSION["scorm_search_string"])) {
725  $tbl->setTitle($this->lng->txt("cont_tracking_items").' - Aktive Suche: "'.$_SESSION["scorm_search_string"].'"');
726  } else {
727  $tbl->setTitle($this->lng->txt("cont_tracking_items"));
728  }
729 
730  $tbl->setHeaderNames(array("",$this->lng->txt("name"), $this->lng->txt("last_access"), $this->lng->txt("attempts"), $this->lng->txt("version") ));
731 
732 
733  $header_params = $this->ctrl->getParameterArray($this, "showTrackingItems");
734 
735  $tbl->setColumnWidth(array("1%", "50%", "29%", "10%","10%"));
736 
737  $cols = array("user_id","username","last_access","attempts","version");
738  $tbl->setHeaderVars($cols, $header_params);
739 
740  //set defaults
741  $_GET["sort_order"] = $_GET["sort_order"] ? $_GET["sort_order"] : "asc";
742  $_GET["sort_by"] = $_GET["sort_by"] ? $_GET["sort_by"] : "username";
743 
744  // control
745  $tbl->setOrderColumn($_GET["sort_by"]);
746  $tbl->setOrderDirection($_GET["sort_order"]);
747  $tbl->setLimit($_GET["limit"]);
748  $tbl->setOffset($_GET["offset"]);
749  $tbl->setMaxCount($this->maxcount);
750 
751  $this->tpl->setVariable("COLUMN_COUNTS", 5);
752 
753  // delete button
754  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
755  $this->tpl->setCurrentBlock("tbl_action_btn");
756  $this->tpl->setVariable("BTN_NAME", "deleteTrackingForUser");
757  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
758  $this->tpl->parseCurrentBlock();
759 
760  // decrease attempts
761  $this->tpl->setCurrentBlock("tbl_action_btn");
762  $this->tpl->setVariable("BTN_NAME", "decreaseAttempts");
763  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("decrease_attempts"));
764  $this->tpl->parseCurrentBlock();
765 
766  // export aggregated data for selected users
767  $this->tpl->setCurrentBlock("tbl_action_btn");
768  $this->tpl->setVariable("BTN_NAME", "exportSelected");
769  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("export"));
770  $this->tpl->parseCurrentBlock();
771 
772  // add search and export all
773  // export aggregated data for all users
774  $this->tpl->setVariable("EXPORT_ACTION",$this->ctrl->getFormAction($this));
775 
776  $this->tpl->setVariable("EXPORT_ALL_VALUE", $this->lng->txt('cont_export_all'));
777  $this->tpl->setVariable("EXPORT_ALL_NAME", "exportAll");
778  $this->tpl->setVariable("IMPORT_VALUE", $this->lng->txt('import'));
779  $this->tpl->setVariable("IMPORT_NAME", "Import");
780 
781  $this->tpl->setVariable("SEARCH_TXT_SEARCH",$this->lng->txt('search'));
782  $this->tpl->setVariable("SEARCH_ACTION",$this->ctrl->getFormAction($this));
783  $this->tpl->setVariable("SEARCH_NAME",'showTrackingItems');
784  if (isset($_SESSION["scorm_search_string"])) {
785  $this->tpl->setVariable("STYLE",'display:inline;');
786  } else {
787  $this->tpl->setVariable("STYLE",'display:none;');
788  }
789  $this->tpl->setVariable("SEARCH_VAL", $_SESSION["scorm_search_string"]);
790  $this->tpl->setVariable("SEARCH_VALUE",$this->lng->txt('search_users'));
791  $this->tpl->parseCurrentBlock();
792 
793  // footer
794  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
795 
796  $items = $this->object->getTrackedUsers($_SESSION["scorm_search_string"]);
797 
798  $tbl->setMaxCount(count($items));
799  $items = ilUtil::sortArray($items ,$_GET["sort_by"],$_GET["sort_order"]);
800  $items = array_slice($items, $_GET["offset"], $_GET["limit"]);
801 
802  $tbl->render();
803 
804  if (count($items) > 0)
805  {
806  foreach ($items as $item)
807  {
808  if (ilObject::_exists($item["user_id"]) && ilObject::_lookUpType($item["user_id"])=="usr")
809  {
810  $user = new ilObjUser($item["user_id"]);
811  $this->tpl->setCurrentBlock("tbl_content");
812  $this->tpl->setVariable("VAL_USERNAME", $item["username"]);
813  $this->tpl->setVariable("VAL_LAST", $item["last_access"]);
814  $this->tpl->setVariable("VAL_ATTEMPT", $item["attempts"]);
815  $this->tpl->setVariable("VAL_VERSION", $item['version']);
816  $this->ctrl->setParameter($this, "user_id", $item["user_id"]);
817  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
818  $this->tpl->setVariable("LINK_ITEM",
819  $this->ctrl->getLinkTarget($this, "showTrackingItem"));
820  $this->tpl->setVariable("CHECKBOX_ID", $item["user_id"]);
821  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
822  $this->tpl->setVariable("CSS_ROW", $css_row);
823  $this->tpl->parseCurrentBlock();
824  }
825  }
826  $this->tpl->setCurrentBlock("selectall");
827  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
828  $this->tpl->setVariable("CSS_ROW", $css_row);
829  $this->tpl->parseCurrentBlock();
830 
831  } //if is_array
832  else
833  {
834  $this->tpl->setCurrentBlock("notfound");
835  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
836  $this->tpl->setVariable("NUM_COLS", $num);
837  $this->tpl->parseCurrentBlock();
838  }
839 
840 }
841 
842 
843 function exportAll(){
844  $this->object->exportSelected(1);
845 }
846 
847 function exportSelected()
848 {
849  if (!isset($_POST["user"]))
850  {
851  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
852  $this->ctrl->redirect($this, "showTrackingItems");
853  } else {
854  $this->object->exportSelected(0,$_POST["user"]);
855  }
856 }
857 
862 {
863 
864  include_once "./Services/Table/classes/class.ilTableGUI.php";
865 
866  // load template for table
867  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
868  // load template for table content data
869  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.scorm2004_track_item.html", "Modules/Scorm2004");
870 
871  $num = 2;
872 
873  $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
874 
875  // create table
876  $tbl = new ilTableGUI();
877 
878  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php");
879  $sc_item =& new ilSCORMItem($_GET["obj_id"]);
880 
881  // title & header columns
882  $user = new ilObjUser( $_GET["user_id"]);
883  $tbl->setTitle($user->getLastname().", ".$user->getFirstname());
884 
885  $tbl->setHeaderNames(array($this->lng->txt("title"),
886  $this->lng->txt("cont_status"), $this->lng->txt("cont_time"),
887  $this->lng->txt("cont_score")));
888 
889  $header_params = array("ref_id" => $this->ref_id, "cmd" => $_GET["cmd"],
890  "cmdClass" => get_class($this), "obj_id" => $_GET["obj_id"], "baseClass"=>"ilSAHSEditGUI", 'user_id'=>$_GET["user_id"]);
891 
892  $cols = array("title", "status", "time", "score");
893  $tbl->setHeaderVars($cols, $header_params);
894  //$tbl->setColumnWidth(array("25%",));
895 
896  // control
897  $tbl->setOrderColumn($_GET["sort_by"]);
898  $tbl->setOrderDirection($_GET["sort_order"]);
899  $tbl->setLimit($_GET["limit"]);
900  $tbl->setOffset($_GET["offset"]);
901  $tbl->setMaxCount($this->maxcount);
902 
903  //$this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
904  //$this->showActions(true);
905 
906  // footer
907  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
908  #$tbl->disable("footer");
909 
910  $tr_data = $this->object->getTrackingDataAgg($_GET["user_id"]);
911 
912  //$objs = ilUtil::sortArray($objs, $_GET["sort_by"], $_GET["sort_order"]);
913  $tbl->setMaxCount(count($tr_data));
914  $tr_data = array_slice($tr_data, $_GET["offset"], $_GET["limit"]);
915 
916  $tbl->render();
917 
918  if (count($tr_data) > 0)
919  {
920  foreach ($tr_data as $data)
921  {
922  $this->tpl->setCurrentBlock("tbl_content");
923  $this->tpl->setVariable("VAL_TITLE", $data["title"]);
924  $this->ctrl->setParameter($this, "user_id", $_GET["user_id"]);
925  $this->ctrl->setParameter($this, "obj_id", $data["sco_id"]);
926 
927  $this->tpl->setVariable("LINK_SCO",
928  $this->ctrl->getLinkTarget($this, "showTrackingItemPerUser"));
929  $this->tpl->setVariable("VAL_TIME", $data["time"]);
930  $this->tpl->setVariable("VAL_STATUS", $data["status"]);
931  $this->tpl->setVariable("VAL_SCORE", $data["score"]);
932 
933  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
934  $this->tpl->setVariable("CSS_ROW", $css_row);
935  $this->tpl->parseCurrentBlock();
936 
937  }
938  } //if is_array
939  else
940  {
941  $this->tpl->setCurrentBlock("notfound");
942  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
943  $this->tpl->setVariable("NUM_COLS", $num);
944  $this->tpl->parseCurrentBlock();
945  }
946 }
947 
948 
953  {
954  if(!isset($_POST["user"]))
955  {
956  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
957  }
958  // SAVE POST VALUES
959  $_SESSION["scorm_user_delete"] = $_POST["user"];
960 
961  unset($this->data);
962  $this->data["cols"] = array("type","title", "description");
963 
964  foreach($_POST["user"] as $id)
965  {
966  if (ilObject::_exists($id) && ilObject::_lookUpType($id)=="usr" ) {
967  $user = new ilObjUser($id);
968  $this->data["data"]["$id"] = array(
969  "type" => "sahs",
970  "title" => $user->getLastname().", ".$user->getFirstname(),
971  "desc" => $this->lng->txt("cont_tracking_data")
972  );
973  }
974  }
975 
976  $this->data["buttons"] = array( "cancelDeleteTracking" => $this->lng->txt("cancel"),
977  "confirmedDeleteTracking" => $this->lng->txt("confirm"));
978 
979  $this->getTemplateFile("confirm");
980 
981  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
982 
983  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
984 
985  // BEGIN TABLE HEADER
986  foreach ($this->data["cols"] as $key)
987  {
988  $this->tpl->setCurrentBlock("table_header");
989  $this->tpl->setVariable("TEXT",$this->lng->txt($key));
990  $this->tpl->parseCurrentBlock();
991  }
992  // END TABLE HEADER
993 
994  // BEGIN TABLE DATA
995  $counter = 0;
996 
997  foreach($this->data["data"] as $key => $value)
998  {
999  // BEGIN TABLE CELL
1000  foreach($value as $key => $cell_data)
1001  {
1002  $this->tpl->setCurrentBlock("table_cell");
1003 
1004  // CREATE TEXT STRING
1005  if($key == "type")
1006  {
1007  $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
1008  }
1009  else
1010  {
1011  $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
1012  }
1013  $this->tpl->parseCurrentBlock();
1014  }
1015 
1016  $this->tpl->setCurrentBlock("table_row");
1017  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
1018  $this->tpl->parseCurrentBlock();
1019  // END TABLE CELL
1020  }
1021  // END TABLE DATA
1022 
1023  // BEGIN OPERATION_BTN
1024  foreach($this->data["buttons"] as $name => $value)
1025  {
1026  $this->tpl->setCurrentBlock("operation_btn");
1027  $this->tpl->setVariable("BTN_NAME",$name);
1028  $this->tpl->setVariable("BTN_VALUE",$value);
1029  $this->tpl->parseCurrentBlock();
1030  }
1031  }
1032 
1033  function resetSearch() {
1034  unset($_SESSION["scorm_search_string"]);
1035  $this->ctrl->redirect($this, "showTrackingItems");
1036  }
1037 
1042  {
1043  session_unregister("scorm_user_delete");
1044  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
1045  $this->ctrl->redirect($this, "showTrackingItems");
1046  }
1047 
1054  {
1055  global $ilDB, $ilUser;
1056 
1057  $scos = array();
1058 
1059  //get all SCO's of this object
1060 
1061  $val_set = $ilDB->queryF('
1062  SELECT cp_node_id FROM cp_node
1063  WHERE nodename = %s
1064  AND cp_node.slm_id = %s',
1065  array('text', 'integer'),
1066  array('item',$this->object->getId()));
1067 
1068  while ($val_rec = $ilDB->fetchAssoc($val_set))
1069  {
1070  array_push($scos,$val_rec['cp_node_id']);
1071  }
1072 
1073  foreach ($_SESSION["scorm_user_delete"] as $user)
1074  {
1075 
1076  foreach ($scos as $sco)
1077  {
1078 
1079  $ret = $ilDB->manipulateF('
1080  DELETE FROM cmi_node
1081  WHERE user_id = %s
1082  AND cp_node_id = %s',
1083  array('integer','integer'),
1084  array($user,$sco));
1085  }
1086 
1087  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
1088  ilLPStatusWrapper::_updateStatus($this->object->getId(), $user);
1089 
1090  }
1091 
1092  $this->ctrl->redirect($this, "showTrackingItems");
1093  }
1094 
1095  function decreaseAttempts()
1096  {
1097  global $ilDB, $ilUser;
1098 
1099  if (!isset($_POST["user"]) || !is_array($_POST["user"]))
1100  {
1101  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
1102  }
1103 
1104  foreach ($_POST["user"] as $user)
1105  {
1106  //first check if there is a package_attempts entry
1107 
1108  //get existing account - sco id is always 0
1109 
1110  $val_set = $ilDB->queryF('
1111  SELECT * FROM cmi_custom
1112  WHERE user_id = %s
1113  AND sco_id = %s
1114  AND lvalue = %s
1115  AND obj_id = %s',
1116  array('integer','integer','text','integer'),
1117  array($user,0,'package_attempts',$this->object->getID()));
1118 
1119  $val_rec = $ilDB->fetchAssoc($val_set);
1120 
1121  $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
1122  if ($val_rec["rvalue"] != null && $val_rec["rvalue"] != 0)
1123  {
1124  $new_rec = $val_rec["rvalue"]-1;
1125  //decrease attempt by 1
1126  $res = $ilDB->queryF('
1127  SELECT * FROM cmi_custom
1128  WHERE user_id = %s
1129  AND lvalue = %s
1130  AND obj_id = %s
1131  AND sco_id = %s',
1132  array('integer','text','integer','integer'),
1133  array($user, 'package_attempts',$this->object->getID(),0));
1134 
1135 
1136  if($ilDB->numRows($res) > 0)
1137  {
1138  $val_set = $ilDB->manipulateF('
1139  UPDATE cmi_custom
1140  SET rvalue = %s,
1141  c_timestamp = %s
1142  WHERE user_id = %s
1143  AND sco_id = %s
1144  AND obj_id = %s
1145  AND lvalue = %s',
1146  array('text','timestamp','integer','integer','integer','text'),
1147  array($new_rec, date("Y-m-d H:i:s") ,$user,0,$this->object->getID(),'package_attempts'));
1148  }
1149  else
1150  {
1151  $val_set = $ilDB->manipulateF('
1152  INSERT INTO cmi_custom
1153  (rvalue,user_id,sco_id,obj_id,lvalue,c_timestamp)
1154  VALUES(%s,%s,%s,%s,%s,%s)',
1155  array('text','integer','integer','integer','text','timestamp'),
1156  array($new_rec,$user,0,$this->object->getID(),'package_attempts',date("Y-m-d H:i:s")));
1157  }
1158  }
1159  }
1160 
1161  //$this->ctrl->saveParameter($this, "cdir");
1162  $this->ctrl->redirect($this, "showTrackingItems");
1163  }
1164 
1166  {
1167  if (is_array($_POST["id"]))
1168  {
1169  $this->object->deleteTrackingDataOfUsers($_POST["id"]);
1170  }
1171  $this->showTrackingItems();
1172  }
1173 
1177  function showTree()
1178  {
1179  global $ilUser, $ilias, $ilCtrl, $lng;
1180 
1181  $mtree = new ilTree($this->object->getId());
1182  $mtree->setTableNames('sahs_sc13_tree','sahs_sc13_tree_node');
1183  $mtree->setTreeTablePK("slm_id");
1184 
1185  if ($_POST["expandAll"] != "")
1186  {
1187  $_GET["scexpand"] = "";
1188  $stree = $mtree->getSubTree($mtree->getNodeData($mtree->readRootId()));
1189  $n_arr = array();
1190  foreach ($stree as $n)
1191  {
1192  $n_arr[] = $n["child"];
1193  }
1194  $_SESSION["scexpand"] = $n_arr;
1195  }
1196 
1197  if ($_POST["collapseAll"] != "")
1198  {
1199  $_GET["scexpand"] = "";
1200  $_SESSION["scexpand"] = array($mtree->readRootId());
1201  }
1202 
1203  $this->tpl = new ilTemplate("tpl.main.html", true, true);
1204  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1205 
1206  $ilCtrl->setParameter($this, "active_node", $_GET["active_node"]);
1207 
1208  $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
1209  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
1210 
1211  $this->tpl->setCurrentBlock("exp2_button");
1212  $this->tpl->setVariable("CMD_EXP2_BTN", "expandAll");
1213  $this->tpl->setVariable("TXT_EXP2_BTN", $lng->txt("expand_all"));
1214  $this->tpl->parseCurrentBlock();
1215 
1216  $this->tpl->setCurrentBlock("exp2_button");
1217  $this->tpl->setVariable("CMD_EXP2_BTN", "collapseAll");
1218  $this->tpl->setVariable("TXT_EXP2_BTN", $lng->txt("collapse_all"));
1219  $this->tpl->parseCurrentBlock();
1220 
1221  require_once ("./Modules/Scorm2004/classes/class.ilSCORM2004EditorExplorer.php");
1222  $exp = new ilSCORM2004EditorExplorer($this->ctrl->getLinkTarget($this, "edit"),
1223  $this->object);
1224  $exp->setFrameUpdater("content", "ilHierarchyFormUpdater");
1225  $exp->setTargetGet("obj_id");
1226  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, "showTree"));
1227 
1228  if ($_GET["scexpand"] == "")
1229  {
1230  $expanded = $mtree->readRootId();
1231  }
1232  else
1233  {
1234  $expanded = $_GET["scexpand"];
1235  }
1236 
1237 //echo "-".$_GET["active_node"]."-";
1238  if ($_GET["active_node"] != "")
1239  {
1240  $path = $mtree->getPathId($_GET["active_node"]);
1241  $exp->setForceOpenPath($path);
1242 
1243  $exp->highlightNode($_GET["active_node"]);
1244  }
1245  $exp->setExpand($expanded);
1246 
1247  // build html-output
1248  $exp->setOutput(0);
1249  $output = $exp->getOutput();
1250 
1251  // asynchronous output
1252  if ($ilCtrl->isAsynch())
1253  {
1254  echo $output; exit;
1255  }
1256 
1257  $this->tpl->setCurrentBlock("content");
1258  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("sahs_organization"));
1259  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
1260  $this->tpl->setVariable("EXPLORER",$output);
1261  $this->ctrl->setParameter($this, "scexpand", $_GET["scexpand"]);
1262  $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, "showTree"));
1263  $this->tpl->parseCurrentBlock();
1264  $this->tpl->show(false);
1265  exit;
1266  }
1267 
1271  function showSequencing()
1272  {
1273  global $tpl,$lng,$ilTabs;
1274 
1275  //navigation options
1276 
1277  $nav_settings = $this->object->getSequencingSettings();
1278  $tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.scormeditor_course_sequencing.html", "Modules/Scorm2004");
1279  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1280  $tpl->setVariable("TXT_TITLE", "Sequencing Navigation Options for Module");
1281 
1282  $tpl->setVariable("BTN_NAME", "saveSequencing");
1283  $tpl->setVariable("TXT_SAVE", $lng->txt('save'));
1284 
1285  $tpl->setVariable("VAL_CHOICE", ilUtil::tf2yn($nav_settings->getChoice()));
1286  $tpl->setVariable("VAL_FLOW", ilUtil::tf2yn($nav_settings->getFlow()));
1287  $tpl->setVariable("VAL_FORWARDONLY", ilUtil::tf2yn($nav_settings->getForwardOnly()));
1288 
1289  $tpl->setVariable("VAL_CHOICE", "y");
1290  $tpl->setVariable("VAL_FLOW", "y");
1291  $tpl->setVariable("VAL_FORWARDONLY", "y");
1292 
1293  if ($nav_settings->getChoice())
1294  {
1295  $tpl->setVariable("CHK_CHOICE", "checked");
1296  }
1297  if ($nav_settings->getFlow())
1298  {
1299  $tpl->setVariable("CHK_FLOW", "checked");
1300  }
1301  if ($nav_settings->getForwardOnly())
1302  {
1303  $tpl->setVariable("CHK_FORWARDONLY", "checked");
1304  }
1305  $tpl->parseCurrentBlock();
1306 
1307  $ilTabs->setTabActive("sahs_sequencing");
1308 
1309  }
1310 
1311  function saveSequencing()
1312  {
1313  global $tpl,$lng;
1314  ilUtil::sendInfo($lng->txt("saved_successfully"),false);
1315  $this->object->updateSequencingSettings();
1316  $this->showSequencing();
1317  }
1318 
1323  {
1324  global $tpl, $lng, $ilCtrl;
1325 
1326  $oa_tpl = new ilTemplate("tpl.objectives_alignment.html", true, true, "Modules/Scorm2004");
1327 
1328  $chaps = $this->object->getTree()->getChilds(
1329  $this->object->getTree()->getRootId());
1330  $s_chaps = array();
1331  foreach($chaps as $chap)
1332  {
1333  $s_chaps[$chap["child"]] = $chap["title"];
1334  }
1335  reset($s_chaps);
1336  if (count($s_chaps) > 0)
1337  {
1338  $cur_chap = $_SESSION["sahs_cur_chap"]
1339  ? $_SESSION["sahs_cur_chap"]
1340  : key($s_chaps);
1341 
1342  $oa_tpl->setCurrentBlock("chapter_selection");
1343  $oa_tpl->setVariable("CHAPTER_SELECTION",
1344  ilUtil::formSelect($cur_chap, "chapter", $s_chaps, false, true));
1345  $oa_tpl->setVariable("TXT_SELECT_CHAPTER",
1346  $lng->txt("chapter"));
1347  $oa_tpl->setVariable("TXT_CHANGE", $lng->txt("change"));
1348  $oa_tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this));
1349  $oa_tpl->setVariable("CMD_CHAP_SEL", "selectLObjChapter");
1350  $oa_tpl->parseCurrentBlock();
1351 
1352  include_once("./Modules/Scorm2004/classes/class.ilObjectivesAlignmentTableGUI.php");
1353  $obj_table = new ilObjectivesAlignmentTableGUI($this, "showLearningObjectivesAlignment",
1354  $this->getEditTree(), $this->object, $cur_chap);
1355  $oa_tpl->setVariable("LOBJ_TABLE", $obj_table->getHTML());
1356  $tpl->setContent($oa_tpl->get());
1357  }
1358  else
1359  {
1360  ilUtil::sendInfo($lng->txt("sahs_oa_no_chapters"));
1361  }
1362  }
1363 
1365  {
1366  global $ilCtrl;
1367 
1368  $_SESSION["sahs_cur_chap"] = $_POST["chapter"];
1369  $ilCtrl->redirect($this, "showLearningObjectivesAlignment");
1370  }
1371 
1375  public function selectExport()
1376  {
1377  switch ($_POST['select_export'])
1378  {
1379  case "exportScorm12":
1380  case "exportScorm2004_3rd":
1381  case "exportScorm2004_4th":
1382  case "exportPDF":
1383  case "exportISO":
1384  case "exportHTML":
1385  $this->ctrl->redirect($this, $_POST['select_export']);
1386  break;
1387  default:
1388  $this->ctrl->redirect($this, 'showExportList');
1389  break;
1390  }
1391  }
1392 
1396  function showExportList()
1397  {
1398  global $tpl;
1399 
1400  $template = new ilTemplate("tpl.scorm2004_export_buttons.html", true, true, 'Modules/Scorm2004');
1401 
1402  $buttons = array(
1403  "exportScorm2004_3rd" => $this->lng->txt("scorm_create_export_file_scrom2004"),
1404  "exportScorm2004_4th" => $this->lng->txt("scorm_create_export_file_scrom2004_4th"),
1405  "exportScorm12" => $this->lng->txt("scorm_create_export_file_scrom12"),
1406  "exportPDF" => $this->lng->txt("scorm_create_export_file_pdf"),
1407  "exportISO" => $this->lng->txt("scorm_create_export_file_iso"),
1408  "exportHTML" => $this->lng->txt("scorm_create_export_file_html")
1409  );
1410  foreach ($buttons as $value => $text)
1411  {
1412  $template->setCurrentBlock('option');
1413  $template->setVariable('OPTION_VALUE', $value);
1414  $template->setVariable('OPTION_TITLE', ilUtil::prepareFormOutput($text));
1415  $template->parseCurrentBlock();
1416  }
1417  $template->setVariable('EXPORT_TITLE', $this->lng->txt('export'));
1418  $template->setVariable('EXPORT_LABEL', $this->lng->txt('type'));
1419  $template->setVariable('FORMACTION', $this->ctrl->getFormAction($this, 'selectExport'));
1420 
1421  $export_files = $this->object->getExportFiles();
1422 
1423  include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ExportTableGUI.php";
1424  $table_gui = new ilSCORM2004ExportTableGUI($this, 'showExportList');
1425  $data = array();
1426  foreach ($export_files as $exp_file)
1427  {
1428  $filetype = $exp_file['type'];
1429  $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($filetype))
1430  ? " <b>(".$this->lng->txt("public").")<b>"
1431  : "";
1432  $file_arr = explode("__", $exp_file["file"]);
1433  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));
1434  }
1435  $table_gui->setData($data);
1436  $this->tpl->setVariable('ADM_CONTENT', $template->get() . "\n" . $table_gui->getHTML());
1437  }
1438 
1444  function getTabs(&$tabs_gui)
1445  {
1446  global $ilAccess;
1447 
1448  if ($this->ctrl->getCmd() == "delete")
1449  {
1450  return;
1451  }
1452 
1453  if (!$this->object->getEditable())
1454  {
1455  return parent::getTabs($tabs_gui);
1456  }
1457 
1458  // organization
1459  $tabs_gui->addTarget("sahs_organization",
1460  $this->ctrl->getLinkTarget($this, "showOrganization"), "showOrganization",
1461  get_class($this));
1462 
1463  // info screen
1464  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui")
1465  ? true
1466  : false;
1467  $tabs_gui->addTarget("info_short",
1468  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"), "",
1469  "ilinfoscreengui", "", $force_active);
1470 
1471  // settings
1472  $tabs_gui->addTarget("settings",
1473  $this->ctrl->getLinkTarget($this, "properties"), "properties",
1474  get_class($this));
1475 
1476  // tracking data
1477  /* Later, only if tracking data exists
1478  $tabs_gui->addTarget("cont_tracking_data",
1479  $this->ctrl->getLinkTarget($this, "showTrackingItems"), "showTrackingItems",
1480  get_class($this));
1481  */
1482 
1483  /*
1484  // sequencing
1485  $tabs_gui->addTarget("sahs_sequencing",
1486  $this->ctrl->getLinkTarget($this, "showSequencing"), "showSequencing",
1487  get_class($this));
1488  */
1489 
1490  // objective alignment
1491  $tabs_gui->addTarget("sahs_objectives_alignment",
1492  $this->ctrl->getLinkTarget($this, "showLearningObjectivesAlignment"), "showLearningObjectivesAlignment",
1493  get_class($this));
1494 
1495  // learning progress
1496  /* Later, only if tracking data exists
1497  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
1498  if(ilObjUserTracking::_enabledLearningProgress())
1499  {
1500  $tabs_gui->addTarget('learning_progress',
1501  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
1502  '',
1503  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
1504  }
1505  */
1506 
1507  // edit meta
1508  $tabs_gui->addTarget("meta_data",
1509  $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
1510  "", "ilmdeditorgui");
1511 
1512  // export
1513  $tabs_gui->addTarget("export",
1514  $this->ctrl->getLinkTarget($this, "showExportList"), array("showExportList", 'confirmDeleteExportFile'),
1515  get_class($this));
1516 
1517  // perm
1518  if ($ilAccess->checkAccess('edit_permission', '', $this->object->getRefId()))
1519  {
1520  $tabs_gui->addTarget("perm_settings",
1521  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1522  }
1523 
1524  if ($this->object->editable==1)
1525  {
1526  // preview
1527  $tabs_gui->addNonTabbedLink("preview",
1528  $this->lng->txt("cont_sc_preview"),
1529  $this->ctrl->getLinkTarget($this, "preview"),
1530  "_blank");
1531  }
1532 
1533  }
1534 
1538  function setSubTabs($a_main_tab, $a_active)
1539  {
1540  global $ilTabs, $ilCtrl, $lng;
1541 
1542  if ($a_main_tab == "settings" &&
1543  $this->object->editable == 1)
1544  {
1545  // general properties
1546  $ilTabs->addSubTab("general_settings",
1547  $lng->txt("general_settings"),
1548  $ilCtrl->getLinkTarget($this, 'properties'));
1549 
1550  // style properties
1551  $ilTabs->addSubTab("style",
1552  $lng->txt("cont_style"),
1553  $ilCtrl->getLinkTarget($this, 'editStyleProperties'));
1554 
1555  $ilTabs->activateSubTab($a_active);
1556  }
1557  }
1558 
1559 
1563  function getEditTree()
1564  {
1565  $slm_tree = new ilTree($this->object->getId());
1566  $slm_tree->setTreeTablePK("slm_id");
1567  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
1568  return $slm_tree;
1569  }
1570 
1574  function showOrganization($a_top_node = 0, $a_form_action = "",
1575  $a_title = "", $a_icon = "", $a_gui_obj = null, $a_gui_cmd = "")
1576  {
1577  global $lng, $ilCtrl, $tpl;
1578 
1579  if ($a_form_action == "")
1580  {
1581  $a_form_action = $ilCtrl->getFormAction($this);
1582  }
1583 
1584  if ($a_icon == "")
1585  {
1586  $a_title = $this->object->getTitle();
1587  $a_icon = ilUtil::getImagePath("icon_lm.gif");
1588  }
1589 
1590  $slm_tree = $this->getEditTree();
1591 
1592  if ($a_top_node == 0)
1593  {
1594  $a_top_node = $slm_tree->getRootId();
1595  }
1596 
1597  if (is_null($a_gui_obj))
1598  {
1599  $a_gui_obj = $this;
1600  $a_gui_cmd = "showOrganization";
1601  }
1602 
1603  $ilCtrl->setParameter($this, "backcmd", "showOrganization");
1604  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
1605  $form_gui = new ilSCORM2004OrganizationHFormGUI();
1606  $form_gui->setParentCommand($a_gui_obj, $a_gui_cmd);
1607  $form_gui->setFormAction($a_form_action);
1608  $form_gui->setTitle($a_title);
1609  $form_gui->setIcon($a_icon);
1610  $form_gui->setTree($slm_tree);
1611  $form_gui->setCurrentTopNodeId($a_top_node);
1612  $form_gui->addMultiCommand($lng->txt("delete"), "deleteNodes");
1613  $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
1614  $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
1615  $form_gui->addCommand($lng->txt("cont_save_all_titles"), "saveAllTitles");
1616  $form_gui->addCommand($lng->txt("expand_all"), "expandAll");
1617  $form_gui->addCommand($lng->txt("collapse_all"), "collapseAll");
1618  $form_gui->setTriggeredUpdateCommand("saveAllTitles");
1619 
1620  // highlighted nodes
1621  if ($_GET["highlight"] != "")
1622  {
1623  $hl = explode(":", $_GET["highlight"]);
1624  $form_gui->setHighlightedNodes($hl);
1625  $form_gui->setFocusId($hl[0]);
1626  }
1627 
1628  $ilCtrl->setParameter($this, "active_node", $_GET["obj_id"]);
1629  $form_gui->setExplorerUpdater("tree", "tree_div",
1630  $ilCtrl->getLinkTarget($this, "showTree", "", true));
1631  $sc_tpl = new ilTemplate("tpl.scormeditor_orga_screen.html", true, true, "Modules/Scorm2004");
1632  $sc_tpl->setVariable("ORGANIZATION", $form_gui->getHTML());
1633  $sc_tpl->setVariable("NOTES", $this->getNotesHTML());
1634 
1635  $tpl->setContent($sc_tpl->get());
1636  }
1637 
1641  function getNotesHTML($a_mode = "")
1642  {
1643  global $ilCtrl;
1644 
1645  // notes
1646  $ilCtrl->setParameter($this, "nodes_mode", $a_mode);
1647  include_once("Services/Notes/classes/class.ilNoteGUI.php");
1648  $node_id = $_GET["obj_id"];
1649  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1650  $node_type = ($node_id > 0)
1651  ? ilSCORM2004Node::_lookupType($node_id)
1652  : "sahs";
1653 
1654  $notes_gui = new ilNoteGUI($this->object->getId(),
1655  (int) $node_id, $node_type);
1656 // if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1657 // {
1658 // $notes_gui->enablePublicNotesDeletion(true);
1659 // }
1660  $notes_gui->enablePrivateNotes();
1661  $notes_gui->enablePublicNotes();
1662 
1663  $next_class = $ilCtrl->getNextClass($this);
1664  if ($next_class == "ilnotegui")
1665  {
1666  $html = $this->ctrl->forwardCommand($notes_gui);
1667  }
1668  else
1669  {
1670  $html = $notes_gui->getNotesHTML();
1671  }
1672  return $html;
1673  }
1674 
1678  function insertChapter($a_redirect = true)
1679  {
1680  global $ilCtrl, $lng;
1681 
1682  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
1683 
1684  $slm_tree =& new ilTree($this->object->getId());
1685  $slm_tree->setTreeTablePK("slm_id");
1686  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
1687 
1690 
1691  if (!ilSCORM2004OrganizationHFormGUI::getPostFirstChild()) // insert after node id
1692  {
1693  $parent_id = $slm_tree->getParentId($node_id);
1694  $target = $node_id;
1695  }
1696  else // insert as first child
1697  {
1698  $parent_id = $node_id;
1699  $target = IL_FIRST_NODE;
1700  }
1701  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php");
1702  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1703 
1704  $chap_ids = array();
1705  for ($i = 1; $i <= $num; $i++)
1706  {
1707  $chap = new ilSCORM2004Chapter($this->object);
1708  $chap->setTitle($lng->txt("sahs_new_chapter"));
1709  $chap->setSLMId($this->object->getId());
1710  $chap->create();
1711  ilSCORM2004Node::putInTree($chap, $parent_id, $target);
1712  $chap_ids[] = $chap->getId();
1713  }
1714  $chap_ids = array_reverse($chap_ids);
1715  $chap_ids = implode($chap_ids, ":");
1716 
1717  if ($a_redirect)
1718  {
1719  $ilCtrl->setParameter($this, "highlight", $chap_ids);
1720  $ilCtrl->redirect($this, "showOrganization", "node_".$node_id);
1721  }
1722  return array("node_id" => $node_id, "items" => $chap_ids);
1723  }
1724 
1728  function insertSco($a_redirect = true)
1729  {
1730  global $ilCtrl, $lng;
1731 
1732  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
1733 
1734  $slm_tree =& new ilTree($this->object->getId());
1735  $slm_tree->setTreeTablePK("slm_id");
1736  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
1737 
1740 
1741  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1742  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1743 
1744  if (!ilSCORM2004OrganizationHFormGUI::getPostFirstChild()) // insert after node id
1745  {
1746  $parent_id = $slm_tree->getParentId($node_id);
1747  $target = $node_id;
1748  }
1749  else // insert as first child
1750  {
1751  $parent_id = $node_id;
1752  $target = IL_FIRST_NODE;
1753  }
1754 
1755  $sco_ids = array();
1756  for ($i = 1; $i <= $num; $i++)
1757  {
1758  $sco = new ilSCORM2004Sco($this->object);
1759  $sco->setTitle($lng->txt("sahs_new_sco"));
1760  $sco->setSLMId($this->object->getId());
1761  $sco->create();
1762  ilSCORM2004Node::putInTree($sco, $parent_id, $target);
1763  $sco_ids[] = $sco->getId();
1764  }
1765  $sco_ids = array_reverse($sco_ids);
1766  $sco_ids = implode($sco_ids, ":");
1767 
1768  if ($a_redirect)
1769  {
1770  $ilCtrl->setParameter($this, "highlight", $sco_ids);
1771  $ilCtrl->redirect($this, "showOrganization", "node_".$node_id);
1772  }
1773  return array("node_id" => $node_id, "items" => $sco_ids);
1774  }
1775 
1779  function insertPage($a_redirect = true)
1780  {
1781  global $ilCtrl, $lng;
1782 
1783  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
1784 
1785  $slm_tree =& new ilTree($this->object->getId());
1786  $slm_tree->setTreeTablePK("slm_id");
1787  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
1788 
1791 
1792  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
1793  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1794  if (!ilSCORM2004OrganizationHFormGUI::getPostFirstChild()) // insert after node id
1795  {
1796  $parent_id = $slm_tree->getParentId($node_id);
1797  $target = $node_id;
1798  }
1799  else // insert as first child
1800  {
1801  $parent_id = $node_id;
1802  $target = IL_FIRST_NODE;
1803  }
1804 
1805  $page_ids = array();
1806  for ($i = 1; $i <= $num; $i++)
1807  {
1808  $page = new ilSCORM2004PageNode($this->object);
1809  $page->setTitle($lng->txt("sahs_new_page"));
1810  $page->setSLMId($this->object->getId());
1811  $page->create();
1812  ilSCORM2004Node::putInTree($page, $parent_id, $target);
1813  $page_ids[] = $page->getId();
1814  }
1815  $page_ids = array_reverse($page_ids);
1816  $page_ids = implode($page_ids, ":");
1817 
1818  if ($a_redirect)
1819  {
1820  $ilCtrl->setParameter($this, "highlight", $page_ids);
1821  $ilCtrl->redirect($this, "showOrganization", "node_".$node_id);
1822  }
1823  return array("node_id" => $node_id, "items" => $page_ids);
1824  }
1825 
1826 
1831  {
1832 
1833  global $ilCtrl,$lng, $tpl;
1834 
1835  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
1836  include_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004SeqTemplate.php");
1837 
1838  $templates = array();
1839  $description = null;
1840  $image = null;
1841 
1842  $default_identifier = $_POST["identifier"];
1843 
1844  //get available templates
1845  $arr_templates = ilSCORM2004SeqTemplate::availableTemplates();
1846 
1847  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scormeditor_seq_chooser.html", "Modules/Scorm2004");
1848 
1849  $this->tpl->setCurrentBlock("option_item");
1850 
1851  $active = null;
1852  foreach ($arr_templates as $templ)
1853  {
1854  $sel= "";
1855  $item_data = $templ->getMetadataProperties();
1856  $item_data['identifier'] = $templ->getIdentifier();
1857  array_push($templates,$item_data);
1858  if ($default_identifier == $item_data['identifier']) {$sel = 'selected'; $active = $item_data;}
1859  $this->tpl->setVariable("VAL_SELECTED",$sel );
1860  $this->tpl->setVariable("VAL_IDENTIFIER",$item_data['identifier'] );
1861  $this->tpl->setVariable("VAL_TITLE",$item_data['title'] );
1862  $this->tpl->parseCurrentBlock();
1863  }
1864 
1865  //default
1866  if ($active == null )
1867  {
1868  $this->saveAllTitles(false);
1869  $description = $templates[0]['description'];
1870  $image = $templates[0]['thumbnail'];
1871  } else {
1872  $description = $active['description'];
1873  $image = $active['thumbnail'];
1874  }
1875 
1876  $this->tpl->setVariable("VAL_DESCRIPTION",$description);
1877  $this->tpl->setVariable("VAL_IMAGE",ilSCORM2004SeqTemplate::SEQ_TEMPLATE_DIR."/images/".$image);
1878 
1879  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1880  $this->tpl->setVariable("BTN_NAME", "insertScenario");
1881  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
1882  $this->tpl->setVariable("TXT_INSERT", $this->lng->txt("insert"));
1883  $this->tpl->setVariable("TXT_CHANGE", $this->lng->txt("change"));
1884 
1885  $this->tpl->setVariable("TXT_TITLE", "Choose Sequencing Template");
1886 
1887  $node_id = $_POST["node_id"];
1888  $first_child = $_POST["first_child"];
1889 
1890  if (!$node_id) {$node_id = ilSCORM2004OrganizationHFormGUI::getPostNodeId();}
1891  if (!$first_child) {$first_child = ilSCORM2004OrganizationHFormGUI::getPostFirstChild();}
1892 
1893  $this->tpl->setVariable("VAL_NODE_ID", $node_id);
1894  $this->tpl->setVariable("VAL_FIRST_CHILD", $first_child);
1895 
1896  }
1897 
1898 
1902  function insertScenario()
1903  {
1904  global $ilCtrl;
1905 
1906  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
1907 
1908  $slm_tree =& new ilTree($this->object->getId());
1909  $slm_tree->setTreeTablePK("slm_id");
1910  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
1911 
1912  $node_id = $_POST["node_id"];
1913 
1914  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
1915  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1916  include_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004SeqTemplate.php");
1917 
1918  if (!$_POST["first_child"]) // insert after node id
1919  {
1920  $parent_id = $slm_tree->getParentId($node_id);
1921  $target = $node_id;
1922  }
1923  else // insert as first child
1924  {
1925  $parent_id = $node_id;
1926  $target = IL_FIRST_NODE;
1927  }
1928 
1929  $template = new ilSCORM2004SeqTemplate($_POST["identifier"]);
1930  $id = $template->insertTemplateForObjectAtParent($this->object,$parent_id,$target);
1931  $ilCtrl->setParameter($this, "highlight", $id);
1932  $ilCtrl->redirect($this, "showOrganization", "node_".$node_id);
1933 
1934  }
1935 
1939  function insertTemplateGUI($a_redirect = true) {
1940  global $ilCtrl,$lng, $tpl;
1941 
1942  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
1943 
1944  $arr_templates = ilPageLayout::activeLayouts();
1945 
1946  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scormeditor_page_layout_chooser.html", "Modules/Scorm2004");
1947 
1948  $this->tpl->setCurrentBlock("option_item");
1949 
1950  $count = 0;
1951  foreach ($arr_templates as $templ)
1952  {
1953  $count++;
1954  $sel= "";
1955  $templ->readObject();
1956  $this->tpl->setVariable("VAL_LAYOUT_TITLE",$templ->getTitle());
1957  $this->tpl->setVariable("VAL_LAYOUT_IMAGE",$templ->getPreview());
1958  $this->tpl->setVariable("VAL_LAYOUT_ID",$templ->getId());
1959  $this->tpl->setVariable("VAL_DISPLAY","inline");
1960  if ($count==1) {
1961  $this->tpl->setVariable("VAL_CHECKED","checked");
1962  }
1963  if ($count%4 == 0) {
1964  $this->tpl->setVariable("END_ROW","</tr>");
1965  }
1966  if ($count == 1 || ($count-1)%4 == 0) {
1967  $this->tpl->setVariable("BEGIN_ROW","<tr>");
1968  }
1969  $this->tpl->parseCurrentBlock();
1970  }
1971 
1972  //matrix table
1973  if ($count%4!=0) {
1974  $rest = 4-($count%4);
1975  } else {
1976  $rest=0;
1977  }
1978 
1979  for ($i=1;$i<=$rest;$i++) {
1980  $this->tpl->setVariable("VAL_DISPLAY","none");
1981  $this->tpl->setVariable("VAL_LAYOUT_ID",$templ->getId());
1982 
1983  if ($i == $rest) {
1984  $this->tpl->setVariable("END_ROW","</tr>");
1985  }
1986  $this->tpl->parseCurrentBlock();
1987  }
1988 
1989  //empty cells and closing <tr>
1990 
1991  $this->tpl->setVariable("VAL_NODE_ID",ilSCORM2004OrganizationHFormGUI::getPostNodeId());
1992  $this->tpl->setVariable("VAL_MULTI", ilSCORM2004OrganizationHFormGUI::getPostMulti());
1993  $this->tpl->setVariable("VAL_FIRST_CHILD", ilSCORM2004OrganizationHFormGUI::getPostFirstChild());
1994  $this->tpl->setVariable("VAL_OBJ_ID", ilSCORM2004OrganizationHFormGUI::getPostFirstChild());
1995 
1996  $ilCtrl->saveParameter($this,"obj_id");
1997 
1998  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1999  $this->tpl->setVariable("BTN_NAME", "insertTemplate");
2000  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
2001  $this->tpl->setVariable("TXT_INSERT", $this->lng->txt("insert"));
2002  $this->tpl->setVariable("TXT_CHANGE", $this->lng->txt("change"));
2003  $this->tpl->setVariable("TXT_TITLE", "Choose Page Layout");
2004 
2005  }
2006 
2007 
2008 
2012  function insertTemplate($a_redirect = true)
2013  {
2014  global $ilCtrl, $lng;
2015 
2016  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
2017 
2018  $slm_tree =& new ilTree($this->object->getId());
2019  $slm_tree->setTreeTablePK("slm_id");
2020  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
2021 
2022  $num = $_POST["multi"];
2023  $node_id = $_POST["node_id"];
2024  $layout_id = $_POST["layout_id"];
2025 
2026 
2027  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
2028  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2029 
2030  if (!$_POST["first_child"]) // insert after node id
2031  {
2032  $parent_id = $slm_tree->getParentId($node_id);
2033  $target = $node_id;
2034  }
2035  else // insert as first child
2036  {
2037  $parent_id = $node_id;
2038  $target = IL_FIRST_NODE;
2039  }
2040 
2041  $page_ids = array();
2042  for ($i = 1; $i <= $num; $i++)
2043  {
2044  $page = new ilSCORM2004PageNode($this->object);
2045  $page->setTitle($lng->txt("sahs_new_page"));
2046  $page->setSLMId($this->object->getId());
2047  $page->create(false,$layout_id);
2048  ilSCORM2004Node::putInTree($page, $parent_id, $target);
2049  $page_ids[] = $page->getId();
2050  }
2051  $page_ids = array_reverse($page_ids);
2052  $page_ids = implode($page_ids, ":");
2053 
2054  if ($a_redirect)
2055  {
2056  if ($_GET["obj_id"] != "")
2057  {
2058  $this->jumpToNode($node_id, $page_ids);
2059  }
2060  else
2061  {
2062  $ilCtrl->setParameter($this, "highlight", $page_ids);
2063  $ilCtrl->redirect($this, "showOrganization", "node_".$node_id);
2064  }
2065  }
2066  }
2067 
2071  function expandAll($a_redirect = true)
2072  {
2073  $_GET["scexpand"] = "";
2074  $mtree = $this->object->getTree();
2075  $n_id = ($_GET["obj_id"] > 0)
2076  ? $_GET["obj_id"]
2077  : $mtree->readRootId();
2078  $stree = $mtree->getSubTree($mtree->getNodeData($n_id));
2079  $n_arr = array();
2080  foreach ($stree as $n)
2081  {
2082  $n_arr[] = $n["child"];
2083  $_SESSION["scexpand"] = $n_arr;
2084  }
2085  $this->saveAllTitles($a_redirect);
2086  }
2087 
2091  function collapseAll($a_redirect = true)
2092  {
2093  $_GET["scexpand"] = "";
2094  $mtree = $this->object->getTree();
2095  $n_id = ($_GET["obj_id"] > 0)
2096  ? $_GET["obj_id"]
2097  : $mtree->readRootId();
2098  $stree = $mtree->getSubTree($mtree->getNodeData($n_id));
2099  $old = $_SESSION["scexpand"];
2100  foreach ($stree as $n)
2101  {
2102  if (in_array($n["child"], $old) && $n["child"] != $n_id)
2103  {
2104  $k = array_search($n["child"], $old);
2105  unset($old[$k]);
2106  }
2107  }
2108  $_SESSION["scexpand"] = $old;
2109  $this->saveAllTitles($a_redirect);
2110  }
2111 
2115  function saveAllTitles($a_redirect = true)
2116  {
2117  global $ilCtrl;
2118 
2119  if (is_array($_POST["title"]))
2120  {
2121  include_once("./Services/MetaData/classes/class.ilMD.php");
2122  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
2123  foreach($_POST["title"] as $id => $title)
2124  {
2125  $node_obj = ilSCORM2004NodeFactory::getInstance($this->object, $id, false);
2126  if (is_object($node_obj))
2127  {
2128  // Update Title and description
2129  $md = new ilMD($this->object->getId(), $id, $node_obj->getType());
2130  $md_gen = $md->getGeneral();
2131  $md_gen->setTitle(ilUtil::stripSlashes($title));
2132  $md_gen->update();
2133  $md->update();
2135  }
2136  }
2137  }
2138  if ($a_redirect)
2139  {
2140  $ilCtrl->redirect($this, "showOrganization");
2141  }
2142  }
2143 
2149  function deleteNodes($a_form_action = "")
2150  {
2151  global $lng, $tpl;
2152 
2153  if(!isset($_POST["id"]))
2154  {
2155  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2156  }
2157 
2158  // SAVE POST VALUES
2159  $_SESSION["saved_post"] = $_POST["id"];
2160 
2161  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2162  $confirmation_gui = new ilConfirmationGUI();
2163 
2164  if ($a_form_action == "")
2165  {
2166  $cmd = ($_GET["backcmd"] == "")
2167  ? "showOrganization"
2168  : $_GET["backcmd"];
2169  $this->ctrl->setParameter($this, "backcmd", $cmd);
2170  $a_form_action = $this->ctrl->getFormAction($this);
2171  }
2172  $confirmation_gui->setFormAction($a_form_action);
2173  $confirmation_gui->setHeaderText($this->lng->txt("info_delete_sure"));
2174 
2175  // Add items to delete
2176  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
2177  foreach($_POST["id"] as $id)
2178  {
2179  if ($id != IL_FIRST_NODE)
2180  {
2181  $node_obj = ilSCORM2004NodeFactory::getInstance($this->object, $id, false);
2182  $confirmation_gui->addItem("id[]", $node_obj->getId(),
2183  $node_obj->getTitle(), ilUtil::getImagePath("icon_".$node_obj->getType().".gif"));
2184  }
2185  }
2186 
2187  $confirmation_gui->setCancel($lng->txt("cancel"), "cancelDelete");
2188  $confirmation_gui->setConfirm($lng->txt("confirm"), "confirmedDelete");
2189 
2190  $tpl->setContent($confirmation_gui->getHTML());
2191  }
2192 
2196  function cancelDelete()
2197  {
2198  $this->ctrl->redirect($this, $_GET["backcmd"]);
2199  }
2200 
2204  function confirmedDelete($a_redirect = true)
2205  {
2206  global $ilCtrl;
2207 
2208  $tree = new ilTree($this->object->getId());
2209  $tree->setTableNames('sahs_sc13_tree','sahs_sc13_tree_node');
2210  $tree->setTreeTablePK("slm_id");
2211 
2212  // delete all selected objects
2213  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
2214  foreach ($_POST["id"] as $id)
2215  {
2216  if ($id != IL_FIRST_NODE)
2217  {
2218  $obj = ilSCORM2004NodeFactory::getInstance($this->object, $id, false);
2219  $node_data = $tree->getNodeData($id);
2220  if (is_object($obj))
2221  {
2222  $obj->setSLMId($this->object->getId());
2223 
2224  /*include_once("classes/class.ilHistory.php");
2225  ilHistory::_createEntry($this->object->getId(), "delete_".$obj->getType(),
2226  array(ilLMObject::_lookupTitle($id), $id),
2227  $this->object->getType());*/
2228 
2229  $obj->delete();
2230  }
2231  if($tree->isInTree($id))
2232  {
2233  $tree->deleteTree($node_data);
2234  }
2235  }
2236  }
2237 
2238  // check the tree
2239  // $this->object->checkTree();
2240 
2241  // feedback
2242  ilUtil::sendInfo($this->lng->txt("info_deleted"),true);
2243 
2244  if ($a_redirect)
2245  {
2246  $ilCtrl->redirect($this, "showOrganization");
2247  }
2248  }
2249 
2253  function proceedDragDrop()
2254  {
2255  global $ilCtrl;
2256 
2257  $this->object->executeDragDrop($_POST["il_hform_source_id"], $_POST["il_hform_target_id"],
2258  $_POST["il_hform_fc"], $_POST["il_hform_as_subitem"]);
2259  $ilCtrl->redirect($this, "showOrganization");
2260  }
2261 
2265  function copyItems($a_return = "showOrganization")
2266  {
2267  global $ilCtrl, $lng;
2268 
2269  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2270 
2271  $items = ilUtil::stripSlashesArray($_POST["id"]);
2272  $todel = array(); // delete IDs < 0 (needed for non-js editing)
2273  foreach($items as $k => $item)
2274  {
2275  if ($item < 0)
2276  {
2277  $todel[] = $k;
2278  }
2279  }
2280  foreach($todel as $k)
2281  {
2282  unset($items[$k]);
2283  }
2284  if (!ilSCORM2004Node::uniqueTypesCheck($items))
2285  {
2286  ilUtil::sendInfo($lng->txt("sahs_choose_pages_or_chapters_or_scos_only"), true);
2287  $ilCtrl->redirect($this, $a_return);
2288  }
2289  ilSCORM2004Node::clipboardCopy($this->object->getId(), $items);
2290 
2291  // @todo: move this to a service since it can be used here, too
2292  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
2294  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
2295 
2296  $ilCtrl->redirect($this, $a_return);
2297  }
2298 
2302  function cutItems($a_return = "showOrganization")
2303  {
2304  global $ilCtrl, $lng;
2305 
2306  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2307 
2308  $items = ilUtil::stripSlashesArray($_POST["id"]);
2309  $todel = array(); // delete IDs < 0 (needed for non-js editing)
2310  foreach($items as $k => $item)
2311  {
2312  if ($item < 0)
2313  {
2314  $todel[] = $k;
2315  }
2316  }
2317  foreach($todel as $k)
2318  {
2319  unset($items[$k]);
2320  }
2321 
2322  if (!ilSCORM2004Node::uniqueTypesCheck($items))
2323  {
2324  ilUtil::sendInfo($lng->txt("sahs_choose_pages_or_chapters_or_scos_only"), true);
2325  $ilCtrl->redirect($this, $a_return);
2326  }
2327 
2328  ilSCORM2004Node::clipboardCut($this->object->getId(), $items);
2329 
2330  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
2332 
2333  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
2334 
2335  $ilCtrl->redirect($this, $a_return);
2336  }
2337 
2341  function insertPageClip()
2342  {
2343  global $ilCtrl, $ilUser;
2344 
2345  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2346  ilSCORM2004Node::insertPageClip($this->object);
2347 
2348  $ilCtrl->redirect($this, "showOrganization",
2350  }
2351 
2355  function insertScoClip()
2356  {
2357  global $ilCtrl, $ilUser;
2358 
2359  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2360  ilSCORM2004Node::insertScoClip($this->object);
2361 
2362  $ilCtrl->redirect($this, "showOrganization",
2364  }
2365 
2370  {
2371  global $ilCtrl, $ilUser;
2372 
2373  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2374  ilSCORM2004Node::insertChapterClip($this->object);
2375 
2376  $ilCtrl->redirect($this, "showOrganization",
2378  }
2379 
2380 
2382  {
2383  $export = new ilScorm2004Export($this->object,'SCORM 2004 4th');
2384  $export->buildExportFile();
2385  $this->ctrl->redirect($this, "showExportList");
2386  }
2387 
2389  {
2390  $export = new ilScorm2004Export($this->object,'SCORM 2004 3rd');
2391  $export->buildExportFile();
2392  $this->ctrl->redirect($this, "showExportList");
2393  }
2394 
2395  function exportScorm12()
2396  {
2397  $export = new ilScorm2004Export($this->object,'SCORM 1.2');
2398  $export->buildExportFile();
2399  $this->ctrl->redirect($this, "showExportList");
2400  }
2401 
2402  function exportHTML()
2403  {
2404  $export = new ilScorm2004Export($this->object,'HTML');
2405  $export->buildExportFile();
2406  $this->ctrl->redirect($this, "showExportList");
2407  }
2408 
2409  function exportISO()
2410  {
2411  $export = new ilScorm2004Export($this->object,'ISO');
2412  if(!$export->buildExportFile())
2413  {
2414  if(!PATH_TO_MKISOFS)
2415  $this->ilias->raiseError($this->lng->txt("no_mkisofs_configured"),$this->ilias->error_obj->MESSAGE);
2416  }
2417  $this->ctrl->redirect($this, "showExportList");
2418  }
2419 
2420  function exportPDF()
2421  {
2422  $export = new ilScorm2004Export($this->object,'PDF');
2423  $export->buildExportFile();
2424  $this->ctrl->redirect($this, "showExportList");
2425  }
2426 
2428  {
2429  if(!isset($_POST["file"]))
2430  {
2431  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2432  }
2433 
2434  if (count($_POST["file"]) > 1)
2435  {
2436  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2437  }
2438  $export = new ilSCORM2004Export($this->object);
2439  $export_dir = $export->getExportDirectoryForType($_POST['type'][$_POST['file'][0]]);
2440  ilUtil::deliverFile($export_dir."/".$_POST['file'][0], $_POST['file'][0]);
2441  }
2442 
2447  {
2448  if(!isset($_POST["file"]))
2449  {
2450  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
2451  $this->ctrl->redirect($this, "showExportList");
2452  }
2453 
2454  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
2455  $export_files = $this->object->getExportFiles();
2456 
2457  include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ExportTableGUI.php";
2458  $table_gui = new ilSCORM2004ExportTableGUI($this, 'showExportList', true);
2459  $data = array();
2460  foreach ($export_files as $exp_file)
2461  {
2462  foreach ($_POST['file'] as $delete_file)
2463  {
2464  if (strcmp($delete_file, $exp_file['file']) == 0)
2465  {
2466  $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($exp_file["type"]))
2467  ? " <b>(".$this->lng->txt("public").")<b>"
2468  : "";
2469  $file_arr = explode("__", $exp_file["file"]);
2470  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));
2471  }
2472  }
2473  }
2474  $table_gui->setData($data);
2475  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2476  }
2477 
2482  {
2483  session_unregister("ilExportFiles");
2484  $this->ctrl->redirect($this, "showExportList");
2485  }
2486 
2487 
2491  function deleteExportFile()
2492  {
2493  include_once "./Services/Utilities/classes/class.ilUtil.php";
2494  $export = new ilSCORM2004Export($this->object);
2495  foreach($_POST['file'] as $idx => $file)
2496  {
2497  $export_dir = $export->getExportDirectoryForType($_POST['type'][$idx]);
2498  $exp_file = $export_dir."/".$file;
2499  if (@is_file($exp_file))
2500  {
2501  unlink($exp_file);
2502  }
2503  }
2504  ilUtil::sendSuccess($this->lng->txt('msg_deleted_export_files'), true);
2505  $this->ctrl->redirect($this, "showExportList");
2506  }
2507 
2508  /*
2509  * download export file
2510  */
2512  {
2513  if(!isset($_POST["file"]))
2514  {
2515  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2516  }
2517  if (count($_POST["file"]) > 1)
2518  {
2519  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2520  }
2521 
2522  $export = new ilSCORM2004Export($this->object);
2523  $file = $_POST['file'][0];
2524  $type = $_POST['type'][$_POST['file'][0]];
2525 
2526  if ($this->object->getPublicExportFile($type) == $file)
2527  {
2528  $this->object->setPublicExportFile($type, "");
2529  }
2530  else
2531  {
2532  $this->object->setPublicExportFile($type, $file);
2533  }
2534  $this->object->update();
2535  $this->ctrl->redirect($this, "showExportList");
2536  }
2537 
2538  /*
2539  * perform silent scorm 2004 export and import for view player
2540  */
2541  function preview()
2542  {
2543  global $ilias;
2544 
2545  $export = new ilScorm2004Export($this->object,'SCORM 2004 3rd');
2546  $zipfile = $export->buildExportFile();
2547  $zipPathinfo = pathinfo($zipfile);
2548  $file_path = $this->object->getDataDirectory()."/".($zipPathinfo["basename"]);
2549  copy($zipfile,$file_path);
2550  unlink($zipfile);
2551 
2552  ilUtil::unzip($file_path,true);
2553  ilUtil::renameExecutables($this->object->getDataDirectory());
2554  unlink($file_path);
2555 
2556  include_once ("./Modules/Scorm2004/classes/ilSCORM13Package.php");
2557  $rte_pkg = new ilSCORM13Package();
2558  $rte_pkg->il_import($this->object->getDataDirectory(),$this->object->getId(),$ilias,false,true);
2559 
2560  //increase module version is it necessary?
2561  //$this->object->setModuleVersion($module_version+1);
2562  //$this->object->update();
2563 
2564  //redirect to view player
2565  ilUtil::redirect("ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=".$this->object->getRefID()."&envEditor=1");
2566  }
2567 
2568 } // END class.ilObjSCORM2004LearningModuleGUI
2569 ?>