50 $this->
object = $a_object;
59 return (
int) $this->
object->getId();
64 $feedbacksgeneric = [];
65 foreach ($item->resprocessing as $resprocessing) {
66 foreach ($resprocessing->respcondition as $respcondition) {
67 foreach ($respcondition->displayfeedback as $feedbackpointer) {
68 if (strlen($feedbackpointer->getLinkrefid())) {
69 foreach ($item->itemfeedback as $ifb) {
70 if (strcmp($ifb->getIdent(),
"response_allcorrect") == 0) {
72 if (count($ifb->material)) {
73 foreach ($ifb->material as $material) {
74 $feedbacksgeneric[1] = $material;
77 if ((count($ifb->flow_mat) > 0)) {
78 foreach ($ifb->flow_mat as $fmat) {
79 if (count($fmat->material)) {
80 foreach ($fmat->material as $material) {
81 $feedbacksgeneric[1] = $material;
86 } elseif (strcmp($ifb->getIdent(),
"response_onenotcorrect") == 0) {
88 if (count($ifb->material)) {
89 foreach ($ifb->material as $material) {
90 $feedbacksgeneric[0] = $material;
93 if ((count($ifb->flow_mat) > 0)) {
94 foreach ($ifb->flow_mat as $fmat) {
95 if (count($fmat->material)) {
96 foreach ($fmat->material as $material) {
97 $feedbacksgeneric[0] = $material;
109 foreach ($feedbacksgeneric as $correctness => $material) {
111 $feedbacksgeneric[$correctness] = $m;
113 return $feedbacksgeneric;
123 return (
int) str_replace($prefix,
'', $feedbackIdent);
135 foreach ($item->itemfeedback as $ifb) {
136 if ($ifb->getIdent() ==
'response_allcorrect' || $ifb->getIdent() ==
'response_onenotcorrect') {
140 if ($ifb->getIdent() == $prefix .
'allcorrect' || $ifb->getIdent() == $prefix .
'onenotcorrect') {
144 if (substr($ifb->getIdent(), 0, strlen($prefix)) != $prefix) {
148 $ident = $ifb->getIdent();
152 if (count($ifb->material)) {
153 foreach ($ifb->material as $material) {
154 $feedbacks[$ident] = $material;
158 if ((count($ifb->flow_mat) > 0)) {
159 foreach ($ifb->flow_mat as $fmat) {
160 if (count($fmat->material)) {
161 foreach ($fmat->material as $material) {
162 $feedbacks[$ident] = $material;
169 foreach ($feedbacks as $ident => $material) {
171 $feedbacks[$ident] = $m;
190 public function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, $import_mapping): array
225 $lomLifecycle->getMappedIliasLifecycleIdentifer()
253 $reg =
'/<img.*src=".*\\/mm_(\\d+)\\/(.*?)".*>/m';
256 if (preg_match_all($reg, $text, $matches)) {
258 for ($i = 0, $max = count($matches[1]); $i < $max; $i++) {
259 $mobSrcId = $matches[1][$i];
260 $mobSrcName = $matches[2][$i];
261 $mobSrcLabel =
'il_' . $sourceNic .
'_mob_' . $mobSrcId;
269 "mob" => $mobSrcLabel,
"uri" =>
'objects/' . $mobSrcLabel .
'/' . $mobSrcName
288 $additionalContentEditingMode = $qtiItem->getMetadataEntry(
'additional_cont_edit_mode');
290 if (!$this->
object->isValidAdditionalContentEditingMode($additionalContentEditingMode ??
'')) {
294 return $additionalContentEditingMode;
299 array $solution_from_import
301 if (!$solution_from_import === []
302 || !isset($solution_from_import[0][
'solution'])) {
306 $solution_item = $solution_from_import[0][
'solution'];
307 $content = $solution_item->getContent();
308 if ($solution_item->getTexttype() ===
'application/json') {
309 $content = json_decode($content,
true);
310 if (!isset($content[
'type']) || !isset($content[
'value'])) {
313 $type = $content[
'type'];
316 if ($type === null) {
322 $solution_object = $repo->create($question_id, $type);
324 if ($type !== assQuestionSuggestedSolution::TYPE_FILE) {
325 $link = is_string($content) ? $content : $content[
'value'];
326 $adapted_link = $this->
object->resolveInternalLink($link);
327 if ($adapted_link ===
'') {
330 $solution_object = $solution_object
331 ->withInternalLink($adapted_link)
332 ->withImportId($link);
334 if (!isset($content[
'title']) || !isset($content[
'filename'])) {
337 $path = str_replace(
CLIENT_WEB_DIR . DIRECTORY_SEPARATOR,
'', $this->
object->getSuggestedSolutionPath() . $content[
'filename']);
339 $solution_object = $solution_object->withTitle($content[
'title'])
340 ->withFilename($content[
'filename'])
341 ->withSize((
int) $this->
filesystem->getSize(
$path, DataSize::Byte)->inBytes())
344 $repo->update([$solution_object]);
349 foreach (array_keys(assQuestionSuggestedSolution::TYPES) as $type) {
350 $search_type =
'_' . $type .
'_';
351 if (strpos($value, $search_type) !==
false) {
362 if (is_null($this->suggestedsolution_repo)) {
364 $this->suggestedsolution_repo =
$dic[
'question.repo.suggestedsolutions'];
379 if (strcmp($material[
"type"],
"mattext") === 0) {
380 $result .= $material[
"material"]->getContent();
382 if (strcmp($material[
"type"],
"matimage") === 0) {
383 $matimage = $material[
"material"];
384 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches)) {
389 $mobs[] = [
"mob" => $matimage->getLabel(),
390 "uri" => $matimage->getUri()
401 if ($size === null) {
402 return $this->
object->getThumbSize();
405 if ($size < $this->
object->getMinimumThumbSize()) {
406 return $this->
object->getMinimumThumbSize();
409 if ($size > $this->
object->getMaximumThumbSize()) {
410 return $this->
object->getMaximumThumbSize();
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)
getFeedbackAnswerSpecific(ilQTIItem $item, $prefix='response_')
static getInstance($identifier)
getSuggestedSolutionsRepo()
deduceThumbSizeFromImportValue(?int $size)
addGeneralMetadata(ilQTIItem $item)
QTIMaterialToString(ilQTIMaterial $a_material)
Reads an QTI material tag and creates a text or XHTML string.
getMetadataEntry(string $a_label)
processNonAbstractedImageReferences($text, $sourceNic)
fetchAdditionalContentEditingModeInformation($qtiItem)
fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_...
getQplImportArchivDirectory()
returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir) ...
getMaterial(int $a_index)
fetchLifecycle(ilQTIItem $item)
fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, $import_mapping)
Creates a question from a QTI file.
Repository for suggested solutions.
getFeedbackGeneric($item)
importSuggestedSolutions(int $question_id, array $solution_from_import)
assQuestionSuggestedSolutionsDatabaseRepository $suggestedsolution_repo
findSolutionTypeByValue(string $value)
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
getTstImportArchivDirectory()
returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir) ...
static _getImportDirectory()
get import directory of lm
Class for question imports.
fetchIndexFromFeedbackIdent($feedbackIdent, $prefix='response_')
static set(string $a_var, $a_val)
Set a value.
static getDraftInstance()
static _getImportDirectory()
Get the import directory location of the test.