ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
4 require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
5 require_once './Modules/Test/classes/inc.AssessmentConstants.php';
6 require_once './Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
7 require_once './Modules/TestQuestionPool/interfaces/interface.ilObjAnswerScoringAdjustable.php';
8 require_once './Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php';
9 require_once './Modules/TestQuestionPool/classes/class.ilUserQuestionResult.php';
10 
27 {
35  public $answers;
36 
45 
53  public $text_rating;
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']);
158  } catch (ilTestQuestionPoolException $e) {
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  global $DIC;
448  $refinery = $DIC->refinery();
449  $textrating = $this->getTextRating();
450 
451  foreach ($answers as $key => $value) {
452  if ($this->answers[$key]->getPoints() <= 0) {
453  continue;
454  }
455  $value = html_entity_decode($value); #SB
456  switch ($textrating) {
458  if (strcmp(ilStr::strToLower($value), ilStr::strToLower($answer)) == 0) { #SB
459  return $key;
460  }
461  break;
463  if (strcmp($value, $answer) == 0) {
464  return $key;
465  }
466  break;
468  $transformation = $refinery->string()->levenshtein()->standard($answer, 1);
469  break;
471  $transformation = $refinery->string()->levenshtein()->standard($answer, 2);
472  break;
474  $transformation = $refinery->string()->levenshtein()->standard($answer, 3);
475  break;
477  $transformation = $refinery->string()->levenshtein()->standard($answer, 4);
478  break;
480  $transformation = $refinery->string()->levenshtein()->standard($answer, 5);
481  break;
482  }
483 
484  // run answers against Levenshtein2 methods
485  if (isset($transformation) && $transformation->transform($value) >= 0) {
486  return $key;
487  }
488  }
489  return false;
490  }
491 
499  public function getTextRating()
500  {
501  return $this->text_rating;
502  }
503 
511  public function setTextRating($a_text_rating)
512  {
513  switch ($a_text_rating) {
521  $this->text_rating = $a_text_rating;
522  break;
523  default:
524  $this->text_rating = TEXTGAP_RATING_CASEINSENSITIVE;
525  break;
526  }
527  }
528 
539  public function calculateReachedPoints($active_id, $pass = null, $authorizedSolution = true, $returndetails = false)
540  {
541  if ($returndetails) {
542  throw new ilTestException('return details not implemented for ' . __METHOD__);
543  }
544 
545  global $DIC;
546  $ilDB = $DIC['ilDB'];
547 
548 
549  if (is_null($pass)) {
550  $pass = $this->getSolutionMaxPass($active_id);
551  }
552  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
553 
554  $enteredTexts = array();
555  while ($data = $ilDB->fetchAssoc($result)) {
556  $enteredTexts[] = $data["value1"];
557  }
558 
559  $points = $this->calculateReachedPointsForSolution($enteredTexts);
560 
561  return $points;
562  }
563 
570  public function setCorrectAnswers($a_correct_answers)
571  {
572  $this->correctanswers = $a_correct_answers;
573  }
574 
581  public function getCorrectAnswers()
582  {
583  return $this->correctanswers;
584  }
585 
594  public function saveWorkingData($active_id, $pass = null, $authorized = true)
595  {
596  global $DIC;
597  $ilDB = $DIC['ilDB'];
598  $ilUser = $DIC['ilUser'];
599 
600  if (is_null($pass)) {
601  include_once "./Modules/Test/classes/class.ilObjTest.php";
602  $pass = ilObjTest::_getPass($active_id);
603  }
604 
605  $entered_values = 0;
606  $solutionSubmit = $this->getSolutionSubmit();
607 
608  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $solutionSubmit, $active_id, $pass, $authorized) {
609  $this->removeCurrentSolution($active_id, $pass, $authorized);
610 
611  foreach ($solutionSubmit as $value) {
612  if (strlen($value)) {
613  $this->saveCurrentSolution($active_id, $pass, $value, null, $authorized);
614  $entered_values++;
615  }
616  }
617  });
618 
619  if ($entered_values) {
620  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
622  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
623  }
624  } else {
625  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
627  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
628  }
629  }
630 
631  return true;
632  }
633 
634  public function saveAdditionalQuestionDataToDb()
635  {
637  global $DIC;
638  $ilDB = $DIC['ilDB'];
639 
640  // save additional data
641  $ilDB->manipulateF(
642  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
643  array( "integer" ),
644  array( $this->getId() )
645  );
646 
647  $ilDB->manipulateF(
648  "INSERT INTO " . $this->getAdditionalTableName(
649  ) . " (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
650  array( "integer", "text", "integer" ),
651  array(
652  $this->getId(),
653  $this->getTextRating(),
654  $this->getCorrectAnswers()
655  )
656  );
657  }
658 
659  public function saveAnswerSpecificDataToDb()
660  {
662  global $DIC;
663  $ilDB = $DIC['ilDB'];
664  $ilDB->manipulateF(
665  "DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
666  array( 'integer' ),
667  array( $this->getId() )
668  );
669 
670  foreach ($this->answers as $key => $value) {
671  $answer_obj = $this->answers[$key];
672  $next_id = $ilDB->nextId('qpl_a_textsubset');
673  $ilDB->manipulateF(
674  "INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
675  array( 'integer', 'integer', 'text', 'float', 'integer', 'integer' ),
676  array(
677  $next_id,
678  $this->getId(),
679  $answer_obj->getAnswertext(),
680  $answer_obj->getPoints(),
681  $answer_obj->getOrder(),
682  time()
683  )
684  );
685  }
686  }
687 
694  public function getQuestionType()
695  {
696  return "assTextSubset";
697  }
698 
705  public function &joinAnswers()
706  {
707  $join = array();
708  foreach ($this->answers as $answer) {
709  if (!is_array($join[$answer->getPoints() . ""])) {
710  $join[$answer->getPoints() . ""] = array();
711  }
712  array_push($join[$answer->getPoints() . ""], $answer->getAnswertext());
713  }
714  return $join;
715  }
716 
723  public function getMaxTextboxWidth()
724  {
725  $maxwidth = 0;
726  foreach ($this->answers as $answer) {
727  $len = strlen($answer->getAnswertext());
728  if ($len > $maxwidth) {
729  $maxwidth = $len;
730  }
731  }
732  return $maxwidth + 3;
733  }
734 
741  public function getAdditionalTableName()
742  {
743  return "qpl_qst_textsubset";
744  }
745 
752  public function getAnswerTableName()
753  {
754  return "qpl_a_textsubset";
755  }
756 
761  public function getRTETextWithMediaObjects()
762  {
763  return parent::getRTETextWithMediaObjects();
764  }
765 
769  public function setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
770  {
771  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
772 
773  $solutions = $this->getSolutionValues($active_id, $pass);
774 
775  $i = 1;
776  foreach ($solutions as $solution) {
777  $worksheet->setCell($startrow + $i, 2, $solution["value1"]);
778  $i++;
779  }
780 
781  return $startrow + $i + 1;
782  }
783 
784  public function getAnswers()
785  {
786  return $this->answers;
787  }
788 
792  public function toJSON()
793  {
794  include_once("./Services/RTE/classes/class.ilRTE.php");
795  $result = array();
796  $result['id'] = (int) $this->getId();
797  $result['type'] = (string) $this->getQuestionType();
798  $result['title'] = (string) $this->getTitle();
799  $result['question'] = $this->formatSAQuestion($this->getQuestion());
800  $result['nr_of_tries'] = (int) $this->getNrOfTries();
801  $result['matching_method'] = (string) $this->getTextRating();
802  $result['feedback'] = array(
803  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
804  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
805  );
806 
807  $answers = array();
808  foreach ($this->getAnswers() as $key => $answer_obj) {
809  array_push($answers, array(
810  "answertext" => (string) $answer_obj->getAnswertext(),
811  "points" => (float) $answer_obj->getPoints(),
812  "order" => (int) $answer_obj->getOrder()
813  ));
814  }
815  $result['correct_answers'] = $answers;
816 
817  $answers = array();
818  for ($loop = 1; $loop <= (int) $this->getCorrectAnswers(); $loop++) {
819  array_push($answers, array(
820  "answernr" => $loop
821  ));
822  }
823  $result['answers'] = $answers;
824 
825  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
826  $result['mobs'] = $mobs;
827 
828  return json_encode($result);
829  }
830 
834  protected function getSolutionSubmit()
835  {
836  $solutionSubmit = array();
837  $purifier = $this->getHtmlUserSolutionPurifier();
838  foreach ($_POST as $key => $val) {
839  if (preg_match("/^TEXTSUBSET_(\d+)/", $key, $matches)) {
840  $val = trim($val);
841  if (strlen($val)) {
842  $val = $purifier->purify($val);
843  $solutionSubmit[] = $val;
844  }
845  }
846  }
847  return $solutionSubmit;
848  }
849 
854  protected function calculateReachedPointsForSolution($enteredTexts)
855  {
856  $available_answers = $this->getAvailableAnswers();
857  $points = 0;
858  foreach ($enteredTexts as $enteredtext) {
859  $index = $this->isAnswerCorrect($available_answers, html_entity_decode($enteredtext));
860  if ($index !== false) {
861  unset($available_answers[$index]);
862  $points += $this->answers[$index]->getPoints();
863  }
864  }
865  return $points;
866  }
867 
876  public function getOperators($expression)
877  {
878  require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
880  }
881 
886  public function getExpressionTypes()
887  {
888  return array(
893  );
894  }
895 
904  public function getUserQuestionResult($active_id, $pass)
905  {
907  global $DIC;
908  $ilDB = $DIC['ilDB'];
909  $result = new ilUserQuestionResult($this, $active_id, $pass);
910 
911  $maxStep = $this->lookupMaxStep($active_id, $pass);
912 
913  if ($maxStep !== null) {
914  $data = $ilDB->queryF(
915  "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s ORDER BY solution_id",
916  array("integer", "integer", "integer","integer"),
917  array($active_id, $pass, $this->getId(), $maxStep)
918  );
919  } else {
920  $data = $ilDB->queryF(
921  "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s ORDER BY solution_id",
922  array("integer", "integer", "integer"),
923  array($active_id, $pass, $this->getId())
924  );
925  }
926 
927  for ($index = 1; $index <= $ilDB->numRows($data); ++$index) {
928  $row = $ilDB->fetchAssoc($data);
929  $result->addKeyValue($index, $row["value1"]);
930  }
931 
932  $points = $this->calculateReachedPoints($active_id, $pass);
933  $max_points = $this->getMaximumPoints();
934 
935  $result->setReachedPercentage(($points / $max_points) * 100);
936 
937  return $result;
938  }
939 
948  public function getAvailableAnswerOptions($index = null)
949  {
950  if ($index !== null) {
951  return $this->getAnswer($index);
952  } else {
953  return $this->getAnswers();
954  }
955  }
956 
957  public function isAddableAnswerOptionValue($qIndex, $answerOptionValue)
958  {
959  $found = false;
960 
961  foreach ($this->getAnswers() as $item) {
962  if ($answerOptionValue !== $item->getAnswerText()) {
963  continue;
964  }
965 
966  $found = true;
967  break;
968  }
969 
970  return !$found;
971  }
972 
973  public function addAnswerOptionValue($qIndex, $answerOptionValue, $points)
974  {
975  $this->addAnswer($answerOptionValue, $points, $qIndex);
976  }
977 }
calculateReachedPointsForSolution($enteredTexts)
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
addAnswer($answertext, $points, $order)
Adds an answer to the question.
getId()
Gets the id of the assQuestion object.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
getCorrectAnswers()
Returns the number of correct answers needed to solve the question.
const TEXTGAP_RATING_LEVENSHTEIN5
Class iQuestionCondition.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
$data
Definition: storeScorm.php:23
flushAnswers()
Deletes all answers.
$result
$mobs
Definition: imgupload.php:54
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
getPoints()
Returns the maximum available points for the question.
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
Abstract basic class which is to be extended by the concrete assessment question type classes...
Class for answers with a binary state indicator.
getOperators($expression)
Get all available operations for a specific question.
copyObject($target_questionpool_id, $title="")
Copies an assTextSubset object.
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
& joinAnswers()
Returns the answers of the question as a comma separated string.
getTextRating()
Returns the rating option for text comparisons.
setTextRating($a_text_rating)
Sets the rating option for text comparisons.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
toJSON()
Returns a JSON representation of the question.
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
setId($id=-1)
Sets the id of the assQuestion object.
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.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Class for TextSubset questions.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second. ...
static strToLower($a_string)
Definition: class.ilStr.php:87
isComplete()
Returns true, if a TextSubset question is complete for use.
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
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...
getObjId()
Get the object id of the container object.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
getQuestionType()
Returns the question type of the question.
Base Exception for all Exceptions relating to Modules/Test.
$index
Definition: metadata.php:128
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assTextSubset constructor
isAddableAnswerOptionValue($qIndex, $answerOptionValue)
static _getLogLanguage()
retrieve the log language for assessment logging
setAuthor($author="")
Sets the authors name of the assQuestion object.
saveToDb($original_id="")
Saves a assTextSubset object to a database.
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
const TEXTGAP_RATING_LEVENSHTEIN3
Class ilUserQuestionResult.
loadFromDb($question_id)
Loads a assTextSubset object from a database.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
& getAvailableAnswers()
Returns the available answers for the question.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
setCorrectAnswers($a_correct_answers)
Sets the number of correct answers needed to solve the question.
const TEXTGAP_RATING_CASESENSITIVE
Interface ilObjAnswerScoringAdjustable.
global $DIC
Definition: goto.php:24
getQuestion()
Gets the question string of the question object.
getAnswerCount()
Returns the number of answers.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getExpressionTypes()
Get all available expression types for a specific question.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
setPoints($a_points)
Sets the maximum available points for the question.
saveQuestionDataToDb($original_id="")
getAnswer($index=0)
Returns an answer with a given index.
setQuestion($question="")
Sets the question string of the question object.
Interface ilObjQuestionScoringAdjustable.
removeCurrentSolution($active_id, $pass, $authorized=true)
__construct(Container $dic, ilPlugin $plugin)
const TEXTGAP_RATING_LEVENSHTEIN4
global $ilDB
setOriginalId($original_id)
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
setLifecycle(ilAssQuestionLifecycle $lifecycle)
getTitle()
Gets the title string of the assQuestion object.
deleteAnswer($index=0)
Deletes an answer with a given index.
$ilUser
Definition: imgupload.php:18
getMaxTextboxWidth()
Returns the maximum width needed for the answer textboxes.
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assTextSubsetQuestion.
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setComment($comment="")
Sets the comment string of the assQuestion object.
isAnswerCorrect($answers, $answer)
Returns the index of the found answer, if the given answer is in the set of correct answers and match...
$_POST["username"]
$i
Definition: metadata.php:24
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{}
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
const TEXTGAP_RATING_CASEINSENSITIVE
addAnswerOptionValue($qIndex, $answerOptionValue, $points)