4 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class.assQuestionImport.php";
30 public function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
37 $presentation = $item->getPresentation();
38 $duration = $item->getDuration();
46 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
48 foreach ($presentation->order as $entry) {
49 switch ($entry[
"type"]) {
51 $material = $presentation->material[$entry[
"index"]];
52 for (
$i = 0;
$i < $material->getMaterialCount();
$i++) {
53 $mat = $material->getMaterial(
$i);
54 if (strcmp($mat[
"type"],
"mattext") == 0) {
55 $mattext = $mat[
"material"];
56 if ((strlen($mattext->getLabel()) == 0) && (strlen($this->object->QTIMaterialToString($item->getQuestiontext())) == 0)) {
57 $item->setQuestiontext($mattext->getContent());
59 if (strcmp($mattext->getLabel(),
"points") == 0) {
60 $maxpoints = $mattext->getContent();
61 } elseif (strcmp($mattext->getLabel(),
"java_code") == 0) {
62 $javacode = $mattext->getContent();
63 } elseif (strcmp($mattext->getLabel(),
"java_codebase") == 0) {
64 $javacodebase = $mattext->getContent();
65 } elseif (strcmp($mattext->getLabel(),
"java_archive") == 0) {
66 $javaarchive = $mattext->getContent();
67 } elseif (strlen($mattext->getLabel()) > 0) {
68 array_push(
$params, array(
"key" => $mattext->getLabel(),
"value" => $mattext->getContent()));
70 } elseif (strcmp($mat[
"type"],
"matapplet") == 0) {
71 $applet = $mat[
"material"];
78 $feedbacksgeneric = array();
79 foreach ($item->resprocessing as $resprocessing) {
80 foreach ($resprocessing->respcondition as $respcondition) {
81 foreach ($respcondition->displayfeedback as $feedbackpointer) {
82 if (strlen($feedbackpointer->getLinkrefid())) {
83 foreach ($item->itemfeedback as $ifb) {
84 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
86 if (count($ifb->material)) {
87 foreach ($ifb->material as $material) {
88 $feedbacksgeneric[1] = $material;
91 if ((count($ifb->flow_mat) > 0)) {
92 foreach ($ifb->flow_mat as $fmat) {
93 if (count($fmat->material)) {
94 foreach ($fmat->material as $material) {
95 $feedbacksgeneric[1] = $material;
100 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
102 if (count($ifb->material)) {
103 foreach ($ifb->material as $material) {
104 $feedbacksgeneric[0] = $material;
107 if ((count($ifb->flow_mat) > 0)) {
108 foreach ($ifb->flow_mat as $fmat) {
109 if (count($fmat->material)) {
110 foreach ($fmat->material as $material) {
111 $feedbacksgeneric[0] = $material;
124 $this->
object->setTitle($item->getTitle());
125 $this->
object->setNrOfTries($item->getMaxattempts());
126 $this->
object->setComment($item->getComment());
127 $this->
object->setAuthor($item->getAuthor());
128 $this->
object->setOwner(
$ilUser->getId());
129 $this->
object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
130 $this->
object->setObjId($questionpool_id);
131 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
132 $this->
object->setJavaAppletFilename($applet->getUri());
133 $this->
object->setJavaWidth($applet->getWidth());
134 $this->
object->setJavaHeight($applet->getHeight());
135 $this->
object->setJavaCode($javacode);
136 $this->
object->setJavaCodebase($javacodebase);
137 $this->
object->setJavaArchive($javaarchive);
138 $this->
object->setPoints($maxpoints);
140 $this->
object->addParameter($pair[
"key"], $pair[
"value"]);
143 $this->
object->setAdditionalContentEditingMode(
146 $this->
object->saveToDb();
147 if (count($item->suggested_solutions)) {
148 foreach ($item->suggested_solutions as $suggested_solution) {
149 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
151 $this->
object->saveToDb();
153 $javaapplet = &base64_decode($applet->getContent());
154 $javapath = $this->
object->getJavaPath();
155 if (!file_exists($javapath)) {
156 include_once
"./Services/Utilities/classes/class.ilUtil.php";
159 $javapath .= $this->
object->getJavaAppletFilename();
160 $fh =
fopen($javapath,
"wb");
167 $javafile = fwrite($fh, $javaapplet);
171 foreach ($feedbacksgeneric as $correctness => $material) {
172 $m = $this->
object->QTIMaterialToString($material);
173 $feedbacksgeneric[$correctness] =
$m;
175 $questiontext = $this->
object->getQuestion();
176 if (is_array(
$_SESSION[
"import_mob_xhtml"])) {
177 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
178 include_once
"./Services/RTE/classes/class.ilRTE.php";
179 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob) {
187 $DIC[
'ilLog']->write(__METHOD__ .
': import mob from dir: ' . $importfile);
191 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
192 foreach ($feedbacksgeneric as $correctness => $material) {
193 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
198 foreach ($feedbacksgeneric as $correctness => $material) {
199 $this->
object->feedbackOBJ->importGenericFeedback(
200 $this->object->getId(),
205 $this->
object->saveToDb();
207 $q_1_id = $this->
object->getId();
208 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
209 $tst_object->questions[$question_counter++] = $question_id;
210 $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id,
"test" => $question_id);
212 $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(),
"test" => 0);
static makeDirParents($a_dir)
Create a new directory and all parent directories.
addGeneralMetadata(ilQTIItem $item)
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
Creates a question from a QTI file.
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) ...
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...
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
Class for question imports.
Class for java applet question imports.