4include_once 
"./Modules/TestQuestionPool/classes/import/qti12/class.assQuestionImport.php";
 
   30    public function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 
   36        $presentation = $item->getPresentation();
 
   37        $duration = $item->getDuration();
 
   39        $questionimage = array();
 
   40        $created = 
sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
 
   42        foreach ($presentation->order as $entry) {
 
   43            switch ($entry[
"type"]) {
 
   45                    $response = $presentation->response[$entry[
"index"]];
 
   47                    switch (strtolower(get_class($rendertype))) {
 
   48                        case "ilqtirenderhotspot":
 
   49                            foreach ($rendertype->material as $mat) {
 
   50                                for (
$i = 0; 
$i < $mat->getMaterialCount(); 
$i++) {
 
   51                                    $m = $mat->getMaterial(
$i);
 
   52                                    if (strcmp(
$m[
"type"], 
"matimage") == 0) {
 
   53                                        $questionimage = array(
 
   54                                            "imagetype" => 
$m[
"material"]->getImageType(),
 
   55                                            "label" => 
$m[
"material"]->getLabel(),
 
   56                                            "content" => 
$m[
"material"]->getContent()
 
   61                            foreach ($rendertype->response_labels as $response_label) {
 
   62                                $ident = $response_label->getIdent();
 
   64                                foreach ($response_label->material as $mat) {
 
   65                                    $answerhint .= $this->
object->QTIMaterialToString($mat);
 
   67                                $answers[$ident] = array(
 
   68                                    "answerhint" => $answerhint,
 
   69                                    "areatype" => $response_label->getRarea(),
 
   70                                    "coordinates" => $response_label->getContent(),
 
   72                                    "answerorder" => $response_label->getIdent(),
 
   75                                    "points_unchecked" => 0
 
   85        $feedbacksgeneric = array();
 
   86        foreach ($item->resprocessing as $resprocessing) {
 
   87            foreach ($resprocessing->respcondition as $respcondition) {
 
   90                $conditionvar = $respcondition->getConditionvar();
 
   91                foreach ($conditionvar->order as $order) {
 
   92                    switch ($order[
"field"]) {
 
   97                            $coordinates = $conditionvar->varinside[$order[
"index"]]->getContent();
 
  100                            $coordinates = $conditionvar->varequal[$order[
"index"]]->getContent();
 
  104                foreach ($respcondition->setvar as $setvar) {
 
  105                    foreach ($answers as $ident => $answer) {
 
  106                        if (strcmp($answer[
"coordinates"], $coordinates) == 0) {
 
  108                                $answers[$ident][
"action"] = $setvar->getAction();
 
  109                                $answers[$ident][
"points"] = $setvar->getContent();
 
  110                                if (count($respcondition->displayfeedback)) {
 
  111                                    foreach ($respcondition->displayfeedback as $feedbackpointer) {
 
  112                                        if (strlen($feedbackpointer->getLinkrefid())) {
 
  113                                            foreach ($item->itemfeedback as $ifb) {
 
  114                                                if (strcmp($ifb->getIdent(), 
"response_allcorrect") == 0) {
 
  116                                                    if (count($ifb->material)) {
 
  117                                                        foreach ($ifb->material as $material) {
 
  118                                                            $feedbacksgeneric[1] = $material;
 
  121                                                    if ((count($ifb->flow_mat) > 0)) {
 
  122                                                        foreach ($ifb->flow_mat as $fmat) {
 
  123                                                            if (count($fmat->material)) {
 
  124                                                                foreach ($fmat->material as $material) {
 
  125                                                                    $feedbacksgeneric[1] = $material;
 
  130                                                } elseif (strcmp($ifb->getIdent(), 
"response_onenotcorrect") == 0) {
 
  132                                                    if (count($ifb->material)) {
 
  133                                                        foreach ($ifb->material as $material) {
 
  134                                                            $feedbacksgeneric[0] = $material;
 
  137                                                    if ((count($ifb->flow_mat) > 0)) {
 
  138                                                        foreach ($ifb->flow_mat as $fmat) {
 
  139                                                            if (count($fmat->material)) {
 
  140                                                                foreach ($fmat->material as $material) {
 
  141                                                                    $feedbacksgeneric[0] = $material;
 
  147                                                if (strcmp($ifb->getIdent(), $feedbackpointer->getLinkrefid()) == 0) {
 
  149                                                    if (count($ifb->material)) {
 
  150                                                        foreach ($ifb->material as $material) {
 
  151                                                            $feedbacks[$ident] = $material;
 
  154                                                    if ((count($ifb->flow_mat) > 0)) {
 
  155                                                        foreach ($ifb->flow_mat as $fmat) {
 
  156                                                            if (count($fmat->material)) {
 
  157                                                                foreach ($fmat->material as $material) {
 
  158                                                                    $feedbacks[$ident] = $material;
 
  169                                $answers[$ident][
"action"] = $setvar->getAction();
 
  170                                $answers[$ident][
"points_unchecked"] = $setvar->getContent();
 
  179        $this->
object->setTitle($item->getTitle());
 
  180        $this->
object->setNrOfTries($item->getMaxattempts());
 
  181        $this->
object->setComment($item->getComment());
 
  182        $this->
object->setAuthor($item->getAuthor());
 
  183        $this->
object->setOwner($ilUser->getId());
 
  184        $this->
object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
 
  185        $this->
object->setObjId($questionpool_id);
 
  186        $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
 
  187        $this->
object->setIsMultipleChoice($item->getMetadataEntry(
"IS_MULTIPLE_CHOICE"));
 
  188        $areas = array(
"2" => 
"rect", 
"1" => 
"circle", 
"3" => 
"poly");
 
  189        $this->
object->setImageFilename($questionimage[
"label"]);
 
  190        foreach ($answers as $answer) {
 
  191            $this->
object->addAnswer($answer[
"answerhint"], $answer[
"points"], $answer[
"answerorder"], $answer[
"coordinates"], $areas[$answer[
"areatype"]], $answer[
"points_unchecked"]);
 
  194        $this->
object->setAdditionalContentEditingMode(
 
  197        $this->
object->saveToDb();
 
  198        if (count($item->suggested_solutions)) {
 
  199            foreach ($item->suggested_solutions as $suggested_solution) {
 
  200                $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"], 
true);
 
  202            $this->
object->saveToDb();
 
  204        $image =&base64_decode($questionimage[
"content"]);
 
  205        $imagepath = $this->
object->getImagePath();
 
  206        if (!file_exists($imagepath)) {
 
  207            include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  210        $imagepath .=  $questionimage[
"label"];
 
  211        $fh = fopen($imagepath, 
"wb");
 
  217            $imagefile = fwrite(
$fh, $image);
 
  221        foreach ($feedbacks as $ident => $material) {
 
  222            $m = $this->
object->QTIMaterialToString($material);
 
  223            $feedbacks[$ident] = 
$m;
 
  225        foreach ($feedbacksgeneric as $correctness => $material) {
 
  226            $m = $this->
object->QTIMaterialToString($material);
 
  227            $feedbacksgeneric[$correctness] = 
$m;
 
  229        $questiontext = $this->
object->getQuestion();
 
  230        if (is_array(
$_SESSION[
"import_mob_xhtml"])) {
 
  231            include_once 
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
 
  232            include_once 
"./Services/RTE/classes/class.ilRTE.php";
 
  233            foreach (
$_SESSION[
"import_mob_xhtml"] as $mob) {
 
  240                $GLOBALS[
'ilLog']->write(__METHOD__ . 
': import mob from dir: ' . $importfile);
 
  244                $questiontext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $questiontext);
 
  245                foreach ($feedbacks as $ident => $material) {
 
  246                    $feedbacks[$ident] = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $material);
 
  248                foreach ($feedbacksgeneric as $correctness => $material) {
 
  249                    $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $material);
 
  254        foreach ($feedbacks as $ident => $material) {
 
  255            $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
 
  256                $this->object->getId(),
 
  261        foreach ($feedbacksgeneric as $correctness => $material) {
 
  262            $this->
object->feedbackOBJ->importGenericFeedback(
 
  263                $this->object->getId(),
 
  268        $this->
object->saveToDb();
 
  270            $q_1_id = $this->
object->getId();
 
  271            $question_id = $this->
object->duplicate(
true, 
null, 
null, 
null, $tst_id);
 
  272            $tst_object->questions[$question_counter++] = $question_id;
 
  273            $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id, 
"test" => $question_id);
 
  275            $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(), 
"test" => 0);
 
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Class for imagemap question imports.
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
Creates a question from a QTI file.
Class for question imports.
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir)
addGeneralMetadata(ilQTIItem $item)
getQplImportArchivDirectory()
returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir)
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.