ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.assTextQuestion.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 
23 {
32 
41  public $keywords;
42 
43  public $answers;
44 
50  public $text_rating;
51 
52  /* method for automatic string matching */
53  private $matchcondition;
54 
55  public $keyword_relation = 'any';
56 
69  public function __construct(
70  $title = "",
71  $comment = "",
72  $author = "",
73  $owner = -1,
74  $question = ""
75  ) {
76  parent::__construct($title, $comment, $author, $owner, $question);
77  $this->maxNumOfChars = 0;
78  $this->points = 1;
79  $this->answers = array();
80  $this->matchcondition = 0;
81  }
82 
88  public function isComplete()
89  {
90  if (strlen($this->title)
91  && $this->author
92  && $this->question
93  && $this->getMaximumPoints() > 0
94  ) {
95  return true;
96  }
97  return false;
98  }
99 
105  public function saveToDb($original_id = "")
106  {
110  parent::saveToDb($original_id);
111  }
112 
120  public function loadFromDb($question_id)
121  {
122  global $ilDB;
123 
124  $result = $ilDB->queryF(
125  "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",
126  array("integer"),
127  array($question_id)
128  );
129  if ($ilDB->numRows($result) == 1) {
130  $data = $ilDB->fetchAssoc($result);
131  $this->setId($question_id);
132  $this->setObjId($data["obj_fi"]);
133  $this->setTitle($data["title"]);
134  $this->setComment($data["description"]);
135  $this->setOriginalId($data["original_id"]);
136  $this->setNrOfTries($data['nr_of_tries']);
137  $this->setAuthor($data["author"]);
138  $this->setPoints((float) $data["points"]);
139  $this->setOwner($data["owner"]);
140  include_once("./Services/RTE/classes/class.ilRTE.php");
141  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
142  $this->setShuffle($data["shuffle"]);
143  $this->setMaxNumOfChars($data["maxnumofchars"]);
144  $this->setTextRating($this->isValidTextRating($data["textgap_rating"]) ? $data["textgap_rating"] : TEXTGAP_RATING_CASEINSENSITIVE);
145  $this->matchcondition = (strlen($data['matchcondition'])) ? $data['matchcondition'] : 0;
146  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
147  $this->setKeywordRelation(($data['keyword_relation']));
148 
149  try {
150  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
151  } catch (ilTestQuestionPoolException $e) {
152  }
153  }
154 
155  $result = $ilDB->queryF(
156  "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
157  array("integer"),
158  array($this->getId())
159  );
160 
161  $this->flushAnswers();
162  while ($row = $ilDB->fetchAssoc($result)) {
163  $this->addAnswer($row['answertext'], $row['points']);
164  }
165 
166  parent::loadFromDb($question_id);
167  }
168 
174  public function duplicate($for_test = true, $title = "", $author = "", $owner = "", $testObjId = null)
175  {
176  if ($this->id <= 0) {
177  // The question has not been saved. It cannot be duplicated
178  return;
179  }
180  // duplicate the question in database
181  $this_id = $this->getId();
182  $thisObjId = $this->getObjId();
183 
184  $clone = $this;
185  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
187  $clone->id = -1;
188 
189  if ((int) $testObjId > 0) {
190  $clone->setObjId($testObjId);
191  }
192 
193  if ($title) {
194  $clone->setTitle($title);
195  }
196 
197  if ($author) {
198  $clone->setAuthor($author);
199  }
200  if ($owner) {
201  $clone->setOwner($owner);
202  }
203 
204  if ($for_test) {
205  $clone->saveToDb($original_id);
206  } else {
207  $clone->saveToDb();
208  }
209 
210  // copy question page content
211  $clone->copyPageOfQuestion($this_id);
212  // copy XHTML media objects
213  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
214  #$clone->duplicateAnswers($this_id);
215 
216  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
217 
218  return $clone->id;
219  }
220 
226  public function copyObject($target_questionpool_id, $title = "")
227  {
228  if ($this->id <= 0) {
229  // The question has not been saved. It cannot be duplicated
230  return;
231  }
232  // duplicate the question in database
233  $clone = $this;
234  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
236  $clone->id = -1;
237  $source_questionpool_id = $this->getObjId();
238  $clone->setObjId($target_questionpool_id);
239  if ($title) {
240  $clone->setTitle($title);
241  }
242  $clone->saveToDb();
243  // copy question page content
244  $clone->copyPageOfQuestion($original_id);
245  // copy XHTML media objects
246  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
247  // duplicate answers
248  #$clone->duplicateAnswers($original_id);
249 
250  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
251 
252  return $clone->id;
253  }
254 
255  public function createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle = "")
256  {
257  if ($this->id <= 0) {
258  // The question has not been saved. It cannot be duplicated
259  return;
260  }
261 
262  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
263 
264  $sourceQuestionId = $this->id;
265  $sourceParentId = $this->getObjId();
266 
267  // duplicate the question in database
268  $clone = $this;
269  $clone->id = -1;
270 
271  $clone->setObjId($targetParentId);
272 
273  if ($targetQuestionTitle) {
274  $clone->setTitle($targetQuestionTitle);
275  }
276 
277  $clone->saveToDb();
278  // copy question page content
279  $clone->copyPageOfQuestion($sourceQuestionId);
280  // copy XHTML media objects
281  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
282  // duplicate answers
283  #$clone->duplicateAnswers($sourceQuestionId);
284 
285  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
286 
287  return $clone->id;
288  }
289 
297  public function getMaxNumOfChars()
298  {
299  if (strcmp($this->maxNumOfChars, "") == 0) {
300  return 0;
301  } else {
302  return $this->maxNumOfChars;
303  }
304  }
305 
313  public function setMaxNumOfChars($maxchars = 0)
314  {
315  $this->maxNumOfChars = $maxchars;
316  }
317 
324  public function getMaximumPoints()
325  {
326  if (in_array($this->getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
327  return parent::getPoints();
328  }
329 
330  $points = 0;
331 
332  foreach ($this->answers as $answer) {
333  if ($answer->getPoints() > 0) {
334  $points = $points + $answer->getPoints();
335  }
336  }
337 
338  return $points;
339  }
340 
341  public function getMinimumPoints()
342  {
343  if (in_array($this->getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
344  return 0;
345  }
346 
347  $points = 0;
348 
349  foreach ($this->answers as $answer) {
350  if ($answer->getPoints() < 0) {
351  $points = $points + $answer->getPoints();
352  }
353  }
354 
355  return $points;
356  }
366  public function setReachedPoints($active_id, $points, $pass = null)
367  {
368  global $ilDB;
369 
370  if (($points > 0) && ($points <= $this->getPoints())) {
371  if (is_null($pass)) {
372  $pass = $this->getSolutionMaxPass($active_id);
373  }
374  $affectedRows = $ilDB->manipulateF(
375  "UPDATE tst_test_result SET points = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
376  array('float','integer','integer','integer'),
377  array($points, $active_id, $this->getId(), $pass)
378  );
379  self::_updateTestPassResults($active_id, $pass);
380  return true;
381  } else {
382  return true;
383  }
384  }
385 
386  private function isValidTextRating($textRating)
387  {
388  switch ($textRating) {
396  return true;
397  }
398 
399  return false;
400  }
401 
410  public function isKeywordMatching($answertext, $a_keyword)
411  {
412  $result = false;
413  $textrating = $this->getTextRating();
414  include_once "./Services/Utilities/classes/class.ilStr.php";
415  switch ($textrating) {
417  if (ilStr::strPos(ilStr::strToLower($answertext), ilStr::strToLower($a_keyword)) !== false) {
418  return true;
419  }
420  break;
422  if (ilStr::strPos($answertext, $a_keyword) !== false) {
423  return true;
424  }
425  break;
426  }
427 
428  // "<p>red</p>" would not match "red" even with distance of 5
429  $answertext = strip_tags($answertext);
430 
431  $answerwords = array();
432  if (preg_match_all("/([^\s.]+)/", $answertext, $matches)) {
433  foreach ($matches[1] as $answerword) {
434  array_push($answerwords, trim($answerword));
435  }
436  }
437  foreach ($answerwords as $a_original) {
438  switch ($textrating) {
440  if (levenshtein($a_original, $a_keyword) <= 1) {
441  return true;
442  }
443  break;
445  if (levenshtein($a_original, $a_keyword) <= 2) {
446  return true;
447  }
448  break;
450  if (levenshtein($a_original, $a_keyword) <= 3) {
451  return true;
452  }
453  break;
455  if (levenshtein($a_original, $a_keyword) <= 4) {
456  return true;
457  }
458  break;
460  if (levenshtein($a_original, $a_keyword) <= 5) {
461  return true;
462  }
463  break;
464  }
465  }
466  return $result;
467  }
468 
469  protected function calculateReachedPointsForSolution($solution)
470  {
471  // Return min points when keyword relation is NON KEYWORDS
472  if ($this->getKeywordRelation() == 'non') {
473  return $this->getMinimumPoints();
474  }
475 
476  // Return min points if there are no answers present.
477  $answers = $this->getAnswers();
478 
479  if (count($answers) == 0) {
480  return $this->getMinimumPoints();
481  }
482 
483  switch ($this->getKeywordRelation()) {
484  case 'any':
485 
486  $points = 0;
487 
488  foreach ($answers as $answer) {
489  $qst_answer = $answer->getAnswertext();
490  $user_answer = ' ' . $solution;
491 
492  if ($this->isKeywordMatching($user_answer, $qst_answer)) {
493  $points += $answer->getPoints();
494  }
495  }
496 
497  break;
498 
499  case 'all':
500 
501  $points = $this->getMaximumPoints();
502 
503  foreach ($answers as $answer) {
504  $qst_answer = $answer->getAnswertext();
505  $user_answer = ' ' . $solution;
506 
507  if (!$this->isKeywordMatching($user_answer, $qst_answer)) {
508  $points = 0;
509  break;
510  }
511  }
512 
513  break;
514 
515  case 'one':
516 
517  $points = 0;
518 
519  foreach ($answers as $answer) {
520  $qst_answer = $answer->getAnswertext();
521  $user_answer = ' ' . $solution;
522 
523  if ($this->isKeywordMatching($user_answer, $qst_answer)) {
524  $points = $this->getMaximumPoints();
525  break;
526  }
527  }
528 
529  break;
530  }
531 
532  return $points;
533  }
534 
545  public function calculateReachedPoints($active_id, $pass = null, $authorizedSolution = true, $returndetails = false)
546  {
547  if ($returndetails) {
548  throw new ilTestException('return details not implemented for ' . __METHOD__);
549  }
550 
551  global $ilDB;
552 
553  $points = 0;
554  if (is_null($pass)) {
555  $pass = $this->getSolutionMaxPass($active_id);
556  }
557 
558  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
559 
560  // Return min points when no answer was given.
561  if ($ilDB->numRows($result) == 0) {
562  return $this->getMinimumPoints();
563  }
564 
565  // Return points of points are already on the row.
566  $row = $ilDB->fetchAssoc($result);
567  if ($row["points"] != null) {
568  return $row["points"];
569  }
570 
571  return $this->calculateReachedPointsForSolution($row['value1']);
572  }
573 
582  public function saveWorkingData($active_id, $pass = null, $authorized = true)
583  {
584  global $ilDB;
585  global $ilUser;
586 
587  include_once "./Services/Utilities/classes/class.ilStr.php";
588  if (is_null($pass)) {
589  include_once "./Modules/Test/classes/class.ilObjTest.php";
590  $pass = ilObjTest::_getPass($active_id);
591  }
592 
593  $entered_values = 0;
594  $text = $this->getSolutionSubmit();
595 
596  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $active_id, $pass, $authorized, $text) {
597  $this->removeCurrentSolution($active_id, $pass, $authorized);
598 
599  if (strlen($text)) {
600  $this->saveCurrentSolution($active_id, $pass, trim($text), null, $authorized);
601  $entered_values++;
602  }
603  });
604 
605  if ($entered_values) {
606  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
608  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
609  }
610  } else {
611  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
613  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
614  }
615  }
616 
617  return true;
618  }
619 
623  public function getSolutionSubmit()
624  {
625  $text = ilUtil::stripSlashes($_POST["TEXT"], false);
626 
627  if (ilUtil::isHTML($text)) {
628  $text = $this->getHtmlUserSolutionPurifier()->purify($text);
629  }
630 
631  return $text;
632  }
633 
634  public function saveAdditionalQuestionDataToDb()
635  {
637  global $ilDB;
638  $ilDB->manipulateF(
639  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
640  array( "integer" ),
641  array( $this->getId()
642  )
643  );
644 
645  $ilDB->manipulateF(
646  "INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, maxnumofchars, keywords,
647  textgap_rating, matchcondition, keyword_relation) VALUES (%s, %s, %s, %s, %s, %s)",
648  array( "integer", "integer", "text", "text", 'integer', 'text' ),
649  array(
650  $this->getId(),
651  $this->getMaxNumOfChars(),
652  null,
653  $this->getTextRating(),
654  $this->matchcondition,
655  $this->getKeywordRelation()
656  )
657  );
658  }
659 
660  public function saveAnswerSpecificDataToDb()
661  {
663  global $ilDB;
664 
665  $ilDB->manipulateF(
666  "DELETE FROM qpl_a_essay WHERE question_fi = %s",
667  array( "integer" ),
668  array( $this->getId() )
669  );
670 
671  foreach ($this->answers as $answer) {
673  $nextID = $ilDB->nextId('qpl_a_essay');
674  $ilDB->manipulateF(
675  "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) VALUES (%s, %s, %s, %s)",
676  array( "integer", "integer", "text", 'float' ),
677  array(
678  $nextID,
679  $this->getId(),
680  $answer->getAnswertext(),
681  $answer->getPoints()
682  )
683  );
684  }
685  }
686 
690  protected function reworkWorkingData($active_id, $pass, $obligationsAnswered, $authorized)
691  {
692  // nothing to rework!
693  }
694 
695  public function createRandomSolution($test_id, $user_id)
696  {
697  }
698 
705  public function getQuestionType()
706  {
707  return "assTextQuestion";
708  }
709 
717  public function getTextRating()
718  {
719  return $this->text_rating;
720  }
721 
729  public function setTextRating($a_text_rating)
730  {
731  switch ($a_text_rating) {
739  $this->text_rating = $a_text_rating;
740  break;
741  default:
742  $this->text_rating = TEXTGAP_RATING_CASEINSENSITIVE;
743  break;
744  }
745  }
746 
753  public function getAdditionalTableName()
754  {
755  return "qpl_qst_essay";
756  }
757 
762  public function getRTETextWithMediaObjects()
763  {
764  return parent::getRTETextWithMediaObjects();
765  }
766 
770  public function setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
771  {
772  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
773 
774  $solutions = $this->getSolutionValues($active_id, $pass);
775 
776  $i = 1;
777  $worksheet->setCell($startrow + $i, 0, $this->lng->txt("result"));
778  $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
779 
780  require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
781  $assessment_folder = new ilObjAssessmentFolder();
782 
783  $string_escaping_org_value = $worksheet->getStringEscaping();
784  if ($assessment_folder->getExportEssayQuestionsWithHtml() == 1) {
785  $worksheet->setStringEscaping(false);
786  }
787 
788  if (strlen($solutions[0]["value1"])) {
789  $worksheet->setCell($startrow + $i, 1, $solutions[0]["value1"]);
790  }
791  $i++;
792 
793  $worksheet->setStringEscaping($string_escaping_org_value);
794  return $startrow + $i + 1;
795  }
796 
800  public function toJSON()
801  {
802  include_once("./Services/RTE/classes/class.ilRTE.php");
803  $result = array();
804  $result['id'] = (int) $this->getId();
805  $result['type'] = (string) $this->getQuestionType();
806  $result['title'] = (string) $this->getTitle();
807  $result['question'] = $this->formatSAQuestion($this->getQuestion());
808  $result['nr_of_tries'] = (int) $this->getNrOfTries();
809  $result['shuffle'] = (bool) $this->getShuffle();
810  $result['maxlength'] = (int) $this->getMaxNumOfChars();
811  return json_encode($result);
812  }
813 
814  public function getAnswerCount()
815  {
816  return count($this->answers);
817  }
818 
832  public function addAnswer(
833  $answertext = "",
834  $points = 0.0,
835  $points_unchecked = 0.0,
836  $order = 0,
837  $answerimage = ""
838  ) {
839  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
840 
841  // add answer
842  $answer = new ASS_AnswerMultipleResponseImage($answertext, $points);
843  $this->answers[] = $answer;
844  }
845 
846  public function getAnswers()
847  {
848  return $this->answers;
849  }
850 
860  public function getAnswer($index = 0)
861  {
862  if ($index < 0) {
863  return null;
864  }
865  if (count($this->answers) < 1) {
866  return null;
867  }
868  if ($index >= count($this->answers)) {
869  return null;
870  }
871 
872  return $this->answers[$index];
873  }
874 
883  public function deleteAnswer($index = 0)
884  {
885  if ($index < 0) {
886  return;
887  }
888  if (count($this->answers) < 1) {
889  return;
890  }
891  if ($index >= count($this->answers)) {
892  return;
893  }
894  $answer = $this->answers[$index];
895  if (strlen($answer->getImage())) {
896  $this->deleteImage($answer->getImage());
897  }
898  unset($this->answers[$index]);
899  $this->answers = array_values($this->answers);
900  for ($i = 0; $i < count($this->answers); $i++) {
901  if ($this->answers[$i]->getOrder() > $index) {
902  $this->answers[$i]->setOrder($i);
903  }
904  }
905  }
906 
907  public function getAnswerTableName()
908  {
909  return 'qpl_a_essay';
910  }
911 
918  public function flushAnswers()
919  {
920  $this->answers = array();
921  }
922 
923  public function setAnswers($answers)
924  {
925  if (isset($answers['answer'])) {
926  $count = count($answers['answer']);
927  $withPoints = true;
928  } else {
929  $count = count($answers);
930  $withPoints = false;
931  }
932 
933  $this->flushAnswers();
934 
935  for ($i = 0; $i < $count; $i++) {
936  if ($withPoints) {
937  $this->addAnswer($answers['answer'][$i], $answers['points'][$i]);
938  } else {
939  $this->addAnswer($answers[$i], 0);
940  }
941  }
942  }
943 
945  {
946  global $ilDB;
947 
948  $result = $ilDB->queryF(
949  "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
950  array('integer'),
952  );
953  if ($result->numRows()) {
954  while ($row = $ilDB->fetchAssoc($result)) {
955  $next_id = $ilDB->nextId('qpl_a_essay');
956  $affectedRows = $ilDB->manipulateF(
957  "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points)
958  VALUES (%s, %s, %s, %s)",
959  array('integer','integer','text','float'),
960  array($next_id, $this->getId(), $row["answertext"], $row["points"])
961  );
962  }
963  }
964  }
965 
966  public function getKeywordRelation()
967  {
969  }
970 
975  public function setKeywordRelation($a_relation)
976  {
977  $this->keyword_relation = $a_relation;
978  }
979 
980  public static function getValidScoringModes()
981  {
982  return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
983  }
984 
985  public static function getScoringModesWithPointsByQuestion()
986  {
987  return array('non', 'all', 'one');
988  }
989 
990  public static function getScoringModesWithPointsByKeyword()
991  {
992  return array('any');
993  }
994 
995 
1006  public function isAnswered($active_id, $pass = null)
1007  {
1008  $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1009 
1010  return $numExistingSolutionRecords > 0;
1011  }
1012 
1023  public static function isObligationPossible($questionId)
1024  {
1025  return true;
1026  }
1027 
1028  public function countLetters($text)
1029  {
1030  $text = strip_tags($text);
1031 
1032  $text = str_replace('&gt;', '>', $text);
1033  $text = str_replace('&lt;', '<', $text);
1034  $text = str_replace('&nbsp;', ' ', $text);
1035  $text = str_replace('&amp;', '&', $text);
1036 
1037  $text = str_replace("\r\n", "\n", $text);
1038  $text = str_replace("\n", "", $text);
1039 
1040  return ilStr::strLen($text);
1041  }
1042 }
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assTextQuestion.
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getId()
Gets the id of the assQuestion object.
Add rich text string
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{}
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
const TEXTGAP_RATING_LEVENSHTEIN5
$worksheet
static strLen($a_string)
Definition: class.ilStr.php:78
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static getScoringModesWithPointsByKeyword()
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
static strPos($a_haystack, $a_needle, $a_offset=null)
Definition: class.ilStr.php:30
$result
isAnswered($active_id, $pass=null)
returns boolean wether the question is answered during test pass or not
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...
isComplete()
Returns true, if a multiple choice question is complete for use.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file.
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.
loadFromDb($question_id)
Loads a assTextQuestion object from a database.
saveToDb($original_id="")
Saves a assTextQuestion object to a database.
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
copyObject($target_questionpool_id, $title="")
Copies an assTextQuestion object.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
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
$index
Definition: metadata.php:60
toJSON()
Returns a JSON representation of the question.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setShuffle($shuffle=true)
Sets the shuffle flag.
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.
getShuffle()
Gets the shuffle flag.
Base Exception for all Exceptions relating to Modules/Test.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
static _getLogLanguage()
retrieve the log language for assessment logging
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assTextQuestion constructor
setAuthor($author="")
Sets the authors name of the assQuestion object.
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
isValidTextRating($textRating)
const TEXTGAP_RATING_LEVENSHTEIN3
Class for text questions.
calculateReachedPointsForSolution($solution)
duplicateAnswers($original_id)
flushAnswers()
Deletes all answers.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
Class ilObjAssessmentFolder.
static getScoringModesWithPointsByQuestion()
const TEXTGAP_RATING_CASESENSITIVE
$text
Definition: errorreport.php:18
setKeywordRelation($a_relation)
This method implements a default behaviour.
Interface ilObjAnswerScoringAdjustable.
setTextRating($a_text_rating)
Sets the rating option for text comparisons.
getQuestion()
Gets the question string of the question object.
$ilUser
Definition: imgupload.php:18
setMaxNumOfChars($maxchars=0)
Sets the maximum number of characters for the text solution.
getQuestionType()
Returns the question type of the question.
setReachedPoints($active_id, $points, $pass=null)
Sets the points, a learner has reached answering the question.
isKeywordMatching($answertext, $a_keyword)
Checks if one of the keywords matches the answertext.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getAnswer($index=0)
Returns an answer with a given index.
Create styles array
The data for the language used.
deleteAnswer($index=0)
Deletes an answer with a given index.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
setPoints($a_points)
Sets the maximum available points for the question.
addAnswer( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="")
Adds a possible answer for a multiple choice question.
saveQuestionDataToDb($original_id="")
getMaxNumOfChars()
Gets the maximum number of characters for the text solution.
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
setQuestion($question="")
Sets the question string of the question object.
Interface ilObjQuestionScoringAdjustable.
removeCurrentSolution($active_id, $pass, $authorized=true)
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...
$i
Definition: disco.tpl.php:19
getTitle()
Gets the title string of the assQuestion object.
static isHTML($a_text)
Checks if a given string contains HTML or not.
getTextRating()
Returns the rating option for text comparisons.
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.
$_POST["username"]
static isObligationPossible($questionId)
returns boolean wether it is possible to set this question type as obligatory or not considering the ...
reworkWorkingData($active_id, $pass, $obligationsAnswered, $authorized)
{}
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
const TEXTGAP_RATING_CASEINSENSITIVE
createRandomSolution($test_id, $user_id)