/** * Returns a QTI xml representation of the test * * @return string The QTI xml representation of the test */ public function toXML() { include_once "./Services/Xml/classes/class.ilXmlWriter.php"; $a_xml_writer = new ilXmlWriter(); // set xml header $a_xml_writer->xmlHeader(); $a_xml_writer->xmlSetDtdDef("<!DOCTYPE questestinterop SYSTEM \"ims_qtiasiv1p2p1.dtd\">"); $a_xml_writer->xmlStartTag("questestinterop"); $attrs = array("ident" => "il_" . IL_INST_ID . "_tst_" . $this->getTestId(), "title" => $this->getTitle()); $a_xml_writer->xmlStartTag("assessment", $attrs); // add qti comment $a_xml_writer->xmlElement("qticomment", NULL, $this->getDescription()); // add qti duration if ($this->enable_processing_time) { preg_match("/(\\d+):(\\d+):(\\d+)/", $this->processing_time, $matches); $a_xml_writer->xmlElement("duration", NULL, sprintf("P0Y0M0DT%dH%dM%dS", $matches[1], $matches[2], $matches[3])); } // add the rest of the preferences in qtimetadata tags, because there is no correspondent definition in QTI $a_xml_writer->xmlStartTag("qtimetadata"); $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "ILIAS_VERSION"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->ilias->getSetting("ilias_version")); $a_xml_writer->xmlEndTag("qtimetadatafield"); // anonymity $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "anonymity"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getAnonymity())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // question set type (fixed, random, dynamic, ...) $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "question_set_type"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getQuestionSetType()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // sequence settings $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "sequence_settings"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getSequenceSettings()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // author $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "author"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getAuthor()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // reset processing time $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "reset_processing_time"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getResetProcessingTime()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // count system $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "count_system"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getCountSystem()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // multiple choice scoring $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "mc_scoring"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getMCScoring()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // multiple choice scoring $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "score_cutting"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getScoreCutting()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // multiple choice scoring $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "password"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getPassword()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // allowed users $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "allowedUsers"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getAllowedUsers()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // allowed users time gap $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "allowedUsersTimeGap"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getAllowedUsersTimeGap()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // pass scoring $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "pass_scoring"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getPassScoring()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // score reporting date if ($this->getReportingDate()) { $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "reporting_date"); preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->reporting_date, $matches); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); $a_xml_writer->xmlEndTag("qtimetadatafield"); } // number of tries $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "nr_of_tries"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getNrOfTries())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // kiosk $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "kiosk"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getKiosk())); $a_xml_writer->xmlEndTag("qtimetadatafield"); //redirection_mode $a_xml_writer->xmlStartTag('qtimetadatafield'); $a_xml_writer->xmlElement("fieldlabel", NULL, "redirection_mode"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getRedirectionMode()); $a_xml_writer->xmlEndTag("qtimetadatafield"); //redirection_url $a_xml_writer->xmlStartTag('qtimetadatafield'); $a_xml_writer->xmlElement("fieldlabel", NULL, "redirection_url"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getRedirectionUrl()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // use previous answers $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "use_previous_answers"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getUsePreviousAnswers()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // hide title points $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "title_output"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getTitleOutput())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // results presentation $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "results_presentation"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getResultsPresentation())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // examid in test pass $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "examid_in_test_pass"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->isShowExamIdInTestPassEnabled())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // examid in kiosk $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "examid_in_test_res"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->isShowExamIdInTestResultsEnabled())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // solution details $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "show_summary"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getListOfQuestionsSettings())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // solution details $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "score_reporting"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getScoreReporting())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // solution details $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "instant_verification"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getInstantFeedbackSolution())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // answer specific feedback $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "answer_feedback"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getAnswerFeedback())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // answer specific feedback of reached points $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "answer_feedback_points"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getAnswerFeedbackPoints())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // highscore $highscore_metadata = array('highscore_enabled' => array('value' => $this->getHighscoreEnabled()), 'highscore_anon' => array('value' => $this->getHighscoreAnon()), 'highscore_achieved_ts' => array('value' => $this->getHighscoreAchievedTS()), 'highscore_score' => array('value' => $this->getHighscoreScore()), 'highscore_percentage' => array('value' => $this->getHighscorePercentage()), 'highscore_hints' => array('value' => $this->getHighscoreHints()), 'highscore_wtime' => array('value' => $this->getHighscoreWTime()), 'highscore_own_table' => array('value' => $this->getHighscoreOwnTable()), 'highscore_top_table' => array('value' => $this->getHighscoreTopTable()), 'highscore_top_num' => array('value' => $this->getHighscoreTopNum())); foreach ($highscore_metadata as $label => $data) { $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, $label); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $data['value'])); $a_xml_writer->xmlEndTag("qtimetadatafield"); } // show cancel $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "show_cancel"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShowCancel())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // show marker $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "show_marker"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShowMarker())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // fixed participants $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "fixed_participants"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getFixedParticipants())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // show final statement $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "showfinalstatement"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShowFinalStatement() ? "1" : "0")); $a_xml_writer->xmlEndTag("qtimetadatafield"); // show introduction only $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "showinfo"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShowInfo() ? "1" : "0")); $a_xml_writer->xmlEndTag("qtimetadatafield"); // mail notification $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "mailnotification"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getMailNotification()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // mail notification type $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "mailnottype"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getMailNotificationType()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // export settings $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "exportsettings"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getExportSettings()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // force JavaScript $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "forcejs"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getForceJS() ? "1" : "0")); $a_xml_writer->xmlEndTag("qtimetadatafield"); // custom style $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "customstyle"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getCustomStyle()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // shuffle questions $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "shuffle_questions"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShuffleQuestions())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // processing time $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "processing_time"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getProcessingTime()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // enable_examview $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "enable_examview"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getEnableExamview()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // show_examview_html $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "show_examview_html"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getShowExamviewHtml()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // show_examview_pdf $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "show_examview_pdf"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getShowExamviewPdf()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // enable_archiving $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "enable_archiving"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getEnableArchiving()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // sign_submission $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "sign_submission"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getSignSubmission()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // char_selector_availability $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "char_selector_availability"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getCharSelectorAvailability())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // char_selector_definition $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "char_selector_definition"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getCharSelectorDefinition()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // skill_service $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "skill_service"); $a_xml_writer->xmlElement("fieldentry", NULL, (int) $this->isSkillServiceEnabled()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // result_tax_filters $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "result_tax_filters"); $a_xml_writer->xmlElement("fieldentry", NULL, serialize((array) $this->getResultFilterTaxIds())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // show_grading_status $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "show_grading_status"); $a_xml_writer->xmlElement("fieldentry", NULL, (int) $this->isShowGradingStatusEnabled()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // show_grading_mark $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "show_grading_mark"); $a_xml_writer->xmlElement("fieldentry", NULL, (int) $this->isShowGradingMarkEnabled()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // starting time if ($this->getStartingTime()) { $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "starting_time"); preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->starting_time, $matches); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); $a_xml_writer->xmlEndTag("qtimetadatafield"); } // ending time if ($this->getEndingTime()) { $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "ending_time"); preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->ending_time, $matches); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); $a_xml_writer->xmlEndTag("qtimetadatafield"); } foreach ($this->mark_schema->mark_steps as $index => $mark) { // mark steps $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "mark_step_{$index}"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("<short>%s</short><official>%s</official><percentage>%.2f</percentage><passed>%d</passed>", $mark->getShortName(), $mark->getOfficialName(), $mark->getMinimumLevel(), $mark->getPassed())); $a_xml_writer->xmlEndTag("qtimetadatafield"); } $a_xml_writer->xmlEndTag("qtimetadata"); // add qti objectives $a_xml_writer->xmlStartTag("objectives"); $this->addQTIMaterial($a_xml_writer, $this->getIntroduction()); $a_xml_writer->xmlEndTag("objectives"); // add qti assessmentcontrol if ($this->getInstantFeedbackSolution() == 1) { $attrs = array("solutionswitch" => "Yes"); } else { $attrs = NULL; } $a_xml_writer->xmlElement("assessmentcontrol", $attrs, NULL); if (strlen($this->getFinalStatement())) { // add qti presentation_material $a_xml_writer->xmlStartTag("presentation_material"); $a_xml_writer->xmlStartTag("flow_mat"); $this->addQTIMaterial($a_xml_writer, $this->getFinalStatement()); $a_xml_writer->xmlEndTag("flow_mat"); $a_xml_writer->xmlEndTag("presentation_material"); } $attrs = array("ident" => "1"); $a_xml_writer->xmlElement("section", $attrs, NULL); $a_xml_writer->xmlEndTag("assessment"); $a_xml_writer->xmlEndTag("questestinterop"); $xml = $a_xml_writer->xmlDumpMem(FALSE); foreach ($this->questions as $question_id) { $question =& ilObjTest::_instanciateQuestion($question_id); $qti_question = $question->toXML(false); $qti_question = preg_replace("/<questestinterop>/", "", $qti_question); $qti_question = preg_replace("/<\\/questestinterop>/", "", $qti_question); if (strpos($xml, "</section>") !== false) { $xml = str_replace("</section>", "{$qti_question}</section>", $xml); } else { $xml = str_replace("<section ident=\"1\"/>", "<section ident=\"1\">\n{$qti_question}</section>", $xml); } } return $xml; }
/** * Export (authoring) scorm package */ function exportScorm($a_inst, $a_target_dir, $ver, &$expLog) { $a_xml_writer = new ilXmlWriter(); // export metadata $this->exportXMLMetaData($a_xml_writer); $metadata_xml = $a_xml_writer->xmlDumpMem(false); $a_xml_writer->_XmlWriter; $xsl = file_get_contents("./Modules/Scorm2004/templates/xsl/metadata.xsl"); $args = array('/_xml' => $metadata_xml, '/_xsl' => $xsl); $xh = xslt_create(); $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL); xslt_free($xh); file_put_contents($a_target_dir . '/indexMD.xml', $output); // export glossary if ($this->getAssignedGlossary() != 0) { ilUtil::makeDir($a_target_dir . "/glossary"); include_once "./Modules/Glossary/classes/class.ilObjGlossary.php"; include_once "./Modules/Glossary/classes/class.ilGlossaryExport.php"; $glo_xml_writer = new ilXmlWriter(); $glo_xml_writer->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">"); // set xml header $glo_xml_writer->xmlHeader(); $glos = new ilObjGlossary($this->getAssignedGlossary(), false); //$glos->exportHTML($a_target_dir."/glossary", $expLog); $glos_export = new ilGlossaryExport($glos, "xml"); $glos->exportXML($glo_xml_writer, $glos_export->getInstId(), $a_target_dir . "/glossary", $expLog); $glo_xml_writer->xmlDumpFile($a_target_dir . "/glossary/glossary.xml"); $glo_xml_writer->_XmlWriter; } $a_xml_writer = new ilXmlWriter(); // set dtd definition $a_xml_writer->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">"); // set generated comment $a_xml_writer->xmlSetGenCmt("Export of ILIAS Content Module " . $this->getId() . " of installation " . $a_inst . "."); // set xml header $a_xml_writer->xmlHeader(); global $ilBench; $a_xml_writer->xmlStartTag("ContentObject", array("Type" => "SCORM2004LearningModule")); // MetaData $this->exportXMLMetaData($a_xml_writer); $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog); // SCO Objects $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Sco Objects"); $this->exportXMLScoObjects($a_inst, $a_target_dir, $ver, $expLog); $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Sco Objects"); $a_xml_writer->xmlEndTag("ContentObject"); $a_xml_writer->xmlDumpFile($a_target_dir . '/index.xml', false); if ($ver == "2004 4th") { $revision = "4th"; $ver = "2004"; } if ($ver == "2004 3rd") { $revision = "3rd"; $ver = "2004"; } // add content css (note: this is also done per item) $css_dir = $a_target_dir . "/ilias_css_4_2"; ilUtil::makeDir($css_dir); include_once "./Modules/Scorm2004/classes/class.ilScormExportUtil.php"; ilScormExportUtil::exportContentCSS($this, $css_dir); // add manifest include_once "./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php"; $manifestBuilder = new ilContObjectManifestBuilder($this); $manifestBuilder->buildManifest($ver, $revision); $manifestBuilder->dump($a_target_dir); $xsl = file_get_contents("./Modules/Scorm2004/templates/xsl/module.xsl"); $args = array('/_xml' => file_get_contents($a_target_dir . "/imsmanifest.xml"), '/_xsl' => $xsl); $xh = xslt_create(); $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL); xslt_free($xh); fputs(fopen($a_target_dir . '/index.html', 'w+'), $output); // copy xsd files to target switch ($ver) { case "2004": if ($revision == "3rd") { ilUtil::rCopy('./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004', $a_target_dir, false); } if ($revision == "4th") { ilUtil::rCopy('./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004_4th', $a_target_dir, false); } break; case "12": ilUtil::rCopy('./Modules/Scorm2004/templates/xsd/adlcp_120_export_12', $a_target_dir, false); break; } $a_xml_writer->_XmlWriter; }
function exportScorm($a_inst, $a_target_dir, $ver, &$expLog) { copy('./xml/ilias_co_3_7.dtd', $a_target_dir . '/ilias_co_3_7.dtd'); copy('./Modules/Scorm2004/templates/xsl/sco.xsl', $a_target_dir . '/sco.xsl'); $a_xml_writer = new ilXmlWriter(); // MetaData //file_put_contents($a_target_dir.'/indexMD.xml','<lom xmlns="http://ltsc.ieee.org/xsd/LOM"><general/><classification/></lom>'); $this->exportXMLMetaData($a_xml_writer); $metadata_xml = $a_xml_writer->xmlDumpMem(false); $a_xml_writer->_XmlWriter; $xsl = file_get_contents("./Modules/Scorm2004/templates/xsl/metadata.xsl"); $args = array('/_xml' => $metadata_xml, '/_xsl' => $xsl); $xh = xslt_create(); $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL); xslt_free($xh); file_put_contents($a_target_dir . '/indexMD.xml', $output); $a_xml_writer = new ilXmlWriter(); // set dtd definition $a_xml_writer->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">"); // set generated comment $a_xml_writer->xmlSetGenCmt("Export of ILIAS Content Module " . $this->getId() . " of installation " . $a_inst . "."); // set xml header $a_xml_writer->xmlHeader(); global $ilBench; $a_xml_writer->xmlStartTag("ContentObject", array("Type" => "SCORM2004SCO")); $this->exportXMLMetaData($a_xml_writer); $this->exportXMLPageObjects($a_target_dir, $a_xml_writer, $a_inst, $expLog); $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog); $this->exportHTML($a_inst, $a_target_dir, $expLog); //overwrite scorm.js for scrom 1.2 if ($ver == "12") { copy('./Modules/Scorm2004/scripts/scorm_12.js', $a_target_dir . '/js/scorm.js'); } $a_xml_writer->xmlEndTag("ContentObject"); $a_xml_writer->xmlDumpFile($a_target_dir . '/index.xml', false); $a_xml_writer->_XmlWriter; // export sco data (currently only objective) to sco.xml if ($this->getType() == "sco") { $objectives_text = ""; $a_xml_writer = new ilXmlWriter(); $tr_data = $this->getObjectives(); foreach ($tr_data as $data) { $objectives_text .= $data->getObjectiveID(); } $a_xml_writer->xmlStartTag("sco"); $a_xml_writer->xmlElement("objective", null, $objectives_text); $a_xml_writer->xmlEndTag("sco"); $a_xml_writer->xmlDumpFile($a_target_dir . '/sco.xml', false); $a_xml_writer->_XmlWriter; } }
/** * Returns a QTI xml representation of the test * * @return string The QTI xml representation of the test * @access public */ function toXML() { include_once "./Services/Xml/classes/class.ilXmlWriter.php"; $a_xml_writer = new ilXmlWriter(); // set xml header $a_xml_writer->xmlHeader(); $a_xml_writer->xmlSetDtdDef("<!DOCTYPE questestinterop SYSTEM \"ims_qtiasiv1p2p1.dtd\">"); $a_xml_writer->xmlStartTag("questestinterop"); $attrs = array("ident" => "il_" . IL_INST_ID . "_tst_" . $this->getTestId(), "title" => $this->getTitle()); $a_xml_writer->xmlStartTag("assessment", $attrs); // add qti comment $a_xml_writer->xmlElement("qticomment", NULL, $this->getDescription()); // add qti duration if ($this->enable_processing_time) { preg_match("/(\\d+):(\\d+):(\\d+)/", $this->processing_time, $matches); $a_xml_writer->xmlElement("duration", NULL, sprintf("P0Y0M0DT%dH%dM%dS", $matches[1], $matches[2], $matches[3])); } // add the rest of the preferences in qtimetadata tags, because there is no correspondent definition in QTI $a_xml_writer->xmlStartTag("qtimetadata"); $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "ILIAS_VERSION"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->ilias->getSetting("ilias_version")); $a_xml_writer->xmlEndTag("qtimetadatafield"); // anonymity $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "anonymity"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getAnonymity())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // random test $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "random_test"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->isRandomTest())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // sequence settings $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "sequence_settings"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getSequenceSettings()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // author $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "author"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getAuthor()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // reset processing time $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "reset_processing_time"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getResetProcessingTime()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // count system $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "count_system"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getCountSystem()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // multiple choice scoring $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "mc_scoring"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getMCScoring()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // multiple choice scoring $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "score_cutting"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getScoreCutting()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // multiple choice scoring $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "password"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getPassword()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // allowed users $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "allowedUsers"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getAllowedUsers()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // allowed users time gap $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "allowedUsersTimeGap"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getAllowedUsersTimeGap()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // pass scoring $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "pass_scoring"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getPassScoring()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // score reporting date if ($this->getReportingDate()) { $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "reporting_date"); preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->reporting_date, $matches); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); $a_xml_writer->xmlEndTag("qtimetadatafield"); } // number of tries $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "nr_of_tries"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getNrOfTries())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // kiosk $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "kiosk"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getKiosk())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // use previous answers $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "use_previous_answers"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getUsePreviousAnswers()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // hide title points $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "title_output"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getTitleOutput())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // random question count $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "random_question_count"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getRandomQuestionCount())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // results presentation $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "results_presentation"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getResultsPresentation())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // solution details $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "show_summary"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getListOfQuestionsSettings())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // solution details $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "score_reporting"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getScoreReporting())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // solution details $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "instant_verification"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getInstantFeedbackSolution())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // answer specific feedback $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "answer_feedback"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getAnswerFeedback())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // answer specific feedback of reached points $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "answer_feedback_points"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getAnswerFeedbackPoints())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // show cancel $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "show_cancel"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShowCancel())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // show marker $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "show_marker"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShowMarker())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // fixed participants $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "fixed_participants"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getFixedParticipants())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // show final statement $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "showfinalstatement"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShowFinalStatement() ? "1" : "0")); $a_xml_writer->xmlEndTag("qtimetadatafield"); // show introduction only $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "showinfo"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShowInfo() ? "1" : "0")); $a_xml_writer->xmlEndTag("qtimetadatafield"); // mail notification $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "mailnotification"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getMailNotification()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // mail notification type $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "mailnottype"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getMailNotificationType()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // export settings $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "exportsettings"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getExportSettings()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // force JavaScript $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "forcejs"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getForceJS() ? "1" : "0")); $a_xml_writer->xmlEndTag("qtimetadatafield"); // custom style $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "customstyle"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getCustomStyle()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // shuffle questions $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "shuffle_questions"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShuffleQuestions())); $a_xml_writer->xmlEndTag("qtimetadatafield"); // processing time $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "processing_time"); $a_xml_writer->xmlElement("fieldentry", NULL, $this->getProcessingTime()); $a_xml_writer->xmlEndTag("qtimetadatafield"); // starting time if ($this->getStartingTime()) { $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "starting_time"); preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->starting_time, $matches); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); $a_xml_writer->xmlEndTag("qtimetadatafield"); } // ending time if ($this->getEndingTime()) { $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "ending_time"); preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->ending_time, $matches); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); $a_xml_writer->xmlEndTag("qtimetadatafield"); } foreach ($this->mark_schema->mark_steps as $index => $mark) { // mark steps $a_xml_writer->xmlStartTag("qtimetadatafield"); $a_xml_writer->xmlElement("fieldlabel", NULL, "mark_step_{$index}"); $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("<short>%s</short><official>%s</official><percentage>%.2f</percentage><passed>%d</passed>", $mark->getShortName(), $mark->getOfficialName(), $mark->getMinimumLevel(), $mark->getPassed())); $a_xml_writer->xmlEndTag("qtimetadatafield"); } $a_xml_writer->xmlEndTag("qtimetadata"); // add qti objectives $a_xml_writer->xmlStartTag("objectives"); $this->addQTIMaterial($a_xml_writer, $this->getIntroduction()); $a_xml_writer->xmlEndTag("objectives"); // add qti assessmentcontrol if ($this->getInstantFeedbackSolution() == 1) { $attrs = array("solutionswitch" => "Yes"); } else { $attrs = NULL; } $a_xml_writer->xmlElement("assessmentcontrol", $attrs, NULL); if (strlen($this->getFinalStatement())) { // add qti presentation_material $a_xml_writer->xmlStartTag("presentation_material"); $a_xml_writer->xmlStartTag("flow_mat"); $this->addQTIMaterial($a_xml_writer, $this->getFinalStatement()); $a_xml_writer->xmlEndTag("flow_mat"); $a_xml_writer->xmlEndTag("presentation_material"); } $attrs = array("ident" => "1"); $a_xml_writer->xmlElement("section", $attrs, NULL); $a_xml_writer->xmlEndTag("assessment"); $a_xml_writer->xmlEndTag("questestinterop"); $xml = $a_xml_writer->xmlDumpMem(FALSE); foreach ($this->questions as $question_id) { $question =& ilObjTest::_instanciateQuestion($question_id); $qti_question = $question->toXML(false); $qti_question = preg_replace("/<questestinterop>/", "", $qti_question); $qti_question = preg_replace("/<\\/questestinterop>/", "", $qti_question); if (strpos($xml, "</section>") !== false) { $xml = str_replace("</section>", "{$qti_question}</section>", $xml); } else { $xml = str_replace("<section ident=\"1\"/>", "<section ident=\"1\">\n{$qti_question}</section>", $xml); } } return $xml; }