2require_once
'Modules/TestQuestionPool/classes/import/qti12/class.assQuestionImport.php';
3require_once
'Modules/TestQuestionPool/classes/class.assLongMenu.php';
9 public function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
15 $presentation = $item->getPresentation();
16 $duration = $item->getDuration();
17 $questiontext = array();
18 $seperate_question_field = $item->getMetadataEntry(
"question");
21 $created =
sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
23 $correct_answers = array();
24 $presentation = $item->getPresentation();
25 $gap_types = json_decode($item->getMetadataEntry(
"gapTypes"));
26 foreach ($presentation->order as $entry) {
27 switch ($entry[
"type"]) {
30 $material = $presentation->material[$entry[
"index"]];
31 if (preg_match(
'/\[Longmenu \d\]/', $this->object->QTIMaterialToString($material))) {
32 $this->
object->setLongMenuTextValue($this->object->QTIMaterialToString($material));
34 $this->
object->setQuestion($this->object->QTIMaterialToString($material));
41 foreach ($item->resprocessing as $resprocessing) {
42 foreach ($resprocessing->respcondition as $respcondition) {
44 $conditionvar = $respcondition->getConditionvar();
45 foreach ($conditionvar->order as $order) {
46 switch ($order[
"field"]) {
48 $equals = $conditionvar->varequal[$order[
"index"]]->getContent();
49 $gapident = $conditionvar->varequal[$order[
"index"]]->getRespident();
51 $answers[
$id][] = $equals;
55 foreach ($respcondition->setvar as $setvar) {
56 if (strcmp($gapident,
"") != 0) {
57 if ($setvar->getContent() > 0) {
59 $correct_answers[
$id][0][] = $equals;
60 $correct_answers[
$id][1] = $setvar->getContent();
61 if (is_array($gap_types) && key_exists(
$id, $gap_types)) {
62 $correct_answers[
$id][2] = $gap_types[
$id];
67 if (count($respcondition->displayfeedback)) {
68 foreach ($respcondition->displayfeedback as $feedbackpointer) {
69 if (strlen($feedbackpointer->getLinkrefid())) {
70 foreach ($item->itemfeedback as $ifb) {
71 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
73 if (count($ifb->material)) {
74 foreach ($ifb->material as $material) {
75 $feedbacksgeneric[1] = $material;
78 if ((count($ifb->flow_mat) > 0)) {
79 foreach ($ifb->flow_mat as $fmat) {
80 if (count($fmat->material)) {
81 foreach ($fmat->material as $material) {
82 $feedbacksgeneric[1] = $material;
87 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
89 if (count($ifb->material)) {
90 foreach ($ifb->material as $material) {
91 $feedbacksgeneric[0] = $material;
94 if ((count($ifb->flow_mat) > 0)) {
95 foreach ($ifb->flow_mat as $fmat) {
96 if (count($fmat->material)) {
97 foreach ($fmat->material as $material) {
98 $feedbacksgeneric[0] = $material;
105 if (count($ifb->material)) {
106 foreach ($ifb->material as $material) {
107 $feedbacks[$ifb->getIdent()] = $material;
110 if ((count($ifb->flow_mat) > 0)) {
111 foreach ($ifb->flow_mat as $fmat) {
112 if (count($fmat->material)) {
113 foreach ($fmat->material as $material) {
114 $feedbacks[$ifb->getIdent()] = $material;
128 foreach ($correct_answers as
$row) {
131 $this->
object->setAnswers($answers);
133 if (count($feedbacks) > 0) {
134 foreach ($feedbacks as $ident => $material) {
135 $m = $this->
object->QTIMaterialToString($material);
136 $feedbacks[$ident] =
$m;
139 if (count($feedbacksgeneric) > 0) {
140 foreach ($feedbacksgeneric as $correctness => $material) {
141 $m = $this->
object->QTIMaterialToString($material);
142 $feedbacksgeneric[$correctness] =
$m;
147 $this->
object->setTitle($item->getTitle());
148 $this->
object->setNrOfTries($item->getMaxattempts());
149 $this->
object->setComment($item->getComment());
150 $this->
object->setAuthor($item->getAuthor());
151 $this->
object->setOwner($ilUser->getId());
152 $this->
object->setObjId($questionpool_id);
153 $this->
object->setMinAutoComplete($item->getMetadataEntry(
"minAutoCompleteLength"));
154 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
155 $this->
object->setCorrectAnswers($correct_answers);
156 $this->
object->setPoints($sum);
158 $this->
object->setAdditionalContentEditingMode(
161 $this->
object->saveToDb();
163 if (count($feedbacks) > 0) {
164 foreach ($feedbacks as $ident => $material) {
165 $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
166 $this->object->getId(),
172 if (count($feedbacksgeneric) > 0) {
173 foreach ($feedbacksgeneric as $correctness => $material) {
174 $this->
object->feedbackOBJ->importGenericFeedback(
175 $this->object->getId(),
181 $this->
object->saveToDb();
182 if (count($item->suggested_solutions)) {
183 foreach ($item->suggested_solutions as $suggested_solution) {
184 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
186 $this->
object->saveToDb();
190 $q_1_id = $this->
object->getId();
191 $question_id = $this->
object->duplicate(
true,
null,
null,
null, $tst_id);
192 $tst_object->questions[$question_counter++] = $question_id;
193 $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id,
"test" => $question_id);
195 $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(),
"test" => 0);
201 $id = preg_split(
'/_/', $ident);
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Class for question imports.
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
addGeneralMetadata(ilQTIItem $item)
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...
if(!array_key_exists('StateId', $_REQUEST)) $id