31 string $importdirectory,
37 int &$question_counter,
49 $feedbacksgeneric = [];
50 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
51 foreach ($presentation->order as $entry) {
52 switch ($entry[
"type"]) {
54 $response = $presentation->response[$entry[
"index"]];
56 switch (strtolower(get_class($rendertype))) {
57 case "ilqtirenderfib":
58 $maxchars = $rendertype->getMaxchars();
65 foreach ($item->resprocessing as $resprocessing) {
66 foreach ($resprocessing->respcondition as $respcondition) {
67 $conditionvar = $respcondition->getConditionvar();
68 foreach ($conditionvar->order as $order) {
69 switch ($order[
"field"]) {
71 $upperlimit = $conditionvar->varlte[$order[
"index"]]->getContent();
74 $lowerlimit = $conditionvar->vargte[$order[
"index"]]->getContent();
78 foreach ($respcondition->setvar as $setvar) {
79 $points = $setvar->getContent();
81 if (count($respcondition->displayfeedback)) {
82 foreach ($respcondition->displayfeedback as $feedbackpointer) {
83 if (strlen($feedbackpointer->getLinkrefid())) {
84 foreach ($item->itemfeedback as $ifb) {
85 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
87 if (count($ifb->material)) {
88 foreach ($ifb->material as $material) {
89 $feedbacksgeneric[1] = $material;
92 if ((count($ifb->flow_mat) > 0)) {
93 foreach ($ifb->flow_mat as $fmat) {
94 if (count($fmat->material)) {
95 foreach ($fmat->material as $material) {
96 $feedbacksgeneric[1] = $material;
101 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
103 if (count($ifb->material)) {
104 foreach ($ifb->material as $material) {
105 $feedbacksgeneric[0] = $material;
108 if ((count($ifb->flow_mat) > 0)) {
109 foreach ($ifb->flow_mat as $fmat) {
110 if (count($fmat->material)) {
111 foreach ($fmat->material as $material) {
112 $feedbacksgeneric[0] = $material;
126 $this->
object->setTitle($item->
getTitle());
128 $this->
object->setComment($item->
getComment());
129 $this->
object->setAuthor($item->
getAuthor());
130 $this->
object->setOwner($user_id);
132 $this->
object->setObjId($questionpool_id);
133 $this->
object->setMaxChars($maxchars);
134 $this->
object->setPoints($points);
135 $this->
object->setLowerLimit($lowerlimit);
136 $this->
object->setUpperLimit($upperlimit);
138 $this->
object->setAdditionalContentEditingMode(
141 $this->
object->saveToDb();
143 foreach ($feedbacksgeneric as $correctness => $material) {
145 $feedbacksgeneric[$correctness] = $m;
148 $questiontext = $this->
object->getQuestion();
151 $importfile = $importdirectory . DIRECTORY_SEPARATOR . $mob[
"uri"];
154 $DIC[
'ilLog']->write(__METHOD__ .
': import mob from dir: ' . $importfile);
158 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
159 foreach ($feedbacksgeneric as $correctness => $material) {
160 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
165 foreach ($feedbacksgeneric as $correctness => $material) {
166 $this->
object->feedbackOBJ->importGenericFeedback(
172 $this->
object->saveToDb();
174 $q_1_id = $this->
object->getId();
175 $question_id = $this->
object->duplicate(
true,
"",
"", -1, $tst_id);
176 $tst_object->questions[$question_counter++] = $question_id;
177 $import_mapping[$item->
getIdent()] = [
"pool" => $q_1_id,
"test" => $question_id];
179 $import_mapping[$item->
getIdent()] = [
"pool" => $this->
object->getId(),
"test" => 0];
181 return $import_mapping;
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fromXML(string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping)
static get(string $a_var)
addGeneralMetadata(ilQTIItem $item)
QTIMaterialToString(ilQTIMaterial $a_material)
Reads an QTI material tag and creates a text or XHTML string.
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
importSuggestedSolutions(int $question_id, array $solution_from_import)
Class for question imports.
static clear(string $a_var)