36 string $importdirectory,
42 int &$question_counter,
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 $feedbacksgeneric = [];
66 foreach ($item->resprocessing as $resprocessing) {
67 $outcomes = $resprocessing->getOutcomes();
68 foreach ($outcomes->decvar as $decvar) {
69 $maxpoints = $decvar->getMaxvalue();
72 foreach ($resprocessing->respcondition as $respcondition) {
73 foreach ($respcondition->displayfeedback as $feedbackpointer) {
74 if (strlen($feedbackpointer->getLinkrefid())) {
75 foreach ($item->itemfeedback as $ifb) {
76 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
78 if (count($ifb->material)) {
79 foreach ($ifb->material as $material) {
80 $feedbacksgeneric[1] = $material;
83 if ((count($ifb->flow_mat) > 0)) {
84 foreach ($ifb->flow_mat as $fmat) {
85 if (count($fmat->material)) {
86 foreach ($fmat->material as $material) {
87 $feedbacksgeneric[1] = $material;
92 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
94 if (count($ifb->material)) {
95 foreach ($ifb->material as $material) {
96 $feedbacksgeneric[0] = $material;
99 if ((count($ifb->flow_mat) > 0)) {
100 foreach ($ifb->flow_mat as $fmat) {
101 if (count($fmat->material)) {
102 foreach ($fmat->material as $material) {
103 $feedbacksgeneric[0] = $material;
115 $this->
object->setTitle($item->
getTitle());
117 $this->
object->setComment($item->
getComment());
118 $this->
object->setAuthor($item->
getAuthor());
119 $this->
object->setOwner($user_id);
121 $this->
object->setObjId($questionpool_id);
122 $this->
object->setPoints($maxpoints);
123 $this->
object->setMaxNumOfChars($maxchars ?? 0);
124 $this->
object->setWordCounterEnabled((
bool) $item->
getMetadataEntry(
'wordcounter'));
126 if (strlen($textrating)) {
127 $this->
object->setTextRating($textrating);
131 $no_keywords_found =
true;
136 for ($i = 0, $iMax = count($termscoring); $i < $iMax; $i++) {
137 $this->
object->addAnswer($termscoring[$i]->getAnswertext(), $termscoring[$i]->getPoints());
138 $no_keywords_found =
false;
147 if ($keywords !==
null) {
148 $answers = explode(
' ', $keywords);
149 foreach ($answers as $answer) {
150 $this->
object->addAnswer($answer, 0);
152 $this->
object->setKeywordRelation(
'one');
153 $no_keywords_found =
false;
155 if ($no_keywords_found) {
156 $this->
object->setKeywordRelation(
'non');
160 $this->
object->setAdditionalContentEditingMode(
163 $this->
object->saveToDb();
165 foreach ($feedbacksgeneric as $correctness => $material) {
167 $feedbacksgeneric[$correctness] = $m;
170 $questiontext = $this->
object->getQuestion();
176 $importfile = $importdirectory . DIRECTORY_SEPARATOR . $mob[
"uri"];
179 $DIC[
'ilLog']->write(__METHOD__ .
': import mob from dir: ' . $importfile);
183 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
184 foreach ($feedbacks as $ident => $material) {
185 $feedbacks[$ident] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
187 foreach ($feedbacksgeneric as $correctness => $material) {
188 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
193 foreach ($feedbacks as $ident => $material) {
196 $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
203 foreach ($feedbacksgeneric as $correctness => $material) {
204 $this->
object->feedbackOBJ->importGenericFeedback(
210 $this->
object->saveToDb();
212 $q_1_id = $this->
object->getId();
213 $question_id = $this->
object->duplicate(
true,
"",
"", -1, $tst_id);
214 $tst_object->questions[$question_counter++] = $question_id;
215 $import_mapping[$item->
getIdent()] = [
"pool" => $q_1_id,
"test" => $question_id];
217 $import_mapping[$item->
getIdent()] = [
"pool" => $this->
object->getId(),
"test" => 0];
219 return $import_mapping;
224 $termScoringString = $item->getMetadataEntry(
'termscoring');
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)) {
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)
getFeedbackAnswerSpecific(ilQTIItem $item, $prefix='response_')
addGeneralMetadata(ilQTIItem $item)
QTIMaterialToString(ilQTIMaterial $a_material)
Reads an QTI material tag and creates a text or XHTML string.
getMetadataEntry(string $a_label)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
fromXML(string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping)
importSuggestedSolutions(int $question_id, array $solution_from_import)
Class for question imports.
static clear(string $a_var)
fetchIndexFromFeedbackIdent($feedbackIdent, $prefix='response_')