38 string $importdirectory,
44 int &$question_counter,
53 foreach ($presentation->order as $entry) {
54 switch ($entry[
"type"]) {
56 $response = $presentation->response[$entry[
"index"]];
58 switch (strtolower(get_class($rendertype))) {
59 case "ilqtirenderfib":
60 $maxchars = $rendertype->getMaxchars();
67 $feedbacksgeneric = [];
68 foreach ($item->resprocessing as $resprocessing) {
69 $outcomes = $resprocessing->getOutcomes();
70 foreach ($outcomes->decvar as $decvar) {
71 $maxpoints = $decvar->getMaxvalue();
74 foreach ($resprocessing->respcondition as $respcondition) {
75 foreach ($respcondition->displayfeedback as $feedbackpointer) {
76 if (strlen($feedbackpointer->getLinkrefid())) {
77 foreach ($item->itemfeedback as $ifb) {
78 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
80 if (count($ifb->material)) {
81 foreach ($ifb->material as $material) {
82 $feedbacksgeneric[1] = $material;
85 if ((count($ifb->flow_mat) > 0)) {
86 foreach ($ifb->flow_mat as $fmat) {
87 if (count($fmat->material)) {
88 foreach ($fmat->material as $material) {
89 $feedbacksgeneric[1] = $material;
94 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
96 if (count($ifb->material)) {
97 foreach ($ifb->material as $material) {
98 $feedbacksgeneric[0] = $material;
101 if ((count($ifb->flow_mat) > 0)) {
102 foreach ($ifb->flow_mat as $fmat) {
103 if (count($fmat->material)) {
104 foreach ($fmat->material as $material) {
105 $feedbacksgeneric[0] = $material;
117 $this->
object->setTitle($item->
getTitle());
119 $this->
object->setComment($item->
getComment());
120 $this->
object->setAuthor($item->
getAuthor());
121 $this->
object->setOwner($user_id);
123 $this->
object->setObjId($questionpool_id);
124 $this->
object->setPoints($maxpoints);
125 $this->
object->setMaxNumOfChars($maxchars ?? 0);
126 $this->
object->setWordCounterEnabled((
bool) $item->
getMetadataEntry(
'wordcounter'));
128 if (strlen($textrating)) {
129 $this->
object->setTextRating($textrating);
133 $no_keywords_found =
true;
138 for ($i = 0, $iMax = count($termscoring); $i < $iMax; $i++) {
139 $this->
object->addAnswer($termscoring[$i]->getAnswertext(), $termscoring[$i]->getPoints());
140 $no_keywords_found =
false;
149 if ($keywords !==
null) {
150 $answers = explode(
' ', $keywords);
151 foreach ($answers as $answer) {
152 $this->
object->addAnswer($answer, 0);
154 $this->
object->setKeywordRelation(
'one');
155 $no_keywords_found =
false;
157 if ($no_keywords_found) {
158 $this->
object->setKeywordRelation(
'non');
162 $this->
object->setAdditionalContentEditingMode(
165 $this->
object->saveToDb();
167 foreach ($feedbacksgeneric as $correctness => $material) {
169 $feedbacksgeneric[$correctness] = $m;
172 $questiontext = $this->
object->getQuestion();
178 $importfile = $importdirectory . DIRECTORY_SEPARATOR . $mob[
"uri"];
181 $DIC[
'ilLog']->info(
'import mob from dir: ' . $importfile);
185 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
186 foreach ($feedbacks as $ident => $material) {
187 $feedbacks[$ident] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
189 foreach ($feedbacksgeneric as $correctness => $material) {
190 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
195 foreach ($feedbacks as $ident => $material) {
198 $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
205 foreach ($feedbacksgeneric as $correctness => $material) {
206 $this->
object->feedbackOBJ->importGenericFeedback(
212 $this->
object->saveToDb();
219 return $import_mapping;
226 if (!strlen($termScoringString)) {
230 $termScoring = @unserialize($termScoringString, [
'allowed_classes' => [ASS_AnswerMultipleResponseImage::class]]);
232 if (is_array($termScoring)) {
236 $termScoringString = base64_decode($termScoringString);
237 $termScoring = unserialize($termScoringString, [
'allowed_classes' => [ASS_AnswerMultipleResponseImage::class]]);
239 if (is_array($termScoring)) {
Class for question imports.
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
getFeedbackAnswerSpecific(ilQTIItem $item, $prefix='response_')
addQuestionToParentObjectAndBuildMappingEntry(int $questionpool_id, ?int $tst_id, int &$question_counter, ?ilObjTest &$tst_object)
QTIMaterialToString(ilQTIMaterial $a_material)
Reads an QTI material tag and creates a text or XHTML string.
addGeneralMetadata(ilQTIItem $item)
fetchIndexFromFeedbackIdent($feedbackIdent, $prefix='response_')
importSuggestedSolutions(int $question_id, array $solution_from_import)
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)
Class ilObject Basic functions for all objects.
getMetadataEntry(string $a_label)
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...
static get(string $a_var)