ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
class.assQuestionImport.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
5 
16 {
24  var $object;
25 
32  function assQuestionImport(&$a_object)
33  {
34  $this->object =& $a_object;
35  }
36 
37  function getFeedbackGeneric($item)
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  }
111 
115  protected function getFeedbackAnswerSpecific(ilQTIItem $item)
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  }
161 
175  function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
176  {
177  }
178 
182  protected function addGeneralMetadata(ilQTIItem $item)
183  {
184  $this->object->setExternalId($item->getMetadataEntry('externalID'));
185  }
186 
190  protected function getQplImportArchivDirectory()
191  {
192  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
193  return ilObjQuestionPool::_getImportDirectory() . '/' . $_SESSION["qpl_import_subdir"];
194  }
195 
199  protected function getTstImportArchivDirectory()
200  {
201  include_once "./Modules/Test/classes/class.ilObjTest.php";
202  return ilObjTest::_getImportDirectory() . '/' . $_SESSION["tst_import_subdir"];
203  }
204 
205  protected function processNonAbstractedImageReferences($text, $sourceNic)
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  }
232 
242  final protected function fetchAdditionalContentEditingModeInformation($qtiItem)
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  }
253 }
254 
255 ?>
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
addGeneralMetadata(ilQTIItem $item)
_getImportDirectory()
Get the import directory location of the test.
processNonAbstractedImageReferences($text, $sourceNic)
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
getQplImportArchivDirectory()
returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir) ...
getMetadataEntry($a_label)
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
Creates a question from a QTI file.
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...
getFeedbackAnswerSpecific(ilQTIItem $item)
_getImportDirectory()
get import directory of lm
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT
constant for additional content editing mode "default"
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
Class for question imports.
assQuestionImport(&$a_object)
assQuestionImport constructor