ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.assTextSubset.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
5require_once './Modules/Test/classes/inc.AssessmentConstants.php';
6require_once './Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
7require_once './Modules/TestQuestionPool/interfaces/interface.ilObjAnswerScoringAdjustable.php';
8require_once './Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php';
9require_once './Modules/TestQuestionPool/classes/class.ilUserQuestionResult.php';
10
27{
35 public $answers;
36
45
54
66 public function __construct(
67 $title = "",
68 $comment = "",
69 $author = "",
70 $owner = -1,
71 $question = ""
72 ) {
74 $this->answers = array();
75 $this->correctanswers = 0;
76 }
77
84 public function isComplete()
85 {
86 if (
87 strlen($this->title)
88 && $this->author
89 && $this->question &&
90 count($this->answers) >= $this->correctanswers
91 && $this->getMaximumPoints() > 0
92 ) {
93 return true;
94 }
95 return false;
96 }
97
104 public function saveToDb($original_id = "")
105 {
106 global $DIC;
107 $ilDB = $DIC['ilDB'];
108
112
113 parent::saveToDb($original_id);
114 }
115
123 public function loadFromDb($question_id)
124 {
125 global $DIC;
126 $ilDB = $DIC['ilDB'];
127
128 $result = $ilDB->queryF(
129 "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",
130 array("integer"),
131 array($question_id)
132 );
133 if ($result->numRows() == 1) {
134 $data = $ilDB->fetchAssoc($result);
135 $this->setId($question_id);
136 $this->setObjId($data["obj_fi"]);
137 $this->setNrOfTries($data['nr_of_tries']);
138 $this->setTitle($data["title"]);
139 $this->setComment($data["description"]);
140 $this->setOriginalId($data["original_id"]);
141 $this->setAuthor($data["author"]);
142 $this->setPoints($data["points"]);
143 $this->setOwner($data["owner"]);
144 include_once("./Services/RTE/classes/class.ilRTE.php");
145 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
146 $this->setCorrectAnswers($data["correctanswers"]);
147 $this->setTextRating($data["textgap_rating"]);
148 $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
149
150 try {
154 }
155
156 try {
157 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
159 }
160 }
161
162
163 $result = $ilDB->queryF(
164 "SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
165 array('integer'),
166 array($question_id)
167 );
168 include_once "./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
169 if ($result->numRows() > 0) {
170 while ($data = $ilDB->fetchAssoc($result)) {
171 array_push($this->answers, new ASS_AnswerBinaryStateImage($data["answertext"], $data["points"], $data["aorder"]));
172 }
173 }
174
175 parent::loadFromDb($question_id);
176 }
177
183 public function addAnswer($answertext, $points, $order)
184 {
185 include_once "./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
186 if (array_key_exists($order, $this->answers)) {
187 // insert answer
188 $answer = new ASS_AnswerBinaryStateImage($answertext, $points, $order);
189 $newchoices = array();
190 for ($i = 0; $i < $order; $i++) {
191 array_push($newchoices, $this->answers[$i]);
192 }
193 array_push($newchoices, $answer);
194 for ($i = $order; $i < count($this->answers); $i++) {
195 $changed = $this->answers[$i];
196 $changed->setOrder($i + 1);
197 array_push($newchoices, $changed);
198 }
199 $this->answers = $newchoices;
200 } else {
201 // add answer
202 array_push($this->answers, new ASS_AnswerBinaryStateImage($answertext, $points, count($this->answers)));
203 }
204 }
205
211 public function duplicate($for_test = true, $title = "", $author = "", $owner = "", $testObjId = null)
212 {
213 if ($this->id <= 0) {
214 // The question has not been saved. It cannot be duplicated
215 return;
216 }
217 // duplicate the question in database
218 $this_id = $this->getId();
219 $thisObjId = $this->getObjId();
220
221 $clone = $this;
222 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
224 $clone->id = -1;
225
226 if ((int) $testObjId > 0) {
227 $clone->setObjId($testObjId);
228 }
229
230 if ($title) {
231 $clone->setTitle($title);
232 }
233
234 if ($author) {
235 $clone->setAuthor($author);
236 }
237 if ($owner) {
238 $clone->setOwner($owner);
239 }
240
241 if ($for_test) {
242 $clone->saveToDb($original_id);
243 } else {
244 $clone->saveToDb();
245 }
246
247 // copy question page content
248 $clone->copyPageOfQuestion($this_id);
249 // copy XHTML media objects
250 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
251
252 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
253
254 return $clone->id;
255 }
256
262 public function copyObject($target_questionpool_id, $title = "")
263 {
264 if ($this->id <= 0) {
265 // The question has not been saved. It cannot be duplicated
266 return;
267 }
268 // duplicate the question in database
269 $clone = $this;
270 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
272 $clone->id = -1;
273 $source_questionpool_id = $this->getObjId();
274 $clone->setObjId($target_questionpool_id);
275 if ($title) {
276 $clone->setTitle($title);
277 }
278 $clone->saveToDb();
279 // copy question page content
280 $clone->copyPageOfQuestion($original_id);
281 // copy XHTML media objects
282 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
283
284 $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
285
286 return $clone->id;
287 }
288
289 public function createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle = "")
290 {
291 if ($this->id <= 0) {
292 // The question has not been saved. It cannot be duplicated
293 return;
294 }
295
296 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
297
298 $sourceQuestionId = $this->id;
299 $sourceParentId = $this->getObjId();
300
301 // duplicate the question in database
302 $clone = $this;
303 $clone->id = -1;
304
305 $clone->setObjId($targetParentId);
306
307 if ($targetQuestionTitle) {
308 $clone->setTitle($targetQuestionTitle);
309 }
310
311 $clone->saveToDb();
312 // copy question page content
313 $clone->copyPageOfQuestion($sourceQuestionId);
314 // copy XHTML media objects
315 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
316
317 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
318
319 return $clone->id;
320 }
321
329 public function getAnswerCount()
330 {
331 return count($this->answers);
332 }
333
343 public function getAnswer($index = 0)
344 {
345 if ($index < 0) {
346 return null;
347 }
348 if (count($this->answers) < 1) {
349 return null;
350 }
351 if ($index >= count($this->answers)) {
352 return null;
353 }
354
355 return $this->answers[$index];
356 }
357
366 public function deleteAnswer($index = 0)
367 {
368 if ($index < 0) {
369 return;
370 }
371 if (count($this->answers) < 1) {
372 return;
373 }
374 if ($index >= count($this->answers)) {
375 return;
376 }
377 unset($this->answers[$index]);
378 $this->answers = array_values($this->answers);
379 for ($i = 0; $i < count($this->answers); $i++) {
380 if ($this->answers[$i]->getOrder() > $index) {
381 $this->answers[$i]->setOrder($i);
382 }
383 }
384 }
385
392 public function flushAnswers()
393 {
394 $this->answers = array();
395 }
396
403 public function getMaximumPoints()
404 {
405 $points = array();
406 foreach ($this->answers as $answer) {
407 if ($answer->getPoints() > 0) {
408 array_push($points, $answer->getPoints());
409 }
410 }
411 rsort($points, SORT_NUMERIC);
412 $maxpoints = 0;
413 for ($counter = 0; $counter < $this->getCorrectAnswers(); $counter++) {
414 $maxpoints += $points[$counter];
415 }
416 return $maxpoints;
417 }
418
425 public function &getAvailableAnswers()
426 {
427 $available_answers = array();
428 foreach ($this->answers as $answer) {
429 array_push($available_answers, $answer->getAnswertext());
430 }
431 return $available_answers;
432 }
433
444 public function isAnswerCorrect($answers, $answer)
445 {
446 include_once "./Services/Utilities/classes/class.ilStr.php";
447 $result = 0;
448 $textrating = $this->getTextRating();
449 foreach ($answers as $key => $value) {
450 switch ($textrating) {
452 if (strcmp(ilStr::strToLower($value), ilStr::strToLower($answer)) == 0 && $this->answers[$key]->getPoints() > 0) {
453 return $key;
454 }
455 break;
457 if (strcmp($value, $answer) == 0 && $this->answers[$key]->getPoints() > 0) {
458 return $key;
459 }
460 break;
462 if (levenshtein($value, $answer) <= 1 && $this->answers[$key]->getPoints() > 0) {
463 return $key;
464 }
465 break;
467 if (levenshtein($value, $answer) <= 2 && $this->answers[$key]->getPoints() > 0) {
468 return $key;
469 }
470 break;
472 if (levenshtein($value, $answer) <= 3 && $this->answers[$key]->getPoints() > 0) {
473 return $key;
474 }
475 break;
477 if (levenshtein($value, $answer) <= 4 && $this->answers[$key]->getPoints() > 0) {
478 return $key;
479 }
480 break;
482 if (levenshtein($value, $answer) <= 5 && $this->answers[$key]->getPoints() > 0) {
483 return $key;
484 }
485 break;
486 }
487 }
488 return false;
489 }
490
498 public function getTextRating()
499 {
500 return $this->text_rating;
501 }
502
510 public function setTextRating($a_text_rating)
511 {
512 switch ($a_text_rating) {
520 $this->text_rating = $a_text_rating;
521 break;
522 default:
523 $this->text_rating = TEXTGAP_RATING_CASEINSENSITIVE;
524 break;
525 }
526 }
527
538 public function calculateReachedPoints($active_id, $pass = null, $authorizedSolution = true, $returndetails = false)
539 {
540 if ($returndetails) {
541 throw new ilTestException('return details not implemented for ' . __METHOD__);
542 }
543
544 global $DIC;
545 $ilDB = $DIC['ilDB'];
546
547
548 if (is_null($pass)) {
549 $pass = $this->getSolutionMaxPass($active_id);
550 }
551 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
552
553 $enteredTexts = array();
554 while ($data = $ilDB->fetchAssoc($result)) {
555 $enteredTexts[] = $data["value1"];
556 }
557
558 $points = $this->calculateReachedPointsForSolution($enteredTexts);
559
560 return $points;
561 }
562
569 public function setCorrectAnswers($a_correct_answers)
570 {
571 $this->correctanswers = $a_correct_answers;
572 }
573
580 public function getCorrectAnswers()
581 {
583 }
584
593 public function saveWorkingData($active_id, $pass = null, $authorized = true)
594 {
595 global $DIC;
596 $ilDB = $DIC['ilDB'];
597 $ilUser = $DIC['ilUser'];
598
599 if (is_null($pass)) {
600 include_once "./Modules/Test/classes/class.ilObjTest.php";
601 $pass = ilObjTest::_getPass($active_id);
602 }
603
604 $entered_values = 0;
605 $solutionSubmit = $this->getSolutionSubmit();
606
607 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $solutionSubmit, $active_id, $pass, $authorized) {
608 $this->removeCurrentSolution($active_id, $pass, $authorized);
609
610 foreach ($solutionSubmit as $value) {
611 if (strlen($value)) {
612 $this->saveCurrentSolution($active_id, $pass, $value, null, $authorized);
613 $entered_values++;
614 }
615 }
616 });
617
618 if ($entered_values) {
619 include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
621 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
622 }
623 } else {
624 include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
626 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
627 }
628 }
629
630 return true;
631 }
632
633 public function saveAdditionalQuestionDataToDb()
634 {
636 global $DIC;
637 $ilDB = $DIC['ilDB'];
638
639 // save additional data
640 $ilDB->manipulateF(
641 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
642 array( "integer" ),
643 array( $this->getId() )
644 );
645
646 $ilDB->manipulateF(
647 "INSERT INTO " . $this->getAdditionalTableName(
648 ) . " (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
649 array( "integer", "text", "integer" ),
650 array(
651 $this->getId(),
652 $this->getTextRating(),
653 $this->getCorrectAnswers()
654 )
655 );
656 }
657
658 public function saveAnswerSpecificDataToDb()
659 {
661 global $DIC;
662 $ilDB = $DIC['ilDB'];
663 $ilDB->manipulateF(
664 "DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
665 array( 'integer' ),
666 array( $this->getId() )
667 );
668
669 foreach ($this->answers as $key => $value) {
670 $answer_obj = $this->answers[$key];
671 $next_id = $ilDB->nextId('qpl_a_textsubset');
672 $ilDB->manipulateF(
673 "INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
674 array( 'integer', 'integer', 'text', 'float', 'integer', 'integer' ),
675 array(
676 $next_id,
677 $this->getId(),
678 $answer_obj->getAnswertext(),
679 $answer_obj->getPoints(),
680 $answer_obj->getOrder(),
681 time()
682 )
683 );
684 }
685 }
686
693 public function getQuestionType()
694 {
695 return "assTextSubset";
696 }
697
704 public function &joinAnswers()
705 {
706 $join = array();
707 foreach ($this->answers as $answer) {
708 if (!is_array($join[$answer->getPoints() . ""])) {
709 $join[$answer->getPoints() . ""] = array();
710 }
711 array_push($join[$answer->getPoints() . ""], $answer->getAnswertext());
712 }
713 return $join;
714 }
715
722 public function getMaxTextboxWidth()
723 {
724 $maxwidth = 0;
725 foreach ($this->answers as $answer) {
726 $len = strlen($answer->getAnswertext());
727 if ($len > $maxwidth) {
728 $maxwidth = $len;
729 }
730 }
731 return $maxwidth + 3;
732 }
733
740 public function getAdditionalTableName()
741 {
742 return "qpl_qst_textsubset";
743 }
744
751 public function getAnswerTableName()
752 {
753 return "qpl_a_textsubset";
754 }
755
761 {
762 return parent::getRTETextWithMediaObjects();
763 }
764
768 public function setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
769 {
770 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
771
772 $solutions = $this->getSolutionValues($active_id, $pass);
773
774 $i = 1;
775 foreach ($solutions as $solution) {
776 $worksheet->setCell($startrow + $i, 0, $solution["value1"]);
777 $i++;
778 }
779
780 return $startrow + $i + 1;
781 }
782
783 public function getAnswers()
784 {
785 return $this->answers;
786 }
787
791 public function toJSON()
792 {
793 include_once("./Services/RTE/classes/class.ilRTE.php");
794 $result = array();
795 $result['id'] = (int) $this->getId();
796 $result['type'] = (string) $this->getQuestionType();
797 $result['title'] = (string) $this->getTitle();
798 $result['question'] = $this->formatSAQuestion($this->getQuestion());
799 $result['nr_of_tries'] = (int) $this->getNrOfTries();
800 $result['matching_method'] = (string) $this->getTextRating();
801 $result['feedback'] = array(
802 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
803 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
804 );
805
806 $answers = array();
807 foreach ($this->getAnswers() as $key => $answer_obj) {
808 array_push($answers, array(
809 "answertext" => (string) $answer_obj->getAnswertext(),
810 "points" => (float) $answer_obj->getPoints(),
811 "order" => (int) $answer_obj->getOrder()
812 ));
813 }
814 $result['correct_answers'] = $answers;
815
816 $answers = array();
817 for ($loop = 1; $loop <= (int) $this->getCorrectAnswers(); $loop++) {
818 array_push($answers, array(
819 "answernr" => $loop
820 ));
821 }
822 $result['answers'] = $answers;
823
824 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
825 $result['mobs'] = $mobs;
826
827 return json_encode($result);
828 }
829
833 protected function getSolutionSubmit()
834 {
835 $solutionSubmit = array();
836 $purifier = $this->getHtmlUserSolutionPurifier();
837 foreach ($_POST as $key => $val) {
838 if (preg_match("/^TEXTSUBSET_(\d+)/", $key, $matches)) {
839 $val = trim($val);
840 if (strlen($val)) {
841 $val = $purifier->purify($val);
842 $solutionSubmit[] = $val;
843 }
844 }
845 }
846 return $solutionSubmit;
847 }
848
853 protected function calculateReachedPointsForSolution($enteredTexts)
854 {
855 $available_answers = $this->getAvailableAnswers();
856 $points = 0;
857 foreach ($enteredTexts as $enteredtext) {
858 $index = $this->isAnswerCorrect($available_answers, $enteredtext);
859 if ($index !== false) {
860 unset($available_answers[$index]);
861 $points += $this->answers[$index]->getPoints();
862 }
863 }
864 return $points;
865 }
866
875 public function getOperators($expression)
876 {
877 require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
879 }
880
885 public function getExpressionTypes()
886 {
887 return array(
892 );
893 }
894
903 public function getUserQuestionResult($active_id, $pass)
904 {
906 global $DIC;
907 $ilDB = $DIC['ilDB'];
908 $result = new ilUserQuestionResult($this, $active_id, $pass);
909
910 $maxStep = $this->lookupMaxStep($active_id, $pass);
911
912 if ($maxStep !== null) {
913 $data = $ilDB->queryF(
914 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s ORDER BY solution_id",
915 array("integer", "integer", "integer","integer"),
916 array($active_id, $pass, $this->getId(), $maxStep)
917 );
918 } else {
919 $data = $ilDB->queryF(
920 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s ORDER BY solution_id",
921 array("integer", "integer", "integer"),
922 array($active_id, $pass, $this->getId())
923 );
924 }
925
926 for ($index = 1; $index <= $ilDB->numRows($data); ++$index) {
927 $row = $ilDB->fetchAssoc($data);
928 $result->addKeyValue($index, $row["value1"]);
929 }
930
931 $points = $this->calculateReachedPoints($active_id, $pass);
932 $max_points = $this->getMaximumPoints();
933
934 $result->setReachedPercentage(($points / $max_points) * 100);
935
936 return $result;
937 }
938
947 public function getAvailableAnswerOptions($index = null)
948 {
949 if ($index !== null) {
950 return $this->getAnswer($index);
951 } else {
952 return $this->getAnswers();
953 }
954 }
955}
$result
$_POST["username"]
Class for answers with a binary state indicator.
An exception for terminatinating execution or to throw for unit testing.
Abstract basic class which is to be extended by the concrete assessment question type classes.
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass.
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
setId($id=-1)
Sets the id of the assQuestion object.
setOriginalId($original_id)
setObjId($obj_id=0)
Set the object id of the container object.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
saveQuestionDataToDb($original_id="")
getId()
Gets the id of the assQuestion object.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
getObjId()
Get the object id of the container object.
setTitle($title="")
Sets the title string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second.
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
removeCurrentSolution($active_id, $pass, $authorized=true)
setAuthor($author="")
Sets the authors name of the assQuestion object.
getPoints()
Returns the maximum available points for the question.
setLifecycle(ilAssQuestionLifecycle $lifecycle)
getTitle()
Gets the title string of the assQuestion object.
setPoints($a_points)
Sets the maximum available points for the question.
setComment($comment="")
Sets the comment string of the assQuestion object.
setNrOfTries($a_nr_of_tries)
getQuestion()
Gets the question string of the question object.
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setQuestion($question="")
Sets the question string of the question object.
Class for TextSubset questions.
getExpressionTypes()
Get all available expression types for a specific question.
getMaxTextboxWidth()
Returns the maximum width needed for the answer textboxes.
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.
isComplete()
Returns true, if a TextSubset question is complete for use.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
setTextRating($a_text_rating)
Sets the rating option for text comparisons.
saveToDb($original_id="")
Saves a assTextSubset object to a database.
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assTextSubsetQuestion.
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{Creates an Excel worksheet for the detailed cumulated results of this question.object}
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 ...
setCorrectAnswers($a_correct_answers)
Sets the number of correct answers needed to solve the question.
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.
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static strToLower($a_string)
Definition: class.ilStr.php:87
Base Exception for all Exceptions relating to Modules/Test.
Class ilUserQuestionResult.
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
Class iQuestionCondition.
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
Interface ilObjAnswerScoringAdjustable.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
Interface ilObjQuestionScoringAdjustable.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
$index
Definition: metadata.php:128
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilDB
$data
Definition: storeScorm.php:23
$mobs
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46