ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)
 MUST return an array of the question settings that can be stored in the log. More...
 
 solutionValuesToText (array $solution_values)
 MUST convert the given solution values into text. More...
 
 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)
 
 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 ()
 
 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 ()
 
 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 ()
 
 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)
 
 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)
 
 validateSolutionSubmit ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
- Public Member Functions inherited from ilObjAnswerScoringAdjustable
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 toJSON ()
 

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 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)
 MUST convert the given solution values into an array or a string that can be stored in the log. More...
 
- 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)
 
 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
 
TestResultRepository $test_result_repository
 
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.

83 {
85 $this->points = 1;
86 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ 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) @access public
See also
$answers
ASS_AnswerBinaryStateImage

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

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,...

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ calculateReachedPoints()

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

Reimplemented from assQuestion.

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

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 }
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
getSolutionMaxPass(int $active_id)
calculateReachedPointsForSolution(string $solution)

References assQuestion\getSolutionMaxPass().

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assTextQuestion::calculateReachedPointsForSolution ( string  $solution)
protected

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

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 }
isKeywordMatching($answertext, $a_keyword)
Checks if one of the keywords matches the answertext.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.

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

+ Here is the call graph for this function:

◆ countLetters()

assTextQuestion::countLetters (   $text)

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

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:60

References ilStr\strLen().

+ 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 @access public
See also
$answers

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

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 }

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

+ Here is the call graph for this function:

◆ duplicateAnswers()

assTextQuestion::duplicateAnswers (   $original_id)

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

662 : void
663 {
664 $result = $this->db->queryF(
665 "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
666 ['integer'],
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 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ flushAnswers()

assTextQuestion::flushAnswers ( )

Deletes all answers.

@access public

See also
$answers

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

633 : void
634 {
635 $this->answers = [];
636 }

Referenced by loadFromDb().

+ 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 @access public

Reimplemented from assQuestion.

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

499 : string
500 {
501 return "qpl_qst_essay";
502 }

Referenced by loadFromDb().

+ 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 @access public
See also
$answers

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

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 }

◆ 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.

561 : array
562 {
563 return $this->answers;
564 }

Referenced by calculateReachedPointsForSolution().

+ Here is the caller graph for this function:

◆ getAnswerTableName()

assTextQuestion::getAnswerTableName ( )

Reimplemented from assQuestion.

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 
)

Reimplemented from assQuestion.

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

846 : array|string
847 {
848 switch ($this->getKeywordRelation()) {
850 return '';
851 default:
852 return array_map(
853 static fn(ASS_AnswerMultipleResponseImage $v): string => $v->getAnswertext(),
854 $this->getAnswers()
855 );
856 }
857 }
getAnswertext()
Gets the answer text.
const SCORING_MODE_KEYWORD_RELATION_NONE

References ASS_AnswerSimple\getAnswertext().

+ Here is the call graph for this function:

◆ getKeywordRelation()

assTextQuestion::getKeywordRelation ( )

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

683 {
685 }

Referenced by calculateReachedPointsForSolution(), getMaximumPoints(), and getMinimumPoints().

+ 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.

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 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ getMatchcondition()

assTextQuestion::getMatchcondition ( )

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

88 : int
89 {
91 }

References $matchcondition.

◆ getMaximumPoints()

assTextQuestion::getMaximumPoints ( )

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

@access public

See also
$points

Reimplemented from assQuestion.

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

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 }

References assQuestion\$points, and getKeywordRelation().

Referenced by calculateReachedPointsForSolution(), and isComplete().

+ 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.

170 : int
171 {
173 }

References $max_num_of_chars.

◆ getMinimumPoints()

assTextQuestion::getMinimumPoints ( )

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

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 }

References assQuestion\$points, and getKeywordRelation().

Referenced by calculateReachedPointsForSolution().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionType()

assTextQuestion::getQuestionType ( )

Reimplemented from assQuestion.

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

465 : string
466 {
467 return "assTextQuestion";
468 }

◆ getRTETextWithMediaObjects()

assTextQuestion::getRTETextWithMediaObjects ( )

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

Reimplemented from assQuestion.

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.

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 }

References SCORING_MODE_KEYWORD_RELATION_ALL, SCORING_MODE_KEYWORD_RELATION_ANY, SCORING_MODE_KEYWORD_RELATION_NONE, and SCORING_MODE_KEYWORD_RELATION_ONE.

◆ getScoringModesWithPointsByKeyword()

static assTextQuestion::getScoringModesWithPointsByKeyword ( )
static

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

712 : array
713 {
714 return [
716 ];
717 }

Referenced by assTextQuestionGUI\getBestAnswer().

+ Here is the caller graph for this function:

◆ getScoringModesWithPointsByQuestion()

static assTextQuestion::getScoringModesWithPointsByQuestion ( )
static

◆ getSolutionSubmit()

assTextQuestion::getSolutionSubmit ( )
protected

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

