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();
44 $feedbacksgeneric = array();
45 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
46 foreach ($presentation->order as $entry) {
47 switch ($entry[
"type"]) {
49 $response = $presentation->response[$entry[
"index"]];
51 switch (strtolower(get_class($rendertype))) {
52 case "ilqtirenderfib":
53 $maxchars = $rendertype->getMaxchars();
60 foreach ($item->resprocessing as $resprocessing) {
61 foreach ($resprocessing->respcondition as $respcondition) {
62 $conditionvar = $respcondition->getConditionvar();
63 foreach ($conditionvar->order as $order) {
64 switch ($order[
"field"]) {
66 $upperlimit = $conditionvar->varlte[$order[
"index"]]->getContent();
69 $lowerlimit = $conditionvar->vargte[$order[
"index"]]->getContent();
73 foreach ($respcondition->setvar as $setvar) {
74 $points = $setvar->getContent();
76 if (count($respcondition->displayfeedback)) {
77 foreach ($respcondition->displayfeedback as $feedbackpointer) {
78 if (strlen($feedbackpointer->getLinkrefid())) {
79 foreach ($item->itemfeedback as $ifb) {
80 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
82 if (count($ifb->material)) {
83 foreach ($ifb->material as $material) {
84 $feedbacksgeneric[1] = $material;
87 if ((count($ifb->flow_mat) > 0)) {
88 foreach ($ifb->flow_mat as $fmat) {
89 if (count($fmat->material)) {
90 foreach ($fmat->material as $material) {
91 $feedbacksgeneric[1] = $material;
96 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
98 if (count($ifb->material)) {
99 foreach ($ifb->material as $material) {
100 $feedbacksgeneric[0] = $material;
103 if ((count($ifb->flow_mat) > 0)) {
104 foreach ($ifb->flow_mat as $fmat) {
105 if (count($fmat->material)) {
106 foreach ($fmat->material as $material) {
107 $feedbacksgeneric[0] = $material;
121 $this->
object->setTitle($item->getTitle());
122 $this->
object->setNrOfTries($item->getMaxattempts());
123 $this->
object->setComment($item->getComment());
124 $this->
object->setAuthor($item->getAuthor());
125 $this->
object->setOwner(
$ilUser->getId());
126 $this->
object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
127 $this->
object->setObjId($questionpool_id);
128 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
129 $this->
object->setMaxChars($maxchars);
130 $this->
object->setPoints($points);
131 $this->
object->setLowerLimit($lowerlimit);
132 $this->
object->setUpperLimit($upperlimit);
134 $this->
object->setAdditionalContentEditingMode(
137 $this->
object->saveToDb();
138 if (count($item->suggested_solutions)) {
139 foreach ($item->suggested_solutions as $suggested_solution) {
140 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
142 $this->
object->saveToDb();
144 foreach ($feedbacksgeneric as $correctness => $material) {
145 $m = $this->
object->QTIMaterialToString($material);
146 $feedbacksgeneric[$correctness] =
$m;
149 $questiontext = $this->
object->getQuestion();
150 if (is_array(
$_SESSION[
"import_mob_xhtml"])) {
151 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
152 include_once
"./Services/RTE/classes/class.ilRTE.php";
153 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob) {
161 $DIC[
'ilLog']->write(__METHOD__ .
': import mob from dir: ' . $importfile);
165 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
166 foreach ($feedbacksgeneric as $correctness => $material) {
167 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
172 foreach ($feedbacksgeneric as $correctness => $material) {
173 $this->
object->feedbackOBJ->importGenericFeedback(
174 $this->object->getId(),
179 $this->
object->saveToDb();
181 $q_1_id = $this->
object->getId();
182 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
183 $tst_object->questions[$question_counter++] = $question_id;
184 $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id,
"test" => $question_id);
186 $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(),
"test" => 0);
Class for numeric question imports.
addGeneralMetadata(ilQTIItem $item)
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...
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
Creates a question from a QTI file.
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
Class for question imports.