4 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class.assQuestionImport.php";
30 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
36 $presentation = $item->getPresentation();
39 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
41 $feedbacksgeneric =
array();
43 $this->
object->setTitle($item->getTitle());
44 $this->
object->setComment($item->getComment());
45 $this->
object->setAuthor($item->getAuthor());
46 $this->
object->setOwner($ilUser->getId());
47 $this->
object->setQuestion($this->
object->QTIMaterialToString($item->getQuestiontext()));
48 $this->
object->setObjId($questionpool_id);
50 if (preg_match_all(
"/(\\\$v\\d+)/ims", $this->
object->getQuestion(), $matches))
52 foreach ($matches[1] as $variable)
54 $data = unserialize($item->getMetadataEntry($variable));
55 $unit = $this->
object->getUnitRepository()->getUnit(
$data[
"unitvalue"]);
56 require_once
'Modules/TestQuestionPool/classes/class.assFormulaQuestionVariable.php';
58 $this->
object->addVariable($varObj);
61 if (preg_match_all(
"/(\\\$r\\d+)/ims", $this->
object->getQuestion(), $rmatches))
63 foreach ($rmatches[1] as
$result)
65 $data = unserialize($item->getMetadataEntry($result));
66 $unit = $this->
object->getUnitRepository()->getUnit(
$data[
"unitvalue"]);
67 require_once
'Modules/TestQuestionPool/classes/class.assFormulaQuestionResult.php';
68 if (!is_array(
$data[
"rating"]))
74 $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"]);
76 $this->
object->addResult($resObj);
77 if (is_array(
$data[
"resultunits"]))
79 foreach (
$data[
"resultunits"] as $resu)
81 $ru = $this->
object->getUnitRepository()->getUnit($resu[
"unitvalue"]);
84 $this->
object->addResultUnit($resObj, $ru);
90 $this->
object->setPoints($item->getMetadataEntry(
"points"));
93 $this->
object->setAdditionalContentEditingMode(
96 $this->
object->saveToDb();
98 $questiontext = $this->
object->getQuestion();
101 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
103 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
104 include_once
"./Services/RTE/classes/class.ilRTE.php";
105 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
109 include_once
"./Modules/Test/classes/class.ilObjTest.php";
114 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
119 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
121 foreach ($feedbacksgeneric as $correctness => $material)
123 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
129 foreach ($feedbacksgeneric as $correctness => $material)
131 $this->
object->feedbackOBJ->importGenericFeedback(
137 $this->
object->setAdditionalContentEditingMode(
141 $this->
object->saveToDb();
142 if (count($item->suggested_solutions))
144 foreach ($item->suggested_solutions as $suggested_solution)
146 $this->
object->setSuggestedSolution($suggested_solution[
"solution"]->getContent(), $suggested_solution[
"gap_index"],
true);
148 $this->
object->saveToDb();
152 $q_1_id = $this->
object->getId();
153 $question_id = $this->
object->duplicate(
true);
154 $tst_object->questions[$question_counter++] = $question_id;
155 $import_mapping[$item->getIdent()] =
array(
"pool" => $q_1_id,
"test" => $question_id);
159 $import_mapping[$item->getIdent()] =
array(
"pool" => $this->
object->getId(),
"test" => 0);
addGeneralMetadata(ilQTIItem $item)
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
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...
getFeedbackGeneric($item)
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
static _getImportDirectory()
get import directory of lm
Class for question imports.
static _getImportDirectory()
Get the import directory location of the test.