ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assJavaAppletExport Class Reference

Class for java applet question exports. More...

+ Inheritance diagram for assJavaAppletExport:
+ Collaboration diagram for assJavaAppletExport:

Public Member Functions

 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
- Public Member Functions inherited from assQuestionExport
 __construct ($a_object)
 assQuestionExport constructor More...
 
 exportFeedbackOnly ($a_xml_writer)
 
 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 

Additional Inherited Members

- Data Fields inherited from assQuestionExport
 $object
 
- Protected Member Functions inherited from assQuestionExport
 addAnswerSpecificFeedback (ilXmlWriter $a_xml_writer, $answers)
 
 addGenericFeedback (ilXmlWriter $a_xml_writer)
 
 addQtiMetaDataField (ilXmlWriter $a_xml_writer, $fieldLabel, $fieldValue)
 adds a qti meta data field with given name and value to the passed xml writer (xml writer must be in context of opened "qtimetadata" tag) More...
 
 addAdditionalContentEditingModeInformation (ilXmlWriter $a_xml_writer)
 adds a qti meta data field for ilias specific information of "additional content editing mode" (xml writer must be in context of opened "qtimetadata" tag) More...
 
 addGeneralMetadata (ilXmlWriter $xmlwriter)
 

Detailed Description

Class for java applet question exports.

assJavaAppletExport is a class for java applet question exports

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

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

Member Function Documentation

◆ toXML()

assJavaAppletExport::toXML (   $a_include_header = true,
  $a_include_binary = true,
  $a_shuffle = false,
  $test_output = false,
  $force_image_references = false 
)

Returns a QTI xml representation of the question.

Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation

Returns
string The QTI xml representation of the question public

Definition at line 26 of file class.assJavaAppletExport.php.

References $fh, $i, $xml, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), array, JAVAAPPLET_QUESTION_IDENTIFIER, object, and ilXmlWriter\xmlHeader().

