ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
assQuestionImport Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for assQuestionImport:
+ Collaboration diagram for assQuestionImport:

Public Member Functions

 __construct ($a_object)
 assQuestionImport constructor More...
 
 getQuestionId ()
 
 getFeedbackGeneric ($item)
 
 fromXML (&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, $import_mapping)
 Creates a question from a QTI file. More...
 
 importSuggestedSolution (int $question_id, string $value="", int $subquestion_index=0)
 

Data Fields

 $object
 

Protected Member Functions

 fetchIndexFromFeedbackIdent ($feedbackIdent, $prefix='response_')
 
 getFeedbackAnswerSpecific (ilQTIItem $item, $prefix='response_')
 
 addGeneralMetadata (ilQTIItem $item)
 
 fetchLifecycle (ilQTIItem $item)
 
 getQplImportArchivDirectory ()
 returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir) More...
 
 getTstImportArchivDirectory ()
 returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) More...
 
 processNonAbstractedImageReferences ($text, $sourceNic)
 
 fetchAdditionalContentEditingModeInformation ($qtiItem)
 fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_CONTENT_EDITING_MODE_RTE when no or invalid information is given More...
 
 deduceThumbSizeFromImportValue (?int $size)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class for question imports

assQuestionImport is a basis class question imports

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.assQuestionImport.php.

Constructor & Destructor Documentation

◆ __construct()

assQuestionImport::__construct (   $a_object)

assQuestionImport constructor

Parameters
object$a_objectThe question object public

Definition at line 42 of file class.assQuestionImport.php.

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

Member Function Documentation

◆ addGeneralMetadata()

assQuestionImport::addGeneralMetadata ( ilQTIItem  $item)
protected
Parameters
ilQTIItem$item

Definition at line 187 of file class.assQuestionImport.php.

References fetchLifecycle(), and ilQTIItem\getMetadataEntry().

Referenced by assLongMenuImport\fromXML(), assKprimChoiceImport\fromXML(), assFlashQuestionImport\fromXML(), assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assTextSubsetImport\fromXML(), assNumericImport\fromXML(), assMultipleChoiceImport\fromXML(), assClozeTestImport\fromXML(), assFormulaQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assOrderingHorizontalImport\fromXML(), assImagemapQuestionImport\fromXML(), assOrderingQuestionImport\fromXML(), assTextQuestionImport\fromXML(), and assMatchingQuestionImport\fromXML().

187  : void
188  {
189  if ($item->getMetadataEntry('externalID')) {
190  $this->object->setExternalId($item->getMetadataEntry('externalID'));
191  } else {
192  $this->object->setExternalId($item->getMetadataEntry('externalId'));
193  }
194 
195  $this->object->setLifecycle($this->fetchLifecycle($item));
196  }
getMetadataEntry(string $a_label)
fetchLifecycle(ilQTIItem $item)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deduceThumbSizeFromImportValue()

assQuestionImport::deduceThumbSizeFromImportValue ( ?int  $size)
protected

Definition at line 306 of file class.assQuestionImport.php.

References ILIAS\Repository\object().

Referenced by assKprimChoiceImport\fromXML(), assSingleChoiceImport\fromXML(), assMultipleChoiceImport\fromXML(), assOrderingQuestionImport\fromXML(), and assMatchingQuestionImport\fromXML().

306  : int
307  {
308  if ($size === null) {
309  return $this->object->getThumbSize();
310  }
311 
312  if ($size < $this->object->getMaximumThumbSize()) {
313  return $this->object->getMaximumThumbSize();
314  }
315 
316  if ($size > $this->object->getMaximumThumbSize()) {
317  return $this->object->getMaximumThumbSize();
318  }
319 
320  return $size;
321  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchAdditionalContentEditingModeInformation()

assQuestionImport::fetchAdditionalContentEditingModeInformation (   $qtiItem)
finalprotected

fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_CONTENT_EDITING_MODE_RTE when no or invalid information is given

protected

Returns
string $additionalContentEditingMode

Definition at line 276 of file class.assQuestionImport.php.

References assQuestion\ADDITIONAL_CONTENT_EDITING_MODE_RTE, and ILIAS\Repository\object().

Referenced by assLongMenuImport\fromXML(), assKprimChoiceImport\fromXML(), assFlashQuestionImport\fromXML(), assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assTextSubsetImport\fromXML(), assNumericImport\fromXML(), assMultipleChoiceImport\fromXML(), assClozeTestImport\fromXML(), assFormulaQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assOrderingHorizontalImport\fromXML(), assImagemapQuestionImport\fromXML(), assOrderingQuestionImport\fromXML(), assTextQuestionImport\fromXML(), and assMatchingQuestionImport\fromXML().

276  : string
277  {
278  $additionalContentEditingMode = $qtiItem->getMetadataEntry('additional_cont_edit_mode');
279 
280  if (!$this->object->isValidAdditionalContentEditingMode($additionalContentEditingMode ?? '')) {
281  $additionalContentEditingMode = assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_RTE;
282  }
283 
284  return $additionalContentEditingMode;
285  }
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchIndexFromFeedbackIdent()

assQuestionImport::fetchIndexFromFeedbackIdent (   $feedbackIdent,
  $prefix = 'response_' 
)
protected
Parameters
$feedbackIdent
string$prefix
Returns
int

Definition at line 111 of file class.assQuestionImport.php.

Referenced by assErrorTextImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), and assTextQuestionImport\fromXML().

