Creates a question from a QTI file.
36 $presentation = $item->getPresentation();
37 $duration = $item->getDuration();
45 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
47 foreach ($presentation->order as $entry)
49 switch ($entry[
"type"])
52 $material = $presentation->material[$entry[
"index"]];
53 for ($i = 0; $i < $material->getMaterialCount(); $i++)
55 $mat = $material->getMaterial($i);
56 if (strcmp($mat[
"type"],
"mattext") == 0)
58 $mattext = $mat[
"material"];
59 if ((strlen($mattext->getLabel()) == 0) && (strlen($this->object->QTIMaterialToString($item->getQuestiontext())) == 0))
61 $item->setQuestiontext($mattext->getContent());
63 if (strcmp($mattext->getLabel(),
"points") == 0)
65 $maxpoints = $mattext->getContent();
67 else if (strcmp($mattext->getLabel(),
"java_code") == 0)
69 $javacode = $mattext->getContent();
71 else if (strcmp($mattext->getLabel(),
"java_codebase") == 0)
73 $javacodebase = $mattext->getContent();
75 else if (strcmp($mattext->getLabel(),
"java_archive") == 0)
77 $javaarchive = $mattext->getContent();
79 else if (strlen($mattext->getLabel()) > 0)
81 array_push($params, array(
"key" => $mattext->getLabel(),
"value" => $mattext->getContent()));
84 elseif (strcmp($mat[
"type"],
"matapplet") == 0)
86 $applet = $mat[
"material"];
93 $feedbacksgeneric = array();
94 foreach ($item->resprocessing as $resprocessing)
96 foreach ($resprocessing->respcondition as $respcondition)
98 foreach ($respcondition->displayfeedback as $feedbackpointer)
100 if (strlen($feedbackpointer->getLinkrefid()))
102 foreach ($item->itemfeedback as $ifb)
104 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0)
107 if (count($ifb->material))
109 foreach ($ifb->material as $material)
111 $feedbacksgeneric[1] = $material;
114 if ((count($ifb->flow_mat) > 0))
116 foreach ($ifb->flow_mat as $fmat)
118 if (count($fmat->material))
120 foreach ($fmat->material as $material)
122 $feedbacksgeneric[1] = $material;
128 else if (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0)
131 if (count($ifb->material))
133 foreach ($ifb->material as $material)
135 $feedbacksgeneric[0] = $material;
138 if ((count($ifb->flow_mat) > 0))
140 foreach ($ifb->flow_mat as $fmat)
142 if (count($fmat->material))
144 foreach ($fmat->material as $material)
146 $feedbacksgeneric[0] = $material;
159 $this->
object->setTitle($item->getTitle());
160 $this->
object->setNrOfTries($item->getMaxattempts());
161 $this->
object->setComment($item->getComment());
162 $this->
object->setAuthor($item->getAuthor());
163 $this->
object->setOwner($ilUser->getId());
164 $this->
object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
165 $this->
object->setObjId($questionpool_id);
166 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
167 $this->
object->setJavaAppletFilename($applet->getUri());
168 $this->
object->setJavaWidth($applet->getWidth());
169 $this->
object->setJavaHeight($applet->getHeight());
170 $this->
object->setJavaCode($javacode);
171 $this->
object->setJavaCodebase($javacodebase);
172 $this->
object->setJavaArchive($javaarchive);
173 $this->
object->setPoints($maxpoints);
174 foreach ($params as $pair)
176 $this->
object->addParameter($pair[
"key"], $pair[
"value"]);
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 $javaapplet =& base64_decode($applet->getContent());
192 $javapath = $this->
object->getJavaPath();
193 if (!file_exists($javapath))
195 include_once
"./Services/Utilities/classes/class.ilUtil.php";
198 $javapath .= $this->
object->getJavaAppletFilename();
199 $fh = fopen($javapath,
"wb");
208 $javafile = fwrite($fh, $javaapplet);
212 foreach ($feedbacksgeneric as $correctness => $material)
214 $m = $this->
object->QTIMaterialToString($material);
215 $feedbacksgeneric[$correctness] = $m;
217 $questiontext = $this->
object->getQuestion();
218 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
220 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
221 include_once
"./Services/RTE/classes/class.ilRTE.php";
222 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
233 $GLOBALS[
'ilLog']->write(__METHOD__.
': import mob from dir: '. $importfile);
237 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
238 foreach ($feedbacksgeneric as $correctness => $material)
240 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
245 foreach ($feedbacksgeneric as $correctness => $material)
247 $this->
object->feedbackOBJ->importGenericFeedback(
251 $this->
object->saveToDb();
254 $q_1_id = $this->
object->getId();
255 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
256 $tst_object->questions[$question_counter++] = $question_id;
257 $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id,
"test" => $question_id);
261 $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(),
"test" => 0);
static makeDirParents($a_dir)
Create a new directory and all parent directories.
addGeneralMetadata(ilQTIItem $item)
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) ...
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
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) ...