43     public function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, $import_mapping): array
    46         $ilUser = $DIC[
'ilUser'];
    50         $presentation = $item->getPresentation();
    53             $item->getMetadataEntry(
"question") ?? 
' ',
    54             $item->getIliasSourceNic()
    57         $clozetext_array = [];
    60         foreach ($presentation->order as $entry) {
    61             switch ($entry[
"type"]) {
    65                         $presentation->material[$entry[
"index"]]
    68                     if ($questiontext === 
' ') {
    70                         $questiontext = $material_string;
    72                         array_push($clozetext_array, $material_string);
    77                     $response = $presentation->response[$entry[
"index"]];
    79                     array_push($clozetext_array, 
"<<" . 
$response->getIdent() . 
">>");
    81                     switch (strtolower(get_class(
$response->getRenderType()))) {
    82                         case "ilqtirenderfib":
    83                             switch (
$response->getRenderType()->getFibtype()) {
    92                                             "minnumber" => 
$response->getRenderType()->getMinnumber(),
    93                                             "maxnumber" => 
$response->getRenderType()->getMaxnumber(),
    94                                             'gap_size' => 
$response->getRenderType()->getMaxchars()
   105                                             'gap_size' => 
$response->getRenderType()->getMaxchars()
   111                         case "ilqtirenderchoice":
   113                             $shuffle = $rendertype->getShuffle();
   115                             foreach ($rendertype->response_labels as $response_label) {
   116                                 $ident = $response_label->getIdent();
   118                                 foreach ($response_label->material as $mat) {
   122                                     "answertext" => $answertext,
   124                                     "answerorder" => $answerorder++,
   126                                     "shuffle" => $rendertype->getShuffle()
   129                             array_push($gaps, [
"ident" => 
$response->getIdent(), 
"type" => 
CLOZE_SELECT, 
"shuffle" => $rendertype->getShuffle(), 
"answers" => $answers]);
   137         $feedbacksgeneric = [];
   138         foreach ($item->resprocessing as $resprocessing) {
   139             foreach ($resprocessing->respcondition as $respcondition) {
   142                 $conditionvar = $respcondition->getConditionvar();
   143                 foreach ($conditionvar->order as $order) {
   144                     switch ($order[
"field"]) {
   146                             $equals = $conditionvar->varequal[$order[
"index"]]->getContent();
   147                             $gapident = $conditionvar->varequal[$order[
"index"]]->getRespident();
   151                 foreach ($respcondition->setvar as $setvar) {
   152                     if (strcmp($gapident, 
"") != 0) {
   153                         foreach ($gaps as $gi => $g) {
   154                             if (strcmp($g[
"ident"], $gapident) == 0) {
   156                                     foreach ($gaps[$gi][
"answers"] as $ai => $answer) {
   157                                         if (strcmp($answer[
"answertext"], $equals) == 0) {
   158                                             $gaps[$gi][
"answers"][$ai][
"action"] = $setvar->getAction();
   159                                             $gaps[$gi][
"answers"][$ai][
"points"] = $setvar->getContent();
   163                                     array_push($gaps[$gi][
"answers"], [
   164                                         "answertext" => $equals,
   165                                         "points" => $setvar->getContent(),
   166                                         "answerorder" => count($gaps[$gi][
"answers"]),
   167                                         "action" => $setvar->getAction()
   171                                     array_push($gaps[$gi][
"answers"], [
   172                                         "answertext" => $equals,
   173                                         "points" => $setvar->getContent(),
   174                                         "answerorder" => count($gaps[$gi][
"answers"]),
   175                                         "action" => $setvar->getAction()
   183                 if (count($respcondition->displayfeedback)) {
   184                     foreach ($respcondition->displayfeedback as $feedbackpointer) {
   185                         if (strlen($feedbackpointer->getLinkrefid())) {
   186                             foreach ($item->itemfeedback as $ifb) {
   187                                 if (strcmp($ifb->getIdent(), 
"response_allcorrect") == 0) {
   189                                     if (count($ifb->material)) {
   190                                         foreach ($ifb->material as $material) {
   191                                             $feedbacksgeneric[1] = $material;
   194                                     if ((count($ifb->flow_mat) > 0)) {
   195                                         foreach ($ifb->flow_mat as $fmat) {
   196                                             if (count($fmat->material)) {
   197                                                 foreach ($fmat->material as $material) {
   198                                                     $feedbacksgeneric[1] = $material;
   203                                 } elseif (strcmp($ifb->getIdent(), 
"response_onenotcorrect") == 0) {
   205                                     if (count($ifb->material)) {
   206                                         foreach ($ifb->material as $material) {
   207                                             $feedbacksgeneric[0] = $material;
   210                                     if ((count($ifb->flow_mat) > 0)) {
   211                                         foreach ($ifb->flow_mat as $fmat) {
   212                                             if (count($fmat->material)) {
   213                                                 foreach ($fmat->material as $material) {
   214                                                     $feedbacksgeneric[0] = $material;
   221                                     if (count($ifb->material)) {
   222                                         foreach ($ifb->material as $material) {
   223                                             $feedbacks[$ifb->getIdent()] = $material;
   226                                     if ((count($ifb->flow_mat) > 0)) {
   227                                         foreach ($ifb->flow_mat as $fmat) {
   228                                             if (count($fmat->material)) {
   229                                                 foreach ($fmat->material as $material) {
   230                                                     $feedbacks[$ifb->getIdent()] = $material;
   244         $this->
object->setTitle($item->getTitle());
   245         $this->
object->setNrOfTries((
int) $item->getMaxattempts());
   246         $this->
object->setComment($item->getComment());
   247         $this->
object->setAuthor($item->getAuthor());
   248         $this->
object->setOwner($ilUser->getId());
   249         $this->
object->setObjId($questionpool_id);
   250         $textgap_rating = $item->getMetadataEntry(
"textgaprating");
   251         $this->
object->setFixedTextLength($item->getMetadataEntry(
"fixedTextLength"));
   252         $this->
object->setIdenticalScoring($item->getMetadataEntry(
"identicalScoring"));
   253         $this->
object->setFeedbackMode(
   254             strlen($item->getMetadataEntry(
"feedback_mode")) ?
   257         $combinations = json_decode(base64_decode($item->getMetadataEntry(
"combinations")));
   258         if (strlen($textgap_rating) == 0) {
   259             $textgap_rating = 
"ci";
   261         $this->
object->setTextgapRating($textgap_rating);
   263         foreach ($gaps as $gapidx => $gap) {
   266             foreach ($gap[
"answers"] as $index => $answer) {
   267                 $gapanswer = 
new assAnswerCloze($answer[
"answertext"], $answer[
"points"], $answer[
"answerorder"]);
   268                 $gapanswer->setGapSize((
int) ($gap[
"gap_size"] ?? 0));
   269                 switch ($clozegap->getType()) {
   271                         $clozegap->setShuffle($answer[
"shuffle"]);
   274                         $gapanswer->setLowerBound($gap[
"minnumber"]);
   275                         $gapanswer->setUpperBound($gap[
"maxnumber"]);
   278                 $clozegap->setGapSize((
int) ($gap[
"gap_size"] ?? 0));
   279                 $clozegap->addItem($gapanswer);
   280                 array_push($gapcontent, $answer[
"answertext"]);
   282             $this->
object->addGapAtIndex($clozegap, $gapidx);
   283             $gaptext[$gap[
"ident"]] = 
"[gap]" . join(
",", $gapcontent) . 
"[/gap]";
   286         $this->
object->setQuestion($questiontext);
   287         $clozetext = join(
"", $clozetext_array);
   289         foreach ($gaptext as $idx => $val) {
   290             $clozetext = str_replace(
"<<" . $idx . 
">>", $val, $clozetext);
   292         $this->
object->setClozeTextValue($clozetext);
   295         $this->
object->setAdditionalContentEditingMode(
   298         $this->
object->saveToDb();
   300         if (is_array($combinations) && count($combinations) > 0) {
   304             $gap_combinations->loadFromDb($this->
object->getId());
   305             $this->
object->setGapCombinations($gap_combinations);
   306             $this->
object->setGapCombinationsExists(
true);
   310         foreach ($feedbacks as $ident => $material) {
   312             $feedbacks[$ident] = $m;
   314         foreach ($feedbacksgeneric as $correctness => $material) {
   316             $feedbacksgeneric[$correctness] = $m;
   327                 $DIC[
'ilLog']->write(__METHOD__ . 
': import mob from dir: ' . $importfile);
   330                 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $questiontext);
   331                 $clozetext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $clozetext);
   332                 foreach ($feedbacks as $ident => $material) {
   333                     $feedbacks[$ident] = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $material);
   335                 foreach ($feedbacksgeneric as $correctness => $material) {
   336                     $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $material);
   342         foreach ($feedbacks as $ident => $material) {
   344             $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
   346                 $fbIdentifier->getQuestionIndex(),
   347                 $fbIdentifier->getAnswerIndex(),
   351         foreach ($feedbacksgeneric as $correctness => $material) {
   352             $this->
object->feedbackOBJ->importGenericFeedback(
   358         $this->
object->saveToDb();
   360         if (isset($tst_id) && $tst_id !== $questionpool_id) {
   361             $qpl_qid = $this->
object->getId();
   362             $tst_qid = $this->
object->duplicate(
true, 
"", 
"", -1, $tst_id);
   363             $tst_object->questions[$question_counter++] = $tst_qid;
   364             $import_mapping[$item->getIdent()] = [
"pool" => $qpl_qid, 
"test" => $tst_qid];
   365             return $import_mapping;
   369             $tst_object->questions[$question_counter++] = $this->
object->getId();
   370             $import_mapping[$item->getIdent()] = [
"pool" => 0, 
"test" => $this->
object->getId()];
   371             return $import_mapping;
   374         $import_mapping[$item->getIdent()] = [
"pool" => $this->
object->getId(), 
"test" => 0];
   375         return $import_mapping;
   386         $ident = explode(
'_', $ident);
   388         if (count($ident) > 1) {
   389             $fbIdentifier->setQuestionIndex($ident[0]);
   390             $fbIdentifier->setAnswerIndex($ident[1]);
   392             $fbIdentifier->setQuestionIndex($ident[0]);
   393             $fbIdentifier->setAnswerIndex(0);
   396         return $fbIdentifier;
 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)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
addGeneralMetadata(ilQTIItem $item)
 
QTIMaterialToString(ilQTIMaterial $a_material)
Reads an QTI material tag and creates a text or XHTML string. 
 
static importGapCombinationToDb($question_id, $gap_combinations)
 
const CLOZE_TEXT
Cloze question constants. 
 
processNonAbstractedImageReferences($text, $sourceNic)
 
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) ...
 
Class for cloze question gaps. 
 
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, $import_mapping)
Creates a question from a QTI file. 
 
static clearGapCombinationsFromDb($question_id)
 
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...
 
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
 
Class for question imports. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static clear(string $a_var)
 
buildFeedbackIdentifier($ident)
 
const FB_MODE_GAP_QUESTION
constants for different feedback modes (per gap or per gap-answers/options)