ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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)
 
 toNormalized (Transformations $transformations, array $context=[])
 
 fromNormalized (array $normalized, Transformations $transformations)
 
- 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)
 
 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)
 
 updateOriginalId (?int $original_id=null)
 
 duplicate (bool $set_original_id=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)
 
 toNormalized (Transformations $transformations, array $context=[])
 
 fromNormalized (array $normalized, Transformations $transformations)
 
 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 ()
 
 toNormalized (Transformations $transformations, array $context=[])
 Convert the internal state of the implementing object into a language-neutral array structure. More...
 
 fromNormalized (array $normalized, Transformations $transformations)
 Restore the object from its normalized representation. 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 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 41 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 80 of file class.assTextQuestion.php.

86 {
88 $this->points = 1;
89 }
__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 550 of file class.assTextQuestion.php.

556 : void {
557 $this->answers[] = new ASS_AnswerMultipleResponseImage($answertext, $points);
558 }
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 364 of file class.assTextQuestion.php.

368 : float {
369 if ($pass === null) {
370 $pass = $this->getSolutionMaxPass($active_id);
371 }
372
373 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
374
375 // Return min points when no answer was given.
376 if ($this->db->numRows($result) === 0) {
377 return $this->getMinimumPoints();
378 }
379
380 // Return points of points are already on the row.
381 $row = $this->db->fetchAssoc($result);
382 if ($row['points'] !== null) {
383 return (float) $row["points"];
384 }
385
386 return $this->calculateReachedPointsForSolution($row['value1']);
387 }
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 314 of file class.assTextQuestion.php.

314 : float
315 {
316 $decoded_solution = html_entity_decode($solution);
317 // Return min points when keyword relation is NON KEYWORDS
318 if ($this->getKeywordRelation() === self::SCORING_MODE_KEYWORD_RELATION_NONE) {
319 return $this->getMinimumPoints();
320 }
321
322 // Return min points if there are no answers present.
323 $answers = $this->getAnswers();
324
325 if ($answers === []) {
326 return $this->getMinimumPoints();
327 }
328
329 switch ($this->getKeywordRelation()) {
330 case 'any':
331 $points = 0.0;
332 foreach ($answers as $answer) {
333 $qst_answer = $answer->getAnswertext();
334 $user_answer = ' ' . $decoded_solution;
335 if ($this->isKeywordMatching($user_answer, $qst_answer)) {
336 $points += $answer->getPoints();
337 }
338 }
339 return $points;
340
341 case 'all':
342 foreach ($answers as $answer) {
343 $qst_answer = $answer->getAnswertext();
344 $user_answer = ' ' . $decoded_solution;
345 if (!$this->isKeywordMatching($user_answer, $qst_answer)) {
346 return 0.0;
347 }
348 }
349 return $this->getMaximumPoints();
350
351 case 'one':
352 foreach ($answers as $answer) {
353 $qst_answer = $answer->getAnswertext();
354 $user_answer = ' ' . $decoded_solution;
355 if ($this->isKeywordMatching($user_answer, $qst_answer)) {
356 return $this->getMaximumPoints();
357 }
358 }
359 }
360
361 return 0.0;
362 }
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 722 of file class.assTextQuestion.php.

722 : int
723 {
724 $text = strip_tags($text);
725
726 $text = str_replace('>', '>', $text);
727 $text = str_replace('&lt;', '<', $text);
728 $text = str_replace('&nbsp;', ' ', $text);
729 $text = str_replace('&amp;', '&', $text);
730
731 $text = str_replace("\r\n", "\n", $text);
732 $text = str_replace("\n", "", $text);
733
734 return ilStr::strLen($text);
735 }
static strLen(string $a_string)
Definition: class.ilStr.php:60
$text
Definition: xapiexit.php:21

References $text, and ilStr\strLen().

+ Here is the call graph for this function:

◆ countWords()

assTextQuestion::countWords (   $text)

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

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

References $text.

◆ 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 601 of file class.assTextQuestion.php.

