48     public function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, $import_mapping): array
    51         $ilUser = $DIC[
'ilUser'];
    56         $presentation = $item->getPresentation();
    60         $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
    61         foreach ($presentation->order as $entry) {
    62             switch ($entry[
"type"]) {
    64                     $response = $presentation->response[$entry[
"index"]];
    66                     switch (strtolower(get_class($rendertype))) {
    67                         case "ilqtirenderfib":
    68                             $maxchars = $rendertype->getMaxchars();
    75         $feedbacksgeneric = [];
    76         foreach ($item->resprocessing as $resprocessing) {
    77             $outcomes = $resprocessing->getOutcomes();
    78             foreach ($outcomes->decvar as $decvar) {
    79                 $maxpoints = $decvar->getMaxvalue();
    82             foreach ($resprocessing->respcondition as $respcondition) {
    83                 foreach ($respcondition->displayfeedback as $feedbackpointer) {
    84                     if (strlen($feedbackpointer->getLinkrefid())) {
    85                         foreach ($item->itemfeedback as $ifb) {
    86                             if (strcmp($ifb->getIdent(), 
"response_allcorrect") == 0) {
    88                                 if (count($ifb->material)) {
    89                                     foreach ($ifb->material as $material) {
    90                                         $feedbacksgeneric[1] = $material;
    93                                 if ((count($ifb->flow_mat) > 0)) {
    94                                     foreach ($ifb->flow_mat as $fmat) {
    95                                         if (count($fmat->material)) {
    96                                             foreach ($fmat->material as $material) {
    97                                                 $feedbacksgeneric[1] = $material;
   102                             } elseif (strcmp($ifb->getIdent(), 
"response_onenotcorrect") == 0) {
   104                                 if (count($ifb->material)) {
   105                                     foreach ($ifb->material as $material) {
   106                                         $feedbacksgeneric[0] = $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[0] = $material;
   125         $this->
object->setTitle($item->getTitle());
   126         $this->
object->setNrOfTries((
int) $item->getMaxattempts());
   127         $this->
object->setComment($item->getComment());
   128         $this->
object->setAuthor($item->getAuthor());
   129         $this->
object->setOwner($ilUser->getId());
   131         $this->
object->setObjId($questionpool_id);
   132         $this->
object->setPoints($maxpoints);
   133         $this->
object->setMaxNumOfChars($maxchars ?? 0);
   134         $this->
object->setWordCounterEnabled((
bool) $item->getMetadataEntry(
'wordcounter'));
   135         $textrating = $item->getMetadataEntry(
"textrating");
   136         if (strlen($textrating)) {
   137             $this->
object->setTextRating($textrating);
   139         $this->
object->setMatchcondition((strlen($item->getMetadataEntry(
'matchcondition'))) ? (
int) $item->getMetadataEntry(
'matchcondition') : 0);
   141         $no_keywords_found = 
true;
   143         if ($item->getMetadataEntry(
'termrelation') !== 
'non'   144             && $item->getMetadataEntry(
'termrelation') !== null) {
   146             for ($i = 0, $iMax = count($termscoring); $i < $iMax; $i++) {
   147                 $this->
object->addAnswer($termscoring[$i]->getAnswertext(), $termscoring[$i]->getPoints());
   148                 $no_keywords_found = 
false;
   152         if ($item->getMetadataEntry(
'termrelation') !== null) {
   153             $this->
object->setKeywordRelation($item->getMetadataEntry(
'termrelation'));
   156         $keywords = $item->getMetadataEntry(
"keywords");
   157         if ($keywords !== null) {
   158             $answers = explode(
' ', $keywords);
   159             foreach ($answers as $answer) {
   160                 $this->
object->addAnswer($answer, 0);
   162             $this->
object->setKeywordRelation(
'one');
   163             $no_keywords_found = 
false;
   165         if ($no_keywords_found) {
   166             $this->
object->setKeywordRelation(
'non');
   170         $this->
object->setAdditionalContentEditingMode(
   173         $this->
object->saveToDb();
   175         foreach ($feedbacksgeneric as $correctness => $material) {
   177             $feedbacksgeneric[$correctness] = $m;
   180         $questiontext = $this->
object->getQuestion();
   193                 $DIC[
'ilLog']->write(__METHOD__ . 
': import mob from dir: ' . $importfile);
   197                 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $questiontext);
   198                 foreach ($feedbacks as $ident => $material) {
   199                     $feedbacks[$ident] = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $material);
   201                 foreach ($feedbacksgeneric as $correctness => $material) {
   202                     $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $material);
   207         foreach ($feedbacks as $ident => $material) {
   210             $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
   217         foreach ($feedbacksgeneric as $correctness => $material) {
   218             $this->
object->feedbackOBJ->importGenericFeedback(
   224         $this->
object->saveToDb();
   226             $q_1_id = $this->
object->getId();
   227             $question_id = $this->
object->duplicate(
true, 
"", 
"", -1, $tst_id);
   228             $tst_object->questions[$question_counter++] = $question_id;
   229             $import_mapping[$item->getIdent()] = [
"pool" => $q_1_id, 
"test" => $question_id];
   231             $import_mapping[$item->getIdent()] = [
"pool" => $this->
object->getId(), 
"test" => 0];
   233         return $import_mapping;
   238         $termScoringString = $item->getMetadataEntry(
'termscoring');
   240         if (!strlen($termScoringString)) {
   244         $termScoring = @unserialize($termScoringString, [
'allowed_classes' => [ASS_AnswerMultipleResponseImage::class]]);
   246         if (is_array($termScoring)) {
   250         $termScoringString = base64_decode($termScoringString);
   251         $termScoring = unserialize($termScoringString, [
'allowed_classes' => [ASS_AnswerMultipleResponseImage::class]]);
   253         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. 
 
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_...
 
getQplImportArchivDirectory()
returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir) ...
 
importSuggestedSolutions(int $question_id, array $solution_from_import)
 
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) ...
 
Class for question imports. 
 
static clear(string $a_var)
 
fetchIndexFromFeedbackIdent($feedbackIdent, $prefix='response_')