43 public function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, $import_mapping): array
46 $ilUser = $DIC[
'ilUser'];
51 $presentation = $item->getPresentation();
57 $feedbacksgeneric = [];
58 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
59 foreach ($presentation->order as $entry) {
60 switch ($entry[
"type"]) {
62 $response = $presentation->response[$entry[
"index"]];
64 switch (strtolower(get_class($rendertype))) {
65 case "ilqtirenderfib":
66 $maxchars = $rendertype->getMaxchars();
73 foreach ($item->resprocessing as $resprocessing) {
74 foreach ($resprocessing->respcondition as $respcondition) {
75 $conditionvar = $respcondition->getConditionvar();
76 foreach ($conditionvar->order as $order) {
77 switch ($order[
"field"]) {
79 $upperlimit = $conditionvar->varlte[$order[
"index"]]->getContent();
82 $lowerlimit = $conditionvar->vargte[$order[
"index"]]->getContent();
86 foreach ($respcondition->setvar as $setvar) {
87 $points = $setvar->getContent();
89 if (count($respcondition->displayfeedback)) {
90 foreach ($respcondition->displayfeedback as $feedbackpointer) {
91 if (strlen($feedbackpointer->getLinkrefid())) {
92 foreach ($item->itemfeedback as $ifb) {
93 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
95 if (count($ifb->material)) {
96 foreach ($ifb->material as $material) {
97 $feedbacksgeneric[1] = $material;
100 if ((count($ifb->flow_mat) > 0)) {
101 foreach ($ifb->flow_mat as $fmat) {
102 if (count($fmat->material)) {
103 foreach ($fmat->material as $material) {
104 $feedbacksgeneric[1] = $material;
109 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
111 if (count($ifb->material)) {
112 foreach ($ifb->material as $material) {
113 $feedbacksgeneric[0] = $material;
116 if ((count($ifb->flow_mat) > 0)) {
117 foreach ($ifb->flow_mat as $fmat) {
118 if (count($fmat->material)) {
119 foreach ($fmat->material as $material) {
120 $feedbacksgeneric[0] = $material;
134 $this->
object->setTitle($item->getTitle());
135 $this->
object->setNrOfTries((
int) $item->getMaxattempts());
136 $this->
object->setComment($item->getComment());
137 $this->
object->setAuthor($item->getAuthor());
138 $this->
object->setOwner($ilUser->getId());
140 $this->
object->setObjId($questionpool_id);
141 $this->
object->setMaxChars($maxchars);
142 $this->
object->setPoints($points);
143 $this->
object->setLowerLimit($lowerlimit);
144 $this->
object->setUpperLimit($upperlimit);
146 $this->
object->setAdditionalContentEditingMode(
149 $this->
object->saveToDb();
151 foreach ($feedbacksgeneric as $correctness => $material) {
153 $feedbacksgeneric[$correctness] = $m;
156 $questiontext = $this->
object->getQuestion();
166 $DIC[
'ilLog']->write(__METHOD__ .
': import mob from dir: ' . $importfile);
170 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
171 foreach ($feedbacksgeneric as $correctness => $material) {
172 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
177 foreach ($feedbacksgeneric as $correctness => $material) {
178 $this->
object->feedbackOBJ->importGenericFeedback(
184 $this->
object->saveToDb();
186 $q_1_id = $this->
object->getId();
187 $question_id = $this->
object->duplicate(
true,
"",
"", -1, $tst_id);
188 $tst_object->questions[$question_counter++] = $question_id;
189 $import_mapping[$item->getIdent()] = [
"pool" => $q_1_id,
"test" => $question_id];
191 $import_mapping[$item->getIdent()] = [
"pool" => $this->
object->getId(),
"test" => 0];
193 return $import_mapping;
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static get(string $a_var)
addGeneralMetadata(ilQTIItem $item)
QTIMaterialToString(ilQTIMaterial $a_material)
Reads an QTI material tag and creates a text or XHTML string.
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, $import_mapping)
Creates a question from a QTI file.
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) ...
importSuggestedSolutions(int $question_id, array $solution_from_import)
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
Class for question imports.
static clear(string $a_var)