ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestExportQTI Class Reference

Class ilTestExportQTI Generates XML export of ILIAS tests in QTI format. More...

+ Collaboration diagram for ilTestExportQTI:

Public Member Functions

 __construct (&$tst_obj)
 toXML ()
 Returns a QTI xml representation of the test.

Protected Member Functions

 addQTIMaterial (&$a_xml_writer, $a_material)
 Creates a QTI material tag from a plain text or xhtml text.

Private Attributes

 $objTest

Detailed Description

Class ilTestExportQTI Generates XML export of ILIAS tests in QTI format.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

Definition at line 13 of file class.ilTestExportQTI.php.

Constructor & Destructor Documentation

ilTestExportQTI::__construct ( $tst_obj)

Definition at line 17 of file class.ilTestExportQTI.php.

{
$this->objTest = $tst_obj;
}

Member Function Documentation

ilTestExportQTI::addQTIMaterial ( $a_xml_writer,
  $a_material 
)
protected

Creates a QTI material tag from a plain text or xhtml text.

Parameters
object$a_xml_writerReference to the ILIAS XML writer
string$a_materialplain text or html text containing the material
Returns
string QTI material tag public

Definition at line 400 of file class.ilTestExportQTI.php.

References $mobs, ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), and ilRTE\_replaceMediaObjectImageSrc().

Referenced by toXML().

{
include_once "./Services/RTE/classes/class.ilRTE.php";
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
$a_xml_writer->xmlStartTag("material");
$attrs = array(
"texttype" => "text/plain"
);
if ($this->objTest->isHTML($a_material))
{
$attrs["texttype"] = "text/xhtml";
}
$a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
$mobs = ilObjMediaObject::_getMobsOfObject("tst:html", $this->objTest->getId());
foreach ($mobs as $mob)
{
$moblabel = "il_" . IL_INST_ID . "_mob_" . $mob;
if (strpos($a_material, "mm_$mob") !== FALSE)
{
{
$mob_obj =& new ilObjMediaObject($mob);
$imgattrs = array(
"label" => $moblabel,
"uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle()
);
}
$a_xml_writer->xmlElement("matimage", $imgattrs, NULL);
}
}
$a_xml_writer->xmlEndTag("material");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestExportQTI::toXML ( )

Returns a QTI xml representation of the test.

Returns
string The QTI xml representation of the test public

Definition at line 28 of file class.ilTestExportQTI.php.

References ilObjTest\_instanciateQuestion(), addQTIMaterial(), and ilXmlWriter\xmlHeader().

{
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->objTest->getTestId(),
"title" => $this->objTest->getTitle()
);
$a_xml_writer->xmlStartTag("assessment", $attrs);
// add qti comment
$a_xml_writer->xmlElement("qticomment", NULL, $this->objTest->getDescription());
// add qti duration
if ($this->objTest->getEnableProcessingTime())
{
preg_match("/(\d+):(\d+):(\d+)/", $this->objTest->getProcessingTime(), $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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->getPassScoring());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// score reporting date
if ($this->objTest->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->objTest->getReportingDate(), $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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->getShowFinalStatement()) ? "1" : "0")));
$a_xml_writer->xmlEndTag("qtimetadatafield");
// redirect after exam
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "redirect_after_exam");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->objTest->getRedirectAfterExam());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// redirect only in kiosk mode
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "redirect_only_kiosk_mode");
$a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", (($this->objTest->getRedirectOnlyKioskMode()) ? "1" : "0")));
$a_xml_writer->xmlEndTag("qtimetadatafield");
// save exam PDF for archive
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "exam_pdf");
$a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", (($this->objTest->getExamPdf()) ? "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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->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->objTest->getProcessingTime());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// autosave
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "autosave");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->objTest->getAutosave());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// enable processing Time
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "enable_processing_time");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->objTest->getEnableProcessingTime());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// starting time
if ($this->objTest->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->objTest->getStartingTime(), $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->objTest->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->objTest->getEndingTime(), $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->objTest->getMarkSchema()->getMarkSteps() 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->objTest->getIntroduction());
$a_xml_writer->xmlEndTag("objectives");
// add qti assessmentcontrol
if ($this->objTest->getInstantFeedbackSolution() == 1)
{
$attrs = array(
"solutionswitch" => "Yes"
);
}
else
{
$attrs = NULL;
}
$a_xml_writer->xmlElement("assessmentcontrol", $attrs, NULL);
if (strlen($this->objTest->getFinalStatement()))
{
// add qti presentation_material
$a_xml_writer->xmlStartTag("presentation_material");
$a_xml_writer->xmlStartTag("flow_mat");
$this->addQTIMaterial($a_xml_writer, $this->objTest->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);
include_once "./Modules/Test/classes/class.ilObjTest.php";
foreach ($this->objTest->getQuestions() 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;
}

+ Here is the call graph for this function:

Field Documentation

ilTestExportQTI::$objTest
private

Definition at line 15 of file class.ilTestExportQTI.php.


The documentation for this class was generated from the following file: