ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.assFlashQuestionExport.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, "width");
86  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getWidth());
87  $a_xml_writer->xmlEndTag("qtimetadatafield");
88  $a_xml_writer->xmlStartTag("qtimetadatafield");
89  $a_xml_writer->xmlElement("fieldlabel", NULL, "height");
90  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getHeight());
91  $a_xml_writer->xmlEndTag("qtimetadatafield");
92  $a_xml_writer->xmlStartTag("qtimetadatafield");
93  $a_xml_writer->xmlElement("fieldlabel", NULL, "applet");
94  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getApplet());
95  $a_xml_writer->xmlEndTag("qtimetadatafield");
96  $a_xml_writer->xmlStartTag("qtimetadatafield");
97  $a_xml_writer->xmlElement("fieldlabel", NULL, "swf");
98  $flashpath = $this->object->getFlashPath() . $this->object->getApplet();
99  $fh = @fopen($flashpath, "rb");
100  $base64 = "";
101  if ($fh != FALSE)
102  {
103  $flashfile = fread($fh, filesize($flashpath));
104  fclose($fh);
105  $base64 = base64_encode($flashfile);
106  }
107  $a_xml_writer->xmlElement("fieldentry", NULL, $base64);
108  $a_xml_writer->xmlEndTag("qtimetadatafield");
109  $a_xml_writer->xmlStartTag("qtimetadatafield");
110  $a_xml_writer->xmlElement("fieldlabel", NULL, "params");
111  $a_xml_writer->xmlElement("fieldentry", NULL, serialize($this->object->getParameters()));
112  $a_xml_writer->xmlEndTag("qtimetadatafield");
113  $a_xml_writer->xmlEndTag("qtimetadata");
114  $a_xml_writer->xmlEndTag("itemmetadata");
115 
116  // PART I: qti presentation
117  $attrs = array(
118  "label" => $this->object->getTitle()
119  );
120  $a_xml_writer->xmlStartTag("presentation", $attrs);
121  // add flow to presentation
122  $a_xml_writer->xmlStartTag("flow");
123  // add material with question text to presentation
124  $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
125  // add answers to presentation
126  $a_xml_writer->xmlEndTag("flow");
127  $a_xml_writer->xmlEndTag("presentation");
128 
129  $this->exportFeedbackOnly($a_xml_writer);
130 
131  $a_xml_writer->xmlEndTag("item");
132  $a_xml_writer->xmlEndTag("questestinterop");
133 
134  $xml = $a_xml_writer->xmlDumpMem(FALSE);
135  if (!$a_include_header)
136  {
137  $pos = strpos($xml, "?>");
138  $xml = substr($xml, $pos + 2);
139  }
140  return $xml;
141  }
142 
143 }
144 
145 ?>