ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
assFileUploadImport Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for assFileUploadImport:
+ Collaboration diagram for assFileUploadImport:

Public Member Functions

 fromXML (&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, $import_mapping)
 Creates a question from a QTI file. More...
 
- Public Member Functions inherited from assQuestionImport
 getQuestionId ()
 
 getFeedbackGeneric ($item)
 
 fromXML (&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, $import_mapping)
 Creates a question from a QTI file. More...
 
 importSuggestedSolutions (int $question_id, array $solution_from_import)
 
 QTIMaterialToString (ilQTIMaterial $a_material)
 Reads an QTI material tag and creates a text or XHTML string. More...
 

Additional Inherited Members

- Data Fields inherited from assQuestionImport
 $object
 
- Protected Member Functions inherited from assQuestionImport
 fetchIndexFromFeedbackIdent ($feedbackIdent, $prefix='response_')
 
 getFeedbackAnswerSpecific (ilQTIItem $item, $prefix='response_')
 
 addGeneralMetadata (ilQTIItem $item)
 
 fetchLifecycle (ilQTIItem $item)
 
 getQplImportArchivDirectory ()
 returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir) More...
 
 getTstImportArchivDirectory ()
 returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) More...
 
 processNonAbstractedImageReferences ($text, $sourceNic)
 
 fetchAdditionalContentEditingModeInformation ($qtiItem)
 fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_CONTENT_EDITING_MODE_RTE when no or invalid information is given More...
 
 findSolutionTypeByValue (string $value)
 
 getSuggestedSolutionsRepo ()
 
 deduceThumbSizeFromImportValue (?int $size)
 
- Protected Attributes inherited from assQuestionImport
assQuestionSuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class for file upload question imports

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 25 of file class.assFileUploadImport.php.

Member Function Documentation

◆ fromXML()

assFileUploadImport::fromXML ( $item,
  $questionpool_id,
$tst_id,
$tst_object,
$question_counter,
  $import_mapping 
)

Creates a question from a QTI file.

Receives parameters from a QTI parser and creates a valid ILIAS question object

Parameters
ilQtiItem$itemThe QTI item object
integer$questionpool_idThe id of the parent questionpool
integer$tst_idThe id of the parent test if the question is part of a test
object$tst_objectA reference to the parent test object
integer$question_counterA reference to a question counter to count the questions of an imported question pool
array$import_mappingAn array containing references to included ILIAS objects public

Definition at line 40 of file class.assFileUploadImport.php.

References ILIAS\LTI\ToolProvider\$created, $DIC, ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObject\_saveUsage(), assQuestionImport\addGeneralMetadata(), ilSession\clear(), assQuestionImport\fetchAdditionalContentEditingModeInformation(), ilSession\get(), assQuestionImport\getFeedbackGeneric(), assQuestionImport\getQplImportArchivDirectory(), assQuestionImport\getTstImportArchivDirectory(), IL_INST_ID, assQuestionImport\importSuggestedSolutions(), ILIAS\Repository\int(), ILIAS\Repository\object(), and assQuestionImport\QTIMaterialToString().

40  : array
41  {
42  global $DIC;
43  $ilUser = $DIC['ilUser'];
44 
45  // empty session variable for imported xhtml mobs
46  ilSession::clear('import_mob_xhtml');
47 
48  $presentation = $item->getPresentation();
49  $now = getdate();
50  $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
51 
52  $feedbacksgeneric = [];
53 
54  $this->addGeneralMetadata($item);
55  $this->object->setTitle($item->getTitle());
56  $this->object->setNrOfTries((int) $item->getMaxattempts());
57  $this->object->setComment($item->getComment());
58  $this->object->setAuthor($item->getAuthor());
59  $this->object->setOwner($ilUser->getId());
60  $this->object->setQuestion($this->QTIMaterialToString($item->getQuestiontext()));
61  $this->object->setObjId($questionpool_id);
62  $this->object->setPoints($item->getMetadataEntry("points"));
63  $this->object->setMaxSize($item->getMetadataEntry("maxsize") ? (int) $item->getMetadataEntry("maxsize") : null);
64  $this->object->setAllowedExtensions($item->getMetadataEntry("allowedextensions") ?? '');
65  // additional content editing mode information
66  $this->object->setAdditionalContentEditingMode(
68  );
69  $this->object->saveToDb();
70 
71  $feedbacksgeneric = $this->getFeedbackGeneric($item);
72 
73  // handle the import of media objects in XHTML code
74  $questiontext = $this->object->getQuestion();
75  if (is_array(ilSession::get("import_mob_xhtml"))) {
76  foreach (ilSession::get("import_mob_xhtml") as $mob) {
77  if ($tst_id > 0) {
78  $importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
79  } else {
80  $importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
81  }
82 
83  global $DIC; /* @var ILIAS\DI\Container $DIC */
84  $DIC['ilLog']->write(__METHOD__ . ': import mob from dir: ' . $importfile);
85 
86  $media_object = ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, false);
87  ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
88  $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
89  foreach ($feedbacksgeneric as $correctness => $material) {
90  $feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
91  }
92  }
93  }
94  $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
95  foreach ($feedbacksgeneric as $correctness => $material) {
96  $this->object->feedbackOBJ->importGenericFeedback(
97  $this->object->getId(),
98  $correctness,
100  );
101  }
102  $this->object->saveToDb();
103  $this->importSuggestedSolutions($this->object->getId(), $item->suggested_solutions);
104  if ($tst_id > 0) {
105  $q_1_id = $this->object->getId();
106  $question_id = $this->object->duplicate(true, "", "", -1, $tst_id);
107  $tst_object->questions[$question_counter++] = $question_id;
108  $import_mapping[$item->getIdent()] = ["pool" => $q_1_id, "test" => $question_id];
109  } else {
110  $import_mapping[$item->getIdent()] = ["pool" => $this->object->getId(), "test" => 0];
111  }
112  return $import_mapping;
113  }
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)
addGeneralMetadata(ilQTIItem $item)
const IL_INST_ID
Definition: constants.php:40
QTIMaterialToString(ilQTIMaterial $a_material)
Reads an QTI material tag and creates a text or XHTML string.
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
static _saveUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Save usage of mob within another container (e.g.
getQplImportArchivDirectory()
returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir) ...
global $DIC
Definition: feed.php:28
importSuggestedSolutions(int $question_id, array $solution_from_import)
static _saveTempFileAsMediaObject(string $name, string $tmp_name, bool $upload=true)
Create new media object and update page in db and return new media object.
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
static clear(string $a_var)
int $created
Timestamp for when the object was created.
Definition: System.php:151
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: