4 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class.assQuestionImport.php";
30 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
36 $presentation = $item->getPresentation();
37 $duration = $item->getDuration();
41 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
42 foreach ($presentation->order as $entry)
44 switch ($entry[
"type"])
47 $response = $presentation->response[$entry[
"index"]];
48 $rendertype = $response->getRenderType();
49 switch (strtolower(get_class($rendertype)))
51 case "ilqtirenderfib":
52 $maxchars = $rendertype->getMaxchars();
59 $feedbacksgeneric = array();
60 foreach ($item->resprocessing as $resprocessing)
62 $outcomes = $resprocessing->getOutcomes();
63 foreach ($outcomes->decvar as $decvar)
65 $maxpoints = $decvar->getMaxvalue();
68 foreach ($resprocessing->respcondition as $respcondition)
70 foreach ($respcondition->displayfeedback as $feedbackpointer)
72 if (strlen($feedbackpointer->getLinkrefid()))
74 foreach ($item->itemfeedback as $ifb)
76 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0)
79 if (count($ifb->material))
81 foreach ($ifb->material as $material)
83 $feedbacksgeneric[1] = $material;
86 if ((count($ifb->flow_mat) > 0))
88 foreach ($ifb->flow_mat as $fmat)
90 if (count($fmat->material))
92 foreach ($fmat->material as $material)
94 $feedbacksgeneric[1] = $material;
100 else if (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0)
103 if (count($ifb->material))
105 foreach ($ifb->material as $material)
107 $feedbacksgeneric[0] = $material;
110 if ((count($ifb->flow_mat) > 0))
112 foreach ($ifb->flow_mat as $fmat)
114 if (count($fmat->material))
116 foreach ($fmat->material as $material)
118 $feedbacksgeneric[0] = $material;
130 $this->
object->setTitle($item->getTitle());
131 $this->
object->setNrOfTries($item->getMaxattempts());
132 $this->
object->setComment($item->getComment());
133 $this->
object->setAuthor($item->getAuthor());
134 $this->
object->setOwner($ilUser->getId());
135 $this->
object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
136 $this->
object->setObjId($questionpool_id);
137 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
138 $this->
object->setPoints($maxpoints);
139 $this->
object->setMaxNumOfChars($maxchars);
140 $textrating = $item->getMetadataEntry(
"textrating");
141 if (strlen($textrating))
143 $this->
object->setTextRating($textrating);
145 $this->
object->matchcondition = (strlen($item->getMetadataEntry(
'matchcondition'))) ? $item->getMetadataEntry(
'matchcondition') : 0;
147 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php';
148 $no_keywords_found=
true;
151 for ($i = 0; $i < count($termscoring); $i++ )
153 $this->
object->addAnswer($termscoring[$i]->getAnswertext(), $termscoring[$i]->getPoints() );
154 $no_keywords_found=
false;
156 if(count($termscoring))
158 $this->
object->setKeywordRelation($item->getMetadataEntry(
'termrelation'));
161 $keywords = $item->getMetadataEntry(
"keywords");
162 if (strlen($keywords))
164 #$this->object->setKeywords($keywords); 165 $answers = explode(
' ', $keywords);
166 foreach ($answers as $answer)
168 $this->
object->addAnswer($answer, 0);
170 $this->
object->setKeywordRelation(
'one');
171 $no_keywords_found=
false;
173 if($no_keywords_found)
175 $this->
object->setKeywordRelation(
'non');
179 $this->
object->setAdditionalContentEditingMode(
182 $this->
object->saveToDb();
183 if (count($item->suggested_solutions))
185 foreach ($item->suggested_solutions as $suggested_solution)
187 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
189 $this->
object->saveToDb();
191 foreach ($feedbacksgeneric as $correctness => $material)
193 $m = $this->
object->QTIMaterialToString($material);
194 $feedbacksgeneric[$correctness] = $m;
197 $questiontext = $this->
object->getQuestion();
198 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
200 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
201 include_once
"./Services/RTE/classes/class.ilRTE.php";
202 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
213 $GLOBALS[
'ilLog']->write(__METHOD__.
': import mob from dir: '. $importfile);
217 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
218 foreach ($feedbacksgeneric as $correctness => $material)
220 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
225 foreach ($feedbacksgeneric as $correctness => $material)
227 $this->
object->feedbackOBJ->importGenericFeedback(
231 $this->
object->saveToDb();
234 $q_1_id = $this->
object->getId();
235 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
236 $tst_object->questions[$question_counter++] = $question_id;
237 $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id,
"test" => $question_id);
241 $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(),
"test" => 0);
247 $termScoringString = $item->getMetadataEntry(
'termscoring');
249 if( !strlen($termScoringString) )
254 $termScoring = unserialize($termScoringString);
256 if( is_array($termScoring) )
261 $termScoringString = base64_decode($termScoringString);
262 $termScoring = unserialize($termScoringString);
264 if( is_array($termScoring) )
addGeneralMetadata(ilQTIItem $item)
Class for essay question imports.
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) ...
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
Creates a question from a QTI file.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
Class for question imports.