ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assLongMenuImport Class Reference
+ Inheritance diagram for assLongMenuImport:
+ Collaboration diagram for assLongMenuImport:

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...
 

Data Fields

 $object
 
- Data Fields inherited from assQuestionImport
 $object
 

Private Member Functions

 getIdFromGapIdent ($ident)
 

Additional Inherited Members

- 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

Definition at line 5 of file class.assLongMenuImport.php.

Member Function Documentation

◆ fromXML()

assLongMenuImport::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 @access public

Reimplemented from assQuestionImport.

Definition at line 9 of file class.assLongMenuImport.php.

10 {
11 global $ilUser;
12
13 unset($_SESSION["import_mob_xhtml"]);
14
15 $presentation = $item->getPresentation();
16 $duration = $item->getDuration();
17 $questiontext = array();
18 $seperate_question_field = $item->getMetadataEntry("question");
19 $clozetext = array();
20 $now = getdate();
21 $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
22 $answers = array();
23 $correct_answers = array();
24 $presentation = $item->getPresentation();
25 $gap_types = json_decode($item->getMetadataEntry("gapTypes"));
26 foreach ($presentation->order as $entry) {
27 switch ($entry["type"]) {
28 case "material":
29
30 $material = $presentation->material[$entry["index"]];
31 if (preg_match('/\[Longmenu \d\]/', $this->object->QTIMaterialToString($material))) {
32 $this->object->setLongMenuTextValue($this->object->QTIMaterialToString($material));
33 } else {
34 $this->object->setQuestion($this->object->QTIMaterialToString($material));
35 }
36
37
38 break;
39 }
40 }
41 foreach ($item->resprocessing as $resprocessing) {
42 foreach ($resprocessing->respcondition as $respcondition) {
43 $correctness = 1;
44 $conditionvar = $respcondition->getConditionvar();
45 foreach ($conditionvar->order as $order) {
46 switch ($order["field"]) {
47 case "varequal":
48 $equals = $conditionvar->varequal[$order["index"]]->getContent();
49 $gapident = $conditionvar->varequal[$order["index"]]->getRespident();
50 $id = $this->getIdFromGapIdent($gapident);
51 $answers[$id][] = $equals;
52 break;
53 }
54 }
55 foreach ($respcondition->setvar as $setvar) {
56 if (strcmp($gapident, "") != 0) {
57 if ($setvar->getContent() > 0) {
58 $id = $this->getIdFromGapIdent($gapident);
59 $correct_answers[$id][0][] = $equals;
60 $correct_answers[$id][1] = $setvar->getContent();
61 if (is_array($gap_types) && key_exists($id, $gap_types)) {
62 $correct_answers[$id][2] = $gap_types[$id];
63 }
64 }
65 }
66 }
67 if (count($respcondition->displayfeedback)) {
68 foreach ($respcondition->displayfeedback as $feedbackpointer) {
69 if (strlen($feedbackpointer->getLinkrefid())) {
70 foreach ($item->itemfeedback as $ifb) {
71 if (strcmp($ifb->getIdent(), "response_allcorrect") == 0) {
72 // found a feedback for the identifier
73 if (count($ifb->material)) {
74 foreach ($ifb->material as $material) {
75 $feedbacksgeneric[1] = $material;
76 }
77 }
78 if ((count($ifb->flow_mat) > 0)) {
79 foreach ($ifb->flow_mat as $fmat) {
80 if (count($fmat->material)) {
81 foreach ($fmat->material as $material) {
82 $feedbacksgeneric[1] = $material;
83 }
84 }
85 }
86 }
87 } elseif (strcmp($ifb->getIdent(), "response_onenotcorrect") == 0) {
88 // found a feedback for the identifier
89 if (count($ifb->material)) {
90 foreach ($ifb->material as $material) {
91 $feedbacksgeneric[0] = $material;
92 }
93 }
94 if ((count($ifb->flow_mat) > 0)) {
95 foreach ($ifb->flow_mat as $fmat) {
96 if (count($fmat->material)) {
97 foreach ($fmat->material as $material) {
98 $feedbacksgeneric[0] = $material;
99 }
100 }
101 }
102 }
103 } else {
104 // found a feedback for the identifier
105 if (count($ifb->material)) {
106 foreach ($ifb->material as $material) {
107 $feedbacks[$ifb->getIdent()] = $material;
108 }
109 }
110 if ((count($ifb->flow_mat) > 0)) {
111 foreach ($ifb->flow_mat as $fmat) {
112 if (count($fmat->material)) {
113 foreach ($fmat->material as $material) {
114 $feedbacks[$ifb->getIdent()] = $material;
115 }
116 }
117 }
118 }
119 }
120 }
121 }
122 }
123 }
124 }
125 }
126
127 $sum = 0;
128 foreach ($correct_answers as $row) {
129 $sum += $row[1];
130 }
131 $this->object->setAnswers($answers);
132 // handle the import of media objects in XHTML code
133 if (count($feedbacks) > 0) {
134 foreach ($feedbacks as $ident => $material) {
135 $m = $this->object->QTIMaterialToString($material);
136 $feedbacks[$ident] = $m;
137 }
138 }
139 if (count($feedbacksgeneric) > 0) {
140 foreach ($feedbacksgeneric as $correctness => $material) {
141 $m = $this->object->QTIMaterialToString($material);
142 $feedbacksgeneric[$correctness] = $m;
143 }
144 }
145
146 $this->addGeneralMetadata($item);
147 $this->object->setTitle($item->getTitle());
148 $this->object->setNrOfTries($item->getMaxattempts());
149 $this->object->setComment($item->getComment());
150 $this->object->setAuthor($item->getAuthor());
151 $this->object->setOwner($ilUser->getId());
152 $this->object->setObjId($questionpool_id);
153 $this->object->setMinAutoComplete($item->getMetadataEntry("minAutoCompleteLength"));
154 $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
155 $this->object->setCorrectAnswers($correct_answers);
156 $this->object->setPoints($sum);
157 // additional content editing mode information
158 $this->object->setAdditionalContentEditingMode(
160 );
161 $this->object->saveToDb();
162
163 if (count($feedbacks) > 0) {
164 foreach ($feedbacks as $ident => $material) {
165 $this->object->feedbackOBJ->importSpecificAnswerFeedback(
166 $this->object->getId(),
167 $ident,
169 );
170 }
171 }
172 if (count($feedbacksgeneric) > 0) {
173 foreach ($feedbacksgeneric as $correctness => $material) {
174 $this->object->feedbackOBJ->importGenericFeedback(
175 $this->object->getId(),
176 $correctness,
178 );
179 }
180 }
181 $this->object->saveToDb();
182 if (count($item->suggested_solutions)) {
183 foreach ($item->suggested_solutions as $suggested_solution) {
184 $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
185 }
186 $this->object->saveToDb();
187 }
188
189 if ($tst_id > 0) {
190 $q_1_id = $this->object->getId();
191 $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
192 $tst_object->questions[$question_counter++] = $question_id;
193 $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
194 } else {
195 $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
196 }
197 }
sprintf('%.4f', $callTime)
$_SESSION["AccountId"]
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
addGeneralMetadata(ilQTIItem $item)
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...
if(!array_key_exists('StateId', $_REQUEST)) $id
$ilUser
Definition: imgupload.php:18

References $_SESSION, $id, $ilUser, $m, $row, ilRTE\_replaceMediaObjectImageSrc(), assQuestionImport\addGeneralMetadata(), assQuestionImport\fetchAdditionalContentEditingModeInformation(), getIdFromGapIdent(), and sprintf.

+ Here is the call graph for this function:

◆ getIdFromGapIdent()

assLongMenuImport::getIdFromGapIdent (   $ident)
private

Definition at line 199 of file class.assLongMenuImport.php.

200 {
201 $id = preg_split('/_/', $ident);
202 return $id[1] -1;
203 }

References $id.

Referenced by fromXML().

+ Here is the caller graph for this function:

Field Documentation

◆ $object

assLongMenuImport::$object

Definition at line 7 of file class.assLongMenuImport.php.


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