ILIAS  eassessment Revision 61809
 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->xmlStartTag("qtimetadatafield");
114  $a_xml_writer->xmlElement("fieldlabel", NULL, "externalID");
115  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getExternalID());
116  $a_xml_writer->xmlEndTag("qtimetadatafield");
117  $a_xml_writer->xmlEndTag("qtimetadata");
118  $a_xml_writer->xmlEndTag("itemmetadata");
119 
120  // PART I: qti presentation
121  $attrs = array(
122  "label" => $this->object->getTitle()
123  );
124  $a_xml_writer->xmlStartTag("presentation", $attrs);
125  // add flow to presentation
126  $a_xml_writer->xmlStartTag("flow");
127  // add material with question text to presentation
128  $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
129  // add answers to presentation
130  $a_xml_writer->xmlEndTag("flow");
131  $a_xml_writer->xmlEndTag("presentation");
132 
133  $this->exportFeedbackOnly($a_xml_writer);
134 
135  $a_xml_writer->xmlEndTag("item");
136  $a_xml_writer->xmlEndTag("questestinterop");
137 
138  $xml = $a_xml_writer->xmlDumpMem(FALSE);
139  if (!$a_include_header)
140  {
141  $pos = strpos($xml, "?>");
142  $xml = substr($xml, $pos + 2);
143  }
144  return $xml;
145  }
146 
147 }
148 
149 ?>