ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
assClozeTest Class Reference

Class for cloze tests. More...

+ Inheritance diagram for assClozeTest:
+ Collaboration diagram for assClozeTest:

Public Member Functions

 __construct (string $title="", string $comment="", string $author="", int $owner=-1, string $question="")
 
 isComplete ()
 Returns TRUE, if a cloze test is complete for use. More...
 
 cleanQuestiontext ($text)
 Cleans cloze question text to remove attributes or tags from older ILIAS versions. More...
 
 replaceFirstGap (string $gaptext, string $content)
 
 loadFromDb (int $question_id)
 
 saveToDb (?int $original_id=null)
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 getGaps ()
 
 flushGaps ()
 
 setClozeText (string $cloze_text='')
 
 setClozeTextValue ($cloze_text="")
 
 getClozeText ()
 Returns the cloze text. More...
 
 getClozeTextForHTMLOutput ()
 Returns the cloze text as HTML (with optional nl2br) Fix for Mantis 29987: We assume Tiny embeds any text in tags, so if no tags are present, we derive it's non-HTML content and apply nl2br. More...
 
 getStartTag ()
 Returns the start tag of a cloze gap. More...
 
 setStartTag ($start_tag="[gap]")
 Sets the start tag of a cloze gap. More...
 
 getEndTag ()
 Returns the end tag of a cloze gap. More...
 
 setEndTag ($end_tag="[/gap]")
 Sets the end tag of a cloze gap. More...
 
 getFeedbackMode ()
 
 setFeedbackMode ($feedbackMode)
 
 createGapsFromQuestiontext ()
 Create gap entries by parsing the question text. More...
 
 setGapType ($gap_index, $gap_type)
 Set the type of a gap with a given index. More...
 
 setGapShuffle ($gap_index=0, $shuffle=1)
 Sets the shuffle state of a gap with a given index. More...
 
 clearGapAnswers ()
 Removes all answers from the gaps. More...
 
 getGapCount ()
 Returns the number of gaps. More...
 
 addGapAnswer ($gap_index, $order, $answer)
 Sets the answer text of a gap with a given index. More...
 
 getGap (int $gap_index=0)
 
 setGapSize ($gap_index, $size)
 
 setGapAnswerPoints ($gap_index, $order, $points)
 Sets the points of a gap with a given index and an answer with a given order. More...
 
 addGapText ($gap_index)
 Adds a new answer text value to a text gap with a given index. More...
 
 addGapAtIndex ($gap, $index)
 Adds a ClozeGap object at a given index. More...
 
 setGapAnswerLowerBound ($gap_index, $order, $bound)
 Sets the lower bound of a gap with a given index and an answer with a given order. More...
 
 setGapAnswerUpperBound ($gap_index, $order, $bound)
 Sets the upper bound of a gap with a given index and an answer with a given order. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 cloneQuestionTypeSpecificProperties (\assQuestion $target)
 
 updateClozeTextFromGaps ()
 Updates the gap parameters in the cloze text from the form input. More...
 
 deleteAnswerText ($gap_index, $answer_index)
 Deletes the answer text of a gap with a given index and an answer with a given order. More...
 
 deleteGap ($gap_index)
 Deletes a gap with a given index. More...
 
 getTextgapPoints ($a_original, $a_entered, $max_points)
 Returns the points for a text gap and compares the given solution with the entered solution using the text gap rating options. More...
 
 getNumericgapPoints ($a_original, $a_entered, $max_points, $lowerBound, $upperBound)
 Returns the points for a text gap and compares the given solution with the entered solution using the text gap rating options. More...
 
 checkForValidFormula (string $value)
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 getUserResultDetails (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 fetchSolutionSubmit ()
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getTextgapRating ()
 Returns the rating option for text gaps. More...
 
 setTextgapRating ($a_textgap_rating)
 Sets the rating option for text gaps. More...
 
 getIdenticalScoring ()
 Returns the identical scoring status of the question. More...
 
 setIdenticalScoring (bool $identical_scoring)
 Sets the identical scoring option for cloze questions. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 
 setFixedTextLength (?int $fixed_text_length)
 Sets a fixed text length for all text fields in the cloze question. More...
 
 getFixedTextLength ()
 Gets the fixed text length for all text fields in the cloze question. More...
 
 getMaximumGapPoints ($gap_index)
 Returns the maximum points for a gap. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 getGapCombinationsExists ()
 
 getGapCombinations ()
 
 setGapCombinationsExists ($value)
 
 setGapCombinations ($value)
 
 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...
 
 calculateCombinationResult ($user_result)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 fetchAnswerValueForGap ($userSolution, $gapIndex)
 
 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 $gaps = []
 
string $textgap_rating = assClozeGap::TEXTGAP_RATING_CASEINSENSITIVE
 The rating option for text gaps. More...
 
ilAssQuestionFeedback $feedbackOBJ
 
- 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

 saveClozeGapItemsToDb (assClozeGap $gap, int $key)
 
 saveClozeTextGapRecordToDb (int $next_id, int $key, assAnswerCloze $item, assClozeGap $gap)
 
 saveClozeSelectGapRecordToDb (int $next_id, int $key, assAnswerCloze $item, assClozeGap $gap)
 
 saveClozeNumericGapRecordToDb (int $next_id, int $key, assAnswerCloze $item, assClozeGap $gap)
 
 isValidNumericSubmitValue ($submittedValue)
 
 getSolutionSubmit ()
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 calculateReachedPointsForSolution (?array $user_result, array &$detailed=[])
 
 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

 $gap_combinations = []
 
bool $gap_combinations_exist = false
 
bool $identical_scoring = true
 Defines the scoring for "identical solutions". More...
 
int $fixed_text_length = null
 
string $cloze_text = ''
 
 $feedbackMode = ilAssClozeTestFeedback::FB_MODE_GAP_QUESTION
 
- 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

 fetchUserResult (int $active_id, ?int $pass)
 

Private Attributes

string $start_tag = '[gap]'
 
string $end_tag = '[/gap]'
 
RandomGroup $randomGroup
 

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)
 
- Static Protected Attributes inherited from assQuestion
static $force_pass_results_update_enabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

Class for cloze tests.

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

Definition at line 38 of file class.assClozeTest.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 82 of file class.assClozeTest.php.

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

88  {
89  global $DIC;
91  $this->setQuestion($question); // @TODO: Should this be $question?? See setter for why this is not trivial.
92  $this->randomGroup = $DIC->refinery()->random();
93  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
setQuestion(string $question="")
+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswerOptionValue()

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

Definition at line 1615 of file class.assClozeTest.php.

References getGap().

1615  : void
1616  {
1617  $gap = $this->getGap($qIndex); /* @var assClozeGap $gap */
1618 
1619  $item = new assAnswerCloze($answerOptionValue, $points);
1620  $item->setOrder($gap->getItemCount());
1621 
1622  $gap->addItem($item);
1623  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getGap(int $gap_index=0)
+ Here is the call graph for this function:

◆ addGapAnswer()

assClozeTest::addGapAnswer (   $gap_index,
  $order,
  $answer 
)

Sets the answer text of a gap with a given index.

The index of the first gap is 0, the index of the second gap is 1 and so on.

Parameters
integer$gap_indexA nonnegative index of the n-th gap
integer$orderThe order of the answer text
string$answerThe answer text public
See also
$gaps

Definition at line 626 of file class.assClozeTest.php.

References assClozeGap\TYPE_NUMERIC.

626  : void
627  {
628  if (array_key_exists($gap_index, $this->gaps)) {
629  if ($this->gaps[$gap_index]->getType() == assClozeGap::TYPE_NUMERIC) {
630  // only allow notation with "." for real numbers
631  $answer = str_replace(",", ".", $answer);
632  }
633  $this->gaps[$gap_index]->addItem(new assAnswerCloze(trim($answer), 0, $order));
634  }
635  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ addGapAtIndex()

assClozeTest::addGapAtIndex (   $gap,
  $index 
)

Adds a ClozeGap object at a given index.

Parameters
object$gapThe gap object
integer$indexA nonnegative index of the n-th gap public
See also
$gaps

Definition at line 697 of file class.assClozeTest.php.

697  : void
698  {
699  $this->gaps[$index] = $gap;
700  }

◆ addGapText()

assClozeTest::addGapText (   $gap_index)

Adds a new answer text value to a text gap with a given index.

The index of the first gap is 0, the index of the second gap is 1 and so on.

Parameters
integer$gap_indexA nonnegative index of the n-th gap public
See also
$gaps

Definition at line 677 of file class.assClozeTest.php.

677  : void
678  {
679  if (array_key_exists($gap_index, $this->gaps)) {
680  $answer = new assAnswerCloze(
681  "",
682  0,
683  $this->gaps[$gap_index]->getItemCount()
684  );
685  $this->gaps[$gap_index]->addItem($answer);
686  }
687  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ calculateCombinationResult()

assClozeTest::calculateCombinationResult (   $user_result)

Definition at line 1399 of file class.assClozeTest.php.

References assQuestion\$points, assQuestion\getId(), getNumericgapPoints(), getTextgapPoints(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

Referenced by calculateReachedPointsForSolution().

1399  : array
1400  {
1401  $points = 0;
1402 
1403  $assClozeGapCombinationObj = new assClozeGapCombination($this->db);
1404  $gap_used_in_combination = [];
1405  if ($assClozeGapCombinationObj->combinationExistsForQid($this->getId())) {
1406  $combinations_for_question = $assClozeGapCombinationObj->getCleanCombinationArray($this->getId());
1407  $gap_answers = [];
1408 
1409  foreach ($user_result as $user_result_build_list) {
1410  if (is_array($user_result_build_list)) {
1411  $gap_answers[$user_result_build_list['gap_id']] = $user_result_build_list['value'];
1412  }
1413  }
1414 
1415  foreach ($combinations_for_question as $combination) {
1416  foreach ($combination as $row_key => $row_answers) {
1417  $combination_fulfilled = true;
1418  $points_for_combination = $row_answers['points'];
1419  foreach ($row_answers as $gap_key => $combination_gap_answer) {
1420  if ($gap_key !== 'points') {
1421  $gap_used_in_combination[$gap_key] = $gap_key;
1422  }
1423  if ($combination_fulfilled && array_key_exists($gap_key, $gap_answers)) {
1424  switch ($combination_gap_answer['type']) {
1426  $is_text_gap_correct = $this->getTextgapPoints($gap_answers[$gap_key], $combination_gap_answer['answer'], 1);
1427  if ($is_text_gap_correct != 1) {
1428  $combination_fulfilled = false;
1429  }
1430  break;
1432  $answer = $this->gaps[$gap_key]->getItem($gap_answers[$gap_key]);
1433  $answertext = $answer?->getAnswertext();
1434  if ($answertext != $combination_gap_answer['answer']) {
1435  $combination_fulfilled = false;
1436  }
1437  break;
1439  $answer = $this->gaps[$gap_key]->getItem(0);
1440  if ($combination_gap_answer['answer'] != 'out_of_bound') {
1441  $is_numeric_gap_correct = $this->getNumericgapPoints($answer->getAnswertext(), $gap_answers[$gap_key], 1, $answer->getLowerBound(), $answer->getUpperBound());
1442  if ($is_numeric_gap_correct != 1) {
1443  $combination_fulfilled = false;
1444  }
1445  } else {
1446  $wrong_is_the_new_right = $this->getNumericgapPoints($answer->getAnswertext(), $gap_answers[$gap_key], 1, $answer->getLowerBound(), $answer->getUpperBound());
1447  if ($wrong_is_the_new_right == 1) {
1448  $combination_fulfilled = false;
1449  }
1450  }
1451  break;
1452  }
1453  } else {
1454  if ($gap_key !== 'points') {
1455  $combination_fulfilled = false;
1456  }
1457  }
1458  }
1459  if ($combination_fulfilled) {
1460  $points += $points_for_combination;
1461  }
1462  }
1463  }
1464  }
1465  return [$points, $gap_used_in_combination];
1466  }
getNumericgapPoints($a_original, $a_entered, $max_points, $lowerBound, $upperBound)
Returns the points for a text gap and compares the given solution with the entered solution using the...
getTextgapPoints($a_original, $a_entered, $max_points)
Returns the points for a text gap and compares the given solution with the entered solution using the...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPoints()

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

Definition at line 968 of file class.assClozeTest.php.

References calculateReachedPointsForSolution(), and fetchUserResult().

Referenced by getUserQuestionResult().

972  : float {
973  $user_result = $this->fetchUserResult($active_id, $pass, $authorized_solution);
974  return $this->calculateReachedPointsForSolution($user_result);
975  }
calculateReachedPointsForSolution(?array $user_result, array &$detailed=[])
fetchUserResult(int $active_id, ?int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsForSolution()

assClozeTest::calculateReachedPointsForSolution ( ?array  $user_result,
array &  $detailed = [] 
)
protected
Parameters
array$user_result
array$detailed

Definition at line 1471 of file class.assClozeTest.php.

References assQuestion\$points, calculateCombinationResult(), getIdenticalScoring(), getMaximumGapPoints(), getNumericgapPoints(), getTextgapPoints(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

Referenced by calculateReachedPoints(), calculateReachedPointsFromPreviewSession(), and getUserResultDetails().

1471  : float
1472  {
1473  $points = 0.0;
1474 
1475  $assClozeGapCombinationObj = new assClozeGapCombination($this->db);
1476  $combinations[1] = [];
1477  if ($this->gap_combinations_exist) {
1478  $combinations = $this->calculateCombinationResult($user_result);
1479  $points = $combinations[0];
1480  }
1481 
1482  $solution_values_text = []; // for identical scoring checks
1483  $solution_values_select = []; // for identical scoring checks
1484  $solution_values_numeric = []; // for identical scoring checks
1485  foreach ($user_result as $gap_id => $value) {
1486  if (is_string($value)) {
1487  $value = ["value" => $value];
1488  }
1489 
1490  if (array_key_exists($gap_id, $this->gaps) && !array_key_exists($gap_id, $combinations[1])) {
1491  switch ($this->gaps[$gap_id]->getType()) {
1493  $gappoints = 0.0;
1494  for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++) {
1495  $answer = $this->gaps[$gap_id]->getItem($order);
1496  $gotpoints = $this->getTextgapPoints($answer->getAnswertext(), $value["value"], $answer->getPoints());
1497  if ($gotpoints > $gappoints) {
1498  $gappoints = $gotpoints;
1499  }
1500  }
1501  if (!$this->getIdenticalScoring()) {
1502  // check if the same solution text was already entered
1503  if ((in_array($value["value"], $solution_values_text)) && ($gappoints > 0.0)) {
1504  $gappoints = 0.0;
1505  }
1506  }
1507  $points += $gappoints;
1508  $detailed[$gap_id] = ["points" => $gappoints, "best" => ($this->getMaximumGapPoints($gap_id) == $gappoints) ? true : false, "positive" => ($gappoints > 0.0) ? true : false];
1509  array_push($solution_values_text, $value["value"]);
1510  break;
1512  $gappoints = 0.0;
1513  for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++) {
1514  $answer = $this->gaps[$gap_id]->getItem($order);
1515  $gotpoints = $this->getNumericgapPoints($answer->getAnswertext(), $value["value"], $answer->getPoints(), $answer->getLowerBound(), $answer->getUpperBound());
1516  if ($gotpoints > $gappoints) {
1517  $gappoints = $gotpoints;
1518  }
1519  }
1520  if (!$this->getIdenticalScoring()) {
1521  // check if the same solution value was already entered
1522  $eval = new EvalMath();
1523  $eval->suppress_errors = true;
1524  $found_value = false;
1525  foreach ($solution_values_numeric as $solval) {
1526  if ($eval->e($solval) == $eval->e($value["value"])) {
1527  $found_value = true;
1528  }
1529  }
1530  if ($found_value && ($gappoints > 0.0)) {
1531  $gappoints = 0.0;
1532  }
1533  }
1534  $points += $gappoints;
1535  $detailed[$gap_id] = ["points" => $gappoints, "best" => ($this->getMaximumGapPoints($gap_id) == $gappoints) ? true : false, "positive" => ($gappoints > 0.0) ? true : false];
1536  array_push($solution_values_numeric, $value["value"]);
1537  break;
1539  if ($value["value"] >= 0.0) {
1540  for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++) {
1541  $answer = $this->gaps[$gap_id]->getItem($order);
1542  if ($value["value"] == $answer->getOrder()) {
1543  $answerpoints = $answer->getPoints();
1544  if (!$this->getIdenticalScoring()) {
1545  // check if the same solution value was already entered
1546  if ((in_array($answer->getAnswertext(), $solution_values_select)) && ($answerpoints > 0.0)) {
1547  $answerpoints = 0.0;
1548  }
1549  }
1550  $points += $answerpoints;
1551  $detailed[$gap_id] = ["points" => $answerpoints, "best" => ($this->getMaximumGapPoints($gap_id) == $answerpoints) ? true : false, "positive" => ($answerpoints > 0.0) ? true : false];
1552  array_push($solution_values_select, $answer->getAnswertext());
1553  }
1554  }
1555  }
1556  break;
1557  }
1558  }
1559  }
1560 
1561  return $points;
1562  }
getMaximumGapPoints($gap_index)
Returns the maximum points for a gap.
calculateCombinationResult($user_result)
getNumericgapPoints($a_original, $a_entered, $max_points, $lowerBound, $upperBound)
Returns the points for a text gap and compares the given solution with the entered solution using the...
getTextgapPoints($a_original, $a_entered, $max_points)
Returns the points for a text gap and compares the given solution with the entered solution using the...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getIdenticalScoring()
Returns the identical scoring status of the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assClozeTest::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $preview_session)

Definition at line 1564 of file class.assClozeTest.php.

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

1564  : float
1565  {
1566  $participant_session = $preview_session->getParticipantsSolution();
1567 
1568  if (!is_array($participant_session)) {
1569  return 0.0;
1570  }
1571 
1572  $user_solution = [];
1573 
1574  foreach ($participant_session as $key => $val) {
1575  $user_solution[$key] = ['gap_id' => $key, 'value' => $val];
1576  }
1577 
1578  $reached_points = $this->calculateReachedPointsForSolution($user_solution);
1579  $reached_points = $this->deductHintPointsFromReachedPoints($preview_session, $reached_points);
1580 
1581  return $this->ensureNonNegativePoints($reached_points);
1582  }
calculateReachedPointsForSolution(?array $user_result, array &$detailed=[])
ensureNonNegativePoints(float $points)
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $preview_session, $reached_points)
+ Here is the call graph for this function:

◆ checkForValidFormula()

assClozeTest::checkForValidFormula ( string  $value)

Definition at line 963 of file class.assClozeTest.php.

963  : int
964  {
965  return preg_match("/^-?(\\d*)(,|\\.|\\/){0,1}(\\d*)$/", $value, $matches);
966  }

◆ cleanQuestiontext()

assClozeTest::cleanQuestiontext (   $text)

Cleans cloze question text to remove attributes or tags from older ILIAS versions.

Parameters
string$textThe cloze question text
Returns
string The cleaned cloze question text

Definition at line 119 of file class.assClozeTest.php.

References null.

Referenced by loadFromDb(), and setClozeText().

119  : string
120  {
121  if ($text === null) {
122  return '';
123  }
124  // fau: fixGapReplace - mask dollars for replacement
125  $text = str_replace('$', 'GAPMASKEDDOLLAR', $text);
126  $text = preg_replace("/\[gap[^\]]*?\]/", "[gap]", $text);
127  $text = preg_replace("/<gap([^>]*?)>/", "[gap]", $text);
128  $text = str_replace("</gap>", "[/gap]", $text);
129  $text = str_replace('GAPMASKEDDOLLAR', '$', $text);
130  // fau.
131  return $text;
132  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ clearGapAnswers()

assClozeTest::clearGapAnswers ( )

Removes all answers from the gaps.

public

See also
$gaps

Definition at line 593 of file class.assClozeTest.php.

593  : void
594  {
595  foreach ($this->gaps as $gap_index => $gap) {
596  $this->gaps[$gap_index]->clearItems();
597  }
598  }

◆ cloneQuestionTypeSpecificProperties()

assClozeTest::cloneQuestionTypeSpecificProperties ( \assQuestion  $target)

Definition at line 784 of file class.assClozeTest.php.

References $gap_combinations, and assQuestion\getId().

786  : \assQuestion {
787  if ($this->gap_combinations_exist) {
788  $gap_combination = new assClozeGapCombination($this->db);
789  $gap_combination->clearGapCombinationsFromDb($target->getId());
790  $gap_combination->importGapCombinationToDb(
791  $target->getId(),
793  );
794  }
795  return $target;
796  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ createGapsFromQuestiontext()

assClozeTest::createGapsFromQuestiontext ( )

Create gap entries by parsing the question text.

public

See also
$gaps

Definition at line 540 of file class.assClozeTest.php.

References getClozeText(), and assClozeGap\TYPE_TEXT.

Referenced by setClozeText().

540  : void
541  {
542  $search_pattern = "|\[gap\](.*?)\[/gap\]|i";
543  preg_match_all($search_pattern, $this->getClozeText(), $found);
544  $this->gaps = [];
545  if (count($found[0])) {
546  foreach ($found[1] as $gap_index => $answers) {
547  // create text gaps by default
549  $textparams = preg_split("/(?<!\\\\),/", $answers);
550  foreach ($textparams as $key => $value) {
551  $answer = new assAnswerCloze($value, 0, $key);
552  $gap->addItem($answer);
553  }
554  $this->gaps[$gap_index] = $gap;
555  }
556  }
557  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAnswerText()

assClozeTest::deleteAnswerText (   $gap_index,
  $answer_index 
)

Deletes the answer text of a gap with a given index and an answer with a given order.

The index of the first gap is 0, the index of the second gap is 1 and so on.

Parameters
integer$gap_indexA nonnegative index of the n-th gap
integer$answer_indexThe order of the answer text public
See also
$gaps

Definition at line 828 of file class.assClozeTest.php.

References deleteGap(), and updateClozeTextFromGaps().

828  : void
829  {
830  if (array_key_exists($gap_index, $this->gaps)) {
831  if ($this->gaps[$gap_index]->getItemCount() == 1) {
832  // this is the last answer text => remove the gap
833  $this->deleteGap($gap_index);
834  } else {
835  // remove the answer text
836  $this->gaps[$gap_index]->deleteItem($answer_index);
837  $this->updateClozeTextFromGaps();
838  }
839  }
840  }
deleteGap($gap_index)
Deletes a gap with a given index.
updateClozeTextFromGaps()
Updates the gap parameters in the cloze text from the form input.
+ Here is the call graph for this function:

◆ deleteGap()

assClozeTest::deleteGap (   $gap_index)

Deletes a gap with a given index.

The index of the first gap is 0, the index of the second gap is 1 and so on.

Parameters
integer$gap_indexA nonnegative index of the n-th gap public
See also
$gaps

Definition at line 850 of file class.assClozeTest.php.

References getClozeText(), getGaps(), and replaceFirstGap().

Referenced by deleteAnswerText().

850  : void
851  {
852  if (array_key_exists($gap_index, $this->gaps)) {
853  $output = $this->getClozeText();
854  foreach ($this->getGaps() as $replace_gap_index => $gap) {
855  $answers = [];
856  foreach ($gap->getItemsRaw() as $item) {
857  array_push($answers, str_replace(",", "\\,", $item->getAnswerText()));
858  }
859  if ($replace_gap_index == $gap_index) {
860  // fau: fixGapReplace - use replace function
861  $output = $this->replaceFirstGap($output, '');
862  // fau.
863  } else {
864  // fau: fixGapReplace - use replace function
865  $output = $this->replaceFirstGap($output, "[_gap]" . join(",", $answers) . "[/_gap]");
866  // fau.
867  }
868  }
869  $output = str_replace("_gap]", "gap]", $output);
870  $this->cloze_text = $output;
871  unset($this->gaps[$gap_index]);
872  $this->gaps = array_values($this->gaps);
873  }
874  }
replaceFirstGap(string $gaptext, string $content)
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchAnswerValueForGap()

assClozeTest::fetchAnswerValueForGap (   $userSolution,
  $gapIndex 
)

Definition at line 1584 of file class.assClozeTest.php.

1584  : string
1585  {
1586  $answerValue = '';
1587 
1588  foreach ($userSolution as $value1 => $value2) {
1589  if ($value1 == $gapIndex) {
1590  $answerValue = $value2;
1591  break;
1592  }
1593  }
1594 
1595  return $answerValue;
1596  }

◆ fetchSolutionSubmit()

assClozeTest::fetchSolutionSubmit ( )

Definition at line 1025 of file class.assClozeTest.php.

References getGaps(), null, assClozeGap\TYPE_NUMERIC, and assClozeGap\TYPE_SELECT.

Referenced by getSolutionSubmit(), and saveWorkingData().

1025  : array
1026  {
1027  $solution_submit = [];
1028  $post_wrapper = $this->dic->http()->wrapper()->post();
1029  foreach ($this->getGaps() as $index => $gap) {
1030  if (!$post_wrapper->has("gap_$index")) {
1031  continue;
1032  }
1033  $value = trim($post_wrapper->retrieve(
1034  "gap_$index",
1035  $this->dic->refinery()->kindlyTo()->string()
1036  ));
1037  if ($value === '') {
1038  continue;
1039  }
1040 
1041  if ($gap->getType() === assClozeGap::TYPE_SELECT && $value === '-1') {
1042  continue;
1043  }
1044 
1045  if ($gap->getType() === assClozeGap::TYPE_NUMERIC) {
1046  $value = str_replace(',', '.', $value);
1047  if (!is_numeric($value)) {
1048  $value = null;
1049  }
1050  }
1051 
1052  $solution_submit[$index] = $value;
1053  }
1054 
1055  return $solution_submit;
1056  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchUserResult()

assClozeTest::fetchUserResult ( int  $active_id,
?int  $pass 
)
private

Definition at line 988 of file class.assClozeTest.php.

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

Referenced by calculateReachedPoints(), and getUserResultDetails().

991  : array {
992  if (is_null($pass)) {
993  $pass = $this->getSolutionMaxPass($active_id);
994  }
995 
996  $result = $this->getCurrentSolutionResultSet($active_id, $pass, true);
997  $user_result = [];
998  while ($data = $this->db->fetchAssoc($result)) {
999  if ($data['value2'] === '') {
1000  continue;
1001  }
1002  $user_result[$data['value1']] = [
1003  'gap_id' => $data['value1'],
1004  'value' => $data['value2']
1005  ];
1006  }
1007 
1008  ksort($user_result);
1009  return $user_result;
1010  }
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:

◆ flushGaps()

assClozeTest::flushGaps ( )

Definition at line 413 of file class.assClozeTest.php.

413  : void
414  {
415  $this->gaps = [];
416  }

◆ getAdditionalTableName()

assClozeTest::getAdditionalTableName ( )

Returns the name of the additional question data table in the database.

Returns
string The additional table name public

Definition at line 1171 of file class.assClozeTest.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

1171  : string
1172  {
1173  return "qpl_qst_cloze";
1174  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assClozeTest::getAnswerTableName ( )

Definition at line 1176 of file class.assClozeTest.php.

1176  : array
1177  {
1178  return ["qpl_a_cloze",'qpl_a_cloze_combi_res'];
1179  }

◆ getAvailableAnswerOptions()

assClozeTest::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
Returns
array|ASS_AnswerSimple

Definition at line 1390 of file class.assClozeTest.php.

References getGap(), getGaps(), and null.

1391  {
1392  if ($index !== null) {
1393  return $this->getGap($index);
1394  } else {
1395  return $this->getGaps();
1396  }
1397  }
getGap(int $gap_index=0)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ getClozeText()

assClozeTest::getClozeText ( )

Returns the cloze text.

Returns
string The cloze text string public
See also
$cloze_text

Definition at line 437 of file class.assClozeTest.php.

References $cloze_text.

Referenced by createGapsFromQuestiontext(), deleteGap(), getClozeTextForHTMLOutput(), getRTETextWithMediaObjects(), isComplete(), lmMigrateQuestionTypeSpecificContent(), saveAdditionalQuestionDataToDb(), toJSON(), toLog(), and updateClozeTextFromGaps().

437  : string
438  {
439  return $this->cloze_text;
440  }
+ Here is the caller graph for this function:

◆ getClozeTextForHTMLOutput()

assClozeTest::getClozeTextForHTMLOutput ( )

Returns the cloze text as HTML (with optional nl2br) Fix for Mantis 29987: We assume Tiny embeds any text in tags, so if no tags are present, we derive it's non-HTML content and apply nl2br.

Returns
string The cloze text string as HTML
See also
$cloze_text

Definition at line 450 of file class.assClozeTest.php.

References getClozeText(), assQuestion\getHtmlQuestionContentPurifier(), assQuestion\isAdditionalContentEditingModePageObject(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

450  : string
451  {
452  $gaps = [];
453  preg_match_all('/\[gap\].*?\[\/gap\]/', $this->getClozeText(), $gaps);
454  $string_with_replaced_gaps = str_replace($gaps[0], '######GAP######', $this->getClozeText());
455  $cleaned_text = $this->getHtmlQuestionContentPurifier()->purify(
456  $string_with_replaced_gaps
457  );
458  $cleaned_text_with_gaps = preg_replace_callback('/######GAP######/', function ($match) use (&$gaps) {
459  return array_shift($gaps[0]);
460  }, $cleaned_text);
461 
463  || !(new ilSetting('advanced_editing'))->get('advanced_editing_javascript_editor') === 'tinymce') {
464  $cleaned_text_with_gaps = nl2br($cleaned_text_with_gaps);
465  }
466 
467  return ilLegacyFormElementsUtil::prepareTextareaOutput($cleaned_text_with_gaps, true);
468  }
isAdditionalContentEditingModePageObject()
getClozeText()
Returns the cloze text.
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:

◆ getCorrectSolutionForTextOutput()

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

Definition at line 1713 of file class.assClozeTest.php.

References getGaps(), and ILIAS\Repository\lng().

1713  : array
1714  {
1715  $answers = [];
1716  foreach ($this->getGaps() as $gap_index => $gap) {
1717  $correct_answers = array_map(
1718  fn(int $v): string => $gap->getItem($v)->getAnswertext(),
1719  $gap->getBestSolutionIndexes()
1720  );
1721  $answers[] = $this->lng->txt('gap') . ' ' . $gap_index + 1 . ': '
1722  . implode(',', $correct_answers);
1723  }
1724  return $answers;
1725  }
+ Here is the call graph for this function:

◆ getEndTag()

assClozeTest::getEndTag ( )

Returns the end tag of a cloze gap.

Returns
string The end tag of a cloze gap public
See also
$end_tag

Definition at line 501 of file class.assClozeTest.php.

References $end_tag.

501  : string
502  {
503  return $this->end_tag;
504  }

◆ getExpressionTypes()

◆ getFeedbackMode()

assClozeTest::getFeedbackMode ( )
Returns
string

Definition at line 521 of file class.assClozeTest.php.

References $feedbackMode.

Referenced by saveAdditionalQuestionDataToDb().

521  : string
522  {
523  return $this->feedbackMode;
524  }
+ Here is the caller graph for this function:

◆ getFixedTextLength()

assClozeTest::getFixedTextLength ( )

Gets the fixed text length for all text fields in the cloze question.

Returns
integer The text field length public

Definition at line 1198 of file class.assClozeTest.php.

References $fixed_text_length.

Referenced by saveAdditionalQuestionDataToDb().

1198  : ?int
1199  {
1200  return $this->fixed_text_length;
1201  }
+ Here is the caller graph for this function:

◆ getGap()

assClozeTest::getGap ( int  $gap_index = 0)

Definition at line 637 of file class.assClozeTest.php.

References null.

Referenced by addAnswerOptionValue(), getAvailableAnswerOptions(), isAddableAnswerOptionValue(), and saveWorkingData().

637  : ?assClozeGap
638  {
639  if (array_key_exists($gap_index, $this->gaps)) {
640  return $this->gaps[$gap_index];
641  }
642  return null;
643  }
Class for cloze question gaps.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getGapCombinations()

assClozeTest::getGapCombinations ( )

Definition at line 1240 of file class.assClozeTest.php.

References $gap_combinations.

1240  : array
1241  {
1242  return $this->gap_combinations;
1243  }

◆ getGapCombinationsExists()

assClozeTest::getGapCombinationsExists ( )

Definition at line 1235 of file class.assClozeTest.php.

References $gap_combinations_exist.

1235  : bool
1236  {
1238  }

◆ getGapCount()

assClozeTest::getGapCount ( )

Returns the number of gaps.

Returns
integer The number of gaps public
See also
$gaps

Definition at line 607 of file class.assClozeTest.php.

607  : int
608  {
609  if (is_array($this->gaps)) {
610  return count($this->gaps);
611  } else {
612  return 0;
613  }
614  }

◆ getGaps()

assClozeTest::getGaps ( )

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

References $gaps.

Referenced by deleteGap(), fetchSolutionSubmit(), getAvailableAnswerOptions(), getCorrectSolutionForTextOutput(), isComplete(), solutionValuesToLog(), solutionValuesToText(), toJSON(), toLog(), and updateClozeTextFromGaps().

408  : array
409  {
410  return $this->gaps;
411  }
+ Here is the caller graph for this function:

◆ getIdenticalScoring()

assClozeTest::getIdenticalScoring ( )

Returns the identical scoring status of the question.

Returns
boolean The identical scoring status
See also
$identical_scoring public

Definition at line 1148 of file class.assClozeTest.php.

References $identical_scoring.

Referenced by calculateReachedPointsForSolution(), and saveAdditionalQuestionDataToDb().

1148  : bool
1149  {
1150  return $this->identical_scoring;
1151  }
bool $identical_scoring
Defines the scoring for "identical solutions".
+ Here is the caller graph for this function:

◆ getMaximumGapPoints()

assClozeTest::getMaximumGapPoints (   $gap_index)

Returns the maximum points for a gap.

Parameters
integer$gap_indexThe index of the gap
Returns
double The maximum points for the gap public
See also
$points

Definition at line 1211 of file class.assClozeTest.php.

References assQuestion\$points.

Referenced by calculateReachedPointsForSolution().

1212  {
1213  $points = 0;
1214  $gap_max_points = 0;
1215  if (array_key_exists($gap_index, $this->gaps)) {
1216  $gap = &$this->gaps[$gap_index];
1217  foreach ($gap->getItems($this->getShuffler()) as $answer) {
1218  if ($answer->getPoints() > $gap_max_points) {
1219  $gap_max_points = $answer->getPoints();
1220  }
1221  }
1222  $points += $gap_max_points;
1223  }
1224  return $points;
1225  }
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assClozeTest::getMaximumPoints ( )

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

public

See also
$points

Definition at line 742 of file class.assClozeTest.php.

References assQuestion\$points, assQuestion\getId(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

Referenced by getUserQuestionResult(), and isComplete().

742  : float
743  {
744  $assClozeGapCombinationObj = new assClozeGapCombination($this->db);
745  $points = 0;
746  $gaps_used_in_combination = [];
747  if ($this->gap_combinations_exist) {
748  $points = $assClozeGapCombinationObj->getMaxPointsForCombination($this->getId());
749  $gaps_used_in_combination = $assClozeGapCombinationObj->getGapsWhichAreUsedInCombination($this->getId());
750  }
751  foreach ($this->gaps as $gap_index => $gap) {
752  if (!array_key_exists($gap_index, $gaps_used_in_combination)) {
753  if ($gap->getType() == assClozeGap::TYPE_TEXT) {
754  $gap_max_points = 0;
755  foreach ($gap->getItems($this->getShuffler()) as $item) {
756  if ($item->getPoints() > $gap_max_points) {
757  $gap_max_points = $item->getPoints();
758  }
759  }
760  $points += $gap_max_points;
761  } elseif ($gap->getType() == assClozeGap::TYPE_SELECT) {
762  $srpoints = 0;
763  foreach ($gap->getItems($this->getShuffler()) as $item) {
764  if ($item->getPoints() > $srpoints) {
765  $srpoints = $item->getPoints();
766  }
767  }
768  $points += $srpoints;
769  } elseif ($gap->getType() == assClozeGap::TYPE_NUMERIC) {
770  $numpoints = 0;
771  foreach ($gap->getItems($this->getShuffler()) as $item) {
772  if ($item->getPoints() > $numpoints) {
773  $numpoints = $item->getPoints();
774  }
775  }
776  $points += $numpoints;
777  }
778  }
779  }
780 
781  return $points;
782  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumericgapPoints()

assClozeTest::getNumericgapPoints (   $a_original,
  $a_entered,
  $max_points,
  $lowerBound,
  $upperBound 
)

Returns the points for a text gap and compares the given solution with the entered solution using the text gap rating options.

Parameters
string$a_originalThe original (correct) text
string$a_enteredThe text entered by the user
float$max_pointsThe maximum number of points for the solution public

Definition at line 937 of file class.assClozeTest.php.

Referenced by calculateCombinationResult(), and calculateReachedPointsForSolution().

937  : float
938  {
939  $eval = new EvalMath();
940  $eval->suppress_errors = true;
941  $result = 0.0;
942 
943  if ($eval->e($a_entered) === false) {
944  return 0.0;
945  } elseif (($eval->e($lowerBound) !== false) && ($eval->e($upperBound) !== false)) {
946  if (($eval->e($a_entered) >= $eval->e($lowerBound)) && ($eval->e($a_entered) <= $eval->e($upperBound))) {
947  $result = $max_points;
948  }
949  } elseif ($eval->e($lowerBound) !== false) {
950  if (($eval->e($a_entered) >= $eval->e($lowerBound)) && ($eval->e($a_entered) <= $eval->e($a_original))) {
951  $result = $max_points;
952  }
953  } elseif ($eval->e($upperBound) !== false) {
954  if (($eval->e($a_entered) >= $eval->e($a_original)) && ($eval->e($a_entered) <= $eval->e($upperBound))) {
955  $result = $max_points;
956  }
957  } elseif ($eval->e($a_entered) == $eval->e($a_original)) {
958  $result = $max_points;
959  }
960  return $result;
961  }
+ Here is the caller graph for this function:

◆ getOperators()

assClozeTest::getOperators ( string  $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

Definition at line 1318 of file class.assClozeTest.php.

1318  : array
1319  {
1320  return ilOperatorsExpressionMapping::getOperatorsByExpression($expression);
1321  }

◆ getQuestionType()

assClozeTest::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

Definition at line 1099 of file class.assClozeTest.php.

Referenced by toJSON(), and toLog().

1099  : string
1100  {
1101  return "assClozeTest";
1102  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assClozeTest::getRTETextWithMediaObjects ( )

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

Definition at line 1231 of file class.assClozeTest.php.

References getClozeText().

1231  : string
1232  {
1233  return parent::getRTETextWithMediaObjects() . $this->getClozeText();
1234  }
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:

◆ getSolutionSubmit()

assClozeTest::getSolutionSubmit ( )
protected

Definition at line 1058 of file class.assClozeTest.php.

References fetchSolutionSubmit().

1058  : array
1059  {
1060  return $this->fetchSolutionSubmit();
1061  }
+ Here is the call graph for this function:

◆ getStartTag()

assClozeTest::getStartTag ( )

Returns the start tag of a cloze gap.

Returns
string The start tag of a cloze gap public
See also
$start_tag

Definition at line 477 of file class.assClozeTest.php.

References $start_tag.

477  : string
478  {
479  return $this->start_tag;
480  }

◆ getTextgapPoints()

assClozeTest::getTextgapPoints (   $a_original,
  $a_entered,
  $max_points 
)

Returns the points for a text gap and compares the given solution with the entered solution using the text gap rating options.

Parameters
string$a_originalThe original (correct) text
string$a_enteredThe text entered by the user
integer$max_pointsThe maximum number of points for the solution public

Definition at line 885 of file class.assClozeTest.php.

References $DIC, assQuestion\$refinery, getTextgapRating(), 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 calculateCombinationResult(), and calculateReachedPointsForSolution().

885  : float
886  {
887  global $DIC;
888  $refinery = $DIC->refinery();
889  $result = 0;
890  $gaprating = $this->getTextgapRating();
891 
892  switch ($gaprating) {
894  if (strcmp(ilStr::strToLower($a_original), ilStr::strToLower($a_entered)) == 0) {
895  $result = $max_points;
896  }
897  break;
899  if (strcmp($a_original, $a_entered) == 0) {
900  $result = $max_points;
901  }
902  break;
904  $transformation = $refinery->string()->levenshtein()->standard($a_original, 1);
905  break;
907  $transformation = $refinery->string()->levenshtein()->standard($a_original, 2);
908  break;
910  $transformation = $refinery->string()->levenshtein()->standard($a_original, 3);
911  break;
913  $transformation = $refinery->string()->levenshtein()->standard($a_original, 4);
914  break;
916  $transformation = $refinery->string()->levenshtein()->standard($a_original, 5);
917  break;
918  }
919 
920  // run answers against Levenshtein2 methods
921  if (isset($transformation) && $transformation->transform($a_entered) >= 0) {
922  $result = $max_points;
923  }
924  return $result;
925  }
const TEXTGAP_RATING_LEVENSHTEIN3
Refinery $refinery
const TEXTGAP_RATING_CASEINSENSITIVE
getTextgapRating()
Returns the rating option for text gaps.
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:

◆ getTextgapRating()

assClozeTest::getTextgapRating ( )

Returns the rating option for text gaps.

Returns
string The rating option for text gaps
See also
$textgap_rating public

Definition at line 1111 of file class.assClozeTest.php.

References $textgap_rating.

Referenced by getTextgapPoints(), and saveAdditionalQuestionDataToDb().

1111  : string
1112  {
1113  return $this->textgap_rating;
1114  }
string $textgap_rating
The rating option for text gaps.
+ Here is the caller graph for this function:

◆ getUserQuestionResult()

assClozeTest::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 1334 of file class.assClozeTest.php.

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

1338  $result = new ilUserQuestionResult($this, $active_id, $pass);
1339 
1340  $maxStep = $this->lookupMaxStep($active_id, $pass);
1341  if ($maxStep > 0) {
1342  $data = $this->db->queryF(
1343  "
1344  SELECT sol.value1+1 as val, sol.value2, cloze.cloze_type
1345  FROM tst_solutions sol
1346  INNER JOIN qpl_a_cloze cloze ON cloze.gap_id = value1 AND cloze.question_fi = sol.question_fi
1347  WHERE sol.active_fi = %s AND sol.pass = %s AND sol.question_fi = %s AND sol.step = %s
1348  GROUP BY sol.solution_id, sol.value1+1, sol.value2, cloze.cloze_type
1349  ",
1350  ["integer", "integer", "integer","integer"],
1351  [$active_id, $pass, $this->getId(), $maxStep]
1352  );
1353  } else {
1354  $data = $this->db->queryF(
1355  "
1356  SELECT sol.value1+1 as val, sol.value2, cloze.cloze_type
1357  FROM tst_solutions sol
1358  INNER JOIN qpl_a_cloze cloze ON cloze.gap_id = value1 AND cloze.question_fi = sol.question_fi
1359  WHERE sol.active_fi = %s AND sol.pass = %s AND sol.question_fi = %s
1360  GROUP BY sol.solution_id, sol.value1+1, sol.value2, cloze.cloze_type
1361  ",
1362  ["integer", "integer", "integer"],
1363  [$active_id, $pass, $this->getId()]
1364  );
1365  }
1366 
1367  while ($row = $this->db->fetchAssoc($data)) {
1368  if ($row["cloze_type"] == 1) {
1369  $row["value2"]++;
1370  }
1371  $result->addKeyValue($row["val"], $row["value2"]);
1372  }
1373 
1374  $points = $this->calculateReachedPoints($active_id, $pass);
1375  $max_points = $this->getMaximumPoints();
1376 
1377  $result->setReachedPercentage(($points / $max_points) * 100);
1378 
1379  return $result;
1380  }
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...
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
lookupMaxStep(int $active_id, int $pass)
+ Here is the call graph for this function:

◆ getUserResultDetails()

assClozeTest::getUserResultDetails ( int  $active_id,
?int  $pass = null,
bool  $authorized_solution = true 
)

Definition at line 977 of file class.assClozeTest.php.

References calculateReachedPointsForSolution(), and fetchUserResult().

981  : array {
982  $user_result = $this->fetchUserResult($active_id, $pass, $authorized_solution);
983  $detailed = [];
984  $this->calculateReachedPointsForSolution($user_result, $detailed);
985  return $detailed;
986  }
calculateReachedPointsForSolution(?array $user_result, array &$detailed=[])
fetchUserResult(int $active_id, ?int $pass)
+ Here is the call graph for this function:

◆ isAddableAnswerOptionValue()

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

Definition at line 1598 of file class.assClozeTest.php.

References getGap(), and assClozeGap\TYPE_TEXT.

1598  : bool
1599  {
1600  $gap = $this->getGap($qIndex);
1601 
1602  if ($gap->getType() != assClozeGap::TYPE_TEXT) {
1603  return false;
1604  }
1605 
1606  foreach ($gap->getItems($this->randomGroup->dontShuffle()) as $item) {
1607  if ($item->getAnswertext() === $answerOptionValue) {
1608  return false;
1609  }
1610  }
1611 
1612  return true;
1613  }
getGap(int $gap_index=0)
+ Here is the call graph for this function:

◆ isComplete()

assClozeTest::isComplete ( )

Returns TRUE, if a cloze test is complete for use.

Returns
boolean TRUE, if the cloze test is complete for use, otherwise FALSE

Definition at line 100 of file class.assClozeTest.php.

References assQuestion\getAuthor(), getClozeText(), getGaps(), getMaximumPoints(), and assQuestion\getTitle().

100  : bool
101  {
102  if ($this->getTitle() !== ''
103  && $this->getAuthor()
104  && $this->getClozeText()
105  && count($this->getGaps())
106  && $this->getMaximumPoints() > 0) {
107  return true;
108  }
109  return false;
110  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:

◆ isValidNumericSubmitValue()

assClozeTest::isValidNumericSubmitValue (   $submittedValue)
protected

Definition at line 1012 of file class.assClozeTest.php.

1012  : bool
1013  {
1014  if (is_numeric($submittedValue)) {
1015  return true;
1016  }
1017 
1018  if (preg_match('/^[-+]{0,1}\d+\/\d+$/', $submittedValue)) {
1019  return true;
1020  }
1021 
1022  return false;
1023  }

◆ lmMigrateQuestionTypeSpecificContent()

assClozeTest::lmMigrateQuestionTypeSpecificContent ( ilAssSelfAssessmentMigrator  $migrator)
protected
Parameters
ilAssSelfAssessmentMigrator$migrator

Definition at line 1258 of file class.assClozeTest.php.

References getClozeText(), and ilAssSelfAssessmentMigrator\migrateToLmContent().

1258  : void
1259  {
1260  // DO NOT USE SETTER FOR CLOZE TEXT -> SETTER DOES RECREATE GAP OBJECTS without having gap type info ^^
1261  //$this->setClozeText( $migrator->migrateToLmContent($this->getClozeText()) );
1262  $this->cloze_text = $migrator->migrateToLmContent($this->getClozeText());
1263  // DO NOT USE SETTER FOR CLOZE TEXT -> SETTER DOES RECREATE GAP OBJECTS without having gap type info ^^
1264  }
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:

◆ loadFromDb()

assClozeTest::loadFromDb ( int  $question_id)

Definition at line 147 of file class.assClozeTest.php.

References $data, Vendor\Package\$e, ilRTE\_replaceMediaObjectImageSrc(), cleanQuestiontext(), ilAssClozeTestFeedback\FB_MODE_GAP_QUESTION, getAdditionalTableName(), ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), null, assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), setClozeText(), assQuestion\setComment(), setFeedbackMode(), setFixedTextLength(), setGapCombinations(), setGapCombinationsExists(), assQuestion\setId(), setIdenticalScoring(), assQuestion\setLifecycle(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setTextgapRating(), assQuestion\setTitle(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

147  : void
148  {
149  $result = $this->db->queryF(
150  "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",
151  ["integer"],
152  [$question_id]
153  );
154  if ($result->numRows() == 1) {
155  $data = $this->db->fetchAssoc($result);
156  $this->setId($question_id);
157  $this->setNrOfTries($data['nr_of_tries']);
158  $this->setObjId($data["obj_fi"]);
159  $this->setTitle((string) $data["title"]);
160  $this->setComment((string) $data["description"]);
161  $this->setOriginalId($data["original_id"]);
162  $this->setAuthor($data["author"]);
163  $this->setPoints($data["points"]);
164  $this->setOwner($data["owner"]);
165  $this->setQuestion($this->cleanQuestiontext($data["question_text"]));
166  $this->setClozeText($data['cloze_text'] ?? '');
167  $this->setFixedTextLength($data["fixed_textlen"]);
168  $this->setIdenticalScoring(($data['tstamp'] === 0) ? true : (bool) $data['identical_scoring']);
169  $this->setFeedbackMode($data['feedback_mode'] === null ? ilAssClozeTestFeedback::FB_MODE_GAP_QUESTION : $data['feedback_mode']);
170 
171  try {
175  }
176 
177  $this->question = ilRTE::_replaceMediaObjectImageSrc($this->question, 1);
178  $this->cloze_text = ilRTE::_replaceMediaObjectImageSrc($this->cloze_text, 1);
179  $this->setTextgapRating($data["textgap_rating"]);
180 
181  try {
182  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
183  } catch (ilTestQuestionPoolException $e) {
184  }
185 
186  $result = $this->db->queryF(
187  "SELECT * FROM qpl_a_cloze WHERE question_fi = %s ORDER BY gap_id, aorder ASC",
188  ["integer"],
189  [$question_id]
190  );
191  if ($result->numRows() > 0) {
192  $this->gaps = [];
193  while ($data = $this->db->fetchAssoc($result)) {
194  switch ($data["cloze_type"]) {
196  if (!array_key_exists($data["gap_id"], $this->gaps)) {
197  $this->gaps[$data["gap_id"]] = new assClozeGap(assClozeGap::TYPE_TEXT);
198  }
199  $answer = new assAnswerCloze(
200  $data["answertext"],
201  $data["points"],
202  $data["aorder"]
203  );
204  $this->gaps[$data["gap_id"]]->setGapSize((int) $data['gap_size']);
205 
206  $this->gaps[$data["gap_id"]]->addItem($answer);
207  break;
209  if (!array_key_exists($data["gap_id"], $this->gaps)) {
210  $this->gaps[$data["gap_id"]] = new assClozeGap(assClozeGap::TYPE_SELECT);
211  $this->gaps[$data["gap_id"]]->setShuffle($data["shuffle"]);
212  }
213  $answer = new assAnswerCloze(
214  $data["answertext"],
215  $data["points"],
216  $data["aorder"]
217  );
218  $this->gaps[$data["gap_id"]]->addItem($answer);
219  break;
221  if (!array_key_exists($data["gap_id"], $this->gaps)) {
222  $this->gaps[$data["gap_id"]] = new assClozeGap(assClozeGap::TYPE_NUMERIC);
223  }
224  $answer = new assAnswerCloze(
225  $data["answertext"],
226  $data["points"],
227  $data["aorder"]
228  );
229  $this->gaps[$data["gap_id"]]->setGapSize((int) $data['gap_size']);
230  $answer->setLowerBound($data["lowerlimit"]);
231  $answer->setUpperBound($data["upperlimit"]);
232  $this->gaps[$data["gap_id"]]->addItem($answer);
233  break;
234  }
235  }
236  }
237  }
238  $check_for_gap_combinations = (new assClozeGapCombination($this->db))->loadFromDb($question_id);
239  if (count($check_for_gap_combinations) != 0) {
240  $this->setGapCombinationsExists(true);
241  $this->setGapCombinations($check_for_gap_combinations);
242  }
243  parent::loadFromDb($question_id);
244  }
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setOwner(int $owner=-1)
Class for cloze question gaps.
setComment(string $comment="")
setIdenticalScoring(bool $identical_scoring)
Sets the identical scoring option for cloze questions.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setGapCombinationsExists($value)
setClozeText(string $cloze_text='')
setFixedTextLength(?int $fixed_text_length)
Sets a fixed text length for all text fields in the cloze question.
setPoints(float $points)
setObjId(int $obj_id=0)
cleanQuestiontext($text)
Cleans cloze question text to remove attributes or tags from older ILIAS versions.
setFeedbackMode($feedbackMode)
setTextgapRating($a_textgap_rating)
Sets the rating option for text gaps.
setId(int $id=-1)
setOriginalId(?int $original_id)
setTitle(string $title="")
setLifecycle(ilAssQuestionLifecycle $lifecycle)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setAuthor(string $author="")
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
const FB_MODE_GAP_QUESTION
constants for different feedback modes (per gap or per gap-answers/options)
loadFromDb(int $question_id)
setQuestion(string $question="")
+ Here is the call graph for this function:

◆ replaceFirstGap()

assClozeTest::replaceFirstGap ( string  $gaptext,
string  $content 
)

Definition at line 134 of file class.assClozeTest.php.

Referenced by deleteGap(), and updateClozeTextFromGaps().

137  : string {
138  $output = preg_replace(
139  '/\[gap\].*?\[\/gap\]/',
140  str_replace('$', 'GAPMASKEDDOLLAR', $content),
141  $gaptext,
142  1
143  );
144  return str_replace('GAPMASKEDDOLLAR', '$', $output);
145  }
+ Here is the caller graph for this function:

◆ saveAdditionalQuestionDataToDb()

assClozeTest::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

Definition at line 268 of file class.assClozeTest.php.

References ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), getClozeText(), getFeedbackMode(), getFixedTextLength(), assQuestion\getId(), getIdenticalScoring(), getTextgapRating(), and null.

Referenced by saveToDb().

268  : void
269  {
270  $this->db->manipulateF(
271  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
272  [ "integer" ],
273  [ $this->getId() ]
274  );
275 
276  $this->db->insert($this->getAdditionalTableName(), [
277  'question_fi' => ['integer', $this->getId()],
278  'textgap_rating' => ['text', $this->getTextgapRating()],
279  'identical_scoring' => ['text', $this->getIdenticalScoring()],
280  'fixed_textlen' => ['integer', $this->getFixedTextLength() ? $this->getFixedTextLength() : null],
281  'cloze_text' => ['text', ilRTE::_replaceMediaObjectImageSrc($this->getClozeText(), 0)],
282  'feedback_mode' => ['text', $this->getFeedbackMode()]
283  ]);
284  }
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...
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getTextgapRating()
Returns the rating option for text gaps.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getFixedTextLength()
Gets the fixed text length for all text fields in the cloze question.
getClozeText()
Returns the cloze text.
getIdenticalScoring()
Returns the identical scoring status of the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAnswerSpecificDataToDb()

assClozeTest::saveAnswerSpecificDataToDb ( )

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

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

Definition at line 255 of file class.assClozeTest.php.

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

Referenced by saveToDb().

255  : void
256  {
257  $this->db->manipulateF(
258  "DELETE FROM qpl_a_cloze WHERE question_fi = %s",
259  [ "integer" ],
260  [ $this->getId() ]
261  );
262 
263  foreach ($this->gaps as $key => $gap) {
264  $this->saveClozeGapItemsToDb($gap, $key);
265  }
266  }
saveClozeGapItemsToDb(assClozeGap $gap, int $key)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeGapItemsToDb()

assClozeTest::saveClozeGapItemsToDb ( assClozeGap  $gap,
int  $key 
)
protected

Definition at line 285 of file class.assClozeTest.php.

References assClozeGap\getItems(), assClozeGap\getType(), saveClozeNumericGapRecordToDb(), saveClozeSelectGapRecordToDb(), saveClozeTextGapRecordToDb(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

Referenced by saveAnswerSpecificDataToDb().

288  : void {
289  foreach ($gap->getItems($this->getShuffler()) as $item) {
290  $next_id = $this->db->nextId('qpl_a_cloze');
291  switch ($gap->getType()) {
293  $this->saveClozeTextGapRecordToDb($next_id, $key, $item, $gap);
294  break;
296  $this->saveClozeSelectGapRecordToDb($next_id, $key, $item, $gap);
297  break;
299  $this->saveClozeNumericGapRecordToDb($next_id, $key, $item, $gap);
300  break;
301  }
302  }
303  }
saveClozeNumericGapRecordToDb(int $next_id, int $key, assAnswerCloze $item, assClozeGap $gap)
saveClozeSelectGapRecordToDb(int $next_id, int $key, assAnswerCloze $item, assClozeGap $gap)
getItems(Transformation $shuffler, ?int $gap_index=null)
saveClozeTextGapRecordToDb(int $next_id, int $key, assAnswerCloze $item, assClozeGap $gap)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeNumericGapRecordToDb()

assClozeTest::saveClozeNumericGapRecordToDb ( int  $next_id,
int  $key,
assAnswerCloze  $item,
assClozeGap  $gap 
)
protected

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

References ASS_AnswerSimple\getAnswertext(), assClozeGap\getGapSize(), assQuestion\getId(), assAnswerCloze\getLowerBound(), ASS_AnswerSimple\getOrder(), ASS_AnswerSimple\getPoints(), assClozeGap\getType(), assAnswerCloze\getUpperBound(), and ILIAS\Repository\int().

Referenced by saveClozeGapItemsToDb().

372  : void {
373  $eval = new EvalMath();
374  $eval->suppress_errors = true;
375  $this->db->manipulateF(
376  'INSERT INTO qpl_a_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type, lowerlimit, upperlimit, gap_size) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
377  [
378  'integer',
379  'integer',
380  'integer',
381  'text',
382  'float',
383  'integer',
384  'text',
385  'text',
386  'text',
387  'integer'
388  ],
389  [
390  $next_id,
391  $this->getId(),
392  $key,
393  strlen($item->getAnswertext()) ? $item->getAnswertext() : '',
394  $item->getPoints(),
395  $item->getOrder(),
396  $gap->getType(),
397  ($eval->e($item->getLowerBound()) !== false && strlen(
398  $item->getLowerBound()
399  ) > 0) ? $item->getLowerBound() : $item->getAnswertext(),
400  ($eval->e($item->getUpperBound()) !== false && strlen(
401  $item->getUpperBound()
402  ) > 0) ? $item->getUpperBound() : $item->getAnswertext(),
403  (int) $gap->getGapSize()
404  ]
405  );
406  }
getLowerBound()
Returns the lower bound.
getUpperBound()
Returns the upper bound.
getPoints()
Gets the points.
getAnswertext()
Gets the answer text.
getOrder()
Gets the sort/display order.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeSelectGapRecordToDb()

assClozeTest::saveClozeSelectGapRecordToDb ( int  $next_id,
int  $key,
assAnswerCloze  $item,
assClozeGap  $gap 
)
protected

Definition at line 336 of file class.assClozeTest.php.

References ASS_AnswerSimple\getAnswertext(), assQuestion\getId(), ASS_AnswerSimple\getOrder(), ASS_AnswerSimple\getPoints(), assClozeGap\getShuffle(), and assClozeGap\getType().

Referenced by saveClozeGapItemsToDb().

341  : void {
342  $this->db->manipulateF(
343  'INSERT INTO qpl_a_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type, shuffle) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)',
344  [
345  'integer',
346  'integer',
347  'integer',
348  'text',
349  'float',
350  'integer',
351  'text',
352  'text'
353  ],
354  [
355  $next_id,
356  $this->getId(),
357  $key,
358  strlen($item->getAnswertext()) ? $item->getAnswertext() : '',
359  $item->getPoints(),
360  $item->getOrder(),
361  $gap->getType(),
362  ($gap->getShuffle()) ? '1' : '0'
363  ]
364  );
365  }
getPoints()
Gets the points.
getAnswertext()
Gets the answer text.
getShuffle()
Gets the shuffle state of the items.
getOrder()
Gets the sort/display order.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeTextGapRecordToDb()

assClozeTest::saveClozeTextGapRecordToDb ( int  $next_id,
int  $key,
assAnswerCloze  $item,
assClozeGap  $gap 
)
protected

Definition at line 305 of file class.assClozeTest.php.

References ASS_AnswerSimple\getAnswertext(), assClozeGap\getGapSize(), assQuestion\getId(), ASS_AnswerSimple\getOrder(), ASS_AnswerSimple\getPoints(), assClozeGap\getType(), and ILIAS\Repository\int().

Referenced by saveClozeGapItemsToDb().

310  : void {
311  $this->db->manipulateF(
312  'INSERT INTO qpl_a_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type, gap_size) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)',
313  [
314  'integer',
315  'integer',
316  'integer',
317  'text',
318  'float',
319  'integer',
320  'text',
321  'integer'
322  ],
323  [
324  $next_id,
325  $this->getId(),
326  $key,
327  strlen($item->getAnswertext()) ? $item->getAnswertext() : '',
328  $item->getPoints(),
329  $item->getOrder(),
330  $gap->getType(),
331  (int) $gap->getGapSize()
332  ]
333  );
334  }
getPoints()
Gets the points.
getAnswertext()
Gets the answer text.
getOrder()
Gets the sort/display order.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

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

Definition at line 246 of file class.assClozeTest.php.

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

246  : void
247  {
251 
252  parent::saveToDb();
253  }
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb(?int $original_id=null)
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
+ Here is the call graph for this function:

◆ saveWorkingData()

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

Definition at line 1063 of file class.assClozeTest.php.

References ilObjTest\_getPass(), fetchSolutionSubmit(), getGap(), assQuestion\getProcessLocker(), null, assQuestion\removeCurrentSolution(), assQuestion\saveCurrentSolution(), and assClozeGap\TYPE_SELECT.

1067  : bool {
1068  if (is_null($pass)) {
1069  $pass = ilObjTest::_getPass($active_id);
1070  }
1071 
1072  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
1073  function () use ($active_id, $pass, $authorized) {
1074  $this->removeCurrentSolution($active_id, $pass, $authorized);
1075 
1076  foreach ($this->fetchSolutionSubmit() as $key => $value) {
1077  if ($value === null || $value === '') {
1078  continue;
1079  }
1080  $gap = $this->getGap($key);
1081  if ($gap === null
1082  || $gap->getType() === assClozeGap::TYPE_SELECT && $value === -1) {
1083  continue;
1084  }
1085  $this->saveCurrentSolution($active_id, $pass, $key, $value, $authorized);
1086  }
1087  }
1088  );
1089 
1090  return true;
1091  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
getGap(int $gap_index=0)
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:

◆ setClozeText()

assClozeTest::setClozeText ( string  $cloze_text = '')

Definition at line 418 of file class.assClozeTest.php.

References cleanQuestiontext(), and createGapsFromQuestiontext().

Referenced by loadFromDb().

418  : void
419  {
420  $this->gaps = [];
421  $this->cloze_text = $this->cleanQuestiontext($cloze_text);
423  }
createGapsFromQuestiontext()
Create gap entries by parsing the question text.
cleanQuestiontext($text)
Cleans cloze question text to remove attributes or tags from older ILIAS versions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setClozeTextValue()

assClozeTest::setClozeTextValue (   $cloze_text = "")

Definition at line 425 of file class.assClozeTest.php.

References $cloze_text.

425  : void
426  {
427  $this->cloze_text = $cloze_text;
428  }

◆ setEndTag()

assClozeTest::setEndTag (   $end_tag = "[/gap]")

Sets the end tag of a cloze gap.

Parameters
string$end_tagThe end tag for a cloze gap public
See also
$end_tag

Definition at line 513 of file class.assClozeTest.php.

References $end_tag.

513  : void
514  {
515  $this->end_tag = $end_tag;
516  }

◆ setFeedbackMode()

assClozeTest::setFeedbackMode (   $feedbackMode)
Parameters
string$feedbackMode

Definition at line 529 of file class.assClozeTest.php.

References $feedbackMode.

Referenced by loadFromDb().

529  : void
530  {
531  $this->feedbackMode = $feedbackMode;
532  }
+ Here is the caller graph for this function:

◆ setFixedTextLength()

assClozeTest::setFixedTextLength ( ?int  $fixed_text_length)

Sets a fixed text length for all text fields in the cloze question.

Parameters
integer$a_text_lenThe text field length public

Definition at line 1187 of file class.assClozeTest.php.

References $fixed_text_length.

Referenced by loadFromDb().

1187  : void
1188  {
1189  $this->fixed_text_length = $fixed_text_length;
1190  }
+ Here is the caller graph for this function:

◆ setGapAnswerLowerBound()

assClozeTest::setGapAnswerLowerBound (   $gap_index,
  $order,
  $bound 
)

Sets the lower bound of a gap with a given index and an answer with a given order.

The index of the first gap is 0, the index of the second gap is 1 and so on.

Parameters
integer$gap_indexA nonnegative index of the n-th gap
integer$orderThe order of the answer text
string$answerThe lower bound of the answer public
See also
$gaps

Definition at line 712 of file class.assClozeTest.php.

712  : void
713  {
714  if (array_key_exists($gap_index, $this->gaps)) {
715  $this->gaps[$gap_index]->setItemLowerBound($order, $bound);
716  }
717  }

◆ setGapAnswerPoints()

assClozeTest::setGapAnswerPoints (   $gap_index,
  $order,
  $points 
)

Sets the points of a gap with a given index and an answer with a given order.

The index of the first gap is 0, the index of the second gap is 1 and so on.

Parameters
integer$gap_indexA nonnegative index of the n-th gap
integer$orderThe order of the answer text
string$answerThe points of the answer public
See also
$gaps

Definition at line 662 of file class.assClozeTest.php.

References assQuestion\$points.

662  : void
663  {
664  if (array_key_exists($gap_index, $this->gaps)) {
665  $this->gaps[$gap_index]->setItemPoints($order, $points);
666  }
667  }

◆ setGapAnswerUpperBound()

assClozeTest::setGapAnswerUpperBound (   $gap_index,
  $order,
  $bound 
)

Sets the upper bound of a gap with a given index and an answer with a given order.

The index of the first gap is 0, the index of the second gap is 1 and so on.

Parameters
integer$gap_indexA nonnegative index of the n-th gap
integer$orderThe order of the answer text
string$answerThe upper bound of the answer public
See also
$gaps

Definition at line 729 of file class.assClozeTest.php.

729  : void
730  {
731  if (array_key_exists($gap_index, $this->gaps)) {
732  $this->gaps[$gap_index]->setItemUpperBound($order, $bound);
733  }
734  }

◆ setGapCombinations()

assClozeTest::setGapCombinations (   $value)

Definition at line 1250 of file class.assClozeTest.php.

Referenced by loadFromDb().

1250  : void
1251  {
1252  $this->gap_combinations = $value;
1253  }
+ Here is the caller graph for this function:

◆ setGapCombinationsExists()

assClozeTest::setGapCombinationsExists (   $value)

Definition at line 1245 of file class.assClozeTest.php.

Referenced by loadFromDb().

1245  : void
1246  {
1247  $this->gap_combinations_exist = $value;
1248  }
+ Here is the caller graph for this function:

◆ setGapShuffle()

assClozeTest::setGapShuffle (   $gap_index = 0,
  $shuffle = 1 
)

Sets the shuffle state of a gap with a given index.

The index of the first gap is 0, the index of the second gap is 1 and so on.

Parameters
integer$indexA nonnegative index of the n-th gap
integer$shuffleTurn shuffle on (=1) or off (=0) public
See also
$gaps

Definition at line 580 of file class.assClozeTest.php.

References assQuestion\$shuffle.

580  : void
581  {
582  if (array_key_exists($gap_index, $this->gaps)) {
583  $this->gaps[$gap_index]->setShuffle($shuffle);
584  }
585  }

◆ setGapSize()

assClozeTest::setGapSize (   $gap_index,
  $size 
)

Definition at line 645 of file class.assClozeTest.php.

645  : void
646  {
647  if (array_key_exists($gap_index, $this->gaps)) {
648  $this->gaps[$gap_index]->setGapSize((int) $size);
649  }
650  }

◆ setGapType()

assClozeTest::setGapType (   $gap_index,
  $gap_type 
)

Set the type of a gap with a given index.

private

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

564  : void
565  {
566  if (array_key_exists($gap_index, $this->gaps)) {
567  $this->gaps[$gap_index]->setType($gap_type);
568  }
569  }

◆ setIdenticalScoring()

assClozeTest::setIdenticalScoring ( bool  $identical_scoring)

Sets the identical scoring option for cloze questions.

Parameters
boolean$a_identical_scoringThe identical scoring option for cloze questions
See also
$identical_scoring public

Definition at line 1160 of file class.assClozeTest.php.

References $identical_scoring.

Referenced by loadFromDb().

1160  : void
1161  {
1162  $this->identical_scoring = $identical_scoring;
1163  }
bool $identical_scoring
Defines the scoring for "identical solutions".
+ Here is the caller graph for this function:

◆ setStartTag()

assClozeTest::setStartTag (   $start_tag = "[gap]")

Sets the start tag of a cloze gap.

Parameters
string$start_tagThe start tag for a cloze gap public
See also
$start_tag

Definition at line 489 of file class.assClozeTest.php.

References $start_tag.

489  : void
490  {
491  $this->start_tag = $start_tag;
492  }

◆ setTextgapRating()

assClozeTest::setTextgapRating (   $a_textgap_rating)

Sets the rating option for text gaps.

Parameters
string$a_textgap_ratingThe rating option for text gaps
See also
$textgap_rating public

Definition at line 1123 of file class.assClozeTest.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 loadFromDb().

1123  : void
1124  {
1125  switch ($a_textgap_rating) {
1133  $this->textgap_rating = $a_textgap_rating;
1134  break;
1135  default:
1136  $this->textgap_rating = assClozeGap::TEXTGAP_RATING_CASEINSENSITIVE;
1137  break;
1138  }
1139  }
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()

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

Definition at line 1669 of file class.assClozeTest.php.

References getGaps(), and assClozeGap\TYPE_SELECT.

1672  : array {
1673  $parsed_solution = [];
1674  foreach ($this->getGaps() as $gap_index => $gap) {
1675  foreach ($solution_values as $solutionvalue) {
1676  if ($gap_index !== (int) $solutionvalue['value1']) {
1677  continue;
1678  }
1679 
1680  if ($gap->getType() === assClozeGap::TYPE_SELECT) {
1681  $parsed_solution[$gap_index + 1] = $gap->getItem($solutionvalue['value2'])->getAnswertext();
1682  continue;
1683  }
1684 
1685  $parsed_solution[$gap_index + 1] = $solutionvalue['value2'];
1686  }
1687  }
1688  return $parsed_solution;
1689  }
+ Here is the call graph for this function:

◆ solutionValuesToText()

assClozeTest::solutionValuesToText ( array  $solution_values)

Definition at line 1691 of file class.assClozeTest.php.

References getGaps(), ILIAS\Repository\lng(), and assClozeGap\TYPE_SELECT.

1691  : array
1692  {
1693  $parsed_solution = [];
1694  foreach ($this->getGaps() as $gap_index => $gap) {
1695  foreach ($solution_values as $solutionvalue) {
1696  if ($gap_index !== (int) $solutionvalue['value1']) {
1697  continue;
1698  }
1699 
1700  if ($gap->getType() === assClozeGap::TYPE_SELECT) {
1701  $parsed_solution[] = $this->lng->txt('gap') . ' ' . $gap_index + 1 . ': '
1702  . $gap->getItem($solutionvalue['value2'])->getAnswertext();
1703  continue;
1704  }
1705 
1706  $parsed_solution[] = $this->lng->txt('gap') . ' ' . $gap_index + 1 . ': '
1707  . $solutionvalue['value2'];
1708  }
1709  }
1710  return $parsed_solution;
1711  }
+ Here is the call graph for this function:

◆ toJSON()

assClozeTest::toJSON ( )

Returns a JSON representation of the question.

Implements ILIAS\TestQuestionPool\Questions\QuestionLMExportable.

Definition at line 1269 of file class.assClozeTest.php.

References $gaps, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getClozeText(), getGaps(), assQuestion\getId(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), assQuestion\getTitleForHTMLOutput(), assClozeGap\TYPE_NUMERIC, and assClozeGap\TYPE_TEXT.

1269  : string
1270  {
1271  $result = [
1272  'id' => $this->getId(),
1273  'type' => (string) $this->getQuestionType(),
1274  'title' => $this->getTitleForHTMLOutput(),
1275  'question' => $this->formatSAQuestion($this->getQuestion()),
1276  'clozetext' => $this->formatSAQuestion($this->getClozeText()),
1277  'nr_of_tries' => $this->getNrOfTries(),
1278  'shuffle' => $this->getShuffle(),
1279  'feedback' => [
1280  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1281  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1282  ]
1283  ];
1284 
1285  $gaps = [];
1286  foreach ($this->getGaps() as $key => $gap) {
1287  $items = [];
1288  foreach ($gap->getItems($this->getShuffler()) as $item) {
1289  $jitem = [];
1290  $jitem['points'] = $item->getPoints();
1291  $jitem['value'] = $this->formatSAQuestion($item->getAnswertext());
1292  $jitem['order'] = $item->getOrder();
1293  if ($gap->getType() == assClozeGap::TYPE_NUMERIC) {
1294  $jitem['lowerbound'] = $item->getLowerBound();
1295  $jitem['upperbound'] = $item->getUpperBound();
1296  } else {
1297  $jitem['value'] = trim($jitem['value']);
1298  }
1299  array_push($items, $jitem);
1300  }
1301 
1302  if ($gap->getGapSize() && ($gap->getType() == assClozeGap::TYPE_TEXT || $gap->getType() == assClozeGap::TYPE_NUMERIC)) {
1303  $jgap['size'] = $gap->getGapSize();
1304  }
1305 
1306  $jgap['shuffle'] = $gap->getShuffle();
1307  $jgap['type'] = $gap->getType();
1308  $jgap['item'] = $items;
1309 
1310  array_push($gaps, $jgap);
1311  }
1312  $result['gaps'] = $gaps;
1313  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1314  $result['mobs'] = $mobs;
1315  return json_encode($result);
1316  }
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="-")
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:

◆ toLog()

assClozeTest::toLog ( AdditionalInformationGenerator  $additional_info)

Implements ILIAS\TestQuestionPool\Questions\Question.

Definition at line 1625 of file class.assClozeTest.php.

References $gaps, assQuestion\formatSAQuestion(), getClozeText(), getGaps(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), assQuestion\getTitleForHTMLOutput(), ILIAS\Test\Logging\AdditionalInformationGenerator\getTrueFalseTagForBool(), and assClozeGap\TYPE_NUMERIC.

1625  : array
1626  {
1627  $result = [
1628  AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
1629  AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
1630  AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
1631  AdditionalInformationGenerator::KEY_QUESTION_CLOZE_CLOZETEXT => $this->formatSAQuestion($this->getClozeText()),
1632  AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS => $additional_info
1633  ->getTrueFalseTagForBool($this->getShuffle()),
1634  AdditionalInformationGenerator::KEY_FEEDBACK => [
1635  AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1636  AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1637  ]
1638  ];
1639 
1640  $gaps = [];
1641  foreach ($this->getGaps() as $gap_index => $gap) {
1642  $items = [];
1643  foreach ($gap->getItems($this->getShuffler()) as $item) {
1644  $item_array = [
1645  AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $item->getPoints(),
1646  AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION => $this->formatSAQuestion($item->getAnswertext()),
1647  AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION_ORDER => $item->getOrder()
1648  ];
1649  if ($gap->getType() === assClozeGap::TYPE_NUMERIC) {
1650  $item_array[AdditionalInformationGenerator::KEY_QUESTION_LOWER_LIMIT] = $item->getLowerBound();
1651  $item_array[AdditionalInformationGenerator::KEY_QUESTION_UPPER_LIMIT] = $item->getUpperBound();
1652  }
1653  array_push($items, $item_array);
1654  }
1655 
1656  $gap_array[AdditionalInformationGenerator::KEY_QUESTION_TEXTSIZE] = $gap->getGapSize();
1657  $gap_array[AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS] = $additional_info->getTrueFalseTagForBool(
1658  $gap->getShuffle()
1659  );
1660  $gap_array[AdditionalInformationGenerator::KEY_QUESTION_CLOZE_GAP_TYPE] = $gap->getType();
1661  $gap_array[AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTIONS] = $items;
1662 
1663  $gaps[$gap_index + 1] = $gap_array;
1664  }
1665  $result[AdditionalInformationGenerator::KEY_QUESTION_CLOZE_GAPS] = $gaps;
1666  return $result;
1667  }
getQuestionType()
Returns the question type of the question.
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:

◆ updateClozeTextFromGaps()

assClozeTest::updateClozeTextFromGaps ( )

Updates the gap parameters in the cloze text from the form input.

private

Definition at line 803 of file class.assClozeTest.php.

References getClozeText(), getGaps(), ilLegacyFormElementsUtil\prepareTextareaOutput(), and replaceFirstGap().

Referenced by deleteAnswerText().

803  : void
804  {
805  $output = $this->getClozeText();
806  foreach ($this->getGaps() as $gap_index => $gap) {
807  $answers = [];
808  foreach ($gap->getItemsRaw() as $item) {
809  array_push($answers, str_replace([',', '['], ["\\,", '[&hairsp;'], $item->getAnswerText()));
810  }
811  // fau: fixGapReplace - use replace function
812  $output = $this->replaceFirstGap($output, "[_gap]" . ilLegacyFormElementsUtil::prepareTextareaOutput(join(",", $answers), true) . "[/_gap]");
813  // fau.
814  }
815  $output = str_replace("_gap]", "gap]", $output);
816  $this->cloze_text = $output;
817  }
replaceFirstGap(string $gaptext, string $content)
getClozeText()
Returns the cloze text.
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $cloze_text

string assClozeTest::$cloze_text = ''
protected

Definition at line 77 of file class.assClozeTest.php.

Referenced by getClozeText(), and setClozeTextValue().

◆ $end_tag

string assClozeTest::$end_tag = '[/gap]'
private

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

Referenced by getEndTag(), and setEndTag().

◆ $feedbackMode

assClozeTest::$feedbackMode = ilAssClozeTestFeedback::FB_MODE_GAP_QUESTION
protected

Definition at line 79 of file class.assClozeTest.php.

Referenced by getFeedbackMode(), and setFeedbackMode().

◆ $feedbackOBJ

ilAssQuestionFeedback assClozeTest::$feedbackOBJ

Definition at line 78 of file class.assClozeTest.php.

◆ $fixed_text_length

int assClozeTest::$fixed_text_length = null
protected

Definition at line 76 of file class.assClozeTest.php.

Referenced by getFixedTextLength(), and setFixedTextLength().

◆ $gap_combinations

assClozeTest::$gap_combinations = []
protected

◆ $gap_combinations_exist

bool assClozeTest::$gap_combinations_exist = false
protected

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

Referenced by getGapCombinationsExists().

◆ $gaps

array assClozeTest::$gaps = []

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

Referenced by getGaps(), toJSON(), and toLog().

◆ $identical_scoring

bool assClozeTest::$identical_scoring = true
protected

Defines the scoring for "identical solutions".

If the learner selects the same solution twice or more in different gaps, only the first choice will be scored if identical_scoring is 0.

Definition at line 75 of file class.assClozeTest.php.

Referenced by getIdenticalScoring(), and setIdenticalScoring().

◆ $randomGroup

RandomGroup assClozeTest::$randomGroup
private

Definition at line 80 of file class.assClozeTest.php.

◆ $start_tag

string assClozeTest::$start_tag = '[gap]'
private

Definition at line 55 of file class.assClozeTest.php.

Referenced by getStartTag(), and setStartTag().

◆ $textgap_rating

string assClozeTest::$textgap_rating = assClozeGap::TEXTGAP_RATING_CASEINSENSITIVE

The rating option for text gaps.

This could contain one of the following options:

  • case insensitive text gaps
  • case sensitive text gaps
  • various levenshtein distances

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

Referenced by getTextgapRating().


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