ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
assErrorText Class Reference

Class for error text questions. More...

+ Inheritance diagram for assErrorText:
+ Collaboration diagram for assErrorText:

Public Member Functions

 __construct (string $title='', string $comment='', string $author='', int $owner=-1, string $question='')
 
 isComplete ()
 
 saveToDb (?int $original_id=null)
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 saveAdditionalQuestionDataToDb ()
 Saves the data for the additional data table. More...
 
 loadFromDb ($question_id)
 Loads the object from the database. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 getQuestionType ()
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 setErrorsFromParsedErrorText ()
 
 setErrorData (array $errors)
 
 removeErrorDataWithoutPosition ()
 
 assembleErrorTextOutput (array $selections, bool $graphical_output=false, bool $show_correct_solution=false, bool $use_link_tags=true, array $correctness_icons=[])
 
 createErrorTextExport (array $selections)
 
 getBestSelection (bool $with_positive_points_only=true)
 
 flushErrorData ()
 
 getErrorData ()
 
 getErrorText ()
 
 setErrorText (?string $text)
 
 getParsedErrorText ()
 
 setParsedErrorText (array $parsed_errortext)
 
 getTextSize ()
 
 setTextSize ($a_value)
 
 getPointsWrong ()
 
 setPointsWrong ($a_value)
 
 toJSON ()
 
 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...
 
 parseErrorText ()
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 
 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...
 

Protected Member Functions

 getPointsForSelectedPositions (array $selected_word_positions)
 
 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)
 

Protected Attributes

const ERROR_TYPE_WORD = 1
 
const ERROR_TYPE_PASSAGE = 2
 
const DEFAULT_TEXT_SIZE = 100.0
 
const ERROR_MAX_LENGTH = 150
 
const PARAGRAPH_SPLIT_REGEXP = '/[\n\r]+/'
 
const WORD_SPLIT_REGEXP = '/\s+/'
 
const FIND_PUNCTUATION_REGEXP = '/\p{P}/'
 
const ERROR_WORD_MARKER = '#'
 
const ERROR_PARAGRAPH_DELIMITERS
 
const string $errortext = ''
 
array $parsed_errortext = []
 
array $errordata = []
 
float $textsize
 
float $points_wrong = null
 
- 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
 

Private Member Functions

 correctDataAfterParserUpdate ()
 
 getAnswersFromRequest ()
 
 addPositionToErrorAnswer (assAnswerErrorText $error)
 
 completeParsedErrorTextFromErrorData ()
 
 getAdditionalInformationFromExistingErrorDataByErrorText (array $current_error_data, string $text_wrong)
 
 generateOutputStringFromPosition (int $position, array $selections, array $paragraph, bool $graphical_output, bool $show_correct_solution, bool $use_link_tags, array $correctness_icons)
 
 getTextForPosition (int $position, array $paragraph, bool $show_correct_solution)
 
 getClassForPosition (int $position, bool $show_correct_solution, array $selections)
 
 getCorrectnessIconForPosition (int $position, bool $graphical_output, array $selections, array $correctness_icons)
 
 getErrorDataAsArrayForJS ()
 
 getParsedErrorTextForJS ()
 
 addErrorInformationToTextParagraphArray (array $paragraph, int $offset)
 
 parsePassageEndWord (string $word)
 
 generateArrayByPositionFromErrorData ()
 
 getErrorTokenHtml ($item, $class, $useLinkTags)
 

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

Detailed Description

Class for error text questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Grégory Saive gsaiv.nosp@m.e@da.nosp@m.tabay.nosp@m..de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 37 of file class.assErrorText.php.

Constructor & Destructor Documentation

◆ __construct()

assErrorText::__construct ( string  $title = '',
string  $comment = '',
string  $author = '',
int  $owner = -1,
string  $question = '' 
)

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

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

