ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
assQuestionImport Class Reference

Class for question imports. More...

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

Public Member Functions

 assQuestionImport (&$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

 getFeedbackAnswerSpecific (ilQTIItem $item)
 
 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 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.

Member Function Documentation

◆ addGeneralMetadata()

◆ assQuestionImport()

assQuestionImport::assQuestionImport ( $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 }

◆ 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 242 of file class.assQuestionImport.php.

243 {
244 $additionalContentEditingMode = $qtiItem->getMetadataEntry('additional_cont_edit_mode');
245
246 if( !$this->object->isValidAdditionalContentEditingMode($additionalContentEditingMode) )
247 {
248 $additionalContentEditingMode = assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT;
249 }
250
251 return $additionalContentEditingMode;
252 }
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(), assMatchingQuestionImport\fromXML(), assNumericImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assTextQuestionImport\fromXML(), assTextSubsetImport\fromXML(), assKprimChoiceImport\fromXML(), assLongMenuImport\fromXML(), and assMultipleChoiceImport\fromXML().

+ 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, assMatchingQuestionImport, assNumericImport, assOrderingHorizontalImport, assOrderingQuestionImport, assSingleChoiceImport, assTextQuestionImport, and assTextSubsetImport.

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

176 {
177 }

◆ getFeedbackAnswerSpecific()

assQuestionImport::getFeedbackAnswerSpecific ( ilQTIItem  $item)
protected
Parameters
ilQTIItem$item

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

116 {
117 $feedbacks = array();
118
119 foreach ($item->itemfeedback as $ifb)
120 {
121 if( substr($ifb->getIdent(), 0, strlen('response_')) != 'response_' )
122 {
123 continue;
124 }
125
126 $ident = $ifb->getIdent();
127
128 // found a feedback for the identifier
129
130 if (count($ifb->material))
131 {
132 foreach ($ifb->material as $material)
133 {
134 $feedbacks[$ident] = $material;
135 }
136 }
137
138 if ((count($ifb->flow_mat) > 0))
139 {
140 foreach ($ifb->flow_mat as $fmat)
141 {
142 if (count($fmat->material))
143 {
144 foreach ($fmat->material as $material)
145 {
146 $feedbacks[$ident] = $material;
147 }
148 }
149 }
150 }
151 }
152
153 foreach($feedbacks as $ident => $material)
154 {
155 $m = $this->object->QTIMaterialToString($material);
156 $feedbacks[$ident] = $m;
157 }
158
159 return $feedbacks;
160 }

Referenced by assErrorTextImport\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 {
42 foreach ($resprocessing->respcondition as $respcondition)
43 {
44 foreach ($respcondition->displayfeedback as $feedbackpointer)
45 {
46 if (strlen($feedbackpointer->getLinkrefid()))
47 {
48 foreach ($item->itemfeedback as $ifb)
49 {
50 if (strcmp($ifb->getIdent(), "response_allcorrect") == 0)
51 {
52 // found a feedback for the identifier
53 if (count($ifb->material))
54 {
55 foreach ($ifb->material as $material)
56 {
57 $feedbacksgeneric[1] = $material;
58 }
59 }
60 if ((count($ifb->flow_mat) > 0))
61 {
62 foreach ($ifb->flow_mat as $fmat)
63 {
64 if (count($fmat->material))
65 {
66 foreach ($fmat->material as $material)
67 {
68 $feedbacksgeneric[1] = $material;
69 }
70 }
71 }
72 }
73 }
74 else if (strcmp($ifb->getIdent(), "response_onenotcorrect") == 0)
75 {
76 // found a feedback for the identifier
77 if (count($ifb->material))
78 {
79 foreach ($ifb->material as $material)
80 {
81 $feedbacksgeneric[0] = $material;
82 }
83 }
84 if ((count($ifb->flow_mat) > 0))
85 {
86 foreach ($ifb->flow_mat as $fmat)
87 {
88 if (count($fmat->material))
89 {
90 foreach ($fmat->material as $material)
91 {
92 $feedbacksgeneric[0] = $material;
93 }
94 }
95 }
96 }
97 }
98 }
99 }
100 }
101 }
102 }
103 // handle the import of media objects in XHTML code
104 foreach ($feedbacksgeneric as $correctness => $material)
105 {
106 $m = $this->object->QTIMaterialToString($material);
107 $feedbacksgeneric[$correctness] = $m;
108 }
109 return $feedbacksgeneric;
110 }

Referenced by assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), and assFlashQuestionImport\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 190 of file class.assQuestionImport.php.

191 {
192 include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
193 return ilObjQuestionPool::_getImportDirectory() . '/' . $_SESSION["qpl_import_subdir"];
194 }
$_SESSION["AccountId"]
_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(), assMatchingQuestionImport\fromXML(), assNumericImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assTextQuestionImport\fromXML(), assTextSubsetImport\fromXML(), assKprimChoiceImport\fromXML(), and assMultipleChoiceImport\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 199 of file class.assQuestionImport.php.

200 {
201 include_once "./Modules/Test/classes/class.ilObjTest.php";
202 return ilObjTest::_getImportDirectory() . '/' . $_SESSION["tst_import_subdir"];
203 }
_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(), assMatchingQuestionImport\fromXML(), assNumericImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assTextQuestionImport\fromXML(), assTextSubsetImport\fromXML(), assKprimChoiceImport\fromXML(), and assMultipleChoiceImport\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 205 of file class.assQuestionImport.php.

206 {
207 $reg = '/<img.*src=".*\\/mm_(\\d+)\\/(.*?)".*>/m';
208 $matches = null;
209
210 if( preg_match_all($reg, $text, $matches) )
211 {
212 for($i = 0, $max = count($matches[1]); $i < $max; $i++)
213 {
214 $mobSrcId = $matches[1][$i];
215 $mobSrcName = $matches[2][$i];
216 $mobSrcLabel = 'il_'.$sourceNic.'_mob_'.$mobSrcId;
217
218 if (!is_array($_SESSION["import_mob_xhtml"]))
219 {
220 $_SESSION["import_mob_xhtml"] = array();
221 }
222
223 $_SESSION["import_mob_xhtml"][] = array(
224 "mob" => $mobSrcLabel, "uri" => 'objects/'.$mobSrcLabel.'/'.$mobSrcName
225 );
226 }
227 }
228
229 include_once "./Services/RTE/classes/class.ilRTE.php";
230 return ilRTE::_replaceMediaObjectImageSrc($text, 0, $sourceNic);
231 }
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...
$text

References $_SESSION, $text, 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: