31 string $importdirectory,
37 int &$question_counter,
43 $this->
object->setTitle($item->
getTitle());
44 $this->
object->setComment($item->
getComment());
45 $this->
object->setAuthor($item->
getAuthor());
46 $this->
object->setOwner($user_id);
48 $this->
object->setObjId($questionpool_id);
49 if (preg_match_all(
"/(\\\$v\\d+)/ims", $this->
object->getQuestion(), $matches)) {
50 foreach ($matches[1] as $variable) {
52 $unit = $this->
object->getUnitRepository()->getUnit((
int)
$data[
"unitvalue"]);
53 $varObj =
new assFormulaQuestionVariable($variable, $data[
"rangemin"], $data[
"rangemax"], $unit, $data[
"precision"], $data[
"intprecision"]);
54 $this->
object->addVariable($varObj);
57 if (preg_match_all(
"/(\\\$r\\d+)/ims", $this->
object->getQuestion(), $rmatches)) {
58 foreach ($rmatches[1] as $result) {
60 $unit = $this->
object->getUnitRepository()->getUnit((
int)
$data[
"unitvalue"]);
61 if (!is_array($data[
"rating"])) {
62 $resObj =
new assFormulaQuestionResult($result, $data[
"rangemin"], $data[
"rangemax"], $data[
"tolerance"], $unit, $data[
"formula"], $data[
"points"], $data[
"precision"],
true);
64 $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"]);
66 if (array_key_exists(
'resulttype', $data)) {
67 $resObj->setResultType($data[
"resulttype"]);
69 $this->
object->addResult($resObj);
70 if (is_array($data[
"resultunits"])) {
71 foreach ($data[
"resultunits"] as $resu) {
72 $ru = $this->
object->getUnitRepository()->getUnit($resu[
"unitvalue"]);
74 $this->
object->addResultUnit($resObj, $ru);
83 $this->
object->setAdditionalContentEditingMode(
86 $this->
object->saveToDb();
88 $questiontext = $this->
object->getQuestion();
93 $importfile = $importdirectory . DIRECTORY_SEPARATOR . $mob[
"uri"];
96 $questiontext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $questiontext);
98 foreach ($feedbacksgeneric as $correctness => $material) {
99 $feedbacksgeneric[$correctness] = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $material);
105 foreach ($feedbacksgeneric as $correctness => $material) {
106 $this->
object->feedbackOBJ->importGenericFeedback(
114 $this->
object->setAdditionalContentEditingMode(
117 $this->
object->saveToDb();
120 $q_1_id = $this->
object->getId();
121 $question_id = $this->
object->duplicate();
122 $tst_object->questions[$question_counter++] = $question_id;
123 $import_mapping[$item->
getIdent()] = [
"pool" => $q_1_id,
"test" => $question_id];
125 $import_mapping[$item->
getIdent()] = [
"pool" => $this->
object->getId(),
"test" => 0];
127 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)
addGeneralMetadata(ilQTIItem $item)
QTIMaterialToString(ilQTIMaterial $a_material)
Reads an QTI material tag and creates a text or XHTML string.
getMetadataEntry(string $a_label)
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
getFeedbackGeneric($item)
importSuggestedSolutions(int $question_id, array $solution_from_import)
Class for question imports.
static clear(string $a_var)