00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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 $in_assessment = FALSE;
00078 var $section;
00079 var $import_mapping;
00080 var $question_counter = 1;
00081
00082 var $founditems = array();
00083 var $verifyroot = false;
00084 var $verifyqticomment = 0;
00085 var $verifymetadatafield = 0;
00086 var $verifyfieldlabel = 0;
00087 var $verifyfieldlabeltext = "";
00088 var $verifyfieldentry = 0;
00089 var $verifyfieldentrytext = "";
00090
00098
00099 function ilQTIParser($a_xml_file, $a_mode = IL_MO_PARSE_QTI, $a_qpl_id = 0, $a_import_idents = "")
00100 {
00101 global $lng;
00102
00103 $this->setParserMode($a_mode);
00104
00105 parent::ilSaxParser($a_xml_file);
00106
00107 $this->qpl_id = $a_qpl_id;
00108 $this->import_idents = array();
00109 if (is_array($a_import_idents))
00110 {
00111 $this->import_idents =& $a_import_idents;
00112 }
00113
00114 $this->lng =& $lng;
00115 $this->hasRootElement = FALSE;
00116 $this->import_mapping = array();
00117 $this->assessments = array();
00118 $this->assessment = NULL;
00119 $this->section = NULL;
00120 $this->path = array();
00121 $this->items = array();
00122 $this->item = NULL;
00123 $this->depth = array();
00124 $this->do_nothing = FALSE;
00125 $this->qti_element = "";
00126 $this->in_presentation = FALSE;
00127 $this->in_reponse = FALSE;
00128 $this->render_type = NULL;
00129 $this->render_hotspot = NULL;
00130 $this->response_label = NULL;
00131 $this->material = NULL;
00132 $this->response = NULL;
00133 $this->matimage = NULL;
00134 $this->resprocessing = NULL;
00135 $this->outcomes = NULL;
00136 $this->decvar = NULL;
00137 $this->respcondition = NULL;
00138 $this->setvar = NULL;
00139 $this->displayfeedback = NULL;
00140 $this->itemfeedback = NULL;
00141 $this->flow_mat = array();
00142 $this->question_counter = 1;
00143 $this->flow = 0;
00144 $this->gap_index = 0;
00145 $this->presentation = NULL;
00146 $this->mattext = NULL;
00147 $this->matapplet = NULL;
00148 $this->sametag = FALSE;
00149 $this->in_assessment = FALSE;
00150 $this->characterbuffer = "";
00151 $this->metadata = array("label" => "", "entry" => "");
00152 }
00153
00154 function setTestObject(&$a_tst_object)
00155 {
00156 $this->tst_object =& $a_tst_object;
00157 if (is_object($a_tst_object))
00158 {
00159 $this->tst_id = $this->tst_object->getId();
00160 }
00161 }
00162
00163 function setParserMode($a_mode = IL_MO_PARSE_QTI)
00164 {
00165 $this->parser_mode = $a_mode;
00166 $this->founditems = array();
00167 $this->verifyroot = false;
00168 $this->verifyqticomment = 0;
00169 $this->verifymetadatafield = 0;
00170 $this->verifyfieldlabel = 0;
00171 $this->verifyfieldentry = 0;
00172 $this->verifyfieldlabeltext = "";
00173 $this->verifyfieldentrytext = "";
00174 $this->question_counter = 1;
00175 }
00176
00182 function setHandlers($a_xml_parser)
00183 {
00184 xml_set_object($a_xml_parser,$this);
00185 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
00186 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
00187 }
00188
00189 function startParsing()
00190 {
00191 $this->question_counter = 1;
00192 parent::startParsing();
00193 return FALSE;
00194 }
00195
00196 function getParent($a_xml_parser)
00197 {
00198 if ($this->depth[$a_xml_parser] > 0)
00199 {
00200 return $this->path[$this->depth[$a_xml_parser]-1];
00201 }
00202 else
00203 {
00204 return "";
00205 }
00206 }
00207
00211 function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
00212 {
00213 switch ($this->parser_mode)
00214 {
00215 case IL_MO_PARSE_QTI:
00216 $this->handlerParseBeginTag($a_xml_parser, $a_name, $a_attribs);
00217 break;
00218 case IL_MO_VERIFY_QTI:
00219 $this->handlerVerifyBeginTag($a_xml_parser, $a_name, $a_attribs);
00220 break;
00221 }
00222 }
00223
00227 function handlerParseBeginTag($a_xml_parser,$a_name,$a_attribs)
00228 {
00229 if ($this->do_nothing) return;
00230 $this->sametag = FALSE;
00231 $this->characterbuffer = "";
00232 $this->depth[$a_xml_parser]++;
00233 $this->path[$this->depth[$a_xml_parser]] = strtolower($a_name);
00234 $this->qti_element = $a_name;
00235
00236 switch (strtolower($a_name))
00237 {
00238 case "assessment":
00239 include_once ("./assessment/classes/class.ilQTIAssessment.php");
00240 $this->assessment =& $this->assessments[array_push($this->assessments, new ilQTIAssessment())-1];
00241 $this->in_assessment = TRUE;
00242 if (is_array($a_attribs))
00243 {
00244 foreach ($a_attribs as $attribute => $value)
00245 {
00246 switch (strtolower($attribute))
00247 {
00248 case "title":
00249 $this->assessment->setTitle($value);
00250 break;
00251 case "ident":
00252 $this->assessment->setIdent($value);
00253 break;
00254 }
00255 }
00256 }
00257 break;
00258 case "assessmentcontrol":
00259 if (is_array($a_attribs))
00260 {
00261 foreach ($a_attribs as $attribute => $value)
00262 {
00263 switch (strtolower($attribute))
00264 {
00265 case "solutionswitch":
00266 if (is_object($this->tst_object))
00267 {
00268 $score_reporting = $value;
00269 switch (strtolower($score_reporting))
00270 {
00271 case "1":
00272 case "yes":
00273 $score_reporting = 1;
00274 break;
00275 default:
00276 $score_reporting = 0;
00277 break;
00278 }
00279 $this->tst_object->setScoreReporting($score_reporting);
00280 }
00281 break;
00282 }
00283 }
00284 }
00285 break;
00286 case "section":
00287 include_once ("./assessment/classes/class.ilQTISection.php");
00288 $this->section = new ilQTISection();
00289 break;
00290 case "qtimetadatafield":
00291 $this->metadata = array("label" => "", "entry" => "");
00292 break;
00293 case "flow":
00294 include_once ("./assessment/classes/class.ilQTIFlow.php");
00295 $this->flow++;
00296 break;
00297 case "flow_mat":
00298 include_once ("./assessment/classes/class.ilQTIFlowMat.php");
00299 array_push($this->flow_mat, new ilQTIFlowMat());
00300 break;
00301 case "itemfeedback":
00302 include_once ("./assessment/classes/class.ilQTIItemfeedback.php");
00303 $this->itemfeedback = new ilQTIItemfeedback();
00304 break;
00305 case "displayfeedback":
00306 include_once ("./assessment/classes/class.ilQTIDisplayfeedback.php");
00307 $this->displayfeedback = new ilQTIDisplayfeedback();
00308 break;
00309 case "setvar":
00310 include_once ("./assessment/classes/class.ilQTISetvar.php");
00311 $this->setvar = new ilQTISetvar();
00312 if (is_array($a_attribs))
00313 {
00314 foreach ($a_attribs as $attribute => $value)
00315 {
00316 switch (strtolower($attribute))
00317 {
00318 case "action":
00319 $this->setvar->setAction($value);
00320 break;
00321 case "varname":
00322 $this->setvar->setVarname($value);
00323 break;
00324 }
00325 }
00326 }
00327 break;
00328 case "conditionvar":
00329 include_once ("./assessment/classes/class.ilQTIConditionvar.php");
00330 $this->conditionvar = new ilQTIConditionvar();
00331 break;
00332 case "not":
00333 if ($this->conditionvar != NULL)
00334 {
00335 $this->conditionvar->addNot();
00336 }
00337 break;
00338 case "and":
00339 if ($this->conditionvar != NULL)
00340 {
00341 $this->conditionvar->addAnd();
00342 }
00343 break;
00344 case "or":
00345 if ($this->conditionvar != NULL)
00346 {
00347 $this->conditionvar->addOr();
00348 }
00349 break;
00350 case "varequal":
00351 include_once("./assessment/classes/class.ilQTIResponseVar.php");
00352 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_EQUAL);
00353 if (is_array($a_attribs))
00354 {
00355 foreach ($a_attribs as $attribute => $value)
00356 {
00357 switch (strtolower($attribute))
00358 {
00359 case "case":
00360 $this->responsevar->setCase($value);
00361 break;
00362 case "respident":
00363 $this->responsevar->setRespident($value);
00364 break;
00365 case "index":
00366 $this->responsevar->setIndex($value);
00367 break;
00368 }
00369 }
00370 }
00371 break;
00372 case "varlt":
00373 include_once("./assessment/classes/class.ilQTIResponseVar.php");
00374 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_LT);
00375 if (is_array($a_attribs))
00376 {
00377 foreach ($a_attribs as $attribute => $value)
00378 {
00379 switch (strtolower($attribute))
00380 {
00381 case "respident":
00382 $this->responsevar->setRespident($value);
00383 break;
00384 case "index":
00385 $this->responsevar->setIndex($value);
00386 break;
00387 }
00388 }
00389 }
00390 break;
00391 case "varlte":
00392 include_once("./assessment/classes/class.ilQTIResponseVar.php");
00393 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_LTE);
00394 if (is_array($a_attribs))
00395 {
00396 foreach ($a_attribs as $attribute => $value)
00397 {
00398 switch (strtolower($attribute))
00399 {
00400 case "respident":
00401 $this->responsevar->setRespident($value);
00402 break;
00403 case "index":
00404 $this->responsevar->setIndex($value);
00405 break;
00406 }
00407 }
00408 }
00409 break;
00410 case "vargt":
00411 include_once("./assessment/classes/class.ilQTIResponseVar.php");
00412 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_GT);
00413 if (is_array($a_attribs))
00414 {
00415 foreach ($a_attribs as $attribute => $value)
00416 {
00417 switch (strtolower($attribute))
00418 {
00419 case "respident":
00420 $this->responsevar->setRespident($value);
00421 break;
00422 case "index":
00423 $this->responsevar->setIndex($value);
00424 break;
00425 }
00426 }
00427 }
00428 break;
00429 case "vargte":
00430 include_once("./assessment/classes/class.ilQTIResponseVar.php");
00431 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_GTE);
00432 if (is_array($a_attribs))
00433 {
00434 foreach ($a_attribs as $attribute => $value)
00435 {
00436 switch (strtolower($attribute))
00437 {
00438 case "respident":
00439 $this->responsevar->setRespident($value);
00440 break;
00441 case "index":
00442 $this->responsevar->setIndex($value);
00443 break;
00444 }
00445 }
00446 }
00447 break;
00448 case "varsubset":
00449 include_once("./assessment/classes/class.ilQTIResponseVar.php");
00450 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_SUBSET);
00451 if (is_array($a_attribs))
00452 {
00453 foreach ($a_attribs as $attribute => $value)
00454 {
00455 switch (strtolower($attribute))
00456 {
00457 case "respident":
00458 $this->responsevar->setRespident($value);
00459 break;
00460 case "setmatch":
00461 $this->responsevar->setSetmatch($value);
00462 break;
00463 case "index":
00464 $this->responsevar->setIndex($value);
00465 break;
00466 }
00467 }
00468 }
00469 break;
00470 case "varinside":
00471 include_once("./assessment/classes/class.ilQTIResponseVar.php");
00472 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_INSIDE);
00473 if (is_array($a_attribs))
00474 {
00475 foreach ($a_attribs as $attribute => $value)
00476 {
00477 switch (strtolower($attribute))
00478 {
00479 case "respident":
00480 $this->responsevar->setRespident($value);
00481 break;
00482 case "areatype":
00483 $this->responsevar->setAreatype($value);
00484 break;
00485 case "index":
00486 $this->responsevar->setIndex($value);
00487 break;
00488 }
00489 }
00490 }
00491 break;
00492 case "varsubstring":
00493 include_once("./assessment/classes/class.ilQTIResponseVar.php");
00494 $this->responsevar = new ilQTIResponseVar(RESPONSEVAR_SUBSTRING);
00495 if (is_array($a_attribs))
00496 {
00497 foreach ($a_attribs as $attribute => $value)
00498 {
00499 switch (strtolower($attribute))
00500 {
00501 case "case":
00502 $this->responsevar->setCase($value);
00503 break;
00504 case "respident":
00505 $this->responsevar->setRespident($value);
00506 break;
00507 case "index":
00508 $this->responsevar->setIndex($value);
00509 break;
00510 }
00511 }
00512 }
00513 break;
00514 case "respcondition":
00515 include_once("./assessment/classes/class.ilQTIRespcondition.php");
00516 $this->respcondition = new ilQTIRespcondition();
00517 if (is_array($a_attribs))
00518 {
00519 foreach ($a_attribs as $attribute => $value)
00520 {
00521 switch (strtolower($attribute))
00522 {
00523 case "continue":
00524 $this->respcondition->setContinue($value);
00525 break;
00526 case "title":
00527 $this->respcondition->setTitle($value);
00528 break;
00529 }
00530 }
00531 }
00532 break;
00533 case "outcomes":
00534 include_once("./assessment/classes/class.ilQTIOutcomes.php");
00535 $this->outcomes = new ilQTIOutcomes();
00536 break;
00537 case "decvar":
00538 include_once("./assessment/classes/class.ilQTIDecvar.php");
00539 $this->decvar = new ilQTIDecvar();
00540 if (is_array($a_attribs))
00541 {
00542 foreach ($a_attribs as $attribute => $value)
00543 {
00544 switch (strtolower($attribute))
00545 {
00546 case "varname":
00547 $this->decvar->setVarname($value);
00548 break;
00549 case "vartype":
00550 $this->decvar->setVartype($value);
00551 break;
00552 case "defaultval":
00553 $this->decvar->setDefaultval($value);
00554 break;
00555 case "minvalue":
00556 $this->decvar->setMinvalue($value);
00557 break;
00558 case "maxvalue":
00559 $this->decvar->setMaxvalue($value);
00560 break;
00561 case "members":
00562 $this->decvar->setMembers($value);
00563 break;
00564 case "cutvalue":
00565 $this->decvar->setCutvalue($value);
00566 break;
00567 }
00568 }
00569 }
00570 break;
00571 case "matimage":
00572 include_once("./assessment/classes/class.ilQTIMatimage.php");
00573 $this->matimage = new ilQTIMatimage();
00574 if (is_array($a_attribs))
00575 {
00576 foreach ($a_attribs as $attribute => $value)
00577 {
00578 switch (strtolower($attribute))
00579 {
00580 case "imagtype":
00581 $this->matimage->setImagetype($value);
00582 break;
00583 case "label":
00584 $this->matimage->setLabel($value);
00585 break;
00586 case "height":
00587 $this->matimage->setHeight($value);
00588 break;
00589 case "width":
00590 $this->matimage->setWidth($value);
00591 break;
00592 case "uri":
00593 $this->matimage->setUri($value);
00594 break;
00595 case "embedded":
00596 $this->matimage->setEmbedded($value);
00597 break;
00598 case "x0":
00599 $this->matimage->setX0($value);
00600 break;
00601 case "y0":
00602 $this->matimage->setY0($value);
00603 break;
00604 case "entityref":
00605 $this->matimage->setEntityref($value);
00606 break;
00607 }
00608 }
00609 }
00610 break;
00611 case "material":
00612 include_once("./assessment/classes/class.ilQTIMaterial.php");
00613 $this->material = new ilQTIMaterial();
00614 $this->material->setFlow($this->flow);
00615 if (is_array($a_attribs))
00616 {
00617 foreach ($a_attribs as $attribute => $value)
00618 {
00619 switch (strtolower($attribute))
00620 {
00621 case "label":
00622 $this->material->setLabel($value);
00623 break;
00624 }
00625 }
00626 }
00627 break;
00628 case "mattext":
00629 include_once ("./assessment/classes/class.ilQTIMattext.php");
00630 $this->mattext = new ilQTIMattext();
00631 if (is_array($a_attribs))
00632 {
00633 foreach ($a_attribs as $attribute => $value)
00634 {
00635 switch (strtolower($attribute))
00636 {
00637 case "texttype":
00638 $this->mattext->setTexttype($value);
00639 break;
00640 case "label":
00641 $this->mattext->setLabel($value);
00642 break;
00643 case "charset":
00644 $this->mattext->setCharset($value);
00645 break;
00646 case "uri":
00647 $this->mattext->setUri($value);
00648 break;
00649 case "xml:space":
00650 $this->mattext->setXmlspace($value);
00651 break;
00652 case "xml:lang":
00653 $this->mattext->setXmllang($value);
00654 break;
00655 case "entityref":
00656 $this->mattext->setEntityref($value);
00657 break;
00658 case "height":
00659 $this->mattext->setHeight($value);
00660 break;
00661 case "width":
00662 $this->mattext->setWidth($value);
00663 break;
00664 case "x0":
00665 $this->mattext->setX0($value);
00666 break;
00667 case "y0":
00668 $this->mattext->setY0($value);
00669 break;
00670 }
00671 }
00672 }
00673 break;
00674 case "matapplet":
00675 include_once ("./assessment/classes/class.ilQTIMatapplet.php");
00676 $this->matapplet = New ilQTIMatapplet();
00677 if (is_array($a_attribs))
00678 {
00679 foreach ($a_attribs as $attribute => $value)
00680 {
00681 switch (strtolower($attribute))
00682 {
00683 case "label":
00684 $this->matapplet->setLabel($value);
00685 break;
00686 case "uri":
00687 $this->matapplet->setUri($value);
00688 break;
00689 case "y0":
00690 $this->matapplet->setY0($value);
00691 break;
00692 case "height":
00693 $this->matapplet->setHeight($value);
00694 break;
00695 case "width":
00696 $this->matapplet->setWidth($value);
00697 break;
00698 case "x0":
00699 $this->matapplet->setX0($value);
00700 break;
00701 case "embedded":
00702 $this->matapplet->setEmbedded($value);
00703 break;
00704 case "entityref":
00705 $this->matapplet->setEntityref($value);
00706 break;
00707 }
00708 }
00709 }
00710 break;
00711 case "questestinterop":
00712 $this->hasRootElement = TRUE;
00713 break;
00714 case "qticomment":
00715 break;
00716 case "objectbank":
00717
00718 break;
00719 case "assessment":
00720 if (is_object($this->tst_object))
00721 {
00722 $this->tst_object->setDescription($this->assessment->getComment());
00723 $this->tst_object->setTitle($this->assessment->getTitle());
00724 }
00725 $this->in_assessment = FALSE;
00726 break;
00727 case "section":
00728 if ($this->assessment != NULL)
00729 {
00730 $this->assessment->addSection($this->section);
00731 }
00732 $this->section = NULL;
00733 break;
00734 case "presentation":
00735 $this->in_presentation = TRUE;
00736 include_once ("./assessment/classes/class.ilQTIPresentation.php");
00737 $this->presentation = new ilQTIPresentation();
00738 break;
00739 case "response_label":
00740 if ($this->render_type != NULL)
00741 {
00742 include_once("./assessment/classes/class.ilQTIResponseLabel.php");
00743 $this->response_label = new ilQTIResponseLabel();
00744 foreach ($a_attribs as $attribute => $value)
00745 {
00746 switch (strtolower($attribute))
00747 {
00748 case "rshuffle":
00749 $this->response_label->setRshuffle($value);
00750 break;
00751 case "rarea":
00752 $this->response_label->setRarea($value);
00753 break;
00754 case "rrange":
00755 $this->response_label->setRrange($value);
00756 break;
00757 case "labelrefid":
00758 $this->response_label->setLabelrefid($value);
00759 break;
00760 case "ident":
00761 $this->response_label->setIdent($value);
00762 break;
00763 case "match_group":
00764 $this->response_label->setMatchGroup($value);
00765 break;
00766 case "match_max":
00767 $this->response_label->setMatchMax($value);
00768 break;
00769 }
00770 }
00771 }
00772 break;
00773 case "render_choice":
00774 if ($this->in_response)
00775 {
00776 include_once("./assessment/classes/class.ilQTIRenderChoice.php");
00777 $this->render_type = new ilQTIRenderChoice();
00778 foreach ($a_attribs as $attribute => $value)
00779 {
00780 switch (strtolower($attribute))
00781 {
00782 case "shuffle":
00783 $this->render_type->setShuffle($value);
00784 break;
00785 }
00786 }
00787 }
00788 break;
00789 case "render_hotspot":
00790 if ($this->in_response)
00791 {
00792 include_once("./assessment/classes/class.ilQTIRenderHotspot.php");
00793 $this->render_type = new ilQTIRenderHotspot();
00794 foreach ($a_attribs as $attribute => $value)
00795 {
00796 switch (strtolower($attribute))
00797 {
00798 case "showdraw":
00799 $this->render_type->setShuffle($value);
00800 break;
00801 case "minnumber":
00802 $this->render_type->setMinnumber($value);
00803 break;
00804 case "maxnumber":
00805 $this->render_type->setMaxnumber($value);
00806 break;
00807 }
00808 }
00809 }
00810 break;
00811 case "render_fib":
00812 if ($this->in_response)
00813 {
00814 include_once("./assessment/classes/class.ilQTIRenderFib.php");
00815 $this->render_type = new ilQTIRenderFib();
00816 foreach ($a_attribs as $attribute => $value)
00817 {
00818 switch (strtolower($attribute))
00819 {
00820 case "encoding":
00821 $this->render_type->setEncoding($value);
00822 break;
00823 case "fibtype":
00824 $this->render_type->setFibtype($value);
00825 break;
00826 case "rows":
00827 $this->render_type->setRows($value);
00828 break;
00829 case "maxchars":
00830 $this->render_type->setMaxchars($value);
00831 break;
00832 case "prompt":
00833 $this->render_type->setPrompt($value);
00834 break;
00835 case "columns":
00836 $this->render_type->setColumns($value);
00837 break;
00838 case "charset":
00839 $this->render_type->setCharset($value);
00840 break;
00841 case "maxnumber":
00842 $this->render_type->setMaxnumber($value);
00843 break;
00844 case "minnumber":
00845 $this->render_type->setMinnumber($value);
00846 break;
00847 }
00848 }
00849 }
00850 break;
00851 case "response_lid":
00852
00853
00854
00855
00856 case "response_xy":
00857
00858 case "response_str":
00859
00860 case "response_num":
00861 case "response_grp":
00862
00863
00864 include_once("./assessment/classes/class.ilQTIResponse.php");
00865 switch (strtolower($a_name))
00866 {
00867 case "response_lid":
00868 $response_type = RT_RESPONSE_LID;
00869 break;
00870 case "response_xy":
00871 $response_type = RT_RESPONSE_XY;
00872 break;
00873 case "response_str":
00874 $response_type = RT_RESPONSE_STR;
00875 break;
00876 case "response_num":
00877 $response_type = RT_RESPONSE_NUM;
00878 break;
00879 case "response_grp":
00880 $response_type = RT_RESPONSE_GRP;
00881 break;
00882 }
00883 $this->in_response = TRUE;
00884 $this->response = new ilQTIResponse($response_type);
00885 $this->response->setFlow($this->flow);
00886 if (is_array($a_attribs))
00887 {
00888 foreach ($a_attribs as $attribute => $value)
00889 {
00890 switch (strtolower($attribute))
00891 {
00892 case "ident":
00893 $this->response->setIdent($value);
00894 break;
00895 case "rtiming":
00896 $this->response->setRTiming($value);
00897 break;
00898 case "rcardinality":
00899 $this->response->setRCardinality($value);
00900 break;
00901 case "numtype":
00902 $this->response->setNumtype($value);
00903 break;
00904 }
00905 }
00906 }
00907 break;
00908 case "item":
00909 include_once("./assessment/classes/class.ilQTIItem.php");
00910 $this->gap_index = 0;
00911 $this->item =& $this->items[array_push($this->items, new ilQTIItem())-1];
00912 if (is_array($a_attribs))
00913 {
00914 foreach ($a_attribs as $attribute => $value)
00915 {
00916 switch (strtolower($attribute))
00917 {
00918 case "ident":
00919 $this->item->setIdent($value);
00920 if (count($this->import_idents) > 0)
00921 {
00922 if (!in_array($value, $this->import_idents))
00923 {
00924 $this->do_nothing = TRUE;
00925 }
00926 }
00927 break;
00928 case "title":
00929 $this->item->setTitle($value);
00930 break;
00931 }
00932 }
00933 }
00934 break;
00935 case "resprocessing":
00936 include_once("./assessment/classes/class.ilQTIResprocessing.php");
00937 $this->resprocessing = new ilQTIResprocessing();
00938 if (is_array($a_attribs))
00939 {
00940 foreach ($a_attribs as $attribute => $value)
00941 {
00942 switch (strtolower($attribute))
00943 {
00944 case "scoremodel":
00945 $this->resprocessing->setScoremodel($value);
00946 break;
00947 }
00948 }
00949 }
00950 break;
00951 }
00952 }
00953
00957 function handlerEndTag($a_xml_parser,$a_name)
00958 {
00959 switch ($this->parser_mode)
00960 {
00961 case IL_MO_PARSE_QTI:
00962 $this->handlerParseEndTag($a_xml_parser, $a_name);
00963 break;
00964 case IL_MO_VERIFY_QTI:
00965 $this->handlerVerifyEndTag($a_xml_parser, $a_name);
00966 break;
00967 }
00968 }
00969
00973 function handlerParseEndTag($a_xml_parser,$a_name)
00974 {
00975 if (($this->do_nothing) && (strcmp(strtolower($a_name), "item") != 0)) return;
00976 switch (strtolower($a_name))
00977 {
00978 case "assessment":
00979 break;
00980 case "qtimetadatafield":
00981
00982 switch ($this->metadata["label"])
00983 {
00984 case "ILIAS_VERSION":
00985 break;
00986 case "QUESTIONTYPE":
00987 if ($this->item != NULL)
00988 {
00989 $this->item->setQuestiontype($this->metadata["entry"]);
00990 }
00991 break;
00992 case "AUTHOR":
00993 if ($this->item != NULL)
00994 {
00995 $this->item->setAuthor($this->metadata["entry"]);
00996 }
00997 break;
00998 }
00999 if ($this->in_assessment)
01000 {
01001 switch ($this->metadata["label"])
01002 {
01003 case "test_type":
01004 if (is_object($this->tst_object))
01005 {
01006 $this->tst_object->setTestType($this->metadata["entry"]);
01007 }
01008 break;
01009 case "sequence_settings":
01010 if (is_object($this->tst_object))
01011 {
01012 $this->tst_object->setSequenceSettings($this->metadata["entry"]);
01013 }
01014 break;
01015 case "author":
01016 if (is_object($this->tst_object))
01017 {
01018 $this->tst_object->setAuthor($this->metadata["entry"]);
01019 }
01020 break;
01021 case "nr_of_tries":
01022 if (is_object($this->tst_object))
01023 {
01024 $this->tst_object->setNrOfTries($this->metadata["entry"]);
01025 }
01026 break;
01027 case "random_test":
01028 if (is_object($this->tst_object))
01029 {
01030 $this->tst_object->setRandomTest($this->metadata["entry"]);
01031 }
01032 break;
01033 case "random_question_count":
01034 if (is_object($this->tst_object))
01035 {
01036 $this->tst_object->setRandomQuestionCount($this->metadata["entry"]);
01037 }
01038 break;
01039 case "count_system":
01040 if (is_object($this->tst_object))
01041 {
01042 $this->tst_object->setCountSystem($this->metadata["entry"]);
01043 }
01044 break;
01045 case "mc_scoring":
01046 if (is_object($this->tst_object))
01047 {
01048 $this->tst_object->setMCScoring($this->metadata["entry"]);
01049 }
01050 break;
01051 case "reporting_date":
01052 if (is_object($this->tst_object))
01053 {
01054 $iso8601period = $this->metadata["entry"];
01055 if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
01056 {
01057 $this->tst_object->setReportingDate(sprintf("%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
01058 }
01059 }
01060 break;
01061 case "starting_time":
01062 if (is_object($this->tst_object))
01063 {
01064 $iso8601period = $this->metadata["entry"];
01065 if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
01066 {
01067 $this->tst_object->setStartingTime(sprintf("%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
01068 }
01069 }
01070 break;
01071 case "ending_time":
01072 if (is_object($this->tst_object))
01073 {
01074 $iso8601period = $this->metadata["entry"];
01075 if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
01076 {
01077 $this->tst_object->setEndingTime(sprintf("%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
01078 }
01079 }
01080 break;
01081 }
01082 if (is_object($this->tst_object))
01083 {
01084 if (preg_match("/mark_step_\d+/", $this->metadata["label"]))
01085 {
01086 $xmlmark = $this->metadata["entry"];
01087 preg_match("/<short>(.*?)<\/short>/", $xmlmark, $matches);
01088 $mark_short = $matches[1];
01089 preg_match("/<official>(.*?)<\/official>/", $xmlmark, $matches);
01090 $mark_official = $matches[1];
01091 preg_match("/<percentage>(.*?)<\/percentage>/", $xmlmark, $matches);
01092 $mark_percentage = $matches[1];
01093 preg_match("/<passed>(.*?)<\/passed>/", $xmlmark, $matches);
01094 $mark_passed = $matches[1];
01095 $this->tst_object->mark_schema->add_mark_step($mark_short, $mark_official, $mark_percentage, $mark_passed);
01096 }
01097 }
01098
01099 }
01100 $this->metadata = array("label" => "", "entry" => "");
01101 break;
01102 case "flow":
01103 $this->flow--;
01104 break;
01105 case "flow_mat":
01106 if (count($this->flow_mat))
01107 {
01108 $flow_mat = array_pop($this->flow_mat);
01109 if (count($this->flow_mat))
01110 {
01111 $this->flow_mat[count($this->flow_mat)-1]->addFlow_mat($flow_mat);
01112 }
01113 else if ($this->itemfeedback != NULL)
01114 {
01115 $this->itemfeedback->addFlow_mat($flow_mat);
01116 }
01117 else if ($this->response_label != NULL)
01118 {
01119 $this->response_label->addFlow_mat($flow_mat);
01120 }
01121 }
01122 break;
01123 case "itemfeedback":
01124 if ($this->item != NULL)
01125 {
01126 if ($this->itemfeedback != NULL)
01127 {
01128 $this->item->addItemfeedback($this->itemfeedback);
01129 }
01130 }
01131 $this->itemfeedback = NULL;
01132 break;
01133 case "displayfeedback":
01134 if ($this->respcondition != NULL)
01135 {
01136 if ($this->displayfeedback != NULL)
01137 {
01138 $this->respcondition->addDisplayfeedback($this->displayfeedback);
01139 }
01140 }
01141 $this->displayfeedback = NULL;
01142 break;
01143 case "setvar":
01144 if ($this->respcondition != NULL)
01145 {
01146 if ($this->setvar != NULL)
01147 {
01148 $this->respcondition->addSetvar($this->setvar);
01149 }
01150 }
01151 $this->setvar = NULL;
01152 break;
01153 case "conditionvar":
01154 if ($this->respcondition != NULL)
01155 {
01156 $this->respcondition->setConditionvar($this->conditionvar);
01157 }
01158 $this->conditionvar = NULL;
01159 break;
01160 case "varequal":
01161 case "varlt":
01162 case "varlte":
01163 case "vargt":
01164 case "vargte":
01165 case "varsubset":
01166 case "varinside":
01167 case "varsubstring":
01168 if ($this->conditionvar != NULL)
01169 {
01170 if ($this->responsevar != NULL)
01171 {
01172 $this->conditionvar->addResponseVar($this->responsevar);
01173 }
01174 }
01175 $this->responsevar = NULL;
01176 break;
01177 case "respcondition":
01178 if ($this->resprocessing != NULL)
01179 {
01180 $this->resprocessing->addRespcondition($this->respcondition);
01181 }
01182 $this->respcondition = NULL;
01183 break;
01184 case "outcomes":
01185 if ($this->resprocessing != NULL)
01186 {
01187 $this->resprocessing->setOutcomes($this->outcomes);
01188 }
01189 $this->outcomes = NULL;
01190 break;
01191 case "decvar":
01192 if ($this->outcomes != NULL)
01193 {
01194 $this->outcomes->addDecvar($this->decvar);
01195 }
01196 $this->decvar = NULL;
01197 break;
01198 case "presentation":
01199 $this->in_presentation = FALSE;
01200 if ($this->presentation != NULL)
01201 {
01202 if ($this->item != NULL)
01203 {
01204 $this->item->setPresentation($this->presentation);
01205 }
01206 }
01207 $this->presentation = NULL;
01208 break;
01209 case "response_label":
01210 if ($this->render_type != NULL)
01211 {
01212 $this->render_type->addResponseLabel($this->response_label);
01213 $this->response_label = NULL;
01214 }
01215 break;
01216 case "render_choice":
01217 case "render_hotspot":
01218 case "render_fib":
01219 if ($this->in_response)
01220 {
01221 if ($this->response != NULL)
01222 {
01223 if ($this->render_type != NULL)
01224 {
01225 $this->response->setRenderType($this->render_type);
01226 $this->render_type = NULL;
01227 }
01228 }
01229 }
01230 break;
01231 case "response_lid":
01232 case "response_xy":
01233 case "response_str":
01234 case "response_num":
01235 case "response_grp":
01236 $this->gap_index++;
01237 if ($this->presentation != NULL)
01238 {
01239 if ($this->response != NULL)
01240 {
01241 $this->presentation->addResponse($this->response);
01242 if ($this->item != NULL)
01243 {
01244 $this->item->addPresentationitem($this->response);
01245 }
01246 }
01247 }
01248 $this->response = NULL;
01249 $this->in_response = FALSE;
01250 break;
01251 case "item":
01252 if ($this->do_nothing)
01253 {
01254 $this->do_nothing = FALSE;
01255 return;
01256 }
01257 global $ilDB;
01258 global $ilUser;
01259
01260
01261
01262
01263
01264
01265 $qt = $this->item->determineQuestionType();
01266 $questionpool_id = $this->qpl_id;
01267 $presentation = $this->item->getPresentation();
01268 switch ($qt)
01269 {
01270 case QT_UNKNOWN:
01271
01272 break;
01273 case QT_MULTIPLE_CHOICE_SR:
01274 case QT_MULTIPLE_CHOICE_MR:
01275 $duration = $this->item->getDuration();
01276 $questiontext = array();
01277 $shuffle = 0;
01278 $now = getdate();
01279 $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
01280 $answers = array();
01281 foreach ($presentation->order as $entry)
01282 {
01283 switch ($entry["type"])
01284 {
01285 case "material":
01286 $material = $presentation->material[$entry["index"]];
01287 if (count($material->mattext))
01288 {
01289 foreach ($material->mattext as $mattext)
01290 {
01291 array_push($questiontext, $mattext->getContent());
01292 }
01293 }
01294 break;
01295 case "response":
01296 $response = $presentation->response[$entry["index"]];
01297 $rendertype = $response->getRenderType();
01298 switch (strtolower(get_class($response->getRenderType())))
01299 {
01300 case "ilqtirenderchoice":
01301 $shuffle = $rendertype->getShuffle();
01302 $answerorder = 0;
01303 foreach ($rendertype->response_labels as $response_label)
01304 {
01305 $ident = $response_label->getIdent();
01306 $answertext = "";
01307 foreach ($response_label->material as $mat)
01308 {
01309 foreach ($mat->mattext as $matt)
01310 {
01311 $answertext .= $matt->getContent();
01312 }
01313 }
01314 $answers[$ident] = array(
01315 "answertext" => $answertext,
01316 "points" => 0,
01317 "answerorder" => $answerorder++,
01318 "correctness" => "",
01319 "action" => ""
01320 );
01321 }
01322 break;
01323 }
01324 break;
01325 }
01326 }
01327 $responses = array();
01328 foreach ($this->item->resprocessing as $resprocessing)
01329 {
01330 foreach ($resprocessing->respcondition as $respcondition)
01331 {
01332 $ident = "";
01333 $correctness = 1;
01334 $conditionvar = $respcondition->getConditionvar();
01335 foreach ($conditionvar->order as $order)
01336 {
01337 switch ($order["field"])
01338 {
01339 case "arr_not":
01340 $correctness = 0;
01341 break;
01342 case "varequal":
01343 $ident = $conditionvar->varequal[$order["index"]]->getContent();
01344 break;
01345 }
01346 }
01347 foreach ($respcondition->setvar as $setvar)
01348 {
01349 if (strcmp($ident, "") != 0)
01350 {
01351 $answers[$ident]["correctness"] = $correctness;
01352 $answers[$ident]["action"] = $setvar->getAction();
01353 $answers[$ident]["points"] = $setvar->getContent();
01354 }
01355 }
01356 }
01357 }
01358 include_once ("./assessment/classes/class.assMultipleChoice.php");
01359 $type = "1";
01360 if ($qt == QT_MULTIPLE_CHOICE_SR)
01361 {
01362 $type = "0";
01363 }
01364 $question = new ASS_MultipleChoice(
01365 $this->item->getTitle(),
01366 $this->item->getComment(),
01367 $this->item->getAuthor(),
01368 $ilUser->id,
01369 join($questiontext, ""),
01370 $type
01371 );
01372
01373 $question->setObjId($questionpool_id);
01374 $question->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
01375 $question->setShuffle($shuffle);
01376 foreach ($answers as $answer)
01377 {
01378 $question->addAnswer($answer["answertext"], $answer["points"], $answer["answerorder"], $answer["correctness"]);
01379 }
01380 $question->saveToDb();
01381 if (count($this->item->suggested_solutions))
01382 {
01383 foreach ($this->item->suggested_solutions as $suggested_solution)
01384 {
01385 $question->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
01386 }
01387 $question->saveToDb();
01388 }
01389 if ($this->tst_id > 0)
01390 {
01391 $q_1_id = $question->getId();
01392 $question_id = $question->duplicate(true);
01393 $this->tst_object->questions[$this->question_counter++] = $question_id;
01394 $this->import_mapping[$this->item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
01395 }
01396 else
01397 {
01398 $this->import_mapping[$this->item->getIdent()] = array("pool" => $question->getId(), "test" => 0);
01399 }
01400 break;
01401 case QT_CLOZE:
01402 $duration = $this->item->getDuration();
01403 $questiontext = array();
01404 $shuffle = 0;
01405 $now = getdate();
01406 $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
01407 $gaps = array();
01408 foreach ($presentation->order as $entry)
01409 {
01410 switch ($entry["type"])
01411 {
01412 case "material":
01413 $material = $presentation->material[$entry["index"]];
01414 if (count($material->mattext))
01415 {
01416 foreach ($material->mattext as $mattext)
01417 {
01418 array_push($questiontext, $mattext->getContent());
01419 }
01420 }
01421 break;
01422 case "response":
01423 $response = $presentation->response[$entry["index"]];
01424 $rendertype = $response->getRenderType();
01425 array_push($questiontext, "<<" . $response->getIdent() . ">>");
01426 switch (strtolower(get_class($response->getRenderType())))
01427 {
01428 case "ilqtirenderfib":
01429 array_push($gaps, array("ident" => $response->getIdent(), "type" => "text", "answers" => array()));
01430 break;
01431 case "ilqtirenderchoice":
01432 $answers = array();
01433 $shuffle = $rendertype->getShuffle();
01434 $answerorder = 0;
01435 foreach ($rendertype->response_labels as $response_label)
01436 {
01437 $ident = $response_label->getIdent();
01438 $answertext = "";
01439 foreach ($response_label->material as $mat)
01440 {
01441 foreach ($mat->mattext as $matt)
01442 {
01443 $answertext .= $matt->getContent();
01444 }
01445 }
01446 $answers[$ident] = array(
01447 "answertext" => $answertext,
01448 "points" => 0,
01449 "answerorder" => $answerorder++,
01450 "action" => "",
01451 "shuffle" => $rendertype->getShuffle()
01452 );
01453 }
01454 array_push($gaps, array("ident" => $response->getIdent(), "type" => "choice", "shuffle" => $rendertype->getShuffle(), "answers" => $answers));
01455 break;
01456 }
01457 break;
01458 }
01459 }
01460 $responses = array();
01461 foreach ($this->item->resprocessing as $resprocessing)
01462 {
01463 foreach ($resprocessing->respcondition as $respcondition)
01464 {
01465 $ident = "";
01466 $correctness = 1;
01467 $conditionvar = $respcondition->getConditionvar();
01468 foreach ($conditionvar->order as $order)
01469 {
01470 switch ($order["field"])
01471 {
01472 case "varequal":
01473 $equals = $conditionvar->varequal[$order["index"]]->getContent();
01474 $gapident = $conditionvar->varequal[$order["index"]]->getRespident();
01475 break;
01476 }
01477 }
01478 foreach ($respcondition->setvar as $setvar)
01479 {
01480 if (strcmp($gapident, "") != 0)
01481 {
01482 foreach ($gaps as $gi => $g)
01483 {
01484 if (strcmp($g["ident"], $gapident) == 0)
01485 {
01486 if (strcmp($g["type"], "choice") == 0)
01487 {
01488 foreach ($gaps[$gi]["answers"] as $ai => $answer)
01489 {
01490 if (strcmp($answer["answertext"], $equals) == 0)
01491 {
01492 $gaps[$gi]["answers"][$ai]["action"] = $setvar->getAction();
01493 $gaps[$gi]["answers"][$ai]["points"] = $setvar->getContent();
01494 }
01495 }
01496 }
01497 else if (strcmp($g["type"], "text") == 0)
01498 {
01499 array_push($gaps[$gi]["answers"], array(
01500 "answertext" => $equals,
01501 "points" => $setvar->getContent(),
01502 "answerorder" => count($gaps[$gi]["answers"]),
01503 "action" => $setvar->getAction(),
01504 "shuffle" => 1
01505 ));
01506 }
01507 }
01508 }
01509 }
01510 }
01511 }
01512 }
01513 include_once ("./assessment/classes/class.assClozeTest.php");
01514 $question = new ASS_ClozeTest(
01515 $this->item->getTitle(),
01516 $this->item->getComment(),
01517 $this->item->getAuthor(),
01518 $ilUser->id
01519 );
01520 $question->setObjId($questionpool_id);
01521 $question->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
01522 $gaptext = array();
01523 foreach ($gaps as $gapidx => $gap)
01524 {
01525 $gapcontent = array();
01526 $type = 0;
01527 $typetext = "text";
01528 $shuffletext = "";
01529 if (strcmp($gap["type"], "choice") == 0)
01530 {
01531 $type = 1;
01532 $typetext = "select";
01533 if ($gap["shuffle"] == 0)
01534 {
01535 $shuffletext = " shuffle=\"no\"";
01536 }
01537 else
01538 {
01539 $shuffletext = " shuffle=\"yes\"";
01540 }
01541 }
01542 foreach ($gap["answers"] as $index => $answer)
01543 {
01544 $question->addAnswer($gapidx, $answer["answertext"], $answer["points"], $answer["answerorder"], 1, $type, $gap["ident"], $answer["shuffle"]);
01545 array_push($gapcontent, $answer["answertext"]);
01546 }
01547 $gaptext[$gap["ident"]] = "<gap type=\"$typetext\" name=\"" . $gap["ident"] . "\"$shuffletext>" . join(",", $gapcontent). "</gap>";
01548 }
01549 $clozetext = join("", $questiontext);
01550 foreach ($gaptext as $idx => $val)
01551 {
01552 $clozetext = str_replace("<<" . $idx . ">>", $val, $clozetext);
01553 }
01554 $question->cloze_text = $clozetext;
01555 $question->saveToDb();
01556 if (count($this->item->suggested_solutions))
01557 {
01558 foreach ($this->item->suggested_solutions as $suggested_solution)
01559 {
01560 $question->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
01561 }
01562 $question->saveToDb();
01563 }
01564 if ($this->tst_id > 0)
01565 {
01566 $q_1_id = $question->getId();
01567 $question_id = $question->duplicate(true);
01568 $this->tst_object->questions[$this->question_counter++] = $question_id;
01569 $this->import_mapping[$this->item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
01570 }
01571 else
01572 {
01573 $this->import_mapping[$this->item->getIdent()] = array("pool" => $question->getId(), "test" => 0);
01574 }
01575 break;
01576 case QT_MATCHING:
01577 $duration = $this->item->getDuration();
01578 $questiontext = array();
01579 $shuffle = 0;
01580 $now = getdate();
01581 $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
01582 $terms = array();
01583 $matches = array();
01584 $foundimage = FALSE;
01585 foreach ($presentation->order as $entry)
01586 {
01587 switch ($entry["type"])
01588 {
01589 case "material":
01590 $material = $presentation->material[$entry["index"]];
01591 if (count($material->mattext))
01592 {
01593 foreach ($material->mattext as $mattext)
01594 {
01595 array_push($questiontext, $mattext->getContent());
01596 }
01597 }
01598 break;
01599 case "response":
01600 $response = $presentation->response[$entry["index"]];
01601 $rendertype = $response->getRenderType();
01602 switch (strtolower(get_class($rendertype)))
01603 {
01604 case "ilqtirenderchoice":
01605 $shuffle = $rendertype->getShuffle();
01606 $answerorder = 0;
01607 foreach ($rendertype->response_labels as $response_label)
01608 {
01609 $ident = $response_label->getIdent();
01610 $answertext = "";
01611 $answerimage = array();
01612 foreach ($response_label->material as $mat)
01613 {
01614 foreach ($mat->mattext as $matt)
01615 {
01616 $answertext .= $matt->getContent();
01617 }
01618 foreach ($mat->matimage as $matimage)
01619 {
01620 $foundimage = TRUE;
01621 $answerimage = array(
01622 "imagetype" => $matimage->getImageType(),
01623 "label" => $matimage->getLabel(),
01624 "content" => $matimage->getContent()
01625 );
01626 }
01627 }
01628 if (($response_label->getMatchMax() == 1) && (strlen($response_label->getMatchGroup())))
01629 {
01630 $terms[$ident] = array(
01631 "answertext" => $answertext,
01632 "answerimage" => $answerimage,
01633 "points" => 0,
01634 "answerorder" => $ident,
01635 "action" => ""
01636 );
01637 }
01638 else
01639 {
01640 $matches[$ident] = array(
01641 "answertext" => $answertext,
01642 "answerimage" => $answerimage,
01643 "points" => 0,
01644 "matchingorder" => $ident,
01645 "action" => ""
01646 );
01647 }
01648 }
01649 break;
01650 }
01651 break;
01652 }
01653 }
01654 $responses = array();
01655 foreach ($this->item->resprocessing as $resprocessing)
01656 {
01657 foreach ($resprocessing->respcondition as $respcondition)
01658 {
01659 $subset = array();
01660 $correctness = 1;
01661 $conditionvar = $respcondition->getConditionvar();
01662 foreach ($conditionvar->order as $order)
01663 {
01664 switch ($order["field"])
01665 {
01666 case "varsubset":
01667 $subset = split(",", $conditionvar->varsubset[$order["index"]]->getContent());
01668 break;
01669 }
01670 }
01671 foreach ($respcondition->setvar as $setvar)
01672 {
01673 array_push($responses, array("subset" => $subset, "action" => $setvar->getAction(), "points" => $setvar->getContent()));
01674 }
01675 }
01676 }
01677 include_once ("./assessment/classes/class.assMatchingQuestion.php");
01678 $type = 1;
01679 if ($foundimage)
01680 {
01681 $type = 0;
01682 }
01683 $question = new ASS_MatchingQuestion(
01684 $this->item->getTitle(),
01685 $this->item->getComment(),
01686 $this->item->getAuthor(),
01687 $ilUser->id,
01688 join($questiontext, ""),
01689 $type
01690 );
01691 $question->setObjId($questionpool_id);
01692 $question->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
01693 $question->setShuffle($shuffle);
01694 foreach ($responses as $response)
01695 {
01696 $subset = $response["subset"];
01697 $term = array();
01698 $match = array();
01699 foreach ($subset as $ident)
01700 {
01701 if (array_key_exists($ident, $terms))
01702 {
01703 $term = $terms[$ident];
01704 }
01705 if (array_key_exists($ident, $matches))
01706 {
01707 $match = $matches[$ident];
01708 }
01709 }
01710 if ($type == 0)
01711 {
01712 $question->addMatchingPair($match["answertext"], $response["points"], $match["matchingorder"], $term["answerimage"]["label"], $term["answerorder"]);
01713 }
01714 else
01715 {
01716 $question->addMatchingPair($match["answertext"], $response["points"], $match["matchingorder"], $term["answertext"], $term["answerorder"]);
01717 }
01718 }
01719 $question->saveToDb();
01720 if (count($this->item->suggested_solutions))
01721 {
01722 foreach ($this->item->suggested_solutions as $suggested_solution)
01723 {
01724 $question->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
01725 }
01726 $question->saveToDb();
01727 }
01728 foreach ($responses as $response)
01729 {
01730 $subset = $response["subset"];
01731 $term = array();
01732 $match = array();
01733 foreach ($subset as $ident)
01734 {
01735 if (array_key_exists($ident, $terms))
01736 {
01737 $term = $terms[$ident];
01738 }
01739 if (array_key_exists($ident, $matches))
01740 {
01741 $match = $matches[$ident];
01742 }
01743 }
01744 if ($type == 0)
01745 {
01746 $image =& base64_decode($term["answerimage"]["content"]);
01747 $imagepath = $question->getImagePath();
01748 if (!file_exists($imagepath))
01749 {
01750 ilUtil::makeDirParents($imagepath);
01751 }
01752 $imagepath .= $term["answerimage"]["label"];
01753 $fh = fopen($imagepath, "wb");
01754 if ($fh == false)
01755 {
01756
01757
01758
01759 }
01760 else
01761 {
01762 $imagefile = fwrite($fh, $image);
01763 fclose($fh);
01764 }
01765
01766 $thumbpath = $imagepath . "." . "thumb.jpg";
01767 ilUtil::convertImage($imagepath, $thumbpath, "JPEG", 100);
01768 }
01769 }
01770 if ($this->tst_id > 0)
01771 {
01772 $q_1_id = $question->getId();
01773 $question_id = $question->duplicate(true);
01774 $this->tst_object->questions[$this->question_counter++] = $question_id;
01775 $this->import_mapping[$this->item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
01776 }
01777 else
01778 {
01779 $this->import_mapping[$this->item->getIdent()] = array("pool" => $question->getId(), "test" => 0);
01780 }
01781 break;
01782 case QT_ORDERING:
01783 $duration = $this->item->getDuration();
01784 $questiontext = array();
01785 $shuffle = 0;
01786 $now = getdate();
01787 $foundimage = FALSE;
01788 $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
01789 $answers = array();
01790 foreach ($presentation->order as $entry)
01791 {
01792 switch ($entry["type"])
01793 {
01794 case "material":
01795 $material = $presentation->material[$entry["index"]];
01796 if (count($material->mattext))
01797 {
01798 foreach ($material->mattext as $mattext)
01799 {
01800 array_push($questiontext, $mattext->getContent());
01801 }
01802 }
01803 break;
01804 case "response":
01805 $response = $presentation->response[$entry["index"]];
01806 $rendertype = $response->getRenderType();
01807 switch (strtolower(get_class($rendertype)))
01808 {
01809 case "ilqtirenderchoice":
01810 $shuffle = $rendertype->getShuffle();
01811 $answerorder = 0;
01812 foreach ($rendertype->response_labels as $response_label)
01813 {
01814 $ident = $response_label->getIdent();
01815 $answertext = "";
01816 foreach ($response_label->material as $mat)
01817 {
01818 foreach ($mat->mattext as $matt)
01819 {
01820 $answertext .= $matt->getContent();
01821 }
01822 foreach ($mat->matimage as $matimage)
01823 {
01824 $foundimage = TRUE;
01825 $answerimage = array(
01826 "imagetype" => $matimage->getImageType(),
01827 "label" => $matimage->getLabel(),
01828 "content" => $matimage->getContent()
01829 );
01830 }
01831 }
01832 $answers[$ident] = array(
01833 "answertext" => $answertext,
01834 "answerimage" => $answerimage,
01835 "points" => 0,
01836 "answerorder" => $answerorder++,
01837 "correctness" => "",
01838 "action" => ""
01839 );
01840 }
01841 break;
01842 }
01843 break;
01844 }
01845 }
01846 $responses = array();
01847 foreach ($this->item->resprocessing as $resprocessing)
01848 {
01849 foreach ($resprocessing->respcondition as $respcondition)
01850 {
01851 $ident = "";
01852 $correctness = 1;
01853 $conditionvar = $respcondition->getConditionvar();
01854 foreach ($conditionvar->order as $order)
01855 {
01856 switch ($order["field"])
01857 {
01858 case "arr_not":
01859 $correctness = 0;
01860 break;
01861 case "varequal":
01862 $ident = $conditionvar->varequal[$order["index"]]->getContent();
01863 $orderindex = $conditionvar->varequal[$order["index"]]->getIndex();
01864 break;
01865 }
01866 }
01867 foreach ($respcondition->setvar as $setvar)
01868 {
01869 if (strcmp($ident, "") != 0)
01870 {
01871 $answers[$ident]["solutionorder"] = $orderindex;
01872 $answers[$ident]["action"] = $setvar->getAction();
01873 $answers[$ident]["points"] = $setvar->getContent();
01874 }
01875 }
01876 }
01877 }
01878 include_once ("./assessment/classes/class.assOrderingQuestion.php");
01879 $type = 1;
01880 if ($foundimage)
01881 {
01882 $type = 0;
01883 }
01884 $question = new ASS_OrderingQuestion(
01885 $this->item->getTitle(),
01886 $this->item->getComment(),
01887 $this->item->getAuthor(),
01888 $ilUser->id,
01889 join($questiontext, ""),
01890 $type
01891 );
01892 $question->setObjId($questionpool_id);
01893 $question->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
01894 $question->setShuffle($shuffle);
01895 foreach ($answers as $answer)
01896 {
01897 if ($type == 1)
01898 {
01899 $question->addAnswer($answer["answertext"], $answer["points"], $answer["answerorder"], $answer["solutionorder"]);
01900 }
01901 else
01902 {
01903 $question->addAnswer($answer["answerimage"]["label"], $answer["points"], $answer["answerorder"], $answer["solutionorder"]);
01904 }
01905 }
01906 $question->saveToDb();
01907 if (count($this->item->suggested_solutions))
01908 {
01909 foreach ($this->item->suggested_solutions as $suggested_solution)
01910 {
01911 $question->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
01912 }
01913 $question->saveToDb();
01914 }
01915 foreach ($answers as $answer)
01916 {
01917 if ($type == 0)
01918 {
01919 $image =& base64_decode($answer["answerimage"]["content"]);
01920 $imagepath = $question->getImagePath();
01921 if (!file_exists($imagepath))
01922 {
01923 ilUtil::makeDirParents($imagepath);
01924 }
01925 $imagepath .= $answer["answerimage"]["label"];
01926 $fh = fopen($imagepath, "wb");
01927 if ($fh == false)
01928 {
01929
01930
01931
01932 }
01933 else
01934 {
01935 $imagefile = fwrite($fh, $image);
01936 fclose($fh);
01937 }
01938
01939 $thumbpath = $imagepath . "." . "thumb.jpg";
01940 ilUtil::convertImage($imagepath, $thumbpath, "JPEG", 100);
01941 }
01942 }
01943 if ($this->tst_id > 0)
01944 {
01945 $q_1_id = $question->getId();
01946 $question_id = $question->duplicate(true);
01947 $this->tst_object->questions[$this->question_counter++] = $question_id;
01948 $this->import_mapping[$this->item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
01949 }
01950 else
01951 {
01952 $this->import_mapping[$this->item->getIdent()] = array("pool" => $question->getId(), "test" => 0);
01953 }
01954 break;
01955 case QT_IMAGEMAP:
01956 $duration = $this->item->getDuration();
01957 $questiontext = array();
01958 $now = getdate();
01959 $questionimage = array();
01960 $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
01961 $answers = array();
01962 foreach ($presentation->order as $entry)
01963 {
01964 switch ($entry["type"])
01965 {
01966 case "material":
01967 $material = $presentation->material[$entry["index"]];
01968 if (count($material->mattext))
01969 {
01970 foreach ($material->mattext as $mattext)
01971 {
01972 array_push($questiontext, $mattext->getContent());
01973 }
01974 }
01975 break;
01976 case "response":
01977 $response = $presentation->response[$entry["index"]];
01978 $rendertype = $response->getRenderType();
01979 switch (strtolower(get_class($rendertype)))
01980 {
01981 case "ilqtirenderhotspot":
01982 foreach ($rendertype->material as $mat)
01983 {
01984 foreach ($mat->matimage as $matimage)
01985 {
01986 $questionimage = array(
01987 "imagetype" => $matimage->getImageType(),
01988 "label" => $matimage->getLabel(),
01989 "content" => $matimage->getContent()
01990 );
01991 }
01992 }
01993 foreach ($rendertype->response_labels as $response_label)
01994 {
01995 $ident = $response_label->getIdent();
01996 $answerhint = "";
01997 foreach ($response_label->material as $mat)
01998 {
01999 foreach ($mat->mattext as $matt)
02000 {
02001 $answerhint .= $matt->getContent();
02002 }
02003 }
02004 $answers[$ident] = array(
02005 "answerhint" => $answerhint,
02006 "areatype" => $response_label->getRarea(),
02007 "coordinates" => $response_label->getContent(),
02008 "points" => 0,
02009 "answerorder" => $response_label->getIdent(),
02010 "correctness" => "1",
02011 "action" => ""
02012 );
02013 }
02014 break;
02015 }
02016 break;
02017 }
02018 }
02019 $responses = array();
02020 foreach ($this->item->resprocessing as $resprocessing)
02021 {
02022 foreach ($resprocessing->respcondition as $respcondition)
02023 {
02024 $coordinates = "";
02025 $conditionvar = $respcondition->getConditionvar();
02026 foreach ($conditionvar->order as $order)
02027 {
02028 switch ($order["field"])
02029 {
02030 case "varinside":
02031 $coordinates = $conditionvar->varinside[$order["index"]]->getContent();
02032 break;
02033 }
02034 }
02035 foreach ($respcondition->setvar as $setvar)
02036 {
02037 foreach ($answers as $ident => $answer)
02038 {
02039 if (strcmp($answer["coordinates"], $coordinates) == 0)
02040 {
02041 $answers[$ident]["action"] = $setvar->getAction();
02042 $answers[$ident]["points"] = $setvar->getContent();
02043 }
02044 }
02045 }
02046 }
02047 }
02048
02049 include_once ("./assessment/classes/class.assImagemapQuestion.php");
02050 $question = new ASS_ImagemapQuestion(
02051 $this->item->getTitle(),
02052 $this->item->getComment(),
02053 $this->item->getAuthor(),
02054 $ilUser->id,
02055 join($questiontext, "")
02056 );
02057 $question->setObjId($questionpool_id);
02058 $question->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
02059 $areas = array("2" => "rect", "1" => "circle", "3" => "poly");
02060 $question->image_filename = $questionimage["label"];
02061 foreach ($answers as $answer)
02062 {
02063 $question->addAnswer($answer["answerhint"], $answer["points"], $answer["answerorder"], $answer["correctness"], $answer["coordinates"], $areas[$answer["areatype"]]);
02064 }
02065 $question->saveToDb();
02066 if (count($this->item->suggested_solutions))
02067 {
02068 foreach ($this->item->suggested_solutions as $suggested_solution)
02069 {
02070 $question->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
02071 }
02072 $question->saveToDb();
02073 }
02074 $image =& base64_decode($questionimage["content"]);
02075 $imagepath = $question->getImagePath();
02076 if (!file_exists($imagepath))
02077 {
02078 ilUtil::makeDirParents($imagepath);
02079 }
02080 $imagepath .= $questionimage["label"];
02081 $fh = fopen($imagepath, "wb");
02082 if ($fh == false)
02083 {
02084
02085
02086
02087 }
02088 else
02089 {
02090 $imagefile = fwrite($fh, $image);
02091 fclose($fh);
02092 }
02093 if ($this->tst_id > 0)
02094 {
02095 $q_1_id = $question->getId();
02096 $question_id = $question->duplicate(true);
02097 $this->tst_object->questions[$this->question_counter++] = $question_id;
02098 $this->import_mapping[$this->item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
02099 }
02100 else
02101 {
02102 $this->import_mapping[$this->item->getIdent()] = array("pool" => $question->getId(), "test" => 0);
02103 }
02104 break;
02105 case QT_JAVAAPPLET:
02106 $duration = $this->item->getDuration();
02107 $now = getdate();
02108 $applet = NULL;
02109 $maxpoints = 0;
02110 $javacode = "";
02111 $params = array();
02112 $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
02113 $answers = array();
02114 foreach ($presentation->order as $entry)
02115 {
02116 switch ($entry["type"])
02117 {
02118 case "material":
02119 $material = $presentation->material[$entry["index"]];
02120 if (count($material->mattext))
02121 {
02122 foreach ($material->mattext as $mattext)
02123 {
02124 if ((strlen($mattext->getLabel()) == 0) && (strlen($this->item->getQuestiontext()) == 0))
02125 {
02126 $this->item->setQuestiontext($mattext->getContent());
02127 }
02128 if (strcmp($mattext->getLabel(), "points") == 0)
02129 {
02130 $maxpoints = $mattext->getContent();
02131 }
02132 else if (strcmp($mattext->getLabel(), "java_code") == 0)
02133 {
02134 $javacode = $mattext->getContent();
02135 }
02136 else if (strlen($mattext->getLabel()) > 0)
02137 {
02138 array_push($params, array("key" => $mattext->getLabel(), "value" => $mattext->getContent()));
02139 }
02140 }
02141 }
02142 if (count($material->matapplet))
02143 {
02144 foreach ($material->matapplet as $matapplet)
02145 {
02146 $applet = $matapplet;
02147 }
02148 }
02149 break;
02150 }
02151 }
02152
02153 include_once ("./assessment/classes/class.assJavaApplet.php");
02154 $question = new ASS_JavaApplet(
02155 $this->item->getTitle(),
02156 $this->item->getComment(),
02157 $this->item->getAuthor(),
02158 $ilUser->id,
02159 $this->item->getQuestiontext()
02160 );
02161 $question->setObjId($questionpool_id);
02162 $question->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
02163 $question->javaapplet_filename = $applet->getUri();
02164 $question->setJavaWidth($applet->getWidth());
02165 $question->setJavaHeight($applet->getHeight());
02166 $question->setJavaCode($javacode);
02167 $question->setPoints($maxpoints);
02168 foreach ($params as $pair)
02169 {
02170 $question->addParameter($pair["key"], $pair["value"]);
02171 }
02172 $question->saveToDb();
02173 if (count($this->item->suggested_solutions))
02174 {
02175 foreach ($this->item->suggested_solutions as $suggested_solution)
02176 {
02177 $question->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
02178 }
02179 $question->saveToDb();
02180 }
02181 $javaapplet =& base64_decode($applet->getContent());
02182 $javapath = $question->getJavaPath();
02183 if (!file_exists($javapath))
02184 {
02185 ilUtil::makeDirParents($javapath);
02186 }
02187 $javapath .= $question->javaapplet_filename;
02188 $fh = fopen($javapath, "wb");
02189 if ($fh == false)
02190 {
02191
02192
02193
02194 }
02195 else
02196 {
02197 $javafile = fwrite($fh, $javaapplet);
02198 fclose($fh);
02199 }
02200 if ($this->tst_id > 0)
02201 {
02202 $q_1_id = $question->getId();
02203 $question_id = $question->duplicate(true);
02204 $this->tst_object->questions[$this->question_counter++] = $question_id;
02205 $this->import_mapping[$this->item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
02206 }
02207 else
02208 {
02209 $this->import_mapping[$this->item->getIdent()] = array("pool" => $question->getId(), "test" => 0);
02210 }
02211 break;
02212 case QT_TEXT:
02213 $duration = $this->item->getDuration();
02214 $now = getdate();
02215 $maxchars = 0;
02216 $maxpoints = 0;
02217 $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
02218 foreach ($presentation->order as $entry)
02219 {
02220 switch ($entry["type"])
02221 {
02222 case "material":
02223 $material = $presentation->material[$entry["index"]];
02224 if (count($material->mattext))
02225 {
02226 foreach ($material->mattext as $mattext)
02227 {
02228 $this->item->setQuestiontext($mattext->getContent());
02229 }
02230 }
02231 case "response":
02232 $response = $presentation->response[$entry["index"]];
02233 $rendertype = $response->getRenderType();
02234 switch (strtolower(get_class($rendertype)))
02235 {
02236 case "ilqtirenderfib":
02237 $maxchars = $rendertype->getMaxchars();
02238 break;
02239 }
02240 break;
02241 }
02242 }
02243
02244 foreach ($this->item->resprocessing as $resprocessing)
02245 {
02246 $outcomes = $resprocessing->getOutcomes();
02247 foreach ($outcomes->decvar as $decvar)
02248 {
02249 $maxpoints = $decvar->getMaxvalue();
02250 }
02251 }
02252
02253 include_once ("./assessment/classes/class.assTextQuestion.php");
02254 $question = new ASS_TextQuestion(
02255 $this->item->getTitle(),
02256 $this->item->getComment(),
02257 $this->item->getAuthor(),
02258 $ilUser->id,
02259 $this->item->getQuestiontext()
02260 );
02261 $question->setObjId($questionpool_id);
02262 $question->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
02263 $question->setPoints($maxpoints);
02264 $question->setMaxNumOfChars($maxchars);
02265 $question->saveToDb();
02266 if (count($this->item->suggested_solutions))
02267 {
02268 foreach ($this->item->suggested_solutions as $suggested_solution)
02269 {
02270 $question->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
02271 }
02272 $question->saveToDb();
02273 }
02274 if ($this->tst_id > 0)
02275 {
02276 $q_1_id = $question->getId();
02277 $question_id = $question->duplicate(true);
02278 $this->tst_object->questions[$this->question_counter++] = $question_id;
02279 $this->import_mapping[$this->item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
02280 }
02281 else
02282 {
02283 $this->import_mapping[$this->item->getIdent()] = array("pool" => $question->getId(), "test" => 0);
02284 }
02285 break;
02286 }
02287 break;
02288 case "material":
02289 if (strcmp($this->material->getLabel(), "suggested_solution") == 0)
02290 {
02291 $this->item->addSuggestedSolution($this->material->mattext[0], $this->gap_index);
02292 }
02293 else if (($this->render_type != NULL) && (strcmp(strtolower($this->getParent($a_xml_parser)), "render_hotspot") == 0))
02294 {
02295 $this->render_type->addMaterial($this->material);
02296 }
02297 else if (count($this->flow_mat) && (strcmp(strtolower($this->getParent($a_xml_parser)), "flow_mat") == 0))
02298 {
02299 $this->flow_mat[count($this->flow_mat)-1]->addMaterial($this->material);
02300 }
02301 else if ($this->itemfeedback != NULL)
02302 {
02303 $this->itemfeedback->addMaterial($this->material);
02304 }
02305 else if ($this->response_label != NULL)
02306 {
02307 $this->response_label->addMaterial($this->material);
02308 }
02309 else if ($this->response != NULL)
02310 {
02311 if ($this->response->hasRendering())
02312 {
02313 $this->response->setMaterial2($this->material);
02314 }
02315 else
02316 {
02317 $this->response->setMaterial1($this->material);
02318 }
02319 }
02320 else if ($this->presentation != NULL)
02321 {
02322 $this->presentation->addMaterial($this->material);
02323 if ($this->item != NULL)
02324 {
02325 $this->item->addPresentationitem($this->material);
02326 }
02327 }
02328 $this->material = NULL;
02329 break;
02330 case "matimage";
02331 if ($this->material != NULL)
02332 {
02333 if ($this->matimage != NULL)
02334 {
02335 $this->material->addMatimage($this->matimage);
02336 }
02337 }
02338 $this->matimage = NULL;
02339 break;
02340 case "resprocessing":
02341 if ($this->item != NULL)
02342 {
02343 $this->item->addResprocessing($this->resprocessing);
02344 }
02345 $this->resprocessing = NULL;
02346 break;
02347 case "mattext":
02348 if ($this->material != NULL)
02349 {
02350 $this->material->addMattext($this->mattext);
02351 if (strcmp($this->mattext->getLabel(), "introduction") == 0)
02352 {
02353 if (is_object($this->tst_object))
02354 {
02355 $this->tst_object->setIntroduction($this->mattext->getContent());
02356 }
02357 }
02358 }
02359 $this->mattext = NULL;
02360 break;
02361 case "matapplet":
02362 if ($this->material != NULL)
02363 {
02364 $this->material->addMatapplet($this->matapplet);
02365 }
02366 $this->matapplet = NULL;
02367 break;
02368 }
02369 $this->depth[$a_xml_parser]--;
02370 }
02371
02375 function handlerCharacterData($a_xml_parser,$a_data)
02376 {
02377 switch ($this->parser_mode)
02378 {
02379 case IL_MO_PARSE_QTI:
02380 $this->handlerParseCharacterData($a_xml_parser, $a_data);
02381 break;
02382 case IL_MO_VERIFY_QTI:
02383 $this->handlerVerifyCharacterData($a_xml_parser, $a_data);
02384 break;
02385 }
02386 }
02387
02391 function handlerParseCharacterData($a_xml_parser,$a_data)
02392 {
02393 if ($this->do_nothing) return;
02394 $this->characterbuffer .= $a_data;
02395 $a_data = $this->characterbuffer;
02396 switch ($this->qti_element)
02397 {
02398 case "fieldlabel":
02399 $this->metadata["label"] = $a_data;
02400 break;
02401 case "fieldentry":
02402 $this->metadata["entry"] = $a_data;
02403 break;
02404 case "response_label":
02405 if ($this->response_label != NULL)
02406 {
02407 $this->response_label->setContent($a_data);
02408 }
02409 break;
02410 case "setvar":
02411 if ($this->setvar != NULL)
02412 {
02413 $this->setvar->setContent($a_data);
02414 }
02415 break;
02416 case "displayfeedback":
02417 if ($this->displayfeedback != NULL)
02418 {
02419 $this->displayfeedback->setContent($a_data);
02420 }
02421 break;
02422 case "varequal":
02423 case "varlt":
02424 case "varlte":
02425 case "vargt":
02426 case "vargte":
02427 case "varsubset":
02428 case "varinside":
02429 case "varsubstring":
02430 if ($this->responsevar != NULL)
02431 {
02432 $this->responsevar->setContent($a_data);
02433 }
02434 break;
02435 case "decvar":
02436 if (strlen($a_data))
02437 {
02438 if ($this->decvar != NULL)
02439 {
02440 $this->decvar->setContent($a_data);
02441 }
02442 }
02443 break;
02444 case "mattext":
02445 if ($this->mattext != NULL)
02446 {
02447 $this->mattext->setContent($a_data);
02448 }
02449 if (($this->in_presentation) && (!$this->in_response))
02450 {
02451 if (($this->mattext != NULL) && (strlen($this->mattext->getLabel()) == 0))
02452 {
02453
02454 $this->item->setQuestiontext($a_data);
02455 }
02456 }
02457 break;
02458 case "matapplet":
02459 if ($this->matapplet != NULL)
02460 {
02461 $this->matapplet->setContent($a_data);
02462 }
02463 break;
02464 case "matimage":
02465 if ($this->matimage != NULL)
02466 {
02467 $this->matimage->setContent($a_data);
02468 }
02469 break;
02470 case "duration":
02471 switch ($this->getParent($a_xml_parser))
02472 {
02473 case "assessment":
02474
02475 break;
02476 case "section":
02477
02478 break;
02479 case "item":
02480 $this->item->setDuration($a_data);
02481 break;
02482 }
02483 break;
02484 case "qticomment":
02485 switch ($this->getParent($a_xml_parser))
02486 {
02487 case "item":
02488 $this->item->setComment($a_data);
02489 break;
02490 case "assessment":
02491 $this->assessment->setComment($a_data);
02492 break;
02493 default:
02494 break;
02495 }
02496 break;
02497 }
02498 $this->sametag = TRUE;
02499 }
02500
02504 function handlerVerifyBeginTag($a_xml_parser,$a_name,$a_attribs)
02505 {
02506 switch (strtolower($a_name))
02507 {
02508 case "questestinterop":
02509 $this->verifyroot = true;
02510 break;
02511 case "qtimetadatafield":
02512 $this->verifymetadatafield = 1;
02513 break;
02514 case "fieldlabel":
02515 $this->verifyfieldlabeltext = "";
02516 if ($this->verifymetadatafield == 1) $this->verifyfieldlabel = 1;
02517 break;
02518 case "fieldentry":
02519 $this->verifyfieldentrytext = "";
02520 if ($this->verifymetadatafield == 1) $this->verifyfieldentry = 1;
02521 break;
02522 case "item":
02523 array_push($this->founditems, array("title" => "", "type" => "", "ident" => $a_attribs["ident"]));
02524 break;
02525 case "qticomment":
02526
02527 $this->verifyqticomment = 1;
02528 break;
02529 case "presentation":
02530 if (is_array($a_attribs))
02531 {
02532 foreach ($a_attribs as $attribute => $value)
02533 {
02534 switch (strtolower($attribute))
02535 {
02536 case "label":
02537 $this->founditems[count($this->founditems)-1]["title"] = $value;
02538 break;
02539 }
02540 }
02541 }
02542 break;
02543 }
02544 }
02545
02549 function handlerVerifyEndTag($a_xml_parser,$a_name)
02550 {
02551 switch (strtolower($a_name))
02552 {
02553 case "qticomment":
02554
02555 $this->verifyqticomment = 0;
02556 break;
02557 case "qtimetadatafield":
02558 $this->verifymetadatafield = 0;
02559 if (strcmp($this->verifyfieldlabeltext, "QUESTIONTYPE") == 0)
02560 {
02561 $this->founditems[count($this->founditems)-1]["type"] = $this->verifyfieldentrytext;
02562 }
02563 break;
02564 case "fieldlabel":
02565 $this->verifyfieldlabel = 0;
02566 break;
02567 case "fieldentry":
02568 $this->verifyfieldentry = 0;
02569 break;
02570 }
02571 }
02572
02576 function handlerVerifyCharacterData($a_xml_parser,$a_data)
02577 {
02578 if ($this->verifyqticomment == 1)
02579 {
02580 if (preg_match("/Questiontype\=(.*)/", $a_data, $matches))
02581 {
02582 if (count($this->founditems))
02583 {
02584 $this->founditems[count($this->founditems)-1]["type"] = $matches[1];
02585 }
02586 }
02587 }
02588 else if ($this->verifyfieldlabel == 1)
02589 {
02590 $this->verifyfieldlabeltext = $a_data;
02591 }
02592 else if ($this->verifyfieldentry == 1)
02593 {
02594 $this->verifyfieldentrytext = $a_data;
02595 }
02596 }
02597
02598 function &getFoundItems()
02599 {
02600 return $this->founditems;
02601 }
02602
02607 function getImportMapping()
02608 {
02609 if (!is_array($this->import_mapping))
02610 {
02611 return array();
02612 }
02613 else
02614 {
02615 return $this->import_mapping;
02616 }
02617 }
02618
02619 }
02620 ?>