32         $image = base64_decode(
$data);
    33         $imagepath = $this->
object->getImagePath();
    34         if (!file_exists($imagepath)) {
    38         $fh = fopen($imagepath, 
"wb");
    41             $imagefile = fwrite($fh, $image);
    47         string $importdirectory,
    53         int &$question_counter,
    63         foreach ($presentation->order as $entry) {
    64             switch ($entry[
"type"]) {
    66                     $response = $presentation->response[$entry[
"index"]];
    68                     switch (strtolower(get_class($rendertype))) {
    69                         case "ilqtirenderchoice":
    70                             $shuffle = $rendertype->getShuffle();
    72                             foreach ($rendertype->response_labels as $response_label) {
    73                                 $ident = $response_label->getIdent();
    76                                 foreach ($response_label->material as $mat) {
    77                                     for ($m = 0; $m < $mat->getMaterialCount(); $m++) {
    78                                         $foundmat = $mat->getMaterial($m);
    79                                         if (strcmp($foundmat[
"type"], 
"mattext") == 0) {
    80                                             $answertext .= $foundmat[
"material"]->getContent();
    82                                         if (strcmp($foundmat[
"type"], 
"matimage") == 0) {
    85                                                 "imagetype" => $foundmat[
"material"]->getImageType(),
    86                                                 "label" => $foundmat[
"material"]->getLabel(),
    87                                                 "content" => $foundmat[
"material"]->getContent()
    92                                 if (($response_label->getMatchMax() == 1) && (strlen($response_label->getMatchGroup()))) {
    93                                     $definitions[$ident] = [
    94                                         "answertext" => $answertext,
    95                                         "answerimage" => $answerimage,
    97                                         "answerorder" => $ident,
   102                                         "term" => $answertext,
   103                                         "answerimage" => $answerimage,
   116         $feedbacksgeneric = [];
   117         foreach ($item->resprocessing as $resprocessing) {
   118             foreach ($resprocessing->respcondition as $respcondition) {
   121                 $conditionvar = $respcondition->getConditionvar();
   122                 foreach ($conditionvar->order as $order) {
   123                     switch ($order[
"field"]) {
   125                             $subset = explode(
",", $conditionvar->varsubset[$order[
"index"]]->getContent());
   129                 foreach ($respcondition->setvar as $setvar) {
   130                     array_push($responses, [
"subset" => $subset, 
"action" => $setvar->getAction(), 
"points" => $setvar->getContent()]);
   133                 if (count($respcondition->displayfeedback)) {
   134                     foreach ($respcondition->displayfeedback as $feedbackpointer) {
   135                         if (strlen($feedbackpointer->getLinkrefid())) {
   136                             foreach ($item->itemfeedback as $ifb) {
   137                                 if (strcmp($ifb->getIdent(), 
"response_allcorrect") == 0) {
   139                                     if (count($ifb->material)) {
   140                                         foreach ($ifb->material as $material) {
   141                                             $feedbacksgeneric[1] = $material;
   144                                     if ((count($ifb->flow_mat) > 0)) {
   145                                         foreach ($ifb->flow_mat as $fmat) {
   146                                             if (count($fmat->material)) {
   147                                                 foreach ($fmat->material as $material) {
   148                                                     $feedbacksgeneric[1] = $material;
   153                                 } elseif (strcmp($ifb->getIdent(), 
"response_onenotcorrect") == 0) {
   155                                     if (count($ifb->material)) {
   156                                         foreach ($ifb->material as $material) {
   157                                             $feedbacksgeneric[0] = $material;
   160                                     if ((count($ifb->flow_mat) > 0)) {
   161                                         foreach ($ifb->flow_mat as $fmat) {
   162                                             if (count($fmat->material)) {
   163                                                 foreach ($fmat->material as $material) {
   164                                                     $feedbacksgeneric[0] = $material;
   177         $this->
object->createNewQuestion();
   179         $this->
object->setTitle($item->
getTitle());
   181         $this->
object->setComment($item->
getComment());
   182         $this->
object->setAuthor($item->
getAuthor());
   183         $this->
object->setOwner($user_id);
   185         $this->
object->setObjId($questionpool_id);
   187         $this->
object->setThumbGeometry(
   198         foreach ($terms as $term) {
   199             if (count($term[
'answerimage'])) {
   200                 $this->
saveImage($term[
'answerimage'][
'content'], $term[
'answerimage'][
'label']);
   203         foreach ($definitions as $definition) {
   204             if (count($definition[
'answerimage'])) {
   205                 $this->
saveImage($definition[
'answerimage'][
'content'], $definition[
'answerimage'][
'label']);
   209         foreach ($terms as $termindex => $term) {
   213             $this->
object->addTerm(
new assAnswerMatchingTerm($term[
"term"], $term[
'answerimage'][
'label'] ?? 
'', $term[
"ident"]));
   215         foreach ($definitions as $definitionindex => $definition) {
   216             $this->
object->addDefinition(
new assAnswerMatchingDefinition($definition[
"answertext"], $definition[
'answerimage'][
'label'] ?? 
'', $definition[
"answerorder"]));
   219         if (strlen($extended_shuffle) > 0) {
   220             $shuffle = $extended_shuffle;
   222         $this->
object->setShuffle($shuffle);
   225             $subset = $response[
"subset"];
   226             foreach ($subset as $ident) {
   227                 if (array_key_exists($ident, $definitions)) {
   228                     $definition = $definitions[$ident];
   230                 if (array_key_exists($ident, $terms)) {
   231                     $term = $terms[$ident];
   237         $this->
object->setAdditionalContentEditingMode(
   240         $this->
object->saveToDb();
   242         foreach ($responses as $response) {
   243             $subset = $response[
"subset"];
   244             foreach ($subset as $ident) {
   245                 if (array_key_exists($ident, $definitions)) {
   246                     $definition = $definitions[$ident];
   248                 if (array_key_exists($ident, $terms)) {
   249                     $term = $terms[$ident];
   254         foreach ($feedbacksgeneric as $correctness => $material) {
   256             $feedbacksgeneric[$correctness] = $m;
   262         $questiontext = $this->
object->getQuestion();
   265                 $importfile = $importdirectory . DIRECTORY_SEPARATOR . $mob[
"uri"];
   268                 $DIC[
'ilLog']->write(__METHOD__ . 
': import mob from dir: ' . $importfile);
   272                 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $questiontext);
   273                 foreach ($feedbacks as $ident => $material) {
   274                     $feedbacks[$ident] = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $material);
   276                 foreach ($feedbacksgeneric as $correctness => $material) {
   277                     $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $material);
   282         foreach ($feedbacks as $ident => $material) {
   285             $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
   292         foreach ($feedbacksgeneric as $correctness => $material) {
   293             $this->
object->feedbackOBJ->importGenericFeedback(
   299         $this->
object->saveToDb();
   306         return $import_mapping;
   316         list($termId, $definitionId) = explode(
'_', str_replace($prefix, 
'', $feedbackIdent));
   318         foreach ($this->
object->getMatchingPairs() as $index => $pair) {
   321             if ($pair->getTerm()->getIdentifier() != $termId) {
   325             if ($pair->getDefinition()->getIdentifier() != $definitionId) {
 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)
 
getFeedbackAnswerSpecific(ilQTIItem $item, $prefix='response_')
 
deduceThumbSizeFromImportValue(?int $size)
 
addGeneralMetadata(ilQTIItem $item)
 
QTIMaterialToString(ilQTIMaterial $a_material)
Reads an QTI material tag and creates a text or XHTML string. 
 
const MATCHING_MODE_1_ON_1
 
addQuestionToParentObjectAndBuildMappingEntry(int $questionpool_id, ?int $tst_id, int &$question_counter, ?ilObjTest &$tst_object)
 
getMetadataEntry(string $a_label)
 
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
 
static makeDirParents(string $a_dir)
Create a new directory and all parent directories. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
saveImage($data, $filename)
 
fetchIndexFromFeedbackIdent($feedbackIdent, $prefix='response_')
 
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...
 
Class for question imports. 
 
static clear(string $a_var)
 
fromXML(string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping)