ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
assQuestionExport Class Reference

Class for question exports. More...

+ Inheritance diagram for assQuestionExport:
+ Collaboration diagram for assQuestionExport:

Public Member Functions

 __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 Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation. More...
 
 addQTIMaterial (ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
 

Data Fields

 $object
 

Protected Member Functions

 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)
 
 addSuggestedSolution (ilXmlWriter $writer)
 

Detailed Description

Class for question exports.

exportQuestion is a basis class 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 30 of file class.assQuestionExport.php.

Constructor & Destructor Documentation

◆ __construct()

assQuestionExport::__construct (   $a_object)

assQuestionExport constructor

Parameters
object$a_objectThe question object @access public

Reimplemented in assClozeTestExport.

Definition at line 43 of file class.assQuestionExport.php.

44 {
45 $this->object = $a_object;
46 }

Member Function Documentation

◆ addAdditionalContentEditingModeInformation()

assQuestionExport::addAdditionalContentEditingModeInformation ( ilXmlWriter  $a_xml_writer)
finalprotected

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)

@final @access protected

Parameters
ilXmlWriter$a_xml_writer

Definition at line 206 of file class.assQuestionExport.php.

206 : void
207 {
208 $this->addQtiMetaDataField(
209 $a_xml_writer,
210 'additional_cont_edit_mode',
211 $this->object->getAdditionalContentEditingMode()
212 );
213 }
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 ...

References addQtiMetaDataField(), and ILIAS\Repository\object().

Referenced by assClozeTestExport\toXML(), assErrorTextExport\toXML(), assFileUploadExport\toXML(), assFormulaQuestionExport\toXML(), assImagemapQuestionExport\toXML(), assKprimChoiceExport\toXML(), assLongMenuExport\toXML(), assMatchingQuestionExport\toXML(), assMultipleChoiceExport\toXML(), assNumericExport\toXML(), assOrderingHorizontalExport\toXML(), assOrderingQuestionExport\toXML(), assSingleChoiceExport\toXML(), assTextQuestionExport\toXML(), and assTextSubsetExport\toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addAnswerSpecificFeedback()

assQuestionExport::addAnswerSpecificFeedback ( ilXmlWriter  $a_xml_writer,
  $answers 
)
protected
Parameters
ilXmlWriter$a_xml_writer

Definition at line 51 of file class.assQuestionExport.php.

