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)) {
157 $this->import_idents =&$a_import_idents;
161 $this->hasRootElement =
false;
162 $this->import_mapping =
array();
163 $this->assessments =
array();
165 $this->section = null;
166 $this->path =
array();
167 $this->items =
array();
169 $this->depth =
array();
170 $this->do_nothing =
false;
171 $this->qti_element =
"";
172 $this->in_presentation =
false;
173 $this->in_objectives =
false;
174 $this->in_reponse =
false;
175 $this->render_type = null;
176 $this->render_hotspot = null;
177 $this->response_label = null;
178 $this->material = null;
179 $this->response = null;
180 $this->assessmentcontrol = null;
181 $this->objectives = null;
182 $this->matimage = null;
183 $this->resprocessing = null;
184 $this->outcomes = null;
185 $this->decvar = null;
186 $this->respcondition = null;
187 $this->setvar = null;
188 $this->displayfeedback = null;
189 $this->itemfeedback = null;
190 $this->flow_mat =
array();
191 $this->question_counter = 1;
193 $this->gap_index = 0;
194 $this->presentation = null;
195 $this->mattext = null;
196 $this->matapplet = null;
197 $this->sametag =
false;
198 $this->in_assessment =
false;
199 $this->characterbuffer =
"";
200 $this->metadata =
array(
"label" =>
"",
"entry" =>
"");
221 $this->tst_object =&$a_tst_object;
222 if (is_object($a_tst_object)) {
223 $this->tst_id = $this->tst_object->getId();
229 $this->parser_mode = $a_mode;
230 $this->founditems =
array();
231 $this->verifyroot =
false;
232 $this->verifyqticomment = 0;
233 $this->verifymetadatafield = 0;
234 $this->verifyfieldlabel = 0;
235 $this->verifyfieldentry = 0;
236 $this->verifyfieldlabeltext =
"";
237 $this->verifyfieldentrytext =
"";
238 $this->question_counter = 1;
248 xml_set_object($a_xml_parser, $this);
249 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
250 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
255 $this->question_counter = 1;
256 parent::startParsing();
262 if ($this->depth[$a_xml_parser] > 0) {
263 return $this->path[$this->depth[$a_xml_parser]-1];
274 switch ($this->parser_mode) {
289 if ($this->do_nothing) {
292 $this->sametag =
false;
293 $this->characterbuffer =
"";
294 $this->depth[$a_xml_parser]++;
295 $this->path[$this->depth[$a_xml_parser]] = strtolower($a_name);
296 $this->qti_element = $a_name;
298 switch (strtolower($a_name)) {
300 include_once(
"./Services/QTI/classes/class.ilQTIAssessment.php");
302 $this->in_assessment =
true;
303 if (is_array($a_attribs)) {
304 foreach ($a_attribs as $attribute => $value) {
305 switch (strtolower($attribute)) {
316 case "assessmentcontrol":
317 include_once(
"./Services/QTI/classes/class.ilQTIAssessmentcontrol.php");
319 if (is_array($a_attribs)) {
320 foreach ($a_attribs as $attribute => $value) {
321 switch (strtolower($attribute)) {
322 case "solutionswitch":
323 $this->assessmentcontrol->setSolutionswitch($value);
326 $this->assessmentcontrol->setHintswitch($value);
328 case "feedbackswitch":
329 $this->assessmentcontrol->setFeedbackswitch($value);
336 include_once(
"./Services/QTI/classes/class.ilQTIObjectives.php");
338 $this->in_objectives =
true;
340 case 'presentation_material':
341 require_once
'Services/QTI/classes/class.ilQTIPresentationMaterial.php';
343 $this->in_prensentation_material =
true;
346 include_once(
"./Services/QTI/classes/class.ilQTISection.php");
350 $this->in_itemmetadata =
true;
352 case "qtimetadatafield":
353 $this->metadata =
array(
"label" =>
"",
"entry" =>
"");
356 include_once(
"./Services/QTI/classes/class.ilQTIFlow.php");
360 include_once(
"./Services/QTI/classes/class.ilQTIFlowMat.php");
364 include_once(
"./Services/QTI/classes/class.ilQTIItemfeedback.php");
366 if (is_array($a_attribs)) {
367 foreach ($a_attribs as $attribute => $value) {
368 switch (strtolower($attribute)) {
370 $this->itemfeedback->setIdent($value);
373 $this->itemfeedback->setView($value);
379 case "displayfeedback":
380 include_once(
"./Services/QTI/classes/class.ilQTIDisplayfeedback.php");
382 if (is_array($a_attribs)) {
383 foreach ($a_attribs as $attribute => $value) {
384 switch (strtolower($attribute)) {
386 $this->displayfeedback->setFeedbacktype($value);
389 $this->displayfeedback->setLinkrefid($value);
396 include_once(
"./Services/QTI/classes/class.ilQTISetvar.php");
398 if (is_array($a_attribs)) {
399 foreach ($a_attribs as $attribute => $value) {
400 switch (strtolower($attribute)) {
402 $this->setvar->setAction($value);
405 $this->setvar->setVarname($value);
412 include_once(
"./Services/QTI/classes/class.ilQTIConditionvar.php");
416 if ($this->conditionvar != null) {
417 $this->conditionvar->addNot();
421 if ($this->conditionvar != null) {
422 $this->conditionvar->addAnd();
426 if ($this->conditionvar != null) {
427 $this->conditionvar->addOr();
431 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
433 if (is_array($a_attribs)) {
434 foreach ($a_attribs as $attribute => $value) {
435 switch (strtolower($attribute)) {
437 $this->responsevar->setCase($value);
440 $this->responsevar->setRespident($value);
443 $this->responsevar->setIndex($value);
450 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
452 if (is_array($a_attribs)) {
453 foreach ($a_attribs as $attribute => $value) {
454 switch (strtolower($attribute)) {
456 $this->responsevar->setRespident($value);
459 $this->responsevar->setIndex($value);
466 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
468 if (is_array($a_attribs)) {
469 foreach ($a_attribs as $attribute => $value) {
470 switch (strtolower($attribute)) {
472 $this->responsevar->setRespident($value);
475 $this->responsevar->setIndex($value);
482 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
484 if (is_array($a_attribs)) {
485 foreach ($a_attribs as $attribute => $value) {
486 switch (strtolower($attribute)) {
488 $this->responsevar->setRespident($value);
491 $this->responsevar->setIndex($value);
498 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
500 if (is_array($a_attribs)) {
501 foreach ($a_attribs as $attribute => $value) {
502 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)) {
517 foreach ($a_attribs as $attribute => $value) {
518 switch (strtolower($attribute)) {
520 $this->responsevar->setRespident($value);
523 $this->responsevar->setSetmatch($value);
526 $this->responsevar->setIndex($value);
533 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
535 if (is_array($a_attribs)) {
536 foreach ($a_attribs as $attribute => $value) {
537 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)) {
555 foreach ($a_attribs as $attribute => $value) {
556 switch (strtolower($attribute)) {
558 $this->responsevar->setCase($value);
561 $this->responsevar->setRespident($value);
564 $this->responsevar->setIndex($value);
570 case "respcondition":
571 include_once(
"./Services/QTI/classes/class.ilQTIRespcondition.php");
573 if (is_array($a_attribs)) {
574 foreach ($a_attribs as $attribute => $value) {
575 switch (strtolower($attribute)) {
577 $this->respcondition->setContinue($value);
580 $this->respcondition->setTitle($value);
587 include_once(
"./Services/QTI/classes/class.ilQTIOutcomes.php");
591 include_once(
"./Services/QTI/classes/class.ilQTIDecvar.php");
593 if (is_array($a_attribs)) {
594 foreach ($a_attribs as $attribute => $value) {
595 switch (strtolower($attribute)) {
597 $this->decvar->setVarname($value);
600 $this->decvar->setVartype($value);
603 $this->decvar->setDefaultval($value);
606 $this->decvar->setMinvalue($value);
609 $this->decvar->setMaxvalue($value);
612 $this->decvar->setMembers($value);
615 $this->decvar->setCutvalue($value);
622 include_once(
"./Services/QTI/classes/class.ilQTIMatimage.php");
624 if (is_array($a_attribs)) {
625 foreach ($a_attribs as $attribute => $value) {
626 switch (strtolower($attribute)) {
628 $this->matimage->setImagetype($value);
631 $this->matimage->setLabel($value);
634 $this->matimage->setHeight($value);
637 $this->matimage->setWidth($value);
640 $this->matimage->setUri($value);
643 $this->matimage->setEmbedded($value);
646 $this->matimage->setX0($value);
649 $this->matimage->setY0($value);
652 $this->matimage->setEntityref($value);
657 if (!$this->matimage->getEmbedded() && strlen($this->matimage->getUri())) {
658 $this->matimage->setContent(@file_get_contents(dirname($this->xml_file) .
'/' . $this->matimage->getUri()));
662 include_once(
"./Services/QTI/classes/class.ilQTIMaterial.php");
664 $this->material->setFlow($this->flow);
665 if (is_array($a_attribs)) {
666 foreach ($a_attribs as $attribute => $value) {
667 switch (strtolower($attribute)) {
669 $this->material->setLabel($value);
676 include_once(
"./Services/QTI/classes/class.ilQTIMattext.php");
678 if (is_array($a_attribs)) {
679 foreach ($a_attribs as $attribute => $value) {
680 switch (strtolower($attribute)) {
682 $this->mattext->setTexttype($value);
685 $this->mattext->setLabel($value);
688 $this->mattext->setCharset($value);
691 $this->mattext->setUri($value);
694 $this->mattext->setXmlspace($value);
697 $this->mattext->setXmllang($value);
700 $this->mattext->setEntityref($value);
703 $this->mattext->setHeight($value);
706 $this->mattext->setWidth($value);
709 $this->mattext->setX0($value);
712 $this->mattext->setY0($value);
719 include_once(
"./Services/QTI/classes/class.ilQTIMatapplet.php");
721 if (is_array($a_attribs)) {
722 foreach ($a_attribs as $attribute => $value) {
723 switch (strtolower($attribute)) {
725 $this->matapplet->setLabel($value);
728 $this->matapplet->setUri($value);
731 $this->matapplet->setY0($value);
734 $this->matapplet->setHeight($value);
737 $this->matapplet->setWidth($value);
740 $this->matapplet->setX0($value);
743 $this->matapplet->setEmbedded($value);
746 $this->matapplet->setEntityref($value);
752 case "questestinterop":
753 $this->hasRootElement =
true;
762 $this->
assessment->addSection($this->section);
764 $this->section = null;
767 $this->in_presentation =
true;
768 include_once(
"./Services/QTI/classes/class.ilQTIPresentation.php");
771 case "response_label":
772 if ($this->render_type != null) {
773 include_once(
"./Services/QTI/classes/class.ilQTIResponseLabel.php");
775 foreach ($a_attribs as $attribute => $value) {
776 switch (strtolower($attribute)) {
778 $this->response_label->setRshuffle($value);
781 $this->response_label->setRarea($value);
784 $this->response_label->setRrange($value);
787 $this->response_label->setLabelrefid($value);
790 $this->response_label->setIdent($value);
793 $this->response_label->setMatchGroup($value);
796 $this->response_label->setMatchMax($value);
802 case "render_choice":
803 if ($this->in_response) {
804 include_once(
"./Services/QTI/classes/class.ilQTIRenderChoice.php");
806 foreach ($a_attribs as $attribute => $value) {
807 switch (strtolower($attribute)) {
809 $this->render_type->setShuffle($value);
812 $this->render_type->setMinnumber($value);
815 $this->render_type->setMaxnumber($value);
821 case "render_hotspot":
822 if ($this->in_response) {
823 include_once(
"./Services/QTI/classes/class.ilQTIRenderHotspot.php");
825 foreach ($a_attribs as $attribute => $value) {
826 switch (strtolower($attribute)) {
828 $this->render_type->setShuffle($value);
831 $this->render_type->setMinnumber($value);
834 $this->render_type->setMaxnumber($value);
841 if ($this->in_response) {
842 include_once(
"./Services/QTI/classes/class.ilQTIRenderFib.php");
844 foreach ($a_attribs as $attribute => $value) {
845 switch (strtolower($attribute)) {
847 $this->render_type->setEncoding($value);
850 $this->render_type->setFibtype($value);
853 $this->render_type->setRows($value);
856 $this->render_type->setMaxchars($value);
859 $this->render_type->setPrompt($value);
862 $this->render_type->setColumns($value);
865 $this->render_type->setCharset($value);
868 $this->render_type->setMaxnumber($value);
871 $this->render_type->setMinnumber($value);
890 include_once
"./Services/QTI/classes/class.ilQTIResponse.php";
891 switch (strtolower($a_name)) {
908 $this->in_response =
true;
910 $this->response->setFlow($this->flow);
911 if (is_array($a_attribs)) {
912 foreach ($a_attribs as $attribute => $value) {
913 switch (strtolower($attribute)) {
915 $this->response->setIdent($value);
918 $this->response->setRTiming($value);
921 $this->response->setRCardinality($value);
924 $this->response->setNumtype($value);
931 include_once(
"./Services/QTI/classes/class.ilQTIItem.php");
932 $this->gap_index = 0;
933 $this->item =&$this->items[array_push($this->items,
new ilQTIItem())-1];
934 if (is_array($a_attribs)) {
935 foreach ($a_attribs as $attribute => $value) {
936 switch (strtolower($attribute)) {
938 $this->item->setIdent($value);
939 $this->item->setIliasSourceNic(
943 $this->do_nothing =
true;
944 } elseif (count($this->import_idents) > 0) {
945 if (!in_array($value, $this->import_idents)) {
946 $this->do_nothing =
true;
951 $this->item->setTitle($value);
954 $this->item->setMaxattempts($value);
960 case "resprocessing":
961 include_once(
"./Services/QTI/classes/class.ilQTIResprocessing.php");
963 if (is_array($a_attribs)) {
964 foreach ($a_attribs as $attribute => $value) {
965 switch (strtolower($attribute)) {
967 $this->resprocessing->setScoremodel($value);
981 switch ($this->parser_mode) {
996 if (($this->do_nothing) && (strcmp(strtolower($a_name),
"item") != 0)) {
999 switch (strtolower($a_name)) {
1001 if (is_object($this->tst_object)) {
1002 $this->tst_object->fromXML($this->
assessment);
1004 $this->in_assessment =
false;
1006 case "assessmentcontrol":
1007 $this->
assessment->addAssessmentcontrol($this->assessmentcontrol);
1008 $this->assessmentcontrol = null;
1011 if (strcmp(strtolower($this->
getParent($a_xml_parser)),
"assessment") == 0) {
1012 $this->
assessment->addObjectives($this->objectives);
1014 $this->in_objectives =
false;
1016 case 'presentation_material':
1017 $this->
assessment->setPresentationMaterial($this->prensentation_material);
1018 $this->in_prensentation_material =
false;
1020 case "itemmetadata":
1021 $this->in_itemmetadata =
false;
1023 case "qtimetadatafield":
1025 switch ($this->metadata[
"label"]) {
1026 case "ILIAS_VERSION":
1027 if ($this->item != null) {
1028 $this->item->setIliasSourceVersion(
1033 case "QUESTIONTYPE":
1034 if ($this->item != null) {
1035 $this->item->setQuestiontype($this->metadata[
"entry"]);
1039 if ($this->item != null) {
1040 $this->item->setAuthor($this->metadata[
"entry"]);
1044 if ($this->item != null) {
1045 $this->item->addMetadata($this->metadata);
1049 if ($this->in_assessment) {
1050 $this->
assessment->addQtiMetadata($this->metadata);
1052 $this->metadata =
array(
"label" =>
"",
"entry" =>
"");
1058 if (count($this->flow_mat)) {
1060 if (count($this->flow_mat)) {
1061 $this->flow_mat[count($this->flow_mat)-1]->addFlow_mat(
$flow_mat);
1062 } elseif ($this->in_prensentation_material) {
1063 $this->prensentation_material->addFlowMat(
$flow_mat);
1064 } elseif ($this->itemfeedback != null) {
1065 $this->itemfeedback->addFlow_mat(
$flow_mat);
1066 } elseif ($this->response_label != null) {
1067 $this->response_label->addFlow_mat(
$flow_mat);
1071 case "itemfeedback":
1072 if ($this->item != null) {
1073 if ($this->itemfeedback != null) {
1074 $this->item->addItemfeedback($this->itemfeedback);
1077 $this->itemfeedback = null;
1079 case "displayfeedback":
1080 if ($this->respcondition != null) {
1081 if ($this->displayfeedback != null) {
1082 $this->respcondition->addDisplayfeedback($this->displayfeedback);
1085 $this->displayfeedback = null;
1088 if ($this->respcondition != null) {
1089 if ($this->setvar != null) {
1090 $this->respcondition->addSetvar($this->setvar);
1093 $this->setvar = null;
1095 case "conditionvar":
1096 if ($this->respcondition != null) {
1097 $this->respcondition->setConditionvar($this->conditionvar);
1099 $this->conditionvar = null;
1108 case "varsubstring":
1109 if ($this->conditionvar != null) {
1110 if ($this->responsevar != null) {
1111 $this->conditionvar->addResponseVar($this->responsevar);
1114 $this->responsevar = null;
1116 case "respcondition":
1117 if ($this->resprocessing != null) {
1118 $this->resprocessing->addRespcondition($this->respcondition);
1120 $this->respcondition = null;
1123 if ($this->resprocessing != null) {
1124 $this->resprocessing->setOutcomes($this->outcomes);
1126 $this->outcomes = null;
1129 if ($this->outcomes != null) {
1130 $this->outcomes->addDecvar($this->decvar);
1132 $this->decvar = null;
1134 case "presentation":
1135 $this->in_presentation =
false;
1136 if ($this->presentation != null) {
1137 if ($this->item != null) {
1138 $this->item->setPresentation($this->presentation);
1141 $this->presentation = null;
1143 case "response_label":
1144 if ($this->render_type != null) {
1145 $this->render_type->addResponseLabel($this->response_label);
1146 $this->response_label = null;
1149 case "render_choice":
1150 case "render_hotspot":
1152 if ($this->in_response) {
1153 if ($this->response != null) {
1154 if ($this->render_type != null) {
1155 $this->response->setRenderType($this->render_type);
1156 $this->render_type = null;
1161 case "response_lid":
1163 case "response_str":
1164 case "response_num":
1165 case "response_grp":
1167 if ($this->presentation != null) {
1168 if ($this->response != null) {
1169 $this->presentation->addResponse($this->response);
1170 if ($this->item != null) {
1171 $this->item->addPresentationitem($this->response);
1175 $this->response = null;
1176 $this->in_response =
false;
1179 if ($this->do_nothing) {
1180 $this->do_nothing =
false;
1183 if (strlen($this->item->getQuestionType())) {
1196 $qt = $this->item->determineQuestionType();
1203 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1205 $question =
new $qt();
1206 $fbt = str_replace(
'ass',
'ilAss', $qt) .
'Feedback';
1207 $question->feedbackOBJ =
new $fbt(
1213 $question->fromXML($this->item, $this->qpl_id, $this->tst_id, $this->tst_object, $this->question_counter, $this->import_mapping);
1214 $this->numImportedItems++;
1217 if ($this->material) {
1218 $mat = $this->material->getMaterial(0);
1219 if ((strcmp($mat[
"type"],
"mattext") == 0) && (strcmp($mat[
"material"]->getLabel(),
"suggested_solution") == 0)) {
1220 $this->item->addSuggestedSolution($mat[
"material"], $this->gap_index);
1222 if ($this->in_objectives) {
1223 $this->objectives->addMaterial($this->material);
1224 } elseif (($this->render_type != null) && (strcmp(strtolower($this->
getParent($a_xml_parser)),
"render_hotspot") == 0)) {
1225 $this->render_type->addMaterial($this->material);
1226 } elseif (count($this->flow_mat) && (strcmp(strtolower($this->
getParent($a_xml_parser)),
"flow_mat") == 0)) {
1227 $this->flow_mat[count($this->flow_mat)-1]->addMaterial($this->material);
1228 } elseif ($this->itemfeedback != null) {
1229 $this->itemfeedback->addMaterial($this->material);
1230 } elseif ($this->response_label != null) {
1231 $this->response_label->addMaterial($this->material);
1232 } elseif ($this->response != null) {
1233 if ($this->response->hasRendering()) {
1234 $this->response->setMaterial2($this->material);
1236 $this->response->setMaterial1($this->material);
1238 } elseif (($this->in_presentation) && (!$this->in_response)) {
1239 if (!is_object($this->item->getQuestiontext())) {
1240 $this->item->setQuestiontext($this->material);
1242 $this->presentation->addMaterial($this->material);
1243 } elseif ($this->presentation != null) {
1244 $this->presentation->addMaterial($this->material);
1245 if ($this->item != null) {
1246 $this->item->addPresentationitem($this->material);
1250 $this->material = null;
1258 if ($this->
virusDetected($this->matimage->getRawContent())) {
1262 require_once
'Services/QTI/classes/class.ilQtiMatImageSecurity.php';
1264 $matImageSecurity->sanitizeLabel();
1266 if (!$matImageSecurity->validate()) {
1270 $this->material->addMatimage($this->matimage);
1271 $this->matimage = null;
1277 $this->mattext->setContent(
'<br />');
1278 $this->material->addMattext($this->mattext);
1279 $this->mattext = null;
1281 case "resprocessing":
1282 if ($this->item != null) {
1283 $this->item->addResprocessing($this->resprocessing);
1285 $this->resprocessing = null;
1288 if ($this->material != null) {
1289 $this->material->addMattext($this->mattext);
1291 $this->mattext = null;
1294 if ($this->material != null) {
1295 $this->material->addMatapplet($this->matapplet);
1297 $this->matapplet = null;
1300 $this->depth[$a_xml_parser]--;
1308 switch ($this->parser_mode) {
1323 if ($this->do_nothing) {
1326 $this->characterbuffer .= $a_data;
1328 switch ($this->qti_element) {
1330 $this->metadata[
"label"] = $a_data;
1333 $this->metadata[
"entry"] = $a_data;
1335 case "response_label":
1336 if ($this->response_label != null) {
1337 $this->response_label->setContent($a_data);
1341 if ($this->setvar != null) {
1342 $this->setvar->setContent($a_data);
1345 case "displayfeedback":
1346 if ($this->displayfeedback != null) {
1347 $this->displayfeedback->setContent($a_data);
1357 case "varsubstring":
1358 if ($this->responsevar != null) {
1359 $this->responsevar->setContent($a_data);
1363 if (strlen($a_data)) {
1364 if ($this->decvar != null) {
1365 $this->decvar->setContent($a_data);
1370 if ($this->mattext != null) {
1371 $this->mattext->setContent($a_data);
1375 if ($this->matapplet != null) {
1376 $this->matapplet->setContent($a_data);
1380 if ($this->matimage != null) {
1381 $this->matimage->setContent($a_data);
1385 switch ($this->
getParent($a_xml_parser)) {
1393 $this->item->setDuration($a_data);
1398 switch ($this->
getParent($a_xml_parser)) {
1400 $this->item->setComment($a_data);
1410 $this->sametag =
true;
1418 $this->qti_element = $a_name;
1420 switch (strtolower($a_name)) {
1422 include_once(
"./Services/QTI/classes/class.ilQTIAssessment.php");
1424 $this->in_assessment =
true;
1425 if (is_array($a_attribs)) {
1426 foreach ($a_attribs as $attribute => $value) {
1427 switch (strtolower($attribute)) {
1438 case "questestinterop":
1439 $this->verifyroot =
true;
1441 case "qtimetadatafield":
1442 $this->metadata =
array(
"label" =>
"",
"entry" =>
"");
1443 $this->verifymetadatafield = 1;
1446 $this->verifyfieldlabeltext =
"";
1447 if ($this->verifymetadatafield == 1) {
1448 $this->verifyfieldlabel = 1;
1452 $this->verifyfieldentrytext =
"";
1453 if ($this->verifymetadatafield == 1) {
1454 $this->verifyfieldentry = 1;
1459 if (is_array($a_attribs)) {
1460 foreach ($a_attribs as $attribute => $value) {
1461 switch (strtolower($attribute)) {
1468 array_push($this->founditems,
array(
"title" =>
"$title",
"type" =>
"",
"ident" => $a_attribs[
"ident"]));
1470 case "response_lid":
1471 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0) {
1473 if (is_array($a_attribs)) {
1474 foreach ($a_attribs as $attribute => $value) {
1475 switch (strtolower($attribute)) {
1476 case "rcardinality":
1477 include_once
"./Services/QTI/classes/class.ilQTIItem.php";
1478 switch (strtolower($value)) {
1486 $this->founditems[count($this->founditems)-1][
"type"] =
QT_ORDERING;
1495 case "response_str":
1496 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0) {
1498 if (is_array($a_attribs)) {
1499 foreach ($a_attribs as $attribute => $value) {
1500 switch (strtolower($attribute)) {
1501 case "rcardinality":
1502 include_once
"./Services/QTI/classes/class.ilQTIItem.php";
1503 switch (strtolower($value)) {
1505 $this->founditems[count($this->founditems)-1][
"type"] =
QT_CLOZE;
1508 $this->founditems[count($this->founditems)-1][
"type"] =
QT_TEXT;
1518 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0) {
1519 $this->founditems[count($this->founditems)-1][
"type"] =
QT_IMAGEMAP;
1522 case "response_num":
1523 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0) {
1524 $this->founditems[count($this->founditems)-1][
"type"] =
QT_NUMERIC;
1527 case "response_grp":
1528 if (strlen($this->founditems[count($this->founditems)-1][
"type"]) == 0) {
1529 $this->founditems[count($this->founditems)-1][
"type"] =
QT_MATCHING;
1534 $this->verifyqticomment = 1;
1536 case "presentation":
1537 if (is_array($a_attribs)) {
1538 foreach ($a_attribs as $attribute => $value) {
1539 switch (strtolower($attribute)) {
1541 $this->founditems[count($this->founditems)-1][
"title"] = $value;
1555 switch (strtolower($a_name)) {
1557 foreach ($this->
assessment->qtimetadata as $metaField) {
1558 if ($metaField[
'label'] ==
'question_set_type') {
1561 } elseif ($metaField[
'label'] ==
'random_test') {
1562 if ($metaField[
'entry'] == 1) {
1570 $this->in_assessment =
false;
1574 $this->verifyqticomment = 0;
1576 case "qtimetadatafield":
1577 $this->verifymetadatafield = 0;
1578 if (strcmp($this->verifyfieldlabeltext,
"QUESTIONTYPE") == 0) {
1581 if ($this->in_assessment) {
1582 $this->
assessment->addQtiMetadata($this->metadata);
1584 $this->metadata =
array(
"label" =>
"",
"entry" =>
"");
1587 $this->verifyfieldlabel = 0;
1590 $this->verifyfieldentry = 0;
1600 if ($this->verifyqticomment == 1) {
1601 if (preg_match(
"/Questiontype\=(.*)/", $a_data, $matches)) {
1602 if (count($this->founditems)) {
1603 $this->founditems[count($this->founditems)-1][
"type"] = $matches[1];
1606 } elseif ($this->verifyfieldlabel == 1) {
1607 $this->verifyfieldlabeltext = $a_data;
1608 } elseif ($this->verifyfieldentry == 1) {
1609 $this->verifyfieldentrytext = $a_data;
1612 switch ($this->qti_element) {
1614 $this->metadata[
"label"] = $a_data;
1617 $this->metadata[
"entry"] = $a_data;
1633 if (!is_array($this->import_mapping)) {
1645 $questionIdMapping =
array();
1648 $oldQuestionId = substr($k, strpos($k,
'qst_')+strlen(
'qst_'));
1649 $newQuestionId = $v[
'test'];
1651 $questionIdMapping[$oldQuestionId] = $newQuestionId;
1654 return $questionIdMapping;
1661 return parent::setXMLContent($a_xml_content);
1666 $xmlContent = file_get_contents($this->xml_file);
1668 file_put_contents($this->xml_file, $xmlContent);
1670 return parent::openXMLFile();
1677 if (preg_match(
'/^(\d+\.\d+\.\d+) .*$/', $versionDateString, $matches)) {
1688 if (preg_match(
'/^il_(\d+?)_qst_\d+$/', $itemIdent, $matches)) {
1705 for (
$i = 0x00, $max = 0x08;
$i <= $max;
$i += 0x01) {
1706 $needles[] =
"&#{$i};";
1708 for (
$i = 0x0b, $max = 0x0c;
$i <= $max;
$i += 0x01) {
1709 $needles[] =
"&#{$i};";
1711 for (
$i = 0x0e, $max = 0x1f;
$i <= $max;
$i += 0x01) {
1712 $needles[] =
"&#{$i};";
1714 for (
$i = 0xd800, $max = 0xdfff;
$i <= $max;
$i += 0x0001) {
1715 $needles[] =
"&#{$i};";
1717 for (
$i = 0xfffe, $max = 0xffff;
$i <= $max;
$i += 0x0001) {
1718 $needles[] =
"&#{$i};";
1720 $reg =
'/(' . implode(
'|', $needles) .
')/';
1721 $xmlContent = preg_replace($reg,
'', $xmlContent);
1736 if (!$this->material) {
1740 if (!$this->matimage) {
1749 require_once
'Services/VirusScanner/classes/class.ilVirusScannerFactory.php';
1756 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