ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSCORM2004ScoGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeGUI.php");
6 require_once("./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
7 require_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Objective.php");
8 
22 {
26  protected $help;
27 
31  protected $error;
32 
33 
39  public $ctrl = null;
40 
41  public function __construct($a_slm_obj, $a_node_id = 0)
42  {
43  global $DIC;
44 
45  $this->ctrl = $DIC->ctrl();
46  $this->tpl = $DIC["tpl"];
47  $this->tabs = $DIC->tabs();
48  $this->lng = $DIC->language();
49  $this->help = $DIC["ilHelp"];
50  $this->error = $DIC["ilErr"];
51  $ilCtrl = $DIC->ctrl();
52 
53  $ilCtrl->saveParameter($this, "obj_id");
54  $this->ctrl = &$ilCtrl;
55 
56  parent::__construct($a_slm_obj, $a_node_id);
57  }
58 
62  public function getType()
63  {
64  return "sco";
65  }
66 
70  public function executeCommand()
71  {
72  $tpl = $this->tpl;
73  $ilCtrl = $this->ctrl;
74  $ilTabs = $this->tabs;
75 
76  $tpl->loadStandardTemplate();
77 
78  $next_class = $ilCtrl->getNextClass($this);
79  $cmd = $ilCtrl->getCmd();
80 
81  switch ($next_class) {
82  // notes
83  case "ilnotegui":
84  switch ($_GET["notes_mode"]) {
85  default:
86  $ilTabs->setTabActive("sahs_organization");
87  return $this->showOrganization();
88  }
89  break;
90 
91  case 'ilobjectmetadatagui':
92  $this->setTabs();
93  $this->setLocator();
94  include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
95  $md_gui = new ilObjectMetaDataGUI(
96  $this->slm_object,
97  $this->node_object->getType(),
98  $this->node_object->getId()
99  );
100  $md_gui->addMDObserver($this->node_object, 'MDUpdateListener', 'General');
101  $ilCtrl->forwardCommand($md_gui);
102  break;
103 
104  case 'ilscorm2004pagegui':
105  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php");
106  $page_obj = new ilSCORM2004PageGUI("sahs", $_GET["pg_id"]);
107  //$page_obj->setPresentationTitle($page["title"]);
108  $page_obj->setOutputMode(ilPageObjectGUI::PREVIEW);
109  $ilCtrl->forwardCommand($page_obj);
110  break;
111 
112  // mainly to fix #21631
113  case "ilassgenfeedbackpagegui":
114  break;
115 
116  default:
117  $cmd = $ilCtrl->getCmd("showOrganization");
118  $ret = $this->$cmd();
119  break;
120  }
121  }
122 
126  public function showProperties()
127  {
128  $tpl = $this->tpl;
129  $lng = $this->lng;
130  $ilTabs = $this->tabs;
131  $ilCtrl = $this->ctrl;
132 
133  $this->setTabs();
134  $this->setLocator();
135  $ilTabs->setTabActive("sahs_desc_objectives");
136 
137  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
138  $form = new ilPropertyFormGUI();
139 
140  // hide objectives page
141  $cb = new ilCheckboxInputGUI($lng->txt("sahs_hide_objectives_page"), "hide_objectives_page");
142  $cb->setInfo($lng->txt("sahs_hide_objectives_page_info"));
143  $form->addItem($cb);
144  $cb->setChecked($this->node_object->getHideObjectivePage());
145 
146  // description
147  $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
148  $ta->setRows(4);
149  $ta->setCols(55);
150  $ta->setInfo($lng->txt("sahs_list_info"));
151  $form->setTitle($lng->txt("properties"));
152  $form->addItem($ta);
153  include_once "./Services/MetaData/classes/class.ilMD.php";
154  $meta = new ilMD($this->node_object->getSLMId(), $this->node_object->getId(), $this->node_object->getType());
155  $desc_ids = $meta->getGeneral()->getDescriptionIds();
156  $ta->setValue($meta->getGeneral()->getDescription($desc_ids[0])->getDescription());
157 
158  // objectives
159  $sh = new ilFormSectionHeaderGUI();
160  $sh->setTitle($lng->txt("sahs_learning_objectives"));
161  $form->addItem($sh);
162 
163  $objectives = $this->node_object->getObjectives();
164 
165  foreach ($objectives as $ob) {
166  // map info
167  $mappings = $ob->getMappings();
168  $mapinfo = null;
169  foreach ($mappings as $map) {
170  $mapinfo .= $map->getTargetObjectiveID();
171  }
172 
173  if ($mapinfo == null) {
174  $mapinfo = "local";
175  } else {
176  $mapinfo = "global to " . $mapinfo;
177  }
178 
179  // objective
180  $ta = new ilTextAreaInputGUI(
181  $mapinfo,
182  "obj_" . $ob->getId()
183  );
184  $ta->setCols(55);
185  $ta->setRows(4);
186  $ta->setInfo($lng->txt("sahs_list_info"));
187  $form->addItem($ta);
188  $ta->setValue($ob->getObjectiveID());
189  }
190  $form->setFormAction($ilCtrl->getFormAction($this));
191  $form->addCommandButton(
192  "updateProperties",
193  $lng->txt("save")
194  );
195  $tpl->setContent($form->getHTML());
196  }
197 
201  public function updateProperties()
202  {
203  $tpl = $this->tpl;
204  $lng = $this->lng;
205  $empty = false;
206 
207  foreach ($_POST as $key => $value) {
208  if (preg_match('/(obj_)(.+)/', $key, $match)) {
209  $objective = new ilScorm2004Objective($this->node_object->getId(), $match[2]);
210  // if (!$value)
211  // {
212  // $empty=true;
213  // } else {
214  $objective->setObjectiveID(ilUtil::stripSlashes($value));
215  $objective->updateObjective();
216  // }
217  }
218  }
219 
220  $this->node_object->setHideObjectivePage(ilUtil::stripSlashes($_POST["hide_objectives_page"]));
221  $this->node_object->update();
222 
223  include_once "./Services/MetaData/classes/class.ilMD.php";
224  $meta = new ilMD($this->node_object->getSLMId(), $this->node_object->getId(), $this->node_object->getType());
225  $gen = $meta->getGeneral();
226  $desc_ids = $gen->getDescriptionIds();
227  $des = $gen->getDescription($desc_ids[0]);
228  $des->setDescription(ilUtil::stripSlashes($_POST["desc"]));
229  $des->update();
230  $gen->update();
231 
232  if (!$empty) {
233  ilUtil::sendInfo($lng->txt("saved_successfully"), true);
234  } else {
235  ilUtil::sendFailure($lng->txt("sahs_empty_objectives_are_not_allowed"), true);
236  }
237  $this->showProperties();
238  }
239 
240  public function sahs_questions()
241  {
242  $this->setTabs();
243  $this->setLocator();
244 
245  $tree = new ilTree($this->slm_object->getId());
246  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
247  $tree->setTreeTablePK("slm_id");
248  $questions = [];
249  foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) {
250  // get question ids
251  $qids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]);
252  if (count($qids) > 0) {
253  // output questions
254  foreach ($qids as $qid) {
255  $questions[] = [
256  "page" => $page,
257  "qid" => $qid
258  ];
259  }
260  }
261  }
262 
263  $tab = new ILIAS\Scorm2004\Editor\ilSCORMQuestionOverviewTableGUI($this, "sahs_questions");
264  $tab->setData($questions);
265  $this->tpl->setContent($tab->getHTML());
266  }
267 
268  public function getEditTree()
269  {
270  die("deprecated");
271  $slm_tree = new ilTree($this->node_object->getId(), $this->slm_object->getId());
272  $slm_tree->setTreeTablePK("slm_id");
273  $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
274  return $slm_tree;
275  }
276 
280  public function setTabs()
281  {
282  $ilTabs = $this->tabs;
283  $ilCtrl = $this->ctrl;
284  $tpl = $this->tpl;
285  $lng = $this->lng;
286  $ilHelp = $this->help;
287 
288  $ilHelp->setScreenIdComponent("sahsed");
289 
290  // subelements
291  $ilTabs->addTarget(
292  "sahs_organization",
293  $ilCtrl->getLinkTarget($this, 'showOrganization'),
294  "showOrganization",
295  get_class($this)
296  );
297 
298  // properties (named learning objectives, since here is currently
299  // no other property)
300  $ilTabs->addTarget(
301  "sahs_desc_objectives",
302  $ilCtrl->getLinkTarget($this, 'showProperties'),
303  "showProperties",
304  get_class($this)
305  );
306 
307  // questions
308  $ilTabs->addTarget(
309  "sahs_questions",
310  $ilCtrl->getLinkTarget($this, 'sahs_questions'),
311  "sahs_questions",
312  get_class($this)
313  );
314 
315  // resources
316  $ilTabs->addTarget(
317  "cont_files",
318  $ilCtrl->getLinkTarget($this, 'sco_resources'),
319  "sco_resources",
320  get_class($this)
321  );
322 
323  // metadata
324  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
325  $mdgui = new ilObjectMetaDataGUI(
326  $this->slm_object,
327  $this->node_object->getType(),
328  $this->node_object->getId()
329  );
330  $mdtab = $mdgui->getTab();
331  if ($mdtab) {
332  $ilTabs->addTarget(
333  "meta_data",
334  $mdtab,
335  "",
336  "ilmdeditorgui"
337  );
338  }
339 
340  // export
341  $ilTabs->addTarget(
342  "export",
343  $ilCtrl->getLinkTarget($this, "showExportList"),
344  "showExportList",
345  get_class($this)
346  );
347 
348  // import
349  $ilTabs->addTarget(
350  "import",
351  $ilCtrl->getLinkTarget($this, "import"),
352  "import",
353  get_class($this)
354  );
355 
356  // preview
357  $ilTabs->addNonTabbedLink(
358  "preview",
359  $lng->txt("cont_preview"),
360  $ilCtrl->getLinkTarget($this, 'sco_preview'),
361  "_blank"
362  );
363 
364  $tpl->setTitleIcon(ilUtil::getImagePath("icon_sco.svg"));
365  $tpl->setTitle(
366  $lng->txt("sahs_unit") . ": " . $this->node_object->getTitle()
367  );
368  }
369 
373  public function proceedDragDrop()
374  {
375  $ilCtrl = $this->ctrl;
376 
377  //echo "-".$_POST["il_hform_source_id"]."-".$_POST["il_hform_target_id"]."-".$_POST["il_hform_fc"]."-";
378  $this->slm_object->executeDragDrop(
379  $_POST["il_hform_source_id"],
380  $_POST["il_hform_target_id"],
381  $_POST["il_hform_fc"],
382  $_POST["il_hform_as_subitem"]
383  );
384  $ilCtrl->redirect($this, "showOrganization");
385  }
386 
390  public function sco_preview()
391  {
392  global $DIC;
393  $tpl = $DIC['tpl'];
394 
395  $ilCtrl = $this->ctrl;
396 
397  // init main template
398  $tpl = new ilGlobalTemplate("tpl.legacy_main.html", true, true, "Modules/Scorm2004");
399  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
400  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
401  $tpl->setBodyClass("");
402  $tpl->setCurrentBlock("ContentStyle");
403  $tpl->setVariable(
404  "LOCATION_CONTENT_STYLESHEET",
405  ilObjStyleSheet::getContentStylePath($this->slm_object->getStyleSheetId())
406  );
407  $tpl->parseCurrentBlock();
408 
409  // get javascript
410  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
413  $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/pure.js");
414  $tpl->addJavaScript("./Modules/Scorm2004/scripts/pager.js");
415  $tpl->addJavaScript("./Services/COPage/js/ilCOPagePres.js");
416  $tpl->addJavascript(iljQueryUtil::getLocalMaphilightPath());
417 
418  $tpl->addOnLoadCode("pager.Init();");
419 
420  $tree = new ilTree($this->slm_object->getId());
421  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
422  $tree->setTreeTablePK("slm_id");
423  include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php";
424  include_once "./Services/MetaData/classes/class.ilMD.php";
425 
426  $meta = new ilMD($this->node_object->getSLMId(), $this->node_object->getId(), $this->node_object->getType());
427  $desc_ids = $meta->getGeneral()->getDescriptionIds();
428  $sco_description = $meta->getGeneral()->getDescription($desc_ids[0])->getDescription();
429 
430  // get sco template
431  $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004");
432 
433  // navigation
434  $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId());
435  ilSCORM2004Asset::renderNavigation($sco_tpl, "", $lk);
436 
437  // meta page (description and objectives)
439  $sco_tpl,
440  $this->node_object,
441  $this->node_object->getType()
442  );
443 
444  // init export (this initialises glossary template)
446  $terms = $this->node_object->getGlossaryTermIds();
447 
448  // render page
449  foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) {
450  $page_obj = new ilSCORM2004PageGUI(
451  $this->node_object->getType(),
452  $page["obj_id"],
453  0,
454  $this->slm_object->getId()
455  );
456  $page_obj->setPresentationTitle($page["title"]);
457  $page_obj->setOutputMode(ilPageObjectGUI::PREVIEW);
458  $page_obj->setStyleId($this->slm_object->getStyleSheetId());
459  if (count($terms) > 1) {
460  $page_obj->setGlossaryOverviewInfo(
462  $this->node_object
463  );
464  }
465  $sco_tpl->setCurrentBlock("page_preview");
466  $html = $ilCtrl->getHTML($page_obj);
467  //$sco_tpl->setVariable("PAGE_PRV", $page_obj->showPage("export"));
468  $sco_tpl->setVariable("PAGE_PRV", $html);
469  $sco_tpl->parseCurrentBlock();
470  }
471 
472  $output = $sco_tpl->get();
473 
474  // append glossary entries on the sco level
475  $output .= ilSCORM2004PageGUI::getGlossaryHTML($this->node_object);
476 
477  //insert questions
478  require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
479  $output = preg_replace_callback("/{{{{{(Question;)(il__qst_[0-9]+)}}}}}/", array(get_class($this), 'insertQuestion'), $output);
480  $output = "<script>var ScormApi=null;" . ilQuestionExporter::questionsJS() . "</script>" . $output;
481 
482  $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId());
483 
484  $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/question_handling.js");
485  $tpl->addCss("./Modules/Scorm2004/templates/default/question_handling.css");
486 
487  include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
489 
490  //inline JS
491  $output .= '<script type="text/javascript" src="./Modules/Scorm2004/scripts/questions/question_handling.js"></script>';
492  $tpl->addOnLoadCode("ilias.questions.refresh_lang();");
493  $tpl->setVariable("CONTENT", $output);
494  $tpl->printToStdout();
495  exit;
496  }
497 
498  //callback function for question export
499  private static function insertQuestion($matches)
500  {
501  $q_exporter = new ilQuestionExporter(false);
502  return $q_exporter->exportQuestion($matches[2]);
503  }
504 
508  public function selectExport()
509  {
510  switch ($_POST['select_export']) {
511  case "exportScorm12":
512  case "exportScorm2004_3rd":
513  case "exportScorm2004_4th":
514  case "exportPDF":
515  case "exportHTML":
516  $this->ctrl->redirect($this, $_POST['select_export']);
517  break;
518  default:
519  $this->ctrl->redirect($this, 'showExportList');
520  break;
521  }
522  }
523 
524  public function showExportList()
525  {
526  $tpl = $this->tpl;
527  $ilCtrl = $this->ctrl;
528  $lng = $this->lng;
529 
530  $this->setTabs();
531  $this->setLocator();
532 
533 
534  $template = new ilTemplate("tpl.scorm2004_export_buttons.html", true, true, 'Modules/Scorm2004');
535 
536  $buttons = array(
537  "exportScorm2004_3rd" => $lng->txt("scorm_create_export_file_scrom2004"),
538  "exportScorm2004_4th" => $lng->txt("scorm_create_export_file_scrom2004_4th"),
539  "exportScorm12" => $lng->txt("scorm_create_export_file_scrom12"),
540  "exportPDF" => $lng->txt("scorm_create_export_file_pdf"),
541  "exportHTML" => $lng->txt("scorm_create_export_file_html")
542  );
543  foreach ($buttons as $value => $text) {
544  $template->setCurrentBlock('option');
545  $template->setVariable('OPTION_VALUE', $value);
546  $template->setVariable('OPTION_TITLE', ilUtil::prepareFormOutput($text));
547  $template->parseCurrentBlock();
548  }
549  $template->setVariable('EXPORT_TITLE', $lng->txt('export'));
550  $template->setVariable('EXPORT_LABEL', $lng->txt('type'));
551  $template->setVariable('FORMACTION', $ilCtrl->getFormAction($this, 'selectExport'));
552 
553  $export_files = $this->node_object->getExportFiles();
554 
555  include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ExportTableGUI.php";
556  $table_gui = new ilSCORM2004ExportTableGUI($this, 'showExportList');
557  $data = array();
558  foreach ($export_files as $exp_file) {
559  $filetype = $exp_file['type'];
560  $public_str = "";
561  // $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($filetype))
562  // ? " <b>(".$this->lng->txt("public").")<b>"
563  // : "";
564  $file_arr = explode("__", $exp_file["file"]);
565  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));
566  }
567  $table_gui->setData($data);
568  $tpl->setVariable('ADM_CONTENT', $template->get() . "\n" . $table_gui->getHTML());
569  }
570 
571  public function exportScorm2004_4th()
572  {
573  $export = new ilScorm2004Export($this->node_object, 'SCORM 2004 4th');
574  $export->buildExportFile();
575  $this->ctrl->redirect($this, "showExportList");
576  }
577 
578 
579  public function exportScorm2004_3rd()
580  {
581  $export = new ilScorm2004Export($this->node_object, 'SCORM 2004 3rd');
582  $export->buildExportFile();
583  $this->ctrl->redirect($this, "showExportList");
584  }
585 
586  public function exportScorm12()
587  {
588  $export = new ilScorm2004Export($this->node_object, 'SCORM 1.2');
589  $export->buildExportFile();
590  $this->ctrl->redirect($this, "showExportList");
591  }
592 
593  public function exportHTML()
594  {
595  $export = new ilScorm2004Export($this->node_object, 'HTML');
596  $export->buildExportFile();
597  $this->ctrl->redirect($this, "showExportList");
598  }
599 
600  public function exportISO()
601  {
602  $export = new ilScorm2004Export($this->node_object, 'ISO');
603  $export->buildExportFile();
604  $this->ctrl->redirect($this, "showExportList");
605  }
606 
607  public function exportPDF()
608  {
609  $export = new ilScorm2004Export($this->node_object, 'PDF');
610  $export->buildExportFile();
611  $this->ctrl->redirect($this, "showExportList");
612  }
613 
614  public function downloadExportFile()
615  {
616  $file = basename($_GET['file']);
617  $export = new ilSCORM2004Export($this->node_object);
618  $export_dir = $export->getExportDirectoryForType($_GET['type']);
619  ilFileDelivery::deliverFileAttached($export_dir . "/" . $file, $file);
620  }
621 
625  public function confirmDeleteExportFile()
626  {
627  $lng = $this->lng;
628  $tpl = $this->tpl;
629 
630  if (!isset($_POST["file"])) {
631  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
632  $this->ctrl->redirect($this, "showExportList");
633  }
634 
635  ilUtil::sendQuestion($lng->txt("info_delete_sure"));
636  $export_files = $this->node_object->getExportFiles();
637 
638  include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ExportTableGUI.php";
639  $table_gui = new ilSCORM2004ExportTableGUI($this, 'showExportList', true);
640  $data = array();
641  foreach ($export_files as $exp_file) {
642  foreach ($_POST['file'] as $delete_file) {
643  if (strcmp($delete_file, $exp_file['file']) == 0) {
644  $public_str = "";
645  // $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($exp_file["type"]))
646  // ? " <b>(".$this->lng->txt("public").")<b>"
647  // : "";
648  $file_arr = explode("__", $exp_file["file"]);
649  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));
650  }
651  }
652  }
653  $table_gui->setData($data);
654  $tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
655  }
656 
660  public function cancelDeleteExportFile()
661  {
662  ilSession::clear("ilExportFiles");
663  $this->ctrl->redirect($this, "showExportList");
664  }
665 
666 
670  public function deleteExportFile()
671  {
672  $lng = $this->lng;
673  include_once "./Services/Utilities/classes/class.ilUtil.php";
674  $export = new ilSCORM2004Export($this->node_object);
675  foreach ($_POST['file'] as $idx => $file) {
676  $export_dir = $export->getExportDirectoryForType($_POST['type'][$idx]);
677  $exp_file = $export_dir . "/" . $file;
678  if (@is_file($exp_file)) {
679  unlink($exp_file);
680  }
681  }
682  ilUtil::sendSuccess($lng->txt('msg_deleted_export_files'), true);
683  $this->ctrl->redirect($this, "showExportList");
684  }
685 
686  public function getExportResources()
687  {
688  $export_files = array();
689 
690  require_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php";
691  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
692  include_once "./Modules/File/classes/class.ilObjFile.php";
693  $tree = new ilTree($this->slm_object->getId());
694  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
695  $tree->setTreeTablePK("slm_id");
696  $i = 0;
697  foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) {
698  $page_obj = new ilSCORM2004Page($page["obj_id"]);
699  $page_obj->buildDom();
700  $mob_ids = $page_obj->collectMediaObjects(false);
701  foreach ($mob_ids as $mob_id) {
702  if ($mob_id > 0 && ilObject::_exists($mob_id)) {
703  $path = ilObjMediaObject::_lookupStandardItemPath($mob_id, false, false);
704 
705  $media_obj = new ilObjMediaObject($mob_id);
706  $export_files[$i]["date"] = $media_obj->getCreateDate();
707  $export_files[$i]["size"] = @filesize($path); // could be remote, e.g. youtube video
708  $export_files[$i]["file"] = $media_obj->getTitle();
709  $export_files[$i]["type"] = $media_obj->getDescription();
710  $export_files[$i]["path"] = $path;
711  $this->ctrl->setParameter(
712  $this,
713  "resource",
714  rawurlencode(ilObjMediaObject::_lookupStandardItemPath($mob_id, false, false))
715  );
716  $export_files[$i]["link"] = $this->ctrl->getLinkTarget($this, "downloadResource");
717  $i++;
718  }
719  }
720  include_once("./Services/COPage/classes/class.ilPCFileList.php");
721  $file_ids = ilPCFileList::collectFileItems($page_obj, $page_obj->getDomDoc());
722  foreach ($file_ids as $file_id) {
723  $file_obj = new ilObjFile($file_id, false);
724  $export_files[$i]["date"] = $file_obj->getCreateDate();
725  $export_files[$i]["size"] = $file_obj->getFileSize();
726  $export_files[$i]["file"] = $file_obj->getFileName();
727  $export_files[$i]["type"] = $file_obj->getFileType();
728  $export_files[$i]["file_id"] = $file_id;
729  $this->ctrl->setParameter($this, "file_id", $file_id);
730  $export_files[$i]["link"] = $this->ctrl->getLinkTarget($this, "downloadFile", "");
731  $i++;
732  }
733  unset($page_obj);
734  }
735 
736  return $export_files;
737  }
738 
739  public function sco_resources()
740  {
741  $this->setTabs();
742  $this->setLocator();
743  $export_files = $this->getExportResources();
744 
745  $tab = new \ILIAS\Scorm2004\Editor\ilSCORMMediaOverviewTableGUI($this, "sco_resources");
746  $tab->setData($export_files);
747 
748  $this->tpl->setContent($tab->getHTML());
749  }
750 
751  public function downloadResource()
752  {
753  $export_files = $this->getExportResources();
754 
755  if ($_GET["file_id"] > 0) {
756  $file = new ilObjFile($_GET["file_id"], false);
757  }
758 
759  // check that file really belongs to SCORM module (security)
760  foreach ($export_files as $f) {
761  if (is_object($file)) {
762  if ($f["file"] == $file->getFileName()) {
763  $file->sendFile();
764  }
765  } else {
766  if ($f["path"] == $_GET["resource"]) {
767  if (is_file($f["path"])) {
768  ilUtil::deliverFile($f["path"], $f["file"]);
769  }
770  }
771  }
772  }
773  exit;
774  }
775 
776  public function downloadFile()
777  {
778  $file = explode("_", $_GET["file_id"]);
779  require_once("./Modules/File/classes/class.ilObjFile.php");
780  $fileObj = new ilObjFile($file[count($file) - 1], false);
781  $fileObj->sendFile();
782  exit;
783  }
784 
785  public function import()
786  {
787  $tpl = $this->tpl;
788  $lng = $this->lng;
789 
790  $this->setTabs();
791  $this->setLocator();
792 
793  $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scormeditor_sco_import.html", "Modules/Scorm2004");
794 
795  $tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_lm.svg'));
796  $tpl->setVariable("ALT_IMG", $lng->txt("obj_sahs"));
797 
798  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
799 
800  $tpl->setVariable("BTN_NAME", "importSave");
801 
802  // this leads to _top target which removes the left organization frame
803  //$tpl->setVariable("TARGET", ' target="'.ilFrameTargetInfo::_getFrame("MainContent").'" ');
804 
805  $tpl->setVariable("TXT_UPLOAD", $lng->txt("upload"));
806  $tpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
807  $tpl->setVariable("TXT_IMPORT_SCO", $lng->txt("import_sco_object"));
808  $tpl->setVariable("TXT_SELECT_FILE", $lng->txt("select_file"));
809  $tpl->setVariable("TXT_VALIDATE_FILE", $lng->txt("cont_validate_file"));
810 
811  // get the value for the maximal uploadable filesize from the php.ini (if available)
812  $umf = get_cfg_var("upload_max_filesize");
813  // get the value for the maximal post data from the php.ini (if available)
814  $pms = get_cfg_var("post_max_size");
815 
816  //convert from short-string representation to "real" bytes
817  $multiplier_a = array("K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024);
818 
819  $umf_parts = preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
820  $pms_parts = preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
821 
822  if (count($umf_parts) == 2) {
823  $umf = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
824  }
825  if (count($pms_parts) == 2) {
826  $pms = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
827  }
828 
829  // use the smaller one as limit
830  $max_filesize = min($umf, $pms);
831 
832  if (!$max_filesize) {
833  $max_filesize = max($umf, $pms);
834  }
835 
836  //format for display in mega-bytes
837  $max_filesize = sprintf("%.1f MB", $max_filesize / 1024 / 1024);
838 
839  // gives out the limit as a little notice
840  $tpl->setVariable("TXT_FILE_INFO", $lng->txt("file_notice") . " $max_filesize");
841  }
842 
843  public function importSave()
844  {
845  $lng = $this->lng;
847 
848  // check if file was uploaded
849  $source = $_FILES["scormfile"]["tmp_name"];
850  if (($source == 'none') || (!$source)) {
851  $ilErr->raiseError("No file selected!", $ilErr->MESSAGE);
852  }
853  // get_cfg_var("upload_max_filesize"); // get the may filesize form t he php.ini
854  switch ($_FILES["scormfile"]["error"]) {
855  case UPLOAD_ERR_INI_SIZE:
856  $ilErr->raiseError($lng->txt("err_max_file_size_exceeds"), $ilErr->MESSAGE);
857  break;
858 
859  case UPLOAD_ERR_FORM_SIZE:
860  $ilErr->raiseError($lng->txt("err_max_file_size_exceeds"), $ilErr->MESSAGE);
861  break;
862 
863  case UPLOAD_ERR_PARTIAL:
864  $ilErr->raiseError($lng->txt("err_partial_file_upload"), $ilErr->MESSAGE);
865  break;
866 
867  case UPLOAD_ERR_NO_FILE:
868  $ilErr->raiseError($lng->txt("err_no_file_uploaded"), $ilErr->MESSAGE);
869  break;
870  }
871 
872  $file = pathinfo($_FILES["scormfile"]["name"]);
873  $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1);
874  $file_path = $this->slm_object->getDataDirectory() . "/" . $this->node_object->getId() . "/" . $_FILES["scormfile"]["name"];
875  ilUtil::createDirectory($this->slm_object->getDataDirectory() . "/" . $this->node_object->getId());
876  ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"], $_FILES["scormfile"]["name"], $file_path);
877  ilUtil::unzip($file_path);
878  ilUtil::renameExecutables($this->slm_object->getDataDirectory() . "/" . $this->node_object->getId());
879 
880  include_once("./Modules/Scorm2004/classes/ilSCORM13Package.php");
881  $newPack = new ilSCORM13Package();
882  $newPack->il_importSco($this->slm_object->getId(), $this->node_object->getId(), $this->slm_object->getDataDirectory() . "/" . $this->node_object->getId());
883 
884  $this->ctrl->redirect($this, "showOrganization");
885  }
886 
890  public function cancel()
891  {
892  $this->ctrl->redirect($this, "showOrganization");
893  }
894 
901  public static function getGlossaryOverviewId()
902  {
903  return "sco_glo_ov";
904  }
905 
912  public static function getGloOverviewOv($a_sco)
913  {
914  global $DIC;
915 
916  $lng = $DIC->language();
917 
918  $tpl = new ilTemplate("tpl.sco_glossary_overview.html", true, true, "Modules/Scorm2004");
919 
920  $terms = $a_sco->getGlossaryTermIds();
921  $lk = ilObjSAHSLearningModule::getAffectiveLocalization($a_sco->getSLMId());
922  foreach ($terms as $k => $t) {
923  $tpl->setCurrentBlock("link");
924  $tpl->setVariable("TXT_LINK", $t);
925  $tpl->setVariable("ID_LINK", "glo_ov_t" . $k);
926  $tpl->parseCurrentBlock();
927  }
928 
929  $tpl->setVariable("DIV_ID", ilSCORM2004ScoGUI::getGlossaryOverviewId());
930  $tpl->setVariable("TXT_SCO_GLOSSARY", $lng->txtlng("content", "cont_sco_glossary", $lk));
931  $tpl->setVariable("TXT_CLOSE", $lng->txtlng("common", "close", $lk));
932 
933  if (count($terms) > 1) {
934  return $tpl->get();
935  } else {
936  return "";
937  }
938  }
939 }
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
__construct($a_slm_obj, $a_node_id=0)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
Class ilObjectMetaDataGUI.
Scorm 2004 Question Exporter.
exit
Definition: login.php:29
$data
Definition: storeScorm.php:23
static _getQuestionIdsForPage($a_parent_type, $a_page_id, $a_lang="-")
Get all questions of a page.
static _lookupStandardItemPath( $a_mob_id, $a_url_encode=false, $a_web=true)
Get path for standard item.
proceedDragDrop()
Perform drag and drop action.
This class represents a property form user interface.
special template class to simplify handling of ITX/PEAR
Class ilSCORM2004NodeGUI.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
This class represents a section header in a property form.
$ctrl
Constructor public.
static getGloOverviewOv($a_sco)
des
addMDObserver($a_class, $a_method, $a_section)
static renderMetaPage($a_tpl, $a_sco, $a_asset_type="", $mode="")
Render meta page (description/objectives at beginning)
selectExport()
Select the export type of the SCORM 2004 module.
This class represents a checkbox property in a property form.
setLocator()
Set Locator Items.
const IL_CAL_UNIX
static getGlossaryOverviewId()
Get sco glossary overlay id.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
$ilErr
Definition: raiseError.php:18
getTab($a_base_class=null)
Get tab link if available.
cancelDeleteExportFile()
cancel deletion of export files
help()
Definition: help.php:2
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if($format !==null) $name
Definition: metadata.php:230
static insertQuestion($matches)
static deliverFileAttached($path_to_file, $download_file_name='', $mime_type='', $delete_file=false)
void
Class ilSCORM2004Page.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static collectFileItems($a_page, $a_domdoc)
Get all file items that are used within the page.
global $DIC
Definition: goto.php:24
& getGeneral()
Definition: class.ilMD.php:40
setPresentationTitle($a_title="")
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static createDirectory($a_dir, $a_mod=0755)
create directory
Export class for SCORM 2004 object.
Class ilObjMediaObject.
static clear($a_var)
Unset a value.
showOrganization()
Confirm deletion screen (delete page or structure objects)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
updateProperties()
update Properties
static renderNavigation($a_tpl, $a_spacer_img="", $a_lang="")
Render navigation.
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
Class ilSCORM2004Page GUI class.
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
$ret
Definition: parser.php:6
static getLocalMaphilightPath()
Get local path of maphilight file.
Class ilSCORM2004ScoGUI.
static getGlossaryHTML($a_sco)
Get glossary html (only in export mode)
static getAffectiveLocalization($a_id)
Get affective localization.
$source
Definition: metadata.php:76
deleteExportFile()
delete export files
$_POST["username"]
showProperties()
Show learning objectives.
executeCommand()
execute command
confirmDeleteExportFile()
confirmation screen for export file deletion
static questionsJS(array $a_qids=null)
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
$i
Definition: metadata.php:24
static initExport()
Init export.
static initJavascript()
Init javascript.