24 string $importdirectory,
30 int &$question_counter,
36 $correct_answers = [];
39 foreach ($presentation->order as $entry) {
40 switch ($entry[
"type"]) {
43 $material = $presentation->material[$entry[
"index"]];
56 $questiontext = $this->
object->getQuestion();
57 $longmenutext = $this->
object->getLongMenuTextValue();
60 $importfile = $importdirectory . DIRECTORY_SEPARATOR . $mob[
"uri"];
63 $DIC[
'ilLog']->write(__METHOD__ .
': import mob from dir: ' . $importfile);
68 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
69 $longmenutext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $longmenutext);
76 foreach ($item->resprocessing as $resprocessing) {
77 foreach ($resprocessing->respcondition as $respcondition) {
79 $conditionvar = $respcondition->getConditionvar();
80 foreach ($conditionvar->order as $order) {
81 switch ($order[
'field']) {
83 $equals = $conditionvar->varequal[$order[
"index"]]->getContent();
84 $gapident = $conditionvar->varequal[$order[
"index"]]->getRespident();
86 if (!isset($answers[
$id]) || !in_array($equals, $answers[$id])) {
87 $answers[
$id][] = $equals;
92 foreach ($respcondition->setvar as $setvar) {
93 if ($gapident !==
'') {
94 if ($setvar->getContent() > 0) {
96 $correct_answers[
$id][0][] = $equals;
97 $correct_answers[
$id][1] = $setvar->getContent();
98 if (is_array($gap_types) && key_exists(
$id, $gap_types)) {
99 $correct_answers[
$id][2] = $gap_types[
$id];
104 foreach ($respcondition->displayfeedback as $feedbackpointer) {
105 if (strlen($feedbackpointer->getLinkrefid())) {
106 foreach ($item->itemfeedback as $ifb) {
107 if ($ifb->getIdent() ===
'response_allcorrect') {
108 foreach ($ifb->material as $material) {
109 $feedbacksgeneric[1] = $material;
111 foreach ($ifb->flow_mat as $fmat) {
112 if (count($fmat->material)) {
113 foreach ($fmat->material as $material) {
114 $feedbacksgeneric[1] = $material;
118 } elseif ($ifb->getIdent() ===
'response_onenotcorrect') {
119 foreach ($ifb->material as $material) {
120 $feedbacksgeneric[0] = $material;
122 foreach ($ifb->flow_mat as $fmat) {
123 if (count($fmat->material)) {
124 foreach ($fmat->material as $material) {
125 $feedbacksgeneric[0] = $material;
130 foreach ($ifb->material as $material) {
131 $feedbacks[$ifb->getIdent()] = $material;
133 foreach ($ifb->flow_mat as $fmat) {
134 if (count($fmat->material)) {
135 foreach ($fmat->material as $material) {
136 $feedbacks[$ifb->getIdent()] = $material;
148 foreach ($correct_answers as $row) {
151 $this->
object->setAnswers($answers);
153 if (isset($feedbacks) && count($feedbacks) > 0) {
154 foreach ($feedbacks as $ident => $material) {
156 $feedbacks[$ident] = $m;
159 if (isset($feedbacksgeneric) && is_array($feedbacksgeneric) && count($feedbacksgeneric) > 0) {
160 foreach ($feedbacksgeneric as $correctness => $material) {
162 $feedbacksgeneric[$correctness] = $m;
167 $this->
object->setTitle($item->
getTitle());
169 $this->
object->setComment($item->
getComment());
170 $this->
object->setAuthor($item->
getAuthor());
171 $this->
object->setOwner($user_id);
172 $this->
object->setObjId($questionpool_id);
174 $this->
object->setIdenticalscoring((
int) $item->
getMetadataEntry(
'identical_scoring'));
175 $this->
object->setCorrectAnswers($correct_answers);
176 $this->
object->setPoints($sum);
178 $this->
object->setAdditionalContentEditingMode(
181 $this->
object->saveToDb();
183 if (isset($feedbacks) && count($feedbacks) > 0) {
184 foreach ($feedbacks as $ident => $material) {
185 $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
193 if (isset($feedbacksgeneric) && is_array($feedbacksgeneric) && count($feedbacksgeneric) > 0) {
194 foreach ($feedbacksgeneric as $correctness => $material) {
195 $this->
object->feedbackOBJ->importGenericFeedback(
202 $this->
object->saveToDb();
205 $q_1_id = $this->
object->getId();
206 $question_id = $this->
object->duplicate(
true,
"",
"", -1, $tst_id);
207 $tst_object->questions[$question_counter++] = $question_id;
208 $import_mapping[$item->
getIdent()] = [
"pool" => $q_1_id,
"test" => $question_id];
210 $import_mapping[$item->
getIdent()] = [
"pool" => $this->
object->getId(),
"test" => 0];
212 return $import_mapping;
217 $id = preg_split(
'/_/', $ident);
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static get(string $a_var)
addGeneralMetadata(ilQTIItem $item)
QTIMaterialToString(ilQTIMaterial $a_material)
Reads an QTI material tag and creates a text or XHTML string.
getMetadataEntry(string $a_label)
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
importSuggestedSolutions(int $question_id, array $solution_from_import)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Class for question imports.
static clear(string $a_var)