ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assOrderingHorizontalImport Class Reference

Class for formula question imports. More...

+ Inheritance diagram for assOrderingHorizontalImport:
+ Collaboration diagram for assOrderingHorizontalImport:

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
 __construct ($a_object)
 assQuestionImport constructor More...
 
 getFeedbackGeneric ($item)
 
 fromXML (&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Creates a question from a QTI file. 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)
 
 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_DEFAULT when no or invalid information is given More...
 

Detailed Description

Class for formula question imports.

assOrderingHorizontalImport is a class for horizontal ordering 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 15 of file class.assOrderingHorizontalImport.php.

Member Function Documentation

◆ fromXML()

assOrderingHorizontalImport::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
object$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 30 of file class.assOrderingHorizontalImport.php.

References $_SESSION, $GLOBALS, $ilUser, $index, ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObject\_saveUsage(), assQuestionImport\addGeneralMetadata(), array, assQuestionImport\fetchAdditionalContentEditingModeInformation(), assQuestionImport\fetchIndexFromFeedbackIdent(), assQuestionImport\getFeedbackAnswerSpecific(), assQuestionImport\getFeedbackGeneric(), assQuestionImport\getQplImportArchivDirectory(), assQuestionImport\getTstImportArchivDirectory(), and object.

31  {
32  global $ilUser;
33 
34  // empty session variable for imported xhtml mobs
35  unset($_SESSION["import_mob_xhtml"]);
36  $presentation = $item->getPresentation();
37  $duration = $item->getDuration();
38  $now = getdate();
39  $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
40 
41  $this->addGeneralMetadata($item);
42  $this->object->setTitle($item->getTitle());
43  $this->object->setNrOfTries($item->getMaxattempts());
44  $this->object->setComment($item->getComment());
45  $this->object->setAuthor($item->getAuthor());
46  $this->object->setOwner($ilUser->getId());
47  $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
48  $this->object->setObjId($questionpool_id);
49  $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
50  $this->object->setPoints($item->getMetadataEntry("points"));
51  $this->object->setOrderText($item->getMetadataEntry("ordertext"));
52  $this->object->setTextSize($item->getMetadataEntry("textsize"));
53  $this->object->setSeparator($item->getMetadataEntry("separator"));
54  // additional content editing mode information
55  $this->object->setAdditionalContentEditingMode(
57  );
58  $this->object->saveToDb();
59 
60  $feedbacks = $this->getFeedbackAnswerSpecific($item);
61  $feedbacksgeneric = $this->getFeedbackGeneric($item);
62 
63  // handle the import of media objects in XHTML code
64  $questiontext = $this->object->getQuestion();
65  if (is_array($_SESSION["import_mob_xhtml"])) {
66  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
67  include_once "./Services/RTE/classes/class.ilRTE.php";
68  foreach ($_SESSION["import_mob_xhtml"] as $mob) {
69  if ($tst_id > 0) {
70  $importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
71  } else {
72  $importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
73  }
74 
75  $GLOBALS['ilLog']->write(__METHOD__ . ': import mob from dir: ' . $importfile);
76 
77  $media_object =&ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, false);
78  ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
79  $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
80 
81  foreach ($feedbacks as $ident => $material) {
82  $feedbacks[$ident] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
83  }
84  foreach ($feedbacksgeneric as $correctness => $material) {
85  $feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
86  }
87  }
88  }
89  $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
90 
91  foreach ($feedbacks as $ident => $material) {
92  $index = $this->fetchIndexFromFeedbackIdent($ident);
93 
94  $this->object->feedbackOBJ->importSpecificAnswerFeedback(
95  $this->object->getId(),
96  $index,
98  );
99  }
100  foreach ($feedbacksgeneric as $correctness => $material) {
101  $this->object->feedbackOBJ->importGenericFeedback(
102  $this->object->getId(),
103  $correctness,
105  );
106  }
107 
108  $this->object->saveToDb();
109  if (count($item->suggested_solutions)) {
110  foreach ($item->suggested_solutions as $suggested_solution) {
111  $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
112  }
113  $this->object->saveToDb();
114  }
115  if ($tst_id > 0) {
116  $q_1_id = $this->object->getId();
117  $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
118  $tst_object->questions[$question_counter++] = $question_id;
119  $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
120  } else {
121  $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
122  }
123  }
getFeedbackAnswerSpecific(ilQTIItem $item, $prefix='response_')
addGeneralMetadata(ilQTIItem $item)
$_SESSION["AccountId"]
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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) ...
$index
Definition: metadata.php:60
static _saveTempFileAsMediaObject($name, $tmp_name, $upload=true)
Create new media object and update page in db and return new media object.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
static _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
fetchIndexFromFeedbackIdent($feedbackIdent, $prefix='response_')
+ Here is the call graph for this function:

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