ILIAS  release_4-4 Revision
class.assOrderingHorizontalImport.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "./Modules/TestQuestionPool/classes/import/qti12/class.assQuestionImport.php";
5 
16 {
30  function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
31  {
32  global $ilUser;
33 
34  // empty session variable for imported xhtml mobs
35  unset($_SESSION["import_mob_xhtml"]);
36  $presentation = $item->getPresentation();
37  $duration = $item->getDuration();
38  $now = getdate();
39  $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
40 
41  $feedbacksgeneric = array();
42 
43  $this->addGeneralMetadata($item);
44  $this->object->setTitle($item->getTitle());
45  $this->object->setNrOfTries($item->getMaxattempts());
46  $this->object->setComment($item->getComment());
47  $this->object->setAuthor($item->getAuthor());
48  $this->object->setOwner($ilUser->getId());
49  $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
50  $this->object->setObjId($questionpool_id);
51  $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
52  $this->object->setPoints($item->getMetadataEntry("points"));
53  $this->object->setOrderText($item->getMetadataEntry("ordertext"));
54  $this->object->setTextSize($item->getMetadataEntry("textsize"));
55  $this->object->setSeparator($item->getMetadataEntry("separator"));
56  // additional content editing mode information
57  $this->object->setAdditionalContentEditingMode(
59  );
60  $this->object->saveToDb();
61 
62  // handle the import of media objects in XHTML code
63  $questiontext = $this->object->getQuestion();
64  if (is_array($_SESSION["import_mob_xhtml"]))
65  {
66  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
67  include_once "./Services/RTE/classes/class.ilRTE.php";
68  foreach ($_SESSION["import_mob_xhtml"] as $mob)
69  {
70  if ($tst_id > 0)
71  {
72  $importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
73  }
74  else
75  {
76  $importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
77  }
78 
79  $GLOBALS['ilLog']->write(__METHOD__.': import mob from dir: '. $importfile);
80 
81  $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
82  ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
83  $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
84  }
85  }
86  $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
87  $this->object->saveToDb();
88  if (count($item->suggested_solutions))
89  {
90  foreach ($item->suggested_solutions as $suggested_solution)
91  {
92  $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
93  }
94  $this->object->saveToDb();
95  }
96  if ($tst_id > 0)
97  {
98  $q_1_id = $this->object->getId();
99  $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
100  $tst_object->questions[$question_counter++] = $question_id;
101  $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
102  }
103  else
104  {
105  $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
106  }
107  }
108 }
109 
110 ?>
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
addGeneralMetadata(ilQTIItem $item)
& _saveTempFileAsMediaObject($name, $tmp_name, $upload=TRUE)
Create new media object and update page in db and return new media object.
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
getQplImportArchivDirectory()
returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir) ...
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
Creates a question from a QTI file.
_saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
$GLOBALS['ct_recipient']
Class for formula question imports.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
global $ilUser
Definition: imgupload.php:15
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
Class for question imports.