ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assErrorTextImport Class Reference

Class for error text question imports. More...

+ Inheritance diagram for assErrorTextImport:
+ Collaboration diagram for assErrorTextImport:

Public Member Functions

 fromXML (&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Creates a question from a QTI file. More...
 
- Public Member Functions inherited from assQuestionImport
 __construct ($a_object)
 assQuestionImport constructor More...
 
 getFeedbackGeneric ($item)
 
 fromXML (&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Creates a question from a QTI file. More...
 

Additional Inherited Members

- Data Fields inherited from assQuestionImport
 $object
 
- Protected Member Functions inherited from assQuestionImport
 fetchIndexFromFeedbackIdent ($feedbackIdent, $prefix='response_')
 
 getFeedbackAnswerSpecific (ilQTIItem $item, $prefix='response_')
 
 addGeneralMetadata (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_DEFAULT when no or invalid information is given More...
 

Detailed Description

Class for error text 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 13 of file class.assErrorTextImport.php.

Member Function Documentation

◆ fromXML()

assErrorTextImport::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
object$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 28 of file class.assErrorTextImport.php.

References $_SESSION, $data, $DIC, $ilUser, $index, ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObject\_saveUsage(), assQuestionImport\addGeneralMetadata(), assQuestionImport\fetchAdditionalContentEditingModeInformation(), assQuestionImport\fetchIndexFromFeedbackIdent(), assQuestionImport\getFeedbackAnswerSpecific(), assQuestionImport\getFeedbackGeneric(), assQuestionImport\getQplImportArchivDirectory(), and assQuestionImport\getTstImportArchivDirectory().

29  {
30  global $DIC;
31  $ilUser = $DIC['ilUser'];
32 
33  // empty session variable for imported xhtml mobs
34  unset($_SESSION["import_mob_xhtml"]);
35  $presentation = $item->getPresentation();
36  $duration = $item->getDuration();
37  $now = getdate();
38  $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
39 
40  $feedbacksgeneric = array();
41 
42  $this->addGeneralMetadata($item);
43  $this->object->setTitle($item->getTitle());
44  $this->object->setNrOfTries($item->getMaxattempts());
45  $this->object->setComment($item->getComment());
46  $this->object->setAuthor($item->getAuthor());
47  $this->object->setOwner($ilUser->getId());
48  $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
49  $this->object->setObjId($questionpool_id);
50  $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
51  $this->object->setPointsWrong($item->getMetadataEntry("points_wrong"));
52  $this->object->setErrorText($item->getMetadataEntry("errortext"));
53  $this->object->setTextSize($item->getMetadataEntry("textsize"));
54  $errordata = unserialize($item->getMetadataEntry("errordata"));
55  if (is_array($errordata)) {
56  foreach ($errordata as $data) {
57  $this->object->addErrorData($data[1], $data[0], $data[2]);
58  }
59  }
60  // additional content editing mode information
61  $this->object->setAdditionalContentEditingMode(
63  );
64  $this->object->saveToDb();
65 
66  $feedbacks = $this->getFeedbackAnswerSpecific($item);
67  $feedbacksgeneric = $this->getFeedbackGeneric($item);
68 
69  // handle the import of media objects in XHTML code
70  $questiontext = $this->object->getQuestion();
71  if (is_array($_SESSION["import_mob_xhtml"])) {
72  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
73  include_once "./Services/RTE/classes/class.ilRTE.php";
74  foreach ($_SESSION["import_mob_xhtml"] as $mob) {
75  if ($tst_id > 0) {
76  $importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
77  } else {
78  $importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
79  }
80 
81  global $DIC; /* @var ILIAS\DI\Container $DIC */
82  $DIC['ilLog']->write(__METHOD__ . ': import mob from dir: ' . $importfile);
83 
84  $media_object = &ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, false);
85  ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
86  $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
87  foreach ($feedbacks as $ident => $material) {
88  $feedbacks[$ident] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
89  }
90  foreach ($feedbacksgeneric as $correctness => $material) {
91  $feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
92  }
93  }
94  }
95  $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
96 
97  foreach ($feedbacks as $ident => $material) {
98  $index = $this->fetchIndexFromFeedbackIdent($ident);
99 
100  $this->object->feedbackOBJ->importSpecificAnswerFeedback(
101  $this->object->getId(),
102  0,
103  $index,
105  );
106  }
107  foreach ($feedbacksgeneric as $correctness => $material) {
108  $this->object->feedbackOBJ->importGenericFeedback(
109  $this->object->getId(),
110  $correctness,
112  );
113  }
114 
115  $this->object->saveToDb();
116  if (count($item->suggested_solutions)) {
117  foreach ($item->suggested_solutions as $suggested_solution) {
118  $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
119  }
120  $this->object->saveToDb();
121  }
122  if ($tst_id > 0) {
123  $q_1_id = $this->object->getId();
124  $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
125  $tst_object->questions[$question_counter++] = $question_id;
126  $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
127  } else {
128  $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
129  }
130  }
getFeedbackAnswerSpecific(ilQTIItem $item, $prefix='response_')
addGeneralMetadata(ilQTIItem $item)
$_SESSION["AccountId"]
global $DIC
Definition: saml.php:7
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
getQplImportArchivDirectory()
returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir) ...
$index
Definition: metadata.php:60
static _saveTempFileAsMediaObject($name, $tmp_name, $upload=true)
Create new media object and update page in db and return new media object.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
$ilUser
Definition: imgupload.php:18
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
static _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
fetchIndexFromFeedbackIdent($feedbackIdent, $prefix='response_')
$data
Definition: bench.php:6
+ Here is the call graph for this function:

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