ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 @access public

Reimplemented from assQuestionExport.

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

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

References $DIC, $i, $param, $xml, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), JAVAAPPLET_QUESTION_IDENTIFIER, and ilXmlWriter\xmlHeader().

+ Here is the call graph for this function:

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