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();
61 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
62 foreach ($presentation->order as $entry)
64 switch ($entry[
"type"])
67 $response = $presentation->response[$entry[
"index"]];
68 $rendertype = $response->getRenderType();
69 switch (strtolower(get_class($rendertype)))
71 case "ilqtirenderfib":
72 $maxchars = $rendertype->getMaxchars();
79 $feedbacksgeneric = array();
80 foreach ($item->resprocessing as $resprocessing)
82 $outcomes = $resprocessing->getOutcomes();
83 foreach ($outcomes->decvar as $decvar)
85 $maxpoints = $decvar->getMaxvalue();
88 foreach ($resprocessing->respcondition as $respcondition)
90 foreach ($respcondition->displayfeedback as $feedbackpointer)
92 if (strlen($feedbackpointer->getLinkrefid()))
94 foreach ($item->itemfeedback as $ifb)
96 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0)
99 if (count($ifb->material))
101 foreach ($ifb->material as $material)
103 $feedbacksgeneric[1] = $material;
106 if ((count($ifb->flow_mat) > 0))
108 foreach ($ifb->flow_mat as $fmat)
110 if (count($fmat->material))
112 foreach ($fmat->material as $material)
114 $feedbacksgeneric[1] = $material;
120 else if (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0)
123 if (count($ifb->material))
125 foreach ($ifb->material as $material)
127 $feedbacksgeneric[0] = $material;
130 if ((count($ifb->flow_mat) > 0))
132 foreach ($ifb->flow_mat as $fmat)
134 if (count($fmat->material))
136 foreach ($fmat->material as $material)
138 $feedbacksgeneric[0] = $material;
150 $this->
object->setTitle($item->getTitle());
151 $this->
object->setExternalID($item->getMetadataEntry(
"externalID"));
152 $this->
object->setNrOfTries($item->getMaxattempts());
153 $this->
object->setComment($item->getComment());
154 $this->
object->setAuthor($item->getAuthor());
155 $this->
object->setOwner($ilUser->getId());
156 $this->
object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
157 $this->
object->setObjId($questionpool_id);
158 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
159 $this->
object->setPoints($maxpoints);
160 $this->
object->setMaxNumOfChars($maxchars);
161 $textrating = $item->getMetadataEntry(
"textrating");
162 if (strlen($textrating))
164 $this->
object->setTextRating($textrating);
166 $this->
object->matchcondition = (strlen($item->getMetadataEntry(
'matchcondition'))) ? $item->getMetadataEntry(
'matchcondition') : 0;
167 $keywords = $item->getMetadataEntry(
"keywords");
168 if (strlen($keywords))
170 $this->
object->setKeywords($keywords);
172 $this->
object->saveToDb();
173 if (count($item->suggested_solutions))
175 foreach ($item->suggested_solutions as $suggested_solution)
177 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
179 $this->
object->saveToDb();
181 foreach ($feedbacksgeneric as $correctness => $material)
183 $m = $this->
object->QTIMaterialToString($material);
184 $feedbacksgeneric[$correctness] = $m;
187 $questiontext = $this->
object->getQuestion();
188 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
190 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
191 include_once
"./Services/RTE/classes/class.ilRTE.php";
192 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
196 include_once
"./Modules/Test/classes/class.ilObjTest.php";
201 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
206 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
207 foreach ($feedbacksgeneric as $correctness => $material)
209 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
214 foreach ($feedbacksgeneric as $correctness => $material)
218 $this->
object->saveToDb();
221 $q_1_id = $this->
object->getId();
222 $question_id = $this->
object->duplicate(
true);
223 $tst_object->questions[$question_counter++] = $question_id;
224 $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id,
"test" => $question_id);
228 $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(),
"test" => 0);