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

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

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 _setReachedPoints (int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $question_id)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
static extendedTrim (string $value)
 Trim non-printable characters from the beginning and end of a string. More...
 
- 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
 
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.

public

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

References assQuestion\$points.

Referenced by addAnswerOptionValue().

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.
+ Here is the caller graph for this function:

◆ addAnswerOptionValue()

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

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

References addAnswer().

686  : void
687  {
688  $this->addAnswer($answerOptionValue, $points, $qIndex);
689  }
addAnswer($answertext, $points, $order)
Adds an answer to the question.
+ Here is the call graph for this function:

◆ calculateReachedPoints()

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

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

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

Referenced by getUserQuestionResult().

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  }
calculateReachedPointsForSolution(?array $enteredTexts)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getSolutionMaxPass(int $active_id)
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsForSolution()

assTextSubset::calculateReachedPointsForSolution ( ?array  $enteredTexts)
protected

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

References assQuestion\$points, getAvailableAnswers(), and isAnswerCorrect().

Referenced by calculateReachedPoints().

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  }
getAvailableAnswers()
Returns the available answers for the question.
isAnswerCorrect($answers, $answer)
Returns the index of the found answer, if the given answer is in the set of correct answers and match...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 public
See also
$answers

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

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

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  }
+ Here is the call graph for this function:

◆ flushAnswers()

assTextSubset::flushAnswers ( )

Deletes all answers.

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 public

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

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

494  : string
495  {
496  return "qpl_qst_textsubset";
497  }
+ 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 public
See also
$answers

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

References null.

Referenced by getAvailableAnswerOptions().

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getAnswerCount()

assTextSubset::getAnswerCount ( )

Returns the number of answers.

Returns
integer The number of answers of the TextSubset question 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.

References $answers.

Referenced by getAvailableAnswerOptions(), getSolutionSubmit(), isAddableAnswerOptionValue(), toJSON(), and toLog().

519  : array
520  {
521  return $this->answers;
522  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assTextSubset::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name public

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.

References getAnswer(), getAnswers(), and null.

662  {
663  if ($index !== null) {
664  return $this->getAnswer($index);
665  } else {
666  return $this->getAnswers();
667  }
668  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getAnswer($index=0)
Returns an answer with a given index.
+ Here is the call graph for this function:

◆ getAvailableAnswers()

assTextSubset::getAvailableAnswers ( )

Returns the available answers for the question.

private

See also
$answers

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

Referenced by calculateReachedPointsForSolution(), and getCorrectSolutionForTextOutput().

250  : array
251  {
252  $available_answers = [];
253  foreach ($this->answers as $answer) {
254  $available_answers[] = $answer->getAnswertext();
255  }
256  return $available_answers;
257  }
+ Here is the caller graph for this function:

◆ getCorrectAnswers()

assTextSubset::getCorrectAnswers ( )

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

References $correctanswers.

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

362  : int
363  {
364  return $this->correctanswers;
365  }
+ Here is the caller graph for this function:

◆ getCorrectSolutionForTextOutput()

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

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

References getAvailableAnswers().

754  : array
755  {
756  return $this->getAvailableAnswers();
757  }
getAvailableAnswers()
Returns the available answers for the question.
+ Here is the call graph for this function:

◆ getExpressionTypes()

◆ getMatchingMethodLangVar()

assTextSubset::getMatchingMethodLangVar ( string  $matching_method)
private

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

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

Referenced by toLog().

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_LEVENSHTEIN3
const TEXTGAP_RATING_CASEINSENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN1
const TEXTGAP_RATING_LEVENSHTEIN4
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assTextSubset::getMaximumPoints ( )

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

public

See also
$points

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

References assQuestion\$points, and getCorrectAnswers().

Referenced by getUserQuestionResult(), and isComplete().

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  }
+ 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 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  {
608  return ilOperatorsExpressionMapping::getOperatorsByExpression($expression);
609  }

◆ getQuestionType()

assTextSubset::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

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

Referenced by toJSON(), and toLog().

445  : string
446  {
447  return "assTextSubset";
448  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assTextSubset::getRTETextWithMediaObjects ( )

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

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.

References Vendor\Package\$a, $post, assQuestion\extendedTrim(), getAnswers(), and assQuestion\getHtmlUserSolutionPurifier().

Referenced by saveWorkingData().

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.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextRating()

assTextSubset::getTextRating ( )

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

References $text_rating.

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

316  : string
317  {
318  return $this->text_rating;
319  }
+ 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.

References $data, assQuestion\$points, calculateReachedPoints(), assQuestion\getId(), getMaximumPoints(), and assQuestion\lookupMaxStep().

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  }
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
lookupMaxStep(int $active_id, int $pass)
+ Here is the call graph for this function:

◆ isAddableAnswerOptionValue()

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

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

References getAnswers().

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  }
+ Here is the call graph for this function:

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

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

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.

Referenced by calculateReachedPointsForSolution().

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  }
const TEXTGAP_RATING_LEVENSHTEIN3
Refinery $refinery
const TEXTGAP_RATING_CASEINSENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN1
global $DIC
Definition: shib_login.php:22
static strToLower(string $a_string)
Definition: class.ilStr.php:72
const TEXTGAP_RATING_LEVENSHTEIN4
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isComplete()

assTextSubset::isComplete ( )

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

References getMaximumPoints().

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  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ 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)

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

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.

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']);
99  } catch (ilTestQuestionPoolException $e) {
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  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setNrOfTries(int $a_nr_of_tries)
setCorrectAnswers(int $a_correct_answers)
Class for answers with a binary state indicator.
setOwner(int $owner=-1)
const TEXTGAP_RATING_CASEINSENSITIVE
setComment(string $comment="")
setTextRating(string $text_rating)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setPoints(float $points)
setObjId(int $obj_id=0)
setId(int $id=-1)
setOriginalId(?int $original_id)
setTitle(string $title="")
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setAuthor(string $author="")
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
+ 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.

References getAdditionalTableName(), getCorrectAnswers(), assQuestion\getId(), and getTextRating().

Referenced by saveToDb().

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  }
getAdditionalTableName()
Returns the name of the additional question data table in the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

References assQuestion\getId().

Referenced by saveToDb().

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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

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

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

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

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.
+ Here is the call graph for this function:

◆ saveWorkingData()

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

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

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

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  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
+ Here is the call graph for this function:

◆ setCorrectAnswers()

assTextSubset::setCorrectAnswers ( int  $a_correct_answers)

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

Referenced by loadFromDb().

357  : void
358  {
359  $this->correctanswers = $a_correct_answers;
360  }
+ Here is the caller graph for this function:

◆ setTextRating()

assTextSubset::setTextRating ( string  $text_rating)

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

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

Referenced by loadFromDb().

321  : void
322  {
323  switch ($text_rating) {
331  $this->text_rating = $text_rating;
332  break;
333  default:
334  $this->text_rating = assClozeGap::TEXTGAP_RATING_CASEINSENSITIVE;
335  break;
336  }
337  }
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASEINSENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN1
const TEXTGAP_RATING_LEVENSHTEIN4
+ Here is the caller graph for this function:

◆ solutionValuesToLog()

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

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)

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.

Implements ILIAS\TestQuestionPool\Questions\QuestionLMExportable.

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

References $answers, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getAnswers(), getCorrectAnswers(), assQuestion\getId(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), getTextRating(), assQuestion\getTitleForHTMLOutput(), and ILIAS\Repository\int().

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="-")
+ Here is the call graph for this function:

◆ toLog()

assTextSubset::toLog ( AdditionalInformationGenerator  $additional_info)

Implements ILIAS\TestQuestionPool\Questions\Question.

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

References assQuestion\formatSAQuestion(), getAnswers(), ASS_AnswerSimple\getAnswertext(), getMatchingMethodLangVar(), ASS_AnswerSimple\getPoints(), assQuestion\getQuestion(), getQuestionType(), ILIAS\Test\Logging\AdditionalInformationGenerator\getTagForLangVar(), getTextRating(), and assQuestion\getTitleForHTMLOutput().

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(
698  $this->getMatchingMethodLangVar($this->getTextRating())
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  }
Class for answers with a binary state indicator.
getQuestionType()
Returns the question type of the question.
getPoints()
Gets the points.
getMatchingMethodLangVar(string $matching_method)
getAnswertext()
Gets the answer text.
+ Here is the call graph for this function:

Field Documentation

◆ $answers

array assTextSubset::$answers = []

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

Referenced by getAnswers(), and toJSON().

◆ $correctanswers

int assTextSubset::$correctanswers = 0

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

Referenced by getCorrectAnswers().

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