51 : void
52 {
53 foreach ($answers as $index => $answer) {
54 $linkrefid = "response_$index";
55 $attrs = [
56 "ident" => $linkrefid,
57 "view" => "All"
58 ];
59 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
60 // qti flow_mat
61 $a_xml_writer->xmlStartTag("flow_mat");
62 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
63 $this->object->getId(),
64 0,
65 $index
66 );
67 $this->addQTIMaterial($a_xml_writer, $fb);
68 $a_xml_writer->xmlEndTag("flow_mat");
69 $a_xml_writer->xmlEndTag("itemfeedback");
70 }
71 }
addQTIMaterial(ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.

References addQTIMaterial(), ILIAS\Repository\object(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by assErrorTextExport\toXML(), and assTextQuestionExport\toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addGeneralMetadata()

assQuestionExport::addGeneralMetadata ( ilXmlWriter  $xmlwriter)
protected
Parameters
ilXmlWriter$xmlwriter

Definition at line 218 of file class.assQuestionExport.php.

218 : void
219 {
220 $this->addQtiMetaDataField($xmlwriter, 'externalId', $this->object->getExternalId());
221
222 $this->addQtiMetaDataField(
223 $xmlwriter,
224 'ilias_lifecycle',
225 $this->object->getLifecycle()->getIdentifier()
226 );
227
228 $this->addQtiMetaDataField(
229 $xmlwriter,
230 'lifecycle',
231 $this->object->getLifecycle()->getMappedLomLifecycle()
232 );
233 }

References addQtiMetaDataField(), and ILIAS\Repository\object().

Referenced by assClozeTestExport\toXML(), assErrorTextExport\toXML(), assFileUploadExport\toXML(), assFormulaQuestionExport\toXML(), assImagemapQuestionExport\toXML(), assKprimChoiceExport\toXML(), assLongMenuExport\toXML(), assMatchingQuestionExport\toXML(), assMultipleChoiceExport\toXML(), assNumericExport\toXML(), assOrderingHorizontalExport\toXML(), assOrderingQuestionExport\toXML(), assSingleChoiceExport\toXML(), assTextQuestionExport\toXML(), and assTextSubsetExport\toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addGenericFeedback()

assQuestionExport::addGenericFeedback ( ilXmlWriter  $a_xml_writer)
protected
Parameters
ilXmlWriter$a_xml_writer

Definition at line 76 of file class.assQuestionExport.php.

76 : void
77 {
78 $this->exportFeedbackOnly($a_xml_writer);
79 }
exportFeedbackOnly($a_xml_writer)

References exportFeedbackOnly().

Referenced by assErrorTextExport\toXML(), assFormulaQuestionExport\toXML(), and assOrderingHorizontalExport\toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addQTIMaterial()

assQuestionExport::addQTIMaterial ( ilXmlWriter  $a_xml_writer,
string  $a_material,
bool  $close_material_tag = true,
bool  $add_mobs = true 
)

Definition at line 271 of file class.assQuestionExport.php.

271 : void
272 {
273 $a_xml_writer->xmlStartTag("material");
274 $attrs = [
275 "texttype" => "text/plain"
276 ];
277 if (ilUtil::isHTML($a_material)) {
278 $attrs["texttype"] = "text/xhtml";
279 }
280 $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
281 if ($add_mobs) {
282 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->object->getId());
283 foreach ($mobs as $mob) {
284 $moblabel = "il_" . IL_INST_ID . "_mob_" . $mob;
285 if (str_contains($a_material, "mm_$mob")) {
286 if (ilObjMediaObject::_exists($mob)) {
287 $mob_obj = new ilObjMediaObject($mob);
288 $imgattrs = [
289 "label" => $moblabel,
290 "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle()
291 ];
292 }
293 $a_xml_writer->xmlElement("matimage", $imgattrs, null);
294 }
295 }
296 }
297 if ($close_material_tag) {
298 $a_xml_writer->xmlEndTag("material");
299 }
300 }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static isHTML(string $a_text)
Checks if a given string contains HTML or not.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
const IL_INST_ID
Definition: constants.php:40

References ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilRTE\_replaceMediaObjectImageSrc(), IL_INST_ID, ilUtil\isHTML(), ILIAS\Repository\object(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by addAnswerSpecificFeedback(), assClozeTestExport\exportAnswerSpecificFeedbacks(), exportFeedbackOnly(), assClozeTestExport\toXML(), assErrorTextExport\toXML(), assFileUploadExport\toXML(), assFormulaQuestionExport\toXML(), assImagemapQuestionExport\toXML(), assKprimChoiceExport\toXML(), assLongMenuExport\toXML(), assMatchingQuestionExport\toXML(), assMultipleChoiceExport\toXML(), assNumericExport\toXML(), assOrderingHorizontalExport\toXML(), assOrderingQuestionExport\toXML(), assSingleChoiceExport\toXML(), assTextQuestionExport\toXML(), and assTextSubsetExport\toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addQtiMetaDataField()

assQuestionExport::addQtiMetaDataField ( ilXmlWriter  $a_xml_writer,
  $fieldLabel,
  $fieldValue 
)
finalprotected

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)

@final @access protected

Parameters
ilXmlWriter$a_xml_writer
string$fieldLabel
string$fieldValue

Definition at line 190 of file class.assQuestionExport.php.

190 : void
191 {
192 $a_xml_writer->xmlStartTag("qtimetadatafield");
193 $a_xml_writer->xmlElement("fieldlabel", null, $fieldLabel);
194 $a_xml_writer->xmlElement("fieldentry", null, $fieldValue);
195 $a_xml_writer->xmlEndTag("qtimetadatafield");
196 }

References ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by addAdditionalContentEditingModeInformation(), addGeneralMetadata(), assMultipleChoiceExport\toXML(), assSingleChoiceExport\toXML(), and assTextQuestionExport\toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addSuggestedSolution()

assQuestionExport::addSuggestedSolution ( ilXmlWriter  $writer)
protected

Definition at line 235 of file class.assQuestionExport.php.

236 {
237 $solution = $this->object->getSuggestedSolution();
238 if ($solution === null) {
239 return $writer;
240 }
241
242 $mattext = ['type' => $solution->getType()];
243 $attrs = [
244 'label' => 'suggested_solution',
245 'texttype' => 'application/json'
246 ];
247
248 if ($solution instanceof SuggestedSolutionFile) {
249 $mattext['title'] = $solution->getTitle();
250 $mattext['filename'] = $solution->getFilename();
251 $mattext['value'] = base64_encode(file_get_contents(
252 $this->object->getSuggestedSolutionPath() . $solution->getFilename()
253 ));
254 } else {
255 if (!preg_match('/il_(\d*?)_(\w+)_(\d+)/', $solution->getInternalLink(), $matches)) {
256 return $writer;
257 }
258 $mattext['value'] = 'il_' . IL_INST_ID . '_' . $matches[2] . '_' . $matches[3];
259 if ($matches[1] !== '') {
260 $mattext['value'] = $solution->getInternalLink();
261 }
262
263 }
264
265 $writer->xmlStartTag('material');
266 $writer->xmlElement('mattext', $attrs, json_encode($mattext));
267 $writer->xmlEndTag('material');
268 return $writer;
269 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References IL_INST_ID, ILIAS\Repository\object(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by assClozeTestExport\toXML(), assErrorTextExport\toXML(), assFileUploadExport\toXML(), assFormulaQuestionExport\toXML(), assImagemapQuestionExport\toXML(), assKprimChoiceExport\toXML(), assLongMenuExport\toXML(), assMatchingQuestionExport\toXML(), assMultipleChoiceExport\toXML(), assNumericExport\toXML(), assOrderingHorizontalExport\toXML(), assOrderingQuestionExport\toXML(), assSingleChoiceExport\toXML(), assTextQuestionExport\toXML(), and assTextSubsetExport\toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportFeedbackOnly()

assQuestionExport::exportFeedbackOnly (   $a_xml_writer)

Definition at line 81 of file class.assQuestionExport.php.

81 : void
82 {
83 $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
84 $this->object->getId(),
85 true
86 );
87 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
88 $this->object->getId(),
89 false
90 );
91 if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
92 $a_xml_writer->xmlStartTag("resprocessing");
93 $a_xml_writer->xmlStartTag("outcomes");
94 $a_xml_writer->xmlStartTag("decvar");
95 $a_xml_writer->xmlEndTag("decvar");
96 $a_xml_writer->xmlEndTag("outcomes");
97
98 if (strlen($feedback_allcorrect)) {
99 $attrs = [
100 "continue" => "Yes"
101 ];
102 $a_xml_writer->xmlStartTag("respcondition", $attrs);
103 // qti conditionvar
104 $a_xml_writer->xmlStartTag("conditionvar");
105 $attrs = [
106 "respident" => "points"
107 ];
108 $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
109 $a_xml_writer->xmlEndTag("conditionvar");
110 // qti displayfeedback
111 $attrs = [
112 "feedbacktype" => "Response",
113 "linkrefid" => "response_allcorrect"
114 ];
115 $a_xml_writer->xmlElement("displayfeedback", $attrs);
116 $a_xml_writer->xmlEndTag("respcondition");
117 }
118
119 if (strlen($feedback_onenotcorrect)) {
120 $attrs = [
121 "continue" => "Yes"
122 ];
123 $a_xml_writer->xmlStartTag("respcondition", $attrs);
124 // qti conditionvar
125 $a_xml_writer->xmlStartTag("conditionvar");
126 $a_xml_writer->xmlStartTag("not");
127 $attrs = [
128 "respident" => "points"
129 ];
130 $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
131 $a_xml_writer->xmlEndTag("not");
132 $a_xml_writer->xmlEndTag("conditionvar");
133 // qti displayfeedback
134 $attrs = [
135 "feedbacktype" => "Response",
136 "linkrefid" => "response_onenotcorrect"
137 ];
138 $a_xml_writer->xmlElement("displayfeedback", $attrs);
139 $a_xml_writer->xmlEndTag("respcondition");
140 }
141 $a_xml_writer->xmlEndTag("resprocessing");
142 }
143
144 if (strlen($feedback_allcorrect)) {
145 $attrs = [
146 "ident" => "response_allcorrect",
147 "view" => "All"
148 ];
149 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
150 // qti flow_mat
151 $a_xml_writer->xmlStartTag("flow_mat");
152 $this->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
153 $a_xml_writer->xmlEndTag("flow_mat");
154 $a_xml_writer->xmlEndTag("itemfeedback");
155 }
156 if (strlen($feedback_onenotcorrect)) {
157 $attrs = [
158 "ident" => "response_onenotcorrect",
159 "view" => "All"
160 ];
161 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
162 // qti flow_mat
163 $a_xml_writer->xmlStartTag("flow_mat");
164 $this->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
165 $a_xml_writer->xmlEndTag("flow_mat");
166 $a_xml_writer->xmlEndTag("itemfeedback");
167 }
168 }

References addQTIMaterial(), and ILIAS\Repository\object().

Referenced by addGenericFeedback(), and assFileUploadExport\toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

assQuestionExport::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.

Reimplemented in assClozeTestExport, assErrorTextExport, assFileUploadExport, assFormulaQuestionExport, assImagemapQuestionExport, assKprimChoiceExport, assLongMenuExport, assMatchingQuestionExport, assMultipleChoiceExport, assNumericExport, assOrderingHorizontalExport, assOrderingQuestionExport, assSingleChoiceExport, assTextQuestionExport, assTextSubsetExport, and assLongMenuExportQti21.

Definition at line 175 of file class.assQuestionExport.php.

175 : string
176 {
177 return '';
178 }

Field Documentation

◆ $object

assQuestionExport::$object

Definition at line 35 of file class.assQuestionExport.php.

Referenced by assClozeTestExport\__construct().


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