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)
36 $presentation = $item->getPresentation();
37 $duration = $item->getDuration();
41 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
43 foreach ($presentation->order as $entry) {
44 switch ($entry[
"type"]) {
46 $response = $presentation->response[$entry[
"index"]];
48 array_push($idents,
$response->getIdent());
54 $feedbacksgeneric =
array();
55 foreach ($item->resprocessing as $resprocessing) {
56 foreach ($resprocessing->respcondition as $respcondition) {
59 $conditionvar = $respcondition->getConditionvar();
60 foreach ($conditionvar->order as $order) {
61 switch ($order[
"field"]) {
63 $respident = $conditionvar->varsubset[$order[
"index"]]->getRespident();
64 $content = $conditionvar->varsubset[$order[
"index"]]->getContent();
65 if (!is_array($responses[$respident])) {
66 $responses[$respident] =
array();
68 $vars = explode(
",", $content);
69 foreach ($vars as $var) {
70 array_push($responses[$respident],
array(
"solution" => $var,
"points" =>
""));
75 foreach ($respcondition->setvar as $setvar) {
76 if ((strcmp($setvar->getVarname(),
"matches") == 0) && ($setvar->getAction() ==
ACTION_ADD)) {
77 foreach ($responses[$respident] as $idx => $solutionarray) {
78 if (strlen($solutionarray[
"points"] == 0)) {
79 $responses[$respident][$idx][
"points"] = $setvar->getContent();
84 foreach ($resprocessing->respcondition as $respcondition) {
85 foreach ($respcondition->displayfeedback as $feedbackpointer) {
86 if (strlen($feedbackpointer->getLinkrefid())) {
87 foreach ($item->itemfeedback as $ifb) {
88 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
90 if (count($ifb->material)) {
91 foreach ($ifb->material as $material) {
92 $feedbacksgeneric[1] = $material;
95 if ((count($ifb->flow_mat) > 0)) {
96 foreach ($ifb->flow_mat as $fmat) {
97 if (count($fmat->material)) {
98 foreach ($fmat->material as $material) {
99 $feedbacksgeneric[1] = $material;
104 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
106 if (count($ifb->material)) {
107 foreach ($ifb->material as $material) {
108 $feedbacksgeneric[0] = $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[0] = $material;
128 $this->
object->setTitle($item->getTitle());
129 $this->
object->setNrOfTries($item->getMaxattempts());
130 $this->
object->setComment($item->getComment());
131 $this->
object->setAuthor($item->getAuthor());
132 $this->
object->setOwner($ilUser->getId());
133 $this->
object->setQuestion($this->
object->QTIMaterialToString($item->getQuestiontext()));
134 $this->
object->setObjId($questionpool_id);
135 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
136 $textrating = $item->getMetadataEntry(
"textrating");
137 if (strlen($textrating) == 0) {
140 $this->
object->setTextRating($textrating);
141 $this->
object->setCorrectAnswers($item->getMetadataEntry(
"correctanswers"));
146 $this->
object->addAnswer($answer[
"solution"], $answer[
"points"],
$counter);
151 $this->
object->setAdditionalContentEditingMode(
154 $this->
object->saveToDb();
155 if (count($item->suggested_solutions)) {
156 foreach ($item->suggested_solutions as $suggested_solution) {
157 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
159 $this->
object->saveToDb();
161 foreach ($feedbacksgeneric as $correctness => $material) {
162 $m = $this->
object->QTIMaterialToString($material);
163 $feedbacksgeneric[$correctness] =
$m;
166 $questiontext = $this->
object->getQuestion();
167 if (is_array(
$_SESSION[
"import_mob_xhtml"])) {
168 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
169 include_once
"./Services/RTE/classes/class.ilRTE.php";
170 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob) {
177 $GLOBALS[
'ilLog']->write(__METHOD__ .
': import mob from dir: ' . $importfile);
181 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
182 foreach ($feedbacksgeneric as $correctness => $material) {
183 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
188 foreach ($feedbacksgeneric as $correctness => $material) {
189 $this->
object->feedbackOBJ->importGenericFeedback(
195 $this->
object->saveToDb();
197 $q_1_id = $this->
object->getId();
198 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
199 $tst_object->questions[$question_counter++] = $question_id;
200 $import_mapping[$item->getIdent()] =
array(
"pool" => $q_1_id,
"test" => $question_id);
202 $import_mapping[$item->getIdent()] =
array(
"pool" => $this->
object->getId(),
"test" => 0);
Class for text subset question imports.
addGeneralMetadata(ilQTIItem $item)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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.
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
Class for question imports.