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->setNrOfTries($item->getMaxattempts());
152 $this->
object->setComment($item->getComment());
153 $this->
object->setAuthor($item->getAuthor());
154 $this->
object->setOwner($ilUser->getId());
155 $this->
object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
156 $this->
object->setObjId($questionpool_id);
157 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
158 $this->
object->setPoints($maxpoints);
159 $this->
object->setMaxNumOfChars($maxchars);
160 $textrating = $item->getMetadataEntry(
"textrating");
161 if (strlen($textrating))
163 $this->
object->setTextRating($textrating);
165 $this->
object->matchcondition = (strlen($item->getMetadataEntry(
'matchcondition'))) ? $item->getMetadataEntry(
'matchcondition') : 0;
167 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php';
168 $no_keywords_found=
true;
171 $termscoring = ( is_array($termscoring) ? $termscoring : array() );
172 for ($i = 0; $i < count($termscoring); $i++ )
174 $this->
object->addAnswer($termscoring[$i]->getAnswertext(), $termscoring[$i]->getPoints() );
175 $no_keywords_found=
false;
177 if(count($termscoring))
179 $this->
object->setKeywordRelation($item->getMetadataEntry(
'termrelation'));
182 $keywords = $item->getMetadataEntry(
"keywords");
183 if (strlen($keywords))
185 #$this->object->setKeywords($keywords);
186 $answers = explode(
' ', $keywords);
187 foreach ($answers as $answer)
189 $this->
object->addAnswer($answer, 0);
191 $this->
object->setKeywordRelation(
'one');
192 $no_keywords_found=
false;
194 if($no_keywords_found)
196 $this->
object->setKeywordRelation(
'non');
199 $this->
object->saveToDb();
200 if (count($item->suggested_solutions))
202 foreach ($item->suggested_solutions as $suggested_solution)
204 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
206 $this->
object->saveToDb();
208 foreach ($feedbacksgeneric as $correctness => $material)
210 $m = $this->
object->QTIMaterialToString($material);
211 $feedbacksgeneric[$correctness] = $m;
214 $questiontext = $this->
object->getQuestion();
215 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
217 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
218 include_once
"./Services/RTE/classes/class.ilRTE.php";
219 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
230 $GLOBALS[
'ilLog']->write(__METHOD__.
': import mob from dir: '. $importfile);
234 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
235 foreach ($feedbacksgeneric as $correctness => $material)
237 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
242 foreach ($feedbacksgeneric as $correctness => $material)
246 $this->
object->saveToDb();
249 $q_1_id = $this->
object->getId();
250 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
251 $tst_object->questions[$question_counter++] = $question_id;
252 $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id,
"test" => $question_id);
256 $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(),
"test" => 0);
262 $termScoringString = $item->getMetadataEntry(
'termscoring');
264 if( !strlen($termScoringString) )
269 $termScoring = unserialize($termScoringString);
271 if( is_array($termScoring) )
276 $termScoringString = base64_decode($termScoringString);
277 $termScoring = unserialize($termScoringString);
279 if( is_array($termScoring) )