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']);
42 foreach ($presentation->order as $entry) {
43 switch ($entry[
"type"]) {
45 $response = $presentation->response[$entry[
"index"]];
47 switch (strtolower(get_class($rendertype))) {
48 case "ilqtirenderfib":
49 $maxchars = $rendertype->getMaxchars();
56 $feedbacksgeneric =
array();
57 foreach ($item->resprocessing as $resprocessing) {
58 $outcomes = $resprocessing->getOutcomes();
59 foreach ($outcomes->decvar as $decvar) {
60 $maxpoints = $decvar->getMaxvalue();
63 foreach ($resprocessing->respcondition as $respcondition) {
64 foreach ($respcondition->displayfeedback as $feedbackpointer) {
65 if (strlen($feedbackpointer->getLinkrefid())) {
66 foreach ($item->itemfeedback as $ifb) {
67 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
69 if (count($ifb->material)) {
70 foreach ($ifb->material as $material) {
71 $feedbacksgeneric[1] = $material;
74 if ((count($ifb->flow_mat) > 0)) {
75 foreach ($ifb->flow_mat as $fmat) {
76 if (count($fmat->material)) {
77 foreach ($fmat->material as $material) {
78 $feedbacksgeneric[1] = $material;
83 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
85 if (count($ifb->material)) {
86 foreach ($ifb->material as $material) {
87 $feedbacksgeneric[0] = $material;
90 if ((count($ifb->flow_mat) > 0)) {
91 foreach ($ifb->flow_mat as $fmat) {
92 if (count($fmat->material)) {
93 foreach ($fmat->material as $material) {
94 $feedbacksgeneric[0] = $material;
106 $this->
object->setTitle($item->getTitle());
107 $this->
object->setNrOfTries($item->getMaxattempts());
108 $this->
object->setComment($item->getComment());
109 $this->
object->setAuthor($item->getAuthor());
110 $this->
object->setOwner($ilUser->getId());
111 $this->
object->setQuestion($this->
object->QTIMaterialToString($item->getQuestiontext()));
112 $this->
object->setObjId($questionpool_id);
113 $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
114 $this->
object->setPoints($maxpoints);
115 $this->
object->setMaxNumOfChars($maxchars);
116 $textrating = $item->getMetadataEntry(
"textrating");
117 if (strlen($textrating)) {
118 $this->
object->setTextRating($textrating);
120 $this->
object->matchcondition = (strlen($item->getMetadataEntry(
'matchcondition'))) ? $item->getMetadataEntry(
'matchcondition') : 0;
122 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php';
123 $no_keywords_found=
true;
126 for (
$i = 0;
$i < count($termscoring);
$i++) {
127 $this->
object->addAnswer($termscoring[
$i]->getAnswertext(), $termscoring[
$i]->getPoints());
128 $no_keywords_found=
false;
130 if (count($termscoring)) {
131 $this->
object->setKeywordRelation($item->getMetadataEntry(
'termrelation'));
134 $keywords = $item->getMetadataEntry(
"keywords");
135 if (strlen($keywords)) {
136 #$this->object->setKeywords($keywords); 137 $answers = explode(
' ', $keywords);
138 foreach ($answers as $answer) {
139 $this->
object->addAnswer($answer, 0);
141 $this->
object->setKeywordRelation(
'one');
142 $no_keywords_found=
false;
144 if ($no_keywords_found) {
145 $this->
object->setKeywordRelation(
'non');
149 $this->
object->setAdditionalContentEditingMode(
152 $this->
object->saveToDb();
153 if (count($item->suggested_solutions)) {
154 foreach ($item->suggested_solutions as $suggested_solution) {
155 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
157 $this->
object->saveToDb();
159 foreach ($feedbacksgeneric as $correctness => $material) {
160 $m = $this->
object->QTIMaterialToString($material);
161 $feedbacksgeneric[$correctness] =
$m;
164 $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) {
178 $GLOBALS[
'ilLog']->write(__METHOD__ .
': import mob from dir: ' . $importfile);
182 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
183 foreach ($feedbacks as $ident => $material) {
184 $feedbacks[$ident] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
186 foreach ($feedbacksgeneric as $correctness => $material) {
187 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
192 foreach ($feedbacks as $ident => $material) {
195 $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
201 foreach ($feedbacksgeneric as $correctness => $material) {
202 $this->
object->feedbackOBJ->importGenericFeedback(
208 $this->
object->saveToDb();
210 $q_1_id = $this->
object->getId();
211 $question_id = $this->
object->duplicate(
true, null, null, null, $tst_id);
212 $tst_object->questions[$question_counter++] = $question_id;
213 $import_mapping[$item->getIdent()] =
array(
"pool" => $q_1_id,
"test" => $question_id);
215 $import_mapping[$item->getIdent()] =
array(
"pool" => $this->
object->getId(),
"test" => 0);
221 $termScoringString = $item->getMetadataEntry(
'termscoring');
223 if (!strlen($termScoringString)) {
227 $termScoring = unserialize($termScoringString);
229 if (is_array($termScoring)) {
233 $termScoringString = base64_decode($termScoringString);
234 $termScoring = unserialize($termScoringString);
236 if (is_array($termScoring)) {
getFeedbackAnswerSpecific(ilQTIItem $item, $prefix='response_')
addGeneralMetadata(ilQTIItem $item)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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...
Create styles array
The data for the language used.
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
Creates a question from a QTI file.
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.
fetchIndexFromFeedbackIdent($feedbackIdent, $prefix='response_')