ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
assQuestionImport Class Reference

Class for question imports. More...

+ Inheritance diagram for assQuestionImport:
+ Collaboration diagram for assQuestionImport:

Public Member Functions

 __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
 

Protected Member Functions

 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_DEFAULT when no or invalid information is given More...
 

Detailed Description

Class for question imports.

assQuestionImport is a basis class 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.assQuestionImport.php.

Constructor & Destructor Documentation

◆ __construct()

assQuestionImport::__construct (   $a_object)

assQuestionImport constructor

Parameters
object$a_objectThe question object @access public

Definition at line 32 of file class.assQuestionImport.php.

33 {
34 $this->object = $a_object;
35 }

Member Function Documentation

◆ addGeneralMetadata()

assQuestionImport::addGeneralMetadata ( ilQTIItem  $item)
protected

◆ fetchAdditionalContentEditingModeInformation()

assQuestionImport::fetchAdditionalContentEditingModeInformation (   $qtiItem)
finalprotected

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

@final @access protected

Parameters
type$qtiItem
Returns
string $additionalContentEditingMode

Definition at line 262 of file class.assQuestionImport.php.

263 {
264 $additionalContentEditingMode = $qtiItem->getMetadataEntry('additional_cont_edit_mode');
265
266 if (!$this->object->isValidAdditionalContentEditingMode($additionalContentEditingMode)) {
267 $additionalContentEditingMode = assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT;
268 }
269
270 return $additionalContentEditingMode;
271 }
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT
constant for additional content editing mode "default"

References assQuestion\ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT.

Referenced by assClozeTestImport\fromXML(), assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assFlashQuestionImport\fromXML(), assFormulaQuestionImport\fromXML(), assImagemapQuestionImport\fromXML(), assJavaAppletImport\fromXML(), assKprimChoiceImport\fromXML(), assLongMenuImport\fromXML(), assMatchingQuestionImport\fromXML(), assMultipleChoiceImport\fromXML(), assNumericImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assTextQuestionImport\fromXML(), and assTextSubsetImport\fromXML().

+ Here is the caller graph for this function:

◆ fetchIndexFromFeedbackIdent()

assQuestionImport::fetchIndexFromFeedbackIdent (   $feedbackIdent,
  $prefix = 'response_' 
)
protected
Parameters
$feedbackIdent
string$prefix
Returns
int

Reimplemented in assMatchingQuestionImport.

Definition at line 96 of file class.assQuestionImport.php.

97 {
98 return (int) str_replace($prefix, '', $feedbackIdent);
99 }

Referenced by assErrorTextImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), and assTextQuestionImport\fromXML().

+ Here is the caller graph for this function:

◆ fetchLifecycle()

assQuestionImport::fetchLifecycle ( ilQTIItem  $item)
protected
Parameters
ilQTIItem$item
Returns
ilAssQuestionLifecycle

Definition at line 187 of file class.assQuestionImport.php.

188 {
189 try {
191 $item->getMetadataEntry('ilias_lifecycle')
192 );
194 try {
195 $lomLifecycle = new ilAssQuestionLomLifecycle(
196 $item->getMetadataEntry('lifecycle')
197 );
198
200 $lomLifecycle->getMappedIliasLifecycleIdentifer()
201 );
204 }
205 }
206
207 return $lifecycle;
208 }

References Vendor\Package\$e, ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), and ilQTIItem\getMetadataEntry().

Referenced by addGeneralMetadata().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromXML()

assQuestionImport::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 in assClozeTestImport, assErrorTextImport, assFileUploadImport, assFlashQuestionImport, assFormulaQuestionImport, assImagemapQuestionImport, assJavaAppletImport, assKprimChoiceImport, assLongMenuImport, assMatchingQuestionImport, assMultipleChoiceImport, assNumericImport, assOrderingHorizontalImport, assOrderingQuestionImport, assSingleChoiceImport, assTextQuestionImport, and assTextSubsetImport.

Definition at line 165 of file class.assQuestionImport.php.

166 {
167 }

◆ getFeedbackAnswerSpecific()

assQuestionImport::getFeedbackAnswerSpecific ( ilQTIItem  $item,
  $prefix = 'response_' 
)
protected
Parameters
ilQTIItem$item
string$prefix
Returns
array

Definition at line 106 of file class.assQuestionImport.php.

107 {
108 $feedbacks = array();
109
110 foreach ($item->itemfeedback as $ifb) {
111 if ($ifb->getIdent() == 'response_allcorrect' || $ifb->getIdent() == 'response_onenotcorrect') {
112 continue;
113 }
114
115 if ($ifb->getIdent() == $prefix . 'allcorrect' || $ifb->getIdent() == $prefix . 'onenotcorrect') {
116 continue;
117 }
118
119 if (substr($ifb->getIdent(), 0, strlen($prefix)) != $prefix) {
120 continue;
121 }
122
123 $ident = $ifb->getIdent();
124
125 // found a feedback for the identifier
126
127 if (count($ifb->material)) {
128 foreach ($ifb->material as $material) {
129 $feedbacks[$ident] = $material;
130 }
131 }
132
133 if ((count($ifb->flow_mat) > 0)) {
134 foreach ($ifb->flow_mat as $fmat) {
135 if (count($fmat->material)) {
136 foreach ($fmat->material as $material) {
137 $feedbacks[$ident] = $material;
138 }
139 }
140 }
141 }
142 }
143
144 foreach ($feedbacks as $ident => $material) {
145 $m = $this->object->QTIMaterialToString($material);
146 $feedbacks[$ident] = $m;
147 }
148
149 return $feedbacks;
150 }

Referenced by assErrorTextImport\fromXML(), assMatchingQuestionImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), and assTextQuestionImport\fromXML().

