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();
42 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
44 foreach ($presentation->order as $entry) {
45 switch ($entry[
"type"]) {
47 $response = $presentation->response[$entry[
"index"]];
49 array_push($idents,
$response->getIdent());
55 $feedbacksgeneric = array();
56 foreach ($item->resprocessing as $resprocessing) {
57 foreach ($resprocessing->respcondition as $respcondition) {
60 $conditionvar = $respcondition->getConditionvar();
61 foreach ($conditionvar->order as $order) {
62 switch ($order[
"field"]) {
64 $respident = $conditionvar->varsubset[$order[
"index"]]->getRespident();
65 $content = $conditionvar->varsubset[$order[
"index"]]->getContent();
66 if (!is_array($responses[$respident])) {
67 $responses[$respident] = array();
69 $vars = explode(
",", $content);
70 foreach ($vars as $var) {
71 array_push($responses[$respident], array(
"solution" => $var,
"points" =>
""));
76 foreach ($respcondition->setvar as $setvar) {
77 if ((strcmp($setvar->getVarname(),
"matches") == 0) && ($setvar->getAction() ==
ACTION_ADD)) {
78 foreach ($responses[$respident] as $idx => $solutionarray) {
79 if (strlen($solutionarray[
"points"] == 0)) {
80 $responses[$respident][$idx][
"points"] = $setvar->getContent();
85 foreach ($resprocessing->respcondition as $respcondition) {
86 foreach ($respcondition->displayfeedback as $feedbackpointer) {
87 if (strlen($feedbackpointer->getLinkrefid())) {
88 foreach ($item->itemfeedback as $ifb) {
89 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
91 if (count($ifb->material)) {
92 foreach ($ifb->material as $material) {
93 $feedbacksgeneric[1] = $material;
96 if ((count($ifb->flow_mat) > 0)) {
97 foreach ($ifb->flow_mat as $fmat) {
98 if (count($fmat->material)) {
99 foreach ($fmat->material as $material) {
100 $feedbacksgeneric[1] = $material;
105 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
107 if (count($ifb->material)) {
108 foreach ($ifb->material as $material) {
109 $feedbacksgeneric[0] = $material;
112 if ((count($ifb->flow_mat) > 0)) {
113 foreach ($ifb->flow_mat as $fmat) {
114 if (count($fmat->material)) {
115 foreach ($fmat->material as $material) {
116 $feedbacksgeneric[0] = $material;
129 $this->
object->setTitle($item->getTitle());
130 $this->
object->setNrOfTries($item->getMaxattempts());
131 $this->
object->setComment($item->getComment());
132 $this->
object->setAuthor($item->getAuthor());
133 $this->
object->setOwner(
$ilUser->getId());
134 $this->
object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
135 $this->
object->setObjId($questionpool_id);
136 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
137 $textrating = $item->getMetadataEntry(
"textrating");
138 if (strlen($textrating) == 0) {
141 $this->
object->setTextRating($textrating);
142 $this->
object->setCorrectAnswers($item->getMetadataEntry(
"correctanswers"));
147 $this->
object->addAnswer($answer[
"solution"], $answer[
"points"], $counter);
152 $this->
object->setAdditionalContentEditingMode(
155 $this->
object->saveToDb();
156 if (count($item->suggested_solutions)) {
157 foreach ($item->suggested_solutions as $suggested_solution) {
158 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
160 $this->
object->saveToDb();
162 foreach ($feedbacksgeneric as $correctness => $material) {
163 $m = $this->
object->QTIMaterialToString($material);
164 $feedbacksgeneric[$correctness] =
$m;
167 $questiontext = $this->
object->getQuestion();
168 if (is_array(
$_SESSION[
"import_mob_xhtml"])) {
169 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
170 include_once
"./Services/RTE/classes/class.ilRTE.php";
171 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob) {
179 $DIC[
'ilLog']->write(__METHOD__ .
': import mob from dir: ' . $importfile);
183 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
184 foreach ($feedbacksgeneric as $correctness => $material) {
185 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
190 foreach ($feedbacksgeneric as $correctness => $material) {
191 $this->
object->feedbackOBJ->importGenericFeedback(
192 $this->object->getId(),
197 $this->
object->saveToDb();
199 $q_1_id = $this->
object->getId();
200 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
201 $tst_object->questions[$question_counter++] = $question_id;
202 $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id,
"test" => $question_id);
204 $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(),
"test" => 0);
Class for text subset 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.