24 include_once(
"./Services/Xml/classes/class.ilSaxParser.php");
25 include_once
'Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/class.ilAssQuestionTypeList.php';
27 define (
"IL_MO_PARSE_QTI", 1);
28 define (
"IL_MO_VERIFY_QTI", 2);
124 parent::ilSaxParser($a_xml_file);
126 $this->qpl_id = $a_qpl_id;
127 $this->import_idents = array();
128 if (is_array($a_import_idents))
130 $this->import_idents =& $a_import_idents;
134 $this->hasRootElement = FALSE;
135 $this->import_mapping = array();
136 $this->assessments = array();
138 $this->section = NULL;
139 $this->path = array();
140 $this->items = array();
142 $this->depth = array();
143 $this->do_nothing = FALSE;
144 $this->qti_element =
"";
145 $this->in_presentation = FALSE;
146 $this->in_objectives = FALSE;
147 $this->in_reponse = FALSE;
148 $this->render_type = NULL;
149 $this->render_hotspot = NULL;
150 $this->response_label = NULL;
151 $this->material = NULL;
152 $this->response = NULL;
153 $this->assessmentcontrol = NULL;
154 $this->objectives = NULL;
155 $this->matimage = NULL;
156 $this->resprocessing = NULL;
157 $this->outcomes = NULL;
158 $this->decvar = NULL;
159 $this->respcondition = NULL;
160 $this->setvar = NULL;
161 $this->displayfeedback = NULL;
162 $this->itemfeedback = NULL;
163 $this->flow_mat = array();
164 $this->question_counter = 1;
166 $this->gap_index = 0;
167 $this->presentation = NULL;
168 $this->mattext = NULL;
169 $this->matapplet = NULL;
170 $this->sametag = FALSE;
171 $this->in_assessment = FALSE;
172 $this->characterbuffer =
"";
173 $this->metadata = array(
"label" =>
"",
"entry" =>
"");
178 $this->tst_object =& $a_tst_object;
179 if (is_object($a_tst_object))
181 $this->tst_id = $this->tst_object->getId();
187 $this->parser_mode = $a_mode;
188 $this->founditems = array();
189 $this->verifyroot =
false;
190 $this->verifyqticomment = 0;
191 $this->verifymetadatafield = 0;
192 $this->verifyfieldlabel = 0;
193 $this->verifyfieldentry = 0;
194 $this->verifyfieldlabeltext =
"";
195 $this->verifyfieldentrytext =
"";
196 $this->question_counter = 1;
206 xml_set_object($a_xml_parser,$this);
207 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
208 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
213 $this->question_counter = 1;
214 parent::startParsing();
220 if ($this->depth[$a_xml_parser] > 0)
222 return $this->path[$this->depth[$a_xml_parser]-1];
235 switch ($this->parser_mode)
251 if ($this->do_nothing)
return;
252 $this->sametag = FALSE;
253 $this->characterbuffer =
"";
254 $this->depth[$a_xml_parser]++;
255 $this->path[$this->depth[$a_xml_parser]] = strtolower($a_name);
256 $this->qti_element = $a_name;
258 switch (strtolower($a_name))
261 include_once (
"./Services/QTI/classes/class.ilQTIAssessment.php");
263 $this->in_assessment = TRUE;
264 if (is_array($a_attribs))
266 foreach ($a_attribs as $attribute => $value)
268 switch (strtolower($attribute))
280 case "assessmentcontrol":
281 include_once (
"./Services/QTI/classes/class.ilQTIAssessmentcontrol.php");
283 if (is_array($a_attribs))
285 foreach ($a_attribs as $attribute => $value)
287 switch (strtolower($attribute))
289 case "solutionswitch":
290 $this->assessmentcontrol->setSolutionswitch($value);
293 $this->assessmentcontrol->setHintswitch($value);
295 case "feedbackswitch":
296 $this->assessmentcontrol->setFeedbackswitch($value);
303 include_once (
"./Services/QTI/classes/class.ilQTIObjectives.php");
305 $this->in_objectives = TRUE;
307 case 'presentation_material':
308 require_once
'Services/QTI/classes/class.ilQTIPresentationMaterial.php';
310 $this->in_prensentation_material = TRUE;
313 include_once (
"./Services/QTI/classes/class.ilQTISection.php");
317 $this->in_itemmetadata = TRUE;
319 case "qtimetadatafield":
320 $this->metadata = array(
"label" =>
"",
"entry" =>
"");
323 include_once (
"./Services/QTI/classes/class.ilQTIFlow.php");
327 include_once (
"./Services/QTI/classes/class.ilQTIFlowMat.php");
331 include_once (
"./Services/QTI/classes/class.ilQTIItemfeedback.php");
333 if (is_array($a_attribs))
335 foreach ($a_attribs as $attribute => $value)
337 switch (strtolower($attribute))
340 $this->itemfeedback->setIdent($value);
343 $this->itemfeedback->setView($value);
349 case "displayfeedback":
350 include_once (
"./Services/QTI/classes/class.ilQTIDisplayfeedback.php");
352 if (is_array($a_attribs))
354 foreach ($a_attribs as $attribute => $value)
356 switch (strtolower($attribute))
359 $this->displayfeedback->setFeedbacktype($value);
362 $this->displayfeedback->setLinkrefid($value);
369 include_once (
"./Services/QTI/classes/class.ilQTISetvar.php");
371 if (is_array($a_attribs))
373 foreach ($a_attribs as $attribute => $value)
375 switch (strtolower($attribute))
378 $this->setvar->setAction($value);
381 $this->setvar->setVarname($value);
388 include_once (
"./Services/QTI/classes/class.ilQTIConditionvar.php");
392 if ($this->conditionvar != NULL)
394 $this->conditionvar->addNot();
398 if ($this->conditionvar != NULL)
400 $this->conditionvar->addAnd();
404 if ($this->conditionvar != NULL)
406 $this->conditionvar->addOr();
410 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
412 if (is_array($a_attribs))
414 foreach ($a_attribs as $attribute => $value)
416 switch (strtolower($attribute))
419 $this->responsevar->setCase($value);
422 $this->responsevar->setRespident($value);
425 $this->responsevar->setIndex($value);
432 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
434 if (is_array($a_attribs))
436 foreach ($a_attribs as $attribute => $value)
438 switch (strtolower($attribute))
441 $this->responsevar->setRespident($value);
444 $this->responsevar->setIndex($value);
451 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
453 if (is_array($a_attribs))
455 foreach ($a_attribs as $attribute => $value)
457 switch (strtolower($attribute))
460 $this->responsevar->setRespident($value);
463 $this->responsevar->setIndex($value);
470 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
472 if (is_array($a_attribs))
474 foreach ($a_attribs as $attribute => $value)
476 switch (strtolower($attribute))
479 $this->responsevar->setRespident($value);
482 $this->responsevar->setIndex($value);
489 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
491 if (is_array($a_attribs))
493 foreach ($a_attribs as $attribute => $value)
495 switch (strtolower($attribute))
498 $this->responsevar->setRespident($value);
501 $this->responsevar->setIndex($value);
508 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
510 if (is_array($a_attribs))
512 foreach ($a_attribs as $attribute => $value)
514 switch (strtolower($attribute))
517 $this->responsevar->setRespident($value);
520 $this->responsevar->setSetmatch($value);
523 $this->responsevar->setIndex($value);
530 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
532 if (is_array($a_attribs))
534 foreach ($a_attribs as $attribute => $value)
536 switch (strtolower($attribute))
539 $this->responsevar->setRespident($value);
542 $this->responsevar->setAreatype($value);
545 $this->responsevar->setIndex($value);
552 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
554 if (is_array($a_attribs))
556 foreach ($a_attribs as $attribute => $value)
558 switch (strtolower($attribute))
561 $this->responsevar->setCase($value);
564 $this->responsevar->setRespident($value);
567 $this->responsevar->setIndex($value);
573 case "respcondition":
574 include_once(
"./Services/QTI/classes/class.ilQTIRespcondition.php");
576 if (is_array($a_attribs))
578 foreach ($a_attribs as $attribute => $value)
580 switch (strtolower($attribute))
583 $this->respcondition->setContinue($value);
586 $this->respcondition->setTitle($value);
593 include_once(
"./Services/QTI/classes/class.ilQTIOutcomes.php");
597 include_once(
"./Services/QTI/classes/class.ilQTIDecvar.php");
599 if (is_array($a_attribs))
601 foreach ($a_attribs as $attribute => $value)
603 switch (strtolower($attribute))
606 $this->decvar->setVarname($value);
609 $this->decvar->setVartype($value);
612 $this->decvar->setDefaultval($value);
615 $this->decvar->setMinvalue($value);
618 $this->decvar->setMaxvalue($value);
621 $this->decvar->setMembers($value);
624 $this->decvar->setCutvalue($value);
631 include_once(
"./Services/QTI/classes/class.ilQTIMatimage.php");
633 if (is_array($a_attribs))
635 foreach ($a_attribs as $attribute => $value)
637 switch (strtolower($attribute))
640 $this->matimage->setImagetype($value);
643 $this->matimage->setLabel($value);
646 $this->matimage->setHeight($value);
649 $this->matimage->setWidth($value);
652 $this->matimage->setUri($value);
655 $this->matimage->setEmbedded($value);
658 $this->matimage->setX0($value);
661 $this->matimage->setY0($value);
664 $this->matimage->setEntityref($value);
669 if (!$this->matimage->getEmbedded() && strlen($this->matimage->getUri()))
671 $this->matimage->setContent(@file_get_contents(dirname($this->xml_file) .
'/'. $this->matimage->getUri()));
675 include_once(
"./Services/QTI/classes/class.ilQTIMaterial.php");
677 $this->material->setFlow($this->flow);
678 if (is_array($a_attribs))
680 foreach ($a_attribs as $attribute => $value)
682 switch (strtolower($attribute))
685 $this->material->setLabel($value);
692 include_once (
"./Services/QTI/classes/class.ilQTIMattext.php");
694 if (is_array($a_attribs))
696 foreach ($a_attribs as $attribute => $value)
698 switch (strtolower($attribute))
701 $this->mattext->setTexttype($value);
704 $this->mattext->setLabel($value);
707 $this->mattext->setCharset($value);
710 $this->mattext->setUri($value);
713 $this->mattext->setXmlspace($value);
716 $this->mattext->setXmllang($value);
719 $this->mattext->setEntityref($value);
722 $this->mattext->setHeight($value);
725 $this->mattext->setWidth($value);
728 $this->mattext->setX0($value);
731 $this->mattext->setY0($value);
738 include_once (
"./Services/QTI/classes/class.ilQTIMatapplet.php");
740 if (is_array($a_attribs))
742 foreach ($a_attribs as $attribute => $value)
744 switch (strtolower($attribute))
747 $this->matapplet->setLabel($value);
750 $this->matapplet->setUri($value);
753 $this->matapplet->setY0($value);
756 $this->matapplet->setHeight($value);
759 $this->matapplet->setWidth($value);
762 $this->matapplet->setX0($value);
765 $this->matapplet->setEmbedded($value);
768 $this->matapplet->setEntityref($value);
774 case "questestinterop":
775 $this->hasRootElement = TRUE;
785 $this->
assessment->addSection($this->section);
787 $this->section = NULL;
790 $this->in_presentation = TRUE;
791 include_once (
"./Services/QTI/classes/class.ilQTIPresentation.php");
794 case "response_label":
795 if ($this->render_type != NULL)
797 include_once(
"./Services/QTI/classes/class.ilQTIResponseLabel.php");
799 foreach ($a_attribs as $attribute => $value)
801 switch (strtolower($attribute))
804 $this->response_label->setRshuffle($value);
807 $this->response_label->setRarea($value);
810 $this->response_label->setRrange($value);
813 $this->response_label->setLabelrefid($value);
816 $this->response_label->setIdent($value);
819 $this->response_label->setMatchGroup($value);
822 $this->response_label->setMatchMax($value);
828 case "render_choice":
829 if ($this->in_response)
831 include_once(
"./Services/QTI/classes/class.ilQTIRenderChoice.php");
833 foreach ($a_attribs as $attribute => $value)
835 switch (strtolower($attribute))
838 $this->render_type->setShuffle($value);
844 case "render_hotspot":
845 if ($this->in_response)
847 include_once(
"./Services/QTI/classes/class.ilQTIRenderHotspot.php");
849 foreach ($a_attribs as $attribute => $value)
851 switch (strtolower($attribute))
854 $this->render_type->setShuffle($value);
857 $this->render_type->setMinnumber($value);
860 $this->render_type->setMaxnumber($value);
867 if ($this->in_response)
869 include_once(
"./Services/QTI/classes/class.ilQTIRenderFib.php");
871 foreach ($a_attribs as $attribute => $value)
873 switch (strtolower($attribute))
876 $this->render_type->setEncoding($value);
879 $this->render_type->setFibtype($value);
882 $this->render_type->setRows($value);
885 $this->render_type->setMaxchars($value);
888 $this->render_type->setPrompt($value);
891 $this->render_type->setColumns($value);
894 $this->render_type->setCharset($value);
897 $this->render_type->setMaxnumber($value);
900 $this->render_type->setMinnumber($value);
919 include_once
"./Services/QTI/classes/class.ilQTIResponse.php";
920 switch (strtolower($a_name))
938 $this->in_response = TRUE;
940 $this->response->setFlow($this->flow);
941 if (is_array($a_attribs))
943 foreach ($a_attribs as $attribute => $value)
945 switch (strtolower($attribute))
948 $this->response->setIdent($value);
951 $this->response->setRTiming($value);
954 $this->response->setRCardinality($value);
957 $this->response->setNumtype($value);
964 include_once(
"./Services/QTI/classes/class.ilQTIItem.php");
965 $this->gap_index = 0;
966 $this->item =& $this->items[array_push($this->items,
new ilQTIItem())-1];
967 if (is_array($a_attribs))
969 foreach ($a_attribs as $attribute => $value)
971 switch (strtolower($attribute))
974 $this->item->setIdent($value);
975 $this->item->setIliasSourceNic(
978 if (count($this->import_idents) > 0)
980 if (!in_array($value, $this->import_idents))
982 $this->do_nothing = TRUE;
987 $this->item->setTitle($value);
990 $this->item->setMaxattempts($value);
996 case "resprocessing":
997 include_once(
"./Services/QTI/classes/class.ilQTIResprocessing.php");
999 if (is_array($a_attribs))
1001 foreach ($a_attribs as $attribute => $value)
1003 switch (strtolower($attribute))
1006 $this->resprocessing->setScoremodel($value);
1020 switch ($this->parser_mode)
1036 if (($this->do_nothing) && (strcmp(strtolower($a_name),
"item") != 0))
return;
1037 switch (strtolower($a_name))
1040 if (is_object($this->tst_object))
1042 $this->tst_object->fromXML($this->
assessment);
1044 $this->in_assessment = FALSE;
1046 case "assessmentcontrol":
1047 $this->
assessment->addAssessmentcontrol($this->assessmentcontrol);
1048 $this->assessmentcontrol = NULL;
1051 if (strcmp(strtolower($this->
getParent($a_xml_parser)),
"assessment") == 0)
1053 $this->
assessment->addObjectives($this->objectives);
1055 $this->in_objectives = FALSE;
1057 case 'presentation_material':
1058 $this->
assessment->setPresentationMaterial($this->prensentation_material);
1059 $this->in_prensentation_material = FALSE;
1061 case "itemmetadata":
1062 $this->in_itemmetadata = FALSE;
1064 case "qtimetadatafield":
1066 switch ($this->metadata[
"label"])
1068 case "ILIAS_VERSION":
1069 if ($this->item != NULL)
1071 $this->item->setIliasSourceVersion(
1076 case "QUESTIONTYPE":
1077 if ($this->item != NULL)
1079 $this->item->setQuestiontype($this->metadata[
"entry"]);
1083 if ($this->item != NULL)
1085 $this->item->setAuthor($this->metadata[
"entry"]);
1088 if ($this->item != NULL)
1090 $this->item->addMetadata($this->metadata);
1094 if ($this->in_assessment)
1096 $this->
assessment->addQtiMetadata($this->metadata);
1098 $this->metadata = array(
"label" =>
"",
"entry" =>
"");
1104 if (count($this->flow_mat))
1106 $flow_mat = array_pop($this->flow_mat);
1107 if (count($this->flow_mat))
1109 $this->flow_mat[count($this->flow_mat)-1]->addFlow_mat($flow_mat);
1111 else if($this->in_prensentation_material)
1113 $this->prensentation_material->addFlowMat($flow_mat);
1115 else if ($this->itemfeedback != NULL)
1117 $this->itemfeedback->addFlow_mat($flow_mat);
1119 else if ($this->response_label != NULL)
1121 $this->response_label->addFlow_mat($flow_mat);
1125 case "itemfeedback":
1126 if ($this->item != NULL)
1128 if ($this->itemfeedback != NULL)
1130 $this->item->addItemfeedback($this->itemfeedback);
1133 $this->itemfeedback = NULL;
1135 case "displayfeedback":
1136 if ($this->respcondition != NULL)
1138 if ($this->displayfeedback != NULL)
1140 $this->respcondition->addDisplayfeedback($this->displayfeedback);
1143 $this->displayfeedback = NULL;
1146 if ($this->respcondition != NULL)
1148 if ($this->setvar != NULL)
1150 $this->respcondition->addSetvar($this->setvar);
1153 $this->setvar = NULL;
1155 case "conditionvar":
1156 if ($this->respcondition != NULL)
1158 $this->respcondition->setConditionvar($this->conditionvar);
1160 $this->conditionvar = NULL;
1169 case "varsubstring":
1170 if ($this->conditionvar != NULL)
1172 if ($this->responsevar != NULL)
1174 $this->conditionvar->addResponseVar($this->responsevar);
1177 $this->responsevar = NULL;
1179 case "respcondition":
1180 if ($this->resprocessing != NULL)
1182 $this->resprocessing->addRespcondition($this->respcondition);
1184 $this->respcondition = NULL;
1187 if ($this->resprocessing != NULL)
1189 $this->resprocessing->setOutcomes($this->outcomes);
1191 $this->outcomes = NULL;
1194 if ($this->outcomes != NULL)
1196 $this->outcomes->addDecvar($this->decvar);
1198 $this->decvar = NULL;
1200 case "presentation":
1201 $this->in_presentation = FALSE;
1202 if ($this->presentation != NULL)
1204 if ($this->item != NULL)
1206 $this->item->setPresentation($this->presentation);
1209 $this->presentation = NULL;
1211 case "response_label":
1212 if ($this->render_type != NULL)
1214 $this->render_type->addResponseLabel($this->response_label);
1215 $this->response_label = NULL;
1218 case "render_choice":
1219 case "render_hotspot":
1221 if ($this->in_response)
1223 if ($this->response != NULL)
1225 if ($this->render_type != NULL)
1227 $this->response->setRenderType($this->render_type);
1228 $this->render_type = NULL;
1233 case "response_lid":
1235 case "response_str":
1236 case "response_num":
1237 case "response_grp":
1239 if ($this->presentation != NULL)
1241 if ($this->response != NULL)
1243 $this->presentation->addResponse($this->response);
1244 if ($this->item != NULL)
1246 $this->item->addPresentationitem($this->response);
1250 $this->response = NULL;
1251 $this->in_response = FALSE;
1254 if ($this->do_nothing)
1256 $this->do_nothing = FALSE;
1259 if (strlen($this->item->getQuestionType()))
1275 $qt = $this->item->determineQuestionType();
1276 $presentation = $this->item->getPresentation();
1283 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1285 $question =
new $qt();
1286 $fbt = str_replace(
'ass',
'ilAss', $qt).
'Feedback';
1287 $question->feedbackOBJ =
new $fbt(
1290 $question->fromXML($this->item, $this->qpl_id, $this->tst_id, $this->tst_object, $this->question_counter, $this->import_mapping);
1293 if ($this->material)
1295 $mat = $this->material->getMaterial(0);
1296 if ((strcmp($mat[
"type"],
"mattext") == 0) && (strcmp($mat[
"material"]->getLabel(),
"suggested_solution") == 0))
1298 $this->item->addSuggestedSolution($mat[
"material"], $this->gap_index);
1300 if ($this->in_objectives)
1302 $this->objectives->addMaterial($this->material);
1304 else if (($this->render_type != NULL) && (strcmp(strtolower($this->
getParent($a_xml_parser)),
"render_hotspot") == 0))
1306 $this->render_type->addMaterial($this->material);
1308 else if (count($this->flow_mat) && (strcmp(strtolower($this->
getParent($a_xml_parser)),
"flow_mat") == 0))
1310 $this->flow_mat[count($this->flow_mat)-1]->addMaterial($this->material);
1312 else if ($this->itemfeedback != NULL)
1314 $this->itemfeedback->addMaterial($this->material);
1316 else if ($this->response_label != NULL)
1318 $this->response_label->addMaterial($this->material);
1320 else if ($this->response != NULL)
1322 if ($this->response->hasRendering())
1324 $this->response->setMaterial2($this->material);
1328 $this->response->setMaterial1($this->material);
1331 elseif (($this->in_presentation) && (!$this->in_response))
1333 if (!is_object($this->item->getQuestiontext()))
1335 $this->item->setQuestiontext($this->material);
1337 $this->presentation->addMaterial($this->material);
1339 else if ($this->presentation != NULL)
1341 $this->presentation->addMaterial($this->material);
1342 if ($this->item != NULL)
1344 $this->item->addPresentationitem($this->material);
1348 $this->material = NULL;
1357 if( $this->
virusDetected($this->matimage->getRawContent()) )
1362 require_once
'Services/QTI/classes/class.ilQtiMatImageSecurity.php';
1364 $matImageSecurity->sanitizeLabel();
1366 if( !$matImageSecurity->validate() )
1371 $this->material->addMatimage($this->matimage);
1372 $this->matimage = NULL;
1378 $this->mattext->setContent(
'<br />');
1379 $this->material->addMattext($this->mattext);
1380 $this->mattext = NULL;
1382 case "resprocessing":
1383 if ($this->item != NULL)
1385 $this->item->addResprocessing($this->resprocessing);
1387 $this->resprocessing = NULL;
1390 if ($this->material != NULL)
1392 $this->material->addMattext($this->mattext);
1394 $this->mattext = NULL;
1397 if ($this->material != NULL)
1399 $this->material->addMatapplet($this->matapplet);
1401 $this->matapplet = NULL;
1404 $this->depth[$a_xml_parser]--;
1412 switch ($this->parser_mode)
1428 if ($this->do_nothing)
return;
1429 $this->characterbuffer .= $a_data;
1431 switch ($this->qti_element)
1434 $this->metadata[
"label"] = $a_data;
1437 $this->metadata[
"entry"] = $a_data;
1439 case "response_label":
1440 if ($this->response_label != NULL)
1442 $this->response_label->setContent($a_data);
1446 if ($this->setvar != NULL)
1448 $this->setvar->setContent($a_data);
1451 case "displayfeedback":
1452 if ($this->displayfeedback != NULL)
1454 $this->displayfeedback->setContent($a_data);
1464 case "varsubstring":
1465 if ($this->responsevar != NULL)
1467 $this->responsevar->setContent($a_data);
1471 if (strlen($a_data))
1473 if ($this->decvar != NULL)
1475 $this->decvar->setContent($a_data);
1480 if ($this->mattext != NULL)
1482 $this->mattext->setContent($a_data);
1486 if ($this->matapplet != NULL)
1488 $this->matapplet->setContent($a_data);
1492 if ($this->matimage != NULL)
1494 $this->matimage->setContent($a_data);
1498 switch ($this->
getParent($a_xml_parser))
1507 $this->item->setDuration($a_data);
1512 switch ($this->
getParent($a_xml_parser))
1515 $this->item->setComment($a_data);
1525 $this->sametag = TRUE;
1533 switch (strtolower($a_name))
1535 case "questestinterop":
1536 $this->verifyroot =
true;
1538 case "qtimetadatafield":
1539 $this->verifymetadatafield = 1;
1542 $this->verifyfieldlabeltext =
"";
1543 if ($this->verifymetadatafield == 1) $this->verifyfieldlabel = 1;
1546 $this->verifyfieldentrytext =
"";
1547 if ($this->verifymetadatafield == 1) $this->verifyfieldentry = 1;
1551 if (is_array($a_attribs))
1553 foreach ($a_attribs as $attribute => $value)
1555 switch (strtolower($attribute))
1563 array_push($this->founditems, array(
"title" =>
"$title",
"type" =>
"",
"ident" => $a_attribs[
"ident"]));
1565 case "response_lid":
1566 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0)
1569 if (is_array($a_attribs))
1571 foreach ($a_attribs as $attribute => $value)
1573 switch (strtolower($attribute))
1575 case "rcardinality":
1576 include_once
"./Services/QTI/classes/class.ilQTIItem.php";
1577 switch (strtolower($value))
1586 $this->founditems[count($this->founditems)-1][
"type"] =
QT_ORDERING;
1595 case "response_str":
1596 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0)
1599 if (is_array($a_attribs))
1601 foreach ($a_attribs as $attribute => $value)
1603 switch (strtolower($attribute))
1605 case "rcardinality":
1606 include_once
"./Services/QTI/classes/class.ilQTIItem.php";
1607 switch (strtolower($value))
1610 $this->founditems[count($this->founditems)-1][
"type"] =
QT_CLOZE;
1613 $this->founditems[count($this->founditems)-1][
"type"] =
QT_TEXT;
1623 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0)
1625 $this->founditems[count($this->founditems)-1][
"type"] =
QT_IMAGEMAP;
1628 case "response_num":
1629 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0)
1631 $this->founditems[count($this->founditems)-1][
"type"] =
QT_NUMERIC;
1634 case "response_grp":
1635 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0)
1637 $this->founditems[count($this->founditems)-1][
"type"] =
QT_MATCHING;
1642 $this->verifyqticomment = 1;
1644 case "presentation":
1645 if (is_array($a_attribs))
1647 foreach ($a_attribs as $attribute => $value)
1649 switch (strtolower($attribute))
1652 $this->founditems[count($this->founditems)-1][
"title"] = $value;
1666 switch (strtolower($a_name))
1670 $this->verifyqticomment = 0;
1672 case "qtimetadatafield":
1673 $this->verifymetadatafield = 0;
1674 if (strcmp($this->verifyfieldlabeltext,
"QUESTIONTYPE") == 0)
1680 $this->verifyfieldlabel = 0;
1683 $this->verifyfieldentry = 0;
1693 if ($this->verifyqticomment == 1)
1695 if (preg_match(
"/Questiontype\=(.*)/", $a_data, $matches))
1697 if (count($this->founditems))
1699 $this->founditems[count($this->founditems)-1][
"type"] = $matches[1];
1703 else if ($this->verifyfieldlabel == 1)
1705 $this->verifyfieldlabeltext = $a_data;
1707 else if ($this->verifyfieldentry == 1)
1709 $this->verifyfieldentrytext = $a_data;
1724 if (!is_array($this->import_mapping))
1738 return parent::setXMLContent($a_xml_content);
1743 $xmlContent = file_get_contents($this->xml_file);
1745 file_put_contents($this->xml_file, $xmlContent);
1747 return parent::openXMLFile();
1754 if( preg_match(
'/^(\d+\.\d+\.\d+) .*$/', $versionDateString, $matches) )
1766 if( preg_match(
'/^il_(\d+?)_qst_\d+$/', $itemIdent, $matches) )
1784 for($i = 0x00, $max = 0x08; $i <= $max; $i += 0x01)
1786 $needles[] =
"&#{$i};";
1788 for($i = 0x0b, $max = 0x0c; $i <= $max; $i += 0x01)
1790 $needles[] =
"&#{$i};";
1792 for($i = 0x0e, $max = 0x1f; $i <= $max; $i += 0x01)
1794 $needles[] =
"&#{$i};";
1796 for($i = 0xd800, $max = 0xdfff; $i <= $max; $i += 0x0001)
1798 $needles[] =
"&#{$i};";
1800 for($i = 0xfffe, $max = 0xffff; $i <= $max; $i += 0x0001)
1802 $needles[] =
"&#{$i};";
1804 $reg =
'/('.implode(
'|', $needles).
')/';
1805 $xmlContent = preg_replace($reg,
'', $xmlContent);
1812 if( !$this->material )
1817 if( !$this->matimage )
1827 require_once
'Services/VirusScanner/classes/class.ilVirusScannerFactory.php';
1835 return (
bool)$vs->scanBuffer($buffer);
setHandlers($a_xml_parser)
set event handler should be overwritten by inherited class private
Class ilQTIPresentationMaterial.
fetchSourceNicFromItemIdent($itemIdent)
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
handlerParseCharacterData($a_xml_parser, $a_data)
handler for character data
const RESPONSEVAR_SUBSTRING
$in_prensentation_material
setXMLContent($a_xml_content)
fetchNumericVersionFromVersionDateString($versionDateString)
const QT_MULTIPLE_CHOICE_SR
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
static isImportable($questionTypeTag)
handlerVerifyEndTag($a_xml_parser, $a_name)
handler for end of element verification
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
ilQTIParser($a_xml_file, $a_mode=IL_MO_PARSE_QTI, $a_qpl_id=0, $a_import_idents="")
Constructor.
setTestObject(&$a_tst_object)
handlerVerifyBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element verification
setParserMode($a_mode=IL_MO_PARSE_QTI)
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
handlerParseEndTag($a_xml_parser, $a_name)
handler for end of element parser
cleanInvalidXmlChars($xmlContent)
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
handlerVerifyCharacterData($a_xml_parser, $a_data)
handler for character data verification
& _getInstance()
Constructor public.
getImportMapping()
get array of new created questions for import id
const QT_MULTIPLE_CHOICE_MR
handlerParseBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element parser