27  {
28  global $ilias;
29  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
30  $a_xml_writer = new ilXmlWriter;
31  // set xml header
32  $a_xml_writer->xmlHeader();
33  $a_xml_writer->xmlStartTag("questestinterop");
34  $attrs = array(
35  "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
36  "title" => $this->object->getTitle(),
37  "maxattempts" => $this->object->getNrOfTries()
38  );
39  $a_xml_writer->xmlStartTag("item", $attrs);
40  // add question description
41  $a_xml_writer->xmlElement("qticomment", null, $this->object->getComment());
42  // add estimated working time
43  $workingtime = $this->object->getEstimatedWorkingTime();
44  $duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
45  $a_xml_writer->xmlElement("duration", null, $duration);
46  // add ILIAS specific metadata
47  $a_xml_writer->xmlStartTag("itemmetadata");
48  $a_xml_writer->xmlStartTag("qtimetadata");
49  $a_xml_writer->xmlStartTag("qtimetadatafield");
50  $a_xml_writer->xmlElement("fieldlabel", null, "ILIAS_VERSION");
51  $a_xml_writer->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
52  $a_xml_writer->xmlEndTag("qtimetadatafield");
53  $a_xml_writer->xmlStartTag("qtimetadatafield");
54  $a_xml_writer->xmlElement("fieldlabel", null, "QUESTIONTYPE");
55  $a_xml_writer->xmlElement("fieldentry", null, JAVAAPPLET_QUESTION_IDENTIFIER);
56  $a_xml_writer->xmlEndTag("qtimetadatafield");
57  $a_xml_writer->xmlStartTag("qtimetadatafield");
58  $a_xml_writer->xmlElement("fieldlabel", null, "AUTHOR");
59  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getAuthor());
60  $a_xml_writer->xmlEndTag("qtimetadatafield");
61 
62  // additional content editing information
63  $this->addAdditionalContentEditingModeInformation($a_xml_writer);
64  $this->addGeneralMetadata($a_xml_writer);
65 
66  $a_xml_writer->xmlEndTag("qtimetadata");
67  $a_xml_writer->xmlEndTag("itemmetadata");
68 
69  // PART I: qti presentation
70  $attrs = array(
71  "label" => $this->object->getTitle()
72  );
73  $a_xml_writer->xmlStartTag("presentation", $attrs);
74  // add flow to presentation
75  $a_xml_writer->xmlStartTag("flow");
76  // add material with question text to presentation
77  $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
78  $solution = $this->object->getSuggestedSolution(0);
79  if (count($solution)) {
80  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches)) {
81  $a_xml_writer->xmlStartTag("material");
82  $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
83  if (strcmp($matches[1], "") != 0) {
84  $intlink = $solution["internal_link"];
85  }
86  $attrs = array(
87  "label" => "suggested_solution"
88  );
89  $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
90  $a_xml_writer->xmlEndTag("material");
91  }
92  }
93 
94  $a_xml_writer->xmlStartTag("material");
95  $attrs = array(
96  "label" => "applet data",
97  "uri" => $this->object->getJavaAppletFilename(),
98  "height" => $this->object->getJavaHeight(),
99  "width" => $this->object->getJavaWidth(),
100  "embedded" => "base64"
101  );
102  $javapath = $this->object->getJavaPath() . $this->object->getJavaAppletFilename();
103  $fh = @fopen($javapath, "rb");
104  if ($fh == false) {
105  return;
106  }
107  $javafile = fread($fh, filesize($javapath));
108  fclose($fh);
109  $base64 = base64_encode($javafile);
110  $a_xml_writer->xmlElement("matapplet", $attrs, $base64);
111 
112  if ($this->object->buildParamsOnly()) {
113  if ($this->object->getJavaCode()) {
114  $attrs = array(
115  "label" => "java_code"
116  );
117  $a_xml_writer->xmlElement("mattext", $attrs, $this->object->getJavaCode());
118  }
119  if ($this->object->getJavaCodebase()) {
120  $attrs = array(
121  "label" => "java_codebase"
122  );
123  $a_xml_writer->xmlElement("mattext", $attrs, $this->object->getJavaCodebase());
124  }
125  if ($this->object->getJavaArchive()) {
126  $attrs = array(
127  "label" => "java_archive"
128  );
129  $a_xml_writer->xmlElement("mattext", $attrs, $this->object->getJavaArchive());
130  }
131  for ($i = 0; $i < $this->object->getParameterCount(); $i++) {
132  $param = $this->object->getParameter($i);
133  $attrs = array(
134  "label" => $param["name"]
135  );
136  $a_xml_writer->xmlElement("mattext", $attrs, $param["value"]);
137  }
138  }
139  $a_xml_writer->xmlEndTag("material");
140  $a_xml_writer->xmlStartTag("material");
141  $attrs = array(
142  "label" => "points"
143  );
144  $a_xml_writer->xmlElement("mattext", $attrs, $this->object->getPoints());
145  $a_xml_writer->xmlEndTag("material");
146 
147  $a_xml_writer->xmlEndTag("flow");
148  $a_xml_writer->xmlEndTag("presentation");
149 
150  // PART II: qti resprocessing
151  $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
152  $this->object->getId(),
153  true
154  );
155  $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
156  $this->object->getId(),
157  false
158  );
159  if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
160  $a_xml_writer->xmlStartTag("resprocessing");
161  $a_xml_writer->xmlStartTag("outcomes");
162  $a_xml_writer->xmlStartTag("decvar");
163  $a_xml_writer->xmlEndTag("decvar");
164  $a_xml_writer->xmlEndTag("outcomes");
165 
166  if (strlen($feedback_allcorrect)) {
167  $attrs = array(
168  "continue" => "Yes"
169  );
170  $a_xml_writer->xmlStartTag("respcondition", $attrs);
171  // qti conditionvar
172  $a_xml_writer->xmlStartTag("conditionvar");
173  $attrs = array(
174  "respident" => "points"
175  );
176  $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
177  $a_xml_writer->xmlEndTag("conditionvar");
178  // qti displayfeedback
179  $attrs = array(
180  "feedbacktype" => "Response",
181  "linkrefid" => "response_allcorrect"
182  );
183  $a_xml_writer->xmlElement("displayfeedback", $attrs);
184  $a_xml_writer->xmlEndTag("respcondition");
185  }
186 
187  if (strlen($feedback_onenotcorrect)) {
188  $attrs = array(
189  "continue" => "Yes"
190  );
191  $a_xml_writer->xmlStartTag("respcondition", $attrs);
192  // qti conditionvar
193  $a_xml_writer->xmlStartTag("conditionvar");
194  $a_xml_writer->xmlStartTag("not");
195  $attrs = array(
196  "respident" => "points"
197  );
198  $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
199  $a_xml_writer->xmlEndTag("not");
200  $a_xml_writer->xmlEndTag("conditionvar");
201  // qti displayfeedback
202  $attrs = array(
203  "feedbacktype" => "Response",
204  "linkrefid" => "response_onenotcorrect"
205  );
206  $a_xml_writer->xmlElement("displayfeedback", $attrs);
207  $a_xml_writer->xmlEndTag("respcondition");
208  }
209  $a_xml_writer->xmlEndTag("resprocessing");
210  }
211 
212  if (strlen($feedback_allcorrect)) {
213  $attrs = array(
214  "ident" => "response_allcorrect",
215  "view" => "All"
216  );
217  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
218  // qti flow_mat
219  $a_xml_writer->xmlStartTag("flow_mat");
220  $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
221  $a_xml_writer->xmlEndTag("flow_mat");
222  $a_xml_writer->xmlEndTag("itemfeedback");
223  }
224  if (strlen($feedback_onenotcorrect)) {
225  $attrs = array(
226  "ident" => "response_onenotcorrect",
227  "view" => "All"
228  );
229  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
230  // qti flow_mat
231  $a_xml_writer->xmlStartTag("flow_mat");
232  $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
233  $a_xml_writer->xmlEndTag("flow_mat");
234  $a_xml_writer->xmlEndTag("itemfeedback");
235  }
236 
237  $a_xml_writer->xmlEndTag("item");
238  $a_xml_writer->xmlEndTag("questestinterop");
239  $xml = $a_xml_writer->xmlDumpMem(false);
240  if (!$a_include_header) {
241  $pos = strpos($xml, "?>");
242  $xml = substr($xml, $pos + 2);
243  }
244  return $xml;
245  }
XML writer class.
addGeneralMetadata(ilXmlWriter $xmlwriter)
const JAVAAPPLET_QUESTION_IDENTIFIER
$xml
Definition: metadata.php:240
xmlHeader()
Writes xml header public.
Create styles array
The data for the language used.
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
Create new PHPExcel object
obj_idprivate
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:

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