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();
43 $feedbacksgeneric =
array();
44 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
45 foreach ($presentation->order as $entry)
47 switch ($entry[
"type"])
50 $response = $presentation->response[$entry[
"index"]];
51 $rendertype = $response->getRenderType();
52 switch (strtolower(get_class($rendertype)))
54 case "ilqtirenderfib":
55 $maxchars = $rendertype->getMaxchars();
62 foreach ($item->resprocessing as $resprocessing)
64 foreach ($resprocessing->respcondition as $respcondition)
66 $conditionvar = $respcondition->getConditionvar();
67 foreach ($conditionvar->order as $order)
69 switch ($order[
"field"])
72 $upperlimit = $conditionvar->varlte[$order[
"index"]]->getContent();
75 $lowerlimit = $conditionvar->vargte[$order[
"index"]]->getContent();
79 foreach ($respcondition->setvar as $setvar)
81 $points = $setvar->getContent();
83 if (count($respcondition->displayfeedback))
85 foreach ($respcondition->displayfeedback as $feedbackpointer)
87 if (strlen($feedbackpointer->getLinkrefid()))
89 foreach ($item->itemfeedback as $ifb)
91 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0)
94 if (count($ifb->material))
96 foreach ($ifb->material as $material)
98 $feedbacksgeneric[1] = $material;
101 if ((count($ifb->flow_mat) > 0))
103 foreach ($ifb->flow_mat as $fmat)
105 if (count($fmat->material))
107 foreach ($fmat->material as $material)
109 $feedbacksgeneric[1] = $material;
115 else if (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0)
118 if (count($ifb->material))
120 foreach ($ifb->material as $material)
122 $feedbacksgeneric[0] = $material;
125 if ((count($ifb->flow_mat) > 0))
127 foreach ($ifb->flow_mat as $fmat)
129 if (count($fmat->material))
131 foreach ($fmat->material as $material)
133 $feedbacksgeneric[0] = $material;
147 $this->
object->setTitle($item->getTitle());
148 $this->
object->setNrOfTries($item->getMaxattempts());
149 $this->
object->setComment($item->getComment());
150 $this->
object->setAuthor($item->getAuthor());
151 $this->
object->setOwner($ilUser->getId());
152 $this->
object->setQuestion($this->
object->QTIMaterialToString($item->getQuestiontext()));
153 $this->
object->setObjId($questionpool_id);
155 $this->
object->setMaxChars($maxchars);
156 $this->
object->setPoints($points);
157 $this->
object->setLowerLimit($lowerlimit);
158 $this->
object->setUpperLimit($upperlimit);
160 $this->
object->setAdditionalContentEditingMode(
163 $this->
object->saveToDb();
164 if (count($item->suggested_solutions))
166 foreach ($item->suggested_solutions as $suggested_solution)
168 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
170 $this->
object->saveToDb();
172 foreach ($feedbacksgeneric as $correctness => $material)
174 $m = $this->
object->QTIMaterialToString($material);
175 $feedbacksgeneric[$correctness] = $m;
178 $questiontext = $this->
object->getQuestion();
179 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
181 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
182 include_once
"./Services/RTE/classes/class.ilRTE.php";
183 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
194 $GLOBALS[
'ilLog']->write(__METHOD__.
': import mob from dir: '. $importfile);
198 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
199 foreach ($feedbacksgeneric as $correctness => $material)
201 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
206 foreach ($feedbacksgeneric as $correctness => $material)
208 $this->
object->feedbackOBJ->importGenericFeedback(
212 $this->
object->saveToDb();
215 $q_1_id = $this->
object->getId();
216 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
217 $tst_object->questions[$question_counter++] = $question_id;
218 $import_mapping[$item->getIdent()] =
array(
"pool" => $q_1_id,
"test" => $question_id);
222 $import_mapping[$item->getIdent()] =
array(
"pool" => $this->
object->getId(),
"test" => 0);
Class for numeric question imports.
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
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
Creates a question from a QTI file.
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
Class for question imports.