ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)
 
- Public Member Functions inherited from assQuestion
 getQuestionType ()
 
 isComplete ()
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 getCurrentUser ()
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML (string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping)
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 setShuffle (?bool $shuffle=true)
 
 setAuthor (string $author="")
 
 setOwner (int $owner=-1)
 
 getTitle ()
 
 getTitleForHTMLOutput ()
 
 getTitleFilenameCompliant ()
 
 getId ()
 
 getShuffle ()
 
 getTestId ()
 
 getComment ()
 
 getDescriptionForHTMLOutput ()
 
 getThumbSize ()
 
 setThumbSize (int $a_size)
 
 getMinimumThumbSize ()
 
 getMaximumThumbSize ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorized_solution=true)
 
 calculateResultsFromSolution (int $active_id, int $pass)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $preview_session)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 getSuggestedSolutionPath ()
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 getSuggestedSolutionPathWeb ()
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getTestOutputSolutions (int $activeId, int $pass)
 
 getUserSolutionPreferingIntermediate (int $active_id, ?int $pass=null)
 
 getSolutionValues (int $active_id, ?int $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 cloneXHTMLMediaObjectsOfQuestion (int $source_question_id)
 
 createPageObject ()
 
 clonePageOfQuestion (int $a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
 fixSvgToPng (string $imageFilenameContainingString)
 
 fixUnavailableSkinImageSources (string $html)
 
 loadFromDb (int $question_id)
 
 createNewQuestion (bool $a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb (?int $original_id=null)
 
 duplicate (bool $for_test=true, string $title='', string $author='', int $owner=-1, $test_obj_id=null)
 
 copyObject (int $target_parent_id, string $title='')
 
 createNewOriginalFromThisDuplicate (int $target_parent_id, string $target_question_title='')
 
 saveToDb (?int $original_id=null)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 
 resolveInternalLink (string $internal_link)
 
 resolveSuggestedSolutionLinks ()
 
 getInternalLinkHref (string $target)
 
 syncWithOriginal ()
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 isWriteable ()
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $preview_session)
 
 adjustReachedPointsByScoringOptions (float $points, int $active_id)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionTypeID ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 getNrOfTries ()
 
 setNrOfTries (int $a_nr_of_tries)
 
 setExportImagePath (string $path)
 
 formatSAQuestion ($a_q)
 
 setPreventRteUsage (bool $prevent_rte_usage)
 
 getPreventRteUsage ()
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode (bool $selfassessmenteditingmode)
 
 getSelfAssessmentEditingMode ()
 
 setDefaultNrOfTries (int $defaultnroftries)
 
 getDefaultNrOfTries ()
 
 syncSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 isAnswered (int $active_id, int $pass)
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange (int $lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 removeCurrentSolution (int $active_id, int $pass, bool $authorized=true)
 
 saveCurrentSolution (int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
 updateCurrentSolution (int $solutionId, $value1, $value2, bool $authorized=true)
 
 updateCurrentSolutionsAuthorization (int $activeId, int $pass, bool $authorized, bool $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 intermediateSolutionExists (int $active_id, int $pass)
 
 authorizedSolutionExists (int $active_id, ?int $pass)
 
 authorizedOrIntermediateSolutionExists (int $active_id, int $pass)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions (int $activeId, int $pass)
 
 resetUsersAnswer (int $activeId, int $pass)
 
 removeResultRecord (int $activeId, int $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $value_pairs)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
 hasWritableOriginalInQuestionPool ()
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 getSolutionForTextOutput (int $active_id, int $pass)
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
 getVariablesAsTextArray (int $active_id, int $pass)
 
 validateSolutionSubmit ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 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 ()
 

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 40 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 123 of file class.assTextSubset.php.

123 : void
124 {
125 if (array_key_exists($order, $this->answers)) {
126 // insert answer
127 $answer = new ASS_AnswerBinaryStateImage($answertext, $points, $order);
128 $newchoices = [];
129 for ($i = 0; $i < $order; $i++) {
130 $newchoices[] = $this->answers[$i];
131 }
132 $newchoices[] = $answer;
133 for ($i = $order, $iMax = count($this->answers); $i < $iMax; $i++) {
134 $changed = $this->answers[$i];
135 $changed->setOrder($i + 1);
136 $newchoices[] = $changed;
137 }
138 $this->answers = $newchoices;
139 } else {
140 // add answer
141 $this->answers[] = new ASS_AnswerBinaryStateImage($answertext, $points, count($this->answers));
142 }
143 }
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 686 of file class.assTextSubset.php.

686 : void
687 {
688 $this->addAnswer($answerOptionValue, $points, $qIndex);
689 }
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 339 of file class.assTextSubset.php.

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

References assQuestion\getSolutionMaxPass().

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assTextSubset::calculateReachedPointsForSolution ( ?array  $enteredTexts)
protected

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

591 : float
592 {
593 $enteredTexts ??= [];
594 $available_answers = $this->getAvailableAnswers();
595 $points = 0.0;
596 foreach ($enteredTexts as $enteredtext) {
597 $index = $this->isAnswerCorrect($available_answers, html_entity_decode($enteredtext));
598 if ($index !== false) {
599 unset($available_answers[$index]);
600 $points += $this->answers[$index]->getPoints();
601 }
602 }
603 return $points;
604 }
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 189 of file class.assTextSubset.php.

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

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

215 : void
216 {
217 $this->answers = [];
218 }

◆ 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 494 of file class.assTextSubset.php.

494 : string
495 {
496 return "qpl_qst_textsubset";
497 }

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

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

◆ 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 152 of file class.assTextSubset.php.

152 : int
153 {
154 return count($this->answers);
155 }

◆ getAnswers()

assTextSubset::getAnswers ( )

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

519 : array
520 {
521 return $this->answers;
522 }

◆ 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 505 of file class.assTextSubset.php.

505 : string
506 {
507 return "qpl_a_textsubset";
508 }

◆ 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 661 of file class.assTextSubset.php.

662 {
663 if ($index !== null) {
664 return $this->getAnswer($index);
665 } else {
666 return $this->getAnswers();
667 }
668 }
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 250 of file class.assTextSubset.php.

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

◆ getCorrectAnswers()

assTextSubset::getCorrectAnswers ( )

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

362 : int
363 {
365 }

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

754 : array
755 {
756 return $this->getAvailableAnswers();
757 }

◆ getExpressionTypes()

◆ getMatchingMethodLangVar()

assTextSubset::getMatchingMethodLangVar ( string  $matching_method)
private

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

714 : string
715 {
716 switch ($matching_method) {
718 return 'cloze_textgap_case_insensitive';
720 return 'cloze_textgap_case_sensitive';
722 return 'cloze_textgap_levenshtein_of:1';
724 return 'cloze_textgap_levenshtein_of:2';
726 return 'cloze_textgap_levenshtein_of:3';
728 return 'cloze_textgap_levenshtein_of:4';
730 return 'cloze_textgap_levenshtein_of:5';
731 default:
732 return '';
733 }
734 }
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 226 of file class.assTextSubset.php.

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

References $counter, 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 476 of file class.assTextSubset.php.

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

◆ getOperators()

assTextSubset::getOperators ( string  $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

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

606 : array
607 {
609 }
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 445 of file class.assTextSubset.php.

445 : string
446 {
447 return "assTextSubset";
448 }

◆ 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 514 of file class.assTextSubset.php.

514 : string
515 {
516 return parent::getRTETextWithMediaObjects();
517 }

◆ getSolutionSubmit()

assTextSubset::getSolutionSubmit ( )
protected
Returns
array

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

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

References Vendor\Package\$a, and $post.

◆ getTextRating()

assTextSubset::getTextRating ( )

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

316 : string
317 {
318 return $this->text_rating;
319 }

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

625 $result = new ilUserQuestionResult($this, $active_id, $pass);
626
627 $maxStep = $this->lookupMaxStep($active_id, $pass);
628 if ($maxStep > 0) {
629 $data = $this->db->queryF(
630 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s ORDER BY solution_id",
631 ["integer", "integer", "integer","integer"],
632 [$active_id, $pass, $this->getId(), $maxStep]
633 );
634 } else {
635 $data = $this->db->queryF(
636 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s ORDER BY solution_id",
637 ["integer", "integer", "integer"],
638 [$active_id, $pass, $this->getId()]
639 );
640 }
641
642 for ($index = 1; $index <= $this->db->numRows($data); ++$index) {
643 $row = $this->db->fetchAssoc($data);
644 $result->addKeyValue($index, $row["value1"]);
645 }
646
647 $points = $this->calculateReachedPoints($active_id, $pass);
648 $max_points = $this->getMaximumPoints();
649
650 $result->setReachedPercentage(($points / $max_points) * 100);
651
652 return $result;
653 }
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 670 of file class.assTextSubset.php.

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

◆ 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 269 of file class.assTextSubset.php.

270 {
271 global $DIC;
272 $refinery = $DIC->refinery();
273 $textrating = $this->getTextRating();
274
275 foreach ($answers as $key => $value) {
276 if ($this->answers[$key]->getPoints() <= 0) {
277 continue;
278 }
279 $value = html_entity_decode($value); #SB
280 switch ($textrating) {
282 if (strcmp(ilStr::strToLower($value), ilStr::strToLower($answer)) == 0) { #SB
283 return $key;
284 }
285 break;
287 if (strcmp($value, $answer) == 0) {
288 return $key;
289 }
290 break;
292 $transformation = $refinery->string()->levenshtein()->standard($answer, 1);
293 break;
295 $transformation = $refinery->string()->levenshtein()->standard($answer, 2);
296 break;
298 $transformation = $refinery->string()->levenshtein()->standard($answer, 3);
299 break;
301 $transformation = $refinery->string()->levenshtein()->standard($answer, 4);
302 break;
304 $transformation = $refinery->string()->levenshtein()->standard($answer, 5);
305 break;
306 }
307
308 // run answers against Levenshtein2 methods
309 if (isset($transformation) && $transformation->transform($value) >= 0) {
310 return $key;
311 }
312 }
313 return false;
314 }
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 46 of file class.assTextSubset.php.

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

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

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

◆ loadFromDb()

assTextSubset::loadFromDb ( int  $question_id)

Reimplemented from assQuestion.

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

69 : void
70 {
71 $result = $this->db->queryF(
72 "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",
73 ["integer"],
74 [$question_id]
75 );
76 if ($result->numRows() == 1) {
77 $data = $this->db->fetchAssoc($result);
78 $this->setId($question_id);
79 $this->setObjId($data['obj_fi']);
80 $this->setNrOfTries($data['nr_of_tries']);
81 $this->setTitle((string) $data['title']);
82 $this->setComment((string) $data['description']);
83 $this->setOriginalId($data['original_id']);
84 $this->setAuthor($data['author']);
85 $this->setPoints($data['points']);
86 $this->setOwner($data['owner']);
87 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data['question_text'], 1));
88 $this->setCorrectAnswers((int) $data['correctanswers']);
90
91 try {
95 }
96
97 try {
98 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
100 }
101 }
102
103
104 $result = $this->db->queryF(
105 "SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
106 ['integer'],
107 [$question_id]
108 );
109 if ($result->numRows() > 0) {
110 while ($data = $this->db->fetchAssoc($result)) {
111 $this->answers[] = new ASS_AnswerBinaryStateImage($data["answertext"], $data["points"], $data["aorder"]);
112 }
113 }
114
115 parent::loadFromDb($question_id);
116 }
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(), ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), 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 392 of file class.assTextSubset.php.

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

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

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

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

60 : void
61 {
65
66 parent::saveToDb();
67 }
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 367 of file class.assTextSubset.php.

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

357 : void
358 {
359 $this->correctanswers = $a_correct_answers;
360 }

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

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

◆ 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 746 of file class.assTextSubset.php.

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

◆ toJSON()

assTextSubset::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

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

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

691 : array
692 {
693 return [
694 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
695 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
696 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
697 AdditionalInformationGenerator::KEY_QUESTION_TEXT_MATCHING_METHOD => $additional_info->getTagForLangVar(
699 ),
700 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTIONS => array_map(
701 fn(ASS_AnswerBinaryStateImage $answer) => [
702 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION => $answer->getAnswertext(),
703 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $answer->getPoints()
704 ],
705 $this->getAnswers()
706 ),
707 AdditionalInformationGenerator::KEY_FEEDBACK => [
708 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
709 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
710 ]
711 ];
712 }
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:

Field Documentation

◆ $answers

array assTextSubset::$answers = []

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

◆ $correctanswers

int assTextSubset::$correctanswers = 0

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

◆ $text_rating

string assTextSubset::$text_rating = assClozeGap::TEXTGAP_RATING_CASEINSENSITIVE

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

Referenced by getTextRating(), and setTextRating().


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