409 : string
410 {
411 $text = $this->questionpool_request->string('TEXT', '');
412
413 $text = (new ilRTESettings($this->lng, $this->current_user))->getRichTextEditor() === 'tinymce'
414 ? ilUtil::stripSlashes($text, false)
415 : htmlentities($text);
416
417 return ilUtil::isHTML($text) ? $this->getHtmlUserSolutionPurifier()->purify($text) : $text;
418 }
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="")

References ilUtil\isHTML(), ILIAS\Repository\lng(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ getTextRating()

assTextQuestion::getTextRating ( )

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

470 : string
471 {
472 return $this->text_rating;
473 }

Referenced by isKeywordMatching().

+ 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 ( )

Reimplemented from assQuestion.

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

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 }

References getMaximumPoints().

+ 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 @access private

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

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 }
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN1
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_CASEINSENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN3
Refinery $refinery
static strPos(string $a_haystack, string $a_needle, int $a_offset=0)
Definition: class.ilStr.php:39
static strToLower(string $a_string)
Definition: class.ilStr.php:69
global $DIC
Definition: shib_login.php:26

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValidTextRating()

◆ isWordCounterEnabled()

assTextQuestion::isWordCounterEnabled ( )

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

180 : bool
181 {
183 }

References $word_counter_enabled.

◆ loadFromDb()

assTextQuestion::loadFromDb ( int  $question_id)

Reimplemented from assQuestion.

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

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']);
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 }
setOriginalId(?int $original_id)
setId(int $id=-1)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setShuffle(?bool $shuffle=true)
setQuestion(string $question="")
setAuthor(string $author="")
setComment(string $comment="")
setObjId(int $obj_id=0)
setOwner(int $owner=-1)
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
setPoints(float $points)
setWordCounterEnabled(bool $word_counter_enabled)
setMaxNumOfChars(int $maxchars=0)
setKeywordRelation(?string $relation)
This method implements a default behaviour.
addAnswer( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="")
Adds a possible answer for a multiple choice question.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
flushAnswers()
Deletes all answers.
setTextRating($a_text_rating)
isValidTextRating($textRating)
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...

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.

+ 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.

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 }

References ILIAS\Survey\Mode\getId(), and ILIAS\Repository\int().

Referenced by saveToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

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

Reimplemented from assQuestion.

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

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

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

+ Here is the call graph for this function:

◆ saveWorkingData()

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

Reimplemented from assQuestion.

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

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 }
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.

References ilObjTest\_getPass().

+ Here is the call graph for this function:

◆ setAnswers()

assTextQuestion::setAnswers (   $answers)

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

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 }

References ILIAS\Repository\refinery().

+ 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.

691 : void
692 {
693 if ($relation !== null) {
694 $this->keyword_relation = $relation;
695 }
696 }
$relation

References $relation.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setMatchcondition()

assTextQuestion::setMatchcondition ( int  $matchcondition)

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

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

References $matchcondition.

◆ setMaxNumOfChars()

assTextQuestion::setMaxNumOfChars ( int  $maxchars = 0)

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

175 : void
176 {
177 $this->max_num_of_chars = $maxchars;
178 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setTextRating()

◆ setWordCounterEnabled()

assTextQuestion::setWordCounterEnabled ( bool  $word_counter_enabled)

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

185 : void
186 {
187 $this->word_counter_enabled = $word_counter_enabled;
188 }

References $word_counter_enabled.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ solutionValuesToLog()

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

MUST convert the given solution values into an array or a string that can be stored in the log.

Language variables must be generated through the corresponding functions in the AdditionalInformationGenerator. If an array is returned it will be rendered into a line per array entry in the format "key: value". If the key exists as a language variable, it will be translated.

Reimplemented from assQuestion.

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

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 }

◆ solutionValuesToText()

assTextQuestion::solutionValuesToText ( array  $solution_values)

MUST convert the given solution values into text.

If the text has multiple lines each line MUST be placed as an entry in an array.

Reimplemented from assQuestion.

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.

Reimplemented from assQuestion.

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

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 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ toLog()

assTextQuestion::toLog ( AdditionalInformationGenerator  $additional_info)

MUST return an array of the question settings that can be stored in the log.

Language variables must be generated through the corresponding functions in the AdditionalInformationGenerator. If an array is returned it will be rendered into a line per array entry in the format "key: value". If the key exists as a language variable, it will be translated.

Reimplemented from assQuestion.

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

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 }
getPoints()
Gets the points.
getScoringModeLangVar(string $scoring_mode)

References ASS_AnswerSimple\getAnswertext(), ILIAS\Test\Logging\AdditionalInformationGenerator\getEnabledDisabledTagForBool(), ASS_AnswerSimple\getPoints(), and ILIAS\Test\Logging\AdditionalInformationGenerator\getTagForLangVar().

+ 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 calculateReachedPointsForSolution().

◆ $keyword_relation

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

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

◆ $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.

◆ $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: