Creates a question from a QTI file. 
        {
                
                $presentation = $item->getPresentation(); 
                $duration = $item->getDuration();
                $questiontext = array();
                $shuffle = 0;
                $now = getdate();
                $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
                $gaps = array();
                foreach ($presentation->order as $entry)
                {
                        switch ($entry["type"])
                        {
                                case "material":
                                        $material = $presentation->material[$entry["index"]];
                                        array_push($questiontext, $this->object->QTIMaterialToString($material));
                                        break;
                                case "response":
                                        $response = $presentation->response[$entry["index"]];
                                        $rendertype = $response->getRenderType(); 
                                        array_push($questiontext, "<<" . $response->getIdent() . ">>");
                                        switch (strtolower(get_class($response->getRenderType())))
                                        {
                                                case "ilqtirenderfib":
                                                        switch ($response->getRenderType()->getFibtype())
                                                        {
                                                                        array_push($gaps, 
                                                                                array(
                                                                                        "ident" => $response->getIdent(), 
                                                                                        "answers" => array(), 
                                                                                        "minnumber" => $response->getRenderType()->getMinnumber(), 
                                                                                        "maxnumber" => $response->getRenderType()->getMaxnumber()
                                                                                )
                                                                        );
                                                                        break;
                                                                default:
                                                                        array_push($gaps, array(
"ident" => $response->getIdent(), 
"type" => 
CLOZE_TEXT, 
"answers" => array()));
                                                                        break;
                                                        }
                                                        break;
                                                case "ilqtirenderchoice":
                                                        $answers = array();
                                                        $shuffle = $rendertype->getShuffle();
                                                        $answerorder = 0;
                                                        foreach ($rendertype->response_labels as $response_label)
                                                        {
                                                                $ident = $response_label->getIdent();
                                                                $answertext = "";
                                                                foreach ($response_label->material as $mat)
                                                                {
                                                                        $answertext .= $this->object->QTIMaterialToString($mat);
                                                                }
                                                                $answers[$ident] = array(
                                                                        "answertext" => $answertext,
                                                                        "points" => 0,
                                                                        "answerorder" => $answerorder++,
                                                                        "action" => "",
                                                                        "shuffle" => $rendertype->getShuffle()
                                                                );
                                                        }
                                                        array_push($gaps, array(
"ident" => $response->getIdent(), 
"type" => 
CLOZE_SELECT, 
"shuffle" => $rendertype->getShuffle(), 
"answers" => $answers));
                                                        break;
                                        }
                                        break;
                        }
                }
                $responses = array();
                $feedbacks = array();
                $feedbacksgeneric = array();
                foreach ($item->resprocessing as $resprocessing)
                {
                        foreach ($resprocessing->respcondition as $respcondition)
                        {
                                $ident = "";
                                $correctness = 1;
                                $conditionvar = $respcondition->getConditionvar();
                                foreach ($conditionvar->order as $order)
                                {
                                        switch ($order["field"])
                                        {
                                                case "varequal":
                                                        $equals = $conditionvar->varequal[$order["index"]]->getContent();
                                                        $gapident = $conditionvar->varequal[$order["index"]]->getRespident();
                                                        break;
                                        }
                                }
                                foreach ($respcondition->setvar as $setvar)
                                {
                                        if (strcmp($gapident, "") != 0)
                                        {
                                                foreach ($gaps as $gi => $g)
                                                {
                                                        if (strcmp($g["ident"], $gapident) == 0)
                                                        {
                                                                {
                                                                        foreach ($gaps[$gi]["answers"] as $ai => $answer)
                                                                        {
                                                                                if (strcmp($answer["answertext"], $equals) == 0)
                                                                                {
                                                                                        $gaps[$gi]["answers"][$ai]["action"] = $setvar->getAction();
                                                                                        $gaps[$gi]["answers"][$ai]["points"] = $setvar->getContent();
                                                                                }
                                                                        }
                                                                }
                                                                {
                                                                        array_push($gaps[$gi]["answers"], array(
                                                                                "answertext" => $equals,
                                                                                "points" => $setvar->getContent(),
                                                                                "answerorder" => count($gaps[$gi]["answers"]),
                                                                                "action" => $setvar->getAction()
                                                                        ));
                                                                }
                                                                {
                                                                        array_push($gaps[$gi]["answers"], array(
                                                                                "answertext" => $equals,
                                                                                "points" => $setvar->getContent(),
                                                                                "answerorder" => count($gaps[$gi]["answers"]),
                                                                                "action" => $setvar->getAction()
                                                                        ));
                                                                }
                                                        }
                                                }
                                        }
                                }
                                if (count($respcondition->displayfeedback))
                                {
                                        foreach ($respcondition->displayfeedback as $feedbackpointer)
                                        {
                                                if (strlen($feedbackpointer->getLinkrefid()))
                                                {
                                                        foreach ($item->itemfeedback as $ifb)
                                                        {
                                                                if (strcmp($ifb->getIdent(), "response_allcorrect") == 0)
                                                                {
                                                                        
                                                                        if (count($ifb->material))
                                                                        {
                                                                                foreach ($ifb->material as $material)
                                                                                {
                                                                                        $feedbacksgeneric[1] = $material;
                                                                                }
                                                                        }
                                                                        if ((count($ifb->flow_mat) > 0))
                                                                        {
                                                                                foreach ($ifb->flow_mat as $fmat)
                                                                                {
                                                                                        if (count($fmat->material))
                                                                                        {
                                                                                                foreach ($fmat->material as $material)
                                                                                                {
                                                                                                        $feedbacksgeneric[1] = $material;
                                                                                                }
                                                                                        }
                                                                                }
                                                                        }
                                                                } 
                                                                else if (strcmp($ifb->getIdent(), "response_onenotcorrect") == 0)
                                                                {
                                                                        
                                                                        if (count($ifb->material))
                                                                        {
                                                                                foreach ($ifb->material as $material)
                                                                                {
                                                                                        $feedbacksgeneric[0] = $material;
                                                                                }
                                                                        }
                                                                        if ((count($ifb->flow_mat) > 0))
                                                                        {
                                                                                foreach ($ifb->flow_mat as $fmat)
                                                                                {
                                                                                        if (count($fmat->material))
                                                                                        {
                                                                                                foreach ($fmat->material as $material)
                                                                                                {
                                                                                                        $feedbacksgeneric[0] = $material;
                                                                                                }
                                                                                        }
                                                                                }
                                                                        } 
                                                                }
                                                        }
                                                }
                                        }
                                }
                        }
                }
                $this->object->setTitle($item->getTitle());
                $this->object->setNrOfTries($item->getMaxattempts());
                $this->object->setComment($item->getComment());
                $this->object->setAuthor($item->getAuthor());
                $this->object->setOwner($ilUser->getId());
                $this->object->setObjId($questionpool_id);
                $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
                $textgap_rating = $item->getMetadataEntry("textgaprating");
                $this->object->setFixedTextLength($item->getMetadataEntry("fixedTextLength"));
                $this->object->setIdenticalScoring($item->getMetadataEntry("identicalScoring"));
                if (strlen($textgap_rating) == 0) $textgap_rating = "ci";
                $this->object->setTextgapRating($textgap_rating);
                $gaptext = array();
                foreach ($gaps as $gapidx => $gap)
                {
                        $gapcontent = array();
                        include_once "./Modules/TestQuestionPool/classes/class.assClozeGap.php";
                        foreach ($gap["answers"] as $index => $answer)
                        {
                                include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
                                $gapanswer = 
new assAnswerCloze($answer[
"answertext"], $answer[
"points"], $answer[
"answerorder"]);
                                switch ($clozegap->getType())
                                {
                                                $clozegap->setShuffle($answer["shuffle"]);
                                                break;
                                                $gapanswer->setLowerBound($gap["minnumber"]);
                                                $gapanswer->setUpperBound($gap["maxnumber"]);
                                                break;
                                }
                                $clozegap->addItem($gapanswer);
                                array_push($gapcontent, $answer["answertext"]);
                        }
                        $this->object->addGapAtIndex($clozegap, $gapidx);
                        $gaptext[$gap["ident"]] = "[gap]" . join(",", $gapcontent). "[/gap]";
                }
                $clozetext = join("", $questiontext);
                foreach ($gaptext as $idx => $val)
                {
                        $clozetext = str_replace("<<" . $idx . ">>", $val, $clozetext);
                }
                $this->object->setQuestion($clozetext);
                $this->object->saveToDb();
                
                foreach ($feedbacks as $ident => $material)
                {
                        $m = $this->object->QTIMaterialToString($material);
                        $feedbacks[$ident] = $m;
                }
                foreach ($feedbacksgeneric as $correctness => $material)
                {
                        $m = $this->object->QTIMaterialToString($material);
                        $feedbacksgeneric[$correctness] = $m;
                }
                $questiontext = $this->object->getQuestion();
                {
                        include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
                        include_once "./Services/RTE/classes/class.ilRTE.php";
                        foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
 
                        {
                                if ($tst_id > 0)
                                {
                                }
                                else
                                {
                                }
                                
                                $GLOBALS[
'ilLog']->write(__METHOD__.
': import mob from dir: '. $importfile);
 
                                
                                $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
                                foreach ($feedbacks as $ident => $material)
                                {
                                        $feedbacks[$ident] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
                                }
                                foreach ($feedbacksgeneric as $correctness => $material)
                                {
                                        $feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
                                }
                        }
                }
                foreach ($feedbacks as $ident => $material)
                {
                        
                }
                foreach ($feedbacksgeneric as $correctness => $material)
                {
                }
                $this->object->saveToDb();
                if (count($item->suggested_solutions))
                {
                        foreach ($item->suggested_solutions as $suggested_solution)
                        {
                                $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
                        }
                        $this->object->saveToDb();
                }
                if ($tst_id > 0)
                {
                        $q_1_id = $this->object->getId();
                        $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
                        $tst_object->questions[$question_counter++] = $question_id;
                        $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
                }
                else
                {
                        $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
                }
        }