ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.assOrderingHorizontalExport.php
Go to the documentation of this file.
1 <?php
2  /*
3  +----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +----------------------------------------------------------------------------+
22 */
23 
24 include_once "./Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php";
25 
36 {
44  function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
45  {
46  global $ilias;
47 
48  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
49  $a_xml_writer = new ilXmlWriter;
50  // set xml header
51  $a_xml_writer->xmlHeader();
52  $a_xml_writer->xmlStartTag("questestinterop");
53  $attrs = array(
54  "ident" => "il_".IL_INST_ID."_qst_".$this->object->getId(),
55  "title" => $this->object->getTitle(),
56  "maxattempts" => $this->object->getNrOfTries()
57  );
58  $a_xml_writer->xmlStartTag("item", $attrs);
59  // add question description
60  $a_xml_writer->xmlElement("qticomment", NULL, $this->object->getComment());
61  // add estimated working time
62  $workingtime = $this->object->getEstimatedWorkingTime();
63  $duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
64  $a_xml_writer->xmlElement("duration", NULL, $duration);
65  // add ILIAS specific metadata
66  $a_xml_writer->xmlStartTag("itemmetadata");
67  $a_xml_writer->xmlStartTag("qtimetadata");
68  $a_xml_writer->xmlStartTag("qtimetadatafield");
69  $a_xml_writer->xmlElement("fieldlabel", NULL, "ILIAS_VERSION");
70  $a_xml_writer->xmlElement("fieldentry", NULL, $ilias->getSetting("ilias_version"));
71  $a_xml_writer->xmlEndTag("qtimetadatafield");
72  $a_xml_writer->xmlStartTag("qtimetadatafield");
73  $a_xml_writer->xmlElement("fieldlabel", NULL, "QUESTIONTYPE");
74  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getQuestionType());
75  $a_xml_writer->xmlEndTag("qtimetadatafield");
76  $a_xml_writer->xmlStartTag("qtimetadatafield");
77  $a_xml_writer->xmlElement("fieldlabel", NULL, "AUTHOR");
78  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getAuthor());
79  $a_xml_writer->xmlEndTag("qtimetadatafield");
80  $a_xml_writer->xmlStartTag("qtimetadatafield");
81  $a_xml_writer->xmlElement("fieldlabel", NULL, "points");
82  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getPoints());
83  $a_xml_writer->xmlEndTag("qtimetadatafield");
84  $a_xml_writer->xmlStartTag("qtimetadatafield");
85  $a_xml_writer->xmlElement("fieldlabel", NULL, "ordertext");
86  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getOrderText());
87  $a_xml_writer->xmlEndTag("qtimetadatafield");
88  $a_xml_writer->xmlStartTag("qtimetadatafield");
89  $a_xml_writer->xmlElement("fieldlabel", NULL, "textsize");
90  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getTextSize());
91  $a_xml_writer->xmlEndTag("qtimetadatafield");
92  $a_xml_writer->xmlStartTag("qtimetadatafield");
93  $a_xml_writer->xmlElement("fieldlabel", NULL, "separator");
94  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getSeparator());
95  $a_xml_writer->xmlEndTag("qtimetadatafield");
96  $a_xml_writer->xmlEndTag("qtimetadata");
97  $a_xml_writer->xmlEndTag("itemmetadata");
98 
99  // PART I: qti presentation
100  $attrs = array(
101  "label" => $this->object->getTitle()
102  );
103  $a_xml_writer->xmlStartTag("presentation", $attrs);
104  // add flow to presentation
105  $a_xml_writer->xmlStartTag("flow");
106  // add material with question text to presentation
107  $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
108  // add answers to presentation
109  $a_xml_writer->xmlEndTag("flow");
110  $a_xml_writer->xmlEndTag("presentation");
111 
112  $a_xml_writer->xmlEndTag("item");
113  $a_xml_writer->xmlEndTag("questestinterop");
114 
115  $xml = $a_xml_writer->xmlDumpMem(FALSE);
116  if (!$a_include_header)
117  {
118  $pos = strpos($xml, "?>");
119  $xml = substr($xml, $pos + 2);
120  }
121  return $xml;
122  }
123 
124 }
125 
126 ?>