ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 29 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 42 of file class.assQuestionExport.php.

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

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 205 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(), assSingleChoiceExport\toXML(), assMultipleChoiceExport\toXML(), assImagemapQuestionExport\toXML(), assMatchingQuestionExport\toXML(), assTextQuestionExport\toXML(), assOrderingQuestionExport\toXML(), and assClozeTestExport\toXML().

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

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

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

50  : void
51  {
52  foreach ($answers as $index => $answer) {
53  $linkrefid = "response_$index";
54  $attrs = [
55  "ident" => $linkrefid,
56  "view" => "All"
57  ];
58  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
59  // qti flow_mat
60  $a_xml_writer->xmlStartTag("flow_mat");
61  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
62  $this->object->getId(),
63  0,
64  $index
65  );
66  $this->addQTIMaterial($a_xml_writer, $fb);
67  $a_xml_writer->xmlEndTag("flow_mat");
68  $a_xml_writer->xmlEndTag("itemfeedback");
69  }
70  }
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 217 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(), assSingleChoiceExport\toXML(), assMultipleChoiceExport\toXML(), assImagemapQuestionExport\toXML(), assMatchingQuestionExport\toXML(), assTextQuestionExport\toXML(), assOrderingQuestionExport\toXML(), and assClozeTestExport\toXML().

217  : void
218  {
219  $this->addQtiMetaDataField($xmlwriter, 'externalId', $this->object->getExternalId());
220 
221  $this->addQtiMetaDataField(
222  $xmlwriter,
223  'ilias_lifecycle',
224  $this->object->getLifecycle()->getIdentifier()
225  );
226 
227  $this->addQtiMetaDataField(
228  $xmlwriter,
229  'lifecycle',
230  $this->object->getLifecycle()->getMappedLomLifecycle()
231  );
232  }
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 75 of file class.assQuestionExport.php.

References exportFeedbackOnly().

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

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

References ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilRTE\_replaceMediaObjectImageSrc(), IL_INST_ID, ilUtil\isHTML(), null, 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(), assSingleChoiceExport\toXML(), assNumericExport\toXML(), assMultipleChoiceExport\toXML(), assImagemapQuestionExport\toXML(), assMatchingQuestionExport\toXML(), assOrderingQuestionExport\toXML(), assTextQuestionExport\toXML(), and assClozeTestExport\toXML().

297  : void
298  {
299  $a_xml_writer->xmlStartTag("material");
300  $attrs = [
301  "texttype" => "text/plain"
302  ];
303  if (ilUtil::isHTML($a_material)) {
304  $attrs["texttype"] = "text/xhtml";
305  }
306  $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
307  if ($add_mobs) {
308  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->object->getId());
309  foreach ($mobs as $mob) {
310  $moblabel = "il_" . IL_INST_ID . "_mob_" . $mob;
311  if (str_contains($a_material, "mm_$mob")) {
312  if (ilObjMediaObject::_exists($mob)) {
313  $mob_obj = new ilObjMediaObject($mob);
314  $imgattrs = [
315  "label" => $moblabel,
316  "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle()
317  ];
318  }
319  $a_xml_writer->xmlElement("matimage", $imgattrs, null);
320  }
321  }
322  }
323  if ($close_material_tag) {
324  $a_xml_writer->xmlEndTag("material");
325  }
326  }
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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 189 of file class.assQuestionExport.php.

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

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

189  : void
190  {
191  $a_xml_writer->xmlStartTag("qtimetadatafield");
192  $a_xml_writer->xmlElement("fieldlabel", null, $fieldLabel);
193  $a_xml_writer->xmlElement("fieldentry", null, $fieldValue);
194  $a_xml_writer->xmlEndTag("qtimetadatafield");
195  }
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 236 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(), assSingleChoiceExport\toXML(), assMultipleChoiceExport\toXML(), assImagemapQuestionExport\toXML(), assMatchingQuestionExport\toXML(), assTextQuestionExport\toXML(), assOrderingQuestionExport\toXML(), and assClozeTestExport\toXML().

236  : ilXmlWriter
237  {
238  $question_id = (int) $this->object->getId();
239  $list = ilAssQuestionHintList::getListByQuestionId($question_id);
240 
241  foreach ($list as $hint) {
242  $attrs = [
243  'index' => $hint->getIndex(),
244  'points' => $hint->getPoints()
245  ];
246  if ($this->object->isAdditionalContentEditingModePageObject()) {
247  try {
248  $data = (new ilAssHintPage($hint->getId()))->getXMLContent();
249  } catch (Exception $e) {
250  continue;
251  }
252  } else {
253  $data = $hint->getText();
254  }
255 
256  $writer->xmlElement(self::ITEM_SOLUTIONHINT, $attrs, $data);
257  }
258  return $writer;
259  }
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...
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 261 of file class.assQuestionExport.php.

References IL_INST_ID, null, 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(), assSingleChoiceExport\toXML(), assMultipleChoiceExport\toXML(), assImagemapQuestionExport\toXML(), assMatchingQuestionExport\toXML(), assTextQuestionExport\toXML(), assOrderingQuestionExport\toXML(), and assClozeTestExport\toXML().

261  : ilXmlWriter
262  {
263  $solution = $this->object->getSuggestedSolution();
264  if ($solution === null) {
265  return $writer;
266  }
267 
268  $mattext = ['type' => $solution->getType()];
269  $attrs = [
270  'label' => 'suggested_solution',
271  'texttype' => 'application/json'
272  ];
273 
274  if ($solution instanceof SuggestedSolutionFile) {
275  $mattext['title'] = $solution->getTitle();
276  $mattext['filename'] = $solution->getFilename();
277  $mattext['value'] = base64_encode(file_get_contents(
278  $this->object->getSuggestedSolutionPath() . $solution->getFilename()
279  ));
280  } else {
281  if (!preg_match('/il_(\d*?)_(\w+)_(\d+)/', $solution->getInternalLink(), $matches)) {
282  return $writer;
283  }
284  $mattext['value'] = 'il_' . IL_INST_ID . '_' . $matches[2] . '_' . $matches[3];
285  if ($matches[1] !== '') {
286  $mattext['value'] = $solution['internal_link'];
287  }
288 
289  }
290 
291  $writer->xmlStartTag('material');
292  $writer->xmlElement('mattext', $attrs, json_encode($mattext));
293  $writer->xmlEndTag('material');
294  return $writer;
295  }
const IL_INST_ID
Definition: constants.php:40
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 80 of file class.assQuestionExport.php.

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

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

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

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

Field Documentation

◆ $object

assQuestionExport::$object

Definition at line 34 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: