ILIAS  release_8 Revision v8.24
class.assTextSubset.php
Go to the documentation of this file.
1<?php
2
19require_once './Modules/Test/classes/inc.AssessmentConstants.php';
20
37{
43 public $answers;
44
51
58
70 public function __construct(
71 $title = "",
72 $comment = "",
73 $author = "",
74 $owner = -1,
75 $question = ""
76 ) {
78 $this->answers = array();
79 $this->correctanswers = 0;
80 }
81
88 public function isComplete(): bool
89 {
90 if (
91 strlen($this->title)
92 && $this->author
93 && $this->question &&
94 count($this->answers) >= $this->correctanswers
95 && $this->getMaximumPoints() > 0
96 ) {
97 return true;
98 }
99 return false;
100 }
101
108 public function saveToDb($original_id = ""): void
109 {
110 if ($original_id == "") {
111 $this->saveQuestionDataToDb();
112 } else {
114 }
115
118
119 parent::saveToDb();
120 }
121
129 public function loadFromDb($question_id): void
130 {
131 global $DIC;
132 $ilDB = $DIC['ilDB'];
133
134 $result = $ilDB->queryF(
135 "SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s",
136 array("integer"),
137 array($question_id)
138 );
139 if ($result->numRows() == 1) {
140 $data = $ilDB->fetchAssoc($result);
141 $this->setId($question_id);
142 $this->setObjId($data["obj_fi"]);
143 $this->setNrOfTries($data['nr_of_tries']);
144 $this->setTitle((string) $data["title"]);
145 $this->setComment((string) $data["description"]);
146 $this->setOriginalId($data["original_id"]);
147 $this->setAuthor($data["author"]);
148 $this->setPoints($data["points"]);
149 $this->setOwner($data["owner"]);
150 include_once("./Services/RTE/classes/class.ilRTE.php");
151 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
152 $this->setCorrectAnswers((int) $data["correctanswers"]);
153 $this->setTextRating($data["textgap_rating"]);
154
155 try {
156 $this->setLifecycle(ilAssQuestionLifecycle::getInstance($data['lifecycle']));
159 }
160
161 try {
162 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
164 }
165 }
166
167
168 $result = $ilDB->queryF(
169 "SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
170 array('integer'),
171 array($question_id)
172 );
173 include_once "./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
174 if ($result->numRows() > 0) {
175 while ($data = $ilDB->fetchAssoc($result)) {
176 $this->answers[] = new ASS_AnswerBinaryStateImage($data["answertext"], $data["points"], $data["aorder"]);
177 }
178 }
179
180 parent::loadFromDb($question_id);
181 }
182
188 public function addAnswer($answertext, $points, $order): void
189 {
190 include_once "./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
191 if (array_key_exists($order, $this->answers)) {
192 // insert answer
193 $answer = new ASS_AnswerBinaryStateImage($answertext, $points, $order);
194 $newchoices = array();
195 for ($i = 0; $i < $order; $i++) {
196 $newchoices[] = $this->answers[$i];
197 }
198 $newchoices[] = $answer;
199 for ($i = $order, $iMax = count($this->answers); $i < $iMax; $i++) {
200 $changed = $this->answers[$i];
201 $changed->setOrder($i + 1);
202 $newchoices[] = $changed;
203 }
204 $this->answers = $newchoices;
205 } else {
206 // add answer
207 $this->answers[] = new ASS_AnswerBinaryStateImage($answertext, $points, count($this->answers));
208 }
209 }
210
216 public function duplicate(bool $for_test = true, string $title = "", string $author = "", string $owner = "", $testObjId = null): int
217 {
218 if ($this->id <= 0) {
219 // The question has not been saved. It cannot be duplicated
220 return -1;
221 }
222 // duplicate the question in database
223 $this_id = $this->getId();
224 $thisObjId = $this->getObjId();
225
226 $clone = $this;
227 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
229 $clone->id = -1;
230
231 if ((int) $testObjId > 0) {
232 $clone->setObjId($testObjId);
233 }
234
235 if ($title) {
236 $clone->setTitle($title);
237 }
238
239 if ($author) {
240 $clone->setAuthor($author);
241 }
242 if ($owner) {
243 $clone->setOwner($owner);
244 }
245
246 if ($for_test) {
247 $clone->saveToDb($original_id);
248 } else {
249 $clone->saveToDb();
250 }
251
252 // copy question page content
253 $clone->copyPageOfQuestion($this_id);
254 // copy XHTML media objects
255 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
256
257 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
258
259 return $clone->id;
260 }
261
267 public function copyObject($target_questionpool_id, $title = ""): int
268 {
269 if ($this->getId() <= 0) {
270 throw new RuntimeException('The question has not been saved. It cannot be duplicated');
271 }
272 // duplicate the question in database
273 $clone = $this;
274 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
276 $clone->id = -1;
277 $source_questionpool_id = $this->getObjId();
278 $clone->setObjId($target_questionpool_id);
279 if ($title) {
280 $clone->setTitle($title);
281 }
282 $clone->saveToDb();
283 // copy question page content
284 $clone->copyPageOfQuestion($original_id);
285 // copy XHTML media objects
286 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
287
288 $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
289
290 return $clone->id;
291 }
292
293 public function createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle = ""): int
294 {
295 if ($this->getId() <= 0) {
296 throw new RuntimeException('The question has not been saved. It cannot be duplicated');
297 }
298
299 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
300
301 $sourceQuestionId = $this->id;
302 $sourceParentId = $this->getObjId();
303
304 // duplicate the question in database
305 $clone = $this;
306 $clone->id = -1;
307
308 $clone->setObjId($targetParentId);
309
310 if ($targetQuestionTitle) {
311 $clone->setTitle($targetQuestionTitle);
312 }
313
314 $clone->saveToDb();
315 // copy question page content
316 $clone->copyPageOfQuestion($sourceQuestionId);
317 // copy XHTML media objects
318 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
319
320 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
321
322 return $clone->id;
323 }
324
332 public function getAnswerCount(): int
333 {
334 return count($this->answers);
335 }
336
346 public function getAnswer($index = 0): ?object
347 {
348 if ($index < 0) {
349 return null;
350 }
351 if (count($this->answers) < 1) {
352 return null;
353 }
354 if ($index >= count($this->answers)) {
355 return null;
356 }
357
358 return $this->answers[$index];
359 }
360
369 public function deleteAnswer($index = 0): void
370 {
371 if ($index < 0) {
372 return;
373 }
374 if (count($this->answers) < 1) {
375 return;
376 }
377 if ($index >= count($this->answers)) {
378 return;
379 }
380 unset($this->answers[$index]);
381 $this->answers = array_values($this->answers);
382 for ($i = 0, $iMax = count($this->answers); $i < $iMax; $i++) {
383 if ($this->answers[$i]->getOrder() > $index) {
384 $this->answers[$i]->setOrder($i);
385 }
386 }
387 }
388
395 public function flushAnswers(): void
396 {
397 $this->answers = array();
398 }
399
406 public function getMaximumPoints(): float
407 {
408 $points = array();
409 foreach ($this->answers as $answer) {
410 if ($answer->getPoints() > 0) {
411 $points[] = $answer->getPoints();
412 }
413 }
414 rsort($points, SORT_NUMERIC);
415 $maxpoints = 0;
416 for ($counter = 0; $counter < $this->getCorrectAnswers(); $counter++) {
417 if (isset($points[$counter])) {
418 $maxpoints += $points[$counter];
419 }
420 }
421 return $maxpoints;
422 }
423
430 public function &getAvailableAnswers(): array
431 {
432 $available_answers = array();
433 foreach ($this->answers as $answer) {
434 $available_answers[] = $answer->getAnswertext();
435 }
436 return $available_answers;
437 }
438
449 public function isAnswerCorrect($answers, $answer)
450 {
451 include_once "./Services/Utilities/classes/class.ilStr.php";
452 global $DIC;
453 $refinery = $DIC->refinery();
454 $textrating = $this->getTextRating();
455
456 foreach ($answers as $key => $value) {
457 if ($this->answers[$key]->getPoints() <= 0) {
458 continue;
459 }
460 $value = html_entity_decode($value); #SB
461 switch ($textrating) {
463 if (strcmp(ilStr::strToLower($value), ilStr::strToLower($answer)) == 0) { #SB
464 return $key;
465 }
466 break;
468 if (strcmp($value, $answer) == 0) {
469 return $key;
470 }
471 break;
473 $transformation = $refinery->string()->levenshtein()->standard($answer, 1);
474 break;
476 $transformation = $refinery->string()->levenshtein()->standard($answer, 2);
477 break;
479 $transformation = $refinery->string()->levenshtein()->standard($answer, 3);
480 break;
482 $transformation = $refinery->string()->levenshtein()->standard($answer, 4);
483 break;
485 $transformation = $refinery->string()->levenshtein()->standard($answer, 5);
486 break;
487 }
488
489 // run answers against Levenshtein2 methods
490 if (isset($transformation) && $transformation->transform($value) >= 0) {
491 return $key;
492 }
493 }
494 return false;
495 }
496
504 public function getTextRating(): string
505 {
506 return $this->text_rating;
507 }
508
516 public function setTextRating($a_text_rating): void
517 {
518 switch ($a_text_rating) {
526 $this->text_rating = $a_text_rating;
527 break;
528 default:
529 $this->text_rating = TEXTGAP_RATING_CASEINSENSITIVE;
530 break;
531 }
532 }
533
544 public function calculateReachedPoints($active_id, $pass = null, $authorizedSolution = true, $returndetails = false)
545 {
546 if ($returndetails) {
547 throw new ilTestException('return details not implemented for ' . __METHOD__);
548 }
549
550 global $DIC;
551 $ilDB = $DIC['ilDB'];
552
553
554 if (is_null($pass)) {
555 $pass = $this->getSolutionMaxPass($active_id);
556 }
557 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
558
559 $enteredTexts = array();
560 while ($data = $ilDB->fetchAssoc($result)) {
561 $enteredTexts[] = $data["value1"];
562 }
563
564 return $this->calculateReachedPointsForSolution($enteredTexts);
565 }
566
573 public function setCorrectAnswers(int $a_correct_answers): void
574 {
575 $this->correctanswers = $a_correct_answers;
576 }
577
584 public function getCorrectAnswers(): int
585 {
587 }
588
597 public function saveWorkingData($active_id, $pass = null, $authorized = true): bool
598 {
599 global $DIC;
600 $ilDB = $DIC['ilDB'];
601 $ilUser = $DIC['ilUser'];
602
603 if (is_null($pass)) {
604 include_once "./Modules/Test/classes/class.ilObjTest.php";
605 $pass = ilObjTest::_getPass($active_id);
606 }
607
608 $entered_values = 0;
609 $solutionSubmit = $this->getSolutionSubmit();
610
611 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $solutionSubmit, $active_id, $pass, $authorized) {
612 $this->removeCurrentSolution($active_id, $pass, $authorized);
613
614 foreach ($solutionSubmit as $value) {
615 if (strlen($value)) {
616 $this->saveCurrentSolution($active_id, $pass, $value, null, $authorized);
617 $entered_values++;
618 }
619 }
620 });
621
622 if ($entered_values) {
624 assQuestion::logAction($this->lng->txtlng(
625 "assessment",
626 "log_user_entered_values",
628 ), $active_id, $this->getId());
629 }
631 assQuestion::logAction($this->lng->txtlng(
632 "assessment",
633 "log_user_not_entered_values",
635 ), $active_id, $this->getId());
636 }
637
638 return true;
639 }
640
641 public function saveAdditionalQuestionDataToDb()
642 {
644 global $DIC;
645 $ilDB = $DIC['ilDB'];
646
647 // save additional data
648 $ilDB->manipulateF(
649 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
650 array( "integer" ),
651 array( $this->getId() )
652 );
653
654 $ilDB->manipulateF(
655 "INSERT INTO " . $this->getAdditionalTableName(
656 ) . " (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
657 array( "integer", "text", "integer" ),
658 array(
659 $this->getId(),
660 $this->getTextRating(),
661 $this->getCorrectAnswers()
662 )
663 );
664 }
665
666 public function saveAnswerSpecificDataToDb()
667 {
669 global $DIC;
670 $ilDB = $DIC['ilDB'];
671 $ilDB->manipulateF(
672 "DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
673 array( 'integer' ),
674 array( $this->getId() )
675 );
676
677 foreach ($this->answers as $key => $value) {
678 $answer_obj = $this->answers[$key];
679 $next_id = $ilDB->nextId('qpl_a_textsubset');
680 $ilDB->manipulateF(
681 "INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
682 array( 'integer', 'integer', 'text', 'float', 'integer', 'integer' ),
683 array(
684 $next_id,
685 $this->getId(),
686 $answer_obj->getAnswertext(),
687 $answer_obj->getPoints(),
688 $answer_obj->getOrder(),
689 time()
690 )
691 );
692 }
693 }
694
701 public function getQuestionType(): string
702 {
703 return "assTextSubset";
704 }
705
710 public function &joinAnswers(): array
711 {
712 $join = [];
713 foreach ($this->answers as $answer) {
714 $key = $answer->getPoints() . '';
715
716 if (!isset($join[$key]) || !is_array($join[$key])) {
717 $join[$key] = [];
718 }
719
720 $join[$key][] = $answer->getAnswertext();
721 }
722
723 return $join;
724 }
725
732 public function getMaxTextboxWidth(): int
733 {
734 $maxwidth = 0;
735 foreach ($this->answers as $answer) {
736 $len = strlen($answer->getAnswertext());
737 if ($len > $maxwidth) {
738 $maxwidth = $len;
739 }
740 }
741 return $maxwidth + 3;
742 }
743
750 public function getAdditionalTableName(): string
751 {
752 return "qpl_qst_textsubset";
753 }
754
761 public function getAnswerTableName(): string
762 {
763 return "qpl_a_textsubset";
764 }
765
770 public function getRTETextWithMediaObjects(): string
771 {
772 return parent::getRTETextWithMediaObjects();
773 }
774
778 public function setExportDetailsXLS(ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass): int
779 {
780 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
781
782 $solutions = $this->getSolutionValues($active_id, $pass);
783
784 $i = 1;
785 foreach ($solutions as $solution) {
786 $worksheet->setCell($startrow + $i, 2, $solution["value1"]);
787 $i++;
788 }
789
790 return $startrow + $i + 1;
791 }
792
793 public function getAnswers(): array
794 {
795 return $this->answers;
796 }
797
801 public function toJSON(): string
802 {
803 include_once("./Services/RTE/classes/class.ilRTE.php");
804 $result = array();
805 $result['id'] = $this->getId();
806 $result['type'] = (string) $this->getQuestionType();
807 $result['title'] = $this->getTitleForHTMLOutput();
808 $result['question'] = $this->formatSAQuestion($this->getQuestion());
809 $result['nr_of_tries'] = $this->getNrOfTries();
810 $result['matching_method'] = $this->getTextRating();
811 $result['feedback'] = array(
812 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
813 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
814 );
815
816 $answers = array();
817 foreach ($this->getAnswers() as $key => $answer_obj) {
818 $answers[] = array(
819 "answertext" => (string) $answer_obj->getAnswertext(),
820 "points" => (float) $answer_obj->getPoints(),
821 "order" => (int) $answer_obj->getOrder()
822 );
823 }
824 $result['correct_answers'] = $answers;
825
826 $answers = array();
827 for ($loop = 1; $loop <= $this->getCorrectAnswers(); $loop++) {
828 $answers[] = array(
829 "answernr" => $loop
830 );
831 }
832 $result['answers'] = $answers;
833
834 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
835 $result['mobs'] = $mobs;
836
837 return json_encode($result);
838 }
839
843 protected function getSolutionSubmit(): array
844 {
845 $purifier = $this->getHtmlUserSolutionPurifier();
846 $post = $this->dic->http()->wrapper()->post();
847
848 $solutionSubmit = [];
849 foreach ($this->getAnswers() as $index => $a) {
850 if ($post->has("TEXTSUBSET_$index")) {
851 $value = $post->retrieve(
852 "TEXTSUBSET_$index",
853 $this->dic->refinery()->kindlyTo()->string()
854 );
855 if ($value) {
856 $value = $this->extendedTrim($value);
857 $value = $purifier->purify($value);
858 $solutionSubmit[] = $value;
859 }
860 }
861 }
862
863 return $solutionSubmit;
864 }
865
869 protected function calculateReachedPointsForSolution($enteredTexts): float
870 {
871 $enteredTexts ??= [];
872 $available_answers = $this->getAvailableAnswers();
873 $points = 0;
874 foreach ($enteredTexts as $enteredtext) {
875 $index = $this->isAnswerCorrect($available_answers, html_entity_decode($enteredtext));
876 if ($index !== false) {
877 unset($available_answers[$index]);
878 $points += $this->answers[$index]->getPoints();
879 }
880 }
881 return $points;
882 }
883
892 public function getOperators($expression): array
893 {
895 }
896
901 public function getExpressionTypes(): array
902 {
903 return array(
908 );
909 }
910
919 public function getUserQuestionResult($active_id, $pass): ilUserQuestionResult
920 {
922 global $DIC;
923 $ilDB = $DIC['ilDB'];
924 $result = new ilUserQuestionResult($this, $active_id, $pass);
925
926 $maxStep = $this->lookupMaxStep($active_id, $pass);
927
928 if ($maxStep !== null) {
929 $data = $ilDB->queryF(
930 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s ORDER BY solution_id",
931 array("integer", "integer", "integer","integer"),
932 array($active_id, $pass, $this->getId(), $maxStep)
933 );
934 } else {
935 $data = $ilDB->queryF(
936 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s ORDER BY solution_id",
937 array("integer", "integer", "integer"),
938 array($active_id, $pass, $this->getId())
939 );
940 }
941
942 for ($index = 1; $index <= $ilDB->numRows($data); ++$index) {
943 $row = $ilDB->fetchAssoc($data);
944 $result->addKeyValue($index, $row["value1"]);
945 }
946
947 $points = $this->calculateReachedPoints($active_id, $pass);
948 $max_points = $this->getMaximumPoints();
949
950 $result->setReachedPercentage(($points / $max_points) * 100);
951
952 return $result;
953 }
954
961 public function getAvailableAnswerOptions($index = null)
962 {
963 if ($index !== null) {
964 return $this->getAnswer($index);
965 } else {
966 return $this->getAnswers();
967 }
968 }
969
970 public function isAddableAnswerOptionValue(int $qIndex, string $answerOptionValue): bool
971 {
972 $found = false;
973
974 foreach ($this->getAnswers() as $item) {
975 if ($answerOptionValue !== $item->getAnswerText()) {
976 continue;
977 }
978
979 $found = true;
980 break;
981 }
982
983 return !$found;
984 }
985
986 public function addAnswerOptionValue(int $qIndex, string $answerOptionValue, float $points): void
987 {
988 $this->addAnswer($answerOptionValue, $points, $qIndex);
989 }
990}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Abstract basic class which is to be extended by the concrete assessment question type classes.
float $points
The maximum available points for the question.
setOriginalId(?int $original_id)
string $question
The question text.
static logAction(string $logtext, int $active_id, int $question_id)
setId(int $id=-1)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
static extendedTrim(string $value)
Trim non-printable characters from the beginning and end of a string.
ILIAS Refinery Factory $refinery
setQuestion(string $question="")
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
static _getOriginalId(int $question_id)
saveQuestionDataToDb(int $original_id=-1)
setAuthor(string $author="")
setComment(string $comment="")
setObjId(int $obj_id=0)
getSolutionMaxPass(int $active_id)
setOwner(int $owner=-1)
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
lookupMaxStep(int $active_id, int $pass)
setPoints(float $points)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getExpressionTypes()
Get all available expression types for a specific question.
getMaxTextboxWidth()
Returns the maximum width needed for the answer textboxes.
setCorrectAnswers(int $a_correct_answers)
Sets the number of correct answers needed to solve the question.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
isAnswerCorrect($answers, $answer)
Returns the index of the found answer, if the given answer is in the set of correct answers and match...
& joinAnswers()
Returns the answers of the question as a comma separated string.
toJSON()
Returns a JSON representation of the question.
deleteAnswer($index=0)
Deletes an answer with a given index.
addAnswerOptionValue(int $qIndex, string $answerOptionValue, float $points)
isComplete()
Returns true, if a TextSubset question is complete for use.
duplicate(bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
Duplicates an assTextSubsetQuestion.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
setTextRating($a_text_rating)
Sets the rating option for text comparisons.
saveToDb($original_id="")
Saves a assTextSubset object to a database.
calculateReachedPointsForSolution($enteredTexts)
addAnswer($answertext, $points, $order)
Adds an answer to the question.
getAnswerTableName()
Returns the name of the answer table in the database.
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
getOperators($expression)
Get all available operations for a specific question.
copyObject($target_questionpool_id, $title="")
Copies an assTextSubset object.
& getAvailableAnswers()
Returns the available answers for the question.
getTextRating()
Returns the rating option for text comparisons.
loadFromDb($question_id)
Loads a assTextSubset object from a database.
getQuestionType()
Returns the question type of the question.
getCorrectAnswers()
Returns the number of correct answers needed to solve the question.
getAnswerCount()
Returns the number of answers.
flushAnswers()
Deletes all answers.
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assTextSubset constructor
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
isAddableAnswerOptionValue(int $qIndex, string $answerOptionValue)
setExportDetailsXLS(ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
{}
getAnswer($index=0)
Returns an answer with a given index.
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setCell($a_row, $a_col, $a_value, $datatype=null)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
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 strToLower(string $a_string)
Definition: class.ilStr.php:72
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$mobs
Definition: imgupload.php:70
$ilUser
Definition: imgupload.php:34
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_CASEINSENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN1
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
$post
Definition: ltitoken.php:49
$index
Definition: metadata.php:145
$i
Definition: metadata.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples