4include_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();
 
   45        $created = 
sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
 
   47        foreach ($presentation->order as $entry) {
 
   48            switch ($entry[
"type"]) {
 
   50                    $material = $presentation->material[$entry[
"index"]];
 
   51                    for (
$i = 0; 
$i < $material->getMaterialCount(); 
$i++) {
 
   52                        $mat = $material->getMaterial(
$i);
 
   53                        if (strcmp($mat[
"type"], 
"mattext") == 0) {
 
   54                            $mattext = $mat[
"material"];
 
   55                            if ((strlen($mattext->getLabel()) == 0) && (strlen($this->object->QTIMaterialToString($item->getQuestiontext())) == 0)) {
 
   56                                $item->setQuestiontext($mattext->getContent());
 
   58                            if (strcmp($mattext->getLabel(), 
"points") == 0) {
 
   59                                $maxpoints = $mattext->getContent();
 
   60                            } elseif (strcmp($mattext->getLabel(), 
"java_code") == 0) {
 
   61                                $javacode = $mattext->getContent();
 
   62                            } elseif (strcmp($mattext->getLabel(), 
"java_codebase") == 0) {
 
   63                                $javacodebase = $mattext->getContent();
 
   64                            } elseif (strcmp($mattext->getLabel(), 
"java_archive") == 0) {
 
   65                                $javaarchive = $mattext->getContent();
 
   66                            } elseif (strlen($mattext->getLabel()) > 0) {
 
   67                                array_push(
$params, array(
"key" => $mattext->getLabel(), 
"value" => $mattext->getContent()));
 
   69                        } elseif (strcmp($mat[
"type"], 
"matapplet") == 0) {
 
   70                            $applet = $mat[
"material"];
 
   77        $feedbacksgeneric = array();
 
   78        foreach ($item->resprocessing as $resprocessing) {
 
   79            foreach ($resprocessing->respcondition as $respcondition) {
 
   80                foreach ($respcondition->displayfeedback as $feedbackpointer) {
 
   81                    if (strlen($feedbackpointer->getLinkrefid())) {
 
   82                        foreach ($item->itemfeedback as $ifb) {
 
   83                            if (strcmp($ifb->getIdent(), 
"response_allcorrect") == 0) {
 
   85                                if (count($ifb->material)) {
 
   86                                    foreach ($ifb->material as $material) {
 
   87                                        $feedbacksgeneric[1] = $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[1] = $material;
 
   99                            } elseif (strcmp($ifb->getIdent(), 
"response_onenotcorrect") == 0) {
 
  101                                if (count($ifb->material)) {
 
  102                                    foreach ($ifb->material as $material) {
 
  103                                        $feedbacksgeneric[0] = $material;
 
  106                                if ((count($ifb->flow_mat) > 0)) {
 
  107                                    foreach ($ifb->flow_mat as $fmat) {
 
  108                                        if (count($fmat->material)) {
 
  109                                            foreach ($fmat->material as $material) {
 
  110                                                $feedbacksgeneric[0] = $material;
 
  123        $this->
object->setTitle($item->getTitle());
 
  124        $this->
object->setNrOfTries($item->getMaxattempts());
 
  125        $this->
object->setComment($item->getComment());
 
  126        $this->
object->setAuthor($item->getAuthor());
 
  127        $this->
object->setOwner($ilUser->getId());
 
  128        $this->
object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
 
  129        $this->
object->setObjId($questionpool_id);
 
  130        $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
 
  131        $this->
object->setJavaAppletFilename($applet->getUri());
 
  132        $this->
object->setJavaWidth($applet->getWidth());
 
  133        $this->
object->setJavaHeight($applet->getHeight());
 
  134        $this->
object->setJavaCode($javacode);
 
  135        $this->
object->setJavaCodebase($javacodebase);
 
  136        $this->
object->setJavaArchive($javaarchive);
 
  137        $this->
object->setPoints($maxpoints);
 
  139            $this->
object->addParameter($pair[
"key"], $pair[
"value"]);
 
  142        $this->
object->setAdditionalContentEditingMode(
 
  145        $this->
object->saveToDb();
 
  146        if (count($item->suggested_solutions)) {
 
  147            foreach ($item->suggested_solutions as $suggested_solution) {
 
  148                $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"], 
true);
 
  150            $this->
object->saveToDb();
 
  152        $javaapplet =&base64_decode($applet->getContent());
 
  153        $javapath = $this->
object->getJavaPath();
 
  154        if (!file_exists($javapath)) {
 
  155            include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  158        $javapath .=  $this->
object->getJavaAppletFilename();
 
  159        $fh = fopen($javapath, 
"wb");
 
  165            $javafile = fwrite(
$fh, $javaapplet);
 
  169        foreach ($feedbacksgeneric as $correctness => $material) {
 
  170            $m = $this->
object->QTIMaterialToString($material);
 
  171            $feedbacksgeneric[$correctness] = 
$m;
 
  173        $questiontext = $this->
object->getQuestion();
 
  174        if (is_array(
$_SESSION[
"import_mob_xhtml"])) {
 
  175            include_once 
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
 
  176            include_once 
"./Services/RTE/classes/class.ilRTE.php";
 
  177            foreach (
$_SESSION[
"import_mob_xhtml"] as $mob) {
 
  184                $GLOBALS[
'ilLog']->write(__METHOD__ . 
': import mob from dir: ' . $importfile);
 
  188                $questiontext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $questiontext);
 
  189                foreach ($feedbacksgeneric as $correctness => $material) {
 
  190                    $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $material);
 
  195        foreach ($feedbacksgeneric as $correctness => $material) {
 
  196            $this->
object->feedbackOBJ->importGenericFeedback(
 
  197                $this->object->getId(),
 
  202        $this->
object->saveToDb();
 
  204            $q_1_id = $this->
object->getId();
 
  205            $question_id = $this->
object->duplicate(
true, 
null, 
null, 
null, $tst_id);
 
  206            $tst_object->questions[$question_counter++] = $question_id;
 
  207            $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id, 
"test" => $question_id);
 
  209            $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(), 
"test" => 0);
 
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Class for java applet question imports.
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
Creates a question from a QTI file.
Class for question imports.
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($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...
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.