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

Class for numeric question imports. More...

+ Inheritance diagram for assNumericImport:
+ Collaboration diagram for assNumericImport:

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 numeric question imports.

assNumericImport is a class for numeric 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.assNumericImport.php.

Member Function Documentation

◆ fromXML()

assNumericImport::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.assNumericImport.php.

References $_SESSION, $GLOBALS, $ilUser, $m, $response, ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObject\_saveUsage(), assQuestionImport\addGeneralMetadata(), array, assQuestionImport\fetchAdditionalContentEditingModeInformation(), 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  $maxchars = 0;
40  $points = 0;
41  $upperlimit = 0;
42  $lowerlimit = 0;
43  $feedbacksgeneric = array();
44  $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
45  foreach ($presentation->order as $entry) {
46  switch ($entry["type"]) {
47  case "response":
48  $response = $presentation->response[$entry["index"]];
49  $rendertype = $response->getRenderType();
50  switch (strtolower(get_class($rendertype))) {
51  case "ilqtirenderfib":
52  $maxchars = $rendertype->getMaxchars();
53  break;
54  }
55  break;
56  }
57  }
58 
59  foreach ($item->resprocessing as $resprocessing) {
60  foreach ($resprocessing->respcondition as $respcondition) {
61  $conditionvar = $respcondition->getConditionvar();
62  foreach ($conditionvar->order as $order) {
63  switch ($order["field"]) {
64  case "varlte":
65  $upperlimit = $conditionvar->varlte[$order["index"]]->getContent();
66  break;
67  case "vargte":
68  $lowerlimit = $conditionvar->vargte[$order["index"]]->getContent();
69  break;
70  }
71  }
72  foreach ($respcondition->setvar as $setvar) {
73  $points = $setvar->getContent();
74  }
75  if (count($respcondition->displayfeedback)) {
76  foreach ($respcondition->displayfeedback as $feedbackpointer) {
77  if (strlen($feedbackpointer->getLinkrefid())) {
78  foreach ($item->itemfeedback as $ifb) {
79  if (strcmp($ifb->getIdent(), "response_allcorrect") == 0) {
80  // found a feedback for the identifier
81  if (count($ifb->material)) {
82  foreach ($ifb->material as $material) {
83  $feedbacksgeneric[1] = $material;
84  }
85  }
86  if ((count($ifb->flow_mat) > 0)) {
87  foreach ($ifb->flow_mat as $fmat) {
88  if (count($fmat->material)) {
89  foreach ($fmat->material as $material) {
90  $feedbacksgeneric[1] = $material;
91  }
92  }
93  }
94  }
95  } elseif (strcmp($ifb->getIdent(), "response_onenotcorrect") == 0) {
96  // found a feedback for the identifier
97  if (count($ifb->material)) {
98  foreach ($ifb->material as $material) {
99  $feedbacksgeneric[0] = $material;
100  }
101  }
102  if ((count($ifb->flow_mat) > 0)) {
103  foreach ($ifb->flow_mat as $fmat) {
104  if (count($fmat->material)) {
105  foreach ($fmat->material as $material) {
106  $feedbacksgeneric[0] = $material;
107  }
108  }
109  }
110  }
111  }
112  }
113  }
114  }
115  }
116  }
117  }
118 
119  $this->addGeneralMetadata($item);
120  $this->object->setTitle($item->getTitle());
121  $this->object->setNrOfTries($item->getMaxattempts());
122  $this->object->setComment($item->getComment());
123  $this->object->setAuthor($item->getAuthor());
124  $this->object->setOwner($ilUser->getId());
125  $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
126  $this->object->setObjId($questionpool_id);
127  $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
128  $this->object->setMaxChars($maxchars);
129  $this->object->setPoints($points);
130  $this->object->setLowerLimit($lowerlimit);
131  $this->object->setUpperLimit($upperlimit);
132  // additional content editing mode information
133  $this->object->setAdditionalContentEditingMode(
135  );
136  $this->object->saveToDb();
137  if (count($item->suggested_solutions)) {
138  foreach ($item->suggested_solutions as $suggested_solution) {
139  $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
140  }
141  $this->object->saveToDb();
142  }
143  foreach ($feedbacksgeneric as $correctness => $material) {
144  $m = $this->object->QTIMaterialToString($material);
145  $feedbacksgeneric[$correctness] = $m;
146  }
147  // handle the import of media objects in XHTML code
148  $questiontext = $this->object->getQuestion();
149  if (is_array($_SESSION["import_mob_xhtml"])) {
150  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
151  include_once "./Services/RTE/classes/class.ilRTE.php";
152  foreach ($_SESSION["import_mob_xhtml"] as $mob) {
153  if ($tst_id > 0) {
154  $importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
155  } else {
156  $importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
157  }
158 
159  $GLOBALS['ilLog']->write(__METHOD__ . ': import mob from dir: ' . $importfile);
160 
161  $media_object =&ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, false);
162  ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
163  $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
164  foreach ($feedbacksgeneric as $correctness => $material) {
165  $feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
166  }
167  }
168  }
169  $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
170  foreach ($feedbacksgeneric as $correctness => $material) {
171  $this->object->feedbackOBJ->importGenericFeedback(
172  $this->object->getId(),
173  $correctness,
175  );
176  }
177  $this->object->saveToDb();
178  if ($tst_id > 0) {
179  $q_1_id = $this->object->getId();
180  $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
181  $tst_object->questions[$question_counter++] = $question_id;
182  $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
183  } else {
184  $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
185  }
186  }
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) ...
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) ...
$response
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.
+ Here is the call graph for this function:

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