ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
assTextSubset Class Reference

Class for TextSubset questions. More...

+ Inheritance diagram for assTextSubset:
+ Collaboration diagram for assTextSubset:

Public Member Functions

 isComplete ()
 
 saveToDb (?int $original_id=null)
 
 loadFromDb (int $question_id)
 
 addAnswer ($answertext, $points, $order)
 Adds an answer to the question. More...
 
 getAnswerCount ()
 Returns the number of answers. More...
 
 getAnswer ($index=0)
 Returns an answer with a given index. More...
 
 deleteAnswer ($index=0)
 Deletes an answer with a given index. More...
 
 flushAnswers ()
 Deletes all answers. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getAvailableAnswers ()
 Returns the available answers for the question. More...
 
 isAnswerCorrect ($answers, $answer)
 Returns the index of the found answer, if the given answer is in the set of correct answers and matchess the matching options, otherwise FALSE is returned. More...
 
 getTextRating ()
 
 setTextRating (string $text_rating)
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 setCorrectAnswers (int $a_correct_answers)
 
 getCorrectAnswers ()
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
& joinAnswers ()
 Returns the answers of the question as a comma separated string. More...
 
 getMaxTextboxWidth ()
 Returns the maximum width needed for the answer textboxes. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer 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...
 
 getAnswers ()
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getOperators (string $expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getUserQuestionResult (int $active_id, int $pass)
 Get the user solution for a question by active_id and the test pass. More...
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
 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...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
- Public Member Functions inherited from iQuestionCondition
 getOperators (string $expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getUserQuestionResult (int $active_id, int $pass)
 Get the user solution for a question by active_id and the test pass. More...
 
 getAvailableAnswerOptions (?int $index=null)
 If index is null, the function returns an array with all anwser options else it returns the specific answer option. 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...
 

Data Fields

array $answers = []
 
int $correctanswers = 0
 
string $text_rating = assClozeGap::TEXTGAP_RATING_CASEINSENSITIVE
 
- 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 = ':'
 
- Data Fields inherited from iQuestionCondition
const StringResultExpression = '~TEXT~'
 
const PercentageResultExpression = '%n%'
 
const NumericResultExpression = '#n#'
 
const MatchingResultExpression = ';n:m;'
 
const OrderingResultExpression = '$n,m,o,p$'
 
const NumberOfResultExpression = '+n+'
 
const ExclusiveResultExpression = '*n,m,o,p*'
 
const EmptyAnswerExpression = "?"
 

Protected Member Functions

 getSolutionSubmit ()
 
 calculateReachedPointsForSolution (?array $enteredTexts)
 
 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)
 

Private Member Functions

 getMatchingMethodLangVar (string $matching_method)
 

Additional Inherited Members

- 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...
 
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 
- 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
 
- Static Protected Attributes inherited from assQuestion
static $force_pass_results_update_enabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

Class for TextSubset questions.

assTextSubset is a class for TextSubset questions. To solve a TextSubset question, a learner has to enter a TextSubsetal value in a defined range

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
Nina Gharib nina@.nosp@m.wgse.nosp@m.rve.d.nosp@m.e
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 43 of file class.assTextSubset.php.

Member Function Documentation

◆ addAnswer()

assTextSubset::addAnswer (   $answertext,
  $points,
  $order 
)

Adds an answer to the question.

@access public

Definition at line 126 of file class.assTextSubset.php.

126 : void
127 {
128 if (array_key_exists($order, $this->answers)) {
129 // insert answer
130 $answer = new ASS_AnswerBinaryStateImage($answertext, $points, $order);
131 $newchoices = [];
132 for ($i = 0; $i < $order; $i++) {
133 $newchoices[] = $this->answers[$i];
134 }
135 $newchoices[] = $answer;
136 for ($i = $order, $iMax = count($this->answers); $i < $iMax; $i++) {
137 $changed = $this->answers[$i];
138 $changed->setOrder($i + 1);
139 $newchoices[] = $changed;
140 }
141 $this->answers = $newchoices;
142 } else {
143 // add answer
144 $this->answers[] = new ASS_AnswerBinaryStateImage($answertext, $points, count($this->answers));
145 }
146 }
Class for answers with a binary state indicator.

References assQuestion\$points.

◆ addAnswerOptionValue()

assTextSubset::addAnswerOptionValue ( int  $qIndex,
string  $answerOptionValue,
float  $points 
)

Reimplemented from assQuestion.

Definition at line 689 of file class.assTextSubset.php.

689 : void
690 {
691 $this->addAnswer($answerOptionValue, $points, $qIndex);
692 }
addAnswer($answertext, $points, $order)
Adds an answer to the question.

◆ calculateReachedPoints()

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

Reimplemented from assQuestion.

Definition at line 342 of file class.assTextSubset.php.

346 : float {
347 if ($pass === null) {
348 $pass = $this->getSolutionMaxPass($active_id);
349 }
350 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
351
352 $enteredTexts = [];
353 while ($data = $this->db->fetchAssoc($result)) {
354 $enteredTexts[] = $data['value1'];
355 }
356
357 return $this->calculateReachedPointsForSolution($enteredTexts);
358 }
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
getSolutionMaxPass(int $active_id)
calculateReachedPointsForSolution(?array $enteredTexts)
$data
Definition: storeScorm.php:45

References assQuestion\getSolutionMaxPass().

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assTextSubset::calculateReachedPointsForSolution ( ?array  $enteredTexts)
protected

Definition at line 594 of file class.assTextSubset.php.

594 : float
595 {
596 $enteredTexts ??= [];
597 $available_answers = $this->getAvailableAnswers();
598 $points = 0.0;
599 foreach ($enteredTexts as $enteredtext) {
600 $index = $this->isAnswerCorrect($available_answers, html_entity_decode($enteredtext));
601 if ($index !== false) {
602 unset($available_answers[$index]);
603 $points += $this->answers[$index]->getPoints();
604 }
605 }
606 return $points;
607 }
isAnswerCorrect($answers, $answer)
Returns the index of the found answer, if the given answer is in the set of correct answers and match...
getAvailableAnswers()
Returns the available answers for the question.

◆ deleteAnswer()

assTextSubset::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 192 of file class.assTextSubset.php.

192 : void
193 {
194 if ($index < 0) {
195 return;
196 }
197 if (count($this->answers) < 1) {
198 return;
199 }
200 if ($index >= count($this->answers)) {
201 return;
202 }
203 unset($this->answers[$index]);
204 $this->answers = array_values($this->answers);
205 for ($i = 0, $iMax = count($this->answers); $i < $iMax; $i++) {
206 if ($this->answers[$i]->getOrder() > $index) {
207 $this->answers[$i]->setOrder($i);
208 }
209 }
210 }

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

+ Here is the call graph for this function:

◆ flushAnswers()

assTextSubset::flushAnswers ( )

Deletes all answers.

@access public

See also
$answers

Definition at line 218 of file class.assTextSubset.php.

218 : void
219 {
220 $this->answers = [];
221 }

◆ fromNormalized()

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

Reimplemented from assQuestion.

Definition at line 777 of file class.assTextSubset.php.

780 : static
781 {
782 $clone = parent::fromNormalized($normalized, $transformations);
783 $clone->text_rating = $transformations->string($normalized['text_rating']);
784 $clone->correctanswers = $transformations->int($normalized['correct_answers']);
785 $clone->answers = array_map(
786 static fn(array $answer): ASS_AnswerBinaryStateImage => $transformations->denormalize(
787 $answer,
789 ),
790 $normalized['answers']
791 );
792 return $clone;
793 }
denormalize(array|float|bool|int|string|null $normalized, string|object $expected)

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

assTextSubset::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 497 of file class.assTextSubset.php.

497 : string
498 {
499 return "qpl_qst_textsubset";
500 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ getAnswer()

assTextSubset::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_assAnswerBinaryStateImage-Object containing the answer @access public
See also
$answers

Definition at line 169 of file class.assTextSubset.php.

169 : ?object
170 {
171 if ($index < 0) {
172 return null;
173 }
174 if (count($this->answers) < 1) {
175 return null;
176 }
177 if ($index >= count($this->answers)) {
178 return null;
179 }
180
181 return $this->answers[$index];
182 }

◆ getAnswerCount()

assTextSubset::getAnswerCount ( )

Returns the number of answers.

Returns
integer The number of answers of the TextSubset question @access public
See also
$ranges

Definition at line 155 of file class.assTextSubset.php.

155 : int
156 {
157 return count($this->answers);
158 }

◆ getAnswers()

assTextSubset::getAnswers ( )

Definition at line 522 of file class.assTextSubset.php.

522 : array
523 {
524 return $this->answers;
525 }

◆ getAnswerTableName()

assTextSubset::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name @access public

Reimplemented from assQuestion.

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

508 : string
509 {
510 return "qpl_a_textsubset";
511 }

◆ getAvailableAnswerOptions()

assTextSubset::getAvailableAnswerOptions (   $index = null)

If index is null, the function returns an array with all anwser options Else it returns the specific answer option.

Parameters
null | int$index

Definition at line 664 of file class.assTextSubset.php.

665 {
666 if ($index !== null) {
667 return $this->getAnswer($index);
668 } else {
669 return $this->getAnswers();
670 }
671 }
getAnswer($index=0)
Returns an answer with a given index.

◆ getAvailableAnswers()

assTextSubset::getAvailableAnswers ( )

Returns the available answers for the question.

@access private

See also
$answers

Definition at line 253 of file class.assTextSubset.php.

253 : array
254 {
255 $available_answers = [];
256 foreach ($this->answers as $answer) {
257 $available_answers[] = $answer->getAnswertext();
258 }
259 return $available_answers;
260 }

◆ getCorrectAnswers()

assTextSubset::getCorrectAnswers ( )

Definition at line 365 of file class.assTextSubset.php.

365 : int
366 {
368 }

Referenced by getMaximumPoints().

+ Here is the caller graph for this function:

◆ getCorrectSolutionForTextOutput()

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

Reimplemented from assQuestion.

Definition at line 757 of file class.assTextSubset.php.

757 : array
758 {
759 return $this->getAvailableAnswers();
760 }

◆ getExpressionTypes()

◆ getMatchingMethodLangVar()

assTextSubset::getMatchingMethodLangVar ( string  $matching_method)
private

Definition at line 717 of file class.assTextSubset.php.

717 : string
718 {
719 switch ($matching_method) {
721 return 'cloze_textgap_case_insensitive';
723 return 'cloze_textgap_case_sensitive';
725 return 'cloze_textgap_levenshtein_of:1';
727 return 'cloze_textgap_levenshtein_of:2';
729 return 'cloze_textgap_levenshtein_of:3';
731 return 'cloze_textgap_levenshtein_of:4';
733 return 'cloze_textgap_levenshtein_of:5';
734 default:
735 return '';
736 }
737 }
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

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

◆ getMaximumPoints()

assTextSubset::getMaximumPoints ( )

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

@access public

See also
$points

Reimplemented from assQuestion.

Definition at line 229 of file class.assTextSubset.php.

229 : float
230 {
231 $points = [];
232 foreach ($this->answers as $answer) {
233 if ($answer->getPoints() > 0) {
234 $points[] = $answer->getPoints();
235 }
236 }
237 rsort($points, SORT_NUMERIC);
238 $maxpoints = 0;
239 for ($counter = 0; $counter < $this->getCorrectAnswers(); $counter++) {
240 if (isset($points[$counter])) {
241 $maxpoints += $points[$counter];
242 }
243 }
244 return $maxpoints;
245 }

References assQuestion\$points, and getCorrectAnswers().

Referenced by isComplete().

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

◆ getMaxTextboxWidth()

assTextSubset::getMaxTextboxWidth ( )

Returns the maximum width needed for the answer textboxes.

Returns
integer Maximum textbox width @access public

Definition at line 479 of file class.assTextSubset.php.

479 : int
480 {
481 $maxwidth = 0;
482 foreach ($this->answers as $answer) {
483 $len = strlen($answer->getAnswertext());
484 if ($len > $maxwidth) {
485 $maxwidth = $len;
486 }
487 }
488 return $maxwidth + 3;
489 }

◆ getOperators()

assTextSubset::getOperators ( string  $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

Definition at line 609 of file class.assTextSubset.php.

609 : array
610 {
612 }
static getOperatorsByExpression(string $expression)

References ilOperatorsExpressionMapping\getOperatorsByExpression().

+ Here is the call graph for this function:

◆ getQuestionType()

assTextSubset::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question @access public

Reimplemented from assQuestion.

Definition at line 448 of file class.assTextSubset.php.

448 : string
449 {
450 return "assTextSubset";
451 }

◆ getRTETextWithMediaObjects()

assTextSubset::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 517 of file class.assTextSubset.php.

517 : string
518 {
519 return parent::getRTETextWithMediaObjects();
520 }

◆ getSolutionSubmit()

assTextSubset::getSolutionSubmit ( )
protected
Returns
array

Definition at line 571 of file class.assTextSubset.php.

571 : array
572 {
573 $purifier = $this->getHtmlUserSolutionPurifier();
574 $post = $this->dic->http()->wrapper()->post();
575
576 $solutionSubmit = [];
577 foreach ($this->getAnswers() as $index => $a) {
578 if ($post->has("TEXTSUBSET_$index")) {
579 $value = $post->retrieve(
580 "TEXTSUBSET_$index",
581 $this->dic->refinery()->kindlyTo()->string()
582 );
583 if ($value) {
584 $value = $this->extendedTrim($value);
585 $value = $purifier->purify($value);
586 $solutionSubmit[] = $value;
587 }
588 }
589 }
590
591 return $solutionSubmit;
592 }
static extendedTrim(string $value)
Trim non-printable characters from the beginning and end of a string.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a.

◆ getTextRating()

assTextSubset::getTextRating ( )

Definition at line 319 of file class.assTextSubset.php.

319 : string
320 {
321 return $this->text_rating;
322 }

References $text_rating.

Referenced by isAnswerCorrect().

+ Here is the caller graph for this function:

◆ getUserQuestionResult()

assTextSubset::getUserQuestionResult ( int  $active_id,
int  $pass 
)

Get the user solution for a question by active_id and the test pass.

Implements iQuestionCondition.

Definition at line 624 of file class.assTextSubset.php.

628 $result = new ilUserQuestionResult($this, $active_id, $pass);
629
630 $maxStep = $this->lookupMaxStep($active_id, $pass);
631 if ($maxStep > 0) {
632 $data = $this->db->queryF(
633 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s ORDER BY solution_id",
634 ["integer", "integer", "integer","integer"],
635 [$active_id, $pass, $this->getId(), $maxStep]
636 );
637 } else {
638 $data = $this->db->queryF(
639 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s ORDER BY solution_id",
640 ["integer", "integer", "integer"],
641 [$active_id, $pass, $this->getId()]
642 );
643 }
644
645 for ($index = 1; $index <= $this->db->numRows($data); ++$index) {
646 $row = $this->db->fetchAssoc($data);
647 $result->addKeyValue($index, $row["value1"]);
648 }
649
650 $points = $this->calculateReachedPoints($active_id, $pass);
651 $max_points = $this->getMaximumPoints();
652
653 $result->setReachedPercentage(($points / $max_points) * 100);
654
655 return $result;
656 }
lookupMaxStep(int $active_id, int $pass)
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ isAddableAnswerOptionValue()

assTextSubset::isAddableAnswerOptionValue ( int  $qIndex,
string  $answerOptionValue 
)

Reimplemented from assQuestion.

Definition at line 673 of file class.assTextSubset.php.

673 : bool
674 {
675 $found = false;
676
677 foreach ($this->getAnswers() as $item) {
678 if ($answerOptionValue !== $item->getAnswerText()) {
679 continue;
680 }
681
682 $found = true;
683 break;
684 }
685
686 return !$found;
687 }

◆ isAnswerCorrect()

assTextSubset::isAnswerCorrect (   $answers,
  $answer 
)

Returns the index of the found answer, if the given answer is in the set of correct answers and matchess the matching options, otherwise FALSE is returned.

Parameters
array$answersAn array containing the correct answers
string$answerThe text of the given answer
Returns
mixed The index of the correct answer, FALSE otherwise @access public

Definition at line 272 of file class.assTextSubset.php.

273 {
274 global $DIC;
275 $refinery = $DIC->refinery();
276 $textrating = $this->getTextRating();
277
278 foreach ($answers as $key => $value) {
279 if ($this->answers[$key]->getPoints() <= 0) {
280 continue;
281 }
282 $value = html_entity_decode($value); #SB
283 switch ($textrating) {
285 if (strcmp(ilStr::strToLower($value), ilStr::strToLower($answer)) == 0) { #SB
286 return $key;
287 }
288 break;
290 if (strcmp($value, $answer) == 0) {
291 return $key;
292 }
293 break;
295 $transformation = $refinery->string()->levenshtein()->standard($answer, 1);
296 break;
298 $transformation = $refinery->string()->levenshtein()->standard($answer, 2);
299 break;
301 $transformation = $refinery->string()->levenshtein()->standard($answer, 3);
302 break;
304 $transformation = $refinery->string()->levenshtein()->standard($answer, 4);
305 break;
307 $transformation = $refinery->string()->levenshtein()->standard($answer, 5);
308 break;
309 }
310
311 // run answers against Levenshtein2 methods
312 if (isset($transformation) && $transformation->transform($value) >= 0) {
313 return $key;
314 }
315 }
316 return false;
317 }
Refinery $refinery
static strToLower(string $a_string)
Definition: class.ilStr.php:69
global $DIC
Definition: shib_login.php:26

References $DIC, assQuestion\$refinery, assQuestion\getPoints(), getTextRating(), 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.

+ Here is the call graph for this function:

◆ isComplete()

assTextSubset::isComplete ( )

Reimplemented from assQuestion.

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

49 : bool
50 {
51 if (
52 strlen($this->title)
53 && $this->author
54 && $this->question &&
55 count($this->answers) >= $this->correctanswers
56 && $this->getMaximumPoints() > 0
57 ) {
58 return true;
59 }
60 return false;
61 }

References getMaximumPoints().

+ Here is the call graph for this function:

◆ joinAnswers()

& assTextSubset::joinAnswers ( )

Returns the answers of the question as a comma separated string.

Definition at line 457 of file class.assTextSubset.php.

457 : array
458 {
459 $join = [];
460 foreach ($this->answers as $answer) {
461 $key = $answer->getPoints() . '';
462
463 if (!isset($join[$key]) || !is_array($join[$key])) {
464 $join[$key] = [];
465 }
466
467 $join[$key][] = $answer->getAnswertext();
468 }
469
470 return $join;
471 }

◆ loadFromDb()

assTextSubset::loadFromDb ( int  $question_id)

Reimplemented from assQuestion.

Definition at line 72 of file class.assTextSubset.php.

72 : void
73 {
74 $result = $this->db->queryF(
75 "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",
76 ["integer"],
77 [$question_id]
78 );
79 if ($result->numRows() == 1) {
80 $data = $this->db->fetchAssoc($result);
81 $this->setId($question_id);
82 $this->setObjId($data['obj_fi']);
83 $this->setNrOfTries($data['nr_of_tries']);
84 $this->setTitle((string) $data['title']);
85 $this->setComment((string) $data['description']);
86 $this->setOriginalId($data['original_id']);
87 $this->setAuthor($data['author']);
88 $this->setPoints($data['points']);
89 $this->setOwner($data['owner']);
90 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data['question_text'], 1));
91 $this->setCorrectAnswers((int) $data['correctanswers']);
93
94 try {
95 $this->setLifecycle(new ilAssQuestionLifecycle($data['lifecycle']));
98 }
99
100 try {
101 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
103 }
104 }
105
106
107 $result = $this->db->queryF(
108 "SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
109 ['integer'],
110 [$question_id]
111 );
112 if ($result->numRows() > 0) {
113 while ($data = $this->db->fetchAssoc($result)) {
114 $this->answers[] = new ASS_AnswerBinaryStateImage($data["answertext"], $data["points"], $data["aorder"]);
115 }
116 }
117
118 parent::loadFromDb($question_id);
119 }
setOriginalId(?int $original_id)
setId(int $id=-1)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
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)
setCorrectAnswers(int $a_correct_answers)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setTextRating(string $text_rating)
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(), getAdditionalTableName(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), setCorrectAnswers(), assQuestion\setId(), assQuestion\setLifecycle(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setTextRating(), assQuestion\setTitle(), and assClozeGap\TEXTGAP_RATING_CASEINSENSITIVE.

+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assTextSubset::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

Definition at line 395 of file class.assTextSubset.php.

396 {
397 // save additional data
398 $this->db->manipulateF(
399 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
400 [ "integer" ],
401 [ $this->getId() ]
402 );
403
404 $this->db->manipulateF(
405 "INSERT INTO " . $this->getAdditionalTableName(
406 ) . " (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
407 [ "integer", "text", "integer" ],
408 [
409 $this->getId(),
410 $this->getTextRating(),
411 $this->getCorrectAnswers()
412 ]
413 );
414 }

References ILIAS\Survey\Mode\getId().

Referenced by saveToDb().

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

◆ saveAnswerSpecificDataToDb()

assTextSubset::saveAnswerSpecificDataToDb ( )

Saves the answer specific records into a question types answer table.

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

Definition at line 416 of file class.assTextSubset.php.

417 {
418 $this->db->manipulateF(
419 "DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
420 [ 'integer' ],
421 [ $this->getId() ]
422 );
423
424 foreach ($this->answers as $key => $value) {
425 $answer_obj = $this->answers[$key];
426 $next_id = $this->db->nextId('qpl_a_textsubset');
427 $this->db->manipulateF(
428 "INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
429 [ 'integer', 'integer', 'text', 'float', 'integer', 'integer' ],
430 [
431 $next_id,
432 $this->getId(),
433 $answer_obj->getAnswertext(),
434 $answer_obj->getPoints(),
435 $answer_obj->getOrder(),
436 time()
437 ]
438 );
439 }
440 }

References ILIAS\Survey\Mode\getId().

Referenced by saveToDb().

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

◆ saveToDb()

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

Reimplemented from assQuestion.

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

63 : void
64 {
68
69 parent::saveToDb();
70 }
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(), saveAnswerSpecificDataToDb(), and assQuestion\saveQuestionDataToDb().

+ Here is the call graph for this function:

◆ saveWorkingData()

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

Reimplemented from assQuestion.

Definition at line 370 of file class.assTextSubset.php.

374 : bool {
375 if ($pass === null) {
376 $pass = ilObjTest::_getPass($active_id);
377 }
378
379 $solution_submit = $this->getSolutionSubmit();
380 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
381 function () use ($active_id, $pass, $authorized, $solution_submit) {
382 $this->removeCurrentSolution($active_id, $pass, $authorized);
383
384 foreach ($solution_submit as $value) {
385 if ($value !== '') {
386 $this->saveCurrentSolution($active_id, $pass, $value, null, $authorized);
387 }
388 }
389 }
390 );
391
392 return true;
393 }
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:

◆ setCorrectAnswers()

assTextSubset::setCorrectAnswers ( int  $a_correct_answers)

Definition at line 360 of file class.assTextSubset.php.

360 : void
361 {
362 $this->correctanswers = $a_correct_answers;
363 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setTextRating()

◆ solutionValuesToLog()

assTextSubset::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 739 of file class.assTextSubset.php.

742 : array {
743 return array_map(
744 static fn(array $v): string => $v['value1'],
745 $solution_values
746 );
747 }

◆ solutionValuesToText()

assTextSubset::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 749 of file class.assTextSubset.php.

749 : array
750 {
751 return array_map(
752 static fn(array $v): string => $v['value1'],
753 $solution_values
754 );
755 }

◆ toJSON()

assTextSubset::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

Definition at line 530 of file class.assTextSubset.php.

530 : string
531 {
532 $result = [];
533 $result['id'] = $this->getId();
534 $result['type'] = (string) $this->getQuestionType();
535 $result['title'] = $this->getTitleForHTMLOutput();
536 $result['question'] = $this->formatSAQuestion($this->getQuestion());
537 $result['nr_of_tries'] = $this->getNrOfTries();
538 $result['matching_method'] = $this->getTextRating();
539 $result['feedback'] = [
540 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
541 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
542 ];
543
544 $answers = [];
545 foreach ($this->getAnswers() as $key => $answer_obj) {
546 $answers[] = [
547 "answertext" => (string) $answer_obj->getAnswertext(),
548 "points" => (float) $answer_obj->getPoints(),
549 "order" => (int) $answer_obj->getOrder()
550 ];
551 }
552 $result['correct_answers'] = $answers;
553
554 $answers = [];
555 for ($loop = 1; $loop <= $this->getCorrectAnswers(); $loop++) {
556 $answers[] = [
557 "answernr" => $loop
558 ];
559 }
560 $result['answers'] = $answers;
561
562 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
563 $result['mobs'] = $mobs;
564
565 return json_encode($result);
566 }
getQuestionType()
Returns the question type of the question.
static _getMobsOfObject(string $a_type, int $a_id, int|false $a_usage_hist_nr=0, string $a_lang="-")

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

+ Here is the call graph for this function:

◆ toLog()

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

694 : array
695 {
696 return [
697 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
698 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
699 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
700 AdditionalInformationGenerator::KEY_QUESTION_TEXT_MATCHING_METHOD => $additional_info->getTagForLangVar(
702 ),
703 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTIONS => array_map(
704 fn(ASS_AnswerBinaryStateImage $answer) => [
705 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION => $answer->getAnswertext(),
706 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $answer->getPoints()
707 ],
708 $this->getAnswers()
709 ),
710 AdditionalInformationGenerator::KEY_FEEDBACK => [
711 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
712 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
713 ]
714 ];
715 }
getPoints()
Gets the points.
getAnswertext()
Gets the answer text.
getMatchingMethodLangVar(string $matching_method)

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

+ Here is the call graph for this function:

◆ toNormalized()

assTextSubset::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 763 of file class.assTextSubset.php.

766 : array|float|bool|int|string|null
767 {
768 return [
769 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
770 'text_rating' => $this->text_rating,
771 'correct_answers' => $this->correctanswers,
772 'answers' => $transformations->normalize($this->answers),
773 ];
774 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $answers

array assTextSubset::$answers = []

Definition at line 45 of file class.assTextSubset.php.

◆ $correctanswers

int assTextSubset::$correctanswers = 0

Definition at line 46 of file class.assTextSubset.php.

◆ $text_rating

string assTextSubset::$text_rating = assClozeGap::TEXTGAP_RATING_CASEINSENSITIVE

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

Referenced by getTextRating(), and setTextRating().


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