111  : int
112  {
113  return (int) str_replace($prefix, '', $feedbackIdent);
114  }
+ Here is the caller graph for this function:

◆ fetchLifecycle()

assQuestionImport::fetchLifecycle ( ilQTIItem  $item)
protected
Parameters
ilQTIItem$item
Returns
ilAssQuestionLifecycle

Definition at line 202 of file class.assQuestionImport.php.

References Vendor\Package\$e, ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), and ilQTIItem\getMetadataEntry().

Referenced by addGeneralMetadata().

203  {
204  try {
206  $item->getMetadataEntry('ilias_lifecycle')
207  );
209  try {
210  $lomLifecycle = new ilAssQuestionLomLifecycle(
211  $item->getMetadataEntry('lifecycle')
212  );
213 
215  $lomLifecycle->getMappedIliasLifecycleIdentifer()
216  );
219  }
220  }
221 
222  return $lifecycle;
223  }
getMetadataEntry(string $a_label)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromXML()

assQuestionImport::fromXML ( $item,
  $questionpool_id,
$tst_id,
$tst_object,
$question_counter,
  $import_mapping 
)

Creates a question from a QTI file.

Receives parameters from a QTI parser and creates a valid ILIAS question object

Parameters
ilQtiItem$itemThe QTI item object
integer$questionpool_idThe id of the parent questionpool
integer$tst_idThe id of the parent test if the question is part of a test
object$tst_objectA reference to the parent test object
integer$question_counterA reference to a question counter to count the questions of an imported question pool
array$import_mappingAn array containing references to included ILIAS objects public

Definition at line 180 of file class.assQuestionImport.php.

180  : array
181  {
182  }

◆ getFeedbackAnswerSpecific()

assQuestionImport::getFeedbackAnswerSpecific ( ilQTIItem  $item,
  $prefix = 'response_' 
)
protected
Parameters
ilQTIItem$item
string$prefix
Returns
array

Definition at line 121 of file class.assQuestionImport.php.

Referenced by assErrorTextImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assTextQuestionImport\fromXML(), and assMatchingQuestionImport\fromXML().

121  : array
122  {
123  $feedbacks = array();
124 
125  foreach ($item->itemfeedback as $ifb) {
126  if ($ifb->getIdent() == 'response_allcorrect' || $ifb->getIdent() == 'response_onenotcorrect') {
127  continue;
128  }
129 
130  if ($ifb->getIdent() == $prefix . 'allcorrect' || $ifb->getIdent() == $prefix . 'onenotcorrect') {
131  continue;
132  }
133 
134  if (substr($ifb->getIdent(), 0, strlen($prefix)) != $prefix) {
135  continue;
136  }
137 
138  $ident = $ifb->getIdent();
139 
140  // found a feedback for the identifier
141 
142  if (count($ifb->material)) {
143  foreach ($ifb->material as $material) {
144  $feedbacks[$ident] = $material;
145  }
146  }
147 
148  if ((count($ifb->flow_mat) > 0)) {
149  foreach ($ifb->flow_mat as $fmat) {
150  if (count($fmat->material)) {
151  foreach ($fmat->material as $material) {
152  $feedbacks[$ident] = $material;
153  }
154  }
155  }
156  }
157  }
158 
159  foreach ($feedbacks as $ident => $material) {
160  $m = $this->object->QTIMaterialToString($material);
161  $feedbacks[$ident] = $m;
162  }
163 
164  return $feedbacks;
165  }
+ Here is the caller graph for this function:

◆ getFeedbackGeneric()

assQuestionImport::getFeedbackGeneric (   $item)

Definition at line 52 of file class.assQuestionImport.php.

Referenced by assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assFlashQuestionImport\fromXML(), assFormulaQuestionImport\fromXML(), and assOrderingHorizontalImport\fromXML().

