24 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class.assQuestionImport.php";
50 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
56 $presentation = $item->getPresentation();
57 $duration = $item->getDuration();
63 $feedbacksgeneric = array();
64 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
65 foreach ($presentation->order as $entry)
67 switch ($entry[
"type"])
70 $response = $presentation->response[$entry[
"index"]];
71 $rendertype = $response->getRenderType();
72 switch (strtolower(get_class($rendertype)))
74 case "ilqtirenderfib":
75 $maxchars = $rendertype->getMaxchars();
82 foreach ($item->resprocessing as $resprocessing)
84 foreach ($resprocessing->respcondition as $respcondition)
86 $conditionvar = $respcondition->getConditionvar();
87 foreach ($conditionvar->order as $order)
89 switch ($order[
"field"])
92 $upperlimit = $conditionvar->varlte[$order[
"index"]]->getContent();
95 $lowerlimit = $conditionvar->vargte[$order[
"index"]]->getContent();
99 foreach ($respcondition->setvar as $setvar)
101 $points = $setvar->getContent();
103 if (count($respcondition->displayfeedback))
105 foreach ($respcondition->displayfeedback as $feedbackpointer)
107 if (strlen($feedbackpointer->getLinkrefid()))
109 foreach ($item->itemfeedback as $ifb)
111 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0)
114 if (count($ifb->material))
116 foreach ($ifb->material as $material)
118 $feedbacksgeneric[1] = $material;
121 if ((count($ifb->flow_mat) > 0))
123 foreach ($ifb->flow_mat as $fmat)
125 if (count($fmat->material))
127 foreach ($fmat->material as $material)
129 $feedbacksgeneric[1] = $material;
135 else if (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0)
138 if (count($ifb->material))
140 foreach ($ifb->material as $material)
142 $feedbacksgeneric[0] = $material;
145 if ((count($ifb->flow_mat) > 0))
147 foreach ($ifb->flow_mat as $fmat)
149 if (count($fmat->material))
151 foreach ($fmat->material as $material)
153 $feedbacksgeneric[0] = $material;
166 $this->
object->setTitle($item->getTitle());
167 $this->
object->setNrOfTries($item->getMaxattempts());
168 $this->
object->setComment($item->getComment());
169 $this->
object->setAuthor($item->getAuthor());
170 $this->
object->setOwner($ilUser->getId());
171 $this->
object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
172 $this->
object->setObjId($questionpool_id);
173 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
174 $this->
object->setMaxChars($maxchars);
175 $this->
object->setPoints($points);
176 $this->
object->setLowerLimit($lowerlimit);
177 $this->
object->setUpperLimit($upperlimit);
178 $this->
object->saveToDb();
179 if (count($item->suggested_solutions))
181 foreach ($item->suggested_solutions as $suggested_solution)
183 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
185 $this->
object->saveToDb();
187 foreach ($feedbacksgeneric as $correctness => $material)
189 $m = $this->
object->QTIMaterialToString($material);
190 $feedbacksgeneric[$correctness] = $m;
193 $questiontext = $this->
object->getQuestion();
194 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
196 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
197 include_once
"./Services/RTE/classes/class.ilRTE.php";
198 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
209 $GLOBALS[
'ilLog']->write(__METHOD__.
': import mob from dir: '. $importfile);
213 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
214 foreach ($feedbacksgeneric as $correctness => $material)
216 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
221 foreach ($feedbacksgeneric as $correctness => $material)
225 $this->
object->saveToDb();
228 $q_1_id = $this->
object->getId();
229 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
230 $tst_object->questions[$question_counter++] = $question_id;
231 $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id,
"test" => $question_id);
235 $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(),
"test" => 0);