66  {
68  $this->textsize = self::DEFAULT_TEXT_SIZE;
69  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addErrorInformationToTextParagraphArray()

assErrorText::addErrorInformationToTextParagraphArray ( array  $paragraph,
int  $offset 
)
private
Parameters
list<string>$paragraph
Returns
array<string|array>

Definition at line 813 of file class.assErrorText.php.

References getPointsWrong(), null, and parsePassageEndWord().

Referenced by parseErrorText().

813  : array
814  {
815  $paragraph_with_error_info = [];
816  $passage_start = null;
817  foreach ($paragraph as $position => $word) {
818  $actual_position = $position + $offset;
819  if ($passage_start !== null
820  && (mb_strrpos($word, self::ERROR_PARAGRAPH_DELIMITERS['end']) === mb_strlen($word) - 2
821  || mb_strrpos($word, self::ERROR_PARAGRAPH_DELIMITERS['end']) === mb_strlen($word) - 3
822  && preg_match(self::FIND_PUNCTUATION_REGEXP, mb_substr($word, -1)) === 1)) {
823  $actual_word = $this->parsePassageEndWord($word);
824 
825  $paragraph_with_error_info[$passage_start]['text_wrong'] .=
826  ' ' . $actual_word;
827  $paragraph_with_error_info[$actual_position] = [
828  'text' => $actual_word,
829  'error_type' => 'passage_end'
830  ];
831  $passage_start = null;
832  continue;
833  }
834  if ($passage_start !== null) {
835  $paragraph_with_error_info[$passage_start]['text_wrong'] .= ' ' . $word;
836  $paragraph_with_error_info[$actual_position] = [
837  'text' => $word,
838  'error_type' => 'in_passage'
839  ];
840  continue;
841  }
842  if (mb_strpos($word, self::ERROR_PARAGRAPH_DELIMITERS['start']) === 0) {
843  $paragraph_with_error_info[$actual_position] = [
844  'text' => substr($word, 2),
845  'text_wrong' => substr($word, 2),
846  'error_type' => 'passage_start',
847  'error_position' => $actual_position,
848  ];
849  $passage_start = $actual_position;
850  continue;
851  }
852  if (mb_strpos($word, self::ERROR_WORD_MARKER) === 0) {
853  $paragraph_with_error_info[$actual_position] = [
854  'text' => substr($word, 1),
855  'text_wrong' => substr($word, 1),
856  'error_type' => 'word',
857  'error_position' => $actual_position,
858  ];
859  continue;
860  }
861 
862  $paragraph_with_error_info[$actual_position] = [
863  'text' => $word,
864  'error_type' => 'none',
865  'points' => $this->getPointsWrong()
866  ];
867  }
868 
869  return $paragraph_with_error_info;
870  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
parsePassageEndWord(string $word)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addPositionToErrorAnswer()

assErrorText::addPositionToErrorAnswer ( assAnswerErrorText  $error)
private

Definition at line 359 of file class.assErrorText.php.

References generateArrayByPositionFromErrorData(), getParsedErrorText(), assAnswerErrorText\getTextWrong(), and assAnswerErrorText\withPosition().

Referenced by correctDataAfterParserUpdate(), and setErrorData().

360  {
361  foreach ($this->getParsedErrorText() as $paragraph) {
362  foreach ($paragraph as $position => $word) {
363  if (isset($word['text_wrong'])
364  && ($word['text_wrong'] === $error->getTextWrong()
365  || mb_substr($word['text_wrong'], 0, -1) === $error->getTextWrong()
366  && preg_match(self::FIND_PUNCTUATION_REGEXP, mb_substr($word['text_wrong'], -1)) === 1)
367  && !array_key_exists($position, $this->generateArrayByPositionFromErrorData())
368  ) {
369  return $error->withPosition($position);
370  }
371  }
372  }
373 
374  return $error;
375  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
generateArrayByPositionFromErrorData()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assembleErrorTextOutput()

assErrorText::assembleErrorTextOutput ( array  $selections,
bool  $graphical_output = false,
bool  $show_correct_solution = false,
bool  $use_link_tags = true,
array  $correctness_icons = [] 
)

Definition at line 438 of file class.assErrorText.php.

References generateOutputStringFromPosition(), and getParsedErrorText().

444  : string {
445  $output_array = [];
446  foreach ($this->getParsedErrorText() as $paragraph) {
447  $array_reduce_function = fn(?string $carry, int $position)
448  => $carry . $this->generateOutputStringFromPosition(
449  $position,
450  $selections,
451  $paragraph,
452  $graphical_output,
453  $show_correct_solution,
454  $use_link_tags,
455  $correctness_icons
456  );
457  $output_array[] = '<p>' . trim(array_reduce(array_keys($paragraph), $array_reduce_function)) . '</p>';
458  }
459 
460  return implode("\n", $output_array);
461  }
generateOutputStringFromPosition(int $position, array $selections, array $paragraph, bool $graphical_output, bool $show_correct_solution, bool $use_link_tags, array $correctness_icons)
+ Here is the call graph for this function:

◆ calculateReachedPoints()

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

Definition at line 249 of file class.assErrorText.php.

References assQuestion\$points, assQuestion\getCurrentSolutionResultSet(), getPointsForSelectedPositions(), assQuestion\getSolutionMaxPass(), and null.

Referenced by getUserQuestionResult().

253  : float {
254  if ($pass === null) {
255  $pass = $this->getSolutionMaxPass($active_id);
256  }
257  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
258 
259  $positions = [];
260  while ($row = $this->db->fetchAssoc($result)) {
261  $positions[] = $row['value1'];
262  }
263  $points = $this->getPointsForSelectedPositions($positions);
264  return $points;
265  }
getPointsForSelectedPositions(array $selected_word_positions)
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:

◆ calculateReachedPointsFromPreviewSession()

assErrorText::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $preview_session)

Definition at line 267 of file class.assErrorText.php.

References assQuestion\deductHintPointsFromReachedPoints(), assQuestion\ensureNonNegativePoints(), ilAssQuestionPreviewSession\getParticipantsSolution(), and getPointsForSelectedPositions().

268  {
269  $reached_points = $this->getPointsForSelectedPositions($preview_session->getParticipantsSolution() ?? []);
270  $reached_points = $this->deductHintPointsFromReachedPoints($preview_session, $reached_points);
271  return $this->ensureNonNegativePoints($reached_points);
272  }
getPointsForSelectedPositions(array $selected_word_positions)
ensureNonNegativePoints(float $points)
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $preview_session, $reached_points)
+ Here is the call graph for this function:

◆ completeParsedErrorTextFromErrorData()

assErrorText::completeParsedErrorTextFromErrorData ( )
private

Definition at line 377 of file class.assErrorText.php.

References getParsedErrorText().

Referenced by correctDataAfterParserUpdate(), and setErrorData().

377  : void
378  {
379  foreach ($this->errordata as $error) {
380  $position = $error->getPosition();
381  foreach ($this->getParsedErrorText() as $key => $paragraph) {
382  if (array_key_exists($position, $paragraph)) {
383  $this->parsed_errortext[$key][$position]['text_correct'] =
384  $error->getTextCorrect();
385  $this->parsed_errortext[$key][$position]['points'] =
386  $error->getPoints();
387  break;
388  }
389  }
390  }
391  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ correctDataAfterParserUpdate()

assErrorText::correctDataAfterParserUpdate ( )
private

Definition at line 208 of file class.assErrorText.php.

References addPositionToErrorAnswer(), completeParsedErrorTextFromErrorData(), getErrorText(), getParsedErrorText(), null, parseErrorText(), saveAdditionalQuestionDataToDb(), and saveAnswerSpecificDataToDb().

Referenced by loadFromDb().

208  : void
209  {
210  if ($this->getErrorText() === '') {
211  return;
212  }
213  $needs_finalizing = false;
214  if ($this->getParsedErrorText() === []) {
215  $needs_finalizing = true;
216  $this->parseErrorText();
217  }
218 
219  if (isset($this->errordata[0])
220  && $this->errordata[0]->getPosition() === null) {
221  foreach ($this->errordata as $key => $error) {
222  $this->errordata[$key] = $this->addPositionToErrorAnswer($error);
223  }
225  }
226 
227  if ($needs_finalizing) {
230  }
231  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
addPositionToErrorAnswer(assAnswerErrorText $error)
saveAdditionalQuestionDataToDb()
Saves the data for the additional data table.
completeParsedErrorTextFromErrorData()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createErrorTextExport()

assErrorText::createErrorTextExport ( array  $selections)

Definition at line 545 of file class.assErrorText.php.

References getParsedErrorText().

Referenced by getCorrectSolutionForTextOutput(), solutionValuesToLog(), and solutionValuesToText().

545  : string
546  {
547  if (!is_array($selections)) {
548  $selections = [];
549  }
550 
551  foreach ($this->getParsedErrorText() as $paragraph) {
552  $array_reduce_function = function ($carry, $k) use ($paragraph, $selections) {
553  $text = $paragraph[$k]['text'];
554  if (in_array($k, $selections)) {
555  $text = self::ERROR_WORD_MARKER . $paragraph[$k]['text'] . self::ERROR_WORD_MARKER;
556  }
557  return $carry . ' ' . $text;
558  };
559  $output_array[] = trim(array_reduce(array_keys($paragraph), $array_reduce_function));
560  }
561  return implode("\n", $output_array);
562  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flushErrorData()

assErrorText::flushErrorData ( )

Definition at line 632 of file class.assErrorText.php.

632  : void
633  {
634  $this->errordata = [];
635  }

◆ generateArrayByPositionFromErrorData()

assErrorText::generateArrayByPositionFromErrorData ( )
private

Definition at line 905 of file class.assErrorText.php.

Referenced by addPositionToErrorAnswer(), getBestSelection(), and getPointsForSelectedPositions().

905  : array
906  {
907  $array_by_position = [];
908  foreach ($this->errordata as $error) {
909  $array_by_position[$error->getPosition()] = [
910  'length' => $error->getLength(),
911  'points' => $error->getPoints(),
912  'text' => $error->getTextWrong(),
913  'text_correct' => $error->getTextCorrect()
914  ];
915  }
916  ksort($array_by_position);
917  return $array_by_position;
918  }
+ Here is the caller graph for this function:

◆ generateOutputStringFromPosition()

assErrorText::generateOutputStringFromPosition ( int  $position,
array  $selections,
array  $paragraph,
bool  $graphical_output,
bool  $show_correct_solution,
bool  $use_link_tags,
array  $correctness_icons 
)
private

Definition at line 463 of file class.assErrorText.php.

References getClassForPosition(), getCorrectnessIconForPosition(), getErrorTokenHtml(), and getTextForPosition().

Referenced by assembleErrorTextOutput().

471  : string {
472  $text = $this->getTextForPosition($position, $paragraph, $show_correct_solution);
473  if ($text === '') {
474  return '';
475  }
476  $class = $this->getClassForPosition($position, $show_correct_solution, $selections);
477  $img = $this->getCorrectnessIconForPosition(
478  $position,
479  $graphical_output,
480  $selections,
481  $correctness_icons
482  );
483 
484  return ' ' . $this->getErrorTokenHtml($text, $class, $use_link_tags) . $img;
485  }
getClassForPosition(int $position, bool $show_correct_solution, array $selections)
getTextForPosition(int $position, array $paragraph, bool $show_correct_solution)
getCorrectnessIconForPosition(int $position, bool $graphical_output, array $selections, array $correctness_icons)
getErrorTokenHtml($item, $class, $useLinkTags)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdditionalInformationFromExistingErrorDataByErrorText()

assErrorText::getAdditionalInformationFromExistingErrorDataByErrorText ( array  $current_error_data,
string  $text_wrong 
)
private
Parameters
array<assAnswerErrorText>$current_error_data
Returns
array<mixed>

Definition at line 423 of file class.assErrorText.php.

Referenced by setErrorsFromParsedErrorText().

426  : array {
427  foreach ($current_error_data as $answer_object) {
428  if (strcmp($answer_object->getTextWrong(), $text_wrong) === 0) {
429  return[
430  $answer_object->getTextCorrect(),
431  $answer_object->getPoints()
432  ];
433  }
434  }
435  return ['', 0.0];
436  }
+ Here is the caller graph for this function:

◆ getAdditionalTableName()

assErrorText::getAdditionalTableName ( )

Definition at line 315 of file class.assErrorText.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

315  : string
316  {
317  return 'qpl_qst_errortext';
318  }
+ Here is the caller graph for this function:

◆ getAnswersFromRequest()

assErrorText::getAnswersFromRequest ( )
private

Definition at line 302 of file class.assErrorText.php.

Referenced by savePreviewData(), and saveWorkingData().

302  : array
303  {
304  return explode(
305  ',',
306  $this->questionpool_request->string('qst_' . $this->getId())
307  );
308  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assErrorText::getAnswerTableName ( )

Definition at line 320 of file class.assErrorText.php.

320  : string
321  {
322  return 'qpl_a_errortext';
323  }

◆ getAvailableAnswerOptions()

assErrorText::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 887 of file class.assErrorText.php.

References $c, and null.

887  : ?int
888  {
889  $error_text_array = array_reduce(
890  $this->parsed_errortext,
891  fn($c, $v) => $c + $v
892  );
893 
894  if ($index === null) {
895  return $error_text_array;
896  }
897 
898  if (array_key_exists($index, $error_text_array)) {
899  return $error_text_array[$index];
900  }
901 
902  return null;
903  }
$c
Definition: deliver.php:25
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getBestSelection()

assErrorText::getBestSelection ( bool  $with_positive_points_only = true)

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

References generateArrayByPositionFromErrorData().

Referenced by getCorrectSolutionForTextOutput().

564  : array
565  {
566  $positions_array = $this->generateArrayByPositionFromErrorData();
567  $selections = [];
568  foreach ($positions_array as $position => $position_data) {
569  if ($position === ''
570  || $with_positive_points_only && $position_data['points'] <= 0) {
571  continue;
572  }
573 
574  $selections[] = $position;
575  if ($position_data['length'] > 1) {
576  for ($i = 1;$i < $position_data['length'];$i++) {
577  $selections[] = $position + $i;
578  }
579  }
580  }
581 
582  return $selections;
583  }
generateArrayByPositionFromErrorData()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClassForPosition()

assErrorText::getClassForPosition ( int  $position,
bool  $show_correct_solution,
array  $selections 
)
private

Definition at line 507 of file class.assErrorText.php.

Referenced by generateOutputStringFromPosition().

511  : string {
512  if ($show_correct_solution !== true
513  && in_array($position, $selections['user'])) {
514  return 'ilc_qetitem_ErrorTextSelected';
515  }
516 
517  if ($show_correct_solution === true
518  && in_array($position, $selections['best'])) {
519  return 'ilc_qetitem_ErrorTextSelected';
520  }
521 
522  return 'ilc_qetitem_ErrorTextItem';
523  }
+ Here is the caller graph for this function:

◆ getCorrectnessIconForPosition()

assErrorText::getCorrectnessIconForPosition ( int  $position,
bool  $graphical_output,
array  $selections,
array  $correctness_icons 
)
private

Definition at line 525 of file class.assErrorText.php.

Referenced by generateOutputStringFromPosition().

530  : string {
531  if ($graphical_output === true
532  && (in_array($position, $selections['user']) && !in_array($position, $selections['best'])
533  || !in_array($position, $selections['user']) && in_array($position, $selections['best']))) {
534  return $correctness_icons['not_correct'];
535  }
536 
537  if ($graphical_output === true
538  && in_array($position, $selections['user']) && in_array($position, $selections['best'])) {
539  return $correctness_icons['correct'];
540  }
541 
542  return '';
543  }
+ Here is the caller graph for this function:

◆ getCorrectSolutionForTextOutput()

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

Definition at line 992 of file class.assErrorText.php.

References createErrorTextExport(), and getBestSelection().

992  : string
993  {
994  return $this->createErrorTextExport($this->getBestSelection());
995  }
createErrorTextExport(array $selections)
getBestSelection(bool $with_positive_points_only=true)
+ Here is the call graph for this function:

◆ getErrorData()

assErrorText::getErrorData ( )
Returns
array<assAnswerErrorText>

Definition at line 641 of file class.assErrorText.php.

References $errordata.

Referenced by getErrorDataAsArrayForJS(), removeErrorDataWithoutPosition(), setErrorsFromParsedErrorText(), and toLog().

641  : array
642  {
643  return $this->errordata;
644  }
+ Here is the caller graph for this function:

◆ getErrorDataAsArrayForJS()

assErrorText::getErrorDataAsArrayForJS ( )
private
Returns
array<mixed>

Definition at line 650 of file class.assErrorText.php.

References getErrorData(), and assQuestion\getId().

Referenced by toJSON().

650  : array
651  {
652  $correct_answers = [];
653  foreach ($this->getErrorData() as $index => $answer_obj) {
654  $correct_answers[] = [
655  'answertext_wrong' => $answer_obj->getTextWrong(),
656  'answertext_correct' => $answer_obj->getTextCorrect(),
657  'points' => $answer_obj->getPoints(),
658  'length' => $answer_obj->getLength(),
659  'pos' => $this->getId() . '_' . $answer_obj->getPosition()
660  ];
661  }
662  return $correct_answers;
663  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrorText()

assErrorText::getErrorText ( )

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

Referenced by correctDataAfterParserUpdate(), parseErrorText(), saveAdditionalQuestionDataToDb(), toJSON(), and toLog().

665  : string
666  {
667  return $this->errortext ?? '';
668  }
+ Here is the caller graph for this function:

◆ getErrorTokenHtml()

assErrorText::getErrorTokenHtml (   $item,
  $class,
  $useLinkTags 
)
private
Parameters
$item
$class
Returns
string

Definition at line 925 of file class.assErrorText.php.

References ilLegacyFormElementsUtil\prepareFormOutput().

Referenced by generateOutputStringFromPosition().

925  : string
926  {
927  if ($useLinkTags) {
928  return '<a class="' . $class . '" href="#">' . ($item == '&nbsp;' ? $item : ilLegacyFormElementsUtil::prepareFormOutput(
929  $item
930  )) . '</a>';
931  }
932 
933  return '<span class="' . $class . '">' . ($item == '&nbsp;' ? $item : ilLegacyFormElementsUtil::prepareFormOutput(
934  $item
935  )) . '</span>';
936  }
static prepareFormOutput($a_str, bool $a_strip=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExpressionTypes()

◆ getMaximumPoints()

assErrorText::getMaximumPoints ( )

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

See also
$points

Definition at line 238 of file class.assErrorText.php.

Referenced by getUserQuestionResult(), and isComplete().

238  : float
239  {
240  $maxpoints = 0.0;
241  foreach ($this->errordata as $error) {
242  if ($error->getPoints() > 0) {
243  $maxpoints += $error->getPoints();
244  }
245  }
246  return $maxpoints;
247  }
+ Here is the caller graph for this function:

◆ getOperators()

assErrorText::getOperators ( string  $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

Definition at line 752 of file class.assErrorText.php.

752  : array
753  {
754  return ilOperatorsExpressionMapping::getOperatorsByExpression($expression);
755  }

◆ getParsedErrorText()

assErrorText::getParsedErrorText ( )

◆ getParsedErrorTextForJS()

assErrorText::getParsedErrorTextForJS ( )
private

Definition at line 680 of file class.assErrorText.php.

References assQuestion\getId().

Referenced by toJSON().

680  : array
681  {
682  $answers = [];
683  foreach ($this->parsed_errortext as $paragraph) {
684  foreach ($paragraph as $position => $word) {
685  $answers[] = [
686  'answertext' => $word['text'],
687  'order' => $this->getId() . '_' . $position
688  ];
689  }
690  $answers[] = [
691  'answertext' => '###'
692  ];
693  }
694  array_pop($answers);
695 
696  return $answers;
697  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPointsForSelectedPositions()

assErrorText::getPointsForSelectedPositions ( array  $selected_word_positions)
protected
Parameters
list<string>|null$selected_words Positions of Selected Words Counting from 0

Definition at line 589 of file class.assErrorText.php.

References assQuestion\$points, generateArrayByPositionFromErrorData(), and getPointsWrong().

Referenced by calculateReachedPoints(), and calculateReachedPointsFromPreviewSession().

589  : float
590  {
591  $points = 0;
592  $correct_positions = $this->generateArrayByPositionFromErrorData();
593 
594  foreach ($correct_positions as $correct_position => $correct_position_data) {
595  $selected_word_key = array_search($correct_position, $selected_word_positions);
596  if ($selected_word_key === false) {
597  continue;
598  }
599 
600  if ($correct_position_data['length'] === 1) {
601  $points += $correct_position_data['points'];
602  unset($selected_word_positions[$selected_word_key]);
603  continue;
604  }
605 
606  $passage_complete = true;
607  for ($i = 1;$i < $correct_position_data['length'];$i++) {
608  $selected_passage_element_key = array_search($correct_position + $i, $selected_word_positions);
609  if ($selected_passage_element_key === false) {
610  $passage_complete = false;
611  continue;
612  }
613  unset($selected_word_positions[$selected_passage_element_key]);
614  }
615 
616  if ($passage_complete) {
617  $points += $correct_position_data['points'];
618  unset($selected_word_positions[$selected_word_key]);
619  }
620  }
621 
622  foreach ($selected_word_positions as $word_position) {
623  if (!array_key_exists($word_position, $correct_positions)) {
624  $points += $this->getPointsWrong();
625  continue;
626  }
627  }
628 
629  return $points;
630  }
generateArrayByPositionFromErrorData()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPointsWrong()

assErrorText::getPointsWrong ( )

Definition at line 718 of file class.assErrorText.php.

References $points_wrong.

Referenced by addErrorInformationToTextParagraphArray(), getPointsForSelectedPositions(), and saveAdditionalQuestionDataToDb().

718  : ?float
719  {
720  return $this->points_wrong;
721  }
+ Here is the caller graph for this function:

◆ getQuestionType()

assErrorText::getQuestionType ( )

Definition at line 310 of file class.assErrorText.php.

Referenced by toJSON(), and toLog().

310  : string
311  {
312  return 'assErrorText';
313  }
+ Here is the caller graph for this function:

◆ getTextForPosition()

assErrorText::getTextForPosition ( int  $position,
array  $paragraph,
bool  $show_correct_solution 
)
private

Definition at line 487 of file class.assErrorText.php.

Referenced by generateOutputStringFromPosition().

491  : string {
492  $v = $paragraph[$position];
493  if ($show_correct_solution === true
494  && ($v['error_type'] === 'in_passage'
495  || $v['error_type'] === 'passage_end')) {
496  return '';
497  }
498  if ($show_correct_solution
499  && ($v['error_type'] === 'passage_start'
500  || $v['error_type'] === 'word')) {
501  return $v['text_correct'] ?? '';
502  }
503 
504  return $v['text'];
505  }
+ Here is the caller graph for this function:

◆ getTextSize()

assErrorText::getTextSize ( )

Definition at line 704 of file class.assErrorText.php.

References $textsize.

Referenced by saveAdditionalQuestionDataToDb().

704  : float
705  {
706  return $this->textsize;
707  }
+ Here is the caller graph for this function:

◆ getUserQuestionResult()

assErrorText::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 767 of file class.assErrorText.php.

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

771  $result = new ilUserQuestionResult($this, $active_id, $pass);
772 
773  $data = $this->db->queryF(
774  "SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = (
775  SELECT MAX(step) FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s
776  )",
777  ["integer", "integer", "integer","integer", "integer", "integer"],
778  [$active_id, $pass, $this->getId(), $active_id, $pass, $this->getId()]
779  );
780 
781  while ($row = $this->db->fetchAssoc($data)) {
782  $result->addKeyValue($row["value1"], $row["value1"]);
783  }
784 
785  $points = $this->calculateReachedPoints($active_id, $pass);
786  $max_points = $this->getMaximumPoints();
787 
788  $result->setReachedPercentage(($points / $max_points) * 100);
789 
790  return $result;
791  }
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...
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ isComplete()

assErrorText::isComplete ( )

Definition at line 71 of file class.assErrorText.php.

References getMaximumPoints().

71  : bool
72  {
73  if (mb_strlen($this->title)
74  && ($this->author)
75  && ($this->question)
76  && ($this->getMaximumPoints() > 0)) {
77  return true;
78  } else {
79  return false;
80  }
81  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ loadFromDb()

assErrorText::loadFromDb (   $question_id)

Loads the object from the database.

Parameters
object$dbA pear DB object
integer$question_idA unique key which defines the multiple choice test in the database

Definition at line 150 of file class.assErrorText.php.

References $data, Vendor\Package\$e, ilRTE\_replaceMediaObjectImageSrc(), correctDataAfterParserUpdate(), getAdditionalTableName(), ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), setErrorText(), assQuestion\setId(), assQuestion\setLifecycle(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), setParsedErrorText(), assQuestion\setPoints(), setPointsWrong(), assQuestion\setQuestion(), setTextSize(), and assQuestion\setTitle().

150  : void
151  {
152  $db_question = $this->db->queryF(
153  "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",
154  ["integer"],
155  [$question_id]
156  );
157  if ($db_question->numRows() === 1) {
158  $data = $this->db->fetchAssoc($db_question);
159  $this->setId($question_id);
160  $this->setObjId($data["obj_fi"]);
161  $this->setTitle((string) $data["title"]);
162  $this->setComment((string) $data["description"]);
163  $this->setOriginalId($data["original_id"]);
164  $this->setNrOfTries($data['nr_of_tries']);
165  $this->setAuthor($data["author"]);
166  $this->setPoints($data["points"]);
167  $this->setOwner($data["owner"]);
168  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
169  $this->setErrorText((string) $data["errortext"]);
170  $this->setParsedErrorText(json_decode($data['parsed_errortext'] ?? json_encode([]), true));
171  $this->setTextSize($data["textsize"]);
172  $this->setPointsWrong($data["points_wrong"]);
173 
174  try {
178  }
179 
180  try {
181  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
182  } catch (ilTestQuestionPoolException $e) {
183  }
184  }
185 
186  $db_error_text = $this->db->queryF(
187  "SELECT * FROM qpl_a_errortext WHERE question_fi = %s ORDER BY sequence ASC",
188  ['integer'],
189  [$question_id]
190  );
191 
192  if ($db_error_text->numRows() > 0) {
193  while ($data = $this->db->fetchAssoc($db_error_text)) {
194  $this->errordata[] = new assAnswerErrorText(
195  (string) $data['text_wrong'],
196  (string) $data['text_correct'],
197  (float) $data['points'],
198  $data['position']
199  );
200  }
201  }
202 
204 
205  parent::loadFromDb($question_id);
206  }
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)
setOwner(int $owner=-1)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setComment(string $comment="")
setPointsWrong($a_value)
setErrorText(?string $text)
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="")
setParsedErrorText(array $parsed_errortext)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
+ Here is the call graph for this function:

◆ parseErrorText()

assErrorText::parseErrorText ( )

Definition at line 793 of file class.assErrorText.php.

References addErrorInformationToTextParagraphArray(), getErrorText(), and setParsedErrorText().

Referenced by correctDataAfterParserUpdate().

793  : void
794  {
795  $text_by_paragraphs = preg_split(self::PARAGRAPH_SPLIT_REGEXP, $this->getErrorText());
796  $text_array = [];
797  $offset = 0;
798  foreach ($text_by_paragraphs as $paragraph) {
799  $text_array[] = $this->addErrorInformationToTextParagraphArray(
800  preg_split(self::WORD_SPLIT_REGEXP, trim($paragraph)),
801  $offset
802  );
803  $offset += count(end($text_array));
804  }
805  $this->setParsedErrorText($text_array);
806  }
addErrorInformationToTextParagraphArray(array $paragraph, int $offset)
setParsedErrorText(array $parsed_errortext)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parsePassageEndWord()

assErrorText::parsePassageEndWord ( string  $word)
private

Definition at line 872 of file class.assErrorText.php.

Referenced by addErrorInformationToTextParagraphArray().

872  : string
873  {
874  if (mb_substr($word, -2) === self::ERROR_PARAGRAPH_DELIMITERS['end']) {
875  return mb_substr($word, 0, -2);
876  }
877  return mb_substr($word, 0, -3) . mb_substr($word, -1);
878  }
+ Here is the caller graph for this function:

◆ removeErrorDataWithoutPosition()

assErrorText::removeErrorDataWithoutPosition ( )

Definition at line 408 of file class.assErrorText.php.

References getErrorData(), and null.

408  : void
409  {
410  foreach ($this->getErrorData() as $index => $error) {
411  if ($error->getPosition() === null) {
412  unset($this->errordata[$index]);
413  }
414  }
415  $this->errordata = array_values($this->errordata);
416  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assErrorText::saveAdditionalQuestionDataToDb ( )

Saves the data for the additional data table.

This method uses the ugly DELETE-INSERT. Here, this does no harm.

Implements ilObjQuestionScoringAdjustable.

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

References getAdditionalTableName(), getErrorText(), assQuestion\getId(), getParsedErrorText(), getPointsWrong(), and getTextSize().

Referenced by correctDataAfterParserUpdate(), and saveToDb().

124  {
125  $this->db->manipulateF(
126  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
127  ["integer"],
128  [$this->getId()]
129  );
130 
131  $this->db->manipulateF(
132  "INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, errortext, parsed_errortext, textsize, points_wrong) VALUES (%s, %s, %s, %s, %s)",
133  ["integer", "text", "text", "float", "float"],
134  [
135  $this->getId(),
136  $this->getErrorText(),
137  json_encode($this->getParsedErrorText()),
138  $this->getTextSize(),
139  $this->getPointsWrong()
140  ]
141  );
142  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAnswerSpecificDataToDb()

assErrorText::saveAnswerSpecificDataToDb ( )

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

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

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

References assQuestion\getId().

Referenced by correctDataAfterParserUpdate(), and saveToDb().

92  {
93  $this->db->manipulateF(
94  "DELETE FROM qpl_a_errortext WHERE question_fi = %s",
95  ['integer'],
96  [$this->getId()]
97  );
98 
99  $sequence = 0;
100  foreach ($this->errordata as $error) {
101  $next_id = $this->db->nextId('qpl_a_errortext');
102  $this->db->manipulateF(
103  "INSERT INTO qpl_a_errortext (answer_id, question_fi, text_wrong, text_correct, points, sequence, position) VALUES (%s, %s, %s, %s, %s, %s, %s)",
104  ['integer', 'integer', 'text', 'text', 'float', 'integer', 'integer'],
105  [
106  $next_id,
107  $this->getId(),
108  $error->getTextWrong(),
109  $error->getTextCorrect(),
110  $error->getPoints(),
111  $sequence++,
112  $error->getPosition()
113  ]
114  );
115  }
116  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePreviewData()

assErrorText::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)

Definition at line 296 of file class.assErrorText.php.

References getAnswersFromRequest(), and ilAssQuestionPreviewSession\setParticipantsSolution().

296  : void
297  {
298  $selection = $this->getAnswersFromRequest();
299  $previewSession->setParticipantsSolution($selection);
300  }
+ Here is the call graph for this function:

◆ saveToDb()

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

Definition at line 83 of file class.assErrorText.php.

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

83  : void
84  {
88  parent::saveToDb();
89  }
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb(?int $original_id=null)
saveAdditionalQuestionDataToDb()
Saves the data for the additional data table.
+ Here is the call graph for this function:

◆ saveWorkingData()

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

Definition at line 274 of file class.assErrorText.php.

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

278  : bool {
279  if (is_null($pass)) {
280  $pass = ilObjTest::_getPass($active_id);
281  }
282 
283  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
284  function () use ($active_id, $pass, $authorized) {
285  $selected = $this->getAnswersFromRequest();
286  $this->removeCurrentSolution($active_id, $pass, $authorized);
287  foreach ($selected as $position) {
288  $this->saveCurrentSolution($active_id, $pass, $position, null, $authorized);
289  }
290  }
291  );
292 
293  return true;
294  }
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:

◆ setErrorData()

assErrorText::setErrorData ( array  $errors)
Parameters
array<assAnswerErrorText>$errors

Definition at line 397 of file class.assErrorText.php.

References addPositionToErrorAnswer(), and completeParsedErrorTextFromErrorData().

397  : void
398  {
399  $this->errordata = [];
400 
401  foreach ($errors as $error) {
402  $answer = $this->addPositionToErrorAnswer($error);
403  $this->errordata[] = $answer;
404  }
406  }
addPositionToErrorAnswer(assAnswerErrorText $error)
completeParsedErrorTextFromErrorData()
+ Here is the call graph for this function:

◆ setErrorsFromParsedErrorText()

assErrorText::setErrorsFromParsedErrorText ( )

Definition at line 325 of file class.assErrorText.php.

References assQuestion\$points, getAdditionalInformationFromExistingErrorDataByErrorText(), getErrorData(), getParsedErrorText(), and ILIAS\Repository\lng().

325  : void
326  {
327  $current_error_data = $this->getErrorData();
328  $this->errordata = [];
329 
330  $has_too_long_errors = false;
331  foreach ($this->getParsedErrorText() as $paragraph) {
332  foreach ($paragraph as $position => $word) {
333  if ($word['error_type'] === 'in_passage'
334  || $word['error_type'] === 'passage_end'
335  || $word['error_type'] === 'none') {
336  continue;
337  }
338 
339  $text_wrong = $word['text_wrong'];
340  if (mb_strlen($text_wrong) > self::ERROR_MAX_LENGTH) {
341  $has_too_long_errors = true;
342  continue;
343  }
344 
345  list($text_correct, $points) =
346  $this->getAdditionalInformationFromExistingErrorDataByErrorText($current_error_data, $text_wrong);
347  $this->errordata[] = new assAnswerErrorText($text_wrong, $text_correct, $points, $position);
348  }
349  }
350 
351  if ($has_too_long_errors) {
352  $this->tpl->setOnScreenMessage(
353  'failure',
354  $this->lng->txt('qst_error_text_too_long')
355  );
356  }
357  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAdditionalInformationFromExistingErrorDataByErrorText(array $current_error_data, string $text_wrong)
+ Here is the call graph for this function:

◆ setErrorText()

assErrorText::setErrorText ( ?string  $text)

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

Referenced by loadFromDb().

670  : void
671  {
672  $this->errortext = $text ?? '';
673  }
+ Here is the caller graph for this function:

◆ setParsedErrorText()

assErrorText::setParsedErrorText ( array  $parsed_errortext)

Definition at line 699 of file class.assErrorText.php.

References $parsed_errortext.

Referenced by loadFromDb(), and parseErrorText().

699  : void
700  {
701  $this->parsed_errortext = $parsed_errortext;
702  }
+ Here is the caller graph for this function:

◆ setPointsWrong()

assErrorText::setPointsWrong (   $a_value)

Definition at line 723 of file class.assErrorText.php.

Referenced by loadFromDb().

723  : void
724  {
725  $this->points_wrong = $a_value;
726  }
+ Here is the caller graph for this function:

◆ setTextSize()

assErrorText::setTextSize (   $a_value)

Definition at line 709 of file class.assErrorText.php.

References null.

Referenced by loadFromDb().

709  : void
710  {
711  // in self-assesment-mode value should always be set (and must not be null)
712  if ($a_value === null) {
713  $a_value = 100;
714  }
715  $this->textsize = $a_value;
716  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ solutionValuesToLog()

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

Definition at line 970 of file class.assErrorText.php.

References createErrorTextExport().

973  : string {
974  return $this->createErrorTextExport(
975  array_map(
976  static fn(array $v): string => $v['value1'],
977  $solution_values
978  )
979  );
980  }
createErrorTextExport(array $selections)
+ Here is the call graph for this function:

◆ solutionValuesToText()

assErrorText::solutionValuesToText ( array  $solution_values)

Definition at line 982 of file class.assErrorText.php.

References createErrorTextExport().

982  : string
983  {
984  return $this->createErrorTextExport(
985  array_map(
986  static fn(array $v): string => $v['value1'],
987  $solution_values
988  )
989  );
990  }
createErrorTextExport(array $selections)
+ Here is the call graph for this function:

◆ toJSON()

assErrorText::toJSON ( )

Implements ILIAS\TestQuestionPool\Questions\QuestionLMExportable.

Definition at line 728 of file class.assErrorText.php.

References ilObjMediaObject\_getMobsOfObject(), ilRTE\_replaceMediaObjectImageSrc(), assQuestion\formatSAQuestion(), getErrorDataAsArrayForJS(), getErrorText(), assQuestion\getId(), assQuestion\getNrOfTries(), getParsedErrorTextForJS(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), and assQuestion\getTitleForHTMLOutput().

728  : string
729  {
730  $result = [];
731  $result['id'] = $this->getId();
732  $result['type'] = (string) $this->getQuestionType();
733  $result['title'] = $this->getTitleForHTMLOutput();
734  $result['question'] = $this->formatSAQuestion($this->getQuestion());
735  $result['text'] = ilRTE::_replaceMediaObjectImageSrc($this->getErrorText(), 0);
736  $result['nr_of_tries'] = $this->getNrOfTries();
737  $result['shuffle'] = $this->getShuffle();
738  $result['feedback'] = [
739  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
740  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
741  ];
742 
743  $result['correct_answers'] = $this->getErrorDataAsArrayForJS();
744  $result['answers'] = $this->getParsedErrorTextForJS();
745 
746  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
747  $result['mobs'] = $mobs;
748 
749  return json_encode($result);
750  }
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...
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()

assErrorText::toLog ( AdditionalInformationGenerator  $additional_info)

Implements ILIAS\TestQuestionPool\Questions\Question.

Definition at line 938 of file class.assErrorText.php.

References $c, ilRTE\_replaceMediaObjectImageSrc(), assQuestion\formatSAQuestion(), getErrorData(), getErrorText(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), assQuestion\getTitleForHTMLOutput(), and ILIAS\Test\Logging\AdditionalInformationGenerator\getTrueFalseTagForBool().

938  : array
939  {
940  $result = [
941  AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
942  AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
943  AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
944  AdditionalInformationGenerator::KEY_QUESTION_ERRORTEXT_ERRORTEXT => ilRTE::_replaceMediaObjectImageSrc($this->getErrorText(), 0),
945  AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS => $additional_info
947  AdditionalInformationGenerator::KEY_FEEDBACK => [
948  AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
949  AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
950  ]
951  ];
952 
953  $error_data = $this->getErrorData();
954  $result[AdditionalInformationGenerator::KEY_QUESTION_CORRECT_ANSWER_OPTIONS] = array_reduce(
955  array_keys($error_data),
956  static function (array $c, int $k) use ($error_data): array {
957  $c[$k + 1] = [
958  'text_wrong' => $error_data[$k]->getTextWrong(),
959  'text_correct' => $error_data[$k]->getTextCorrect(),
960  'points' => $error_data[$k]->getPoints()
961  ];
962  return $c;
963  },
964  []
965  );
966 
967  return $result;
968  }
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...
$c
Definition: deliver.php:25
+ Here is the call graph for this function:

Field Documentation

◆ $errordata

array assErrorText::$errordata = []
protected

Definition at line 56 of file class.assErrorText.php.

Referenced by getErrorData().

◆ $errortext

const string assErrorText::$errortext = ''
protected

Definition at line 53 of file class.assErrorText.php.

◆ $parsed_errortext

array assErrorText::$parsed_errortext = []
protected

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

Referenced by getParsedErrorText(), and setParsedErrorText().

◆ $points_wrong

float assErrorText::$points_wrong = null
protected

Definition at line 58 of file class.assErrorText.php.

Referenced by getPointsWrong().

◆ $textsize

float assErrorText::$textsize
protected

Definition at line 57 of file class.assErrorText.php.

Referenced by getTextSize().

◆ DEFAULT_TEXT_SIZE

const assErrorText::DEFAULT_TEXT_SIZE = 100.0
protected

Definition at line 41 of file class.assErrorText.php.

◆ ERROR_MAX_LENGTH

const assErrorText::ERROR_MAX_LENGTH = 150
protected

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

◆ ERROR_PARAGRAPH_DELIMITERS

const assErrorText::ERROR_PARAGRAPH_DELIMITERS
protected
Initial value:
= [
'start' => '(('

Definition at line 48 of file class.assErrorText.php.

◆ ERROR_TYPE_PASSAGE

const assErrorText::ERROR_TYPE_PASSAGE = 2
protected

Definition at line 40 of file class.assErrorText.php.

◆ ERROR_TYPE_WORD

const assErrorText::ERROR_TYPE_WORD = 1
protected

Definition at line 39 of file class.assErrorText.php.

◆ ERROR_WORD_MARKER

const assErrorText::ERROR_WORD_MARKER = '#'
protected

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

◆ FIND_PUNCTUATION_REGEXP

const assErrorText::FIND_PUNCTUATION_REGEXP = '/\p{P}/'
protected

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

◆ PARAGRAPH_SPLIT_REGEXP

const assErrorText::PARAGRAPH_SPLIT_REGEXP = '/[\n\r]+/'
protected

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

◆ WORD_SPLIT_REGEXP

const assErrorText::WORD_SPLIT_REGEXP = '/\s+/'
protected

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


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