52  : array
53  {
54  $feedbacksgeneric = array();
55  foreach ($item->resprocessing as $resprocessing) {
56  foreach ($resprocessing->respcondition as $respcondition) {
57  foreach ($respcondition->displayfeedback as $feedbackpointer) {
58  if (strlen($feedbackpointer->getLinkrefid())) {
59  foreach ($item->itemfeedback as $ifb) {
60  if (strcmp($ifb->getIdent(), "response_allcorrect") == 0) {
61  // found a feedback for the identifier
62  if (count($ifb->material)) {
63  foreach ($ifb->material as $material) {
64  $feedbacksgeneric[1] = $material;
65  }
66  }
67  if ((count($ifb->flow_mat) > 0)) {
68  foreach ($ifb->flow_mat as $fmat) {
69  if (count($fmat->material)) {
70  foreach ($fmat->material as $material) {
71  $feedbacksgeneric[1] = $material;
72  }
73  }
74  }
75  }
76  } elseif (strcmp($ifb->getIdent(), "response_onenotcorrect") == 0) {
77  // found a feedback for the identifier
78  if (count($ifb->material)) {
79  foreach ($ifb->material as $material) {
80  $feedbacksgeneric[0] = $material;
81  }
82  }
83  if ((count($ifb->flow_mat) > 0)) {
84  foreach ($ifb->flow_mat as $fmat) {
85  if (count($fmat->material)) {
86  foreach ($fmat->material as $material) {
87  $feedbacksgeneric[0] = $material;
88  }
89  }
90  }
91  }
92  }
93  }
94  }
95  }
96  }
97  }
98  // handle the import of media objects in XHTML code
99  foreach ($feedbacksgeneric as $correctness => $material) {
100  $m = $this->object->QTIMaterialToString($material);
101  $feedbacksgeneric[$correctness] = $m;
102  }
103  return $feedbacksgeneric;
104  }
+ Here is the caller graph for this function:

◆ getQplImportArchivDirectory()

assQuestionImport::getQplImportArchivDirectory ( )
protected

◆ getQuestionId()

assQuestionImport::getQuestionId ( )

Definition at line 47 of file class.assQuestionImport.php.

47  : int
48  {
49  return (int) $this->object->getId();
50  }

◆ getTstImportArchivDirectory()

assQuestionImport::getTstImportArchivDirectory ( )
protected

returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir)

Definition at line 236 of file class.assQuestionImport.php.

References ilObjTest\_getImportDirectory(), and ilSession\get().

Referenced by assLongMenuImport\fromXML(), assKprimChoiceImport\fromXML(), assFlashQuestionImport\fromXML(), assFileUploadImport\fromXML(), assErrorTextImport\fromXML(), assOrderingHorizontalImport\fromXML(), assNumericImport\fromXML(), assClozeTestImport\fromXML(), assMultipleChoiceImport\fromXML(), assSingleChoiceImport\fromXML(), assImagemapQuestionImport\fromXML(), assTextSubsetImport\fromXML(), assTextQuestionImport\fromXML(), assOrderingQuestionImport\fromXML(), and assMatchingQuestionImport\fromXML().

236  : string
237  {
238  return ilObjTest::_getImportDirectory() . '/' . ilSession::get("tst_import_subdir");
239  }
static get(string $a_var)
static _getImportDirectory()
Get the import directory location of the test.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importSuggestedSolution()

assQuestionImport::importSuggestedSolution ( int  $question_id,
string  $value = "",
int  $subquestion_index = 0 
)

Definition at line 287 of file class.assQuestionImport.php.

References $type.

291  : void {
292  $type = $this->findSolutionTypeByValue($value);
293  if (!$type) {
294  return;
295  }
296 
297  $repo = $this->getSuggestedSolutionsRepo();
298 
299  $nu_value = $this->object->_resolveInternalLink($value);
300  $solution = $repo->create($question_id, $type)
301  ->withInternalLink($nu_value)
302  ->withImportId($value);
303  $repo->update($solution);
304  }
$type

◆ processNonAbstractedImageReferences()

assQuestionImport::processNonAbstractedImageReferences (   $text,
  $sourceNic 
)
protected

Definition at line 241 of file class.assQuestionImport.php.

References $i, $mobs, ilRTE\_replaceMediaObjectImageSrc(), and ilSession\set().

Referenced by assClozeTestImport\fromXML().

241  : string
242  {
243  $reg = '/<img.*src=".*\\/mm_(\\d+)\\/(.*?)".*>/m';
244  $matches = null;
245 
246  if (preg_match_all($reg, $text, $matches)) {
247  $mobs = array();
248  for ($i = 0, $max = count($matches[1]); $i < $max; $i++) {
249  $mobSrcId = $matches[1][$i];
250  $mobSrcName = $matches[2][$i];
251  $mobSrcLabel = 'il_' . $sourceNic . '_mob_' . $mobSrcId;
252 
253  //if (!is_array(ilSession::get("import_mob_xhtml"))) {
254  // ilSession::set("import_mob_xhtml", array());
255  //}
256 
257  //$_SESSION["import_mob_xhtml"][] = array(
258  $mobs[] = array(
259  "mob" => $mobSrcLabel, "uri" => 'objects/' . $mobSrcLabel . '/' . $mobSrcName
260  );
261  }
262  ilSession::set('import_mob_xhtml', $mobs);
263  }
264 
265  return ilRTE::_replaceMediaObjectImageSrc($text, 0, $sourceNic);
266  }
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...
$mobs
Definition: imgupload.php:70
static set(string $a_var, $a_val)
Set a value.
$i
Definition: metadata.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $object

assQuestionImport::$object

Definition at line 34 of file class.assQuestionImport.php.


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