43 public function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, $import_mapping): array
51 $presentation = $item->getPresentation();
55 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
57 foreach ($presentation->order as $entry) {
58 switch ($entry[
"type"]) {
60 $response = $presentation->response[$entry[
"index"]];
62 array_push($idents,
$response->getIdent());
68 $feedbacksgeneric = array();
69 foreach ($item->resprocessing as $resprocessing) {
70 foreach ($resprocessing->respcondition as $respcondition) {
73 $conditionvar = $respcondition->getConditionvar();
74 foreach ($conditionvar->order as $order) {
75 switch ($order[
"field"]) {
77 $respident = $conditionvar->varsubset[$order[
"index"]]->getRespident();
78 $content = $conditionvar->varsubset[$order[
"index"]]->getContent();
79 if (!isset($responses[$respident]) || !is_array($responses[$respident])) {
80 $responses[$respident] = array();
82 $vars = explode(
",", $content);
83 foreach ($vars as $var) {
84 array_push($responses[$respident], array(
"solution" => $var,
"points" =>
""));
89 foreach ($respcondition->setvar as $setvar) {
91 foreach ($responses[$respident] as $idx => $solutionarray) {
92 if (strlen($solutionarray[
"points"]) == 0) {
93 $responses[$respident][$idx][
"points"] = $setvar->getContent();
98 foreach ($resprocessing->respcondition as $e_respcondition) {
99 foreach ($e_respcondition->displayfeedback as $feedbackpointer) {
100 if (strlen($feedbackpointer->getLinkrefid())) {
101 foreach ($item->itemfeedback as $ifb) {
102 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
104 if (count($ifb->material)) {
105 foreach ($ifb->material as $material) {
106 $feedbacksgeneric[1] = $material;
109 if ((count($ifb->flow_mat) > 0)) {
110 foreach ($ifb->flow_mat as $fmat) {
111 if (count($fmat->material)) {
112 foreach ($fmat->material as $material) {
113 $feedbacksgeneric[1] = $material;
118 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
120 if (count($ifb->material)) {
121 foreach ($ifb->material as $material) {
122 $feedbacksgeneric[0] = $material;
125 if ((count($ifb->flow_mat) > 0)) {
126 foreach ($ifb->flow_mat as $fmat) {
127 if (count($fmat->material)) {
128 foreach ($fmat->material as $material) {
129 $feedbacksgeneric[0] = $material;
142 $this->
object->setTitle($item->getTitle());
143 $this->
object->setNrOfTries((
int) $item->getMaxattempts());
144 $this->
object->setComment($item->getComment());
145 $this->
object->setAuthor($item->getAuthor());
146 $this->
object->setOwner(
$ilUser->getId());
147 $this->
object->setQuestion($this->
object->QTIMaterialToString($item->getQuestiontext()));
148 $this->
object->setObjId($questionpool_id);
149 $textrating = $item->getMetadataEntry(
"textrating");
150 if (strlen($textrating) == 0) {
153 $this->
object->setTextRating($textrating);
154 $this->
object->setCorrectAnswers($item->getMetadataEntry(
"correctanswers"));
159 $this->
object->addAnswer($answer[
"solution"], $answer[
"points"], $counter);
164 $this->
object->setAdditionalContentEditingMode(
167 $this->
object->saveToDb();
168 if (count($item->suggested_solutions)) {
169 foreach ($item->suggested_solutions as $suggested_solution) {
170 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->
getContent(), $suggested_solution[
"gap_index"],
true);
172 $this->
object->saveToDb();
174 foreach ($feedbacksgeneric as $correctness => $material) {
175 $m = $this->
object->QTIMaterialToString($material);
176 $feedbacksgeneric[$correctness] = $m;
179 $questiontext = $this->
object->getQuestion();
189 $DIC[
'ilLog']->write(__METHOD__ .
': import mob from dir: ' . $importfile);
193 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
194 foreach ($feedbacksgeneric as $correctness => $material) {
195 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
200 foreach ($feedbacksgeneric as $correctness => $material) {
201 $this->
object->feedbackOBJ->importGenericFeedback(
207 $this->
object->saveToDb();
209 $q_1_id = $this->
object->getId();
210 $question_id = $this->
object->duplicate(
true,
"",
"",
"", $tst_id);
211 $tst_object->questions[$question_counter++] = $question_id;
212 $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id,
"test" => $question_id);
214 $import_mapping[$item->getIdent()] = array(
"pool" => $this->
object->getId(),
"test" => 0);
216 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...
static get(string $a_var)
addGeneralMetadata(ilQTIItem $item)
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) ...
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) ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static clear(string $a_var)