24include_once(
"./Services/Xml/classes/class.ilSaxParser.php");
 
   25include_once 
'Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/class.ilAssQuestionTypeList.php';
 
   27define(
"IL_MO_PARSE_QTI", 1);
 
   28define(
"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';
 
 1265                    $matImageSecurity->sanitizeLabel();
 
 1266                } 
catch (Exception $e) {
 
 1269                if (!$matImageSecurity->validate()) {
 
 1273                $this->material->addMatimage($this->matimage);
 
 1274                $this->matimage = 
null;
 
 1280                $this->mattext->setContent(
'<br />');
 
 1281                $this->material->addMattext($this->mattext);
 
 1282                $this->mattext = 
null;
 
 1284            case "resprocessing":
 
 1285                if ($this->item != 
null) {
 
 1286                    $this->item->addResprocessing($this->resprocessing);
 
 1288                $this->resprocessing = 
null;
 
 1291                if ($this->material != 
null) {
 
 1292                    $this->material->addMattext($this->mattext);
 
 1294                $this->mattext = 
null;
 
 1297                if ($this->material != 
null) {
 
 1298                    $this->material->addMatapplet($this->matapplet);
 
 1300                $this->matapplet = 
null;
 
 1303        $this->depth[$a_xml_parser]--;
 
 1311        switch ($this->parser_mode) {
 
 1326        if ($this->do_nothing) {
 
 1329        $this->characterbuffer .= $a_data;
 
 1331        switch ($this->qti_element) {
 
 1333                $this->metadata[
"label"] = $a_data;
 
 1336                $this->metadata[
"entry"] = $a_data;
 
 1338            case "response_label":
 
 1339                if ($this->response_label != 
null) {
 
 1340                    $this->response_label->setContent($a_data);
 
 1344                if ($this->setvar != 
null) {
 
 1345                    $this->setvar->setContent($a_data);
 
 1348            case "displayfeedback":
 
 1349                if ($this->displayfeedback != 
null) {
 
 1350                    $this->displayfeedback->setContent($a_data);
 
 1360            case "varsubstring":
 
 1361                if ($this->responsevar != 
null) {
 
 1362                    $this->responsevar->setContent($a_data);
 
 1366                if (strlen($a_data)) {
 
 1367                    if ($this->decvar != 
null) {
 
 1368                        $this->decvar->setContent($a_data);
 
 1373                if ($this->mattext != 
null) {
 
 1374                    $this->mattext->setContent($a_data);
 
 1378                if ($this->matapplet != 
null) {
 
 1379                    $this->matapplet->setContent($a_data);
 
 1383                if ($this->matimage != 
null) {
 
 1384                    $this->matimage->setContent($a_data);
 
 1388                switch ($this->
getParent($a_xml_parser)) {
 
 1396                        $this->item->setDuration($a_data);
 
 1401                switch ($this->
getParent($a_xml_parser)) {
 
 1403                        $this->item->setComment($a_data);
 
 1413        $this->sametag = 
true;
 
 1421        $this->qti_element = $a_name;
 
 1423        switch (strtolower($a_name)) {
 
 1425                include_once(
"./Services/QTI/classes/class.ilQTIAssessment.php");
 
 1427                $this->in_assessment = 
true;
 
 1428                if (is_array($a_attribs)) {
 
 1429                    foreach ($a_attribs as $attribute => $value) {
 
 1430                        switch (strtolower($attribute)) {
 
 1441            case "questestinterop":
 
 1442                $this->verifyroot = 
true;
 
 1444            case "qtimetadatafield":
 
 1445                $this->metadata = array(
"label" => 
"", 
"entry" => 
"");
 
 1446                $this->verifymetadatafield = 1;
 
 1449                $this->verifyfieldlabeltext = 
"";
 
 1450                if ($this->verifymetadatafield == 1) {
 
 1451                    $this->verifyfieldlabel = 1;
 
 1455                $this->verifyfieldentrytext = 
"";
 
 1456                if ($this->verifymetadatafield == 1) {
 
 1457                    $this->verifyfieldentry = 1;
 
 1462                if (is_array($a_attribs)) {
 
 1463                    foreach ($a_attribs as $attribute => $value) {
 
 1464                        switch (strtolower($attribute)) {
 
 1471                array_push($this->founditems, array(
"title" => 
"$title", 
"type" => 
"", 
"ident" => $a_attribs[
"ident"]));
 
 1473            case "response_lid":
 
 1474                if (strlen($this->founditems[count($this->founditems) - 1][
"type"]) == 0) {
 
 1476                    if (is_array($a_attribs)) {
 
 1477                        foreach ($a_attribs as $attribute => $value) {
 
 1478                            switch (strtolower($attribute)) {
 
 1479                                case "rcardinality":
 
 1480                                    include_once 
"./Services/QTI/classes/class.ilQTIItem.php";
 
 1481                                    switch (strtolower($value)) {
 
 1489                                            $this->founditems[count($this->founditems) - 1][
"type"] = 
QT_ORDERING;
 
 1498            case "response_str":
 
 1499                if (strlen($this->founditems[count($this->founditems) - 1][
"type"]) == 0) {
 
 1501                    if (is_array($a_attribs)) {
 
 1502                        foreach ($a_attribs as $attribute => $value) {
 
 1503                            switch (strtolower($attribute)) {
 
 1504                                case "rcardinality":
 
 1505                                    include_once 
"./Services/QTI/classes/class.ilQTIItem.php";
 
 1506                                    switch (strtolower($value)) {
 
 1508                                            $this->founditems[count($this->founditems) - 1][
"type"] = 
QT_CLOZE;
 
 1511                                            $this->founditems[count($this->founditems) - 1][
"type"] = 
QT_TEXT;
 
 1521                if (strlen($this->founditems[count($this->founditems) - 1][
"type"]) == 0) {
 
 1522                    $this->founditems[count($this->founditems) - 1][
"type"] = 
QT_IMAGEMAP;
 
 1525            case "response_num":
 
 1526                if (strlen($this->founditems[count($this->founditems) - 1][
"type"]) == 0) {
 
 1527                    $this->founditems[count($this->founditems) - 1][
"type"] = 
QT_NUMERIC;
 
 1530            case "response_grp":
 
 1531                if (strlen($this->founditems[count($this->founditems) - 1][
"type"]) == 0) {
 
 1532                    $this->founditems[count($this->founditems) - 1][
"type"] = 
QT_MATCHING;
 
 1537                $this->verifyqticomment = 1;
 
 1539            case "presentation":
 
 1540                if (is_array($a_attribs)) {
 
 1541                    foreach ($a_attribs as $attribute => $value) {
 
 1542                        switch (strtolower($attribute)) {
 
 1544                                $this->founditems[count($this->founditems) - 1][
"title"] = $value;
 
 1558        switch (strtolower($a_name)) {
 
 1560                foreach ($this->
assessment->qtimetadata as $metaField) {
 
 1561                    if ($metaField[
'label'] == 
'question_set_type') {
 
 1564                    } elseif ($metaField[
'label'] == 
'random_test') {
 
 1565                        if ($metaField[
'entry'] == 1) {
 
 1573                $this->in_assessment = 
false;
 
 1577                $this->verifyqticomment = 0;
 
 1579            case "qtimetadatafield":
 
 1580                $this->verifymetadatafield = 0;
 
 1581                if (strcmp($this->verifyfieldlabeltext, 
"QUESTIONTYPE") == 0) {
 
 1584                if ($this->in_assessment) {
 
 1585                    $this->
assessment->addQtiMetadata($this->metadata);
 
 1587                $this->metadata = array(
"label" => 
"", 
"entry" => 
"");
 
 1590                $this->verifyfieldlabel = 0;
 
 1593                $this->verifyfieldentry = 0;
 
 1603        if ($this->verifyqticomment == 1) {
 
 1604            if (preg_match(
"/Questiontype\=(.*)/", $a_data, $matches)) {
 
 1605                if (count($this->founditems)) {
 
 1606                    $this->founditems[count($this->founditems) - 1][
"type"] = $matches[1];
 
 1609        } elseif ($this->verifyfieldlabel == 1) {
 
 1610            $this->verifyfieldlabeltext = $a_data;
 
 1611        } elseif ($this->verifyfieldentry == 1) {
 
 1612            $this->verifyfieldentrytext = $a_data;
 
 1615        switch ($this->qti_element) {
 
 1617                $this->metadata[
"label"] = $a_data;
 
 1620                $this->metadata[
"entry"] = $a_data;
 
 1636        if (!is_array($this->import_mapping)) {
 
 1648        $questionIdMapping = array();
 
 1651            $oldQuestionId = substr($k, strpos($k, 
'qst_') + strlen(
'qst_'));
 
 1652            $newQuestionId = $v[
'test']; 
 
 1654            $questionIdMapping[$oldQuestionId] = $newQuestionId;
 
 1657        return $questionIdMapping;
 
 1664        return parent::setXMLContent($a_xml_content);
 
 1669        $xmlContent = file_get_contents($this->xml_file);
 
 1671        file_put_contents($this->xml_file, $xmlContent);
 
 1673        return parent::openXMLFile();
 
 1680        if (preg_match(
'/^(\d+\.\d+\.\d+) .*$/', $versionDateString, $matches)) {
 
 1691        if (preg_match(
'/^il_(\d+?)_qst_\d+$/', $itemIdent, $matches)) {
 
 1708        for (
$i = 0x00, $max = 0x08; 
$i <= $max; 
$i += 0x01) {
 
 1709            $needles[] = 
"&#{$i};";
 
 1711        for (
$i = 0x0b, $max = 0x0c; 
$i <= $max; 
$i += 0x01) {
 
 1712            $needles[] = 
"&#{$i};";
 
 1714        for (
$i = 0x0e, $max = 0x1f; 
$i <= $max; 
$i += 0x01) {
 
 1715            $needles[] = 
"&#{$i};";
 
 1717        for (
$i = 0xd800, $max = 0xdfff; 
$i <= $max; 
$i += 0x0001) {
 
 1718            $needles[] = 
"&#{$i};";
 
 1720        for (
$i = 0xfffe, $max = 0xffff; 
$i <= $max; 
$i += 0x0001) {
 
 1721            $needles[] = 
"&#{$i};";
 
 1723        $reg = 
'/(' . implode(
'|', $needles) . 
')/';
 
 1724        $xmlContent = preg_replace($reg, 
'', $xmlContent);
 
 1739        if (!$this->material) {
 
 1743        if (!$this->matimage) {
 
 1752        require_once 
'Services/VirusScanner/classes/class.ilVirusScannerFactory.php';
 
 1759        return (
bool) $vs->scanBuffer($buffer);
 
An exception for terminatinating execution or to throw for unit testing.
const QT_MULTIPLE_CHOICE_MR
const QT_MULTIPLE_CHOICE_SR
const RESPONSEVAR_SUBSTRING
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
static isImportable($questionTypeTag)
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
setHandlers($a_xml_parser)
set event handler should be overwritten by inherited class @access private
fetchNumericVersionFromVersionDateString($versionDateString)
handlerVerifyEndTag($a_xml_parser, $a_name)
handler for end of element verification
openXMLFile()
open xml file
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
__construct($a_xml_file, $a_mode=IL_MO_PARSE_QTI, $a_qpl_id=0, $a_import_idents="")
Constructor.
setXMLContent($a_xml_content)
handlerParseEndTag($a_xml_parser, $a_name)
handler for end of element parser
startParsing()
stores xml data in array
getImportMapping()
get array of new created questions for import id
setQuestionSetType($questionSetType)
setTestObject(&$a_tst_object)
handlerVerifyBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element verification
setIgnoreItemsEnabled($ignoreItemsEnabled)
handlerParseCharacterData($a_xml_parser, $a_data)
handler for character data
cleanInvalidXmlChars($xmlContent)
setParserMode($a_mode=IL_MO_PARSE_QTI)
handlerParseBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element parser
handlerVerifyCharacterData($a_xml_parser, $a_data)
handler for character data verification
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
fetchSourceNicFromItemIdent($itemIdent)
$in_prensentation_material
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
Class ilQTIPresentationMaterial.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.