19 declare(strict_types=1);
   100         if (strlen($this->title)
   120         $result = $this->db->queryF(
   125         if ($this->db->numRows($result) == 1) {
   126             $data = $this->db->fetchAssoc($result);
   127             $this->
setId($question_id);
   130             $this->
setComment((
string) $data[
"description"]);
   134             $this->
setPoints((
float) $data[
"points"]);
   141             $this->matchcondition = (isset($data[
'matchcondition'])) ? (
int) $data[
'matchcondition'] : 0;
   156         $result = $this->db->queryF(
   157             'SELECT * FROM qpl_a_essay WHERE question_fi = %s',
   163         while ($row = $this->db->fetchAssoc($result)) {
   164             $this->
addAnswer($row[
'answertext'] ?? 
'', $row[
'points'] ?? 0.0);
   167         parent::loadFromDb($question_id);
   177         $this->max_num_of_chars = $maxchars;
   198         if (in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
   199             return parent::getPoints();
   204         foreach ($this->answers as $answer) {
   205             if ($answer->getPoints() > 0) {
   215         if (in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
   221         foreach ($this->answers as $answer) {
   222             if ($answer->getPoints() < 0) {
   232         switch ($textRating) {
   261         switch ($textrating) {
   275         $answertext = strip_tags($answertext);
   277         if (preg_match_all(
"/([^\s.]+)/", $answertext, $matches)) {
   278             foreach ($matches[1] as $answerword) {
   279                 array_push($answerwords, trim($answerword));
   284         switch ($textrating) {
   286                 $transformation = 
$refinery->string()->levenshtein()->standard($a_keyword, 1);
   289                 $transformation = 
$refinery->string()->levenshtein()->standard($a_keyword, 2);
   292                 $transformation = 
$refinery->string()->levenshtein()->standard($a_keyword, 3);
   295                 $transformation = 
$refinery->string()->levenshtein()->standard($a_keyword, 4);
   298                 $transformation = 
$refinery->string()->levenshtein()->standard($a_keyword, 5);
   303         foreach ($answerwords as $a_original) {
   304             if (isset($transformation) && $transformation->transform($a_original) >= 0) {
   313         $decoded_solution = html_entity_decode($solution);
   322         if ($answers === []) {
   329                 foreach ($answers as $answer) {
   330                     $qst_answer = $answer->getAnswertext();
   331                     $user_answer = 
'  ' . $decoded_solution;
   333                         $points += $answer->getPoints();
   339                 foreach ($answers as $answer) {
   340                     $qst_answer = $answer->getAnswertext();
   341                     $user_answer = 
'  ' . $decoded_solution;
   349                 foreach ($answers as $answer) {
   350                     $qst_answer = $answer->getAnswertext();
   351                     $user_answer = 
'  ' . $decoded_solution;
   364         bool $authorized_solution = 
true   366         if ($pass === null) {
   373         if ($this->db->numRows($result) === 0) {
   378         $row = $this->db->fetchAssoc($result);
   379         if ($row[
'points'] !== null) {
   380             return (
float) $row[
"points"];
   389         bool $authorized = 
true   391         if ($pass === null) {
   397             function () use ($answer, $active_id, $pass, $authorized) {
   400                 if ($answer !== 
'') {
   411         $text = $this->questionpool_request->string(
'TEXT', 
'');
   415             : htmlentities(
$text);
   422         $this->db->manipulateF(
   429             'question_fi' => [
'integer', $this->
getId()],
   432             'keywords' => [
'text', null],
   443         $this->db->manipulateF(
   444             "DELETE FROM qpl_a_essay WHERE question_fi = %s",
   449         foreach ($this->answers as $answer) {
   451             $nextID = $this->db->nextId(
'qpl_a_essay');
   452             $this->db->manipulateF(
   453                 "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) VALUES (%s, %s, %s, %s)",
   454                 [
'integer', 
'integer', 
'text', 
'float'],
   458                     $answer->getAnswertext(),
   467         return "assTextQuestion";
   477         switch ($a_text_rating) {
   485                 $this->text_rating = $a_text_rating;
   501         return "qpl_qst_essay";
   510         return parent::getRTETextWithMediaObjects();
   519         $result[
'id'] = $this->
getId();
   526         return json_encode($result);
   531         return count($this->answers);
   550         $points_unchecked = 0.0,
   580         if (count($this->answers) < 1) {
   583         if ($index >= count($this->answers)) {
   587         return $this->answers[$index];
   603         if (count($this->answers) < 1) {
   606         if ($index >= count($this->answers)) {
   609         $answer = $this->answers[$index];
   613         unset($this->answers[$index]);
   614         $this->answers = array_values($this->answers);
   615         for ($i = 0, $iMax = count($this->answers); $i < $iMax; $i++) {
   616             if ($this->answers[$i]->
getOrder() > $index) {
   617                 $this->answers[$i]->setOrder($i);
   624         return 'qpl_a_essay';
   640         if (isset($answers[
'answer'])) {
   641             $count = count($answers[
'answer']);
   644             $count = count($answers);
   650         for ($i = 0; $i < $count; $i++) {
   652                 $points = $this->
refinery->kindlyTo()->float()->transform($answers[
'points'][$i]);
   662         $result = $this->db->queryF(
   663             "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
   667         if ($result->numRows()) {
   668             while ($row = $this->db->fetchAssoc($result)) {
   669                 $next_id = $this->db->nextId(
'qpl_a_essay');
   670                 $affectedRows = $this->db->manipulateF(
   671                     "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points)   672                                          VALUES (%s, %s, %s, %s)",
   673                     [
'integer',
'integer',
'text',
'float'],
   674                     [$next_id, $this->
getId(), $row[
"answertext"], $row[
"points"]]
   691         if ($relation !== null) {
   698         return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
   704             self::SCORING_MODE_KEYWORD_RELATION_NONE,
   705             self::SCORING_MODE_KEYWORD_RELATION_ALL,
   706             self::SCORING_MODE_KEYWORD_RELATION_ONE
   713             self::SCORING_MODE_KEYWORD_RELATION_ANY
   739         $text = preg_replace(
'/[.,:;!?\-_#\'"+*\\/=()&%§$]/m', 
'', 
$text);
   745         return count(explode(
' ', 
$text));
   750         $question_fi = $this->
getId();
   753         $cntresult = $this->db->query(
   755             SELECT count(solution_id) cnt   757             WHERE active_fi = ' . $this->db->quote($active_id, 
'int') . 
'   758             AND question_fi = ' . $this->db->quote($this->
getId(), 
'int') . 
'   759             AND authorized = ' . $this->db->quote(0, 
'int')
   760             . 
' AND pass = ' . $this->db->quote($pass, 
'int')
   762         $row = $this->db->fetchAssoc($cntresult);
   763         if ($row[
'cnt'] > 0) {
   764             $tresult = $this->db->query(
   768             WHERE active_fi = ' . $this->db->quote($active_id, 
'int') . 
'   769             AND question_fi = ' . $this->db->quote($this->
getId(), 
'int') . 
'   770             AND authorized = ' . $this->db->quote(0, 
'int')
   771             . 
' AND pass = ' . $this->db->quote($pass, 
'int')
   773             $trow = $this->db->fetchAssoc($tresult);
   774             return $trow[
'value1'];
   782             AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->
getQuestionType(),
   785             AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->
getMaximumPoints(),
   786             AdditionalInformationGenerator::KEY_QUESTION_TEXT_WORDCOUNT_ENABLED => $additional_info
   788             AdditionalInformationGenerator::KEY_QUESTION_MAXCHARS => $this->
getMaxNumOfChars(),
   789             AdditionalInformationGenerator::KEY_QUESTION_TEXT_SCORING_MODE => $additional_info->
getTagForLangVar(
   792             AdditionalInformationGenerator::KEY_QUESTION_CORRECT_ANSWER_OPTIONS => 
array_map(
   794                     AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION => $answer->
getAnswertext(),
   795                     AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $answer->
getPoints() === 0.0 ? 
'' : $answer->
getPoints()
   799             AdditionalInformationGenerator::KEY_FEEDBACK => [
   800                 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), 
false)),
   801                 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), 
true))
   808         switch ($scoring_mode) {
   810                 return 'essay_scoring_mode_without_keywords';
   812                 return 'essay_scoring_mode_keyword_relation_any';
   814                 return 'essay_scoring_mode_keyword_relation_all';
   816                 return 'essay_scoring_mode_keyword_relation_one';
   824         array $solution_values
   826         if (!array_key_exists(0, $solution_values)
   827             || !array_key_exists(
'value1', $solution_values[0])) {
   830         return $this->
refinery->string()->stripTags()->transform(
   831             html_entity_decode($solution_values[0][
'value1'])
   837         if (!array_key_exists(0, $solution_values)
   838             || !array_key_exists(
'value1', $solution_values[0])) {
   841         return $solution_values[0][
'value1'];
   847             case self::SCORING_MODE_KEYWORD_RELATION_NONE:
 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...
 
setNrOfTries(int $a_nr_of_tries)
 
static getInstance($identifier)
 
toLog(AdditionalInformationGenerator $additional_info)
 
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test. 
 
static getScoringModesWithPointsByKeyword()
 
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table. 
 
getLatestAutosaveContent(int $active_id, int $pass)
 
const SCORING_MODE_KEYWORD_RELATION_ALL
 
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor. 
 
static isHTML(string $a_text)
Checks if a given string contains HTML or not. 
 
saveWorkingData(int $active_id, ?int $pass=null, bool $authorized=true)
 
static strPos(string $a_haystack, string $a_needle, int $a_offset=0)
 
const TEXTGAP_RATING_LEVENSHTEIN3
 
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
 
setMaxNumOfChars(int $maxchars=0)
 
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file. 
 
loadFromDb(int $question_id)
 
bool $word_counter_enabled
 
calculateReachedPointsForSolution(string $solution)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
const TEXTGAP_RATING_CASEINSENSITIVE
 
const SCORING_MODE_KEYWORD_RELATION_ONE
 
const TEXTGAP_RATING_LEVENSHTEIN5
 
static getValidScoringModes()
 
toJSON()
Returns a JSON representation of the question. 
 
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
const TEXTGAP_RATING_LEVENSHTEIN2
 
setComment(string $comment="")
 
const TEXTGAP_RATING_CASESENSITIVE
 
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question. 
 
const TEXTGAP_RATING_LEVENSHTEIN1
 
setWordCounterEnabled(bool $word_counter_enabled)
 
solutionValuesToLog(AdditionalInformationGenerator $additional_info, array $solution_values)
 
static strLen(string $a_string)
 
getPoints()
Gets the points. 
 
getScoringModeLangVar(string $scoring_mode)
 
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
isValidTextRating($textRating)
 
Class for text questions. 
 
setMatchcondition(int $matchcondition)
 
duplicateAnswers($original_id)
 
flushAnswers()
Deletes all answers. 
 
static getScoringModesWithPointsByQuestion()
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
setTextRating($a_text_rating)
 
getHtmlUserSolutionPurifier()
 
__construct(string $title="", string $comment="", string $author="", int $owner=-1, string $question="")
assTextQuestion constructor 
 
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. 
 
saveQuestionDataToDb(?int $original_id=null)
 
const HAS_SPECIFIC_FEEDBACK
 
getAnswer($index=0)
Returns an answer with a given index. 
 
getCorrectSolutionForTextOutput(int $active_id, int $pass)
 
deleteAnswer($index=0)
Deletes an answer with a given index. 
 
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table. 
 
solutionValuesToText(array $solution_values)
 
addAnswer( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="")
Adds a possible answer for a multiple choice question. 
 
setKeywordRelation(?string $relation)
This method implements a default behaviour. 
 
getAnswertext()
Gets the answer text. 
 
getSolutionMaxPass(int $active_id)
 
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
 
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
__construct(Container $dic, ilPlugin $plugin)
 
setOriginalId(?int $original_id)
 
setTitle(string $title="")
 
static strToLower(string $a_string)
 
setLifecycle(ilAssQuestionLifecycle $lifecycle)
 
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
 
setAuthor(string $author="")
 
const SCORING_MODE_KEYWORD_RELATION_NONE
 
saveToDb(?int $original_id=null)
 
setShuffle(?bool $shuffle=true)
 
const SCORING_MODE_KEYWORD_RELATION_ANY
 
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
 
static getDraftInstance()
 
const TEXTGAP_RATING_LEVENSHTEIN4
 
setQuestion(string $question="")