601 : void
602 {
603 if ($index < 0) {
604 return;
605 }
606 if (count($this->answers) < 1) {
607 return;
608 }
609 if ($index >= count($this->answers)) {
610 return;
611 }
612 $answer = $this->answers[$index];
613 //if (strlen($answer->getImage())) {
614 // $this->deleteImage($answer->getImage());
615 //}
616 unset($this->answers[$index]);
617 $this->answers = array_values($this->answers);
618 for ($i = 0, $iMax = count($this->answers); $i < $iMax; $i++) {
619 if ($this->answers[$i]->getOrder() > $index) {
620 $this->answers[$i]->setOrder($i);
621 }
622 }
623 }

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

+ Here is the call graph for this function:

◆ duplicateAnswers()

assTextQuestion::duplicateAnswers (   $original_id)

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

665 : void
666 {
667 $result = $this->db->queryF(
668 "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
669 ['integer'],
671 );
672 if ($result->numRows()) {
673 while ($row = $this->db->fetchAssoc($result)) {
674 $next_id = $this->db->nextId('qpl_a_essay');
675 $affectedRows = $this->db->manipulateF(
676 "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points)
677 VALUES (%s, %s, %s, %s)",
678 ['integer','integer','text','float'],
679 [$next_id, $this->getId(), $row["answertext"], $row["points"]]
680 );
681 }
682 }
683 }

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 636 of file class.assTextQuestion.php.

636 : void
637 {
638 $this->answers = [];
639 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ fromNormalized()

assTextQuestion::fromNormalized ( array  $normalized,
Transformations  $transformations 
)
Parameters
array<array-key,mixed>$normalized

Reimplemented from assQuestion.

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

883 : static
884 {
885 $clone = parent::fromNormalized($normalized, $transformations);
886 $clone->word_counter_enabled = $transformations->bool($normalized['word_counter_enabled']);
887 $clone->max_num_of_chars = $transformations->int($normalized['max_num_of_chars']);
888 $clone->text_rating = $transformations->string($normalized['text_rating']);
889 $clone->matchcondition = $transformations->int($normalized['matchcondition']);
890 $clone->keyword_relation = $transformations->string($normalized['keyword_relation']);
891 $clone->answers = array_map(
892 static fn(array $answer): ASS_AnswerMultipleResponseImage => $transformations->denormalize(
893 $answer,
895 ),
896 $normalized['answers']
897 );
898
899 return $clone;
900 }
denormalize(array|float|bool|int|string|null $normalized, string|object $expected)

References ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\bool(), ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\denormalize(), ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\int(), and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\string().

+ Here is the call 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 502 of file class.assTextQuestion.php.

502 : string
503 {
504 return "qpl_qst_essay";
505 }

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 578 of file class.assTextQuestion.php.

579 {
580 if ($index < 0) {
581 return null;
582 }
583 if (count($this->answers) < 1) {
584 return null;
585 }
586 if ($index >= count($this->answers)) {
587 return null;
588 }
589
590 return $this->answers[$index];
591 }

◆ getAnswerCount()

assTextQuestion::getAnswerCount ( )

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

532 : int
533 {
534 return count($this->answers);
535 }

◆ getAnswers()

assTextQuestion::getAnswers ( )
Returns
array<ASS_AnswerMultipleResponseImage>

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

564 : array
565 {
566 return $this->answers;
567 }

Referenced by calculateReachedPointsForSolution().

+ Here is the caller graph for this function:

◆ getAnswerTableName()

assTextQuestion::getAnswerTableName ( )

Reimplemented from assQuestion.

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

625 : string
626 {
627 return 'qpl_a_essay';
628 }

◆ getCorrectSolutionForTextOutput()

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

Reimplemented from assQuestion.

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

849 : array|string
850 {
851 switch ($this->getKeywordRelation()) {
853 return '';
854 default:
855 return array_map(
856 static fn(ASS_AnswerMultipleResponseImage $v): string => $v->getAnswertext(),
857 $this->getAnswers()
858 );
859 }
860 }
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 685 of file class.assTextQuestion.php.

686 {
688 }

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 753 of file class.assTextQuestion.php.

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

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ getMatchcondition()

assTextQuestion::getMatchcondition ( )

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

91 : int
92 {
94 }

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 199 of file class.assTextQuestion.php.

199 : float
200 {
201 if (in_array($this->getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
202 return parent::getPoints();
203 }
204
205 $points = 0;
206
207 foreach ($this->answers as $answer) {
208 if ($answer->getPoints() > 0) {
209 $points = $points + $answer->getPoints();
210 }
211 }
212
213 return $points;
214 }

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 173 of file class.assTextQuestion.php.

173 : int
174 {
176 }

References $max_num_of_chars.

◆ getMinimumPoints()

assTextQuestion::getMinimumPoints ( )

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

217 {
218 if (in_array($this->getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
219 return 0;
220 }
221
222 $points = 0;
223
224 foreach ($this->answers as $answer) {
225 if ($answer->getPoints() < 0) {
226 $points = $points + $answer->getPoints();
227 }
228 }
229
230 return $points;
231 }

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 468 of file class.assTextQuestion.php.

468 : string
469 {
470 return "assTextQuestion";
471 }

◆ 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 511 of file class.assTextQuestion.php.

511 : string
512 {
513 return parent::getRTETextWithMediaObjects();
514 }

◆ getScoringModeLangVar()

assTextQuestion::getScoringModeLangVar ( string  $scoring_mode)
private

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

811 : string
812 {
813 switch ($scoring_mode) {
815 return 'essay_scoring_mode_without_keywords';
817 return 'essay_scoring_mode_keyword_relation_any';
819 return 'essay_scoring_mode_keyword_relation_all';
821 return 'essay_scoring_mode_keyword_relation_one';
822 default:
823 return '';
824 }
825 }

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 715 of file class.assTextQuestion.php.

715 : array
716 {
717 return [
719 ];
720 }

Referenced by assTextQuestionGUI\getBestAnswer().

+ Here is the caller graph for this function:

◆ getScoringModesWithPointsByQuestion()

static assTextQuestion::getScoringModesWithPointsByQuestion ( )
static

◆ getSolutionSubmit()

assTextQuestion::getSolutionSubmit ( )
protected

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

412 : string
413 {
414 $text = $this->questionpool_request->string('TEXT', '');
415
416 $text = (new ilRTESettings($this->lng, $this->current_user))->getRichTextEditor() === 'tinymce'
418 : htmlentities($text);
419
420 return ilUtil::isHTML($text) ? $this->getHtmlUserSolutionPurifier()->purify($text) : $text;
421 }
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 $text, ilUtil\isHTML(), ILIAS\Repository\lng(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ getTextRating()

assTextQuestion::getTextRating ( )

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

473 : string
474 {
475 return $this->text_rating;
476 }

Referenced by isKeywordMatching().

+ Here is the caller graph for this function:

◆ getValidScoringModes()

static assTextQuestion::getValidScoringModes ( )
static

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

701 : array
702 {
703 return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
704 }

◆ isComplete()

assTextQuestion::isComplete ( )

Reimplemented from assQuestion.

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

101 : bool
102 {
103 if (strlen($this->title)
104 && $this->author
105 && $this->question
106 && $this->getMaximumPoints() > 0
107 ) {
108 return true;
109 }
110 return false;
111 }

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 257 of file class.assTextQuestion.php.

257 : bool
258 {
259 global $DIC;
260 $refinery = $DIC->refinery();
261 $result = false;
262 $textrating = $this->getTextRating();
263
264 switch ($textrating) {
266 if (ilStr::strPos(ilStr::strToLower($answertext), ilStr::strToLower($a_keyword), 0) !== false) {
267 return true;
268 }
269 break;
271 if (ilStr::strPos($answertext, $a_keyword) !== false) {
272 return true;
273 }
274 break;
275 }
276
277 // "<p>red</p>" would not match "red" even with distance of 5
278 $answertext = strip_tags($answertext);
279 $answerwords = [];
280 if (preg_match_all("/([^\s.]+)/", $answertext, $matches)) {
281 foreach ($matches[1] as $answerword) {
282 array_push($answerwords, trim($answerword));
283 }
284 }
285
286 // create correct transformation
287 switch ($textrating) {
289 $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 1);
290 break;
292 $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 2);
293 break;
295 $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 3);
296 break;
298 $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 4);
299 break;
301 $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 5);
302 break;
303 }
304
305 // run answers against Levenshtein methods
306 foreach ($answerwords as $a_original) {
307 if (isset($transformation) && $transformation->transform($a_original) >= 0) {
308 return true;
309 }
310 }
311 return $result;
312 }
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 183 of file class.assTextQuestion.php.

183 : bool
184 {
186 }

References $word_counter_enabled.

◆ loadFromDb()

assTextQuestion::loadFromDb ( int  $question_id)

Reimplemented from assQuestion.

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

121 : void
122 {
123 $result = $this->db->queryF(
124 "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",
125 ["integer"],
126 [$question_id]
127 );
128 if ($this->db->numRows($result) == 1) {
129 $data = $this->db->fetchAssoc($result);
130 $this->setId($question_id);
131 $this->setObjId($data["obj_fi"]);
132 $this->setTitle((string) $data["title"]);
133 $this->setComment((string) $data["description"]);
134 $this->setOriginalId($data["original_id"]);
135 $this->setNrOfTries($data['nr_of_tries']);
136 $this->setAuthor($data["author"]);
137 $this->setPoints((float) $data["points"]);
138 $this->setOwner($data["owner"]);
139 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
140 $this->setShuffle(false);
141 $this->setWordCounterEnabled((bool) $data['word_cnt_enabled']);
142 $this->setMaxNumOfChars($data["maxnumofchars"] ?? 0);
143 $this->setTextRating($this->isValidTextRating($data["textgap_rating"]) ? $data["textgap_rating"] : assClozeGap::TEXTGAP_RATING_CASEINSENSITIVE);
144 $this->matchcondition = (isset($data['matchcondition'])) ? (int) $data['matchcondition'] : 0;
145 $this->setKeywordRelation(($data['keyword_relation']));
146
147 try {
148 $this->setLifecycle(new ilAssQuestionLifecycle($data['lifecycle']));
151 }
152
153 try {
154 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
156 }
157 }
158
159 $result = $this->db->queryF(
160 'SELECT * FROM qpl_a_essay WHERE question_fi = %s',
161 ['integer'],
162 [$this->getId()]
163 );
164
165 $this->flushAnswers();
166 while ($row = $this->db->fetchAssoc($result)) {
167 $this->addAnswer($row['answertext'] ?? '', $row['points'] ?? 0.0);
168 }
169
170 parent::loadFromDb($question_id);
171 }
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...
$data
Definition: storeScorm.php:45

References $data, Vendor\Package\$e, ilRTE\_replaceMediaObjectImageSrc(), addAnswer(), flushAnswers(), getAdditionalTableName(), assQuestion\getId(), 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 423 of file class.assTextQuestion.php.

424 {
425 $this->db->manipulateF(
426 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
427 ['integer'],
428 [$this->getId()]
429 );
430
431 $fields = [
432 'question_fi' => ['integer', $this->getId()],
433 'maxnumofchars' => ['integer', $this->getMaxNumOfChars()],
434 'word_cnt_enabled' => ['integer', (int) $this->isWordCounterEnabled()],
435 'keywords' => ['text', null],
436 'textgap_rating' => ['text', $this->getTextRating()],
437 'matchcondition' => ['integer', $this->getMatchcondition()],
438 'keyword_relation' => ['text', $this->getKeywordRelation()]
439 ];
440
441 $this->db->insert($this->getAdditionalTableName(), $fields);
442 }

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 113 of file class.assTextQuestion.php.

113 : void
114 {
118 parent::saveToDb();
119 }
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 389 of file class.assTextQuestion.php.

393 : bool {
394 if ($pass === null) {
395 $pass = ilObjTest::_getPass($active_id);
396 }
397
398 $answer = $this->getSolutionSubmit();
399 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
400 function () use ($answer, $active_id, $pass, $authorized) {
401 $this->removeCurrentSolution($active_id, $pass, $authorized);
402
403 if ($answer !== '') {
404 $this->saveCurrentSolution($active_id, $pass, $answer, null, $authorized);
405 }
406 }
407 );
408
409 return true;
410 }
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 641 of file class.assTextQuestion.php.

641 : void
642 {
643 if (isset($answers['answer'])) {
644 $count = count($answers['answer']);
645 $withPoints = true;
646 } else {
647 $count = count($answers);
648 $withPoints = false;
649 }
650
651 $this->flushAnswers();
652
653 for ($i = 0; $i < $count; $i++) {
654 if ($withPoints) {
655 $this->addAnswer(
656 $answers['answer'][$i],
657 $this->refinery->kindlyTo()->float()->transform($answers['points'][$i])
658 );
659 } else {
660 $this->addAnswer($answers[$i], 0);
661 }
662 }
663 }

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 694 of file class.assTextQuestion.php.

694 : void
695 {
696 if ($relation !== null) {
697 $this->keyword_relation = $relation;
698 }
699 }
$relation

References $relation.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setMatchcondition()

assTextQuestion::setMatchcondition ( int  $matchcondition)

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

96 : void
97 {
98 $this->matchcondition = $matchcondition;
99 }

References $matchcondition.

◆ setMaxNumOfChars()

assTextQuestion::setMaxNumOfChars ( int  $maxchars = 0)

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

178 : void
179 {
180 $this->max_num_of_chars = $maxchars;
181 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setTextRating()

◆ setWordCounterEnabled()

assTextQuestion::setWordCounterEnabled ( bool  $word_counter_enabled)

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

188 : void
189 {
190 $this->word_counter_enabled = $word_counter_enabled;
191 }

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 827 of file class.assTextQuestion.php.

830 : string {
831 if (!array_key_exists(0, $solution_values)
832 || !array_key_exists('value1', $solution_values[0])) {
833 return '';
834 }
835 return $this->refinery->string()->stripTags()->transform(
836 html_entity_decode($solution_values[0]['value1'])
837 );
838 }

◆ 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 840 of file class.assTextQuestion.php.

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

◆ toJSON()

assTextQuestion::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

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

519 : string
520 {
521 $result = [];
522 $result['id'] = $this->getId();
523 $result['type'] = (string) $this->getQuestionType();
524 $result['title'] = $this->getTitleForHTMLOutput();
525 $result['question'] = $this->formatSAQuestion($this->getQuestion());
526 $result['nr_of_tries'] = $this->getNrOfTries();
527 $result['shuffle'] = $this->getShuffle();
528 $result['maxlength'] = $this->getMaxNumOfChars();
529 return json_encode($result);
530 }

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 784 of file class.assTextQuestion.php.

784 : array
785 {
786 return [
787 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
788 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
789 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
790 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->getMaximumPoints(),
791 AdditionalInformationGenerator::KEY_QUESTION_TEXT_WORDCOUNT_ENABLED => $additional_info
793 AdditionalInformationGenerator::KEY_QUESTION_MAXCHARS => $this->getMaxNumOfChars(),
794 AdditionalInformationGenerator::KEY_QUESTION_TEXT_SCORING_MODE => $additional_info->getTagForLangVar(
796 ),
797 AdditionalInformationGenerator::KEY_QUESTION_CORRECT_ANSWER_OPTIONS => array_map(
798 fn(ASS_AnswerMultipleResponseImage $answer) => [
799 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION => $answer->getAnswertext(),
800 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $answer->getPoints() === 0.0 ? '' : $answer->getPoints()
801 ],
802 $this->getAnswers()
803 ),
804 AdditionalInformationGenerator::KEY_FEEDBACK => [
805 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
806 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
807 ]
808 ];
809 }
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:

◆ toNormalized()

assTextQuestion::toNormalized ( Transformations  $transformations,
array  $context = [] 
)
Parameters
array<string,mixed>$context
Returns
array<array-key, mixed>|float|bool|int|string|null

Reimplemented from assQuestion.

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

866 : array|float|bool|int|string|null
867 {
868 return [
869 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
870 'word_counter_enabled' => $this->word_counter_enabled,
871 'max_num_of_chars' => $this->max_num_of_chars,
872 'text_rating' => $this->text_rating,
873 'matchcondition' => $this->matchcondition,
874 'keyword_relation' => $this->keyword_relation,
875 'answers' => $transformations->normalize($this->answers),
876 ];
877 }

References ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\normalize().

+ Here is the call graph for this function:

Field Documentation

◆ $answers

array assTextQuestion::$answers = []

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

Referenced by calculateReachedPointsForSolution().

◆ $keyword_relation

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

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

◆ $keywords

array assTextQuestion::$keywords

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

◆ $matchcondition

int assTextQuestion::$matchcondition = 0
private

Definition at line 53 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 50 of file class.assTextQuestion.php.

Referenced by getMaxNumOfChars().

◆ $text_rating

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

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

◆ $word_counter_enabled

bool assTextQuestion::$word_counter_enabled = false
private

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

Referenced by isWordCounterEnabled(), and setWordCounterEnabled().

◆ HAS_SPECIFIC_FEEDBACK

const assTextQuestion::HAS_SPECIFIC_FEEDBACK = false
protected

Definition at line 43 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: