/** * Export HTML pages of SCO */ function exportHTMLPageObjects($a_inst, $a_target_dir, &$expLog, $mode, $a_asset_type = "sco", $a_one_file = "", $a_sco_tpl = null) { global $tpl, $ilCtrl, $ilBench, $ilLog, $lng; include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php"; include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModuleGUI.php"; include_once "./Services/MetaData/classes/class.ilMD.php"; $output = ""; $tree = new ilTree($this->slm_id); $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $tree->setTreeTablePK("slm_id"); // @todo // Why is that much HTML code in an application class? // Please extract all this HTML to a tpl.<t_name>.html file and use // placeholders and the template engine to insert data. // // There copy/paste code residenting in ilSCORM2004ScoGUI. This // should be merged. // // alex, 4 Apr 09 // // if ($a_one_file == "") // { $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004"); // } // else // { // $sco_tpl = $a_sco_tpl; // } if ($mode != 'pdf' && $a_one_file == "") { include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php"; $pg_exp = new ilCOPageHTMLExport($a_target_dir); $pg_exp->getPreparedMainTemplate($sco_tpl); // init and question lang vars $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->slm_id); $sco_tpl->setCurrentBlock("init"); include_once "./Services/COPage/classes/class.ilPCQuestion.php"; $sco_tpl->setVariable("TXT_INIT_CODE", ilPCQuestion::getJSTextInitCode($lk)); $sco_tpl->parseCurrentBlock(); // (additional) style sheets needed $styles = array("./css/yahoo/container.css", "./css/question_handling.css"); foreach ($styles as $style) { $sco_tpl->setCurrentBlock("css_file"); $sco_tpl->setVariable("CSS_FILE", $style); $sco_tpl->parseCurrentBlock(); } // (additional) scripts needed $scripts = array("./js/scorm.js", "./js/pager.js", "./js/pure.js", "./js/questions_" . $this->getId() . ".js"); foreach ($scripts as $script) { $sco_tpl->setCurrentBlock("js_file"); $sco_tpl->setVariable("JS_FILE", $script); $sco_tpl->parseCurrentBlock(); } if ($a_asset_type != "entry_asset" && $a_asset_type != "final_asset") { self::renderNavigation($sco_tpl, "./images/spacer.png", $lk); } $sco_tpl->touchBlock("finish"); } // render head $sco_tpl->setCurrentBlock("head"); $sco_tpl->setVariable("SCO_TITLE", $this->getTitle()); $sco_tpl->parseCurrentBlock(); $sco_tpl->touchBlock("tail"); // meta page (meta info at SCO beginning) self::renderMetaPage($sco_tpl, $this, $a_asset_type, $mode); if ($a_one_file != "") { fputs($a_one_file, "<a name='sco" . $this->getId() . "'></a>"); fputs($a_one_file, $sco_tpl->get("meta_page")); } //notify Question Exporter of new SCO require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php'; ilQuestionExporter::indicateNewSco(); // init export (this initialises glossary template) ilSCORM2004PageGUI::initExport(); $terms = array(); $terms = $this->getGlossaryTermIds(); include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ScoGUI.php"; $pages = $tree->getSubTree($tree->getNodeData($this->getId()), true, 'page'); $sco_q_ids = array(); foreach ($pages as $page) { //echo(print_r($page)); $page_obj = new ilSCORM2004PageGUI($this->getType(), $page["obj_id"], 0, $this->slm_object->getId()); $page_obj->setPresentationTitle($page["title"]); $page_obj->setOutputMode(IL_PAGE_OFFLINE); $page_obj->setStyleId($this->slm_object->getStyleSheetId()); if (count($terms) > 1) { $page_obj->setGlossaryOverviewInfo(ilSCORM2004ScoGUI::getGlossaryOverviewId(), $this); } $page_output = $page_obj->showPage("export"); // collect media objects $mob_ids = $page_obj->getSCORM2004Page()->collectMediaObjects(false); foreach ($mob_ids as $mob_id) { $this->mob_ids[$mob_id] = $mob_id; $media_obj = new ilObjMediaObject($mob_id); if ($media_obj->hasFullscreenItem()) { $media_obj->exportMediaFullscreen($a_target_dir, $page_obj->getPageObject()); } } // collect glossary items $int_links = $page_obj->getPageObject()->getInternalLinks(true); include_once "./Services/Link/classes/class.ilInternalLink.php"; include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php"; if (is_array($int_links)) { foreach ($int_links as $k => $e) { // glossary link if ($e["Type"] == "GlossaryItem") { $karr = explode(":", $k); $tid = ilInternalLink::_extractObjIdOfTarget($karr[0]); $dids = ilGlossaryDefinition::getDefinitionList($tid); foreach ($dids as $did) { include_once "./Modules/Glossary/classes/class.ilGlossaryDefPage.php"; $def_pg = new ilGlossaryDefPage($did["id"]); $def_pg->buildDom(); $mob_ids = $def_pg->collectMediaObjects(false); foreach ($mob_ids as $mob_id) { $this->mob_ids[$mob_id] = $mob_id; //echo "<br>-$mob_id-"; $media_obj = new ilObjMediaObject($mob_id); if ($media_obj->hasFullscreenItem()) { $media_obj->exportMediaFullscreen($a_target_dir, $def_pg); } } include_once "./Services/COPage/classes/class.ilPCFileList.php"; $file_ids = ilPCFileList::collectFileItems($def_pg, $def_pg->getDomDoc()); foreach ($file_ids as $file_id) { $this->file_ids[$file_id] = $file_id; } } } } } //exit; // collect all file items include_once "./Services/COPage/classes/class.ilPCFileList.php"; $file_ids = ilPCFileList::collectFileItems($page_obj->getSCORM2004Page(), $page_obj->getSCORM2004Page()->getDomDoc()); foreach ($file_ids as $file_id) { $this->file_ids[$file_id] = $file_id; } if ($mode == 'pdf') { include_once "./Services/COPage/classes/class.ilPCQuestion.php"; $q_ids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]); foreach ($q_ids as $q_id) { include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php"; $q_gui =& assQuestionGUI::_getQuestionGUI("", $q_id); $q_gui->outAdditionalOutput(); $html = $q_gui->getPreview(TRUE); $page_output = preg_replace("/{{{{{Question;il__qst_" . $q_id . "}}}}}/i", $html, $page_output); } $sco_tpl->touchBlock("pdf_pg_break"); } $sco_tpl->setCurrentBlock("page"); $sco_tpl->setVariable("PAGE", $page_output); $sco_tpl->parseCurrentBlock(); // get all question ids of the sco if ($a_one_file != "") { include_once "./Services/COPage/classes/class.ilPCQuestion.php"; $q_ids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]); foreach ($q_ids as $i) { if (!in_array($i, $sco_q_ids)) { $sco_q_ids[] = $i; } } } } // glossary if ($mode != 'pdf') { $sco_tpl->setVariable("GLOSSARY_HTML", ilSCORM2004PageGUI::getGlossaryHTML($this)); } if ($a_one_file == "") { $output = $sco_tpl->get(); } else { $output = $sco_tpl->get("page"); } if ($mode == 'pdf') { $output = preg_replace("/<div class=\"ilc_page_title_PageTitle\">(.*?)<\\/div>/i", "<h2>\$1</h2>", $output); } //$output = preg_replace("/\.\/mobs\/mm_(\d+)\/([^\"]+)/i","./objects/il_".IL_INST_ID."_mob_$1/$2",$output); $output = preg_replace("/mobs\\/mm_(\\d+)\\/([^\"]+)/i", "./objects/il_" . IL_INST_ID . "_mob_\$1/\$2", $output); $output = preg_replace("/\\.\\/files\\/file_(\\d+)\\/([^\"]+)/i", "./objects/il_" . IL_INST_ID . "_file_\$1/\$2", $output); $output = preg_replace("/\\.\\/Services\\/MediaObjects\\/flash_mp3_player/i", "./players", $output); // $output = preg_replace("/\.\/".str_replace("/", "\/", ilPlayerUtil::getFlashVideoPlayerDirectory())."/i","./players",$output); $output = preg_replace("/file=..\\/..\\/..\\/.\\//i", "file=../", $output); if ($mode != 'pdf') { $output = preg_replace_callback("/href=\"&mob_id=(\\d+)&pg_id=(\\d+)\"/", array(get_class($this), 'fixFullscreeenLink'), $output); // this one is for fullscreen in glossary entries $output = preg_replace_callback("/href=\"fullscreen_(\\d+)\\.html\"/", array(get_class($this), 'fixFullscreeenLink'), $output); $output = preg_replace_callback("/{{{{{(Question;)(il__qst_[0-9]+)}}}}}/", array(get_class($this), 'insertQuestion'), $output); // $output = preg_replace("/{/","",$output); // $output = preg_replace("/}/","",$output); $q_handling = file_get_contents('./Modules/Scorm2004/scripts/questions/question_handling.js'); fputs(fopen($a_target_dir . '/js/questions_' . $this->getId() . '.js', 'w+'), ilQuestionExporter::questionsJS() . $q_handling); copy("./Modules/Scorm2004/templates/default/question_handling.css", $a_target_dir . '/css/question_handling.css'); // hack to get the question js into the file and to display the correct answers if ($a_one_file != "") { $output = '<script type="text/javascript">' . ilQuestionExporter::questionsJS() . '</script>' . $output; if (count($sco_q_ids) > 0) { $output .= '<script type="text/javascript">'; foreach ($sco_q_ids as $i) { if ($i > 0) { $output .= "ilias.questions.showCorrectAnswers(" . $i . "); \n"; } } $output .= '</script>'; } } foreach (ilQuestionExporter::getMobs() as $mob_id) { $this->mob_ids[$mob_id] = $mob_id; } } $this->q_media = ilQuestionExporter::getFiles(); //questions export end if ($a_one_file != "") { fputs($a_one_file, $output); } else { fputs(fopen($a_target_dir . '/index.html', 'w+'), $output); } $this->exportFileItems($a_target_dir, $expLog); }
/** * SCO preview */ function sco_preview() { global $tpl, $ilCtrl, $lng; // init main template $tpl = new ilTemplate("tpl.main.html", true, true); include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation()); $tpl->setBodyClass(""); $tpl->setCurrentBlock("ContentStyle"); $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->slm_object->getStyleSheetId())); $tpl->parseCurrentBlock(); // get javascript include_once "./Services/jQuery/classes/class.iljQueryUtil.php"; iljQueryUtil::initjQuery(); iljQueryUtil::initjQueryUI(); $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/pure.js"); $tpl->addJavaScript("./Modules/Scorm2004/scripts/pager.js"); $tpl->addOnLoadCode("pager.Init();"); $tree = new ilTree($this->slm_object->getId()); $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $tree->setTreeTablePK("slm_id"); include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php"; include_once "./Services/MetaData/classes/class.ilMD.php"; $meta = new ilMD($this->node_object->getSLMId(), $this->node_object->getId(), $this->node_object->getType()); $desc_ids = $meta->getGeneral()->getDescriptionIds(); $sco_description = $meta->getGeneral()->getDescription($desc_ids[0])->getDescription(); // get sco template $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004"); // navigation $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId()); ilSCORM2004Asset::renderNavigation($sco_tpl, "", $lk); // meta page (description and objectives) ilSCORM2004Asset::renderMetaPage($sco_tpl, $this->node_object, $this->node_object->getType()); // init export (this initialises glossary template) ilSCORM2004PageGUI::initExport(); $terms = $this->node_object->getGlossaryTermIds(); // render page foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) { $page_obj = new ilSCORM2004PageGUI($this->node_object->getType(), $page["obj_id"], 0, $this->slm_object->getId()); $page_obj->setPresentationTitle($page["title"]); $page_obj->setOutputMode(IL_PAGE_PREVIEW); $page_obj->setStyleId($this->slm_object->getStyleSheetId()); if (count($terms) > 1) { $page_obj->setGlossaryOverviewInfo(ilSCORM2004ScoGUI::getGlossaryOverviewId(), $this->node_object); } $sco_tpl->setCurrentBlock("page_preview"); $html = $ilCtrl->getHTML($page_obj); //$sco_tpl->setVariable("PAGE_PRV", $page_obj->showPage("export")); $sco_tpl->setVariable("PAGE_PRV", $html); $sco_tpl->parseCurrentBlock(); } $output = $sco_tpl->get(); // append glossary entries on the sco level $output .= ilSCORM2004PageGUI::getGlossaryHTML($this->node_object); //insert questions require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php'; $output = preg_replace_callback("/{{{{{(Question;)(il__qst_[0-9]+)}}}}}/", array(get_class($this), 'insertQuestion'), $output); // $output = preg_replace("/{/","",$output); // $output = preg_replace("/}/","",$output); $output = "<script>var ScormApi=null;" . ilQuestionExporter::questionsJS() . "</script>" . $output; $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId()); // include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php"); // ilSCORM2004PageGUI::addPreparationJavascript($tpl, $lk); $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/question_handling.js"); $tpl->addCss("./Modules/Scorm2004/templates/default/question_handling.css"); include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php"; ilOverlayGUI::initJavascript(); //inline JS $output .= '<script type="text/javascript" src="./Modules/Scorm2004/scripts/questions/question_handling.js"></script>'; $tpl->setVariable("CONTENT", $output); }