ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
5require_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeGUI.php");
6require_once("./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
7require_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 {
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 {
130 $ilTabs = $this->tabs;
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 {
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
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;
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 {
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
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");
417 $tpl->addCss("./Modules/Test/templates/default/ta.css");
418
419 $tpl->addOnLoadCode("pager.Init();");
420
421 $tree = new ilTree($this->slm_object->getId());
422 $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
423 $tree->setTreeTablePK("slm_id");
424 include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php";
425 include_once "./Services/MetaData/classes/class.ilMD.php";
426
427 $meta = new ilMD($this->node_object->getSLMId(), $this->node_object->getId(), $this->node_object->getType());
428 $desc_ids = $meta->getGeneral()->getDescriptionIds();
429 $sco_description = $meta->getGeneral()->getDescription($desc_ids[0])->getDescription();
430
431 // get sco template
432 $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004");
433
434 // navigation
435 $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId());
436 ilSCORM2004Asset::renderNavigation($sco_tpl, "", $lk);
437
438 // meta page (description and objectives)
440 $sco_tpl,
441 $this->node_object,
442 $this->node_object->getType()
443 );
444
445 // init export (this initialises glossary template)
447 $terms = $this->node_object->getGlossaryTermIds();
448
449 // render page
450 foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) {
451 $page_obj = new ilSCORM2004PageGUI(
452 $this->node_object->getType(),
453 $page["obj_id"],
454 0,
455 $this->slm_object->getId()
456 );
457 $page_obj->setPresentationTitle($page["title"]);
458 $page_obj->setOutputMode(ilPageObjectGUI::PREVIEW);
459 $page_obj->setStyleId($this->slm_object->getStyleSheetId());
460 if (count($terms) > 1) {
461 $page_obj->setGlossaryOverviewInfo(
463 $this->node_object
464 );
465 }
466 $sco_tpl->setCurrentBlock("page_preview");
467 $html = $ilCtrl->getHTML($page_obj);
468 //$sco_tpl->setVariable("PAGE_PRV", $page_obj->showPage("export"));
469 $sco_tpl->setVariable("PAGE_PRV", $html);
470 $sco_tpl->parseCurrentBlock();
471 }
472
473 $output = $sco_tpl->get();
474
475 // append glossary entries on the sco level
476 $output .= ilSCORM2004PageGUI::getGlossaryHTML($this->node_object);
477
478 //insert questions
479 require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
480 $output = preg_replace_callback("/{{{{{(Question;)(il__qst_[0-9]+)}}}}}/", array(get_class($this), 'insertQuestion'), $output);
481 $output = "<script>var ScormApi=null;" . ilQuestionExporter::questionsJS() . "</script>" . $output;
482
483 $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId());
484
485 $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/question_handling.js");
486 $tpl->addCss("./Modules/Scorm2004/templates/default/question_handling.css");
487
488 include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
490
491 //inline JS
492 $output .= '<script type="text/javascript" src="./Modules/Scorm2004/scripts/questions/question_handling.js"></script>';
493 $tpl->addOnLoadCode("ilias.questions.refresh_lang();");
494 $tpl->setVariable("CONTENT", $output);
495 $tpl->printToStdout();
496 exit;
497 }
498
499 //callback function for question export
500 private static function insertQuestion($matches)
501 {
502 $q_exporter = new ilQuestionExporter(false);
503 return $q_exporter->exportQuestion($matches[2]);
504 }
505
509 public function selectExport()
510 {
511 switch ($_POST['select_export']) {
512 case "exportScorm12":
513 case "exportScorm2004_3rd":
514 case "exportScorm2004_4th":
515 case "exportPDF":
516 case "exportHTML":
517 $this->ctrl->redirect($this, $_POST['select_export']);
518 break;
519 default:
520 $this->ctrl->redirect($this, 'showExportList');
521 break;
522 }
523 }
524
525 public function showExportList()
526 {
530
531 $this->setTabs();
532 $this->setLocator();
533
534
535 $template = new ilTemplate("tpl.scorm2004_export_buttons.html", true, true, 'Modules/Scorm2004');
536
537 $buttons = array(
538 "exportScorm2004_3rd" => $lng->txt("scorm_create_export_file_scrom2004"),
539 "exportScorm2004_4th" => $lng->txt("scorm_create_export_file_scrom2004_4th"),
540 "exportScorm12" => $lng->txt("scorm_create_export_file_scrom12"),
541 "exportPDF" => $lng->txt("scorm_create_export_file_pdf"),
542 "exportHTML" => $lng->txt("scorm_create_export_file_html")
543 );
544 foreach ($buttons as $value => $text) {
545 $template->setCurrentBlock('option');
546 $template->setVariable('OPTION_VALUE', $value);
547 $template->setVariable('OPTION_TITLE', ilUtil::prepareFormOutput($text));
548 $template->parseCurrentBlock();
549 }
550 $template->setVariable('EXPORT_TITLE', $lng->txt('export'));
551 $template->setVariable('EXPORT_LABEL', $lng->txt('type'));
552 $template->setVariable('FORMACTION', $ilCtrl->getFormAction($this, 'selectExport'));
553
554 $export_files = $this->node_object->getExportFiles();
555
556 include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ExportTableGUI.php";
557 $table_gui = new ilSCORM2004ExportTableGUI($this, 'showExportList');
558 $data = array();
559 foreach ($export_files as $exp_file) {
560 $filetype = $exp_file['type'];
561 $public_str = "";
562 // $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($filetype))
563 // ? " <b>(".$this->lng->txt("public").")<b>"
564 // : "";
565 $file_arr = explode("__", $exp_file["file"]);
566 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));
567 }
568 $table_gui->setData($data);
569 $tpl->setVariable('ADM_CONTENT', $template->get() . "\n" . $table_gui->getHTML());
570 }
571
572 public function exportScorm2004_4th()
573 {
574 $export = new ilScorm2004Export($this->node_object, 'SCORM 2004 4th');
575 $export->buildExportFile();
576 $this->ctrl->redirect($this, "showExportList");
577 }
578
579
580 public function exportScorm2004_3rd()
581 {
582 $export = new ilScorm2004Export($this->node_object, 'SCORM 2004 3rd');
583 $export->buildExportFile();
584 $this->ctrl->redirect($this, "showExportList");
585 }
586
587 public function exportScorm12()
588 {
589 $export = new ilScorm2004Export($this->node_object, 'SCORM 1.2');
590 $export->buildExportFile();
591 $this->ctrl->redirect($this, "showExportList");
592 }
593
594 public function exportHTML()
595 {
596 $export = new ilScorm2004Export($this->node_object, 'HTML');
597 $export->buildExportFile();
598 $this->ctrl->redirect($this, "showExportList");
599 }
600
601 public function exportISO()
602 {
603 $export = new ilScorm2004Export($this->node_object, 'ISO');
604 $export->buildExportFile();
605 $this->ctrl->redirect($this, "showExportList");
606 }
607
608 public function exportPDF()
609 {
610 $export = new ilScorm2004Export($this->node_object, 'PDF');
611 $export->buildExportFile();
612 $this->ctrl->redirect($this, "showExportList");
613 }
614
615 public function downloadExportFile()
616 {
617 $file = str_replace("..", "", $_GET['file']);
618 $export = new ilSCORM2004Export($this->node_object);
619 $export_dir = $export->getExportDirectoryForType($_GET['type']);
620 ilUtil::deliverFile($export_dir . "/" . $file, $file);
621 }
622
626 public function confirmDeleteExportFile()
627 {
630
631 if (!isset($_POST["file"])) {
632 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
633 $this->ctrl->redirect($this, "showExportList");
634 }
635
636 ilUtil::sendQuestion($lng->txt("info_delete_sure"));
637 $export_files = $this->node_object->getExportFiles();
638
639 include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ExportTableGUI.php";
640 $table_gui = new ilSCORM2004ExportTableGUI($this, 'showExportList', true);
641 $data = array();
642 foreach ($export_files as $exp_file) {
643 foreach ($_POST['file'] as $delete_file) {
644 if (strcmp($delete_file, $exp_file['file']) == 0) {
645 $public_str = "";
646 // $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($exp_file["type"]))
647 // ? " <b>(".$this->lng->txt("public").")<b>"
648 // : "";
649 $file_arr = explode("__", $exp_file["file"]);
650 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));
651 }
652 }
653 }
654 $table_gui->setData($data);
655 $tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
656 }
657
661 public function cancelDeleteExportFile()
662 {
663 ilSession::clear("ilExportFiles");
664 $this->ctrl->redirect($this, "showExportList");
665 }
666
667
671 public function deleteExportFile()
672 {
674 include_once "./Services/Utilities/classes/class.ilUtil.php";
675 $export = new ilSCORM2004Export($this->node_object);
676 foreach ($_POST['file'] as $idx => $file) {
677 $export_dir = $export->getExportDirectoryForType($_POST['type'][$idx]);
678 $exp_file = $export_dir . "/" . $file;
679 if (@is_file($exp_file)) {
680 unlink($exp_file);
681 }
682 }
683 ilUtil::sendSuccess($lng->txt('msg_deleted_export_files'), true);
684 $this->ctrl->redirect($this, "showExportList");
685 }
686
687 public function getExportResources()
688 {
689 $export_files = array();
690
691 require_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php";
692 include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
693 include_once "./Modules/File/classes/class.ilObjFile.php";
694 $tree = new ilTree($this->slm_object->getId());
695 $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
696 $tree->setTreeTablePK("slm_id");
697 $i = 0;
698 foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) {
699 $page_obj = new ilSCORM2004Page($page["obj_id"]);
700 $page_obj->buildDom();
701 $mob_ids = $page_obj->collectMediaObjects(false);
702 foreach ($mob_ids as $mob_id) {
703 if ($mob_id > 0 && ilObject::_exists($mob_id)) {
704 $path = ilObjMediaObject::_lookupStandardItemPath($mob_id, false, false);
705
706 $media_obj = new ilObjMediaObject($mob_id);
707 $export_files[$i]["date"] = $media_obj->getCreateDate();
708 $export_files[$i]["size"] = @filesize($path); // could be remote, e.g. youtube video
709 $export_files[$i]["file"] = $media_obj->getTitle();
710 $export_files[$i]["type"] = $media_obj->getDescription();
711 $export_files[$i]["path"] = $path;
712 $this->ctrl->setParameter(
713 $this,
714 "resource",
715 rawurlencode(ilObjMediaObject::_lookupStandardItemPath($mob_id, false, false))
716 );
717 $export_files[$i]["link"] = $this->ctrl->getLinkTarget($this, "downloadResource");
718 $i++;
719 }
720 }
721 include_once("./Services/COPage/classes/class.ilPCFileList.php");
722 $file_ids = ilPCFileList::collectFileItems($page_obj, $page_obj->getDomDoc());
723 foreach ($file_ids as $file_id) {
724 $file_obj = new ilObjFile($file_id, false);
725 $export_files[$i]["date"] = $file_obj->getCreateDate();
726 $export_files[$i]["size"] = $file_obj->getFileSize();
727 $export_files[$i]["file"] = $file_obj->getFileName();
728 $export_files[$i]["type"] = $file_obj->getFileType();
729 $export_files[$i]["file_id"] = $file_id;
730 $this->ctrl->setParameter($this, "file_id", $file_id);
731 $export_files[$i]["link"] = $this->ctrl->getLinkTarget($this, "downloadFile", "");
732 $i++;
733 }
734 unset($page_obj);
735 }
736
737 return $export_files;
738 }
739
740 public function sco_resources()
741 {
742 $this->setTabs();
743 $this->setLocator();
744 $export_files = $this->getExportResources();
745
746 $tab = new \ILIAS\Scorm2004\Editor\ilSCORMMediaOverviewTableGUI($this, "sco_resources");
747 $tab->setData($export_files);
748
749 $this->tpl->setContent($tab->getHTML());
750 }
751
752 public function downloadResource()
753 {
754 $export_files = $this->getExportResources();
755
756 if ($_GET["file_id"] > 0) {
757 $file = new ilObjFile($_GET["file_id"], false);
758 }
759
760 // check that file really belongs to SCORM module (security)
761 foreach ($export_files as $f) {
762 if (is_object($file)) {
763 if ($f["file"] == $file->getFileName()) {
764 $file->sendFile();
765 }
766 } else {
767 if ($f["path"] == $_GET["resource"]) {
768 if (is_file($f["path"])) {
769 ilUtil::deliverFile($f["path"], $f["file"]);
770 }
771 }
772 }
773 }
774 exit;
775 }
776
777 public function downloadFile()
778 {
779 $file = explode("_", $_GET["file_id"]);
780 require_once("./Modules/File/classes/class.ilObjFile.php");
781 $fileObj = new ilObjFile($file[count($file) - 1], false);
782 $fileObj->sendFile();
783 exit;
784 }
785
786 public function import()
787 {
790
791 $this->setTabs();
792 $this->setLocator();
793
794 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scormeditor_sco_import.html", "Modules/Scorm2004");
795
796 $tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_lm.svg'));
797 $tpl->setVariable("ALT_IMG", $lng->txt("obj_sahs"));
798
799 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
800
801 $tpl->setVariable("BTN_NAME", "importSave");
802
803 // this leads to _top target which removes the left organization frame
804 //$tpl->setVariable("TARGET", ' target="'.ilFrameTargetInfo::_getFrame("MainContent").'" ');
805
806 $tpl->setVariable("TXT_UPLOAD", $lng->txt("upload"));
807 $tpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
808 $tpl->setVariable("TXT_IMPORT_SCO", $lng->txt("import_sco_object"));
809 $tpl->setVariable("TXT_SELECT_FILE", $lng->txt("select_file"));
810 $tpl->setVariable("TXT_VALIDATE_FILE", $lng->txt("cont_validate_file"));
811
812 // get the value for the maximal uploadable filesize from the php.ini (if available)
813 $umf = get_cfg_var("upload_max_filesize");
814 // get the value for the maximal post data from the php.ini (if available)
815 $pms = get_cfg_var("post_max_size");
816
817 //convert from short-string representation to "real" bytes
818 $multiplier_a = array("K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024);
819
820 $umf_parts = preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
821 $pms_parts = preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
822
823 if (count($umf_parts) == 2) {
824 $umf = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
825 }
826 if (count($pms_parts) == 2) {
827 $pms = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
828 }
829
830 // use the smaller one as limit
831 $max_filesize = min($umf, $pms);
832
833 if (!$max_filesize) {
834 $max_filesize = max($umf, $pms);
835 }
836
837 //format for display in mega-bytes
838 $max_filesize = sprintf("%.1f MB", $max_filesize / 1024 / 1024);
839
840 // gives out the limit as a little notice
841 $tpl->setVariable("TXT_FILE_INFO", $lng->txt("file_notice") . " $max_filesize");
842 }
843
844 public function importSave()
845 {
848
849 // check if file was uploaded
850 $source = $_FILES["scormfile"]["tmp_name"];
851 if (($source == 'none') || (!$source)) {
852 $ilErr->raiseError("No file selected!", $ilErr->MESSAGE);
853 }
854 // get_cfg_var("upload_max_filesize"); // get the may filesize form t he php.ini
855 switch ($_FILES["scormfile"]["error"]) {
856 case UPLOAD_ERR_INI_SIZE:
857 $ilErr->raiseError($lng->txt("err_max_file_size_exceeds"), $ilErr->MESSAGE);
858 break;
859
860 case UPLOAD_ERR_FORM_SIZE:
861 $ilErr->raiseError($lng->txt("err_max_file_size_exceeds"), $ilErr->MESSAGE);
862 break;
863
864 case UPLOAD_ERR_PARTIAL:
865 $ilErr->raiseError($lng->txt("err_partial_file_upload"), $ilErr->MESSAGE);
866 break;
867
868 case UPLOAD_ERR_NO_FILE:
869 $ilErr->raiseError($lng->txt("err_no_file_uploaded"), $ilErr->MESSAGE);
870 break;
871 }
872
873 $file = pathinfo($_FILES["scormfile"]["name"]);
874 $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1);
875 $file_path = $this->slm_object->getDataDirectory() . "/" . $this->node_object->getId() . "/" . $_FILES["scormfile"]["name"];
876 ilUtil::createDirectory($this->slm_object->getDataDirectory() . "/" . $this->node_object->getId());
877 ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"], $_FILES["scormfile"]["name"], $file_path);
878 ilUtil::unzip($file_path);
879 ilUtil::renameExecutables($this->slm_object->getDataDirectory() . "/" . $this->node_object->getId());
880
881 include_once("./Modules/Scorm2004/classes/ilSCORM13Package.php");
882 $newPack = new ilSCORM13Package();
883 $newPack->il_importSco($this->slm_object->getId(), $this->node_object->getId(), $this->slm_object->getDataDirectory() . "/" . $this->node_object->getId());
884
885 $this->ctrl->redirect($this, "showOrganization");
886 }
887
891 public function cancel()
892 {
893 $this->ctrl->redirect($this, "showOrganization");
894 }
895
902 public static function getGlossaryOverviewId()
903 {
904 return "sco_glo_ov";
905 }
906
913 public static function getGloOverviewOv($a_sco)
914 {
915 global $DIC;
916
917 $lng = $DIC->language();
918
919 $tpl = new ilTemplate("tpl.sco_glossary_overview.html", true, true, "Modules/Scorm2004");
920
921 $terms = $a_sco->getGlossaryTermIds();
923 foreach ($terms as $k => $t) {
924 $tpl->setCurrentBlock("link");
925 $tpl->setVariable("TXT_LINK", $t);
926 $tpl->setVariable("ID_LINK", "glo_ov_t" . $k);
927 $tpl->parseCurrentBlock();
928 }
929
930 $tpl->setVariable("DIV_ID", ilSCORM2004ScoGUI::getGlossaryOverviewId());
931 $tpl->setVariable("TXT_SCO_GLOSSARY", $lng->txtlng("content", "cont_sco_glossary", $lk));
932 $tpl->setVariable("TXT_CLOSE", $lng->txtlng("common", "close", $lk));
933
934 if (count($terms) > 1) {
935 return $tpl->get();
936 } else {
937 return "";
938 }
939 }
940}
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
error($a_errmsg)
set error message @access public
This class represents a checkbox property in a property form.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
This class represents a section header in a property form.
special template class to simplify handling of ITX/PEAR
Class ilObjFile.
Class ilObjMediaObject.
static _lookupStandardItemPath( $a_mob_id, $a_url_encode=false, $a_web=true)
Get path for standard item.
static getAffectiveLocalization($a_id)
Get affective localization.
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
Class ilObjectMetaDataGUI.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static initJavascript()
Init javascript.
static collectFileItems($a_page, $a_domdoc)
Get all file items that are used within the page.
static _getQuestionIdsForPage($a_parent_type, $a_page_id, $a_lang="-")
Get all questions of a page.
This class represents a property form user interface.
Scorm 2004 Question Exporter.
static questionsJS(array $a_qids=null)
static renderMetaPage($a_tpl, $a_sco, $a_asset_type="", $mode="")
Render meta page (description/objectives at beginning)
static renderNavigation($a_tpl, $a_spacer_img="", $a_lang="")
Render navigation.
Class ilSCORM2004NodeGUI.
showOrganization()
Confirm deletion screen (delete page or structure objects)
setLocator()
Set Locator Items.
Class ilSCORM2004Page GUI class.
static initExport()
Init export.
static getGlossaryHTML($a_sco)
Get glossary html (only in export mode)
Class ilSCORM2004Page.
Class ilSCORM2004ScoGUI.
$ctrl
Constructor @access public.
static getGloOverviewOv($a_sco)
des
__construct($a_slm_obj, $a_node_id=0)
constructor
deleteExportFile()
delete export files
confirmDeleteExportFile()
confirmation screen for export file deletion
cancelDeleteExportFile()
cancel deletion of export files
updateProperties()
update Properties
showProperties()
Show learning objectives.
proceedDragDrop()
Perform drag and drop action.
executeCommand()
execute command
selectExport()
Select the export type of the SCORM 2004 module.
static insertQuestion($matches)
static getGlossaryOverviewId()
Get sco glossary overlay id.
Export class for SCORM 2004 object.
static clear($a_var)
Unset a value.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
static createDirectory($a_dir, $a_mod=0755)
create directory
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
static getLocalMaphilightPath()
Get local path of maphilight file.
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components....
help()
Definition: help.php:2
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:29
if($format !==null) $name
Definition: metadata.php:230
$i
Definition: metadata.php:24
$source
Definition: metadata.php:76
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$ilErr
Definition: raiseError.php:18
$data
Definition: storeScorm.php:23
$DIC
Definition: xapitoken.php:46