ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
assFormulaQuestionImport Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for assFormulaQuestionImport:
+ Collaboration diagram for assFormulaQuestionImport:

Public Member Functions

 fromXML (string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping)
 
- Public Member Functions inherited from assQuestionImport
 getQuestionId ()
 
 getFeedbackGeneric ($item)
 
 fromXML (string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping)
 
 importSuggestedSolutions (int $question_id, array $solution_from_import)
 
 QTIMaterialToString (ilQTIMaterial $a_material)
 Reads an QTI material tag and creates a text or XHTML string. More...
 

Additional Inherited Members

- Data Fields inherited from assQuestionImport
 $object
 
- Protected Member Functions inherited from assQuestionImport
 fetchIndexFromFeedbackIdent ($feedbackIdent, $prefix='response_')
 
 getFeedbackAnswerSpecific (ilQTIItem $item, $prefix='response_')
 
 addGeneralMetadata (ilQTIItem $item)
 
 fetchLifecycle (ilQTIItem $item)
 
 processNonAbstractedImageReferences ($text, $sourceNic)
 
 fetchAdditionalContentEditingModeInformation ($qtiItem)
 fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_CONTENT_EDITING_MODE_RTE when no or invalid information is given More...
 
 findSolutionTypeByValue (string $value)
 
 getSuggestedSolutionsRepo ()
 
 deduceThumbSizeFromImportValue (?int $size)
 
- Protected Attributes inherited from assQuestionImport
SuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class for formula question imports

assFormulaQuestionImport is a class for formula question imports

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
Id
class.assFormulaQuestionImport.php 1185 2010-02-02 08:36:26Z hschottm

\

Definition at line 28 of file class.assFormulaQuestionImport.php.

Member Function Documentation

◆ fromXML()

assFormulaQuestionImport::fromXML ( string  $importdirectory,
int  $user_id,
ilQTIItem  $item,
int  $questionpool_id,
?int  $tst_id,
?ilObject $tst_object,
int &  $question_counter,
array  $import_mapping 
)

Definition at line 30 of file class.assFormulaQuestionImport.php.

References $data, ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObject\_saveUsage(), assQuestionImport\addGeneralMetadata(), ilSession\clear(), assQuestionImport\fetchAdditionalContentEditingModeInformation(), ilSession\get(), ilQTIItem\getAuthor(), ilQTIItem\getComment(), assQuestionImport\getFeedbackGeneric(), ilQTIItem\getIdent(), ilQTIItem\getMetadataEntry(), ilQTIItem\getQuestiontext(), ilQTIItem\getTitle(), IL_INST_ID, assQuestionImport\importSuggestedSolutions(), ILIAS\Repository\object(), and assQuestionImport\QTIMaterialToString().

39  : array {
40  // empty session variable for imported xhtml mobs
41  ilSession::clear('import_mob_xhtml');
42 
43  $this->object->setTitle($item->getTitle());
44  $this->object->setComment($item->getComment());
45  $this->object->setAuthor($item->getAuthor());
46  $this->object->setOwner($user_id);
47  $this->object->setQuestion($this->QTIMaterialToString($item->getQuestiontext()));
48  $this->object->setObjId($questionpool_id);
49  if (preg_match_all("/(\\\$v\\d+)/ims", $this->object->getQuestion(), $matches)) {
50  foreach ($matches[1] as $variable) {
51  $data = unserialize($item->getMetadataEntry($variable), ["allowed_classes" => false]);
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);
55  }
56  }
57  if (preg_match_all("/(\\\$r\\d+)/ims", $this->object->getQuestion(), $rmatches)) {
58  foreach ($rmatches[1] as $result) {
59  $data = unserialize($item->getMetadataEntry($result), ["allowed_classes" => false]);
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);
63  } else {
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"]);
65  }
66  if (array_key_exists('resulttype', $data)) {
67  $resObj->setResultType($data["resulttype"]);
68  }
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"]);
73  if (is_object($ru)) {
74  $this->object->addResultUnit($resObj, $ru);
75  }
76  }
77  }
78  }
79  }
80  $this->object->setPoints($item->getMetadataEntry("points"));
81  $this->addGeneralMetadata($item);
82  // additional content editing mode information
83  $this->object->setAdditionalContentEditingMode(
85  );
86  $this->object->saveToDb();
87  // handle the import of media objects in XHTML code
88  $questiontext = $this->object->getQuestion();
89  $feedbacksgeneric = $this->getFeedbackGeneric($item);
90 
91  if (is_array(ilSession::get("import_mob_xhtml"))) {
92  foreach (ilSession::get("import_mob_xhtml") as $mob) {
93  $importfile = $importdirectory . DIRECTORY_SEPARATOR . $mob["uri"];
94  $media_object = ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, false);
95  ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
96  $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
97 
98  foreach ($feedbacksgeneric as $correctness => $material) {
99  $feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
100  }
101  }
102  }
103  $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
104 
105  foreach ($feedbacksgeneric as $correctness => $material) {
106  $this->object->feedbackOBJ->importGenericFeedback(
107  $this->object->getId(),
108  $correctness,
110  );
111  }
112 
113  // additional content editing mode information
114  $this->object->setAdditionalContentEditingMode(
116  );
117  $this->object->saveToDb();
118  $this->importSuggestedSolutions($this->object->getId(), $item->suggested_solutions);
119  if ($tst_id > 0) {
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];
124  } else {
125  $import_mapping[$item->getIdent()] = ["pool" => $this->object->getId(), "test" => 0];
126  }
127  return $import_mapping;
128  }
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)
const IL_INST_ID
Definition: constants.php:40
QTIMaterialToString(ilQTIMaterial $a_material)
Reads an QTI material tag and creates a text or XHTML string.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getMetadataEntry(string $a_label)
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
static _saveUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Save usage of mob within another container (e.g.
importSuggestedSolutions(int $question_id, array $solution_from_import)
static _saveTempFileAsMediaObject(string $name, string $tmp_name, bool $upload=true)
static clear(string $a_var)
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: