ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.assFileUploadExport.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 
34 {
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, "maxsize");
86  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getMaxSize());
87  $a_xml_writer->xmlEndTag("qtimetadatafield");
88  $a_xml_writer->xmlStartTag("qtimetadatafield");
89  $a_xml_writer->xmlElement("fieldlabel", NULL, "allowedextensions");
90  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getAllowedExtensions());
91  $a_xml_writer->xmlEndTag("qtimetadatafield");
92  $a_xml_writer->xmlEndTag("qtimetadata");
93  $a_xml_writer->xmlEndTag("itemmetadata");
94 
95  // PART I: qti presentation
96  $attrs = array(
97  "label" => $this->object->getTitle()
98  );
99  $a_xml_writer->xmlStartTag("presentation", $attrs);
100  // add flow to presentation
101  $a_xml_writer->xmlStartTag("flow");
102  // add material with question text to presentation
103  $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
104  // add answers to presentation
105  $a_xml_writer->xmlEndTag("flow");
106  $a_xml_writer->xmlEndTag("presentation");
107 
108  $this->exportFeedbackOnly($a_xml_writer);
109 
110  $a_xml_writer->xmlEndTag("item");
111  $a_xml_writer->xmlEndTag("questestinterop");
112 
113  $xml = $a_xml_writer->xmlDumpMem(FALSE);
114  if (!$a_include_header)
115  {
116  $pos = strpos($xml, "?>");
117  $xml = substr($xml, $pos + 2);
118  }
119  return $xml;
120  }
121 
122 }
123 
124 ?>