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']);
43 foreach ($presentation->order as $entry) {
44 switch ($entry[
"type"]) {
46 $response = $presentation->response[$entry[
"index"]];
48 switch (strtolower(get_class($rendertype))) {
49 case "ilqtirenderfib":
50 $maxchars = $rendertype->getMaxchars();
57 $feedbacksgeneric = array();
58 foreach ($item->resprocessing as $resprocessing) {
59 $outcomes = $resprocessing->getOutcomes();
60 foreach ($outcomes->decvar as $decvar) {
61 $maxpoints = $decvar->getMaxvalue();
64 foreach ($resprocessing->respcondition as $respcondition) {
65 foreach ($respcondition->displayfeedback as $feedbackpointer) {
66 if (strlen($feedbackpointer->getLinkrefid())) {
67 foreach ($item->itemfeedback as $ifb) {
68 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
70 if (count($ifb->material)) {
71 foreach ($ifb->material as $material) {
72 $feedbacksgeneric[1] = $material;
75 if ((count($ifb->flow_mat) > 0)) {
76 foreach ($ifb->flow_mat as $fmat) {
77 if (count($fmat->material)) {
78 foreach ($fmat->material as $material) {
79 $feedbacksgeneric[1] = $material;
84 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
86 if (count($ifb->material)) {
87 foreach ($ifb->material as $material) {
88 $feedbacksgeneric[0] = $material;
91 if ((count($ifb->flow_mat) > 0)) {
92 foreach ($ifb->flow_mat as $fmat) {
93 if (count($fmat->material)) {
94 foreach ($fmat->material as $material) {
95 $feedbacksgeneric[0] = $material;
107 $this->
object->setTitle($item->getTitle());
108 $this->
object->setNrOfTries($item->getMaxattempts());
109 $this->
object->setComment($item->getComment());
110 $this->
object->setAuthor($item->getAuthor());
111 $this->
object->setOwner(
$ilUser->getId());
112 $this->
object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
113 $this->
object->setObjId($questionpool_id);
114 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
115 $this->
object->setPoints($maxpoints);
116 $this->
object->setMaxNumOfChars($maxchars);
117 $textrating = $item->getMetadataEntry(
"textrating");
118 if (strlen($textrating)) {
119 $this->
object->setTextRating($textrating);
121 $this->
object->matchcondition = (strlen($item->getMetadataEntry(
'matchcondition'))) ? $item->getMetadataEntry(
'matchcondition') : 0;
123 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php';
124 $no_keywords_found =
true;
127 for (
$i = 0;
$i < count($termscoring);
$i++) {
128 $this->
object->addAnswer($termscoring[
$i]->getAnswertext(), $termscoring[
$i]->getPoints());
129 $no_keywords_found =
false;
131 if (count($termscoring)) {
132 $this->
object->setKeywordRelation($item->getMetadataEntry(
'termrelation'));
135 $keywords = $item->getMetadataEntry(
"keywords");
136 if (strlen($keywords)) {
137 #$this->object->setKeywords($keywords); 138 $answers = explode(
' ', $keywords);
139 foreach ($answers as $answer) {
140 $this->
object->addAnswer($answer, 0);
142 $this->
object->setKeywordRelation(
'one');
143 $no_keywords_found =
false;
145 if ($no_keywords_found) {
146 $this->
object->setKeywordRelation(
'non');
150 $this->
object->setAdditionalContentEditingMode(
153 $this->
object->saveToDb();
154 if (count($item->suggested_solutions)) {
155 foreach ($item->suggested_solutions as $suggested_solution) {
156 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
158 $this->
object->saveToDb();
160 foreach ($feedbacksgeneric as $correctness => $material) {
161 $m = $this->
object->QTIMaterialToString($material);
162 $feedbacksgeneric[$correctness] =
$m;
165 $questiontext = $this->
object->getQuestion();
169 if (is_array(
$_SESSION[
"import_mob_xhtml"])) {
170 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
171 include_once
"./Services/RTE/classes/class.ilRTE.php";
172 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob) {
180 $DIC[
'ilLog']->write(__METHOD__ .
': import mob from dir: ' . $importfile);
184 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
185 foreach ($feedbacks as $ident => $material) {
186 $feedbacks[$ident] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
188 foreach ($feedbacksgeneric as $correctness => $material) {
189 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
194 foreach ($feedbacks as $ident => $material) {
197 $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
198 $this->object->getId(),
204 foreach ($feedbacksgeneric as $correctness => $material) {
205 $this->
object->feedbackOBJ->importGenericFeedback(
206 $this->object->getId(),
211 $this->
object->saveToDb();
213 $q_1_id = $this->
object->getId();
214 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
215 $tst_object->questions[$question_counter++] = $question_id;
216 $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id,
"test" => $question_id);
218 $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(),
"test" => 0);
224 $termScoringString = $item->getMetadataEntry(
'termscoring');
226 if (!strlen($termScoringString)) {
230 $termScoring = unserialize($termScoringString);
232 if (is_array($termScoring)) {
236 $termScoringString = base64_decode($termScoringString);
237 $termScoring = unserialize($termScoringString);
239 if (is_array($termScoring)) {
getFeedbackAnswerSpecific(ilQTIItem $item, $prefix='response_')
addGeneralMetadata(ilQTIItem $item)
Class for essay question imports.
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.
fetchIndexFromFeedbackIdent($feedbackIdent, $prefix='response_')