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)
 
   37        $presentation = $item->getPresentation();
 
   38        $duration = $item->getDuration();
 
   40        $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
 
   42        $feedbacksgeneric = array();
 
   44        $this->
object->setTitle($item->getTitle());
 
   45        $this->
object->setComment($item->getComment());
 
   46        $this->
object->setAuthor($item->getAuthor());
 
   47        $this->
object->setOwner(
$ilUser->getId());
 
   48        $this->
object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
 
   49        $this->
object->setObjId($questionpool_id);
 
   50        $this->
object->setEstimatedWorkingTime($duration[
"h"], $duration[
"m"], $duration[
"s"]);
 
   51        if (preg_match_all(
"/(\\\$v\\d+)/ims", $this->object->getQuestion(), $matches)) {
 
   52            foreach ($matches[1] as $variable) {
 
   53                $data = unserialize($item->getMetadataEntry($variable));
 
   54                $unit = $this->
object->getUnitRepository()->getUnit(
$data[
"unitvalue"]);
 
   55                require_once 
'Modules/TestQuestionPool/classes/class.assFormulaQuestionVariable.php';
 
   57                $this->
object->addVariable($varObj);
 
   60        if (preg_match_all(
"/(\\\$r\\d+)/ims", $this->object->getQuestion(), $rmatches)) {
 
   61            foreach ($rmatches[1] as 
$result) {
 
   63                $unit = $this->
object->getUnitRepository()->getUnit(
$data[
"unitvalue"]);
 
   64                require_once 
'Modules/TestQuestionPool/classes/class.assFormulaQuestionResult.php';
 
   65                if (!is_array(
$data[
"rating"])) {
 
   68                    $resObj = 
new assFormulaQuestionResult(
$result, 
$data[
"rangemin"], 
$data[
"rangemax"], 
$data[
"tolerance"], $unit, 
$data[
"formula"], 
$data[
"points"], 
$data[
"precision"], 
false, 
$data[
"rating"][
"sign"], 
$data[
"rating"][
"value"], 
$data[
"rating"][
"unit"]);
 
   70                if (array_key_exists(
'resulttype', 
$data)) {
 
   71                    $resObj->setResultType(
$data[
"resulttype"]);
 
   73                $this->
object->addResult($resObj);
 
   74                if (is_array(
$data[
"resultunits"])) {
 
   75                    foreach (
$data[
"resultunits"] as $resu) {
 
   76                        $ru = $this->
object->getUnitRepository()->getUnit($resu[
"unitvalue"]);
 
   78                            $this->
object->addResultUnit($resObj, $ru);
 
   84        $this->
object->setPoints($item->getMetadataEntry(
"points"));
 
   87        $this->
object->setAdditionalContentEditingMode(
 
   90        $this->
object->saveToDb();
 
   92        $questiontext = $this->
object->getQuestion();
 
   95        if (is_array(
$_SESSION[
"import_mob_xhtml"])) {
 
   96            include_once 
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
 
   97            include_once 
"./Services/RTE/classes/class.ilRTE.php";
 
   98            foreach (
$_SESSION[
"import_mob_xhtml"] as $mob) {
 
  100                    include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  103                    include_once 
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
 
  108                $questiontext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $questiontext);
 
  110                foreach ($feedbacksgeneric as $correctness => $material) {
 
  111                    $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $material);
 
  117        foreach ($feedbacksgeneric as $correctness => $material) {
 
  118            $this->
object->feedbackOBJ->importGenericFeedback(
 
  119                $this->object->getId(),
 
  126        $this->
object->setAdditionalContentEditingMode(
 
  130        $this->
object->saveToDb();
 
  131        if (count($item->suggested_solutions)) {
 
  132            foreach ($item->suggested_solutions as $suggested_solution) {
 
  133                $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"], 
true);
 
  135            $this->
object->saveToDb();
 
  138            $q_1_id = $this->
object->getId();
 
  139            $question_id = $this->
object->duplicate(
true);
 
  140            $tst_object->questions[$question_counter++] = $question_id;
 
  141            $import_mapping[$item->getIdent()] = array(
"pool" => $q_1_id, 
"test" => $question_id);
 
  143            $import_mapping[$item->getIdent()] = array(
"pool" => $this->object->getId(), 
"test" => 0);
 
An exception for terminatinating execution or to throw for unit testing.
Class for question imports.
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
addGeneralMetadata(ilQTIItem $item)
getFeedbackGeneric($item)
static _getImportDirectory()
get import directory of lm
static _getImportDirectory()
Get the import directory location of the test.
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...