44 : array {
45
47
49 $shuffle = 0;
50 $foundimage = false;
51 $answers = [];
53
54 foreach ($presentation->order as $entry) {
55 switch ($entry['type']) {
56 case 'response':
57 $response = $presentation->response[$entry[
"index"]];
61 } elseif (
$response->getIdent() ===
'OQNP') {
63 } elseif (
$response->getIdent() ===
'OQNT') {
65 } elseif (
$response->getIdent() ===
'OQT') {
67 }
68
70 switch (get_class($rendertype)) {
71 case ilQTIRenderChoice::class:
72 $shuffle = $rendertype->getShuffle();
73 $answerorder = 0;
74 foreach ($rendertype->response_labels as $response_label) {
75 $ident = $response_label->getIdent();
76 $answertext = '';
77 $answerimage = [];
78 $answerdepth = 0;
79 foreach ($response_label->material as $mat) {
80 for ($m = 0; $m < $mat->getMaterialCount(); $m++) {
81 $foundmat = $mat->getMaterial($m);
82
83 if ($foundmat[
'material']->
getLabel() ===
'answerdepth') {
84 $answerdepth = $foundmat['material']->getContent();
85 }
86 if ($foundmat['type'] === 'mattext'
87 && $foundmat[
'material']->
getLabel() !==
'answerdepth') {
88 $answertext .= $foundmat['material']->getContent();
89 }
90 if ($foundmat['type'] === 'matimage'
91 && $foundmat[
'material']->
getLabel() !==
'answerdepth') {
92 $foundimage = true;
93 $answerimage = [
94 'imagetype' => $foundmat['material']->getImageType(),
95 'label' => $foundmat['material']->getLabel(),
96 'content' => $foundmat['material']->getContent()
97 ];
98 }
99 }
100 }
101 $answers[$answerorder] = [
102 'ident' => $ident,
103 'answertext' => $answertext,
104 'answerimage' => $answerimage,
105 'points' => 0,
106 'answerorder' => $answerorder,
107 'answerdepth' => $answerdepth,
108 'correctness' => '',
109 'action' => ''
110 ];
111 $answerorder++;
112 }
113 break;
114 }
115 break;
116 }
117 }
118
119 $feedbacksgeneric = [];
120 foreach ($item->resprocessing as $resprocessing) {
121 foreach ($resprocessing->respcondition as $respcondition) {
122 $ident = '';
123 $correctness = 1;
124 $conditionvar = $respcondition->getConditionvar();
125 foreach ($conditionvar->order as $order) {
126 switch ($order['field']) {
127 case "arr_not":
128 $correctness = 0;
129 break;
130 case "varequal":
131 $ident = $conditionvar->varequal[$order['index']]->getContent();
132 $orderindex = $conditionvar->varequal[$order['index']]->getIndex();
133 break;
134 }
135 }
136 foreach ($respcondition->setvar as $setvar) {
137 if ($ident !== '') {
138 $answers[$ident]['solutionorder'] = $orderindex;
139 $answers[$ident]['action'] = $setvar->getAction();
140 $answers[$ident]['points'] = $setvar->getContent();
141 }
142 }
143 if (!is_array($respcondition->displayfeedback)) {
144 continue;
145 }
146
147 foreach ($respcondition->displayfeedback as $feedbackpointer) {
148 if ($feedbackpointer->getLinkrefid() === '') {
149 continue;
150 }
151
152 foreach ($item->itemfeedback as $ifb) {
153 if ($ifb->getIdent() === 'response_allcorrect') {
154
155 foreach ($ifb->material as $material) {
156 $feedbacksgeneric[1] = $material;
157 }
158 foreach ($ifb->flow_mat as $fmat) {
159 foreach ($fmat->material as $material) {
160 $feedbacksgeneric[1] = $material;
161 }
162 }
163 continue;
164 }
165
166 if ($ifb->getIdent() === 'response_onenotcorrect') {
167
168 foreach ($ifb->material as $material) {
169 $feedbacksgeneric[0] = $material;
170 }
171 foreach ($ifb->flow_mat as $fmat) {
172 foreach ($fmat->material as $material) {
173 $feedbacksgeneric[0] = $material;
174 }
175 }
176 }
177 }
178 }
179 }
180 }
181
183
185 $this->
object->setTitle($item->
getTitle());
187 $this->
object->setComment($item->
getComment());
188 $this->
object->setAuthor($item->
getAuthor());
191 $this->object->setOrderingType($type);
192 $this->object->setObjId($questionpool_id);
193 $this->object->setThumbSize(
195 );
198 : null);
199 $this->object->setShuffle($shuffle);
200 $this->object->setPoints(0);
201 $this->object->saveQuestionDataToDb();
202 $points = 0;
203 $solanswers = [];
204
205 foreach ($answers as $answer) {
206 if (isset($answer['solutionorder'])) {
207 $solanswers[$answer['solutionorder']] = $answer;
208 }
209 }
210 ksort($solanswers);
211 $position = 0;
212 $element_list = $this->object->getOrderingElementList();
213 foreach ($solanswers as $answer) {
214 $points += $answer['points'];
215
217
218 if ($element->isExportIdent($answer['ident'])) {
219 $element->setExportIdent($answer['ident']);
220 } else {
221 $element = $element->withPosition($position++);
222 if (isset($answer['answerdepth'])) {
223 $element = $element->withIndentation((int) $answer['answerdepth']);
224 }
225 }
226
227 if ($this->
object->isImageOrderingType()) {
228 $filename = $this->handleUploadedfile($answer);
230 $element = $element->withContent(
$filename);
231 }
232 } else {
233 $element = $element->withContent($answer['answertext']);
234 }
235
236 $element_list->addElement($element);
237 }
238 $this->object->setOrderingElementList($element_list);
240 $this->object->setPoints($points);
241
242 $this->object->setAdditionalContentEditingMode(
244 );
245 $this->object->saveToDb();
247 foreach ($feedbacksgeneric as $correctness => $material) {
249 $feedbacksgeneric[$correctness] = $m;
250 }
251 $questiontext = $this->object->getQuestion();
252
253
256 $importfile = $importdirectory . DIRECTORY_SEPARATOR . $mob['uri'];
257
259 $DIC[
'ilLog']->write(__METHOD__ .
': import mob from dir: ' . $importfile);
260
263 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
264 foreach ($this->
object->getOrderingElementList() as $element) {
265 $element->setContent(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $element->getContent()));
266 }
267 foreach ($feedbacksgeneric as $correctness => $material) {
268 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
269 }
270 foreach ($itemfeedbacks as $ident => $material) {
271 $itemfeedbacks[$ident] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
272 }
273 }
274 }
276 foreach ($this->
object->getOrderingElementList() as $element) {
278 }
279 foreach ($feedbacksgeneric as $correctness => $material) {
280 $this->object->feedbackOBJ->importGenericFeedback(
282 $correctness,
284 );
285 }
286 foreach ($itemfeedbacks as $ident => $material) {
288
289 $this->object->feedbackOBJ->importSpecificAnswerFeedback(
291 0,
292 $index,
294 );
295 }
296 $this->object->saveToDb();
298 $questionpool_id,
299 $tst_id,
300 $question_counter,
301 $tst_object
302 );
303 return $import_mapping;
304 }
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)
deduceThumbSizeFromImportValue(?int $size)
fetchIndexFromFeedbackIdent($feedbackIdent, $prefix='response_')
importSuggestedSolutions(int $question_id, array $solution_from_import)
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)
static clear(string $a_var)