19declare(strict_types=1);
102 $this->ident = $a_ident;
112 $this->title = $a_title;
122 if (preg_match(
"/(.*?)\=(.*)/", $a_comment, $matches)) {
124 switch ($matches[1]) {
125 case "ILIAS Version":
126 $this->ilias_version = $matches[2];
129 $this->questiontype = $matches[2];
132 $this->author = $matches[2] ??
'';
146 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $a_duration, $matches)) {
165 $this->questiontext = $a_questiontext;
175 $this->resprocessing[] = $a_resprocessing;
180 $this->itemfeedback[] = $a_itemfeedback;
185 $this->maxattempts = $a_maxattempts;
195 $this->label = $a_label;
205 $this->xmllang = $a_xmllang;
215 $this->presentation = $a_presentation;
225 $this->questiontype = $a_questiontype;
238 $this->presentationitem[] = $a_presentationitem;
243 if (in_array($this->questiontype, self::VALID_QUESTION_TYPES)) {
247 switch ($this->questiontype) {
248 case "ORDERING QUESTION":
250 case "KPRIM CHOICE QUESTION":
252 case "LONG MENU QUESTION":
254 case "SINGLE CHOICE QUESTION":
256 case "MULTIPLE CHOICE QUESTION":
258 case "MATCHING QUESTION":
260 case "CLOZE QUESTION":
262 case "IMAGE MAP QUESTION":
264 case "TEXT QUESTION":
266 case "NUMERIC QUESTION":
268 case "TEXTSUBSET QUESTION":
271 if (!$this->presentation) {
274 foreach ($this->presentation->order as $entry) {
275 if (
'response' !== $entry[
"type"]) {
278 $result = $this->
typeFromResponse($this->presentation->response[$entry[
"index"]]);
279 if ($result !==
null) {
283 if ($this->questiontype ===
'') {
292 $this->unit_categories[
$label] = $unit_category;
308 $formula_question_unit_category->setCategory($key);
309 $formula_question_unit_category->setId((
int) $unit_category[
'id']);
310 $formula_question_unit_category->setQuestionFi((
int) $unit_category[
'question_fi']);
319 $this->units[
$label] = $unit;
333 foreach ($this->
getUnits() as $key => $unit) {
335 $formula_question_unit->setUnit($key);
336 $formula_question_unit->setId((
int) $unit[
'id']);
337 $formula_question_unit->setSequence((
int) $unit[
'sequence']);
338 $formula_question_unit->setFactor((
float) $unit[
'factor']);
339 $formula_question_unit->setBaseUnit((
int) $unit[
'base_unit']);
340 $formula_question_unit->setBaseunitTitle($unit[
'base_unit_title']);
341 $formula_question_unit->setCategory((
int) $unit[
'category']);
342 $units[$key] = $formula_question_unit;
350 $this->author = $a_author;
380 $this->suggested_solutions[] = [
"solution" => $a_solution,
"gap_index" => $a_gap_index];
388 $this->itemmetadata[] = $a_metadata;
398 foreach ($this->itemmetadata as $metadata) {
399 if ($metadata[
"label"] === $a_label) {
400 return $metadata[
"entry"];
425 default:
return null;
const QT_MULTIPLE_CHOICE_MR
addMetadata(array $a_metadata)
setPresentation(ilQTIPresentation $a_presentation)
const QT_MULTIPLE_CHOICE_SR
setAuthor(string $a_author)
const VALID_QUESTION_TYPES
setQuestiontext(ilQTIMaterial $a_questiontext)
setIdent(string $a_ident)
setQuestiontype(string $a_questiontype)
setComment(string $a_comment)
setLabel(string $a_label)
ilQTIMaterial $questiontext
array $suggested_solutions
addItemfeedback(ilQTIItemfeedback $a_itemfeedback)
const QT_ORDERING_HORIZONTAL
setTitle(string $a_title)
string $iliasSourceVersion
addResprocessing(ilQTIResprocessing $a_resprocessing)
addUnitCategory(string $label, array $unit_category)
getMetadataEntry(string $a_label)
setXmllang(string $a_xmllang)
addUnit(string $label, array $unit)
setDuration(string $a_duration)
setIliasSourceVersion(?string $iliasSourceVersion)
addPresentationitem($a_presentationitem)
addSuggestedSolution(ilQTIMattext $a_solution, int $a_gap_index)
ilQTIPresentation $presentation
setMaxattempts(string $a_maxattempts)
typeFromResponse(ilQTIResponse $response)
setIliasSourceNic(?string $iliasSourceNic)
const R_CARDINALITY_MULTIPLE
const R_CARDINALITY_SINGLE
const R_CARDINALITY_ORDERED