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);
152 parent::__construct($a_xml_file);
154 $this->qpl_id = $a_qpl_id;
155 $this->import_idents =
array();
156 if (is_array($a_import_idents))
158 $this->import_idents =& $a_import_idents;
162 $this->hasRootElement = FALSE;
163 $this->import_mapping =
array();
164 $this->assessments =
array();
166 $this->section = NULL;
167 $this->path =
array();
168 $this->items =
array();
170 $this->depth =
array();
171 $this->do_nothing = FALSE;
172 $this->qti_element =
"";
173 $this->in_presentation = FALSE;
174 $this->in_objectives = FALSE;
175 $this->in_reponse = FALSE;
176 $this->render_type = NULL;
177 $this->render_hotspot = NULL;
178 $this->response_label = NULL;
179 $this->material = NULL;
180 $this->response = NULL;
181 $this->assessmentcontrol = NULL;
182 $this->objectives = NULL;
183 $this->matimage = NULL;
184 $this->resprocessing = NULL;
185 $this->outcomes = NULL;
186 $this->decvar = NULL;
187 $this->respcondition = NULL;
188 $this->setvar = NULL;
189 $this->displayfeedback = NULL;
190 $this->itemfeedback = NULL;
191 $this->flow_mat =
array();
192 $this->question_counter = 1;
194 $this->gap_index = 0;
195 $this->presentation = NULL;
196 $this->mattext = NULL;
197 $this->matapplet = NULL;
198 $this->sametag = FALSE;
199 $this->in_assessment = FALSE;
200 $this->characterbuffer =
"";
201 $this->metadata =
array(
"label" =>
"",
"entry" =>
"");
222 $this->tst_object =& $a_tst_object;
223 if (is_object($a_tst_object))
225 $this->tst_id = $this->tst_object->getId();
231 $this->parser_mode = $a_mode;
232 $this->founditems =
array();
233 $this->verifyroot =
false;
234 $this->verifyqticomment = 0;
235 $this->verifymetadatafield = 0;
236 $this->verifyfieldlabel = 0;
237 $this->verifyfieldentry = 0;
238 $this->verifyfieldlabeltext =
"";
239 $this->verifyfieldentrytext =
"";
240 $this->question_counter = 1;
250 xml_set_object($a_xml_parser,$this);
251 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
252 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
257 $this->question_counter = 1;
258 parent::startParsing();
264 if ($this->depth[$a_xml_parser] > 0)
266 return $this->path[$this->depth[$a_xml_parser]-1];
279 switch ($this->parser_mode)
295 if ($this->do_nothing)
return;
296 $this->sametag = FALSE;
297 $this->characterbuffer =
"";
298 $this->depth[$a_xml_parser]++;
299 $this->path[$this->depth[$a_xml_parser]] = strtolower($a_name);
300 $this->qti_element = $a_name;
302 switch (strtolower($a_name))
305 include_once (
"./Services/QTI/classes/class.ilQTIAssessment.php");
307 $this->in_assessment = TRUE;
308 if (is_array($a_attribs))
310 foreach ($a_attribs as $attribute => $value)
312 switch (strtolower($attribute))
324 case "assessmentcontrol":
325 include_once (
"./Services/QTI/classes/class.ilQTIAssessmentcontrol.php");
327 if (is_array($a_attribs))
329 foreach ($a_attribs as $attribute => $value)
331 switch (strtolower($attribute))
333 case "solutionswitch":
334 $this->assessmentcontrol->setSolutionswitch($value);
337 $this->assessmentcontrol->setHintswitch($value);
339 case "feedbackswitch":
340 $this->assessmentcontrol->setFeedbackswitch($value);
347 include_once (
"./Services/QTI/classes/class.ilQTIObjectives.php");
349 $this->in_objectives = TRUE;
351 case 'presentation_material':
352 require_once
'Services/QTI/classes/class.ilQTIPresentationMaterial.php';
354 $this->in_prensentation_material = TRUE;
357 include_once (
"./Services/QTI/classes/class.ilQTISection.php");
361 $this->in_itemmetadata = TRUE;
363 case "qtimetadatafield":
364 $this->metadata =
array(
"label" =>
"",
"entry" =>
"");
367 include_once (
"./Services/QTI/classes/class.ilQTIFlow.php");
371 include_once (
"./Services/QTI/classes/class.ilQTIFlowMat.php");
375 include_once (
"./Services/QTI/classes/class.ilQTIItemfeedback.php");
377 if (is_array($a_attribs))
379 foreach ($a_attribs as $attribute => $value)
381 switch (strtolower($attribute))
384 $this->itemfeedback->setIdent($value);
387 $this->itemfeedback->setView($value);
393 case "displayfeedback":
394 include_once (
"./Services/QTI/classes/class.ilQTIDisplayfeedback.php");
396 if (is_array($a_attribs))
398 foreach ($a_attribs as $attribute => $value)
400 switch (strtolower($attribute))
403 $this->displayfeedback->setFeedbacktype($value);
406 $this->displayfeedback->setLinkrefid($value);
413 include_once (
"./Services/QTI/classes/class.ilQTISetvar.php");
415 if (is_array($a_attribs))
417 foreach ($a_attribs as $attribute => $value)
419 switch (strtolower($attribute))
422 $this->setvar->setAction($value);
425 $this->setvar->setVarname($value);
432 include_once (
"./Services/QTI/classes/class.ilQTIConditionvar.php");
436 if ($this->conditionvar != NULL)
438 $this->conditionvar->addNot();
442 if ($this->conditionvar != NULL)
444 $this->conditionvar->addAnd();
448 if ($this->conditionvar != NULL)
450 $this->conditionvar->addOr();
454 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
456 if (is_array($a_attribs))
458 foreach ($a_attribs as $attribute => $value)
460 switch (strtolower($attribute))
463 $this->responsevar->setCase($value);
466 $this->responsevar->setRespident($value);
469 $this->responsevar->setIndex($value);
476 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
478 if (is_array($a_attribs))
480 foreach ($a_attribs as $attribute => $value)
482 switch (strtolower($attribute))
485 $this->responsevar->setRespident($value);
488 $this->responsevar->setIndex($value);
495 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
497 if (is_array($a_attribs))
499 foreach ($a_attribs as $attribute => $value)
501 switch (strtolower($attribute))
504 $this->responsevar->setRespident($value);
507 $this->responsevar->setIndex($value);
514 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
516 if (is_array($a_attribs))
518 foreach ($a_attribs as $attribute => $value)
520 switch (strtolower($attribute))
523 $this->responsevar->setRespident($value);
526 $this->responsevar->setIndex($value);
533 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
535 if (is_array($a_attribs))
537 foreach ($a_attribs as $attribute => $value)
539 switch (strtolower($attribute))
542 $this->responsevar->setRespident($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->setRespident($value);
564 $this->responsevar->setSetmatch($value);
567 $this->responsevar->setIndex($value);
574 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
576 if (is_array($a_attribs))
578 foreach ($a_attribs as $attribute => $value)
580 switch (strtolower($attribute))
583 $this->responsevar->setRespident($value);
586 $this->responsevar->setAreatype($value);
589 $this->responsevar->setIndex($value);
596 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
598 if (is_array($a_attribs))
600 foreach ($a_attribs as $attribute => $value)
602 switch (strtolower($attribute))
605 $this->responsevar->setCase($value);
608 $this->responsevar->setRespident($value);
611 $this->responsevar->setIndex($value);
617 case "respcondition":
618 include_once(
"./Services/QTI/classes/class.ilQTIRespcondition.php");
620 if (is_array($a_attribs))
622 foreach ($a_attribs as $attribute => $value)
624 switch (strtolower($attribute))
627 $this->respcondition->setContinue($value);
630 $this->respcondition->setTitle($value);
637 include_once(
"./Services/QTI/classes/class.ilQTIOutcomes.php");
641 include_once(
"./Services/QTI/classes/class.ilQTIDecvar.php");
643 if (is_array($a_attribs))
645 foreach ($a_attribs as $attribute => $value)
647 switch (strtolower($attribute))
650 $this->decvar->setVarname($value);
653 $this->decvar->setVartype($value);
656 $this->decvar->setDefaultval($value);
659 $this->decvar->setMinvalue($value);
662 $this->decvar->setMaxvalue($value);
665 $this->decvar->setMembers($value);
668 $this->decvar->setCutvalue($value);
675 include_once(
"./Services/QTI/classes/class.ilQTIMatimage.php");
677 if (is_array($a_attribs))
679 foreach ($a_attribs as $attribute => $value)
681 switch (strtolower($attribute))
684 $this->matimage->setImagetype($value);
687 $this->matimage->setLabel($value);
690 $this->matimage->setHeight($value);
693 $this->matimage->setWidth($value);
696 $this->matimage->setUri($value);
699 $this->matimage->setEmbedded($value);
702 $this->matimage->setX0($value);
705 $this->matimage->setY0($value);
708 $this->matimage->setEntityref($value);
713 if (!$this->matimage->getEmbedded() && strlen($this->matimage->getUri()))
715 $this->matimage->setContent(@file_get_contents(dirname($this->xml_file) .
'/'. $this->matimage->getUri()));
719 include_once(
"./Services/QTI/classes/class.ilQTIMaterial.php");
721 $this->material->setFlow($this->flow);
722 if (is_array($a_attribs))
724 foreach ($a_attribs as $attribute => $value)
726 switch (strtolower($attribute))
729 $this->material->setLabel($value);
736 include_once (
"./Services/QTI/classes/class.ilQTIMattext.php");
738 if (is_array($a_attribs))
740 foreach ($a_attribs as $attribute => $value)
742 switch (strtolower($attribute))
745 $this->mattext->setTexttype($value);
748 $this->mattext->setLabel($value);
751 $this->mattext->setCharset($value);
754 $this->mattext->setUri($value);
757 $this->mattext->setXmlspace($value);
760 $this->mattext->setXmllang($value);
763 $this->mattext->setEntityref($value);
766 $this->mattext->setHeight($value);
769 $this->mattext->setWidth($value);
772 $this->mattext->setX0($value);
775 $this->mattext->setY0($value);
782 include_once (
"./Services/QTI/classes/class.ilQTIMatapplet.php");
784 if (is_array($a_attribs))
786 foreach ($a_attribs as $attribute => $value)
788 switch (strtolower($attribute))
791 $this->matapplet->setLabel($value);
794 $this->matapplet->setUri($value);
797 $this->matapplet->setY0($value);
800 $this->matapplet->setHeight($value);
803 $this->matapplet->setWidth($value);
806 $this->matapplet->setX0($value);
809 $this->matapplet->setEmbedded($value);
812 $this->matapplet->setEntityref($value);
818 case "questestinterop":
819 $this->hasRootElement = TRUE;
829 $this->
assessment->addSection($this->section);
831 $this->section = NULL;
834 $this->in_presentation = TRUE;
835 include_once (
"./Services/QTI/classes/class.ilQTIPresentation.php");
838 case "response_label":
839 if ($this->render_type != NULL)
841 include_once(
"./Services/QTI/classes/class.ilQTIResponseLabel.php");
843 foreach ($a_attribs as $attribute => $value)
845 switch (strtolower($attribute))
848 $this->response_label->setRshuffle($value);
851 $this->response_label->setRarea($value);
854 $this->response_label->setRrange($value);
857 $this->response_label->setLabelrefid($value);
860 $this->response_label->setIdent($value);
863 $this->response_label->setMatchGroup($value);
866 $this->response_label->setMatchMax($value);
872 case "render_choice":
873 if ($this->in_response)
875 include_once(
"./Services/QTI/classes/class.ilQTIRenderChoice.php");
877 foreach ($a_attribs as $attribute => $value)
879 switch (strtolower($attribute))
882 $this->render_type->setShuffle($value);
885 $this->render_type->setMinnumber($value);
888 $this->render_type->setMaxnumber($value);
894 case "render_hotspot":
895 if ($this->in_response)
897 include_once(
"./Services/QTI/classes/class.ilQTIRenderHotspot.php");
899 foreach ($a_attribs as $attribute => $value)
901 switch (strtolower($attribute))
904 $this->render_type->setShuffle($value);
907 $this->render_type->setMinnumber($value);
910 $this->render_type->setMaxnumber($value);
917 if ($this->in_response)
919 include_once(
"./Services/QTI/classes/class.ilQTIRenderFib.php");
921 foreach ($a_attribs as $attribute => $value)
923 switch (strtolower($attribute))
926 $this->render_type->setEncoding($value);
929 $this->render_type->setFibtype($value);
932 $this->render_type->setRows($value);
935 $this->render_type->setMaxchars($value);
938 $this->render_type->setPrompt($value);
941 $this->render_type->setColumns($value);
944 $this->render_type->setCharset($value);
947 $this->render_type->setMaxnumber($value);
950 $this->render_type->setMinnumber($value);
969 include_once
"./Services/QTI/classes/class.ilQTIResponse.php";
970 switch (strtolower($a_name))
988 $this->in_response = TRUE;
990 $this->response->setFlow($this->flow);
991 if (is_array($a_attribs))
993 foreach ($a_attribs as $attribute => $value)
995 switch (strtolower($attribute))
998 $this->response->setIdent($value);
1001 $this->response->setRTiming($value);
1003 case "rcardinality":
1004 $this->response->setRCardinality($value);
1007 $this->response->setNumtype($value);
1014 include_once(
"./Services/QTI/classes/class.ilQTIItem.php");
1015 $this->gap_index = 0;
1016 $this->item =& $this->items[array_push($this->items,
new ilQTIItem())-1];
1017 if (is_array($a_attribs))
1019 foreach ($a_attribs as $attribute => $value)
1021 switch (strtolower($attribute))
1024 $this->item->setIdent($value);
1025 $this->item->setIliasSourceNic(
1030 $this->do_nothing =
true;
1032 elseif (count($this->import_idents) > 0)
1034 if (!in_array($value, $this->import_idents))
1036 $this->do_nothing = TRUE;
1041 $this->item->setTitle($value);
1044 $this->item->setMaxattempts($value);
1050 case "resprocessing":
1051 include_once(
"./Services/QTI/classes/class.ilQTIResprocessing.php");
1053 if (is_array($a_attribs))
1055 foreach ($a_attribs as $attribute => $value)
1057 switch (strtolower($attribute))
1060 $this->resprocessing->setScoremodel($value);
1074 switch ($this->parser_mode)
1090 if (($this->do_nothing) && (strcmp(strtolower($a_name),
"item") != 0))
return;
1091 switch (strtolower($a_name))
1094 if (is_object($this->tst_object))
1096 $this->tst_object->fromXML($this->
assessment);
1098 $this->in_assessment = FALSE;
1100 case "assessmentcontrol":
1101 $this->
assessment->addAssessmentcontrol($this->assessmentcontrol);
1102 $this->assessmentcontrol = NULL;
1105 if (strcmp(strtolower($this->
getParent($a_xml_parser)),
"assessment") == 0)
1107 $this->
assessment->addObjectives($this->objectives);
1109 $this->in_objectives = FALSE;
1111 case 'presentation_material':
1112 $this->
assessment->setPresentationMaterial($this->prensentation_material);
1113 $this->in_prensentation_material = FALSE;
1115 case "itemmetadata":
1116 $this->in_itemmetadata = FALSE;
1118 case "qtimetadatafield":
1120 switch ($this->metadata[
"label"])
1122 case "ILIAS_VERSION":
1123 if ($this->item != NULL)
1125 $this->item->setIliasSourceVersion(
1130 case "QUESTIONTYPE":
1131 if ($this->item != NULL)
1133 $this->item->setQuestiontype($this->metadata[
"entry"]);
1137 if ($this->item != NULL)
1139 $this->item->setAuthor($this->metadata[
"entry"]);
1142 if ($this->item != NULL)
1144 $this->item->addMetadata($this->metadata);
1148 if ($this->in_assessment)
1150 $this->
assessment->addQtiMetadata($this->metadata);
1152 $this->metadata =
array(
"label" =>
"",
"entry" =>
"");
1158 if (count($this->flow_mat))
1160 $flow_mat = array_pop($this->flow_mat);
1161 if (count($this->flow_mat))
1163 $this->flow_mat[count($this->flow_mat)-1]->addFlow_mat($flow_mat);
1165 else if($this->in_prensentation_material)
1167 $this->prensentation_material->addFlowMat($flow_mat);
1169 else if ($this->itemfeedback != NULL)
1171 $this->itemfeedback->addFlow_mat($flow_mat);
1173 else if ($this->response_label != NULL)
1175 $this->response_label->addFlow_mat($flow_mat);
1179 case "itemfeedback":
1180 if ($this->item != NULL)
1182 if ($this->itemfeedback != NULL)
1184 $this->item->addItemfeedback($this->itemfeedback);
1187 $this->itemfeedback = NULL;
1189 case "displayfeedback":
1190 if ($this->respcondition != NULL)
1192 if ($this->displayfeedback != NULL)
1194 $this->respcondition->addDisplayfeedback($this->displayfeedback);
1197 $this->displayfeedback = NULL;
1200 if ($this->respcondition != NULL)
1202 if ($this->setvar != NULL)
1204 $this->respcondition->addSetvar($this->setvar);
1207 $this->setvar = NULL;
1209 case "conditionvar":
1210 if ($this->respcondition != NULL)
1212 $this->respcondition->setConditionvar($this->conditionvar);
1214 $this->conditionvar = NULL;
1223 case "varsubstring":
1224 if ($this->conditionvar != NULL)
1226 if ($this->responsevar != NULL)
1228 $this->conditionvar->addResponseVar($this->responsevar);
1231 $this->responsevar = NULL;
1233 case "respcondition":
1234 if ($this->resprocessing != NULL)
1236 $this->resprocessing->addRespcondition($this->respcondition);
1238 $this->respcondition = NULL;
1241 if ($this->resprocessing != NULL)
1243 $this->resprocessing->setOutcomes($this->outcomes);
1245 $this->outcomes = NULL;
1248 if ($this->outcomes != NULL)
1250 $this->outcomes->addDecvar($this->decvar);
1252 $this->decvar = NULL;
1254 case "presentation":
1255 $this->in_presentation = FALSE;
1256 if ($this->presentation != NULL)
1258 if ($this->item != NULL)
1260 $this->item->setPresentation($this->presentation);
1263 $this->presentation = NULL;
1265 case "response_label":
1266 if ($this->render_type != NULL)
1268 $this->render_type->addResponseLabel($this->response_label);
1269 $this->response_label = NULL;
1272 case "render_choice":
1273 case "render_hotspot":
1275 if ($this->in_response)
1277 if ($this->response != NULL)
1279 if ($this->render_type != NULL)
1281 $this->response->setRenderType($this->render_type);
1282 $this->render_type = NULL;
1287 case "response_lid":
1289 case "response_str":
1290 case "response_num":
1291 case "response_grp":
1293 if ($this->presentation != NULL)
1295 if ($this->response != NULL)
1297 $this->presentation->addResponse($this->response);
1298 if ($this->item != NULL)
1300 $this->item->addPresentationitem($this->response);
1304 $this->response = NULL;
1305 $this->in_response = FALSE;
1308 if ($this->do_nothing)
1310 $this->do_nothing = FALSE;
1313 if (strlen($this->item->getQuestionType()))
1329 $qt = $this->item->determineQuestionType();
1330 $presentation = $this->item->getPresentation();
1337 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1339 $question =
new $qt();
1340 $fbt = str_replace(
'ass',
'ilAss', $qt).
'Feedback';
1341 $question->feedbackOBJ =
new $fbt(
1344 $question->fromXML($this->item, $this->qpl_id, $this->tst_id, $this->tst_object, $this->question_counter, $this->import_mapping);
1345 $this->numImportedItems++;
1348 if ($this->material)
1350 $mat = $this->material->getMaterial(0);
1351 if ((strcmp($mat[
"type"],
"mattext") == 0) && (strcmp($mat[
"material"]->getLabel(),
"suggested_solution") == 0))
1353 $this->item->addSuggestedSolution($mat[
"material"], $this->gap_index);
1355 if ($this->in_objectives)
1357 $this->objectives->addMaterial($this->material);
1359 else if (($this->render_type != NULL) && (strcmp(strtolower($this->
getParent($a_xml_parser)),
"render_hotspot") == 0))
1361 $this->render_type->addMaterial($this->material);
1363 else if (count($this->flow_mat) && (strcmp(strtolower($this->
getParent($a_xml_parser)),
"flow_mat") == 0))
1365 $this->flow_mat[count($this->flow_mat)-1]->addMaterial($this->material);
1367 else if ($this->itemfeedback != NULL)
1369 $this->itemfeedback->addMaterial($this->material);
1371 else if ($this->response_label != NULL)
1373 $this->response_label->addMaterial($this->material);
1375 else if ($this->response != NULL)
1377 if ($this->response->hasRendering())
1379 $this->response->setMaterial2($this->material);
1383 $this->response->setMaterial1($this->material);
1386 elseif (($this->in_presentation) && (!$this->in_response))
1388 if (!is_object($this->item->getQuestiontext()))
1390 $this->item->setQuestiontext($this->material);
1392 $this->presentation->addMaterial($this->material);
1394 else if ($this->presentation != NULL)
1396 $this->presentation->addMaterial($this->material);
1397 if ($this->item != NULL)
1399 $this->item->addPresentationitem($this->material);
1403 $this->material = NULL;
1412 if( $this->
virusDetected($this->matimage->getRawContent()) )
1417 require_once
'Services/QTI/classes/class.ilQtiMatImageSecurity.php';
1419 $matImageSecurity->sanitizeLabel();
1421 if( !$matImageSecurity->validate() )
1426 $this->material->addMatimage($this->matimage);
1427 $this->matimage = NULL;
1433 $this->mattext->setContent(
'<br />');
1434 $this->material->addMattext($this->mattext);
1435 $this->mattext = NULL;
1437 case "resprocessing":
1438 if ($this->item != NULL)
1440 $this->item->addResprocessing($this->resprocessing);
1442 $this->resprocessing = NULL;
1445 if ($this->material != NULL)
1447 $this->material->addMattext($this->mattext);
1449 $this->mattext = NULL;
1452 if ($this->material != NULL)
1454 $this->material->addMatapplet($this->matapplet);
1456 $this->matapplet = NULL;
1459 $this->depth[$a_xml_parser]--;
1467 switch ($this->parser_mode)
1483 if ($this->do_nothing)
return;
1484 $this->characterbuffer .= $a_data;
1486 switch ($this->qti_element)
1489 $this->metadata[
"label"] = $a_data;
1492 $this->metadata[
"entry"] = $a_data;
1494 case "response_label":
1495 if ($this->response_label != NULL)
1497 $this->response_label->setContent($a_data);
1501 if ($this->setvar != NULL)
1503 $this->setvar->setContent($a_data);
1506 case "displayfeedback":
1507 if ($this->displayfeedback != NULL)
1509 $this->displayfeedback->setContent($a_data);
1519 case "varsubstring":
1520 if ($this->responsevar != NULL)
1522 $this->responsevar->setContent($a_data);
1526 if (strlen($a_data))
1528 if ($this->decvar != NULL)
1530 $this->decvar->setContent($a_data);
1535 if ($this->mattext != NULL)
1537 $this->mattext->setContent($a_data);
1541 if ($this->matapplet != NULL)
1543 $this->matapplet->setContent($a_data);
1547 if ($this->matimage != NULL)
1549 $this->matimage->setContent($a_data);
1553 switch ($this->
getParent($a_xml_parser))
1562 $this->item->setDuration($a_data);
1567 switch ($this->
getParent($a_xml_parser))
1570 $this->item->setComment($a_data);
1580 $this->sametag = TRUE;
1588 $this->qti_element = $a_name;
1590 switch (strtolower($a_name))
1593 include_once (
"./Services/QTI/classes/class.ilQTIAssessment.php");
1595 $this->in_assessment = TRUE;
1596 if (is_array($a_attribs))
1598 foreach ($a_attribs as $attribute => $value)
1600 switch (strtolower($attribute))
1612 case "questestinterop":
1613 $this->verifyroot =
true;
1615 case "qtimetadatafield":
1616 $this->metadata =
array(
"label" =>
"",
"entry" =>
"");
1617 $this->verifymetadatafield = 1;
1620 $this->verifyfieldlabeltext =
"";
1621 if ($this->verifymetadatafield == 1) $this->verifyfieldlabel = 1;
1624 $this->verifyfieldentrytext =
"";
1625 if ($this->verifymetadatafield == 1) $this->verifyfieldentry = 1;
1629 if (is_array($a_attribs))
1631 foreach ($a_attribs as $attribute => $value)
1633 switch (strtolower($attribute))
1641 array_push($this->founditems,
array(
"title" =>
"$title",
"type" =>
"",
"ident" => $a_attribs[
"ident"]));
1643 case "response_lid":
1644 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0)
1647 if (is_array($a_attribs))
1649 foreach ($a_attribs as $attribute => $value)
1651 switch (strtolower($attribute))
1653 case "rcardinality":
1654 include_once
"./Services/QTI/classes/class.ilQTIItem.php";
1655 switch (strtolower($value))
1664 $this->founditems[count($this->founditems)-1][
"type"] =
QT_ORDERING;
1673 case "response_str":
1674 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0)
1677 if (is_array($a_attribs))
1679 foreach ($a_attribs as $attribute => $value)
1681 switch (strtolower($attribute))
1683 case "rcardinality":
1684 include_once
"./Services/QTI/classes/class.ilQTIItem.php";
1685 switch (strtolower($value))
1688 $this->founditems[count($this->founditems)-1][
"type"] =
QT_CLOZE;
1691 $this->founditems[count($this->founditems)-1][
"type"] =
QT_TEXT;
1701 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0)
1703 $this->founditems[count($this->founditems)-1][
"type"] =
QT_IMAGEMAP;
1706 case "response_num":
1707 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0)
1709 $this->founditems[count($this->founditems)-1][
"type"] =
QT_NUMERIC;
1712 case "response_grp":
1713 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0)
1715 $this->founditems[count($this->founditems)-1][
"type"] =
QT_MATCHING;
1720 $this->verifyqticomment = 1;
1722 case "presentation":
1723 if (is_array($a_attribs))
1725 foreach ($a_attribs as $attribute => $value)
1727 switch (strtolower($attribute))
1730 $this->founditems[count($this->founditems)-1][
"title"] = $value;
1744 switch (strtolower($a_name))
1747 foreach($this->
assessment->qtimetadata as $metaField)
1749 if( $metaField[
'label'] ==
'question_set_type' )
1754 elseif( $metaField[
'label'] ==
'random_test' )
1756 if( $metaField[
'entry'] == 1 )
1767 $this->in_assessment = FALSE;
1771 $this->verifyqticomment = 0;
1773 case "qtimetadatafield":
1774 $this->verifymetadatafield = 0;
1775 if (strcmp($this->verifyfieldlabeltext,
"QUESTIONTYPE") == 0)
1779 if ($this->in_assessment)
1781 $this->
assessment->addQtiMetadata($this->metadata);
1783 $this->metadata =
array(
"label" =>
"",
"entry" =>
"");
1786 $this->verifyfieldlabel = 0;
1789 $this->verifyfieldentry = 0;
1799 if ($this->verifyqticomment == 1)
1801 if (preg_match(
"/Questiontype\=(.*)/", $a_data, $matches))
1803 if (count($this->founditems))
1805 $this->founditems[count($this->founditems)-1][
"type"] = $matches[1];
1809 else if ($this->verifyfieldlabel == 1)
1811 $this->verifyfieldlabeltext = $a_data;
1813 else if ($this->verifyfieldentry == 1)
1815 $this->verifyfieldentrytext = $a_data;
1818 switch($this->qti_element)
1821 $this->metadata[
"label"] = $a_data;
1824 $this->metadata[
"entry"] = $a_data;
1840 if (!is_array($this->import_mapping))
1855 $questionIdMapping =
array();
1859 $oldQuestionId = substr($k, strpos($k,
'qst_')+strlen(
'qst_'));
1860 $newQuestionId = $v[
'test'];
1862 $questionIdMapping[$oldQuestionId] = $newQuestionId;
1865 return $questionIdMapping;
1872 return parent::setXMLContent($a_xml_content);
1877 $xmlContent = file_get_contents($this->xml_file);
1879 file_put_contents($this->xml_file, $xmlContent);
1881 return parent::openXMLFile();
1888 if( preg_match(
'/^(\d+\.\d+\.\d+) .*$/', $versionDateString, $matches) )
1900 if( preg_match(
'/^il_(\d+?)_qst_\d+$/', $itemIdent, $matches) )
1918 for($i = 0x00, $max = 0x08; $i <= $max; $i += 0x01)
1920 $needles[] =
"&#{$i};";
1922 for($i = 0x0b, $max = 0x0c; $i <= $max; $i += 0x01)
1924 $needles[] =
"&#{$i};";
1926 for($i = 0x0e, $max = 0x1f; $i <= $max; $i += 0x01)
1928 $needles[] =
"&#{$i};";
1930 for($i = 0xd800, $max = 0xdfff; $i <= $max; $i += 0x0001)
1932 $needles[] =
"&#{$i};";
1934 for($i = 0xfffe, $max = 0xffff; $i <= $max; $i += 0x0001)
1936 $needles[] =
"&#{$i};";
1938 $reg =
'/('.implode(
'|', $needles).
')/';
1939 $xmlContent = preg_replace($reg,
'', $xmlContent);
1954 if( !$this->material )
1959 if( !$this->matimage )
1969 require_once
'Services/VirusScanner/classes/class.ilVirusScannerFactory.php';
1977 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.
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
handlerParseCharacterData($a_xml_parser, $a_data)
handler for character data
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const RESPONSEVAR_SUBSTRING
__construct($a_xml_file, $a_mode=IL_MO_PARSE_QTI, $a_qpl_id=0, $a_import_idents="")
Constructor.
$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 ...
setQuestionSetType($questionSetType)
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
setTestObject(&$a_tst_object)
handlerVerifyBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element verification
Create styles array
The data for the language used.
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
getImportMapping()
get array of new created questions for import id
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
const QT_MULTIPLE_CHOICE_MR
setIgnoreItemsEnabled($ignoreItemsEnabled)
handlerParseBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element parser