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);
157 $this->qpl_id = $a_qpl_id;
158 $this->import_idents = array();
159 if (is_array($a_import_idents)) {
160 $this->import_idents = &$a_import_idents;
164 $this->hasRootElement =
false;
165 $this->import_mapping = array();
166 $this->assessments = array();
168 $this->section = null;
169 $this->path = array();
170 $this->items = array();
172 $this->depth = array();
173 $this->do_nothing =
false;
174 $this->qti_element =
"";
175 $this->in_presentation =
false;
176 $this->in_objectives =
false;
177 $this->in_reponse =
false;
178 $this->render_type = null;
179 $this->render_hotspot = null;
180 $this->response_label = null;
181 $this->material = null;
182 $this->response = null;
183 $this->assessmentcontrol = null;
184 $this->objectives = null;
185 $this->matimage = null;
186 $this->resprocessing = null;
187 $this->outcomes = null;
188 $this->decvar = null;
189 $this->respcondition = null;
190 $this->setvar = null;
191 $this->displayfeedback = null;
192 $this->itemfeedback = null;
193 $this->flow_mat = array();
194 $this->question_counter = 1;
196 $this->gap_index = 0;
197 $this->presentation = null;
198 $this->mattext = null;
199 $this->matapplet = null;
200 $this->sametag =
false;
201 $this->in_assessment =
false;
202 $this->characterbuffer =
"";
203 $this->metadata = array(
"label" =>
"",
"entry" =>
"");
224 $this->tst_object = &$a_tst_object;
225 if (is_object($a_tst_object)) {
226 $this->tst_id = $this->tst_object->getId();
232 $this->parser_mode = $a_mode;
233 $this->founditems = array();
234 $this->verifyroot =
false;
235 $this->verifyqticomment = 0;
236 $this->verifymetadatafield = 0;
237 $this->verifyfieldlabel = 0;
238 $this->verifyfieldentry = 0;
239 $this->verifyfieldlabeltext =
"";
240 $this->verifyfieldentrytext =
"";
241 $this->question_counter = 1;
251 xml_set_object($a_xml_parser, $this);
252 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
253 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
258 $this->question_counter = 1;
259 parent::startParsing();
265 if ($this->depth[$a_xml_parser] > 0) {
266 return $this->path[$this->depth[$a_xml_parser] - 1];
277 switch ($this->parser_mode) {
292 if ($this->do_nothing) {
295 $this->sametag =
false;
296 $this->characterbuffer =
"";
297 $this->depth[$a_xml_parser]++;
298 $this->path[$this->depth[$a_xml_parser]] = strtolower($a_name);
299 $this->qti_element = $a_name;
301 switch (strtolower($a_name)) {
303 include_once(
"./Services/QTI/classes/class.ilQTIAssessment.php");
305 $this->in_assessment =
true;
306 if (is_array($a_attribs)) {
307 foreach ($a_attribs as $attribute => $value) {
308 switch (strtolower($attribute)) {
319 case "assessmentcontrol":
320 include_once(
"./Services/QTI/classes/class.ilQTIAssessmentcontrol.php");
322 if (is_array($a_attribs)) {
323 foreach ($a_attribs as $attribute => $value) {
324 switch (strtolower($attribute)) {
325 case "solutionswitch":
326 $this->assessmentcontrol->setSolutionswitch($value);
329 $this->assessmentcontrol->setHintswitch($value);
331 case "feedbackswitch":
332 $this->assessmentcontrol->setFeedbackswitch($value);
339 include_once(
"./Services/QTI/classes/class.ilQTIObjectives.php");
341 $this->in_objectives =
true;
343 case 'presentation_material':
344 require_once
'Services/QTI/classes/class.ilQTIPresentationMaterial.php';
346 $this->in_prensentation_material =
true;
349 include_once(
"./Services/QTI/classes/class.ilQTISection.php");
353 $this->in_itemmetadata =
true;
355 case "qtimetadatafield":
356 $this->metadata = array(
"label" =>
"",
"entry" =>
"");
359 include_once(
"./Services/QTI/classes/class.ilQTIFlow.php");
363 include_once(
"./Services/QTI/classes/class.ilQTIFlowMat.php");
367 include_once(
"./Services/QTI/classes/class.ilQTIItemfeedback.php");
369 if (is_array($a_attribs)) {
370 foreach ($a_attribs as $attribute => $value) {
371 switch (strtolower($attribute)) {
373 $this->itemfeedback->setIdent($value);
376 $this->itemfeedback->setView($value);
382 case "displayfeedback":
383 include_once(
"./Services/QTI/classes/class.ilQTIDisplayfeedback.php");
385 if (is_array($a_attribs)) {
386 foreach ($a_attribs as $attribute => $value) {
387 switch (strtolower($attribute)) {
389 $this->displayfeedback->setFeedbacktype($value);
392 $this->displayfeedback->setLinkrefid($value);
399 include_once(
"./Services/QTI/classes/class.ilQTISetvar.php");
401 if (is_array($a_attribs)) {
402 foreach ($a_attribs as $attribute => $value) {
403 switch (strtolower($attribute)) {
405 $this->setvar->setAction($value);
408 $this->setvar->setVarname($value);
415 include_once(
"./Services/QTI/classes/class.ilQTIConditionvar.php");
419 if ($this->conditionvar != null) {
420 $this->conditionvar->addNot();
424 if ($this->conditionvar != null) {
425 $this->conditionvar->addAnd();
429 if ($this->conditionvar != null) {
430 $this->conditionvar->addOr();
434 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
436 if (is_array($a_attribs)) {
437 foreach ($a_attribs as $attribute => $value) {
438 switch (strtolower($attribute)) {
440 $this->responsevar->setCase($value);
443 $this->responsevar->setRespident($value);
446 $this->responsevar->setIndex($value);
453 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
455 if (is_array($a_attribs)) {
456 foreach ($a_attribs as $attribute => $value) {
457 switch (strtolower($attribute)) {
459 $this->responsevar->setRespident($value);
462 $this->responsevar->setIndex($value);
469 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
471 if (is_array($a_attribs)) {
472 foreach ($a_attribs as $attribute => $value) {
473 switch (strtolower($attribute)) {
475 $this->responsevar->setRespident($value);
478 $this->responsevar->setIndex($value);
485 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
487 if (is_array($a_attribs)) {
488 foreach ($a_attribs as $attribute => $value) {
489 switch (strtolower($attribute)) {
491 $this->responsevar->setRespident($value);
494 $this->responsevar->setIndex($value);
501 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
503 if (is_array($a_attribs)) {
504 foreach ($a_attribs as $attribute => $value) {
505 switch (strtolower($attribute)) {
507 $this->responsevar->setRespident($value);
510 $this->responsevar->setIndex($value);
517 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
519 if (is_array($a_attribs)) {
520 foreach ($a_attribs as $attribute => $value) {
521 switch (strtolower($attribute)) {
523 $this->responsevar->setRespident($value);
526 $this->responsevar->setSetmatch($value);
529 $this->responsevar->setIndex($value);
536 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
538 if (is_array($a_attribs)) {
539 foreach ($a_attribs as $attribute => $value) {
540 switch (strtolower($attribute)) {
542 $this->responsevar->setRespident($value);
545 $this->responsevar->setAreatype($value);
548 $this->responsevar->setIndex($value);
555 include_once(
"./Services/QTI/classes/class.ilQTIResponseVar.php");
557 if (is_array($a_attribs)) {
558 foreach ($a_attribs as $attribute => $value) {
559 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)) {
577 foreach ($a_attribs as $attribute => $value) {
578 switch (strtolower($attribute)) {
580 $this->respcondition->setContinue($value);
583 $this->respcondition->setTitle($value);
590 include_once(
"./Services/QTI/classes/class.ilQTIOutcomes.php");
594 include_once(
"./Services/QTI/classes/class.ilQTIDecvar.php");
596 if (is_array($a_attribs)) {
597 foreach ($a_attribs as $attribute => $value) {
598 switch (strtolower($attribute)) {
600 $this->decvar->setVarname($value);
603 $this->decvar->setVartype($value);
606 $this->decvar->setDefaultval($value);
609 $this->decvar->setMinvalue($value);
612 $this->decvar->setMaxvalue($value);
615 $this->decvar->setMembers($value);
618 $this->decvar->setCutvalue($value);
625 include_once(
"./Services/QTI/classes/class.ilQTIMatimage.php");
627 if (is_array($a_attribs)) {
628 foreach ($a_attribs as $attribute => $value) {
629 switch (strtolower($attribute)) {
631 $this->matimage->setImagetype($value);
634 $this->matimage->setLabel($value);
637 $this->matimage->setHeight($value);
640 $this->matimage->setWidth($value);
643 $this->matimage->setUri($value);
646 $this->matimage->setEmbedded($value);
649 $this->matimage->setX0($value);
652 $this->matimage->setY0($value);
655 $this->matimage->setEntityref($value);
660 if (!$this->matimage->getEmbedded() && strlen($this->matimage->getUri())) {
661 $this->matimage->setContent(@file_get_contents(dirname($this->xml_file) .
'/' . $this->matimage->getUri()));
665 include_once(
"./Services/QTI/classes/class.ilQTIMaterial.php");
667 $this->material->setFlow($this->flow);
668 if (is_array($a_attribs)) {
669 foreach ($a_attribs as $attribute => $value) {
670 switch (strtolower($attribute)) {
672 $this->material->setLabel($value);
679 include_once(
"./Services/QTI/classes/class.ilQTIMattext.php");
681 if (is_array($a_attribs)) {
682 foreach ($a_attribs as $attribute => $value) {
683 switch (strtolower($attribute)) {
685 $this->mattext->setTexttype($value);
688 $this->mattext->setLabel($value);
691 $this->mattext->setCharset($value);
694 $this->mattext->setUri($value);
697 $this->mattext->setXmlspace($value);
700 $this->mattext->setXmllang($value);
703 $this->mattext->setEntityref($value);
706 $this->mattext->setHeight($value);
709 $this->mattext->setWidth($value);
712 $this->mattext->setX0($value);
715 $this->mattext->setY0($value);
722 include_once(
"./Services/QTI/classes/class.ilQTIMatapplet.php");
724 if (is_array($a_attribs)) {
725 foreach ($a_attribs as $attribute => $value) {
726 switch (strtolower($attribute)) {
728 $this->matapplet->setLabel($value);
731 $this->matapplet->setUri($value);
734 $this->matapplet->setY0($value);
737 $this->matapplet->setHeight($value);
740 $this->matapplet->setWidth($value);
743 $this->matapplet->setX0($value);
746 $this->matapplet->setEmbedded($value);
749 $this->matapplet->setEntityref($value);
755 case "questestinterop":
756 $this->hasRootElement =
true;
765 $this->
assessment->addSection($this->section);
767 $this->section = null;
770 $this->in_presentation =
true;
771 include_once(
"./Services/QTI/classes/class.ilQTIPresentation.php");
774 case "response_label":
775 if ($this->render_type != null) {
776 include_once(
"./Services/QTI/classes/class.ilQTIResponseLabel.php");
778 foreach ($a_attribs as $attribute => $value) {
779 switch (strtolower($attribute)) {
781 $this->response_label->setRshuffle($value);
784 $this->response_label->setRarea($value);
787 $this->response_label->setRrange($value);
790 $this->response_label->setLabelrefid($value);
793 $this->response_label->setIdent($value);
796 $this->response_label->setMatchGroup($value);
799 $this->response_label->setMatchMax($value);
805 case "render_choice":
806 if ($this->in_response) {
807 include_once(
"./Services/QTI/classes/class.ilQTIRenderChoice.php");
809 foreach ($a_attribs as $attribute => $value) {
810 switch (strtolower($attribute)) {
812 $this->render_type->setShuffle($value);
815 $this->render_type->setMinnumber($value);
818 $this->render_type->setMaxnumber($value);
824 case "render_hotspot":
825 if ($this->in_response) {
826 include_once(
"./Services/QTI/classes/class.ilQTIRenderHotspot.php");
828 foreach ($a_attribs as $attribute => $value) {
829 switch (strtolower($attribute)) {
831 $this->render_type->setShuffle($value);
834 $this->render_type->setMinnumber($value);
837 $this->render_type->setMaxnumber($value);
844 if ($this->in_response) {
845 include_once(
"./Services/QTI/classes/class.ilQTIRenderFib.php");
847 foreach ($a_attribs as $attribute => $value) {
848 switch (strtolower($attribute)) {
850 $this->render_type->setEncoding($value);
853 $this->render_type->setFibtype($value);
856 $this->render_type->setRows($value);
859 $this->render_type->setMaxchars($value);
862 $this->render_type->setPrompt($value);
865 $this->render_type->setColumns($value);
868 $this->render_type->setCharset($value);
871 $this->render_type->setMaxnumber($value);
874 $this->render_type->setMinnumber($value);
893 include_once
"./Services/QTI/classes/class.ilQTIResponse.php";
894 switch (strtolower($a_name)) {
911 $this->in_response =
true;
913 $this->response->setFlow($this->flow);
914 if (is_array($a_attribs)) {
915 foreach ($a_attribs as $attribute => $value) {
916 switch (strtolower($attribute)) {
918 $this->response->setIdent($value);
921 $this->response->setRTiming($value);
924 $this->response->setRCardinality($value);
927 $this->response->setNumtype($value);
934 include_once(
"./Services/QTI/classes/class.ilQTIItem.php");
935 $this->gap_index = 0;
936 $this->item = &$this->items[array_push($this->items,
new ilQTIItem()) - 1];
937 if (is_array($a_attribs)) {
938 foreach ($a_attribs as $attribute => $value) {
939 switch (strtolower($attribute)) {
941 $this->item->setIdent($value);
942 $this->item->setIliasSourceNic(
946 $this->do_nothing =
true;
947 } elseif (count($this->import_idents) > 0) {
948 if (!in_array($value, $this->import_idents)) {
949 $this->do_nothing =
true;
954 $this->item->setTitle($value);
957 $this->item->setMaxattempts($value);
963 case "resprocessing":
964 include_once(
"./Services/QTI/classes/class.ilQTIResprocessing.php");
966 if (is_array($a_attribs)) {
967 foreach ($a_attribs as $attribute => $value) {
968 switch (strtolower($attribute)) {
970 $this->resprocessing->setScoremodel($value);
978 $this->solutionhint = array_map(
'intval', $a_attribs);
979 $this->solutionhint[
'txt'] =
'';
990 switch ($this->parser_mode) {
1005 if (($this->do_nothing) && (strcmp(strtolower($a_name),
"item") != 0)) {
1008 switch (strtolower($a_name)) {
1010 if (is_object($this->tst_object)) {
1011 $this->tst_object->fromXML($this->
assessment);
1013 $this->in_assessment =
false;
1015 case "assessmentcontrol":
1016 $this->
assessment->addAssessmentcontrol($this->assessmentcontrol);
1017 $this->assessmentcontrol = null;
1020 if (strcmp(strtolower($this->
getParent($a_xml_parser)),
"assessment") == 0) {
1021 $this->
assessment->addObjectives($this->objectives);
1023 $this->in_objectives =
false;
1025 case 'presentation_material':
1026 $this->
assessment->setPresentationMaterial($this->prensentation_material);
1027 $this->in_prensentation_material =
false;
1029 case "itemmetadata":
1030 $this->in_itemmetadata =
false;
1032 case "qtimetadatafield":
1034 switch ($this->metadata[
"label"]) {
1035 case "ILIAS_VERSION":
1036 if ($this->item != null) {
1037 $this->item->setIliasSourceVersion(
1042 case "QUESTIONTYPE":
1043 if ($this->item != null) {
1044 $this->item->setQuestiontype($this->metadata[
"entry"]);
1048 if ($this->item != null) {
1049 $this->item->setAuthor($this->metadata[
"entry"]);
1053 if ($this->item != null) {
1054 $this->item->addMetadata($this->metadata);
1058 if ($this->in_assessment) {
1059 $this->
assessment->addQtiMetadata($this->metadata);
1061 $this->metadata = array(
"label" =>
"",
"entry" =>
"");
1067 if (count($this->flow_mat)) {
1069 if (count($this->flow_mat)) {
1070 $this->flow_mat[count($this->flow_mat) - 1]->addFlow_mat(
$flow_mat);
1071 } elseif ($this->in_prensentation_material) {
1072 $this->prensentation_material->addFlowMat(
$flow_mat);
1073 } elseif ($this->itemfeedback != null) {
1074 $this->itemfeedback->addFlow_mat(
$flow_mat);
1075 } elseif ($this->response_label != null) {
1076 $this->response_label->addFlow_mat(
$flow_mat);
1080 case "itemfeedback":
1081 if ($this->item != null) {
1082 if ($this->itemfeedback != null) {
1083 $this->item->addItemfeedback($this->itemfeedback);
1086 $this->itemfeedback = null;
1088 case "displayfeedback":
1089 if ($this->respcondition != null) {
1090 if ($this->displayfeedback != null) {
1091 $this->respcondition->addDisplayfeedback($this->displayfeedback);
1094 $this->displayfeedback = null;
1097 if ($this->respcondition != null) {
1098 if ($this->setvar != null) {
1099 $this->respcondition->addSetvar($this->setvar);
1102 $this->setvar = null;
1104 case "conditionvar":
1105 if ($this->respcondition != null) {
1106 $this->respcondition->setConditionvar($this->conditionvar);
1108 $this->conditionvar = null;
1117 case "varsubstring":
1118 if ($this->conditionvar != null) {
1119 if ($this->responsevar != null) {
1120 $this->conditionvar->addResponseVar($this->responsevar);
1123 $this->responsevar = null;
1125 case "respcondition":
1126 if ($this->resprocessing != null) {
1127 $this->resprocessing->addRespcondition($this->respcondition);
1129 $this->respcondition = null;
1132 if ($this->resprocessing != null) {
1133 $this->resprocessing->setOutcomes($this->outcomes);
1135 $this->outcomes = null;
1138 if ($this->outcomes != null) {
1139 $this->outcomes->addDecvar($this->decvar);
1141 $this->decvar = null;
1143 case "presentation":
1144 $this->in_presentation =
false;
1145 if ($this->presentation != null) {
1146 if ($this->item != null) {
1147 $this->item->setPresentation($this->presentation);
1150 $this->presentation = null;
1152 case "response_label":
1153 if ($this->render_type != null) {
1154 $this->render_type->addResponseLabel($this->response_label);
1155 $this->response_label = null;
1158 case "render_choice":
1159 case "render_hotspot":
1161 if ($this->in_response) {
1162 if ($this->response != null) {
1163 if ($this->render_type != null) {
1164 $this->response->setRenderType($this->render_type);
1165 $this->render_type = null;
1170 case "response_lid":
1172 case "response_str":
1173 case "response_num":
1174 case "response_grp":
1176 if ($this->presentation != null) {
1177 if ($this->response != null) {
1178 $this->presentation->addResponse($this->response);
1179 if ($this->item != null) {
1180 $this->item->addPresentationitem($this->response);
1184 $this->response = null;
1185 $this->in_response =
false;
1188 if ($this->do_nothing) {
1189 $this->do_nothing =
false;
1192 if (strlen($this->item->getQuestionType())) {
1205 $qt = $this->item->determineQuestionType();
1212 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1214 $question =
new $qt();
1215 $fbt = str_replace(
'ass',
'ilAss', $qt) .
'Feedback';
1216 $question->feedbackOBJ =
new $fbt(
1227 $this->question_counter,
1228 $this->import_mapping,
1229 $this->solutionhints
1232 $this->solutionhints = [];
1234 $this->numImportedItems++;
1238 if ($this->material) {
1239 $mat = $this->material->getMaterial(0);
1240 if ((strcmp($mat[
"type"],
"mattext") == 0) && (strcmp($mat[
"material"]->getLabel(),
"suggested_solution") == 0)) {
1241 $this->item->addSuggestedSolution($mat[
"material"], $this->gap_index);
1243 if ($this->in_objectives) {
1244 $this->objectives->addMaterial($this->material);
1245 } elseif (($this->render_type != null) && (strcmp(strtolower($this->
getParent($a_xml_parser)),
"render_hotspot") == 0)) {
1246 $this->render_type->addMaterial($this->material);
1247 } elseif (count($this->flow_mat) && (strcmp(strtolower($this->
getParent($a_xml_parser)),
"flow_mat") == 0)) {
1248 $this->flow_mat[count($this->flow_mat) - 1]->addMaterial($this->material);
1249 } elseif ($this->itemfeedback != null) {
1250 $this->itemfeedback->addMaterial($this->material);
1251 } elseif ($this->response_label != null) {
1252 $this->response_label->addMaterial($this->material);
1253 } elseif ($this->response != null) {
1254 if ($this->response->hasRendering()) {
1255 $this->response->setMaterial2($this->material);
1257 $this->response->setMaterial1($this->material);
1259 } elseif (($this->in_presentation) && (!$this->in_response)) {
1260 if (!is_object($this->item->getQuestiontext())) {
1261 $this->item->setQuestiontext($this->material);
1263 $this->presentation->addMaterial($this->material);
1264 } elseif ($this->presentation != null) {
1265 $this->presentation->addMaterial($this->material);
1266 if ($this->item != null) {
1267 $this->item->addPresentationitem($this->material);
1271 $this->material = null;
1279 if ($this->
virusDetected($this->matimage->getRawContent())) {
1283 require_once
'Services/QTI/classes/class.ilQtiMatImageSecurity.php';
1286 $matImageSecurity->sanitizeLabel();
1290 if (!$matImageSecurity->validate()) {
1294 $this->material->addMatimage($this->matimage);
1295 $this->matimage = null;
1301 $this->mattext->setContent(
'<br />');
1302 $this->material->addMattext($this->mattext);
1303 $this->mattext = null;
1305 case "resprocessing":
1306 if ($this->item != null) {
1307 $this->item->addResprocessing($this->resprocessing);
1309 $this->resprocessing = null;
1312 if ($this->material != null) {
1313 $this->material->addMattext($this->mattext);
1315 $this->mattext = null;
1318 if ($this->material != null) {
1319 $this->material->addMatapplet($this->matapplet);
1321 $this->matapplet = null;
1329 $this->depth[$a_xml_parser]--;
1337 switch ($this->parser_mode) {
1352 if ($this->do_nothing) {
1355 $this->characterbuffer .= $a_data;
1357 switch ($this->qti_element) {
1359 $this->metadata[
"label"] = $a_data;
1362 $this->metadata[
"entry"] = $a_data;
1364 case "response_label":
1365 if ($this->response_label != null) {
1366 $this->response_label->setContent($a_data);
1370 if ($this->setvar != null) {
1371 $this->setvar->setContent($a_data);
1374 case "displayfeedback":
1375 if ($this->displayfeedback != null) {
1376 $this->displayfeedback->setContent($a_data);
1386 case "varsubstring":
1387 if ($this->responsevar != null) {
1388 $this->responsevar->setContent($a_data);
1392 if (strlen($a_data)) {
1393 if ($this->decvar != null) {
1394 $this->decvar->setContent($a_data);
1399 if ($this->mattext != null) {
1400 $this->mattext->setContent($a_data);
1404 if ($this->matapplet != null) {
1405 $this->matapplet->setContent($a_data);
1409 if ($this->matimage != null) {
1410 $this->matimage->setContent($a_data);
1414 switch ($this->
getParent($a_xml_parser)) {
1422 $this->item->setDuration($a_data);
1427 switch ($this->
getParent($a_xml_parser)) {
1429 $this->item->setComment($a_data);
1439 $this->sametag =
true;
1447 $this->qti_element = $a_name;
1449 switch (strtolower($a_name)) {
1451 include_once(
"./Services/QTI/classes/class.ilQTIAssessment.php");
1453 $this->in_assessment =
true;
1454 if (is_array($a_attribs)) {
1455 foreach ($a_attribs as $attribute => $value) {
1456 switch (strtolower($attribute)) {
1467 case "questestinterop":
1468 $this->verifyroot =
true;
1470 case "qtimetadatafield":
1471 $this->metadata = array(
"label" =>
"",
"entry" =>
"");
1472 $this->verifymetadatafield = 1;
1475 $this->verifyfieldlabeltext =
"";
1476 if ($this->verifymetadatafield == 1) {
1477 $this->verifyfieldlabel = 1;
1481 $this->verifyfieldentrytext =
"";
1482 if ($this->verifymetadatafield == 1) {
1483 $this->verifyfieldentry = 1;
1488 if (is_array($a_attribs)) {
1489 foreach ($a_attribs as $attribute => $value) {
1490 switch (strtolower($attribute)) {
1497 array_push($this->founditems, array(
"title" =>
"$title",
"type" =>
"",
"ident" => $a_attribs[
"ident"]));
1499 case "response_lid":
1500 if (strlen($this->founditems[count($this->founditems) - 1][
"type"]) == 0) {
1502 if (is_array($a_attribs)) {
1503 foreach ($a_attribs as $attribute => $value) {
1504 switch (strtolower($attribute)) {
1505 case "rcardinality":
1506 include_once
"./Services/QTI/classes/class.ilQTIItem.php";
1507 switch (strtolower($value)) {
1515 $this->founditems[count($this->founditems) - 1][
"type"] =
QT_ORDERING;
1524 case "response_str":
1525 if (strlen($this->founditems[count($this->founditems) - 1][
"type"]) == 0) {
1527 if (is_array($a_attribs)) {
1528 foreach ($a_attribs as $attribute => $value) {
1529 switch (strtolower($attribute)) {
1530 case "rcardinality":
1531 include_once
"./Services/QTI/classes/class.ilQTIItem.php";
1532 switch (strtolower($value)) {
1534 $this->founditems[count($this->founditems) - 1][
"type"] =
QT_CLOZE;
1537 $this->founditems[count($this->founditems) - 1][
"type"] =
QT_TEXT;
1547 if (strlen($this->founditems[count($this->founditems) - 1][
"type"]) == 0) {
1548 $this->founditems[count($this->founditems) - 1][
"type"] =
QT_IMAGEMAP;
1551 case "response_num":
1552 if (strlen($this->founditems[count($this->founditems) - 1][
"type"]) == 0) {
1553 $this->founditems[count($this->founditems) - 1][
"type"] =
QT_NUMERIC;
1556 case "response_grp":
1557 if (strlen($this->founditems[count($this->founditems) - 1][
"type"]) == 0) {
1558 $this->founditems[count($this->founditems) - 1][
"type"] =
QT_MATCHING;
1563 $this->verifyqticomment = 1;
1565 case "presentation":
1566 if (is_array($a_attribs)) {
1567 foreach ($a_attribs as $attribute => $value) {
1568 switch (strtolower($attribute)) {
1570 $this->founditems[count($this->founditems) - 1][
"title"] = $value;
1584 switch (strtolower($a_name)) {
1586 foreach ($this->
assessment->qtimetadata as $metaField) {
1587 if ($metaField[
'label'] ==
'question_set_type') {
1590 } elseif ($metaField[
'label'] ==
'random_test') {
1591 if ($metaField[
'entry'] == 1) {
1599 $this->in_assessment =
false;
1603 $this->verifyqticomment = 0;
1605 case "qtimetadatafield":
1606 $this->verifymetadatafield = 0;
1607 if (strcmp($this->verifyfieldlabeltext,
"QUESTIONTYPE") == 0) {
1610 if ($this->in_assessment) {
1611 $this->
assessment->addQtiMetadata($this->metadata);
1613 $this->metadata = array(
"label" =>
"",
"entry" =>
"");
1616 $this->verifyfieldlabel = 0;
1619 $this->verifyfieldentry = 0;
1629 if ($this->verifyqticomment == 1) {
1630 if (preg_match(
"/Questiontype\=(.*)/", $a_data, $matches)) {
1631 if (count($this->founditems)) {
1632 $this->founditems[count($this->founditems) - 1][
"type"] = $matches[1];
1635 } elseif ($this->verifyfieldlabel == 1) {
1636 $this->verifyfieldlabeltext = $a_data;
1637 } elseif ($this->verifyfieldentry == 1) {
1638 $this->verifyfieldentrytext = $a_data;
1641 switch ($this->qti_element) {
1643 $this->metadata[
"label"] = $a_data;
1646 $this->metadata[
"entry"] = $a_data;
1662 if (!is_array($this->import_mapping)) {
1674 $questionIdMapping = array();
1677 $oldQuestionId = substr($k, strpos($k,
'qst_') + strlen(
'qst_'));
1678 $newQuestionId = $v[
'test'];
1680 $questionIdMapping[$oldQuestionId] = $newQuestionId;
1683 return $questionIdMapping;
1690 return parent::setXMLContent($a_xml_content);
1695 $xmlContent = file_get_contents($this->xml_file);
1697 file_put_contents($this->xml_file, $xmlContent);
1699 return parent::openXMLFile();
1706 if (preg_match(
'/^(\d+\.\d+\.\d+) .*$/', $versionDateString, $matches)) {
1717 if (preg_match(
'/^il_(\d+?)_qst_\d+$/', $itemIdent, $matches)) {
1734 for (
$i = 0x00, $max = 0x08;
$i <= $max;
$i += 0x01) {
1735 $needles[] =
"&#{$i};";
1737 for (
$i = 0x0b, $max = 0x0c;
$i <= $max;
$i += 0x01) {
1738 $needles[] =
"&#{$i};";
1740 for (
$i = 0x0e, $max = 0x1f;
$i <= $max;
$i += 0x01) {
1741 $needles[] =
"&#{$i};";
1743 for (
$i = 0xd800, $max = 0xdfff;
$i <= $max;
$i += 0x0001) {
1744 $needles[] =
"&#{$i};";
1746 for (
$i = 0xfffe, $max = 0xffff;
$i <= $max;
$i += 0x0001) {
1747 $needles[] =
"&#{$i};";
1749 $reg =
'/(' . implode(
'|', $needles) .
')/';
1750 $xmlContent = preg_replace($reg,
'', $xmlContent);
1765 if (!$this->material) {
1769 if (!$this->matimage) {
1778 require_once
'Services/VirusScanner/classes/class.ilVirusScannerFactory.php';
1785 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
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
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
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
__construct(Container $dic, ilPlugin $plugin)
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