/**
  * export scorm package
  */
 function exportSCORM($a_target_dir, $log)
 {
     ilUtil::delDir($a_target_dir);
     ilUtil::makeDir($a_target_dir);
     //ilUtil::makeDir($a_target_dir."/res");
     // export everything to html
     $this->exportHTML($a_target_dir . "/res", $log, false, "scorm");
     // build manifest file
     include "./Modules/LearningModule/classes/class.ilContObjectManifestBuilder.php";
     $man_builder = new ilContObjectManifestBuilder($this);
     $man_builder->buildManifest();
     $man_builder->dump($a_target_dir);
     // copy scorm 1.2 schema definitions
     copy("Modules/LearningModule/scorm_xsd/adlcp_rootv1p2.xsd", $a_target_dir . "/adlcp_rootv1p2.xsd");
     copy("Modules/LearningModule/scorm_xsd/imscp_rootv1p1p2.xsd", $a_target_dir . "/imscp_rootv1p1p2.xsd");
     copy("Modules/LearningModule/scorm_xsd/imsmd_rootv1p2p1.xsd", $a_target_dir . "/imsmd_rootv1p2p1.xsd");
     copy("Modules/LearningModule/scorm_xsd/ims_xml.xsd", $a_target_dir . "/ims_xml.xsd");
     // zip it all
     $date = time();
     $zip_file = $a_target_dir . "/" . $date . "__" . IL_INST_ID . "__" . $this->getType() . "_" . $this->getId() . ".zip";
     //echo "zip-".$a_target_dir."-to-".$zip_file;
     ilUtil::zip(array($a_target_dir . "/res", $a_target_dir . "/imsmanifest.xml", $a_target_dir . "/adlcp_rootv1p2.xsd", $a_target_dir . "/imscp_rootv1p1p2.xsd", $a_target_dir . "/ims_xml.xsd", $a_target_dir . "/imsmd_rootv1p2p1.xsd"), $zip_file);
     $dest_file = $this->getExportDirectory("scorm") . "/" . $date . "__" . IL_INST_ID . "__" . $this->getType() . "_" . $this->getId() . ".zip";
     rename($zip_file, $dest_file);
     ilUtil::delDir($a_target_dir);
 }
 function exportHTMLScoObjects($a_inst, $a_target_dir, &$expLog, $a_one_file = "")
 {
     global $ilBench;
     $tree = new ilTree($this->getId());
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     // copy all necessary files now
     if ($a_one_file != "") {
         $this->prepareHTMLExporter($a_target_dir);
         // put header into file
         $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004");
         include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php";
         $sco_tpl = ilCOPageHTMLExport::getPreparedMainTemplate($sco_tpl);
         $sco_tpl->setCurrentBlock("js_file");
         $sco_tpl->setVariable("JS_FILE", "./js/pure.js");
         $sco_tpl->parseCurrentBlock();
         $sco_tpl->setCurrentBlock("js_file");
         $sco_tpl->setVariable("JS_FILE", "./js/question_handling.js");
         $sco_tpl->parseCurrentBlock();
         $sco_tpl->setCurrentBlock("head");
         $sco_tpl->parseCurrentBlock();
         fputs($a_one_file, $sco_tpl->get("head"));
         // toc
         include_once "./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php";
         $manifestBuilder = new ilContObjectManifestBuilder($this);
         $manifestBuilder->buildManifest('12');
         $xsl = file_get_contents("./Modules/Scorm2004/templates/xsl/module.xsl");
         $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
         $args = array('/_xml' => $xml->organizations->organization->asXml(), '/_xsl' => $xsl);
         $xh = xslt_create();
         $params = array("one_page" => "y");
         $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
         xslt_free($xh);
         fputs($a_one_file, $output);
     }
     foreach ($tree->getSubTree($tree->getNodeData($tree->getRootId()), true, 'sco') as $sco) {
         include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php";
         $sco_folder = $a_target_dir . "/" . $sco['obj_id'];
         ilUtil::makeDir($sco_folder);
         $node = new ilSCORM2004Sco($this, $sco['obj_id']);
         if ($a_one_file == "") {
             $node->exportHTML($a_inst, $sco_folder, $expLog, $a_one_file);
         } else {
             $node->exportHTMLPageObjects($a_inst, $a_target_dir, $expLog, 'full', "sco", $a_one_file, $sco_tpl);
         }
         if ($this->getAssignedGlossary() != 0) {
             include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
             $glos = new ilObjGlossary($this->getAssignedGlossary(), false);
             //$glos->exportHTML($sco_folder."/glossary", $expLog);
         }
     }
     // copy all necessary files now
     if ($a_one_file != "") {
         // put tail into file
         fputs($a_one_file, $sco_tpl->get("tail"));
     }
 }