Creates a question from a QTI file.
36 $presentation = $item->getPresentation();
41 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
43 foreach ($presentation->order as $entry)
45 switch ($entry[
"type"])
48 $response = $presentation->response[$entry[
"index"]];
51 array_push($idents, $response->getIdent());
57 $feedbacksgeneric =
array();
58 foreach ($item->resprocessing as $resprocessing)
60 foreach ($resprocessing->respcondition as $respcondition)
64 $conditionvar = $respcondition->getConditionvar();
65 foreach ($conditionvar->order as $order)
67 switch ($order[
"field"])
70 $respident = $conditionvar->varsubset[$order[
"index"]]->getRespident();
71 $content = $conditionvar->varsubset[$order[
"index"]]->getContent();
72 if (!is_array($responses[$respident])) $responses[$respident] =
array();
73 $vars = explode(
",", $content);
74 foreach ($vars as $var)
76 array_push($responses[$respident],
array(
"solution" => $var,
"points" =>
""));
81 foreach ($respcondition->setvar as $setvar)
83 if ((strcmp($setvar->getVarname(),
"matches") == 0) && ($setvar->getAction() ==
ACTION_ADD))
85 foreach ($responses[$respident] as $idx => $solutionarray)
87 if (strlen($solutionarray[
"points"] == 0))
89 $responses[$respident][$idx][
"points"] = $setvar->getContent();
94 foreach ($resprocessing->respcondition as $respcondition)
96 foreach ($respcondition->displayfeedback as $feedbackpointer)
98 if (strlen($feedbackpointer->getLinkrefid()))
100 foreach ($item->itemfeedback as $ifb)
102 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0)
105 if (count($ifb->material))
107 foreach ($ifb->material as $material)
109 $feedbacksgeneric[1] = $material;
112 if ((count($ifb->flow_mat) > 0))
114 foreach ($ifb->flow_mat as $fmat)
116 if (count($fmat->material))
118 foreach ($fmat->material as $material)
120 $feedbacksgeneric[1] = $material;
126 else if (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0)
129 if (count($ifb->material))
131 foreach ($ifb->material as $material)
133 $feedbacksgeneric[0] = $material;
136 if ((count($ifb->flow_mat) > 0))
138 foreach ($ifb->flow_mat as $fmat)
140 if (count($fmat->material))
142 foreach ($fmat->material as $material)
144 $feedbacksgeneric[0] = $material;
157 $this->
object->setTitle($item->getTitle());
158 $this->
object->setNrOfTries($item->getMaxattempts());
159 $this->
object->setComment($item->getComment());
160 $this->
object->setAuthor($item->getAuthor());
161 $this->
object->setOwner($ilUser->getId());
162 $this->
object->setQuestion($this->
object->QTIMaterialToString($item->getQuestiontext()));
163 $this->
object->setObjId($questionpool_id);
165 $textrating = $item->getMetadataEntry(
"textrating");
166 if (strlen($textrating) == 0) $textrating =
"ci";
167 $this->
object->setTextRating($textrating);
168 $this->
object->setCorrectAnswers($item->getMetadataEntry(
"correctanswers"));
169 $response = current($responses);
171 if (is_array($response))
173 foreach ($response as $answer)
175 $this->
object->addAnswer($answer[
"solution"], $answer[
"points"],
$counter);
180 $this->
object->setAdditionalContentEditingMode(
183 $this->
object->saveToDb();
184 if (count($item->suggested_solutions))
186 foreach ($item->suggested_solutions as $suggested_solution)
188 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
190 $this->
object->saveToDb();
192 foreach ($feedbacksgeneric as $correctness => $material)
194 $m = $this->
object->QTIMaterialToString($material);
195 $feedbacksgeneric[$correctness] = $m;
198 $questiontext = $this->
object->getQuestion();
199 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
201 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
202 include_once
"./Services/RTE/classes/class.ilRTE.php";
203 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
214 $GLOBALS[
'ilLog']->write(__METHOD__.
': import mob from dir: '. $importfile);
218 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
219 foreach ($feedbacksgeneric as $correctness => $material)
221 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
226 foreach ($feedbacksgeneric as $correctness => $material)
228 $this->
object->feedbackOBJ->importGenericFeedback(
232 $this->
object->saveToDb();
235 $q_1_id = $this->
object->getId();
236 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
237 $tst_object->questions[$question_counter++] = $question_id;
238 $import_mapping[$item->getIdent()] =
array(
"pool" => $q_1_id,
"test" => $question_id);
242 $import_mapping[$item->getIdent()] =
array(
"pool" => $this->
object->getId(),
"test" => 0);
addGeneralMetadata(ilQTIItem $item)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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...
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...