ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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)
 
 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()

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

265 {
266 $additionalContentEditingMode = $qtiItem->getMetadataEntry('additional_cont_edit_mode');
267
268 if( !$this->object->isValidAdditionalContentEditingMode($additionalContentEditingMode) )
269 {
270 $additionalContentEditingMode = assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT;
271 }
272
273 return $additionalContentEditingMode;
274 }
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 117 of file class.assQuestionImport.php.

118 {
119 return (int)str_replace($prefix, '', $feedbackIdent);
120 }

Referenced by assErrorTextImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), and assTextQuestionImport\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, assKprimChoiceImport, assLongMenuImport, assMatchingQuestionImport, assMultipleChoiceImport, assNumericImport, assOrderingHorizontalImport, assOrderingQuestionImport, assSingleChoiceImport, assTextQuestionImport, and assTextSubsetImport.

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

198 {
199 }

◆ getFeedbackAnswerSpecific()

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

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

128 {
129 $feedbacks = array();
130
131 foreach ($item->itemfeedback as $ifb)
132 {
133 if( $ifb->getIdent() == 'response_allcorrect' || $ifb->getIdent() == 'response_onenotcorrect' )
134 {
135 continue;
136 }
137
138 if( $ifb->getIdent() == $prefix.'allcorrect' || $ifb->getIdent() == $prefix.'onenotcorrect' )
139 {
140 continue;
141 }
142
143 if( substr($ifb->getIdent(), 0, strlen($prefix)) != $prefix )
144 {
145 continue;
146 }
147
148 $ident = $ifb->getIdent();
149
150 // found a feedback for the identifier
151
152 if (count($ifb->material))
153 {
154 foreach ($ifb->material as $material)
155 {
156 $feedbacks[$ident] = $material;
157 }
158 }
159
160 if ((count($ifb->flow_mat) > 0))
161 {
162 foreach ($ifb->flow_mat as $fmat)
163 {
164 if (count($fmat->material))
165 {
166 foreach ($fmat->material as $material)
167 {
168 $feedbacks[$ident] = $material;
169 }
170 }
171 }
172 }
173 }
174
175 foreach($feedbacks as $ident => $material)
176 {
177 $m = $this->object->QTIMaterialToString($material);
178 $feedbacks[$ident] = $m;
179 }
180
181 return $feedbacks;
182 }

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 {
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(), 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 212 of file class.assQuestionImport.php.

213 {
214 include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
215 return ilObjQuestionPool::_getImportDirectory() . '/' . $_SESSION["qpl_import_subdir"];
216 }
$_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(), 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 221 of file class.assQuestionImport.php.

222 {
223 include_once "./Modules/Test/classes/class.ilObjTest.php";
224 return ilObjTest::_getImportDirectory() . '/' . $_SESSION["tst_import_subdir"];
225 }
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(), 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 227 of file class.assQuestionImport.php.

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