ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
assTextQuestion Class Reference

Class for text questions. More...

+ Inheritance diagram for assTextQuestion:
+ Collaboration diagram for assTextQuestion:

Public Member Functions

 __construct (string $title="", string $comment="", string $author="", int $owner=-1, string $question="")
 assTextQuestion constructor More...
 
 getMatchcondition ()
 
 setMatchcondition (int $matchcondition)
 
 isComplete ()
 
 saveToDb (?int $original_id=null)
 
 loadFromDb (int $question_id)
 
 getMaxNumOfChars ()
 
 setMaxNumOfChars (int $maxchars=0)
 
 isWordCounterEnabled ()
 
 setWordCounterEnabled (bool $word_counter_enabled)
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getMinimumPoints ()
 
 isKeywordMatching ($answertext, $a_keyword)
 Checks if one of the keywords matches the answertext. More...
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 getQuestionType ()
 
 getTextRating ()
 
 setTextRating ($a_text_rating)
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getAnswerCount ()
 
 addAnswer ( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="")
 Adds a possible answer for a multiple choice question. More...
 
 getAnswers ()
 
 getAnswer ($index=0)
 Returns an answer with a given index. More...
 
 deleteAnswer ($index=0)
 Deletes an answer with a given index. More...
 
 getAnswerTableName ()
 
 flushAnswers ()
 Deletes all answers. More...
 
 setAnswers ($answers)
 
 duplicateAnswers ($original_id)
 
 getKeywordRelation ()
 
 setKeywordRelation (?string $relation)
 This method implements a default behaviour. More...
 
 countLetters ($text)
 
 countWords ($text)
 
 getLatestAutosaveContent (int $active_id, int $pass)
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 solutionValuesToText (array $solution_values)
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
- Public Member Functions inherited from assQuestion
 getQuestionType ()
 
 isComplete ()
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 getCurrentUser ()
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML (string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping, array $solutionhints=[])
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 setShuffle (?bool $shuffle=true)
 
 setAuthor (string $author="")
 
 setOwner (int $owner=-1)
 
 getTitle ()
 
 getTitleForHTMLOutput ()
 
 getTitleFilenameCompliant ()
 
 getId ()
 
 getShuffle ()
 
 getTestId ()
 
 getComment ()
 
 getDescriptionForHTMLOutput ()
 
 getThumbSize ()
 
 setThumbSize (int $a_size)
 
 getMinimumThumbSize ()
 
 getMaximumThumbSize ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorized_solution=true)
 
 calculateResultsFromSolution (int $active_id, int $pass)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $preview_session)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 getSuggestedSolutionPath ()
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 getSuggestedSolutionPathWeb ()
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getTestOutputSolutions (int $activeId, int $pass)
 
 getUserSolutionPreferingIntermediate (int $active_id, ?int $pass=null)
 
 getSolutionValues (int $active_id, ?int $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 cloneXHTMLMediaObjectsOfQuestion (int $source_question_id)
 
 createPageObject ()
 
 clonePageOfQuestion (int $a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
static fixSvgToPng (string $imageFilenameContainingString)
 
 fixUnavailableSkinImageSources (string $html)
 
 loadFromDb (int $question_id)
 
 createNewQuestion (bool $a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb (?int $original_id=null)
 
 duplicate (bool $for_test=true, string $title='', string $author='', int $owner=-1, $test_obj_id=null)
 
 copyObject (int $target_parent_id, string $title='')
 
 createNewOriginalFromThisDuplicate (int $target_parent_id, string $target_question_title='')
 
 saveToDb (?int $original_id=null)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 
 resolveInternalLink (string $internal_link)
 
 resolveSuggestedSolutionLinks ()
 
 getInternalLinkHref (string $target)
 
 syncWithOriginal ()
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 isWriteable ()
 
 deductHintPointsFromReachedPoints (ilAssQuestionPreviewSession $preview_session, $reached_points)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $preview_session)
 
 adjustReachedPointsByScoringOptions (float $points, int $active_id)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionTypeID ()
 
 cloneHints (int $source_question_id, int $target_question_id)
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 getNrOfTries ()
 
 setNrOfTries (int $a_nr_of_tries)
 
 setExportImagePath (string $path)
 
 formatSAQuestion ($a_q)
 
 setPreventRteUsage (bool $prevent_rte_usage)
 
 getPreventRteUsage ()
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode (bool $selfassessmenteditingmode)
 
 getSelfAssessmentEditingMode ()
 
 setDefaultNrOfTries (int $defaultnroftries)
 
 getDefaultNrOfTries ()
 
 syncSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 ensureHintPageObjectExists ($pageObjectId)
 
 isAnswered (int $active_id, int $pass)
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange (int $lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 removeCurrentSolution (int $active_id, int $pass, bool $authorized=true)
 
 saveCurrentSolution (int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
 updateCurrentSolution (int $solutionId, $value1, $value2, bool $authorized=true)
 
 updateCurrentSolutionsAuthorization (int $activeId, int $pass, bool $authorized, bool $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 intermediateSolutionExists (int $active_id, int $pass)
 
 authorizedSolutionExists (int $active_id, ?int $pass)
 
 authorizedOrIntermediateSolutionExists (int $active_id, int $pass)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions (int $activeId, int $pass)
 
 resetUsersAnswer (int $activeId, int $pass)
 
 removeResultRecord (int $activeId, int $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $value_pairs)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
 hasWritableOriginalInQuestionPool ()
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 getSolutionForTextOutput (int $active_id, int $pass)
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
 getVariablesAsTextArray (int $active_id, int $pass)
 
- Public Member Functions inherited from ilObjAnswerScoringAdjustable
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 

Static Public Member Functions

static getValidScoringModes ()
 
static getScoringModesWithPointsByQuestion ()
 
static getScoringModesWithPointsByKeyword ()
 
- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $force_pass_results_update_enabled)
 
static isForcePassResultUpdateEnabled ()
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static isFileAvailable (string $file)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static _setReachedPoints (int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $question_id)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
static extendedTrim (string $value)
 Trim non-printable characters from the beginning and end of a string. More...
 

Data Fields

const SCORING_MODE_KEYWORD_RELATION_NONE = 'non'
 
const SCORING_MODE_KEYWORD_RELATION_ANY = 'any'
 
const SCORING_MODE_KEYWORD_RELATION_ALL = 'all'
 
const SCORING_MODE_KEYWORD_RELATION_ONE = 'one'
 
array $keywords
 
array $answers = []
 
- Data Fields inherited from assQuestion
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
const TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
ilAssQuestionFeedback $feedbackOBJ
 
bool $prevent_rte_usage = false
 
bool $selfassessmenteditingmode = false
 
int $defaultnroftries = 0
 
string $questionActionCmd = 'handleQuestionAction'
 
const KEY_VALUES_IMPLOSION_SEPARATOR = ':'
 

Protected Member Functions

 calculateReachedPointsForSolution (string $solution)
 
 getSolutionSubmit ()
 
 solutionValuesToLog (AdditionalInformationGenerator $additional_info, array $solution_values)
 
- Protected Member Functions inherited from assQuestion
 solutionValuesToLog (AdditionalInformationGenerator $additional_info, array $solution_values)
 MUST convert the given solution values into an array or a string that can be stored in the log. More...
 
 solutionValuesToText (array $solution_values)
 MUST convert the given solution values into text. More...
 
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $post_submission_field_name)
 
 savePreviewData (ilAssQuestionPreviewSession $preview_session)
 
 deletePageOfQuestion (int $question_id)
 
 cloneQuestionTypeSpecificProperties (self $target)
 
 removeAllImageFiles (string $image_target_path)
 
 onDuplicate (int $original_parent_id, int $original_question_id, int $duplicate_parent_id, int $duplicate_question_id)
 
 afterSyncWithOriginal (int $original_question_id, int $clone_question_id, int $original_parent_id, int $clone_parent_id)
 
 onCopy (int $sourceParentId, int $sourceQuestionId, int $targetParentId, int $targetQuestionId)
 
 duplicateComments (int $parent_source_id, int $source_id, int $parent_target_id, int $target_id)
 
 deleteComments ()
 
 getNotesManager ()
 
 getNotesDataService ()
 
 getNotesRepo ()
 
 cloneSuggestedSolutions (int $source_question_id, int $target_question_id)
 
 duplicateSuggestedSolutionFiles (int $parent_id, int $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 cloneSuggestedSolutionFiles (int $source_question_id, int $target_question_id)
 
 copySuggestedSolutions (int $target_question_id)
 
 ensureNonNegativePoints (float $points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints (int $original_question_id, int $duplicate_question_id)
 
 duplicateSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet (int $active_id, int $pass, bool $authorized=true)
 
 removeSolutionRecordById (int $solutionId)
 
 getSolutionRecordById (int $solutionId)
 
 deleteDummySolutionRecord (int $activeId, int $passIndex)
 
 isDummySolutionRecord (array $solutionRecord)
 
 deleteSolutionRecordByValues (int $activeId, int $passIndex, bool $authorized, array $matchValues)
 
 duplicateIntermediateSolutionAuthorized (int $activeId, int $passIndex)
 
 forceExistingIntermediateSolution (int $activeId, int $passIndex, bool $considerDummyRecordCreation)
 
 lookupMaxStep (int $active_id, int $pass)
 
 buildTestPresentationConfig ()
 
 getSuggestedSolutionsRepo ()
 
 loadSuggestedSolutions ()
 
 answerToLog (AdditionalInformationGenerator $additional_info, int $active_id, int $pass)
 

Protected Attributes

const HAS_SPECIFIC_FEEDBACK = false
 
- Protected Attributes inherited from assQuestion
const HAS_SPECIFIC_FEEDBACK = true
 
GeneralQuestionPropertiesRepository $questionrepository
 
RequestDataCollector $questionpool_request
 
QuestionFiles $question_files
 
ilAssQuestionProcessLocker $processLocker
 
ilTestQuestionConfig $testQuestionConfig
 
SuggestedSolutionsDatabaseRepository $suggestedsolution_repo
 
ILIAS $ilias
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
ilDBInterface $db
 
ilObjUser $current_user
 
SkillUsageService $skillUsageService
 
HTTPServices $http
 
Refinery $refinery
 
Transformation $shuffler
 
LoggingServices $log
 
Container $dic
 
ilAssQuestionLifecycle $lifecycle
 
ilAssQuestionPage $page
 
int $id
 
string $title
 
string $comment
 
int $owner
 
string $author
 
int $thumb_size
 
string $question
 
float $points = 0.0
 
bool $shuffle = true
 
int $test_id
 
int $obj_id = 0
 
int $original_id = null
 
int $lastChange = null
 
string $external_id = null
 
int $step = null
 
array $suggested_solutions
 

Private Member Functions

 isValidTextRating ($textRating)
 
 getScoringModeLangVar (string $scoring_mode)
 

Private Attributes

int $max_num_of_chars = 0
 
bool $word_counter_enabled = false
 
string $text_rating = assClozeGap::TEXTGAP_RATING_CASEINSENSITIVE
 
int $matchcondition = 0
 
string $keyword_relation = self::SCORING_MODE_KEYWORD_RELATION_NONE
 

Additional Inherited Members

- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 
- Static Protected Attributes inherited from assQuestion
static $force_pass_results_update_enabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

Class for text questions.

assTextQuestion is a class for text questions

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 38 of file class.assTextQuestion.php.

Constructor & Destructor Documentation

◆ __construct()

assTextQuestion::__construct ( string  $title = "",
string  $comment = "",
string  $author = "",
int  $owner = -1,
string  $question = "" 
)

assTextQuestion constructor

The constructor takes possible arguments an creates an instance of the assTextQuestion object.

Parameters
string$titleA title string to describe the question
string$commentA comment string to describe the question
string$authorA string containing the name of the questions author
integer$ownerA numerical ID to identify the owner/creator
string$questionThe question string of the text question

Definition at line 77 of file class.assTextQuestion.php.

References assQuestion\$author, assQuestion\$comment, assQuestion\$owner, assQuestion\$question, assQuestion\$title, and ILIAS\GlobalScreen\Provider\__construct().

83  {
85  $this->points = 1;
86  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswer()

assTextQuestion::addAnswer (   $answertext = "",
  $points = 0.0,
  $points_unchecked = 0.0,
  $order = 0,
  $answerimage = "" 
)

Adds a possible answer for a multiple choice question.

A ASS_AnswerBinaryStateImage object will be created and assigned to the array $this->answers.

Parameters
string$answertextThe answer text
double$pointsThe points for selecting the answer (even negative points can be used)
boolean$stateDefines the answer as correct (TRUE) or incorrect (FALSE)
integer$orderA possible display order of the answer
double$pointsThe points for not selecting the answer (even negative points can be used) public
See also
$answers
ASS_AnswerBinaryStateImage

Definition at line 547 of file class.assTextQuestion.php.

References assQuestion\$points.

Referenced by loadFromDb(), and setAnswers().

553  : void {
554  $this->answers[] = new ASS_AnswerMultipleResponseImage($answertext, $points);
555  }
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file.
+ Here is the caller graph for this function:

◆ calculateReachedPoints()

assTextQuestion::calculateReachedPoints ( int  $active_id,
?int  $pass = null,
bool  $authorized_solution = true 
)

Definition at line 361 of file class.assTextQuestion.php.

References calculateReachedPointsForSolution(), assQuestion\getCurrentSolutionResultSet(), getMinimumPoints(), assQuestion\getSolutionMaxPass(), and null.

365  : float {
366  if ($pass === null) {
367  $pass = $this->getSolutionMaxPass($active_id);
368  }
369 
370  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
371 
372  // Return min points when no answer was given.
373  if ($this->db->numRows($result) === 0) {
374  return $this->getMinimumPoints();
375  }
376 
377  // Return points of points are already on the row.
378  $row = $this->db->fetchAssoc($result);
379  if ($row['points'] !== null) {
380  return (float) $row["points"];
381  }
382 
383  return $this->calculateReachedPointsForSolution($row['value1']);
384  }
calculateReachedPointsForSolution(string $solution)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getSolutionMaxPass(int $active_id)
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assTextQuestion::calculateReachedPointsForSolution ( string  $solution)
protected

Definition at line 311 of file class.assTextQuestion.php.

References assQuestion\$points, getAnswers(), getKeywordRelation(), getMaximumPoints(), getMinimumPoints(), and isKeywordMatching().

Referenced by calculateReachedPoints().

311  : float
312  {
313  $decoded_solution = html_entity_decode($solution);
314  // Return min points when keyword relation is NON KEYWORDS
315  if ($this->getKeywordRelation() === self::SCORING_MODE_KEYWORD_RELATION_NONE) {
316  return $this->getMinimumPoints();
317  }
318 
319  // Return min points if there are no answers present.
320  $answers = $this->getAnswers();
321 
322  if ($answers === []) {
323  return $this->getMinimumPoints();
324  }
325 
326  switch ($this->getKeywordRelation()) {
327  case 'any':
328  $points = 0.0;
329  foreach ($answers as $answer) {
330  $qst_answer = $answer->getAnswertext();
331  $user_answer = ' ' . $decoded_solution;
332  if ($this->isKeywordMatching($user_answer, $qst_answer)) {
333  $points += $answer->getPoints();
334  }
335  }
336  return $points;
337 
338  case 'all':
339  foreach ($answers as $answer) {
340  $qst_answer = $answer->getAnswertext();
341  $user_answer = ' ' . $decoded_solution;
342  if (!$this->isKeywordMatching($user_answer, $qst_answer)) {
343  return 0.0;
344  }
345  }
346  return $this->getMaximumPoints();
347 
348  case 'one':
349  foreach ($answers as $answer) {
350  $qst_answer = $answer->getAnswertext();
351  $user_answer = ' ' . $decoded_solution;
352  if ($this->isKeywordMatching($user_answer, $qst_answer)) {
353  return $this->getMaximumPoints();
354  }
355  }
356  }
357 
358  return 0.0;
359  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
isKeywordMatching($answertext, $a_keyword)
Checks if one of the keywords matches the answertext.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countLetters()

assTextQuestion::countLetters (   $text)

Definition at line 719 of file class.assTextQuestion.php.

References ilStr\strLen().

719  : int
720  {
721  $text = strip_tags($text);
722 
723  $text = str_replace('>', '>', $text);
724  $text = str_replace('&lt;', '<', $text);
725  $text = str_replace('&nbsp;', ' ', $text);
726  $text = str_replace('&amp;', '&', $text);
727 
728  $text = str_replace("\r\n", "\n", $text);
729  $text = str_replace("\n", "", $text);
730 
731  return ilStr::strLen($text);
732  }
static strLen(string $a_string)
Definition: class.ilStr.php:63
+ Here is the call graph for this function:

◆ countWords()

assTextQuestion::countWords (   $text)

Definition at line 734 of file class.assTextQuestion.php.

734  : int
735  {
736  if ($text === '') {
737  return 0;
738  }
739  $text = str_replace('&nbsp;', ' ', $text);
740 
741  $text = preg_replace('/[.,:;!?\-_#\'"+*\\/=()&%§$]/m', '', $text);
742 
743  $text = preg_replace('/^\s*/m', '', $text);
744  $text = preg_replace('/\s*$/m', '', $text);
745  $text = preg_replace('/\s+/m', ' ', $text);
746 
747  return count(explode(' ', $text));
748  }

◆ deleteAnswer()

assTextQuestion::deleteAnswer (   $index = 0)

Deletes an answer with a given index.

The index of the first answer is 0, the index of the second answer is 1 and so on.

Parameters
integer$indexA nonnegative index of the n-th answer public
See also
$answers

Definition at line 598 of file class.assTextQuestion.php.

References ILIAS\UI\Implementation\Component\Table\getOrder().

598  : void
599  {
600  if ($index < 0) {
601  return;
602  }
603  if (count($this->answers) < 1) {
604  return;
605  }
606  if ($index >= count($this->answers)) {
607  return;
608  }
609  $answer = $this->answers[$index];
610  //if (strlen($answer->getImage())) {
611  // $this->deleteImage($answer->getImage());
612  //}
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);
618  }
619  }
620  }
+ Here is the call graph for this function:

◆ duplicateAnswers()

assTextQuestion::duplicateAnswers (   $original_id)

Definition at line 662 of file class.assTextQuestion.php.

References assQuestion\$original_id, and assQuestion\getId().

662  : void
663  {
664  $result = $this->db->queryF(
665  "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
666  ['integer'],
667  [$original_id]
668  );
669  if ($result->numRows()) {
670  while ($row = $this->db->fetchAssoc($result)) {
671  $next_id = $this->db->nextId('qpl_a_essay');
672  $affectedRows = $this->db->manipulateF(
673  "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points)
674  VALUES (%s, %s, %s, %s)",
675  ['integer','integer','text','float'],
676  [$next_id, $this->getId(), $row["answertext"], $row["points"]]
677  );
678  }
679  }
680  }
+ Here is the call graph for this function:

◆ flushAnswers()

assTextQuestion::flushAnswers ( )

Deletes all answers.

public

See also
$answers

Definition at line 633 of file class.assTextQuestion.php.

Referenced by loadFromDb(), and setAnswers().

633  : void
634  {
635  $this->answers = [];
636  }
+ Here is the caller graph for this function:

◆ getAdditionalTableName()

assTextQuestion::getAdditionalTableName ( )

Returns the name of the additional question data table in the database.

Returns
string The additional table name public

Definition at line 499 of file class.assTextQuestion.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

499  : string
500  {
501  return "qpl_qst_essay";
502  }
+ Here is the caller graph for this function:

◆ getAnswer()

assTextQuestion::getAnswer (   $index = 0)

Returns an answer with a given index.

The index of the first answer is 0, the index of the second answer is 1 and so on.

Parameters
integer$indexA nonnegative index of the n-th answer
Returns
object ASS_AnswerBinaryStateImage-Object containing the answer public
See also
$answers

Definition at line 575 of file class.assTextQuestion.php.

References null.

576  {
577  if ($index < 0) {
578  return null;
579  }
580  if (count($this->answers) < 1) {
581  return null;
582  }
583  if ($index >= count($this->answers)) {
584  return null;
585  }
586 
587  return $this->answers[$index];
588  }
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getAnswerCount()

assTextQuestion::getAnswerCount ( )

Definition at line 529 of file class.assTextQuestion.php.

529  : int
530  {
531  return count($this->answers);
532  }

◆ getAnswers()

assTextQuestion::getAnswers ( )
Returns
array<ASS_AnswerMultipleResponseImage>

Definition at line 561 of file class.assTextQuestion.php.

References $answers.

Referenced by calculateReachedPointsForSolution(), getCorrectSolutionForTextOutput(), and toLog().

561  : array
562  {
563  return $this->answers;
564  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assTextQuestion::getAnswerTableName ( )

Definition at line 622 of file class.assTextQuestion.php.

622  : string
623  {
624  return 'qpl_a_essay';
625  }

◆ getCorrectSolutionForTextOutput()

assTextQuestion::getCorrectSolutionForTextOutput ( int  $active_id,
int  $pass 
)

Definition at line 846 of file class.assTextQuestion.php.

References getAnswers(), ASS_AnswerSimple\getAnswertext(), and getKeywordRelation().

846  : array|string
847  {
848  switch ($this->getKeywordRelation()) {
849  case self::SCORING_MODE_KEYWORD_RELATION_NONE:
850  return '';
851  default:
852  return array_map(
853  static fn(ASS_AnswerMultipleResponseImage $v): string => $v->getAnswertext(),
854  $this->getAnswers()
855  );
856  }
857  }
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file.
getAnswertext()
Gets the answer text.
+ Here is the call graph for this function:

◆ getKeywordRelation()

assTextQuestion::getKeywordRelation ( )

Definition at line 682 of file class.assTextQuestion.php.

References $keyword_relation.

Referenced by calculateReachedPointsForSolution(), getCorrectSolutionForTextOutput(), getMaximumPoints(), getMinimumPoints(), saveAdditionalQuestionDataToDb(), and toLog().

683  {
685  }
+ Here is the caller graph for this function:

◆ getLatestAutosaveContent()

assTextQuestion::getLatestAutosaveContent ( int  $active_id,
int  $pass 
)

Definition at line 750 of file class.assTextQuestion.php.

References assQuestion\getId(), and null.

750  : ?string
751  {
752  $question_fi = $this->getId();
753 
754  // Do we have an unauthorized result?
755  $cntresult = $this->db->query(
756  '
757  SELECT count(solution_id) cnt
758  FROM tst_solutions
759  WHERE active_fi = ' . $this->db->quote($active_id, 'int') . '
760  AND question_fi = ' . $this->db->quote($this->getId(), 'int') . '
761  AND authorized = ' . $this->db->quote(0, 'int')
762  . ' AND pass = ' . $this->db->quote($pass, 'int')
763  );
764  $row = $this->db->fetchAssoc($cntresult);
765  if ($row['cnt'] > 0) {
766  $tresult = $this->db->query(
767  '
768  SELECT value1
769  FROM tst_solutions
770  WHERE active_fi = ' . $this->db->quote($active_id, 'int') . '
771  AND question_fi = ' . $this->db->quote($this->getId(), 'int') . '
772  AND authorized = ' . $this->db->quote(0, 'int')
773  . ' AND pass = ' . $this->db->quote($pass, 'int')
774  );
775  $trow = $this->db->fetchAssoc($tresult);
776  return $trow['value1'];
777  }
778  return null;
779  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ getMatchcondition()

assTextQuestion::getMatchcondition ( )

Definition at line 88 of file class.assTextQuestion.php.

References $matchcondition.

Referenced by saveAdditionalQuestionDataToDb().

88  : int
89  {
90  return $this->matchcondition;
91  }
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assTextQuestion::getMaximumPoints ( )

Returns the maximum points, a learner can reach answering the question.

public

See also
$points

Definition at line 196 of file class.assTextQuestion.php.

References assQuestion\$points, and getKeywordRelation().

Referenced by calculateReachedPointsForSolution(), isComplete(), and toLog().

196  : float
197  {
198  if (in_array($this->getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
199  return parent::getPoints();
200  }
201 
202  $points = 0;
203 
204  foreach ($this->answers as $answer) {
205  if ($answer->getPoints() > 0) {
206  $points = $points + $answer->getPoints();
207  }
208  }
209 
210  return $points;
211  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMaxNumOfChars()

assTextQuestion::getMaxNumOfChars ( )

Definition at line 170 of file class.assTextQuestion.php.

References $max_num_of_chars.

Referenced by saveAdditionalQuestionDataToDb(), toJSON(), and toLog().

170  : int
171  {
173  }
+ Here is the caller graph for this function:

◆ getMinimumPoints()

assTextQuestion::getMinimumPoints ( )

Definition at line 213 of file class.assTextQuestion.php.

References assQuestion\$points, and getKeywordRelation().

Referenced by calculateReachedPoints(), and calculateReachedPointsForSolution().

214  {
215  if (in_array($this->getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
216  return 0;
217  }
218 
219  $points = 0;
220 
221  foreach ($this->answers as $answer) {
222  if ($answer->getPoints() < 0) {
223  $points = $points + $answer->getPoints();
224  }
225  }
226 
227  return $points;
228  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionType()

assTextQuestion::getQuestionType ( )

Definition at line 465 of file class.assTextQuestion.php.

Referenced by toJSON(), and toLog().

465  : string
466  {
467  return "assTextQuestion";
468  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assTextQuestion::getRTETextWithMediaObjects ( )

Collects all text in the question which could contain media objects which were created with the Rich Text Editor.

Definition at line 508 of file class.assTextQuestion.php.

508  : string
509  {
510  return parent::getRTETextWithMediaObjects();
511  }

◆ getScoringModeLangVar()

assTextQuestion::getScoringModeLangVar ( string  $scoring_mode)
private

Definition at line 808 of file class.assTextQuestion.php.

References SCORING_MODE_KEYWORD_RELATION_ALL, SCORING_MODE_KEYWORD_RELATION_ANY, SCORING_MODE_KEYWORD_RELATION_NONE, and SCORING_MODE_KEYWORD_RELATION_ONE.

Referenced by toLog().

808  : string
809  {
810  switch ($scoring_mode) {
812  return 'essay_scoring_mode_without_keywords';
814  return 'essay_scoring_mode_keyword_relation_any';
816  return 'essay_scoring_mode_keyword_relation_all';
818  return 'essay_scoring_mode_keyword_relation_one';
819  default:
820  return '';
821  }
822  }
const SCORING_MODE_KEYWORD_RELATION_NONE
+ Here is the caller graph for this function:

◆ getScoringModesWithPointsByKeyword()

static assTextQuestion::getScoringModesWithPointsByKeyword ( )
static

Definition at line 712 of file class.assTextQuestion.php.

Referenced by assTextQuestionGUI\getBestAnswer().

712  : array
713  {
714  return [
715  self::SCORING_MODE_KEYWORD_RELATION_ANY
716  ];
717  }
+ Here is the caller graph for this function:

◆ getScoringModesWithPointsByQuestion()

static assTextQuestion::getScoringModesWithPointsByQuestion ( )
static

Definition at line 703 of file class.assTextQuestion.php.

703  : array
704  {
705  return [
706  self::SCORING_MODE_KEYWORD_RELATION_NONE,
707  self::SCORING_MODE_KEYWORD_RELATION_ALL,
708  self::SCORING_MODE_KEYWORD_RELATION_ONE
709  ];
710  }

◆ getSolutionSubmit()

assTextQuestion::getSolutionSubmit ( )
protected

Definition at line 409 of file class.assTextQuestion.php.

References ilObjAdvancedEditing\_getRichTextEditor(), assQuestion\getHtmlUserSolutionPurifier(), ilUtil\isHTML(), and ilUtil\stripSlashes().

Referenced by saveWorkingData().

409  : string
410  {
411  $text = $this->questionpool_request->string('TEXT', '');
412 
413  $text = ilObjAdvancedEditing::_getRichTextEditor() === 'tinymce'
414  ? ilUtil::stripSlashes($text, false)
415  : htmlentities($text);
416 
417  return ilUtil::isHTML($text) ? $this->getHtmlUserSolutionPurifier()->purify($text) : $text;
418  }
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
static isHTML(string $a_text)
Checks if a given string contains HTML or not.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextRating()

assTextQuestion::getTextRating ( )

Definition at line 470 of file class.assTextQuestion.php.

References $text_rating.

Referenced by isKeywordMatching(), and saveAdditionalQuestionDataToDb().

470  : string
471  {
472  return $this->text_rating;
473  }
+ Here is the caller graph for this function:

◆ getValidScoringModes()

static assTextQuestion::getValidScoringModes ( )
static

Definition at line 698 of file class.assTextQuestion.php.

698  : array
699  {
700  return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
701  }

◆ isComplete()

assTextQuestion::isComplete ( )

Definition at line 98 of file class.assTextQuestion.php.

References getMaximumPoints().

98  : bool
99  {
100  if (strlen($this->title)
101  && $this->author
102  && $this->question
103  && $this->getMaximumPoints() > 0
104  ) {
105  return true;
106  }
107  return false;
108  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ isKeywordMatching()

assTextQuestion::isKeywordMatching (   $answertext,
  $a_keyword 
)

Checks if one of the keywords matches the answertext.

Parameters
string$answertextThe answertext of the user
string$a_keywordThe keyword which should be checked
Returns
boolean TRUE if the keyword matches, FALSE otherwise private

Definition at line 254 of file class.assTextQuestion.php.

References $DIC, assQuestion\$refinery, getTextRating(), ilStr\strPos(), ilStr\strToLower(), assClozeGap\TEXTGAP_RATING_CASEINSENSITIVE, assClozeGap\TEXTGAP_RATING_CASESENSITIVE, assClozeGap\TEXTGAP_RATING_LEVENSHTEIN1, assClozeGap\TEXTGAP_RATING_LEVENSHTEIN2, assClozeGap\TEXTGAP_RATING_LEVENSHTEIN3, assClozeGap\TEXTGAP_RATING_LEVENSHTEIN4, and assClozeGap\TEXTGAP_RATING_LEVENSHTEIN5.

Referenced by calculateReachedPointsForSolution().

254  : bool
255  {
256  global $DIC;
257  $refinery = $DIC->refinery();
258  $result = false;
259  $textrating = $this->getTextRating();
260 
261  switch ($textrating) {
263  if (ilStr::strPos(ilStr::strToLower($answertext), ilStr::strToLower($a_keyword), 0) !== false) {
264  return true;
265  }
266  break;
268  if (ilStr::strPos($answertext, $a_keyword) !== false) {
269  return true;
270  }
271  break;
272  }
273 
274  // "<p>red</p>" would not match "red" even with distance of 5
275  $answertext = strip_tags($answertext);
276  $answerwords = [];
277  if (preg_match_all("/([^\s.]+)/", $answertext, $matches)) {
278  foreach ($matches[1] as $answerword) {
279  array_push($answerwords, trim($answerword));
280  }
281  }
282 
283  // create correct transformation
284  switch ($textrating) {
286  $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 1);
287  break;
289  $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 2);
290  break;
292  $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 3);
293  break;
295  $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 4);
296  break;
298  $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 5);
299  break;
300  }
301 
302  // run answers against Levenshtein methods
303  foreach ($answerwords as $a_original) {
304  if (isset($transformation) && $transformation->transform($a_original) >= 0) {
305  return true;
306  }
307  }
308  return $result;
309  }
static strPos(string $a_haystack, string $a_needle, int $a_offset=0)
Definition: class.ilStr.php:42
const TEXTGAP_RATING_LEVENSHTEIN3
Refinery $refinery
const TEXTGAP_RATING_CASEINSENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN1
global $DIC
Definition: shib_login.php:22
static strToLower(string $a_string)
Definition: class.ilStr.php:72
const TEXTGAP_RATING_LEVENSHTEIN4
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValidTextRating()

assTextQuestion::isValidTextRating (   $textRating)
private

Definition at line 230 of file class.assTextQuestion.php.

References assClozeGap\TEXTGAP_RATING_CASEINSENSITIVE, assClozeGap\TEXTGAP_RATING_CASESENSITIVE, assClozeGap\TEXTGAP_RATING_LEVENSHTEIN1, assClozeGap\TEXTGAP_RATING_LEVENSHTEIN2, assClozeGap\TEXTGAP_RATING_LEVENSHTEIN3, assClozeGap\TEXTGAP_RATING_LEVENSHTEIN4, and assClozeGap\TEXTGAP_RATING_LEVENSHTEIN5.

Referenced by loadFromDb().

230  : bool
231  {
232  switch ($textRating) {
240  return true;
241  }
242 
243  return false;
244  }
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASEINSENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN1
const TEXTGAP_RATING_LEVENSHTEIN4
+ Here is the caller graph for this function:

◆ isWordCounterEnabled()

assTextQuestion::isWordCounterEnabled ( )

Definition at line 180 of file class.assTextQuestion.php.

References $word_counter_enabled.

Referenced by saveAdditionalQuestionDataToDb(), and toLog().

180  : bool
181  {
183  }
+ Here is the caller graph for this function:

◆ loadFromDb()

assTextQuestion::loadFromDb ( int  $question_id)

Definition at line 118 of file class.assTextQuestion.php.

References $data, Vendor\Package\$e, ilRTE\_replaceMediaObjectImageSrc(), addAnswer(), flushAnswers(), getAdditionalTableName(), ilAssQuestionLifecycle\getDraftInstance(), assQuestion\getId(), ilAssQuestionLifecycle\getInstance(), isValidTextRating(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setId(), setKeywordRelation(), assQuestion\setLifecycle(), setMaxNumOfChars(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), assQuestion\setShuffle(), setTextRating(), assQuestion\setTitle(), setWordCounterEnabled(), and assClozeGap\TEXTGAP_RATING_CASEINSENSITIVE.

118  : void
119  {
120  $result = $this->db->queryF(
121  "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",
122  ["integer"],
123  [$question_id]
124  );
125  if ($this->db->numRows($result) == 1) {
126  $data = $this->db->fetchAssoc($result);
127  $this->setId($question_id);
128  $this->setObjId($data["obj_fi"]);
129  $this->setTitle((string) $data["title"]);
130  $this->setComment((string) $data["description"]);
131  $this->setOriginalId($data["original_id"]);
132  $this->setNrOfTries($data['nr_of_tries']);
133  $this->setAuthor($data["author"]);
134  $this->setPoints((float) $data["points"]);
135  $this->setOwner($data["owner"]);
136  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
137  $this->setShuffle(false);
138  $this->setWordCounterEnabled((bool) $data['word_cnt_enabled']);
139  $this->setMaxNumOfChars($data["maxnumofchars"] ?? 0);
140  $this->setTextRating($this->isValidTextRating($data["textgap_rating"]) ? $data["textgap_rating"] : assClozeGap::TEXTGAP_RATING_CASEINSENSITIVE);
141  $this->matchcondition = (isset($data['matchcondition'])) ? (int) $data['matchcondition'] : 0;
142  $this->setKeywordRelation(($data['keyword_relation']));
143 
144  try {
148  }
149 
150  try {
151  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
152  } catch (ilTestQuestionPoolException $e) {
153  }
154  }
155 
156  $result = $this->db->queryF(
157  'SELECT * FROM qpl_a_essay WHERE question_fi = %s',
158  ['integer'],
159  [$this->getId()]
160  );
161 
162  $this->flushAnswers();
163  while ($row = $this->db->fetchAssoc($result)) {
164  $this->addAnswer($row['answertext'] ?? '', $row['points'] ?? 0.0);
165  }
166 
167  parent::loadFromDb($question_id);
168  }
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)
setOwner(int $owner=-1)
setMaxNumOfChars(int $maxchars=0)
const TEXTGAP_RATING_CASEINSENSITIVE
setComment(string $comment="")
setWordCounterEnabled(bool $word_counter_enabled)
isValidTextRating($textRating)
flushAnswers()
Deletes all answers.
setTextRating($a_text_rating)
setPoints(float $points)
setObjId(int $obj_id=0)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
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.
setId(int $id=-1)
setOriginalId(?int $original_id)
setTitle(string $title="")
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setAuthor(string $author="")
setShuffle(?bool $shuffle=true)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assTextQuestion::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

Definition at line 420 of file class.assTextQuestion.php.

References getAdditionalTableName(), assQuestion\getId(), getKeywordRelation(), getMatchcondition(), getMaxNumOfChars(), getTextRating(), ILIAS\Repository\int(), isWordCounterEnabled(), null, and ilObjAnswerScoringAdjustable\saveAnswerSpecificDataToDb().

Referenced by saveToDb().

421  {
422  $this->db->manipulateF(
423  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
424  ['integer'],
425  [$this->getId()]
426  );
427 
428  $fields = [
429  'question_fi' => ['integer', $this->getId()],
430  'maxnumofchars' => ['integer', $this->getMaxNumOfChars()],
431  'word_cnt_enabled' => ['integer', (int) $this->isWordCounterEnabled()],
432  'keywords' => ['text', null],
433  'textgap_rating' => ['text', $this->getTextRating()],
434  'matchcondition' => ['integer', $this->getMatchcondition()],
435  'keyword_relation' => ['text', $this->getKeywordRelation()]
436  ];
437 
438  $this->db->insert($this->getAdditionalTableName(), $fields);
439  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getAdditionalTableName()
Returns the name of the additional question data table in the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

assTextQuestion::saveToDb ( ?int  $original_id = null)

Definition at line 110 of file class.assTextQuestion.php.

References assQuestion\$original_id, saveAdditionalQuestionDataToDb(), ilObjAnswerScoringAdjustable\saveAnswerSpecificDataToDb(), and assQuestion\saveQuestionDataToDb().

110  : void
111  {
115  parent::saveToDb();
116  }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb(?int $original_id=null)
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
+ Here is the call graph for this function:

◆ saveWorkingData()

assTextQuestion::saveWorkingData ( int  $active_id,
?int  $pass = null,
bool  $authorized = true 
)

Definition at line 386 of file class.assTextQuestion.php.

References ilObjTest\_getPass(), assQuestion\getProcessLocker(), getSolutionSubmit(), null, assQuestion\removeCurrentSolution(), and assQuestion\saveCurrentSolution().

390  : bool {
391  if ($pass === null) {
392  $pass = ilObjTest::_getPass($active_id);
393  }
394 
395  $answer = $this->getSolutionSubmit();
396  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
397  function () use ($answer, $active_id, $pass, $authorized) {
398  $this->removeCurrentSolution($active_id, $pass, $authorized);
399 
400  if ($answer !== '') {
401  $this->saveCurrentSolution($active_id, $pass, $answer, null, $authorized);
402  }
403  }
404  );
405 
406  return true;
407  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
+ Here is the call graph for this function:

◆ setAnswers()

assTextQuestion::setAnswers (   $answers)

Definition at line 638 of file class.assTextQuestion.php.

References addAnswer(), flushAnswers(), and ILIAS\Repository\refinery().

638  : void
639  {
640  if (isset($answers['answer'])) {
641  $count = count($answers['answer']);
642  $withPoints = true;
643  } else {
644  $count = count($answers);
645  $withPoints = false;
646  }
647 
648  $this->flushAnswers();
649 
650  for ($i = 0; $i < $count; $i++) {
651  if ($withPoints) {
652  $this->addAnswer(
653  $answers['answer'][$i],
654  $this->refinery->kindlyTo()->float()->transform($answers['points'][$i])
655  );
656  } else {
657  $this->addAnswer($answers[$i], 0);
658  }
659  }
660  }
flushAnswers()
Deletes all answers.
addAnswer( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="")
Adds a possible answer for a multiple choice question.
+ Here is the call graph for this function:

◆ setKeywordRelation()

assTextQuestion::setKeywordRelation ( ?string  $relation)

This method implements a default behaviour.

During the creation of a text question, the record which holds the keyword relation is not existing, so keyword_relation defaults to 'one'.

Definition at line 691 of file class.assTextQuestion.php.

References $relation, and null.

Referenced by loadFromDb().

691  : void
692  {
693  if ($relation !== null) {
694  $this->keyword_relation = $relation;
695  }
696  }
$relation
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ setMatchcondition()

assTextQuestion::setMatchcondition ( int  $matchcondition)

Definition at line 93 of file class.assTextQuestion.php.

References $matchcondition.

93  : void
94  {
95  $this->matchcondition = $matchcondition;
96  }

◆ setMaxNumOfChars()

assTextQuestion::setMaxNumOfChars ( int  $maxchars = 0)

Definition at line 175 of file class.assTextQuestion.php.

Referenced by loadFromDb().

175  : void
176  {
177  $this->max_num_of_chars = $maxchars;
178  }
+ Here is the caller graph for this function:

◆ setTextRating()

assTextQuestion::setTextRating (   $a_text_rating)

Definition at line 475 of file class.assTextQuestion.php.

References assClozeGap\TEXTGAP_RATING_CASEINSENSITIVE, assClozeGap\TEXTGAP_RATING_CASESENSITIVE, assClozeGap\TEXTGAP_RATING_LEVENSHTEIN1, assClozeGap\TEXTGAP_RATING_LEVENSHTEIN2, assClozeGap\TEXTGAP_RATING_LEVENSHTEIN3, assClozeGap\TEXTGAP_RATING_LEVENSHTEIN4, and assClozeGap\TEXTGAP_RATING_LEVENSHTEIN5.

Referenced by loadFromDb().

475  : void
476  {
477  switch ($a_text_rating) {
485  $this->text_rating = $a_text_rating;
486  break;
487  default:
488  $this->text_rating = assClozeGap::TEXTGAP_RATING_CASEINSENSITIVE;
489  break;
490  }
491  }
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASEINSENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN1
const TEXTGAP_RATING_LEVENSHTEIN4
+ Here is the caller graph for this function:

◆ setWordCounterEnabled()

assTextQuestion::setWordCounterEnabled ( bool  $word_counter_enabled)

Definition at line 185 of file class.assTextQuestion.php.

References $word_counter_enabled.

Referenced by loadFromDb().

185  : void
186  {
187  $this->word_counter_enabled = $word_counter_enabled;
188  }
+ Here is the caller graph for this function:

◆ solutionValuesToLog()

assTextQuestion::solutionValuesToLog ( AdditionalInformationGenerator  $additional_info,
array  $solution_values 
)
protected

Definition at line 824 of file class.assTextQuestion.php.

References ILIAS\Repository\refinery().

827  : string {
828  if (!array_key_exists(0, $solution_values)
829  || !array_key_exists('value1', $solution_values[0])) {
830  return '';
831  }
832  return $this->refinery->string()->stripTags()->transform(
833  html_entity_decode($solution_values[0]['value1'])
834  );
835  }
+ Here is the call graph for this function:

◆ solutionValuesToText()

assTextQuestion::solutionValuesToText ( array  $solution_values)

Definition at line 837 of file class.assTextQuestion.php.

837  : string
838  {
839  if (!array_key_exists(0, $solution_values)
840  || !array_key_exists('value1', $solution_values[0])) {
841  return '';
842  }
843  return $solution_values[0]['value1'];
844  }

◆ toJSON()

assTextQuestion::toJSON ( )

Returns a JSON representation of the question.

Implements ILIAS\TestQuestionPool\Questions\QuestionLMExportable.

Definition at line 516 of file class.assTextQuestion.php.

References assQuestion\formatSAQuestion(), assQuestion\getId(), getMaxNumOfChars(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), and assQuestion\getTitleForHTMLOutput().

516  : string
517  {
518  $result = [];
519  $result['id'] = $this->getId();
520  $result['type'] = (string) $this->getQuestionType();
521  $result['title'] = $this->getTitleForHTMLOutput();
522  $result['question'] = $this->formatSAQuestion($this->getQuestion());
523  $result['nr_of_tries'] = $this->getNrOfTries();
524  $result['shuffle'] = $this->getShuffle();
525  $result['maxlength'] = $this->getMaxNumOfChars();
526  return json_encode($result);
527  }
+ Here is the call graph for this function:

◆ toLog()

assTextQuestion::toLog ( AdditionalInformationGenerator  $additional_info)

Implements ILIAS\TestQuestionPool\Questions\Question.

Definition at line 781 of file class.assTextQuestion.php.

References assQuestion\formatSAQuestion(), getAnswers(), ASS_AnswerSimple\getAnswertext(), ILIAS\Test\Logging\AdditionalInformationGenerator\getEnabledDisabledTagForBool(), getKeywordRelation(), getMaximumPoints(), getMaxNumOfChars(), ASS_AnswerSimple\getPoints(), assQuestion\getQuestion(), getQuestionType(), getScoringModeLangVar(), ILIAS\Test\Logging\AdditionalInformationGenerator\getTagForLangVar(), assQuestion\getTitleForHTMLOutput(), and isWordCounterEnabled().

781  : array
782  {
783  return [
784  AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
785  AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
786  AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
787  AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->getMaximumPoints(),
788  AdditionalInformationGenerator::KEY_QUESTION_TEXT_WORDCOUNT_ENABLED => $additional_info
790  AdditionalInformationGenerator::KEY_QUESTION_MAXCHARS => $this->getMaxNumOfChars(),
791  AdditionalInformationGenerator::KEY_QUESTION_TEXT_SCORING_MODE => $additional_info->getTagForLangVar(
793  ),
794  AdditionalInformationGenerator::KEY_QUESTION_CORRECT_ANSWER_OPTIONS => array_map(
795  fn(ASS_AnswerMultipleResponseImage $answer) => [
796  AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION => $answer->getAnswertext(),
797  AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $answer->getPoints() === 0.0 ? '' : $answer->getPoints()
798  ],
799  $this->getAnswers()
800  ),
801  AdditionalInformationGenerator::KEY_FEEDBACK => [
802  AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
803  AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
804  ]
805  ];
806  }
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
getPoints()
Gets the points.
getScoringModeLangVar(string $scoring_mode)
getAnswertext()
Gets the answer text.
+ Here is the call graph for this function:

Field Documentation

◆ $answers

array assTextQuestion::$answers = []

Definition at line 63 of file class.assTextQuestion.php.

Referenced by getAnswers().

◆ $keyword_relation

string assTextQuestion::$keyword_relation = self::SCORING_MODE_KEYWORD_RELATION_NONE
private

Definition at line 51 of file class.assTextQuestion.php.

Referenced by getKeywordRelation().

◆ $keywords

array assTextQuestion::$keywords

Definition at line 57 of file class.assTextQuestion.php.

◆ $matchcondition

int assTextQuestion::$matchcondition = 0
private

Definition at line 50 of file class.assTextQuestion.php.

Referenced by getMatchcondition(), and setMatchcondition().

◆ $max_num_of_chars

int assTextQuestion::$max_num_of_chars = 0
private

Definition at line 47 of file class.assTextQuestion.php.

Referenced by getMaxNumOfChars().

◆ $text_rating

string assTextQuestion::$text_rating = assClozeGap::TEXTGAP_RATING_CASEINSENSITIVE
private

Definition at line 49 of file class.assTextQuestion.php.

Referenced by getTextRating().

◆ $word_counter_enabled

bool assTextQuestion::$word_counter_enabled = false
private

Definition at line 48 of file class.assTextQuestion.php.

Referenced by isWordCounterEnabled(), and setWordCounterEnabled().

◆ HAS_SPECIFIC_FEEDBACK

const assTextQuestion::HAS_SPECIFIC_FEEDBACK = false
protected

Definition at line 40 of file class.assTextQuestion.php.

◆ SCORING_MODE_KEYWORD_RELATION_ALL

const assTextQuestion::SCORING_MODE_KEYWORD_RELATION_ALL = 'all'

◆ SCORING_MODE_KEYWORD_RELATION_ANY

const assTextQuestion::SCORING_MODE_KEYWORD_RELATION_ANY = 'any'

◆ SCORING_MODE_KEYWORD_RELATION_NONE

const assTextQuestion::SCORING_MODE_KEYWORD_RELATION_NONE = 'non'

◆ SCORING_MODE_KEYWORD_RELATION_ONE

const assTextQuestion::SCORING_MODE_KEYWORD_RELATION_ONE = 'one'

The documentation for this class was generated from the following file: