22    public function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, $import_mapping): array
 
   29        $presentation = $item->getPresentation();
 
   30        $questiontext = array();
 
   31        $seperate_question_field = $item->getMetadataEntry(
"question");
 
   34        $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
 
   36        $correct_answers = array();
 
   37        $presentation = $item->getPresentation();
 
   38        $gap_types = json_decode($item->getMetadataEntry(
"gapTypes"));
 
   39        foreach ($presentation->order as $entry) {
 
   40            switch ($entry[
"type"]) {
 
   43                    $material = $presentation->material[$entry[
"index"]];
 
   44                    if (preg_match(
'/\[Longmenu \d\]/', $this->
object->QTIMaterialToString($material))) {
 
   45                        $this->
object->setLongMenuTextValue($this->
object->QTIMaterialToString($material));
 
   47                        $this->
object->setQuestion($this->
object->QTIMaterialToString($material));
 
   56        $questiontext = $this->
object->getQuestion();
 
   57        $longmenutext = $this->
object->getLongMenuTextValue();
 
   67                $DIC[
'ilLog']->write(__METHOD__ . 
': import mob from dir: ' . $importfile);
 
   72                $questiontext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $questiontext);
 
   73                $longmenutext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $longmenutext);
 
   80        foreach ($item->resprocessing as $resprocessing) {
 
   81            foreach ($resprocessing->respcondition as $respcondition) {
 
   83                $conditionvar = $respcondition->getConditionvar();
 
   84                foreach ($conditionvar->order as $order) {
 
   85                    switch ($order[
"field"]) {
 
   87                            $equals = $conditionvar->varequal[$order[
"index"]]->getContent();
 
   88                            $gapident = $conditionvar->varequal[$order[
"index"]]->getRespident();
 
   90                            $answers[
$id][] = $equals;
 
   94                foreach ($respcondition->setvar as $setvar) {
 
   95                    if (strcmp($gapident, 
"") != 0) {
 
   96                        if ($setvar->getContent() > 0) {
 
   98                            $correct_answers[
$id][0][] = $equals;
 
   99                            $correct_answers[
$id][1] = $setvar->getContent();
 
  100                            if (is_array($gap_types) && key_exists(
$id, $gap_types)) {
 
  101                                $correct_answers[
$id][2] = $gap_types[
$id];
 
  106                if (count($respcondition->displayfeedback)) {
 
  107                    foreach ($respcondition->displayfeedback as $feedbackpointer) {
 
  108                        if (strlen($feedbackpointer->getLinkrefid())) {
 
  109                            foreach ($item->itemfeedback as $ifb) {
 
  110                                if (strcmp($ifb->getIdent(), 
"response_allcorrect") == 0) {
 
  112                                    if (count($ifb->material)) {
 
  113                                        foreach ($ifb->material as $material) {
 
  114                                            $feedbacksgeneric[1] = $material;
 
  117                                    if ((count($ifb->flow_mat) > 0)) {
 
  118                                        foreach ($ifb->flow_mat as $fmat) {
 
  119                                            if (count($fmat->material)) {
 
  120                                                foreach ($fmat->material as $material) {
 
  121                                                    $feedbacksgeneric[1] = $material;
 
  126                                } elseif (strcmp($ifb->getIdent(), 
"response_onenotcorrect") == 0) {
 
  128                                    if (count($ifb->material)) {
 
  129                                        foreach ($ifb->material as $material) {
 
  130                                            $feedbacksgeneric[0] = $material;
 
  133                                    if ((count($ifb->flow_mat) > 0)) {
 
  134                                        foreach ($ifb->flow_mat as $fmat) {
 
  135                                            if (count($fmat->material)) {
 
  136                                                foreach ($fmat->material as $material) {
 
  137                                                    $feedbacksgeneric[0] = $material;
 
  144                                    if (count($ifb->material)) {
 
  145                                        foreach ($ifb->material as $material) {
 
  146                                            $feedbacks[$ifb->getIdent()] = $material;
 
  149                                    if ((count($ifb->flow_mat) > 0)) {
 
  150                                        foreach ($ifb->flow_mat as $fmat) {
 
  151                                            if (count($fmat->material)) {
 
  152                                                foreach ($fmat->material as $material) {
 
  153                                                    $feedbacks[$ifb->getIdent()] = $material;
 
  167        foreach ($correct_answers as $row) {
 
  170        $this->
object->setAnswers($answers);
 
  172        if (isset($feedbacks) && count($feedbacks) > 0) {
 
  173            foreach ($feedbacks as $ident => $material) {
 
  174                $m = $this->
object->QTIMaterialToString($material);
 
  175                $feedbacks[$ident] = $m;
 
  178        if (isset($feedbacksgeneric) && is_array($feedbacksgeneric) && count($feedbacksgeneric) > 0) {
 
  179            foreach ($feedbacksgeneric as $correctness => $material) {
 
  180                $m = $this->
object->QTIMaterialToString($material);
 
  181                $feedbacksgeneric[$correctness] = $m;
 
  186        $this->
object->setTitle($item->getTitle());
 
  187        $this->
object->setNrOfTries((
int)$item->getMaxattempts());
 
  188        $this->
object->setComment($item->getComment());
 
  189        $this->
object->setAuthor($item->getAuthor());
 
  190        $this->
object->setOwner(
$ilUser->getId());
 
  191        $this->
object->setObjId($questionpool_id);
 
  192        $this->
object->setMinAutoComplete($item->getMetadataEntry(
"minAutoCompleteLength"));
 
  193        $this->
object->setIdenticalscoring((
int) $item->getMetadataEntry(
"identical_scoring"));
 
  194        $this->
object->setCorrectAnswers($correct_answers);
 
  195        $this->
object->setPoints($sum);
 
  197        $this->
object->setAdditionalContentEditingMode(
 
  200        $this->
object->saveToDb();
 
  202        if (isset($feedbacks) && count($feedbacks) > 0) {
 
  203            foreach ($feedbacks as $ident => $material) {
 
  204                $this->
object->feedbackOBJ->importSpecificAnswerFeedback(
 
  212        if (isset($feedbacksgeneric) && is_array($feedbacksgeneric) && count($feedbacksgeneric) > 0) {
 
  213            foreach ($feedbacksgeneric as $correctness => $material) {
 
  214                $this->
object->feedbackOBJ->importGenericFeedback(
 
  221        $this->
object->saveToDb();
 
  222        if (count($item->suggested_solutions)) {
 
  223            foreach ($item->suggested_solutions as $suggested_solution) {
 
  224                $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->
getContent(), $suggested_solution[
"gap_index"], 
true);
 
  226            $this->
object->saveToDb();
 
  230            $q_1_id = $this->
object->getId();
 
  231            $question_id = $this->
object->duplicate(
true, 
"", 
"", 
"", $tst_id);
 
  232            $tst_object->questions[$question_counter++] = $question_id;
 
  233            $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id, 
"test" => $question_id);
 
  235            $import_mapping[$item->getIdent()] = array(
"pool" => $this->
object->getId(), 
"test" => 0);
 
  237        return $import_mapping;
 
  242        $id = preg_split(
'/_/', $ident);
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
 
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir)
 
addGeneralMetadata(ilQTIItem $item)
 
getQplImportArchivDirectory()
returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir)
 
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)
 
static clear(string $a_var)