+ Here is the caller graph for this function:

◆ getFeedbackGeneric()

assQuestionImport::getFeedbackGeneric (   $item)

Definition at line 37 of file class.assQuestionImport.php.

38 {
39 $feedbacksgeneric = array();
40 foreach ($item->resprocessing as $resprocessing) {
41 foreach ($resprocessing->respcondition as $respcondition) {
42 foreach ($respcondition->displayfeedback as $feedbackpointer) {
43 if (strlen($feedbackpointer->getLinkrefid())) {
44 foreach ($item->itemfeedback as $ifb) {
45 if (strcmp($ifb->getIdent(), "response_allcorrect") == 0) {
46 // found a feedback for the identifier
47 if (count($ifb->material)) {
48 foreach ($ifb->material as $material) {
49 $feedbacksgeneric[1] = $material;
50 }
51 }
52 if ((count($ifb->flow_mat) > 0)) {
53 foreach ($ifb->flow_mat as $fmat) {
54 if (count($fmat->material)) {
55 foreach ($fmat->material as $material) {
56 $feedbacksgeneric[1] = $material;
57 }
58 }
59 }
60 }
61 } elseif (strcmp($ifb->getIdent(), "response_onenotcorrect") == 0) {
62 // found a feedback for the identifier
63 if (count($ifb->material)) {
64 foreach ($ifb->material as $material) {
65 $feedbacksgeneric[0] = $material;
66 }
67 }
68 if ((count($ifb->flow_mat) > 0)) {
69 foreach ($ifb->flow_mat as $fmat) {
70 if (count($fmat->material)) {
71 foreach ($fmat->material as $material) {
72 $feedbacksgeneric[0] = $material;
73 }
74 }
75 }
76 }
77 }
78 }
79 }
80 }
81 }
82 }
83 // handle the import of media objects in XHTML code
84 foreach ($feedbacksgeneric as $correctness => $material) {
85 $m = $this->object->QTIMaterialToString($material);
86 $feedbacksgeneric[$correctness] = $m;
87 }
88 return $feedbacksgeneric;
89 }

Referenced by assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assFlashQuestionImport\fromXML(), assFormulaQuestionImport\fromXML(), and assOrderingHorizontalImport\fromXML().

+ Here is the caller graph for this function:

◆ getQplImportArchivDirectory()

assQuestionImport::getQplImportArchivDirectory ( )
protected

returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir)

Definition at line 213 of file class.assQuestionImport.php.

214 {
215 include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
216 return ilObjQuestionPool::_getImportDirectory() . '/' . $_SESSION["qpl_import_subdir"];
217 }
$_SESSION["AccountId"]
static _getImportDirectory()
get import directory of lm

References $_SESSION, and ilObjQuestionPool\_getImportDirectory().

Referenced by assClozeTestImport\fromXML(), assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assFlashQuestionImport\fromXML(), assImagemapQuestionImport\fromXML(), assJavaAppletImport\fromXML(), assKprimChoiceImport\fromXML(), assLongMenuImport\fromXML(), assMatchingQuestionImport\fromXML(), assMultipleChoiceImport\fromXML(), assNumericImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assTextQuestionImport\fromXML(), and assTextSubsetImport\fromXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTstImportArchivDirectory()

assQuestionImport::getTstImportArchivDirectory ( )
protected

returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir)

Definition at line 222 of file class.assQuestionImport.php.

223 {
224 include_once "./Modules/Test/classes/class.ilObjTest.php";
225 return ilObjTest::_getImportDirectory() . '/' . $_SESSION["tst_import_subdir"];
226 }
static _getImportDirectory()
Get the import directory location of the test.

References $_SESSION, and ilObjTest\_getImportDirectory().

Referenced by assClozeTestImport\fromXML(), assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assFlashQuestionImport\fromXML(), assImagemapQuestionImport\fromXML(), assJavaAppletImport\fromXML(), assKprimChoiceImport\fromXML(), assLongMenuImport\fromXML(), assMatchingQuestionImport\fromXML(), assMultipleChoiceImport\fromXML(), assNumericImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assTextQuestionImport\fromXML(), and assTextSubsetImport\fromXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processNonAbstractedImageReferences()

assQuestionImport::processNonAbstractedImageReferences (   $text,
  $sourceNic 
)
protected

Definition at line 228 of file class.assQuestionImport.php.

229 {
230 $reg = '/<img.*src=".*\\/mm_(\\d+)\\/(.*?)".*>/m';
231 $matches = null;
232
233 if (preg_match_all($reg, $text, $matches)) {
234 for ($i = 0, $max = count($matches[1]); $i < $max; $i++) {
235 $mobSrcId = $matches[1][$i];
236 $mobSrcName = $matches[2][$i];
237 $mobSrcLabel = 'il_' . $sourceNic . '_mob_' . $mobSrcId;
238
239 if (!is_array($_SESSION["import_mob_xhtml"])) {
240 $_SESSION["import_mob_xhtml"] = array();
241 }
242
243 $_SESSION["import_mob_xhtml"][] = array(
244 "mob" => $mobSrcLabel, "uri" => 'objects/' . $mobSrcLabel . '/' . $mobSrcName
245 );
246 }
247 }
248
249 include_once "./Services/RTE/classes/class.ilRTE.php";
250 return ilRTE::_replaceMediaObjectImageSrc($text, 0, $sourceNic);
251 }
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...
$i
Definition: metadata.php:24

References $_SESSION, $i, and ilRTE\_replaceMediaObjectImageSrc().

Referenced by assClozeTestImport\fromXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $object

assQuestionImport::$object

Definition at line 24 of file class.assQuestionImport.php.


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