• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/QTI/classes/class.ilQTIParser.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once("./classes/class.ilSaxParser.php");
00025 
00026 define ("IL_MO_PARSE_QTI",  1);
00027 define ("IL_MO_VERIFY_QTI", 2);
00028 
00038 class ilQTIParser extends ilSaxParser
00039 {
00040         var $lng;
00041         var $hasRootElement;
00042         var $path;
00043         var $items;
00044         var $item;
00045         var $depth;
00046         var $qti_element;
00047         var $in_presentation;
00048         var $in_response;
00049         var $render_type;
00050         var $response_label;
00051         var $material;
00052         var $matimage;
00053         var $response;
00054         var $resprocessing;
00055         var $outcomes;
00056         var $decvar;
00057         var $respcondition;
00058         var $setvar;
00059         var $displayfeedback;
00060         var $itemfeedback;
00061         var $flow_mat;
00062         var $flow;
00063         var $presentation;
00064         var $mattext;
00065         var $sametag;
00066         var $characterbuffer;
00067         var $conditionvar;
00068         var $parser_mode;
00069         var $import_idents;
00070         var $qpl_id;
00071         var $tst_id;
00072         var $tst_object;
00073         var $do_nothing;
00074         var $gap_index;
00075         var $assessments;
00076         var $assessment;
00077         var $assessmentcontrol;
00078         var $objectives;
00079         var $in_assessment = FALSE;
00080         var $section;
00081         var $import_mapping;
00082         var $question_counter = 1;
00083         var $in_itemmetadata;
00084         var $in_objectives = FALSE;
00085 
00086         var $founditems = array();
00087         var $verifyroot = false;
00088         var $verifyqticomment = 0;
00089         var $verifymetadatafield = 0;
00090         var $verifyfieldlabel = 0;
00091         var $verifyfieldlabeltext = "";
00092         var $verifyfieldentry = 0;
00093         var $verifyfieldentrytext = "";
00094         
00102         //  TODO: The following line gets me an parse error in PHP 4, but I found no hint that pass-by-reference is forbidden in PHP 4 ????
00103         function ilQTIParser($a_xml_file, $a_mode = IL_MO_PARSE_QTI, $a_qpl_id = 0, $a_import_idents = "")
00104         {
00105                 global $lng;
00106 
00107                 $this->setParserMode($a_mode);
00108 
00109                 parent::ilSaxParser($a_xml_file);
00110 
00111                 $this->qpl_id = $a_qpl_id;
00112                 $this->import_idents = array();
00113                 if (is_array($a_import_idents))
00114                 {
00115                         $this->import_idents =& $a_import_idents;
00116                 }
00117                 
00118                 $this->lng =& $lng;
00119                 $this->hasRootElement = FALSE;
00120                 $this->import_mapping = array();
00121                 $this->assessments = array();
00122                 $this->assessment = NULL;
00123                 $this->section = NULL;
00124                 $this->path = array();
00125                 $this->items = array();
00126                 $this->item = NULL;
00127                 $this->depth = array();
00128                 $this->do_nothing = FALSE;
00129                 $this->qti_element = "";
00130                 $this->in_presentation = FALSE;
00131                 $this->in_objectives = FALSE;
00132                 $this->in_reponse = FALSE;
00133                 $this->render_type = NULL;
00134                 $this->render_hotspot = NULL;
00135                 $this->response_label = NULL;
00136                 $this->material = NULL;
00137                 $this->response = NULL;
00138                 $this->assessmentcontrol = NULL;
00139                 $this->objectives = NULL;
00140                 $this->matimage = NULL;
00141                 $this->resprocessing = NULL;
00142                 $this->outcomes = NULL;
00143                 $this->decvar = NULL;
00144                 $this->respcondition = NULL;
00145                 $this->setvar = NULL;
00146                 $this->displayfeedback = NULL;
00147                 $this->itemfeedback = NULL;
00148                 $this->flow_mat = array();
00149                 $this->question_counter = 1;
00150                 $this->flow = 0;
00151                 $this->gap_index = 0;
00152                 $this->presentation = NULL;
00153                 $this->mattext = NULL;
00154                 $this->matapplet = NULL;
00155                 $this->sametag = FALSE;
00156                 $this->in_assessment = FALSE;
00157                 $this->characterbuffer = "";
00158                 $this->metadata = array("label" => "", "entry" => "");
00159         }
00160         
00161         function setTestObject(&$a_tst_object)
00162         {
00163                 $this->tst_object =& $a_tst_object;
00164                 if (is_object($a_tst_object))
00165                 {
00166                         $this->tst_id = $this->tst_object->getId();
00167                 }
00168         }
00169 
00170         function setParserMode($a_mode = IL_MO_PARSE_QTI)
00171         {
00172                 $this->parser_mode = $a_mode;
00173                 $this->founditems = array();
00174                 $this->verifyroot = false;
00175                 $this->verifyqticomment = 0;
00176                 $this->verifymetadatafield = 0;
00177                 $this->verifyfieldlabel = 0;
00178                 $this->verifyfieldentry = 0;
00179                 $this->verifyfieldlabeltext = "";
00180                 $this->verifyfieldentrytext = "";
00181                 $this->question_counter = 1;
00182         }
00183         
00189         function setHandlers($a_xml_parser)
00190         {
00191                 xml_set_object($a_xml_parser,$this);
00192                 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
00193                 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
00194         }
00195 
00196         function startParsing()
00197         {
00198                 $this->question_counter = 1;
00199                 parent::startParsing();
00200                 return FALSE;
00201         }
00202 
00203         function getParent($a_xml_parser)
00204         {
00205                 if ($this->depth[$a_xml_parser] > 0)
00206                 {
00207                         return $this->path[$this->depth[$a_xml_parser]-1];
00208                 }
00209                 else
00210                 {
00211                         return "";
00212                 }
00213         }
00214         
00218         function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
00219         {
00220                 switch ($this->parser_mode)
00221                 {
00222                         case IL_MO_PARSE_QTI:
00223                                 $this->handlerParseBeginTag($a_xml_parser, $a_name, $a_attribs);
00224                                 break;
00225                         case IL_MO_VERIFY_QTI:
00226                                 $this->handlerVerifyBeginTag($a_xml_parser, $a_name, $a_attribs);
00227                                 break;
00228                 }
00229         }
00230 
00234         function handlerParseBeginTag($a_xml_parser,$a_name,$a_attribs)
00235         {
00236                 if ($this->do_nothing) return;
00237                 $this->sametag = FALSE;
00238                 $this->characterbuffer = "";
00239                 $this->depth[$a_xml_parser]++;
00240                 $this->path[$this->depth[$a_xml_parser]] = strtolower($a_name);
00241                 $this->qti_element = $a_name;
00242                 
00243                 switch (strtolower($a_name))
00244                 {
00245                         case "assessment":
00246                                 include_once ("./Services/QTI/classes/class.ilQTIAssessment.php");
00247                                 $this->assessment =& $this->assessments[array_push($this->assessments, new ilQTIAssessment())-1];
00248                                 $this->in_assessment = TRUE;
00249                                 if (is_array($a_attribs))
00250                                 {
00251                                         foreach ($a_attribs as $attribute => $value)
00252                                         {
00253                                                 switch (strtolower($attribute))
00254                                                 {
00255                                                         case "title":
00256                                                                 $this->assessment->setTitle($value);
00257                                                                 break;
00258                                                         case "ident":
00259                                                                 $this->assessment->setIdent($value);
00260                                                                 break;
00261                                                 }
00262                                         }
00263                                 }
00264                                 break;
00265                         case "assessmentcontrol":
00266                                 include_once ("./Services/QTI/classes/class.ilQTIAssessmentcontrol.php");
00267                                 $this->assessmentcontrol = new ilQTIAssessmentcontrol();
00268                                 if (is_array($a_attribs))
00269                                 {
00270                                         foreach ($a_attribs as $attribute => $value)
00271                                         {
00272                                                 switch (strtolower($attribute))
00273                                                 {
00274                                                         case "solutionswitch":
00275                                                                 $this->assessmentcontrol->setSolutionswitch($value);
00276                                                                 break;
00277                                                         case "hintswitch":
00278                                                                 $this->assessmentcontrol->setHintswitch($value);
00279                                                                 break;
00280                                                         case "feedbackswitch":
00281                                                                 $this->assessmentcontrol->setFeedbackswitch($value);
00282                                                                 break;
00283                                                 }
00284                                         }
00285                                 }
00286                                 break;
00287                         case "objectives":
00288                                 include_once ("./Services/QTI/classes/class.ilQTIObjectives.php");
00289                                 $this->objectives = new ilQTIObjectives();
00290                                 $this->in_objectives = TRUE;
00291                                 break;
00292                         case "section":
00293                                 include_once ("./Services/QTI/classes/class.ilQTISection.php");
00294                                 $this->section = new ilQTISection();
00295                                 break;
00296                         case "itemmetadata":
00297                                 $this->in_itemmetadata = TRUE;
00298                                 break;
00299                         case "qtimetadatafield":
00300                                 $this->metadata = array("label" => "", "entry" => "");
00301                                 break;
00302                         case "flow":
00303                                 include_once ("./Services/QTI/classes/class.ilQTIFlow.php");
00304                                 $this->flow++;
00305                                 break;
00306                         case "flow_mat":
00307                                 include_once ("./Services/QTI/classes/class.ilQTIFlowMat.php");
00308                                 array_push($this->flow_mat, new ilQTIFlowMat());
00309                                 break;
00310                         case "itemfeedback":
00311                                 include_once ("./Services/QTI/classes/class.ilQTIItemfeedback.php");
00312                                 $this->itemfeedback = new ilQTIItemfeedback();
00313                                 if (is_array($a_attribs))
00314                                 {
00315                                         foreach ($a_attribs as $attribute => $value)
00316                                         {
00317                                                 switch (strtolower($attribute))
00318                                                 {
00319                                                         case "ident":
00320                                                                 $this->itemfeedback->setIdent($value);
00321                                                                 break;
00322                                                         case "view":
00323                                                                 $this->itemfeedback->setView($value);
00324                                                                 break;
00325                                                 }
00326                                         }
00327                                 }
00328                                 break;
00329                         case "displayfeedback":
00330                                 include_once ("./Services/QTI/classes/class.ilQTIDisplayfeedback.php");
00331                                 $this->displayfeedback = new ilQTIDisplayfeedback();
00332                                 if (is_array($a_attribs))
00333                                 {
00334                                         foreach ($a_attribs as $attribute => $value)
00335                                         {
00336                                                 switch (strtolower($attribute))
00337                                                 {
00338                                                         case "feedbacktype":
00339                                                                 $this->displayfeedback->setFeedbacktype($value);
00340                                                                 break;
00341                                                         case "linkrefid":
00342                                                                 $this->displayfeedback->setLinkrefid($value);
00343                                                                 break;
00344                                                 }
00345                                         }
00346                                 }
00347                                 break;
00348                         case "setvar":
00349                                 include_once ("./Services/QTI/classes/class.ilQTISetvar.php");
00350                                 $this->setvar = new ilQTISetvar();
00351                                 if (is_array($a_attribs))
00352                                 {
00353                                         foreach ($a_attribs as $attribute => $value)
00354                                         {
00355                                                 switch (strtolower($attribute))
00356                                                 {
00357                                                         case "action":
00358                                                                 $this->setvar->setAction($value);
00359                                                                 break;
00360                                                         case "varname":
00361                                                                 $this->setvar->setVarname($value);
00362                                                                 break;
00363                                                 }
00364                                         }
00365                                 }
00366                                 break;
00367                         case "conditionvar":
00368                                 include_once ("./Services/QTI/classes/class.ilQTIConditionvar.php");
00369                                 $this->conditionvar = new ilQTIConditionvar();
00370                                 break;
00371                         case "not":
00372                                 if ($this->conditionvar != NULL)
00373                                 {
00374                                         $this->conditionvar->addNot();
00375                                 }
00376                                 break;
00377                         case "and":
00378                                 if ($this->conditionvar != NULL)
00379                                 {
00380                                         $this->conditionvar->addAnd();
00381                                 }
00382                                 break;
00383                         case "or":
00384                                 if ($this->conditionvar != NULL)
00385                                 {
00386                                         $this->conditionvar->addOr();
00387                                 }
00388                                 break;
00389                         case "varequal":
00390                                 include_once("./Services/QTI/classes/class.ilQTIResponseVar.php");
00391                                 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_EQUAL);
00392                                 if (is_array($a_attribs))
00393                                 {
00394                                         foreach ($a_attribs as $attribute => $value)
00395                                         {
00396                                                 switch (strtolower($attribute))
00397                                                 {
00398                                                         case "case":
00399                                                                 $this->responsevar->setCase($value);
00400                                                                 break;
00401                                                         case "respident":
00402                                                                 $this->responsevar->setRespident($value);
00403                                                                 break;
00404                                                         case "index":
00405                                                                 $this->responsevar->setIndex($value);
00406                                                                 break;
00407                                                 }
00408                                         }
00409                                 }
00410                                 break;
00411                         case "varlt":
00412                                 include_once("./Services/QTI/classes/class.ilQTIResponseVar.php");
00413                                 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_LT);
00414                                 if (is_array($a_attribs))
00415                                 {
00416                                         foreach ($a_attribs as $attribute => $value)
00417                                         {
00418                                                 switch (strtolower($attribute))
00419                                                 {
00420                                                         case "respident":
00421                                                                 $this->responsevar->setRespident($value);
00422                                                                 break;
00423                                                         case "index":
00424                                                                 $this->responsevar->setIndex($value);
00425                                                                 break;
00426                                                 }
00427                                         }
00428                                 }
00429                                 break;
00430                         case "varlte":
00431                                 include_once("./Services/QTI/classes/class.ilQTIResponseVar.php");
00432                                 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_LTE);
00433                                 if (is_array($a_attribs))
00434                                 {
00435                                         foreach ($a_attribs as $attribute => $value)
00436                                         {
00437                                                 switch (strtolower($attribute))
00438                                                 {
00439                                                         case "respident":
00440                                                                 $this->responsevar->setRespident($value);
00441                                                                 break;
00442                                                         case "index":
00443                                                                 $this->responsevar->setIndex($value);
00444                                                                 break;
00445                                                 }
00446                                         }
00447                                 }
00448                                 break;
00449                         case "vargt":
00450                                 include_once("./Services/QTI/classes/class.ilQTIResponseVar.php");
00451                                 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_GT);
00452                                 if (is_array($a_attribs))
00453                                 {
00454                                         foreach ($a_attribs as $attribute => $value)
00455                                         {
00456                                                 switch (strtolower($attribute))
00457                                                 {
00458                                                         case "respident":
00459                                                                 $this->responsevar->setRespident($value);
00460                                                                 break;
00461                                                         case "index":
00462                                                                 $this->responsevar->setIndex($value);
00463                                                                 break;
00464                                                 }
00465                                         }
00466                                 }
00467                                 break;
00468                         case "vargte":
00469                                 include_once("./Services/QTI/classes/class.ilQTIResponseVar.php");
00470                                 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_GTE);
00471                                 if (is_array($a_attribs))
00472                                 {
00473                                         foreach ($a_attribs as $attribute => $value)
00474                                         {
00475                                                 switch (strtolower($attribute))
00476                                                 {
00477                                                         case "respident":
00478                                                                 $this->responsevar->setRespident($value);
00479                                                                 break;
00480                                                         case "index":
00481                                                                 $this->responsevar->setIndex($value);
00482                                                                 break;
00483                                                 }
00484                                         }
00485                                 }
00486                                 break;
00487                         case "varsubset":
00488                                 include_once("./Services/QTI/classes/class.ilQTIResponseVar.php");
00489                                 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_SUBSET);
00490                                 if (is_array($a_attribs))
00491                                 {
00492                                         foreach ($a_attribs as $attribute => $value)
00493                                         {
00494                                                 switch (strtolower($attribute))
00495                                                 {
00496                                                         case "respident":
00497                                                                 $this->responsevar->setRespident($value);
00498                                                                 break;
00499                                                         case "setmatch":
00500                                                                 $this->responsevar->setSetmatch($value);
00501                                                                 break;
00502                                                         case "index":
00503                                                                 $this->responsevar->setIndex($value);
00504                                                                 break;
00505                                                 }
00506                                         }
00507                                 }
00508                                 break;
00509                         case "varinside":
00510                                 include_once("./Services/QTI/classes/class.ilQTIResponseVar.php");
00511                                 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_INSIDE);
00512                                 if (is_array($a_attribs))
00513                                 {
00514                                         foreach ($a_attribs as $attribute => $value)
00515                                         {
00516                                                 switch (strtolower($attribute))
00517                                                 {
00518                                                         case "respident":
00519                                                                 $this->responsevar->setRespident($value);
00520                                                                 break;
00521                                                         case "areatype":
00522                                                                 $this->responsevar->setAreatype($value);
00523                                                                 break;
00524                                                         case "index":
00525                                                                 $this->responsevar->setIndex($value);
00526                                                                 break;
00527                                                 }
00528                                         }
00529                                 }
00530                                 break;
00531                         case "varsubstring":
00532                                 include_once("./Services/QTI/classes/class.ilQTIResponseVar.php");
00533                                 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_SUBSTRING);
00534                                 if (is_array($a_attribs))
00535                                 {
00536                                         foreach ($a_attribs as $attribute => $value)
00537                                         {
00538                                                 switch (strtolower($attribute))
00539                                                 {
00540                                                         case "case":
00541                                                                 $this->responsevar->setCase($value);
00542                                                                 break;
00543                                                         case "respident":
00544                                                                 $this->responsevar->setRespident($value);
00545                                                                 break;
00546                                                         case "index":
00547                                                                 $this->responsevar->setIndex($value);
00548                                                                 break;
00549                                                 }
00550                                         }
00551                                 }
00552                                 break;
00553                         case "respcondition":
00554                                 include_once("./Services/QTI/classes/class.ilQTIRespcondition.php");
00555                                 $this->respcondition = new ilQTIRespcondition();
00556                                 if (is_array($a_attribs))
00557                                 {
00558                                         foreach ($a_attribs as $attribute => $value)
00559                                         {
00560                                                 switch (strtolower($attribute))
00561                                                 {
00562                                                         case "continue":
00563                                                                 $this->respcondition->setContinue($value);
00564                                                                 break;
00565                                                         case "title":
00566                                                                 $this->respcondition->setTitle($value);
00567                                                                 break;
00568                                                 }
00569                                         }
00570                                 }
00571                                 break;
00572                         case "outcomes":
00573                                 include_once("./Services/QTI/classes/class.ilQTIOutcomes.php");
00574                                 $this->outcomes = new ilQTIOutcomes();
00575                                 break;
00576                         case "decvar":
00577                                 include_once("./Services/QTI/classes/class.ilQTIDecvar.php");
00578                                 $this->decvar = new ilQTIDecvar();
00579                                 if (is_array($a_attribs))
00580                                 {
00581                                         foreach ($a_attribs as $attribute => $value)
00582                                         {
00583                                                 switch (strtolower($attribute))
00584                                                 {
00585                                                         case "varname":
00586                                                                 $this->decvar->setVarname($value);
00587                                                                 break;
00588                                                         case "vartype":
00589                                                                 $this->decvar->setVartype($value);
00590                                                                 break;
00591                                                         case "defaultval":
00592                                                                 $this->decvar->setDefaultval($value);
00593                                                                 break;
00594                                                         case "minvalue":
00595                                                                 $this->decvar->setMinvalue($value);
00596                                                                 break;
00597                                                         case "maxvalue":
00598                                                                 $this->decvar->setMaxvalue($value);
00599                                                                 break;
00600                                                         case "members":
00601                                                                 $this->decvar->setMembers($value);
00602                                                                 break;
00603                                                         case "cutvalue":
00604                                                                 $this->decvar->setCutvalue($value);
00605                                                                 break;
00606                                                 }
00607                                         }
00608                                 }
00609                                 break;
00610                         case "matimage":
00611                                 include_once("./Services/QTI/classes/class.ilQTIMatimage.php");
00612                                 $this->matimage = new ilQTIMatimage();
00613                                 if (is_array($a_attribs))
00614                                 {
00615                                         foreach ($a_attribs as $attribute => $value)
00616                                         {
00617                                                 switch (strtolower($attribute))
00618                                                 {
00619                                                         case "imagtype":
00620                                                                 $this->matimage->setImagetype($value);
00621                                                                 break;
00622                                                         case "label":
00623                                                                 $this->matimage->setLabel($value);
00624                                                                 break;
00625                                                         case "height":
00626                                                                 $this->matimage->setHeight($value);
00627                                                                 break;
00628                                                         case "width":
00629                                                                 $this->matimage->setWidth($value);
00630                                                                 break;
00631                                                         case "uri":
00632                                                                 $this->matimage->setUri($value);
00633                                                                 break;
00634                                                         case "embedded":
00635                                                                 $this->matimage->setEmbedded($value);
00636                                                                 break;
00637                                                         case "x0":
00638                                                                 $this->matimage->setX0($value);
00639                                                                 break;
00640                                                         case "y0":
00641                                                                 $this->matimage->setY0($value);
00642                                                                 break;
00643                                                         case "entityref":
00644                                                                 $this->matimage->setEntityref($value);
00645                                                                 break;
00646                                                 }
00647                                         }
00648                                 }
00649                                 break;
00650                         case "material":
00651                                 include_once("./Services/QTI/classes/class.ilQTIMaterial.php");
00652                                 $this->material = new ilQTIMaterial();
00653                                 $this->material->setFlow($this->flow);
00654                                 if (is_array($a_attribs))
00655                                 {
00656                                         foreach ($a_attribs as $attribute => $value)
00657                                         {
00658                                                 switch (strtolower($attribute))
00659                                                 {
00660                                                         case "label":
00661                                                                 $this->material->setLabel($value);
00662                                                                 break;
00663                                                 }
00664                                         }
00665                                 }
00666                                 break;
00667                         case "mattext":
00668                                 include_once ("./Services/QTI/classes/class.ilQTIMattext.php");
00669                                 $this->mattext = new ilQTIMattext();
00670                                 if (is_array($a_attribs))
00671                                 {
00672                                         foreach ($a_attribs as $attribute => $value)
00673                                         {
00674                                                 switch (strtolower($attribute))
00675                                                 {
00676                                                         case "texttype":
00677                                                                 $this->mattext->setTexttype($value);
00678                                                                 break;
00679                                                         case "label":
00680                                                                 $this->mattext->setLabel($value);
00681                                                                 break;
00682                                                         case "charset":
00683                                                                 $this->mattext->setCharset($value);
00684                                                                 break;
00685                                                         case "uri":
00686                                                                 $this->mattext->setUri($value);
00687                                                                 break;
00688                                                         case "xml:space":
00689                                                                 $this->mattext->setXmlspace($value);
00690                                                                 break;
00691                                                         case "xml:lang":
00692                                                                 $this->mattext->setXmllang($value);
00693                                                                 break;
00694                                                         case "entityref":
00695                                                                 $this->mattext->setEntityref($value);
00696                                                                 break;
00697                                                         case "height":
00698                                                                 $this->mattext->setHeight($value);
00699                                                                 break;
00700                                                         case "width":
00701                                                                 $this->mattext->setWidth($value);
00702                                                                 break;
00703                                                         case "x0":
00704                                                                 $this->mattext->setX0($value);
00705                                                                 break;
00706                                                         case "y0":
00707                                                                 $this->mattext->setY0($value);
00708                                                                 break;
00709                                                 }
00710                                         }
00711                                 }
00712                                 break;
00713                         case "matapplet":
00714                                 include_once ("./Services/QTI/classes/class.ilQTIMatapplet.php");
00715                                 $this->matapplet = New ilQTIMatapplet();
00716                                 if (is_array($a_attribs))
00717                                 {
00718                                         foreach ($a_attribs as $attribute => $value)
00719                                         {
00720                                                 switch (strtolower($attribute))
00721                                                 {
00722                                                         case "label":
00723                                                                 $this->matapplet->setLabel($value);
00724                                                                 break;
00725                                                         case "uri":
00726                                                                 $this->matapplet->setUri($value);
00727                                                                 break;
00728                                                         case "y0":
00729                                                                 $this->matapplet->setY0($value);
00730                                                                 break;
00731                                                         case "height":
00732                                                                 $this->matapplet->setHeight($value);
00733                                                                 break;
00734                                                         case "width":
00735                                                                 $this->matapplet->setWidth($value);
00736                                                                 break;
00737                                                         case "x0":
00738                                                                 $this->matapplet->setX0($value);
00739                                                                 break;
00740                                                         case "embedded":
00741                                                                 $this->matapplet->setEmbedded($value);
00742                                                                 break;
00743                                                         case "entityref":
00744                                                                 $this->matapplet->setEntityref($value);
00745                                                                 break;
00746                                                 }
00747                                         }
00748                                 }
00749                                 break;
00750                         case "questestinterop":
00751                                 $this->hasRootElement = TRUE;
00752                                 break;
00753                         case "qticomment":
00754                                 break;
00755                         case "objectbank":
00756                                 // not implemented yet
00757                                 break;
00758                         case "section":
00759                                 if ($this->assessment != NULL)
00760                                 {
00761                                         $this->assessment->addSection($this->section);
00762                                 }
00763                                 $this->section = NULL;
00764                                 break;
00765                         case "presentation":
00766                                 $this->in_presentation = TRUE;
00767                                 include_once ("./Services/QTI/classes/class.ilQTIPresentation.php");
00768                                 $this->presentation = new ilQTIPresentation();
00769                                 break;
00770                         case "response_label":
00771                                 if ($this->render_type != NULL)
00772                                 {
00773                                 include_once("./Services/QTI/classes/class.ilQTIResponseLabel.php");
00774                                         $this->response_label = new ilQTIResponseLabel();
00775                                         foreach ($a_attribs as $attribute => $value)
00776                                         {
00777                                                 switch (strtolower($attribute))
00778                                                 {
00779                                                         case "rshuffle":
00780                                                                 $this->response_label->setRshuffle($value);
00781                                                                 break;
00782                                                         case "rarea":
00783                                                                 $this->response_label->setRarea($value);
00784                                                                 break;
00785                                                         case "rrange":
00786                                                                 $this->response_label->setRrange($value);
00787                                                                 break;
00788                                                         case "labelrefid":
00789                                                                 $this->response_label->setLabelrefid($value);
00790                                                                 break;
00791                                                         case "ident":
00792                                                                 $this->response_label->setIdent($value);
00793                                                                 break;
00794                                                         case "match_group":
00795                                                                 $this->response_label->setMatchGroup($value);
00796                                                                 break;
00797                                                         case "match_max":
00798                                                                 $this->response_label->setMatchMax($value);
00799                                                                 break;
00800                                                 }
00801                                         }
00802                                 }
00803                                 break;
00804                         case "render_choice":
00805                                 if ($this->in_response)
00806                                 {
00807                                         include_once("./Services/QTI/classes/class.ilQTIRenderChoice.php");
00808                                         $this->render_type = new ilQTIRenderChoice();
00809                                         foreach ($a_attribs as $attribute => $value)
00810                                         {
00811                                                 switch (strtolower($attribute))
00812                                                 {
00813                                                         case "shuffle":
00814                                                                 $this->render_type->setShuffle($value);
00815                                                                 break;
00816                                                 }
00817                                         }
00818                                 }
00819                                 break;
00820                         case "render_hotspot":
00821                                 if ($this->in_response)
00822                                 {
00823                                         include_once("./Services/QTI/classes/class.ilQTIRenderHotspot.php");
00824                                         $this->render_type = new ilQTIRenderHotspot();
00825                                         foreach ($a_attribs as $attribute => $value)
00826                                         {
00827                                                 switch (strtolower($attribute))
00828                                                 {
00829                                                         case "showdraw":
00830                                                                 $this->render_type->setShuffle($value);
00831                                                                 break;
00832                                                         case "minnumber":
00833                                                                 $this->render_type->setMinnumber($value);
00834                                                                 break;
00835                                                         case "maxnumber":
00836                                                                 $this->render_type->setMaxnumber($value);
00837                                                                 break;
00838                                                 }
00839                                         }
00840                                 }
00841                                 break;
00842                         case "render_fib":
00843                                 if ($this->in_response)
00844                                 {
00845                                         include_once("./Services/QTI/classes/class.ilQTIRenderFib.php");
00846                                         $this->render_type = new ilQTIRenderFib();
00847                                         foreach ($a_attribs as $attribute => $value)
00848                                         {
00849                                                 switch (strtolower($attribute))
00850                                                 {
00851                                                         case "encoding":
00852                                                                 $this->render_type->setEncoding($value);
00853                                                                 break;
00854                                                         case "fibtype":
00855                                                                 $this->render_type->setFibtype($value);
00856                                                                 break;
00857                                                         case "rows":
00858                                                                 $this->render_type->setRows($value);
00859                                                                 break;
00860                                                         case "maxchars":
00861                                                                 $this->render_type->setMaxchars($value);
00862                                                                 break;
00863                                                         case "prompt":
00864                                                                 $this->render_type->setPrompt($value);
00865                                                                 break;
00866                                                         case "columns":
00867                                                                 $this->render_type->setColumns($value);
00868                                                                 break;
00869                                                         case "charset":
00870                                                                 $this->render_type->setCharset($value);
00871                                                                 break;
00872                                                         case "maxnumber":
00873                                                                 $this->render_type->setMaxnumber($value);
00874                                                                 break;
00875                                                         case "minnumber":
00876                                                                 $this->render_type->setMinnumber($value);
00877                                                                 break;
00878                                                 }
00879                                         }
00880                                 }
00881                                 break;
00882                         case "response_lid":
00883                                 // Ordering Terms and Definitions    or
00884                                 // Ordering Terms and Pictures       or
00885                                 // Multiple choice single response   or
00886                                 // Multiple choice multiple response
00887                         case "response_xy":
00888                                 // Imagemap question
00889                         case "response_str":
00890                                 // Close question
00891                         case "response_num":
00892                         case "response_grp":
00893                                 // Matching terms and definitions
00894                                 // Matching terms and images
00895                                 include_once "./Services/QTI/classes/class.ilQTIResponse.php";
00896                                 switch (strtolower($a_name))
00897                                 {
00898                                         case "response_lid":
00899                                                 $response_type = RT_RESPONSE_LID;
00900                                                 break;
00901                                         case "response_xy":
00902                                                 $response_type = RT_RESPONSE_XY;
00903                                                 break;
00904                                         case "response_str":
00905                                                 $response_type = RT_RESPONSE_STR;
00906                                                 break;
00907                                         case "response_num":
00908                                                 $response_type = RT_RESPONSE_NUM;
00909                                                 break;
00910                                         case "response_grp":
00911                                                 $response_type = RT_RESPONSE_GRP;
00912                                                 break;
00913                                 }
00914                                 $this->in_response = TRUE;
00915                                 $this->response = new ilQTIResponse($response_type);
00916                                 $this->response->setFlow($this->flow);
00917                                 if (is_array($a_attribs))
00918                                 {
00919                                         foreach ($a_attribs as $attribute => $value)
00920                                         {
00921                                                 switch (strtolower($attribute))
00922                                                 {
00923                                                         case "ident":
00924                                                                 $this->response->setIdent($value);
00925                                                                 break;
00926                                                         case "rtiming":
00927                                                                 $this->response->setRTiming($value);
00928                                                                 break;
00929                                                         case "rcardinality":
00930                                                                 $this->response->setRCardinality($value);
00931                                                                 break;
00932                                                         case "numtype":
00933                                                                 $this->response->setNumtype($value);
00934                                                                 break;
00935                                                 }
00936                                         }
00937                                 }
00938                                 break;
00939                         case "item":
00940                                 include_once("./Services/QTI/classes/class.ilQTIItem.php");
00941                                 $this->gap_index = 0;
00942                                 $this->item =& $this->items[array_push($this->items, new ilQTIItem())-1];
00943                                 if (is_array($a_attribs))
00944                                 {
00945                                         foreach ($a_attribs as $attribute => $value)
00946                                         {
00947                                                 switch (strtolower($attribute))
00948                                                 {
00949                                                         case "ident":
00950                                                                 $this->item->setIdent($value);
00951                                                                 if (count($this->import_idents) > 0)
00952                                                                 {
00953                                                                         if (!in_array($value, $this->import_idents))
00954                                                                         {
00955                                                                                 $this->do_nothing = TRUE;
00956                                                                         }
00957                                                                 }
00958                                                                 break;
00959                                                         case "title":
00960                                                                 $this->item->setTitle($value);
00961                                                                 break;
00962                                                 }
00963                                         }
00964                                 }
00965                                 break;
00966                         case "resprocessing":
00967                                 include_once("./Services/QTI/classes/class.ilQTIResprocessing.php");
00968                                 $this->resprocessing = new ilQTIResprocessing();
00969                                 if (is_array($a_attribs))
00970                                 {
00971                                         foreach ($a_attribs as $attribute => $value)
00972                                         {
00973                                                 switch (strtolower($attribute))
00974                                                 {
00975                                                         case "scoremodel":
00976                                                                 $this->resprocessing->setScoremodel($value);
00977                                                                 break;
00978                                                 }
00979                                         }
00980                                 }
00981                                 break;
00982                 }
00983         }
00984 
00988         function handlerEndTag($a_xml_parser,$a_name)
00989         {
00990                 switch ($this->parser_mode)
00991                 {
00992                         case IL_MO_PARSE_QTI:
00993                                 $this->handlerParseEndTag($a_xml_parser, $a_name);
00994                                 break;
00995                         case IL_MO_VERIFY_QTI:
00996                                 $this->handlerVerifyEndTag($a_xml_parser, $a_name);
00997                                 break;
00998                 }
00999         }
01000         
01004         function handlerParseEndTag($a_xml_parser,$a_name)
01005         {
01006                 if (($this->do_nothing) && (strcmp(strtolower($a_name), "item") != 0)) return;
01007                 switch (strtolower($a_name))
01008                 {
01009                         case "assessment":
01010                                 if (is_object($this->tst_object))
01011                                 {
01012                                         $this->tst_object->fromXML($this->assessment);
01013                                 }
01014                                 $this->in_assessment = FALSE;
01015                                 break;
01016                         case "assessmentcontrol":
01017                                 $this->assessment->addAssessmentcontrol($this->assessmentcontrol);
01018                                 $this->assessmentcontrol = NULL;
01019                                 break;
01020                         case "objectives":
01021                                 if (strcmp(strtolower($this->getParent($a_xml_parser)), "assessment") == 0)
01022                                 {
01023                                         $this->assessment->addObjectives($this->objectives);
01024                                 }
01025                                 $this->in_objectives = FALSE;
01026                                 break;
01027                         case "itemmetadata":
01028                                 $this->in_itemmetadata = FALSE;
01029                                 break;
01030                         case "qtimetadatafield":
01031                                 // handle only specific ILIAS metadata
01032                                 switch ($this->metadata["label"])
01033                                 {
01034                                         case "ILIAS_VERSION":
01035                                                 break;
01036                                         case "QUESTIONTYPE":
01037                                                 if ($this->item != NULL)
01038                                                 {
01039                                                         $this->item->setQuestiontype($this->metadata["entry"]);
01040                                                 }
01041                                                 break;
01042                                         case "AUTHOR":
01043                                                 if ($this->item != NULL)
01044                                                 {
01045                                                         $this->item->setAuthor($this->metadata["entry"]);
01046                                                 }
01047                                         default:
01048                                                 if ($this->item != NULL)
01049                                                 {
01050                                                         $this->item->addMetadata($this->metadata);
01051                                                 }
01052                                                 break;
01053                                 }
01054                                 if ($this->in_assessment)
01055                                 {
01056                                         $this->assessment->addQtiMetadata($this->metadata);
01057                                 }
01058                                 $this->metadata = array("label" => "", "entry" => "");
01059                                 break;
01060                         case "flow":
01061                                 $this->flow--;
01062                                 break;
01063                         case "flow_mat":
01064                                 if (count($this->flow_mat))
01065                                 {
01066                                         $flow_mat = array_pop($this->flow_mat);
01067                                         if (count($this->flow_mat))
01068                                         {
01069                                                 $this->flow_mat[count($this->flow_mat)-1]->addFlow_mat($flow_mat);
01070                                         }
01071                                         else if ($this->itemfeedback != NULL)
01072                                         {
01073                                                 $this->itemfeedback->addFlow_mat($flow_mat);
01074                                         }
01075                                         else if ($this->response_label != NULL)
01076                                         {
01077                                                 $this->response_label->addFlow_mat($flow_mat);
01078                                         }
01079                                 }
01080                                 break;
01081                         case "itemfeedback":
01082                                 if ($this->item != NULL)
01083                                 {
01084                                         if ($this->itemfeedback != NULL)
01085                                         {
01086                                                 $this->item->addItemfeedback($this->itemfeedback);
01087                                         }
01088                                 }
01089                                 $this->itemfeedback = NULL;
01090                                 break;
01091                         case "displayfeedback":
01092                                 if ($this->respcondition != NULL)
01093                                 {
01094                                         if ($this->displayfeedback != NULL)
01095                                         {
01096                                                 $this->respcondition->addDisplayfeedback($this->displayfeedback);
01097                                         }
01098                                 }
01099                                 $this->displayfeedback = NULL;
01100                                 break;
01101                         case "setvar":
01102                                 if ($this->respcondition != NULL)
01103                                 {
01104                                         if ($this->setvar != NULL)
01105                                         {
01106                                                 $this->respcondition->addSetvar($this->setvar);
01107                                         }
01108                                 }
01109                                 $this->setvar = NULL;
01110                                 break;
01111                         case "conditionvar":
01112                                 if ($this->respcondition != NULL)
01113                                 {
01114                                         $this->respcondition->setConditionvar($this->conditionvar);
01115                                 }
01116                                 $this->conditionvar = NULL;
01117                                 break;
01118                         case "varequal":
01119                         case "varlt":
01120                         case "varlte":
01121                         case "vargt":
01122                         case "vargte":
01123                         case "varsubset":
01124                         case "varinside":
01125                         case "varsubstring":
01126                                 if ($this->conditionvar != NULL)
01127                                 {
01128                                         if ($this->responsevar != NULL)
01129                                         {
01130                                                 $this->conditionvar->addResponseVar($this->responsevar);
01131                                         }
01132                                 }
01133                                 $this->responsevar = NULL;
01134                                 break;
01135                         case "respcondition":
01136                                 if ($this->resprocessing != NULL)
01137                                 {
01138                                         $this->resprocessing->addRespcondition($this->respcondition);
01139                                 }
01140                                 $this->respcondition = NULL;
01141                                 break;
01142                         case "outcomes":
01143                                 if ($this->resprocessing != NULL)
01144                                 {
01145                                         $this->resprocessing->setOutcomes($this->outcomes);
01146                                 }
01147                                 $this->outcomes = NULL;
01148                                 break;
01149                         case "decvar":
01150                                 if ($this->outcomes != NULL)
01151                                 {
01152                                         $this->outcomes->addDecvar($this->decvar);
01153                                 }
01154                                 $this->decvar = NULL;
01155                                 break;
01156                         case "presentation":
01157                                 $this->in_presentation = FALSE;
01158                                 if ($this->presentation != NULL)
01159                                 {
01160                                         if ($this->item != NULL)
01161                                         {
01162                                                 $this->item->setPresentation($this->presentation);
01163                                         }
01164                                 }
01165                                 $this->presentation = NULL;
01166                                 break;
01167                         case "response_label":
01168                                 if ($this->render_type != NULL)
01169                                 {
01170                                         $this->render_type->addResponseLabel($this->response_label);
01171                                         $this->response_label = NULL;
01172                                 }
01173                                 break;
01174                         case "render_choice":
01175                         case "render_hotspot":
01176                         case "render_fib":
01177                                 if ($this->in_response)
01178                                 {
01179                                         if ($this->response != NULL)
01180                                         {
01181                                                 if ($this->render_type != NULL)
01182                                                 {
01183                                                         $this->response->setRenderType($this->render_type);
01184                                                         $this->render_type = NULL;
01185                                                 }
01186                                         }
01187                                 }
01188                                 break;
01189                         case "response_lid":
01190                         case "response_xy":
01191                         case "response_str":
01192                         case "response_num":
01193                         case "response_grp":
01194                                 $this->gap_index++;
01195                                 if ($this->presentation != NULL)
01196                                 {
01197                                         if ($this->response != NULL)
01198                                         {
01199                                                 $this->presentation->addResponse($this->response);
01200                                                 if ($this->item != NULL)
01201                                                 {
01202                                                         $this->item->addPresentationitem($this->response);
01203                                                 }
01204                                         }
01205                                 }
01206                                 $this->response = NULL;
01207                                 $this->in_response = FALSE;
01208                                 break;
01209                         case "item":
01210                                 if ($this->do_nothing)
01211                                 {
01212                                         $this->do_nothing = FALSE;
01213                                         return;
01214                                 }
01215                                 if (strlen($this->item->getQuestionType()))
01216                                 {
01217                                         // this is an ILIAS QTI question
01218                                 }
01219                                 else
01220                                 {
01221                                         // this is a QTI question which wasn't generated by ILIAS
01222                                 }
01223                                 global $ilDB;
01224                                 global $ilUser;
01225                                 // save the item directly to save memory
01226                                 // the database id's of the created items are exported. if the import fails
01227                                 // ILIAS can delete the already imported items
01228                                 
01229                                 // problems: the object id of the parent questionpool is not yet known. must be set later
01230                                 //           the complete flag must be calculated?
01231                                 $qt = $this->item->determineQuestionType();
01232                                 $presentation = $this->item->getPresentation(); 
01233                                 if (file_exists("./Modules/TestQuestionPool/classes/class.$qt.php"))
01234                                 {
01235                                         include_once "./Modules/TestQuestionPool/classes/class.$qt.php";
01236                                         $question = new $qt();
01237                                         $question->fromXML($this->item, $this->qpl_id, $this->tst_id, $this->tst_object, $this->question_counter, $this->import_mapping);
01238                                 }
01239                                 break;
01240                         case "material":
01241                                 if ($this->material)
01242                                 {
01243                                         $mat = $this->material->getMaterial(0);
01244                                         if ((strcmp($mat["type"], "mattext") == 0) && (strcmp($mat["material"]->getLabel(), "suggested_solution") == 0))
01245                                         {
01246                                                 $this->item->addSuggestedSolution($mat["material"], $this->gap_index);
01247                                         }
01248                                         if ($this->in_objectives)
01249                                         {
01250                                                 $this->objectives->addMaterial($this->material);
01251                                         }
01252                                         else if (($this->render_type != NULL) && (strcmp(strtolower($this->getParent($a_xml_parser)), "render_hotspot") == 0))
01253                                         {
01254                                                 $this->render_type->addMaterial($this->material);
01255                                         }
01256                                         else if (count($this->flow_mat) && (strcmp(strtolower($this->getParent($a_xml_parser)), "flow_mat") == 0))
01257                                         {
01258                                                 $this->flow_mat[count($this->flow_mat)-1]->addMaterial($this->material);
01259                                         }
01260                                         else if ($this->itemfeedback != NULL)
01261                                         {
01262                                                 $this->itemfeedback->addMaterial($this->material);
01263                                         }
01264                                         else if ($this->response_label != NULL)
01265                                         {
01266                                                 $this->response_label->addMaterial($this->material);
01267                                         }
01268                                         else if ($this->response != NULL)
01269                                         {
01270                                                 if ($this->response->hasRendering())
01271                                                 {
01272                                                         $this->response->setMaterial2($this->material);
01273                                                 }
01274                                                 else
01275                                                 {
01276                                                         $this->response->setMaterial1($this->material);
01277                                                 }
01278                                         }
01279                                         elseif (($this->in_presentation) && (!$this->in_response))
01280                                         {
01281                                                 if (!is_object($this->item->getQuestiontext()))
01282                                                 {
01283                                                         $this->item->setQuestiontext($this->material);
01284                                                 }
01285                                                 $this->presentation->addMaterial($this->material);
01286                                         }
01287                                         else if ($this->presentation != NULL)
01288                                         {
01289                                                 $this->presentation->addMaterial($this->material);
01290                                                 if ($this->item != NULL)
01291                                                 {
01292                                                         $this->item->addPresentationitem($this->material);
01293                                                 }
01294                                         }
01295                                 }
01296                                 $this->material = NULL;
01297                                 break;
01298                         case "matimage";
01299                                 if ($this->material != NULL)
01300                                 {
01301                                         if ($this->matimage != NULL)
01302                                         {
01303                                                 $this->material->addMatimage($this->matimage);
01304                                         }
01305                                 }
01306                                 $this->matimage = NULL;
01307                                 break;
01308                         case "resprocessing":
01309                                 if ($this->item != NULL)
01310                                 {
01311                                         $this->item->addResprocessing($this->resprocessing);
01312                                 }
01313                                 $this->resprocessing = NULL;
01314                                 break;
01315                         case "mattext":
01316                                 if ($this->material != NULL)
01317                                 {
01318                                         $this->material->addMattext($this->mattext);
01319                                 }
01320                                 $this->mattext = NULL;
01321                                 break;
01322                         case "matapplet":
01323                                 if ($this->material != NULL)
01324                                 {
01325                                         $this->material->addMatapplet($this->matapplet);
01326                                 }
01327                                 $this->matapplet = NULL;
01328                                 break;
01329                 }
01330                 $this->depth[$a_xml_parser]--;
01331         }
01332 
01336         function handlerCharacterData($a_xml_parser,$a_data)
01337         {
01338                 switch ($this->parser_mode)
01339                 {
01340                         case IL_MO_PARSE_QTI:
01341                                 $this->handlerParseCharacterData($a_xml_parser, $a_data);
01342                                 break;
01343                         case IL_MO_VERIFY_QTI:
01344                                 $this->handlerVerifyCharacterData($a_xml_parser, $a_data);
01345                                 break;
01346                 }
01347         }
01348 
01352         function handlerParseCharacterData($a_xml_parser,$a_data)
01353         {
01354                 if ($this->do_nothing) return;
01355                 $this->characterbuffer .= $a_data;
01356                 $a_data = $this->characterbuffer;
01357                 switch ($this->qti_element)
01358                 {
01359                         case "fieldlabel":
01360                                 $this->metadata["label"] = $a_data;
01361                                 break;
01362                         case "fieldentry":
01363                                 $this->metadata["entry"] = $a_data;
01364                                 break;
01365                         case "response_label":
01366                                 if ($this->response_label != NULL)
01367                                 {
01368                                         $this->response_label->setContent($a_data);
01369                                 }
01370                                 break;
01371                         case "setvar":
01372                                 if ($this->setvar != NULL)
01373                                 {
01374                                         $this->setvar->setContent($a_data);
01375                                 }
01376                                 break;
01377                         case "displayfeedback":
01378                                 if ($this->displayfeedback != NULL)
01379                                 {
01380                                         $this->displayfeedback->setContent($a_data);
01381                                 }
01382                                 break;
01383                         case "varequal":
01384                         case "varlt":
01385                         case "varlte":
01386                         case "vargt":
01387                         case "vargte":
01388                         case "varsubset":
01389                         case "varinside":
01390                         case "varsubstring":
01391                                 if ($this->responsevar != NULL)
01392                                 {
01393                                         $this->responsevar->setContent($a_data);
01394                                 }
01395                                 break;
01396                         case "decvar":
01397                                 if (strlen($a_data))
01398                                 {
01399                                         if ($this->decvar != NULL)
01400                                         {
01401                                                 $this->decvar->setContent($a_data);
01402                                         }
01403                                 }
01404                                 break;
01405                         case "mattext":
01406                                 if ($this->mattext != NULL)
01407                                 {
01408                                         $this->mattext->setContent($a_data);
01409                                 }
01410                                 break;
01411                         case "matapplet":
01412                                 if ($this->matapplet != NULL)
01413                                 {
01414                                         $this->matapplet->setContent($a_data);
01415                                 }
01416                                 break;
01417                         case "matimage":
01418                                 if ($this->matimage != NULL)
01419                                 {
01420                                         $this->matimage->setContent($a_data);
01421                                 }
01422                                 break;
01423                         case "duration":
01424                                 switch ($this->getParent($a_xml_parser))
01425                                 {
01426                                         case "assessment":
01427                                                 // to be done
01428                                                 break;
01429                                         case "section":
01430                                                 // to be done
01431                                                 break;
01432                                         case "item":
01433                                                 $this->item->setDuration($a_data);
01434                                                 break;
01435                                 }
01436                                 break;
01437                         case "qticomment":
01438                                 switch ($this->getParent($a_xml_parser))
01439                                 {
01440                                         case "item":
01441                                                 $this->item->setComment($a_data);
01442                                                 break;
01443                                         case "assessment":
01444                                                 $this->assessment->setComment($a_data);
01445                                                 break;
01446                                         default:
01447                                                 break;
01448                                 }
01449                                 break;
01450                 }
01451                 $this->sametag = TRUE;
01452         }
01453 
01457         function handlerVerifyBeginTag($a_xml_parser,$a_name,$a_attribs)
01458         {
01459                 switch (strtolower($a_name))
01460                 {
01461                         case "questestinterop":
01462                                 $this->verifyroot = true;
01463                                 break;
01464                         case "qtimetadatafield":
01465                                 $this->verifymetadatafield = 1;
01466                                 break;
01467                         case "fieldlabel":
01468                                 $this->verifyfieldlabeltext = "";
01469                                 if ($this->verifymetadatafield == 1) $this->verifyfieldlabel = 1;
01470                                 break;
01471                         case "fieldentry":
01472                                 $this->verifyfieldentrytext = "";
01473                                 if ($this->verifymetadatafield == 1) $this->verifyfieldentry = 1;
01474                                 break;
01475                         case "item":
01476                                 $title = "";
01477                                 if (is_array($a_attribs))
01478                                 {
01479                                         foreach ($a_attribs as $attribute => $value)
01480                                         {
01481                                                 switch (strtolower($attribute))
01482                                                 {
01483                                                         case "title":
01484                                                                 $title = $value;
01485                                                                 break;
01486                                                 }
01487                                         }
01488                                 }
01489                                 array_push($this->founditems, array("title" => "$title", "type" => "", "ident" => $a_attribs["ident"]));
01490                                 break;
01491                         case "response_lid":
01492                                 if (strlen($this->founditems[count($this->founditems)-1]["type"]) == 0)
01493                                 {
01494                                         // test for non ILIAS generated question types
01495                                         if (is_array($a_attribs))
01496                                         {
01497                                                 foreach ($a_attribs as $attribute => $value)
01498                                                 {
01499                                                         switch (strtolower($attribute))
01500                                                         {
01501                                                                 case "rcardinality":
01502                                                                         include_once "./Services/QTI/classes/class.ilQTIItem.php";
01503                                                                         switch (strtolower($value))
01504                                                                         {
01505                                                                                 case "single":
01506                                                                                         $this->founditems[count($this->founditems)-1]["type"] = QT_MULTIPLE_CHOICE_SR;
01507                                                                                         break;
01508                                                                                 case "multiple":
01509                                                                                         $this->founditems[count($this->founditems)-1]["type"] = QT_MULTIPLE_CHOICE_MR;
01510                                                                                         break;
01511                                                                                 case "ordered":
01512                                                                                         $this->founditems[count($this->founditems)-1]["type"] = QT_ORDERING;
01513                                                                                         break;
01514                                                                         }
01515                                                                         break;
01516                                                         }
01517                                                 }
01518                                         }
01519                                 }
01520                                 break;
01521                         case "response_str":
01522                                 if (strlen($this->founditems[count($this->founditems)-1]["type"]) == 0)
01523                                 {
01524                                         // test for non ILIAS generated question types
01525                                         if (is_array($a_attribs))
01526                                         {
01527                                                 foreach ($a_attribs as $attribute => $value)
01528                                                 {
01529                                                         switch (strtolower($attribute))
01530                                                         {
01531                                                                 case "rcardinality":
01532                                                                         include_once "./Services/QTI/classes/class.ilQTIItem.php";
01533                                                                         switch (strtolower($value))
01534                                                                         {
01535                                                                                 case "single":
01536                                                                                         $this->founditems[count($this->founditems)-1]["type"] = QT_CLOZE;
01537                                                                                         break;
01538                                                                                 case "ordered":
01539                                                                                         $this->founditems[count($this->founditems)-1]["type"] = QT_TEXT;
01540                                                                                         break;
01541                                                                         }
01542                                                                         break;
01543                                                         }
01544                                                 }
01545                                         }
01546                                 }
01547                                 break;
01548                         case "response_xy":
01549                                 if (strlen($this->founditems[count($this->founditems)-1]["type"]) == 0)
01550                                 {
01551                                         $this->founditems[count($this->founditems)-1]["type"] = QT_IMAGEMAP;
01552                                 }
01553                                 break;
01554                         case "response_num":
01555                                 if (strlen($this->founditems[count($this->founditems)-1]["type"]) == 0)
01556                                 {
01557                                         $this->founditems[count($this->founditems)-1]["type"] = QT_NUMERIC;
01558                                 }
01559                                 break;
01560                         case "response_grp":
01561                                 if (strlen($this->founditems[count($this->founditems)-1]["type"]) == 0)
01562                                 {
01563                                         $this->founditems[count($this->founditems)-1]["type"] = QT_MATCHING;
01564                                 }
01565                                 break;
01566                         case "qticomment":
01567                                 // check for "old" ILIAS qti format (not well formed)
01568                                 $this->verifyqticomment = 1;
01569                                 break;
01570                         case "presentation":
01571                                 if (is_array($a_attribs))
01572                                 {
01573                                         foreach ($a_attribs as $attribute => $value)
01574                                         {
01575                                                 switch (strtolower($attribute))
01576                                                 {
01577                                                         case "label":
01578                                                                 $this->founditems[count($this->founditems)-1]["title"] = $value;
01579                                                                 break;
01580                                                 }
01581                                         }
01582                                 }
01583                                 break;
01584                 }
01585         }
01586 
01590         function handlerVerifyEndTag($a_xml_parser,$a_name)
01591         {
01592                 switch (strtolower($a_name))
01593                 {
01594                         case "qticomment":
01595                                 // check for "old" ILIAS qti format (not well formed)
01596                                 $this->verifyqticomment = 0;
01597                                 break;
01598                         case "qtimetadatafield":
01599                                 $this->verifymetadatafield = 0;
01600                                 if (strcmp($this->verifyfieldlabeltext, "QUESTIONTYPE") == 0)
01601                                 {
01602                                         $this->founditems[count($this->founditems)-1]["type"] = $this->verifyfieldentrytext;
01603                                 }
01604                                 break;
01605                         case "fieldlabel":
01606                                 $this->verifyfieldlabel = 0;
01607                                 break;
01608                         case "fieldentry":
01609                                 $this->verifyfieldentry = 0;
01610                                 break;
01611                 }
01612         }
01613 
01617         function handlerVerifyCharacterData($a_xml_parser,$a_data)
01618         {
01619                 if ($this->verifyqticomment == 1)
01620                 {
01621                         if (preg_match("/Questiontype\=(.*)/", $a_data, $matches))
01622                         {
01623                                 if (count($this->founditems))
01624                                 {
01625                                         $this->founditems[count($this->founditems)-1]["type"] = $matches[1];
01626                                 }
01627                         }
01628                 }
01629                 else if ($this->verifyfieldlabel == 1)
01630                 {
01631                         $this->verifyfieldlabeltext = $a_data;
01632                 }
01633                 else if ($this->verifyfieldentry == 1)
01634                 {
01635                         $this->verifyfieldentrytext = $a_data;
01636                 }
01637         }
01638         
01639         function &getFoundItems()
01640         {
01641                 return $this->founditems;
01642         }
01643 
01648         function getImportMapping()
01649         {
01650                 if (!is_array($this->import_mapping))
01651                 {
01652                         return array();
01653                 }
01654                 else
01655                 {
01656                         return $this->import_mapping;
01657                 }
01658         }
01659         
01660 }
01661 ?>

Generated on Fri Dec 13 2013 17:57:00 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1