2 require_once
'Modules/TestQuestionPool/classes/import/qti12/class.assQuestionImport.php';
3 require_once
'Modules/TestQuestionPool/classes/class.assLongMenu.php';
9 public function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
16 $presentation = $item->getPresentation();
17 $duration = $item->getDuration();
18 $questiontext = array();
19 $seperate_question_field = $item->getMetadataEntry(
"question");
22 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
24 $correct_answers = array();
25 $presentation = $item->getPresentation();
26 $gap_types = json_decode($item->getMetadataEntry(
"gapTypes"));
27 foreach ($presentation->order as $entry) {
28 switch ($entry[
"type"]) {
31 $material = $presentation->material[$entry[
"index"]];
32 if (preg_match(
'/\[Longmenu \d\]/', $this->object->QTIMaterialToString($material))) {
33 $this->
object->setLongMenuTextValue($this->object->QTIMaterialToString($material));
35 $this->
object->setQuestion($this->object->QTIMaterialToString($material));
44 $questiontext = $this->
object->getQuestion();
45 $longmenutext = $this->
object->getLongMenuTextValue();
46 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
48 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
60 $DIC[
'ilLog']->write(__METHOD__.
': import mob from dir: '. $importfile);
65 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
66 $longmenutext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $longmenutext);
74 foreach ($item->resprocessing as $resprocessing) {
75 foreach ($resprocessing->respcondition as $respcondition) {
77 $conditionvar = $respcondition->getConditionvar();
78 foreach ($conditionvar->order as $order) {
79 switch ($order[
"field"]) {
81 $equals = $conditionvar->varequal[$order[
"index"]]->getContent();
82 $gapident = $conditionvar->varequal[$order[
"index"]]->getRespident();
84 $answers[
$id][] = $equals;
88 foreach ($respcondition->setvar as $setvar) {
89 if (strcmp($gapident,
"") != 0) {
90 if ($setvar->getContent() > 0) {
92 $correct_answers[
$id][0][] = $equals;
93 $correct_answers[
$id][1] = $setvar->getContent();
94 if (is_array($gap_types) && key_exists(
$id, $gap_types)) {
95 $correct_answers[
$id][2] = $gap_types[
$id];
100 if (count($respcondition->displayfeedback)) {
101 foreach ($respcondition->displayfeedback as $feedbackpointer) {
102 if (strlen($feedbackpointer->getLinkrefid())) {
103 foreach ($item->itemfeedback as $ifb) {
104 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
106 if (count($ifb->material)) {
107 foreach ($ifb->material as $material) {
108 $feedbacksgeneric[1] = $material;
111 if ((count($ifb->flow_mat) > 0)) {
112 foreach ($ifb->flow_mat as $fmat) {
113 if (count($fmat->material)) {
114 foreach ($fmat->material as $material) {
115 $feedbacksgeneric[1] = $material;
120 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
122 if (count($ifb->material)) {
123 foreach ($ifb->material as $material) {
124 $feedbacksgeneric[0] = $material;
127 if ((count($ifb->flow_mat) > 0)) {
128 foreach ($ifb->flow_mat as $fmat) {
129 if (count($fmat->material)) {
130 foreach ($fmat->material as $material) {
131 $feedbacksgeneric[0] = $material;
138 if (count($ifb->material)) {
139 foreach ($ifb->material as $material) {
140 $feedbacks[$ifb->getIdent()] = $material;
143 if ((count($ifb->flow_mat) > 0)) {
144 foreach ($ifb->flow_mat as $fmat) {
145 if (count($fmat->material)) {
146 foreach ($fmat->material as $material) {
147 $feedbacks[$ifb->getIdent()] = $material;
161 foreach ($correct_answers as
$row) {
164 $this->
object->setAnswers($answers);
166 if (count($feedbacks) > 0) {
167 foreach ($feedbacks as $ident => $material) {
168 $m = $this->
object->QTIMaterialToString($material);
169 $feedbacks[$ident] =
$m;
172 if (is_array($feedbacksgeneric) && count($feedbacksgeneric) > 0) {
173 foreach ($feedbacksgeneric as $correctness => $material) {
174 $m = $this->
object->QTIMaterialToString($material);
175 $feedbacksgeneric[$correctness] =
$m;
180 $this->
object->setTitle($item->getTitle());
181 $this->
object->setNrOfTries($item->getMaxattempts());
182 $this->
object->setComment($item->getComment());
183 $this->
object->setAuthor($item->getAuthor());
184 $this->
object->setOwner(
$ilUser->getId());
185 $this->
object->setObjId($questionpool_id);
186 $this->
object->setMinAutoComplete($item->getMetadataEntry(
"minAutoCompleteLength"));
187 $this->
object->setIdenticalscoring((
int) $item->getMetadataEntry(
"identical_scoring"));
188 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
189 $this->
object->setCorrectAnswers($correct_answers);
190 $this->
object->setPoints($sum);
192 $this->
object->setAdditionalContentEditingMode(
195 $this->
object->saveToDb();
197 if (count($feedbacks) > 0) {
198 foreach ($feedbacks as $ident => $material) {
199 $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
200 $this->object->getId(),
207 if (is_array($feedbacksgeneric) && count($feedbacksgeneric) > 0) {
208 foreach ($feedbacksgeneric as $correctness => $material) {
209 $this->
object->feedbackOBJ->importGenericFeedback(
210 $this->object->getId(),
216 $this->
object->saveToDb();
217 if (count($item->suggested_solutions)) {
218 foreach ($item->suggested_solutions as $suggested_solution) {
219 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
221 $this->
object->saveToDb();
225 $q_1_id = $this->
object->getId();
226 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
227 $tst_object->questions[$question_counter++] = $question_id;
228 $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id,
"test" => $question_id);
230 $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(),
"test" => 0);
236 $id = preg_split(
'/_/', $ident);
addGeneralMetadata(ilQTIItem $item)
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
if(!array_key_exists('StateId', $_REQUEST)) $id
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.