ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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->getStandardTemplate();
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(IL_PAGE_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 {
245
246 $this->setTabs();
247 $this->setLocator();
248
249 include_once "./Services/Table/classes/class.ilTableGUI.php";
250 include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php";
251 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
252 include_once("./Services/COPage/classes/class.ilPCQuestionGUI.php");
253
254 // load template for table
255 $tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
256 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.scormeditor_sco_question.html", "Modules/Scorm2004");
257
258 $tbl = new ilTableGUI();
259 $tbl->setTitle("Questions for " . $this->node_object->getTitle());
260 $tbl->setHeaderNames(array("Question","Page"));
261 $cols = array("question","page");
262 $tbl->setHeaderVars($cols, $header_params);
263 $tbl->setColumnWidth(array("50%", "50%"));
264 $tbl->disable("sort");
265 $tbl->disable("footer");
266
267 $tree = new ilTree($this->slm_object->getId());
268 $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
269 $tree->setTreeTablePK("slm_id");
270
271 foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) {
272 // get question ids
273 include_once("./Services/COPage/classes/class.ilPCQuestion.php");
274 $qids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]);
275 if (count($qids) > 0) {
276 // output questions
277 foreach ($qids as $qid) {
278 $tpl->setCurrentBlock("tbl_content");
279 $tpl->setVariable("TXT_PAGE_TITLE", $page["title"]);
280 $ilCtrl->setParameterByClass("ilscorm2004pagenodegui", "obj_id", $page["obj_id"]);
281 $tpl->setVariable("HREF_EDIT_PAGE", $ilCtrl->getLinkTargetByClass("ilscorm2004pagenodegui", "edit"));
282
283 $qtitle = assQuestion::_getTitle($qid);
284 $tpl->setVariable("TXT_QUESTION", $qtitle);
285 $ilCtrl->setParameterByClass("ilscorm2004pagenodegui", "obj_id", $page["obj_id"]);
286 //$tpl->setVariable("HREF_EDIT_QUESTION", $ilCtrl->getLinkTargetByClass("ilscorm2004pagenodegui", "edit"));
287
288 $tpl->setVariable("CSS_ROW", ilUtil::switchColor($i++, "tblrow1", "tblrow2"));
289 $tpl->parseCurrentBlock();
290 }
291 }
292 }
293 $tbl->render();
294 }
295
296 public function getEditTree()
297 {
298 die("deprecated");
299 $slm_tree = new ilTree($this->node_object->getId(), $this->slm_object->getId());
300 $slm_tree->setTreeTablePK("slm_id");
301 $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
302 return $slm_tree;
303 }
304
308 public function setTabs()
309 {
310 $ilTabs = $this->tabs;
314 $ilHelp = $this->help;
315
316 $ilHelp->setScreenIdComponent("sahsed");
317
318 // subelements
319 $ilTabs->addTarget(
320 "sahs_organization",
321 $ilCtrl->getLinkTarget($this, 'showOrganization'),
322 "showOrganization",
323 get_class($this)
324 );
325
326 // properties (named learning objectives, since here is currently
327 // no other property)
328 $ilTabs->addTarget(
329 "sahs_desc_objectives",
330 $ilCtrl->getLinkTarget($this, 'showProperties'),
331 "showProperties",
332 get_class($this)
333 );
334
335 // questions
336 $ilTabs->addTarget(
337 "sahs_questions",
338 $ilCtrl->getLinkTarget($this, 'sahs_questions'),
339 "sahs_questions",
340 get_class($this)
341 );
342
343 // resources
344 $ilTabs->addTarget(
345 "cont_files",
346 $ilCtrl->getLinkTarget($this, 'sco_resources'),
347 "sco_resources",
348 get_class($this)
349 );
350
351 // metadata
352 include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
353 $mdgui = new ilObjectMetaDataGUI(
354 $this->slm_object,
355 $this->node_object->getType(),
356 $this->node_object->getId()
357 );
358 $mdtab = $mdgui->getTab();
359 if ($mdtab) {
360 $ilTabs->addTarget(
361 "meta_data",
362 $mdtab,
363 "",
364 "ilmdeditorgui"
365 );
366 }
367
368 // export
369 $ilTabs->addTarget(
370 "export",
371 $ilCtrl->getLinkTarget($this, "showExportList"),
372 "showExportList",
373 get_class($this)
374 );
375
376 // import
377 $ilTabs->addTarget(
378 "import",
379 $ilCtrl->getLinkTarget($this, "import"),
380 "import",
381 get_class($this)
382 );
383
384 // preview
385 $ilTabs->addNonTabbedLink(
386 "preview",
387 $lng->txt("cont_preview"),
388 $ilCtrl->getLinkTarget($this, 'sco_preview'),
389 "_blank"
390 );
391
392 $tpl->setTitleIcon(ilUtil::getImagePath("icon_sco.svg"));
393 $tpl->setTitle(
394 $lng->txt("sahs_unit") . ": " . $this->node_object->getTitle()
395 );
396 }
397
401 public function proceedDragDrop()
402 {
404
405 //echo "-".$_POST["il_hform_source_id"]."-".$_POST["il_hform_target_id"]."-".$_POST["il_hform_fc"]."-";
406 $this->slm_object->executeDragDrop(
407 $_POST["il_hform_source_id"],
408 $_POST["il_hform_target_id"],
409 $_POST["il_hform_fc"],
410 $_POST["il_hform_as_subitem"]
411 );
412 $ilCtrl->redirect($this, "showOrganization");
413 }
414
418 public function sco_preview()
419 {
420 global $tpl;
421
423
424 // init main template
425 $tpl = new ilTemplate("tpl.main.html", true, true);
426 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
427 $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
428 $tpl->setBodyClass("");
429 $tpl->setCurrentBlock("ContentStyle");
430 $tpl->setVariable(
431 "LOCATION_CONTENT_STYLESHEET",
432 ilObjStyleSheet::getContentStylePath($this->slm_object->getStyleSheetId())
433 );
434 $tpl->parseCurrentBlock();
435
436 // get javascript
437 include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
440 $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/pure.js");
441 $tpl->addJavaScript("./Modules/Scorm2004/scripts/pager.js");
442
443 $tpl->addOnLoadCode("pager.Init();");
444
445 $tree = new ilTree($this->slm_object->getId());
446 $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
447 $tree->setTreeTablePK("slm_id");
448 include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php";
449 include_once "./Services/MetaData/classes/class.ilMD.php";
450
451 $meta = new ilMD($this->node_object->getSLMId(), $this->node_object->getId(), $this->node_object->getType());
452 $desc_ids = $meta->getGeneral()->getDescriptionIds();
453 $sco_description = $meta->getGeneral()->getDescription($desc_ids[0])->getDescription();
454
455 // get sco template
456 $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004");
457
458 // navigation
459 $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId());
460 ilSCORM2004Asset::renderNavigation($sco_tpl, "", $lk);
461
462 // meta page (description and objectives)
464 $sco_tpl,
465 $this->node_object,
466 $this->node_object->getType()
467 );
468
469 // init export (this initialises glossary template)
471 $terms = $this->node_object->getGlossaryTermIds();
472
473 // render page
474 foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) {
475 $page_obj = new ilSCORM2004PageGUI(
476 $this->node_object->getType(),
477 $page["obj_id"],
478 0,
479 $this->slm_object->getId()
480 );
481 $page_obj->setPresentationTitle($page["title"]);
482 $page_obj->setOutputMode(IL_PAGE_PREVIEW);
483 $page_obj->setStyleId($this->slm_object->getStyleSheetId());
484 if (count($terms) > 1) {
485 $page_obj->setGlossaryOverviewInfo(
487 $this->node_object
488 );
489 }
490 $sco_tpl->setCurrentBlock("page_preview");
491 $html = $ilCtrl->getHTML($page_obj);
492 //$sco_tpl->setVariable("PAGE_PRV", $page_obj->showPage("export"));
493 $sco_tpl->setVariable("PAGE_PRV", $html);
494 $sco_tpl->parseCurrentBlock();
495 }
496
497 $output = $sco_tpl->get();
498
499 // append glossary entries on the sco level
500 $output.= ilSCORM2004PageGUI::getGlossaryHTML($this->node_object);
501
502 //insert questions
503 require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
504 $output = preg_replace_callback("/{{{{{(Question;)(il__qst_[0-9]+)}}}}}/", array(get_class($this), 'insertQuestion'), $output);
505 $output = "<script>var ScormApi=null;" . ilQuestionExporter::questionsJS() . "</script>" . $output;
506
507 $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId());
508
509 $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/question_handling.js");
510 $tpl->addCss("./Modules/Scorm2004/templates/default/question_handling.css");
511
512 include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
514
515 //inline JS
516 $output .='<script type="text/javascript" src="./Modules/Scorm2004/scripts/questions/question_handling.js"></script>';
517 $tpl->setVariable("CONTENT", $output);
518 $tpl->show();
519 exit;
520 }
521
522 //callback function for question export
523 private static function insertQuestion($matches)
524 {
525 $q_exporter = new ilQuestionExporter(false);
526 return $q_exporter->exportQuestion($matches[2]);
527 }
528
532 public function selectExport()
533 {
534 switch ($_POST['select_export']) {
535 case "exportScorm12":
536 case "exportScorm2004_3rd":
537 case "exportScorm2004_4th":
538 case "exportPDF":
539 case "exportHTML":
540 $this->ctrl->redirect($this, $_POST['select_export']);
541 break;
542 default:
543 $this->ctrl->redirect($this, 'showExportList');
544 break;
545 }
546 }
547
548 public function showExportList()
549 {
553
554 $this->setTabs();
555 $this->setLocator();
556
557
558 $template = new ilTemplate("tpl.scorm2004_export_buttons.html", true, true, 'Modules/Scorm2004');
559
560 $buttons = array(
561 "exportScorm2004_3rd" => $lng->txt("scorm_create_export_file_scrom2004"),
562 "exportScorm2004_4th" => $lng->txt("scorm_create_export_file_scrom2004_4th"),
563 "exportScorm12" => $lng->txt("scorm_create_export_file_scrom12"),
564 "exportPDF" => $lng->txt("scorm_create_export_file_pdf"),
565 "exportHTML" => $lng->txt("scorm_create_export_file_html")
566 );
567 foreach ($buttons as $value => $text) {
568 $template->setCurrentBlock('option');
569 $template->setVariable('OPTION_VALUE', $value);
570 $template->setVariable('OPTION_TITLE', ilUtil::prepareFormOutput($text));
571 $template->parseCurrentBlock();
572 }
573 $template->setVariable('EXPORT_TITLE', $lng->txt('export'));
574 $template->setVariable('EXPORT_LABEL', $lng->txt('type'));
575 $template->setVariable('FORMACTION', $ilCtrl->getFormAction($this, 'selectExport'));
576
577 $export_files = $this->node_object->getExportFiles();
578
579 include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ExportTableGUI.php";
580 $table_gui = new ilSCORM2004ExportTableGUI($this, 'showExportList');
581 $data = array();
582 foreach ($export_files as $exp_file) {
583 $filetype = $exp_file['type'];
584 // $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($filetype))
585 // ? " <b>(".$this->lng->txt("public").")<b>"
586 // : "";
587 $file_arr = explode("__", $exp_file["file"]);
588 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));
589 }
590 $table_gui->setData($data);
591 $tpl->setVariable('ADM_CONTENT', $template->get() . "\n" . $table_gui->getHTML());
592 }
593
594 public function exportScorm2004_4th()
595 {
596 $export = new ilScorm2004Export($this->node_object, 'SCORM 2004 4th');
597 $export->buildExportFile();
598 $this->ctrl->redirect($this, "showExportList");
599 }
600
601
602 public function exportScorm2004_3rd()
603 {
604 $export = new ilScorm2004Export($this->node_object, 'SCORM 2004 3rd');
605 $export->buildExportFile();
606 $this->ctrl->redirect($this, "showExportList");
607 }
608
609 public function exportScorm12()
610 {
611 $export = new ilScorm2004Export($this->node_object, 'SCORM 1.2');
612 $export->buildExportFile();
613 $this->ctrl->redirect($this, "showExportList");
614 }
615
616 public function exportHTML()
617 {
618 $export = new ilScorm2004Export($this->node_object, 'HTML');
619 $export->buildExportFile();
620 $this->ctrl->redirect($this, "showExportList");
621 }
622
623 public function exportISO()
624 {
625 $export = new ilScorm2004Export($this->node_object, 'ISO');
626 $export->buildExportFile();
627 $this->ctrl->redirect($this, "showExportList");
628 }
629
630 public function exportPDF()
631 {
632 $export = new ilScorm2004Export($this->node_object, 'PDF');
633 $export->buildExportFile();
634 $this->ctrl->redirect($this, "showExportList");
635 }
636
637 public function downloadExportFile()
638 {
639 $file = str_replace("..", "", $_GET['file']);
640 $export = new ilSCORM2004Export($this->node_object);
641 $export_dir = $export->getExportDirectoryForType($_GET['type']);
642 ilUtil::deliverFile($export_dir . "/" . $file, $file);
643 }
644
648 public function confirmDeleteExportFile()
649 {
652
653 if (!isset($_POST["file"])) {
654 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
655 $this->ctrl->redirect($this, "showExportList");
656 }
657
658 ilUtil::sendQuestion($lng->txt("info_delete_sure"));
659 $export_files = $this->node_object->getExportFiles();
660
661 include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ExportTableGUI.php";
662 $table_gui = new ilSCORM2004ExportTableGUI($this, 'showExportList', true);
663 $data = array();
664 foreach ($export_files as $exp_file) {
665 foreach ($_POST['file'] as $delete_file) {
666 if (strcmp($delete_file, $exp_file['file']) == 0) {
667 // $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($exp_file["type"]))
668 // ? " <b>(".$this->lng->txt("public").")<b>"
669 // : "";
670 $file_arr = explode("__", $exp_file["file"]);
671 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));
672 }
673 }
674 }
675 $table_gui->setData($data);
676 $tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
677 }
678
682 public function cancelDeleteExportFile()
683 {
684 ilSession::clear("ilExportFiles");
685 $this->ctrl->redirect($this, "showExportList");
686 }
687
688
692 public function deleteExportFile()
693 {
695 include_once "./Services/Utilities/classes/class.ilUtil.php";
696 $export = new ilSCORM2004Export($this->node_object);
697 foreach ($_POST['file'] as $idx => $file) {
698 $export_dir = $export->getExportDirectoryForType($_POST['type'][$idx]);
699 $exp_file = $export_dir . "/" . $file;
700 if (@is_file($exp_file)) {
701 unlink($exp_file);
702 }
703 }
704 ilUtil::sendSuccess($lng->txt('msg_deleted_export_files'), true);
705 $this->ctrl->redirect($this, "showExportList");
706 }
707
708 public function getExportResources()
709 {
710 $export_files = array();
711
712 require_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php";
713 include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
714 include_once "./Modules/File/classes/class.ilObjFile.php";
715 $tree = new ilTree($this->slm_object->getId());
716 $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
717 $tree->setTreeTablePK("slm_id");
718 foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) {
719 $page_obj = new ilSCORM2004Page($page["obj_id"]);
720 $page_obj->buildDom();
721 $mob_ids = $page_obj->collectMediaObjects(false);
722 foreach ($mob_ids as $mob_id) {
723 if ($mob_id > 0 && ilObject::_exists($mob_id)) {
724 $path = ilObjMediaObject::_lookupStandardItemPath($mob_id, false, false);
725
726 $media_obj = new ilObjMediaObject($mob_id);
727 $export_files[$i]["date"] = $media_obj->getCreateDate();
728 $export_files[$i]["size"] = @filesize($path); // could be remote, e.g. youtube video
729 $export_files[$i]["file"] = $media_obj->getTitle();
730 $export_files[$i]["type"] = $media_obj->getDescription();
731 $export_files[$i]["path"] = $path;
732 $this->ctrl->setParameter(
733 $this,
734 "resource",
735 rawurlencode(ilObjMediaObject::_lookupStandardItemPath($mob_id, false, false))
736 );
737 $export_files[$i]["link"] = $this->ctrl->getLinkTarget($this, "downloadResource");
738 $i++;
739 }
740 }
741 include_once("./Services/COPage/classes/class.ilPCFileList.php");
742 $file_ids =ilPCFileList::collectFileItems($page_obj, $page_obj->getDomDoc());
743 foreach ($file_ids as $file_id) {
744 $file_obj = new ilObjFile($file_id, false);
745 $export_files[$i]["date"] = $file_obj->getCreateDate();
746 $export_files[$i]["size"] = $file_obj->getFileSize();
747 $export_files[$i]["file"] = $file_obj->getFileName();
748 $export_files[$i]["type"] = $file_obj->getFileType();
749 $export_files[$i]["file_id"] = $file_id;
750 $this->ctrl->setParameter($this, "file_id", $file_id);
751 $export_files[$i]["link"] = $this->ctrl->getLinkTarget($this, "downloadFile", "");
752 $i++;
753 }
754 unset($page_obj);
755 }
756
757 return $export_files;
758 }
759
760 public function sco_resources()
761 {
765
766 $this->setTabs();
767 $this->setLocator();
768 $i = 0;
769
770 $export_files = $this->getExportResources();
771
772 // create table
773 require_once("./Services/Table/classes/class.ilTableGUI.php");
774 $tbl = new ilTableGUI();
775
776 // load files templates
777 $tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
778
779 // load template for table content data
780 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", "Modules/LearningModule");
781
782 $num = 0;
783
784 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
785
786 $tbl->setTitle($lng->txt("cont_files"));
787
788 $tbl->setHeaderNames(array($lng->txt("cont_format"),
789 $lng->txt("cont_file"),
790 $lng->txt("size"), $lng->txt("date"),
791 ""));
792
793 $cols = array("format", "file", "size", "date", "download");
794 $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
795 "cmd" => "sco_resources", "cmdClass" => strtolower(get_class($this)),
796 "cmdNode" => $_GET["cmdNode"], "baseClass" => $_GET["baseClass"]);
797 $tbl->setHeaderVars($cols, $header_params);
798 $tbl->setColumnWidth(array("10%", "30%", "20%", "20%","20%"));
799 $tbl->disable("sort");
800
801 $tbl->setOrderColumn($_GET["sort_by"]);
802 $tbl->setOrderDirection($_GET["sort_order"]);
803 $tbl->setLimit($_GET["limit"]);
804 $tbl->setOffset($_GET["offset"]);
805 $tbl->setMaxCount($this->maxcount); // ???
806
807
808 $tbl->setMaxCount(count($export_files));
809
810 // footer
811 $tbl->setFooter("tblfooter", $lng->txt("previous"), $lng->txt("next"));
812 //$tbl->disable("footer");
813
814 $tbl->setMaxCount(count($export_files));
815 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
816
817 $tbl->render();
818 if (count($export_files) > 0) {
819 $i=0;
820 foreach ($export_files as $exp_file) {
821 /* remote files (youtube videos) have no size, so we allow them now
822 if (!$exp_file["size"] > 0)
823 {
824 continue;
825 }
826 */
827
828 $tpl->setCurrentBlock("tbl_content");
829 $tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
830
831 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
832 $tpl->setVariable("CSS_ROW", $css_row);
833
834 $tpl->setVariable("TXT_SIZE", $exp_file["size"]);
835 $tpl->setVariable("TXT_FORMAT", $exp_file["type"]);
836
837 $tpl->setVariable("TXT_DATE", $exp_file["date"]);
838
839 if ($exp_file["size"] > 0) {
840 $tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download"));
841 $ilCtrl->setParameter($this, "resource", rawurlencode($exp_file["path"]));
842 $ilCtrl->setParameter($this, "file_id", rawurlencode($exp_file["file_id"]));
843 $tpl->setVariable(
844 "LINK_DOWNLOAD",
845 $ilCtrl->getLinkTarget($this, "downloadResource")
846 );
847 } else {
848 $tpl->setVariable("TXT_DOWNLOAD", $lng->txt("show"));
849 $tpl->setVariable("LINK_TARGET", " target=\"_blank\"");
850 $tpl->setVariable("LINK_DOWNLOAD", $exp_file["path"]);
851 }
852
853 $tpl->parseCurrentBlock();
854 }
855 } //if is_array
856 /* not found in template?
857 else
858 {
859 $tpl->setCurrentBlock("notfound");
860 $tpl->setVariable("TXT_OBJECT_NOT_FOUND", $lng->txt("obj_not_found"));
861 $tpl->setVariable("NUM_COLS", 4);
862 $tpl->parseCurrentBlock();
863 }
864 */
865 // $tpl->parseCurrentBlock();
866 }
867
868 public function downloadResource()
869 {
870 $export_files = $this->getExportResources();
871
872 if ($_GET["file_id"] > 0) {
873 $file = new ilObjFile($_GET["file_id"], false);
874 }
875
876 // check that file really belongs to SCORM module (security)
877 foreach ($export_files as $f) {
878 if (is_object($file)) {
879 if ($f["file"] == $file->getFileName()) {
880 $file->sendFile();
881 }
882 } else {
883 if ($f["path"] == $_GET["resource"]) {
884 if (is_file($f["path"])) {
885 ilUtil::deliverFile($f["path"], $f["file"]);
886 }
887 }
888 }
889 }
890 exit;
891 }
892
893 public function downloadFile()
894 {
895 $file = explode("_", $_GET["file_id"]);
896 require_once("./Modules/File/classes/class.ilObjFile.php");
897 $fileObj = new ilObjFile($file[count($file) - 1], false);
898 $fileObj->sendFile();
899 exit;
900 }
901
902 public function import()
903 {
906
907 $this->setTabs();
908 $this->setLocator();
909
910 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scormeditor_sco_import.html", "Modules/Scorm2004");
911
912 $tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_lm.svg'));
913 $tpl->setVariable("ALT_IMG", $lng->txt("obj_sahs"));
914
915 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
916
917 $tpl->setVariable("BTN_NAME", "importSave");
918
919 // this leads to _top target which removes the left organization frame
920 //$tpl->setVariable("TARGET", ' target="'.ilFrameTargetInfo::_getFrame("MainContent").'" ');
921
922 $tpl->setVariable("TXT_UPLOAD", $lng->txt("upload"));
923 $tpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
924 $tpl->setVariable("TXT_IMPORT_SCO", $lng->txt("import_sco_object"));
925 $tpl->setVariable("TXT_SELECT_FILE", $lng->txt("select_file"));
926 $tpl->setVariable("TXT_VALIDATE_FILE", $lng->txt("cont_validate_file"));
927
928 // get the value for the maximal uploadable filesize from the php.ini (if available)
929 $umf=get_cfg_var("upload_max_filesize");
930 // get the value for the maximal post data from the php.ini (if available)
931 $pms=get_cfg_var("post_max_size");
932
933 //convert from short-string representation to "real" bytes
934 $multiplier_a=array("K"=>1024, "M"=>1024*1024, "G"=>1024*1024*1024);
935
936 $umf_parts=preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
937 $pms_parts=preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
938
939 if (count($umf_parts) == 2) {
940 $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]];
941 }
942 if (count($pms_parts) == 2) {
943 $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]];
944 }
945
946 // use the smaller one as limit
947 $max_filesize=min($umf, $pms);
948
949 if (!$max_filesize) {
950 $max_filesize=max($umf, $pms);
951 }
952
953 //format for display in mega-bytes
954 $max_filesize=sprintf("%.1f MB", $max_filesize/1024/1024);
955
956 // gives out the limit as a little notice
957 $tpl->setVariable("TXT_FILE_INFO", $lng->txt("file_notice") . " $max_filesize");
958 }
959
960 public function importSave()
961 {
964
965 // check if file was uploaded
966 $source = $_FILES["scormfile"]["tmp_name"];
967 if (($source == 'none') || (!$source)) {
968 $ilErr->raiseError("No file selected!", $ilErr->MESSAGE);
969 }
970 // get_cfg_var("upload_max_filesize"); // get the may filesize form t he php.ini
971 switch ($_FILES["scormfile"]["error"]) {
972 case UPLOAD_ERR_INI_SIZE:
973 $ilErr->raiseError($lng->txt("err_max_file_size_exceeds"), $ilErr->MESSAGE);
974 break;
975
976 case UPLOAD_ERR_FORM_SIZE:
977 $ilErr->raiseError($lng->txt("err_max_file_size_exceeds"), $ilErr->MESSAGE);
978 break;
979
980 case UPLOAD_ERR_PARTIAL:
981 $ilErr->raiseError($lng->txt("err_partial_file_upload"), $ilErr->MESSAGE);
982 break;
983
984 case UPLOAD_ERR_NO_FILE:
985 $ilErr->raiseError($lng->txt("err_no_file_uploaded"), $ilErr->MESSAGE);
986 break;
987 }
988
989 $file = pathinfo($_FILES["scormfile"]["name"]);
990 $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1);
991 $file_path = $this->slm_object->getDataDirectory() . "/" . $this->node_object->getId() . "/" . $_FILES["scormfile"]["name"];
992 ilUtil::createDirectory($this->slm_object->getDataDirectory() . "/" . $this->node_object->getId());
993 ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"], $_FILES["scormfile"]["name"], $file_path);
994 ilUtil::unzip($file_path);
995 ilUtil::renameExecutables($this->slm_object->getDataDirectory() . "/" . $this->node_object->getId());
996
997 include_once("./Modules/Scorm2004/classes/ilSCORM13Package.php");
998 $newPack = new ilSCORM13Package();
999 $newPack->il_importSco($this->slm_object->getId(), $this->node_object->getId(), $this->slm_object->getDataDirectory() . "/" . $this->node_object->getId());
1000
1001 $this->ctrl->redirect($this, "showOrganization");
1002 }
1003
1007 public function cancel()
1008 {
1009 $this->ctrl->redirect($this, "showOrganization");
1010 }
1011
1018 public static function getGlossaryOverviewId()
1019 {
1020 return "sco_glo_ov";
1021 }
1022
1029 public static function getGloOverviewOv($a_sco)
1030 {
1031 global $DIC;
1032
1033 $lng = $DIC->language();
1034
1035 $tpl = new ilTemplate("tpl.sco_glossary_overview.html", true, true, "Modules/Scorm2004");
1036
1037 $terms = $a_sco->getGlossaryTermIds();
1038 $lk = ilObjSAHSLearningModule::getAffectiveLocalization($a_sco->getSLMId());
1039 foreach ($terms as $k => $t) {
1040 $tpl->setCurrentBlock("link");
1041 $tpl->setVariable("TXT_LINK", $t);
1042 $tpl->setVariable("ID_LINK", "glo_ov_t" . $k);
1043 $tpl->parseCurrentBlock();
1044 }
1045
1046 $tpl->setVariable("DIV_ID", ilSCORM2004ScoGUI::getGlossaryOverviewId());
1047 $tpl->setVariable("TXT_SCO_GLOSSARY", $lng->txtlng("content", "cont_sco_glossary", $lk));
1048 $tpl->setVariable("TXT_CLOSE", $lng->txtlng("common", "close", $lk));
1049
1050 if (count($terms) > 1) {
1051 return $tpl->get();
1052 } else {
1053 return "";
1054 }
1055 }
1056}
sprintf('%.4f', $callTime)
$source
Definition: linkback.php:22
$_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
const IL_PAGE_PREVIEW
static _getTitle($a_q_id)
Returns the title of a question.
This class represents a checkbox property in a property form.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
This class represents a section header in a property form.
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)
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.
Class ilTableGUI.
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 sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message 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 switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
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 initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components....
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
$template
$key
Definition: croninfo.php:18
$i
Definition: disco.tpl.php:19
$html
Definition: example_001.php:87
$tbl
Definition: example_048.php:81
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
global $ilCtrl
Definition: ilias.php:18
if($format !==null) $name
Definition: metadata.php:146
$ret
Definition: parser.php:6
global $ilErr
Definition: raiseError.php:16
if(isset($_POST['submit'])) $form
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $DIC
Definition: saml.php:7
echo;exit;}function LogoutNotification($SessionID){ global $ilDB;$q="SELECT session_id, data FROM usr_session WHERE expires > (\w+)\|/" PREG_SPLIT_NO_EMPTY PREG_SPLIT_DELIM_CAPTURE
$text
Definition: errorreport.php:18
$cols
Definition: xhr_table.php:11