45         $selectionLimit = null;
    47         $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
    49         foreach ($presentation->order as $entry) {
    50             switch ($entry[
"type"]) {
    52                     $response = $presentation->response[$entry[
"index"]];
    54                     switch (strtolower(get_class(
$response->getRenderType()))) {
    55                         case "ilqtirenderchoice":
    56                             $shuffle = $rendertype->getShuffle();
    57                             if ($rendertype->getMaxnumber()) {
    58                                 $selectionLimit = $rendertype->getMaxnumber();
    62                             foreach ($rendertype->response_labels as $response_label) {
    63                                 $ident = $response_label->getIdent();
    66                                 foreach ($response_label->material as $mat) {
    68                                     for ($m = 0; $m < $mat->getMaterialCount(); $m++) {
    69                                         $foundmat = $mat->getMaterial($m);
    70                                         if (strcmp($foundmat[
"type"], 
"mattext") == 0) {
    72                                         if (strcmp($foundmat[
"type"], 
"matimage") == 0) {
    73                                             if (strlen($foundmat[
"material"]->getEmbedded())) {
    79                                         for ($m = 0; $m < $mat->getMaterialCount(); $m++) {
    80                                             $foundmat = $mat->getMaterial($m);
    81                                             if (strcmp($foundmat[
"type"], 
"mattext") == 0) {
    82                                                 $answertext .= $foundmat[
"material"]->getContent();
    84                                             if (strcmp($foundmat[
"type"], 
"matimage") == 0) {
    87                                                     "imagetype" => $foundmat[
"material"]->getImageType(),
    88                                                     "label" => $foundmat[
"material"]->getLabel(),
    89                                                     "content" => $foundmat[
"material"]->getContent()
    98                                     "answertext" => $answertext,
    99                                     "imagefile" => $answerimage,
   101                                     "answerorder" => $answerorder++,
   102                                     "points_unchecked" => 0,
   112         $feedbacksgeneric = [];
   113         foreach ($item->resprocessing as $resprocessing) {
   114             foreach ($resprocessing->respcondition as $respcondition) {
   117                 $conditionvar = $respcondition->getConditionvar();
   118                 foreach ($conditionvar->order as $order) {
   119                     switch ($order[
"field"]) {
   124                             $ident = $conditionvar->varequal[$order[
"index"]]->getContent();
   128                 foreach ($respcondition->setvar as $setvar) {
   129                     if (strcmp($ident, 
"") != 0) {
   131                             $answers[$ident][
"action"] = $setvar->getAction();
   132                             $answers[$ident][
"points"] = $setvar->getContent();
   133                             if (count($respcondition->displayfeedback)) {
   134                                 foreach ($respcondition->displayfeedback as $feedbackpointer) {
   135                                     if (strlen($feedbackpointer->getLinkrefid())) {
   136                                         foreach ($item->itemfeedback as $ifb) {
   137                                             if (strcmp($ifb->getIdent(), 
"response_allcorrect") == 0) {
   139                                                 if (count($ifb->material)) {
   140                                                     foreach ($ifb->material as $material) {
   141                                                         $feedbacksgeneric[1] = $material;
   144                                                 if ((count($ifb->flow_mat) > 0)) {
   145                                                     foreach ($ifb->flow_mat as $fmat) {
   146                                                         if (count($fmat->material)) {
   147                                                             foreach ($fmat->material as $material) {
   148                                                                 $feedbacksgeneric[1] = $material;
   153                                             } elseif (strcmp($ifb->getIdent(), 
"response_onenotcorrect") == 0) {
   155                                                 if (count($ifb->material)) {
   156                                                     foreach ($ifb->material as $material) {
   157                                                         $feedbacksgeneric[0] = $material;
   160                                                 if ((count($ifb->flow_mat) > 0)) {
   161                                                     foreach ($ifb->flow_mat as $fmat) {
   162                                                         if (count($fmat->material)) {
   163                                                             foreach ($fmat->material as $material) {
   164                                                                 $feedbacksgeneric[0] = $material;
   170                                             if (strcmp($ifb->getIdent(), $feedbackpointer->getLinkrefid()) == 0) {
   172                                                 if (count($ifb->material)) {
   173                                                     foreach ($ifb->material as $material) {
   174                                                         $feedbacks[$ident] = $material;
   177                                                 if ((count($ifb->flow_mat) > 0)) {
   178                                                     foreach ($ifb->flow_mat as $fmat) {
   179                                                         if (count($fmat->material)) {
   180                                                             foreach ($fmat->material as $material) {
   181                                                                 $feedbacks[$ident] = $material;
   192                             $answers[$ident][
"action"] = $setvar->getAction();
   193                             $answers[$ident][
"points_unchecked"] = $setvar->getContent();
   200         $this->
object->setTitle($item->
getTitle());
   202         $this->
object->setComment($item->
getComment());
   203         $this->
object->setAuthor($item->
getAuthor());
   206         $this->
object->setObjId($questionpool_id);
   207         $this->
object->setShuffle($shuffle);
   208         $this->
object->setSelectionLimit($selectionLimit);
   209         $this->
object->setIsSingleline(
false);
   210         $this->
object->setThumbSize(
   214         foreach ($answers as $answer) {
   215             if ($item->
getMetadataEntry(
'singleline') || (is_array($answer[
"imagefile"]) && count($answer[
"imagefile"]) > 0)) {
   216                 $this->
object->setIsSingleline(
true);
   218             $this->
object->addAnswer(
   219                 $answer[
"answertext"],
   220                 (
float) $answer[
"points"],
   221                 (
float) $answer[
"points_unchecked"],
   222                 $answer[
"answerorder"],
   223                 $answer[
"imagefile"][
"label"] ?? null
   227         $this->
object->setAdditionalContentEditingMode(
   230         $this->
object->saveToDb();
   231         foreach ($answers as $answer) {
   232             if (is_array($answer[
"imagefile"]) && (count($answer[
"imagefile"]) > 0)) {
   233                 $image = base64_decode($answer[
"imagefile"][
"content"]);
   234                 $imagepath = $this->
object->getImagePath();
   235                 if (!file_exists($imagepath)) {
   238                 $imagepath .= $answer[
"imagefile"][
"label"];
   239                 $fh = fopen($imagepath, 
"wb");
   241                     $imagefile = fwrite($fh, $image);
   243                     $this->
object->generateThumbForFile(
   244                         $answer[
"imagefile"][
"label"],
   245                         $this->
object->getImagePath(),
   246                         $this->
object->getThumbSize()
   253         if (!is_null($feedbackSetting)) {
   254             $this->
object->feedbackOBJ->saveSpecificFeedbackSetting($this->
object->getId(), $feedbackSetting);
   258         foreach ($feedbacks as $ident => $material) {
   260             $feedbacks[$ident] = $m;
   262         foreach ($feedbacksgeneric as $correctness => $material) {
   264             $feedbacksgeneric[$correctness] = $m;
   266         $questiontext = $this->
object->getQuestion();
   267         $answers = $this->
object->getAnswers();
   270                 $importfile = $importdirectory . DIRECTORY_SEPARATOR . $mob[
"uri"];
   273                 $DIC[
'ilLog']->write(__METHOD__ . 
': import mob from dir: ' . $importfile);
   277                 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $questiontext);
   278                 foreach ($answers as $key => $value) {
   279                     $answer_obj = &$answers[$key];
   280                     $answer_obj->setAnswertext(str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $answer_obj->getAnswertext()));
   282                 foreach ($feedbacks as $ident => $material) {
   283                     $feedbacks[$ident] = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $material);
   285                 foreach ($feedbacksgeneric as $correctness => $material) {
   286                     $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $material);
   291         foreach ($answers as $key => $value) {
   292             $answer_obj = &$answers[$key];
   295         foreach ($feedbacks as $ident => $material) {
   296             $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
   303         foreach ($feedbacksgeneric as $correctness => $material) {
   304             $this->
object->feedbackOBJ->importGenericFeedback(
   310         $this->
object->saveToDb();
   318         return $import_mapping;
 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)
 
deduceThumbSizeFromImportValue(?int $size)
 
addGeneralMetadata(ilQTIItem $item)
 
QTIMaterialToString(ilQTIMaterial $a_material)
Reads an QTI material tag and creates a text or XHTML string. 
 
addQuestionToParentObjectAndBuildMappingEntry(int $questionpool_id, ?int $tst_id, int &$question_counter, ?ilObjTest &$tst_object)
 
getMetadataEntry(string $a_label)
 
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
 
static makeDirParents(string $a_dir)
Create a new directory and all parent directories. 
 
importSuggestedSolutions(int $question_id, array $solution_from_import)
 
static clear(string $a_var)