ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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
 
const ITEM_SOLUTIONHINT = 'solutionhint'
 

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

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)

protected

Parameters
ilXmlWriter$a_xml_writer

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

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

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

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 ...
+ 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.

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

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

51  : void
52  {
53  foreach ($answers as $index => $answer) {
54  $linkrefid = "response_$index";
55  $attrs = array(
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.
+ 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.

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

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

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  }
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 ...
+ 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.

References exportFeedbackOnly().

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

76  : void
77  {
78  $this->exportFeedbackOnly($a_xml_writer);
79  }
exportFeedbackOnly($a_xml_writer)
+ 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 299 of file class.assQuestionExport.php.

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(), assLongMenuExport\toXML(), assKprimChoiceExport\toXML(), assFileUploadExport\toXML(), assErrorTextExport\toXML(), assTextSubsetExport\toXML(), assFormulaQuestionExport\toXML(), assOrderingHorizontalExport\toXML(), assNumericExport\toXML(), assSingleChoiceExport\toXML(), assImagemapQuestionExport\toXML(), assMultipleChoiceExport\toXML(), assMatchingQuestionExport\toXML(), assTextQuestionExport\toXML(), assOrderingQuestionExport\toXML(), and assClozeTestExport\toXML().

299  : void
300  {
301  $a_xml_writer->xmlStartTag("material");
302  $attrs = array(
303  "texttype" => "text/plain"
304  );
305  if (ilUtil::isHTML($a_material)) {
306  $attrs["texttype"] = "text/xhtml";
307  }
308  $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
309  if ($add_mobs) {
310  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->object->getId());
311  foreach ($mobs as $mob) {
312  $moblabel = "il_" . IL_INST_ID . "_mob_" . $mob;
313  if (str_contains($a_material, "mm_$mob")) {
314  if (ilObjMediaObject::_exists($mob)) {
315  $mob_obj = new ilObjMediaObject($mob);
316  $imgattrs = array(
317  "label" => $moblabel,
318  "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle()
319  );
320  }
321  $a_xml_writer->xmlElement("matimage", $imgattrs, null);
322  }
323  }
324  }
325  if ($close_material_tag) {
326  $a_xml_writer->xmlEndTag("material");
327  }
328  }
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...
const IL_INST_ID
Definition: constants.php:40
static isHTML(string $a_text)
Checks if a given string contains HTML or not.
xmlEndTag(string $tag)
Writes an endtag.
static _exists(int $id, bool $reference=false, ?string $type=null)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ 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)

protected

Parameters
ilXmlWriter$a_xml_writer
string$fieldLabel
string$fieldValue

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

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

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

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  }
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addSolutionHints()

assQuestionExport::addSolutionHints ( ilXmlWriter  $writer)
protected

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

References $data, Vendor\Package\$e, ilAssQuestionHintList\getListByQuestionId(), ILIAS\Repository\int(), ILIAS\Repository\object(), and ilXmlWriter\xmlElement().

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

237  : ilXmlWriter
238  {
239  $question_id = (int) $this->object->getId();
240  $list = ilAssQuestionHintList::getListByQuestionId($question_id);
241 
242  foreach ($list as $hint) {
243  $attrs = [
244  'index' => $hint->getIndex(),
245  'points' => $hint->getPoints()
246  ];
247  if ($this->object->isAdditionalContentEditingModePageObject()) {
248  try {
249  $data = (new ilAssHintPage($hint->getId()))->getXMLContent();
250  } catch (Exception $e) {
251  continue;
252  }
253  } else {
254  $data = $hint->getText();
255  }
256 
257  $writer->xmlElement(self::ITEM_SOLUTIONHINT, $attrs, $data);
258  }
259  return $writer;
260  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ 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 262 of file class.assQuestionExport.php.

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

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

262  : ilXmlWriter
263  {
264  $solution = $this->object->getSuggestedSolution();
265  if ($solution === null) {
266  return $writer;
267  }
268 
269  $mattext = ['type' => $solution->getType()];
270  $attrs = [
271  'label' => 'suggested_solution',
272  'texttype' => 'application/json'
273  ];
274 
275  if ($solution instanceof assSuggestedSolutionFile) {
276  $mattext['title'] = $solution->getTitle();
277  $mattext['filename'] = $solution->getFilename();
278  $mattext['value'] = base64_encode(file_get_contents(
279  $this->object->getSuggestedSolutionPath() . $solution->getFilename()
280  ));
281  } else {
282  if (!preg_match('/il_(\d*?)_(\w+)_(\d+)/', $solution->getInternalLink(), $matches)) {
283  return $writer;
284  }
285  $mattext['value'] = 'il_' . IL_INST_ID . '_' . $matches[2] . '_' . $matches[3];
286  if ($matches[1] !== '') {
287  $mattext['value'] = $solution['internal_link'];
288  }
289 
290  }
291 
292  $writer->xmlStartTag('material');
293  $writer->xmlElement('mattext', $attrs, json_encode($mattext));
294  $writer->xmlEndTag('material');
295 
296  return $writer;
297  }
const IL_INST_ID
Definition: constants.php:40
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlEndTag(string $tag)
Writes an endtag.
a suggested solution for file-contents
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ 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.

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

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

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 = array(
100  "continue" => "Yes"
101  );
102  $a_xml_writer->xmlStartTag("respcondition", $attrs);
103  // qti conditionvar
104  $a_xml_writer->xmlStartTag("conditionvar");
105  $attrs = array(
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 = array(
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 = array(
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 = array(
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 = array(
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 = array(
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 = array(
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  }
addQTIMaterial(ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
+ 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.

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().

◆ ITEM_SOLUTIONHINT

const assQuestionExport::ITEM_SOLUTIONHINT = 'solutionhint'

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