ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
class.assErrorTextImport.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 
14 {
28  function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
29  {
30  global $ilUser;
31 
32  // empty session variable for imported xhtml mobs
33  unset($_SESSION["import_mob_xhtml"]);
34  $presentation = $item->getPresentation();
35  $duration = $item->getDuration();
36  $now = getdate();
37  $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
38 
39  $feedbacksgeneric = array();
40 
41  $this->addGeneralMetadata($item);
42  $this->object->setTitle($item->getTitle());
43  $this->object->setNrOfTries($item->getMaxattempts());
44  $this->object->setComment($item->getComment());
45  $this->object->setAuthor($item->getAuthor());
46  $this->object->setOwner($ilUser->getId());
47  $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
48  $this->object->setObjId($questionpool_id);
49  $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
50  $this->object->setPointsWrong($item->getMetadataEntry("points_wrong"));
51  $this->object->setErrorText($item->getMetadataEntry("errortext"));
52  $this->object->setTextSize($item->getMetadataEntry("textsize"));
53  $errordata = unserialize($item->getMetadataEntry("errordata"));
54  if (is_array($errordata))
55  {
56  foreach ($errordata as $data)
57  {
58  $this->object->addErrorData($data[1], $data[0], $data[2]);
59  }
60  }
61  // additional content editing mode information
62  $this->object->setAdditionalContentEditingMode(
64  );
65  $this->object->saveToDb();
66 
67  // handle the import of media objects in XHTML code
68  $questiontext = $this->object->getQuestion();
69  if (is_array($_SESSION["import_mob_xhtml"]))
70  {
71  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
72  include_once "./Services/RTE/classes/class.ilRTE.php";
73  foreach ($_SESSION["import_mob_xhtml"] as $mob)
74  {
75  if ($tst_id > 0)
76  {
77  $importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
78  }
79  else
80  {
81  $importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
82  }
83 
84  $GLOBALS['ilLog']->write(__METHOD__.': import mob from dir: '. $importfile);
85 
86  $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
87  ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
88  $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
89  }
90  }
91  $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
92  $this->object->saveToDb();
93  if (count($item->suggested_solutions))
94  {
95  foreach ($item->suggested_solutions as $suggested_solution)
96  {
97  $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
98  }
99  $this->object->saveToDb();
100  }
101  if ($tst_id > 0)
102  {
103  $q_1_id = $this->object->getId();
104  $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
105  $tst_object->questions[$question_counter++] = $question_id;
106  $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
107  }
108  else
109  {
110  $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
111  }
112  }
113 }
114 
115 ?>
< 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) ...
_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']
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
Creates a question from a QTI file.
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...
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
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.
Class for error text question imports.