ILIAS  release_7 Revision v7.30-3-g800a261c036
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...
 
 getQuestionId ()
 
 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_RTE 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 public

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

29  {
30  $this->object = $a_object;
31  }

Member Function Documentation

◆ addGeneralMetadata()

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

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

References fetchLifecycle(), and ilQTIItem\getMetadataEntry().

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

174  {
175  if ($item->getMetadataEntry('externalID')) {
176  $this->object->setExternalId($item->getMetadataEntry('externalID'));
177  } else {
178  $this->object->setExternalId($item->getMetadataEntry('externalId'));
179  }
180 
181  $this->object->setLifecycle($this->fetchLifecycle($item));
182  }
getMetadataEntry($a_label)
fetchLifecycle(ilQTIItem $item)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchAdditionalContentEditingModeInformation()

assQuestionImport::fetchAdditionalContentEditingModeInformation (   $qtiItem)
finalprotected

fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_CONTENT_EDITING_MODE_RTE when no or invalid information is given

protected

Parameters
type$qtiItem
Returns
string $additionalContentEditingMode

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

References assQuestion\ADDITIONAL_CONTENT_EDITING_MODE_RTE.

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

264  {
265  $additionalContentEditingMode = $qtiItem->getMetadataEntry('additional_cont_edit_mode');
266 
267  if (!$this->object->isValidAdditionalContentEditingMode($additionalContentEditingMode)) {
268  $additionalContentEditingMode = assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_RTE;
269  }
270 
271  return $additionalContentEditingMode;
272  }
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
constant for additional content editing mode "default"
+ Here is the caller graph for this function:

◆ fetchIndexFromFeedbackIdent()

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

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

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

98  {
99  return (int) str_replace($prefix, '', $feedbackIdent);
100  }
+ Here is the caller graph for this function:

◆ fetchLifecycle()

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

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

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

Referenced by addGeneralMetadata().

189  {
190  try {
192  $item->getMetadataEntry('ilias_lifecycle')
193  );
195  try {
196  $lomLifecycle = new ilAssQuestionLomLifecycle(
197  $item->getMetadataEntry('lifecycle')
198  );
199 
201  $lomLifecycle->getMappedIliasLifecycleIdentifer()
202  );
205  }
206  }
207 
208  return $lifecycle;
209  }
getMetadataEntry($a_label)
+ 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 public

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

167  {
168  }

◆ getFeedbackAnswerSpecific()

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

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

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

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

◆ getFeedbackGeneric()

assQuestionImport::getFeedbackGeneric (   $item)

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

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

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

References $_SESSION, and ilObjQuestionPool\_getImportDirectory().

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

215  {
216  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
217  return ilObjQuestionPool::_getImportDirectory() . '/' . $_SESSION["qpl_import_subdir"];
218  }
$_SESSION["AccountId"]
static _getImportDirectory()
get import directory of lm
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionId()

assQuestionImport::getQuestionId ( )

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

33  : int
34  {
35  return (int) $this->object->getId();
36  }

◆ getTstImportArchivDirectory()

assQuestionImport::getTstImportArchivDirectory ( )
protected

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

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

References $_SESSION, and ilObjTest\_getImportDirectory().

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

224  {
225  include_once "./Modules/Test/classes/class.ilObjTest.php";
226  return ilObjTest::_getImportDirectory() . '/' . $_SESSION["tst_import_subdir"];
227  }
$_SESSION["AccountId"]
static _getImportDirectory()
Get the import directory location of the test.
+ 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 229 of file class.assQuestionImport.php.

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

Referenced by assClozeTestImport\fromXML().

230  {
231  $reg = '/<img.*src=".*\\/mm_(\\d+)\\/(.*?)".*>/m';
232  $matches = null;
233 
234  if (preg_match_all($reg, $text, $matches)) {
235  for ($i = 0, $max = count($matches[1]); $i < $max; $i++) {
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  $_SESSION["import_mob_xhtml"] = array();
242  }
243 
244  $_SESSION["import_mob_xhtml"][] = array(
245  "mob" => $mobSrcLabel, "uri" => 'objects/' . $mobSrcLabel . '/' . $mobSrcName
246  );
247  }
248  }
249 
250  include_once "./Services/RTE/classes/class.ilRTE.php";
251  return ilRTE::_replaceMediaObjectImageSrc($text, 0, $sourceNic);
252  }
$_SESSION["AccountId"]
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $object

assQuestionImport::$object

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


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