ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
assClozeTest Class Reference

Class for cloze tests. More...

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

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assClozeTest constructor More...
 
 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 ($gaptext, $content)
 Replace the first gap in a string without treating backreferences. More...
 
 loadFromDb ($question_id)
 Loads a assClozeTest object from a database. More...
 
 saveToDb ($original_id="")
 Saves a assClozeTest object to a database. More...
 
 saveAnswerSpecificDataToDb ()
 Save all gaps to the database. More...
 
 saveAdditionalQuestionDataToDb ()
 Saves the data for the additional data table. More...
 
 getGaps ()
 Returns the array of gaps. More...
 
 flushGaps ()
 Deletes all gaps without changing the cloze text. More...
 
 setClozeText ($cloze_text="")
 Evaluates the text gap solutions from the cloze text. More...
 
 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 ($gap_index=0)
 Returns the gap at a given index. More...
 
 setGapSize ($gap_index, $order, $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...
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates an assClozeTest. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assClozeTest object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 copyGapCombination ($orgID, $newID)
 
 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 ($value)
 
 calculateReachedPoints ($active_id, $pass=null, $authorized=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 validateSolutionSubmit ()
 
 fetchSolutionSubmit ($submit)
 
 getSolutionSubmitValidation ()
 
 getSolutionSubmit ()
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 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 ($a_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 ()
 Returns the name of the answer table in the database. More...
 
 setFixedTextLength ($a_text_len)
 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)
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 {} More...
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. 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 $previewSession)
 
 fetchAnswerValueForGap ($userSolution, $gapIndex)
 
 isAddableAnswerOptionValue ($qIndex, $answerOptionValue)
 
 addAnswerOptionValue ($qIndex, $answerOptionValue, $points)
 
 savePartial ()
 
- Public Member Functions inherited from assQuestion
 getShuffler ()
 
 setShuffler (ilArrayElementShuffler $shuffler)
 
 setProcessLocker ($processLocker)
 
 getProcessLocker ()
 
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping, array $solutionhints=[])
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 isComplete ()
 Returns true, if a question is complete for use. More...
 
 questionTitleExists ($questionpool_id, $title)
 Returns TRUE if the question title exists in the database. More...
 
 setTitle ($title="")
 Sets the title string of the assQuestion object. More...
 
 setId ($id=-1)
 Sets the id of the assQuestion object. More...
 
 setTestId ($id=-1)
 Sets the test id of the assQuestion object. More...
 
 setComment ($comment="")
 Sets the comment string of the assQuestion object. More...
 
 setOutputType ($outputType=OUTPUT_HTML)
 Sets the output type. More...
 
 setShuffle ($shuffle=true)
 Sets the shuffle flag. More...
 
 setEstimatedWorkingTime ($hour=0, $min=0, $sec=0)
 Sets the estimated working time of a question from given hour, minute and second. More...
 
 setEstimatedWorkingTimeFromDurationString ($durationString)
 Sets the estimated working time of a question from a given datetime string. More...
 
 keyInArray ($searchkey, $array)
 returns TRUE if the key occurs in an array More...
 
 setAuthor ($author="")
 Sets the authors name of the assQuestion object. More...
 
 setOwner ($owner="")
 Sets the creator/owner ID of the assQuestion object. More...
 
 getTitle ()
 Gets the title string of the assQuestion object. More...
 
 getTitleFilenameCompliant ()
 returns the object title prepared to be used as a filename More...
 
 getId ()
 Gets the id of the assQuestion object. More...
 
 getShuffle ()
 Gets the shuffle flag. More...
 
 getTestId ()
 Gets the test id of the assQuestion object. More...
 
 getComment ()
 Gets the comment string of the assQuestion object. More...
 
 getOutputType ()
 Gets the output type. More...
 
 getDescriptionForHTMLOutput ()
 
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output. More...
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getEstimatedWorkingTime ()
 Gets the estimated working time of a question. More...
 
 getAuthor ()
 Gets the authors name of the assQuestion object. More...
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 Gets the creator/owner ID of the assQuestion object. More...
 
 getObjId ()
 Get the object id of the container object. More...
 
 setObjId ($obj_id=0)
 Set the object id of the container object. More...
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId ($external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 Return the suggested solutions. More...
 
 getReachedPoints ($active_id, $pass=null)
 Returns the points, a learner has reached answering the question This is the fast way to get the points directly from the database. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getAdjustedReachedPoints ($active_id, $pass=null, $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution ($active_id, $pass=null, $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState ($active_id, $pass=null, $obligationsEnabled=false, $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution. More...
 
 getJavaPath ()
 Returns the image path for web accessable images of a question. More...
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 buildImagePath ($questionId, $parentObjectId)
 
 getFlashPath ()
 Returns the image path for web accessable flash files of a question. More...
 
 getJavaPathWeb ()
 Returns the web image path for web accessable java applets of a question. More...
 
 getSuggestedSolutionPathWeb ()
 Returns the web path for a suggested solution. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getFlashPathWeb ()
 Returns the web image path for web accessable flash applications of a question. More...
 
 getTestOutputSolutions ($activeId, $pass)
 
 getUserSolutionPreferingIntermediate ($active_id, $pass=null)
 
 getSolutionValues ($active_id, $pass=null, $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse ($question_id="")
 Checks whether the question is in use or not. More...
 
 isClone ($question_id="")
 Checks whether the question is a clone of another question or not. More...
 
 pcArrayShuffle ($array)
 Shuffles the values of a given array. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 getTotalAnswers ()
 get total number of answers More...
 
 _getTotalAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 create page object of question More...
 
 copyPageOfQuestion ($a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 fixSvgToPng ($imageFilenameContainingString)
 
 fixUnavailableSkinImageSources ($html)
 
 loadFromDb ($question_id)
 Loads the question from the database. More...
 
 createNewQuestion ($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 ($original_id="")
 
 saveToDb ($original_id="")
 Saves the question to the database. More...
 
 setNewOriginalId ($newId)
 
 deleteSuggestedSolutions ()
 Deletes all suggestes solutions in the database. More...
 
 getSuggestedSolution ($subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle ($subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution ($solution_id="", $subquestion_index=0, $is_import=false)
 Sets a suggested solution for the question. More...
 
 _resolveInternalLink ($internal_link)
 
 _resolveIntLinks ($question_id)
 
 syncWithOriginal ()
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool ($question_id)
 Returns true if the question already exists in the database and is assigned to a question pool. More...
 
 getPoints ()
 Returns the maximum available points for the question. More...
 
 setPoints ($a_points)
 Sets the maximum available points for the question. More...
 
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 deductHintPointsFromReachedPoints (ilAssQuestionPreviewSession $previewSession, $reachedPoints)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=null)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output in tests. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addQTIMaterial (&$a_xml_writer, $a_material, $close_material_tag=true, $add_mobs=true)
 Creates a QTI material tag from a plain text or xhtml text. More...
 
 buildHashedImageFilename ($plain_image_filename, $unique=false)
 
 getQuestion ()
 Gets the question string of the question object. More...
 
 setQuestion ($question="")
 Sets the question string of the question object. More...
 
 getQuestionForHTMLOutput ()
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 Returns the question type of the question. More...
 
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table More...
 
getInstances ()
 Gets all instances of the question. More...
 
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id. More...
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getNrOfTries ()
 
 setNrOfTries ($a_nr_of_tries)
 
 setExportImagePath ($a_path)
 
 formatSAQuestion ($a_q)
 Format self assessment question. More...
 
 setPreventRteUsage ($a_val)
 Set prevent rte usage. More...
 
 getPreventRteUsage ()
 Get prevent rte usage. More...
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode ($a_selfassessmenteditingmode)
 Set Self-Assessment Editing Mode. More...
 
 getSelfAssessmentEditingMode ()
 Get Self-Assessment Editing Mode. More...
 
 setDefaultNrOfTries ($a_defaultnroftries)
 Set Default Nr of Tries. More...
 
 getDefaultNrOfTries ()
 Get Default Nr of Tries. More...
 
 syncSkillAssignments ($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId)
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not More...
 
 isAutosaveable ()
 
 getAdditionalContentEditingMode ()
 getter for additional content editing mode for this question More...
 
 setAdditionalContentEditingMode ($additinalContentEditingMode)
 setter for additional content editing mode for this question More...
 
 isAdditionalContentEditingModePageObject ()
 isser for additional "pageobject" content editing mode More...
 
 isValidAdditionalContentEditingMode ($additionalContentEditingMode)
 returns the fact wether the passed additional content mode is valid or not More...
 
 getValidAdditionalContentEditingModes ()
 getter for valid additional content editing modes More...
 
 addQuestionChangeListener (ilQuestionChangeListener $listener)
 
 getQuestionChangeListeners ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution ($active_id, $pass)
 
 removeCurrentSolution ($active_id, $pass, $authorized=true)
 
 saveCurrentSolution ($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
 
 updateCurrentSolution ($solutionId, $value1, $value2, $authorized=true)
 
 updateCurrentSolutionsAuthorization ($activeId, $pass, $authorized, $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
 intermediateSolutionExists ($active_id, $pass)
 
 authorizedSolutionExists ($active_id, $pass)
 
 authorizedOrIntermediateSolutionExists ($active_id, $pass)
 
 isAddableAnswerOptionValue ($qIndex, $answerOptionValue)
 
 addAnswerOptionValue ($qIndex, $answerOptionValue, $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions ($activeId, $pass)
 
 resetUsersAnswer ($activeId, $pass)
 
 removeResultRecord ($activeId, $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered ($obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 Get the test question configuration (initialised once) More...
 
 savePartial ()
 
 isInActiveTest ()
 
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 

Data Fields

 $gaps
 
 $gap_combinations
 
 $gap_combinations_exists
 
 $start_tag
 
 $end_tag
 
 $textgap_rating
 
 $identical_scoring
 
 $fixedTextLength
 
 $cloze_text
 
 $feedbackOBJ
 
- Data Fields inherited from assQuestion
const IMG_MIME_TYPE_JPG = 'image/jpeg'
 
const IMG_MIME_TYPE_PNG = 'image/png'
 
const IMG_MIME_TYPE_GIF = 'image/gif'
 
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 constant for additional content editing mode "default" More...
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 constant for additional content editing mode "pageobject" More...
 
 $feedbackOBJ = null
 
 $prevent_rte_usage = false
 
 $selfassessmenteditingmode = false
 
 $defaultnroftries = 0
 
 $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 ($gap, $key)
 Save all items belonging to one cloze gap to the db. More...
 
 saveClozeTextGapRecordToDb ($next_id, $key, $item, $gap)
 Saves a gap-item record. More...
 
 saveClozeSelectGapRecordToDb ($next_id, $key, $item, $gap)
 Saves a gap-item record. More...
 
 saveClozeNumericGapRecordToDb ($next_id, $key, $item, $gap)
 Saves a gap-item record. More...
 
 isValidNumericSubmitValue ($submittedValue)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 calculateReachedPointsForSolution ($user_result, &$detailed=null)
 
- Protected Member Functions inherited from assQuestion
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission ($postSubmissionFieldname)
 
 ensureCurrentTestPass ($active_id, $pass)
 
 lookupCurrentTestPass ($active_id, $pass)
 
 lookupTestId ($active_id)
 
 log ($active_id, $langVar)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID. More...
 
 onDuplicate ($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test) More...
 
 beforeSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 onCopy ($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId)
 Will be called when a question is copied (into another question pool) More...
 
 duplicateSuggestedSolutionFiles ($parent_id, $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles ($original_id)
 Syncs the files of a suggested solution if the question is synced. More...
 
 copySuggestedSolutionFiles ($source_questionpool_id, $source_question_id)
 
 ensureNonNegativePoints ($points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 
 duplicateSkillAssignments ($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet ($active_id, $pass, $authorized=true)
 Get a restulset for the current user solution for a this question by active_id and pass. More...
 
 removeSolutionRecordById ($solutionId)
 
 getSolutionRecordById ($solutionId)
 
 deleteDummySolutionRecord ($activeId, $passIndex)
 
 isDummySolutionRecord ($solutionRecord)
 
 deleteSolutionRecordByValues ($activeId, $passIndex, $authorized, $matchValues)
 
 duplicateIntermediateSolutionAuthorized ($activeId, $passIndex)
 
 forceExistingIntermediateSolution ($activeId, $passIndex, $considerDummyRecordCreation)
 
 buildTestPresentationConfig ()
 build basic test question configuration instance More...
 

Protected Attributes

 $feedbackMode = ilAssClozeTestFeedback::FB_MODE_GAP_QUESTION
 
- Protected Attributes inherited from assQuestion
 $id
 
 $title
 
 $comment
 
 $owner
 
 $author
 
 $question
 
 $points
 
 $est_working_time
 
 $shuffle
 
 $test_id
 
 $obj_id
 
 $ilias
 
 $tpl
 
 $lng
 
 $db
 
 $refinery
 
 $outputType = OUTPUT_JAVASCRIPT
 
 $suggested_solutions
 
 $original_id
 
 $page
 
 $external_id = ''
 
 $questionChangeListeners = array()
 
 $processLocker
 
 $step = null
 
 $lastChange
 
 $shuffler
 
 $testQuestionConfig
 
 $lifecycle
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled ($forcePassResultsUpdateEnabled)
 
static isForcePassResultUpdateEnabled ()
 
static isAllowedImageMimeType ($mimeType)
 
static fetchMimeTypeIdentifier ($contentTypeString)
 
static getAllowedFileExtensionsForMimeType ($mimeType)
 
static isAllowedImageFileExtension ($mimeType, $fileExtension)
 
static getAllowedImageMaterialFileExtensions ()
 
static _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
static _getQuestionInfo ($question_id)
 Returns question information from the database. More...
 
static _getSuggestedSolutionCount ($question_id)
 Returns the number of suggested solutions associated with a question. More...
 
static _getSuggestedSolutionOutput ($question_id)
 Returns the output of the suggested solution. More...
 
static _getReachedPoints ($active_id, $question_id, $pass=null)
 Returns the points, a learner has reached answering the question. More...
 
static _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place. More...
 
static logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
static getQuestionTypeFromDb ($question_id)
 get question type for question id More...
 
static _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
static _getTitle ($a_q_id)
 Returns the title of a question. More...
 
static _getQuestionText ($a_q_id)
 Returns question text. More...
 
static isFileAvailable ($file)
 
static _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
static _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
static saveOriginalId ($questionId, $originalId)
 
static resetOriginalId ($questionId)
 
static _getInternalLinkHref ($target="")
 
static _getOriginalId ($question_id)
 Returns the original id of a question. More...
 
static originalQuestionExists ($questionId)
 
static _instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id. More...
 
static _instantiateQuestion ($question_id)
 
static _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution. More...
 
static _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
static _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not. More...
 
static _isWorkedThrough ($active_id, $question_id, $pass=null)
 Returns true if the question was worked through in the given pass Worked through means that the user entered at least one value. More...
 
static _areAnswered ($a_user_id, $a_question_ids)
 Checks if an array of question ids is answered by an user or not. More...
 
static _setReachedPoints ($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static _needsManualScoring ($question_id)
 
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type. More...
 
static getGuiClassNameByQuestionType ($questionType)
 
static getObjectClassNameByQuestionType ($questionType)
 
static getFeedbackClassNameByQuestionType ($questionType)
 
static isCoreQuestionType ($questionType)
 
static includeCoreClass ($questionType, $withGuiClass)
 
static includePluginClass ($questionType, $withGuiClass)
 
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag. More...
 
static & _instanciateQuestionGUI ($question_id)
 Creates an instance of a question gui with a given question id. More...
 
static instantiateQuestionGUI ($a_question_id)
 Creates an instance of a question gui with a given question id. More...
 
static _questionExistsInTest ($question_id, $test_id)
 
static lookupParentObjId ($questionId)
 ilDBInterface $ilDB More...
 
static lookupOriginalParentObjId ($originalQuestionId)
 returns the parent object id for given original question id (should be a qpl id, but theoretically it can be a tst id, too) More...
 
static isObligationPossible ($questionId)
 returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration More...
 
static implodeKeyValues ($keyValues)
 
static explodeKeyValues ($keyValues)
 
static setResultGateway ($resultGateway)
 
static getResultGateway ()
 
static sumTimesInISO8601FormatH_i_s_Extended ($time1, $time2)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds ($time)
 
static missingResultRecordExists ($activeId, $pass, $questionIds)
 
static getQuestionsMissingResultRecord ($activeId, $pass, $questionIds)
 
static lookupResultRecordExist ($activeId, $questionId, $pass)
 
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords ($activeId, $pass, $questionId)
 returns the number of existing solution records for the given test active / pass and given question id More...
 
static getKeyValuesImplosionSeparator ()
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $allowedImageMaterialFileExtensionsByMimeType
 
static $forcePassResultsUpdateEnabled = 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 24 of file class.assClozeTest.php.

Constructor & Destructor Documentation

◆ __construct()

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

assClozeTest constructor

The constructor takes possible arguments an creates an instance of the assClozeTest object.

Parameters
string$titleA title string to describe the question
string$commentA comment string to describe the question
string$authorA string containing the name of the questions author
integer$ownerA numerical ID to identify the owner/creator
string$question
Returns

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

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

123  {
125  $this->start_tag = "[gap]";
126  $this->end_tag = "[/gap]";
127  $this->gaps = array();
128  $this->setQuestion($question); // @TODO: Should this be $question?? See setter for why this is not trivial.
129  $this->fixedTextLength = "";
130  $this->identical_scoring = 1;
131  $this->gap_combinations_exists = false;
132  $this->gap_combinations = array();
133  }
setQuestion($question="")
Sets the question string of the question object.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswerOptionValue()

assClozeTest::addAnswerOptionValue (   $qIndex,
  $answerOptionValue,
  $points 
)

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

References assQuestion\$points, and getGap().

2029  {
2030  $gap = $this->getGap($qIndex); /* @var assClozeGap $gap */
2031 
2032  $item = new assAnswerCloze($answerOptionValue, $points);
2033  $item->setOrder($gap->getItemCount());
2034 
2035  $gap->addItem($item);
2036  }
Class for cloze question numeric answers.
getGap($gap_index=0)
Returns the gap at a given index.
+ 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 762 of file class.assClozeTest.php.

References CLOZE_NUMERIC.

763  {
764  if (array_key_exists($gap_index, $this->gaps)) {
765  if ($this->gaps[$gap_index]->getType() == CLOZE_NUMERIC) {
766  // only allow notation with "." for real numbers
767  $answer = str_replace(",", ".", $answer);
768  }
769  $this->gaps[$gap_index]->addItem(new assAnswerCloze(trim($answer), 0, $order));
770  }
771  }
Class for cloze question numeric answers.
const CLOZE_NUMERIC

◆ 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 843 of file class.assClozeTest.php.

References $index.

844  {
845  $this->gaps[$index] = $gap;
846  }
$index
Definition: metadata.php:128

◆ 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 822 of file class.assClozeTest.php.

823  {
824  if (array_key_exists($gap_index, $this->gaps)) {
825  include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
826  $answer = new assAnswerCloze(
827  "",
828  0,
829  $this->gaps[$gap_index]->getItemCount()
830  );
831  $this->gaps[$gap_index]->addItem($answer);
832  }
833  }
Class for cloze question numeric answers.

◆ calculateCombinationResult()

assClozeTest::calculateCombinationResult (   $user_result)

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

References assQuestion\$points, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, assQuestion\getId(), getNumericgapPoints(), and getTextgapPoints().

Referenced by calculateReachedPointsForSolution().

1815  {
1816  $points = 0;
1817 
1818  $assClozeGapCombinationObj = new assClozeGapCombination();
1819 
1820  if ($assClozeGapCombinationObj->combinationExistsForQid($this->getId())) {
1821  $combinations_for_question = $assClozeGapCombinationObj->getCleanCombinationArray($this->getId());
1822  $gap_answers = array();
1823  $gap_used_in_combination = array();
1824  foreach ($user_result as $user_result_build_list) {
1825  if (is_array($user_result_build_list)) {
1826  $gap_answers[$user_result_build_list['gap_id']] = $user_result_build_list['value'];
1827  }
1828  }
1829 
1830  foreach ($combinations_for_question as $combination) {
1831  foreach ($combination as $row_key => $row_answers) {
1832  $combination_fulfilled = true;
1833  $points_for_combination = $row_answers['points'];
1834  foreach ($row_answers as $gap_key => $combination_gap_answer) {
1835  if ($gap_key !== 'points') {
1836  $gap_used_in_combination[$gap_key] = $gap_key;
1837  }
1838  if ($combination_fulfilled && array_key_exists($gap_key, $gap_answers)) {
1839  switch ($combination_gap_answer['type']) {
1840  case CLOZE_TEXT:
1841  $is_text_gap_correct = $this->getTextgapPoints($gap_answers[$gap_key], $combination_gap_answer['answer'], 1);
1842  if ($is_text_gap_correct != 1) {
1843  $combination_fulfilled = false;
1844  }
1845  break;
1846  case CLOZE_SELECT:
1847  $answer = $this->gaps[$gap_key]->getItem($gap_answers[$gap_key]);
1848  $answertext = $answer->getAnswertext();
1849  if ($answertext != $combination_gap_answer['answer']) {
1850  $combination_fulfilled = false;
1851  }
1852  break;
1853  case CLOZE_NUMERIC:
1854  $answer = $this->gaps[$gap_key]->getItem(0);
1855  if ($combination_gap_answer['answer'] != 'out_of_bound') {
1856  $is_numeric_gap_correct = $this->getNumericgapPoints($answer->getAnswertext(), $gap_answers[$gap_key], 1, $answer->getLowerBound(), $answer->getUpperBound());
1857  if ($is_numeric_gap_correct != 1) {
1858  $combination_fulfilled = false;
1859  }
1860  } else {
1861  $wrong_is_the_new_right = $this->getNumericgapPoints($answer->getAnswertext(), $gap_answers[$gap_key], 1, $answer->getLowerBound(), $answer->getUpperBound());
1862  if ($wrong_is_the_new_right == 1) {
1863  $combination_fulfilled = false;
1864  }
1865  }
1866  break;
1867  }
1868  } else {
1869  if ($gap_key !== 'points') {
1870  $combination_fulfilled = false;
1871  }
1872  }
1873  }
1874  if ($combination_fulfilled) {
1875  $points += $points_for_combination;
1876  }
1877  }
1878  }
1879  }
1880  return array($points, $gap_used_in_combination);
1881  }
getId()
Gets the id of the assQuestion object.
const CLOZE_TEXT
Cloze question constants.
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...
const CLOZE_SELECT
const CLOZE_NUMERIC
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPoints()

assClozeTest::calculateReachedPoints (   $active_id,
  $pass = null,
  $authorized = true,
  $returndetails = false 
)

Returns the points, a learner has reached answering the question.

The points are calculated from the given answers.

public

Parameters
integer$active_id
integer$pass
boolean$returndetails(deprecated !!)
Returns
integer/array $points/$details (array $details is deprecated !!)

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

References $data, $DIC, $ilDB, $pass, $result, calculateReachedPointsForSolution(), assQuestion\getCurrentSolutionResultSet(), and assQuestion\getSolutionMaxPass().

Referenced by getExpressionTypes().

1267  {
1268  global $DIC;
1269  $ilDB = $DIC['ilDB'];
1270 
1271  if (is_null($pass)) {
1272  $pass = $this->getSolutionMaxPass($active_id);
1273  }
1274 
1275  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized);
1276  $user_result = array();
1277  while ($data = $ilDB->fetchAssoc($result)) {
1278  if (strcmp($data["value2"], "") != 0) {
1279  $user_result[$data["value1"]] = array(
1280  "gap_id" => $data["value1"],
1281  "value" => $data["value2"]
1282  );
1283  }
1284  }
1285 
1286  ksort($user_result); // this is required when identical scoring for same solutions is disabled
1287 
1288  if ($returndetails) {
1289  $detailed = array();
1290  $this->calculateReachedPointsForSolution($user_result, $detailed);
1291  return $detailed;
1292  }
1293 
1294  return $this->calculateReachedPointsForSolution($user_result);
1295  }
$data
Definition: storeScorm.php:23
$result
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
global $DIC
Definition: goto.php:24
global $ilDB
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
calculateReachedPointsForSolution($user_result, &$detailed=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsForSolution()

assClozeTest::calculateReachedPointsForSolution (   $user_result,
$detailed = null 
)
protected
Parameters
$user_result
$detailed
Returns
array

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

References assQuestion\$points, calculateCombinationResult(), CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, getIdenticalScoring(), getMaximumGapPoints(), getNumericgapPoints(), and getTextgapPoints().

Referenced by calculateReachedPoints(), and calculateReachedPointsFromPreviewSession().

1888  {
1889  if ($detailed === null) {
1890  $detailed = array();
1891  }
1892 
1893  $assClozeGapCombinationObj = new assClozeGapCombination();
1894  $combinations[1] = array();
1895  if ($assClozeGapCombinationObj->combinationExistsForQid($this->getId())) {
1896  $combinations = $this->calculateCombinationResult($user_result);
1897  $points = $combinations[0];
1898  }
1899  $counter = 0;
1900  $solution_values_text = array(); // for identical scoring checks
1901  $solution_values_select = array(); // for identical scoring checks
1902  $solution_values_numeric = array(); // for identical scoring checks
1903  foreach ($user_result as $gap_id => $value) {
1904  if (is_string($value)) {
1905  $value = array("value" => $value);
1906  }
1907 
1908  if (array_key_exists($gap_id, $this->gaps) && !array_key_exists($gap_id, $combinations[1])) {
1909  switch ($this->gaps[$gap_id]->getType()) {
1910  case CLOZE_TEXT:
1911  $gappoints = 0;
1912  for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++) {
1913  $answer = $this->gaps[$gap_id]->getItem($order);
1914  $gotpoints = $this->getTextgapPoints($answer->getAnswertext(), $value["value"], $answer->getPoints());
1915  if ($gotpoints > $gappoints) {
1916  $gappoints = $gotpoints;
1917  }
1918  }
1919  if (!$this->getIdenticalScoring()) {
1920  // check if the same solution text was already entered
1921  if ((in_array($value["value"], $solution_values_text)) && ($gappoints > 0)) {
1922  $gappoints = 0;
1923  }
1924  }
1925  $points += $gappoints;
1926  $detailed[$gap_id] = array("points" => $gappoints, "best" => ($this->getMaximumGapPoints($gap_id) == $gappoints) ? true : false, "positive" => ($gappoints > 0) ? true : false);
1927  array_push($solution_values_text, $value["value"]);
1928  break;
1929  case CLOZE_NUMERIC:
1930  $gappoints = 0;
1931  for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++) {
1932  $answer = $this->gaps[$gap_id]->getItem($order);
1933  $gotpoints = $this->getNumericgapPoints($answer->getAnswertext(), $value["value"], $answer->getPoints(), $answer->getLowerBound(), $answer->getUpperBound());
1934  if ($gotpoints > $gappoints) {
1935  $gappoints = $gotpoints;
1936  }
1937  }
1938  if (!$this->getIdenticalScoring()) {
1939  // check if the same solution value was already entered
1940  include_once "./Services/Math/classes/class.EvalMath.php";
1941  $eval = new EvalMath();
1942  $eval->suppress_errors = true;
1943  $found_value = false;
1944  foreach ($solution_values_numeric as $solval) {
1945  if ($eval->e($solval) == $eval->e($value["value"])) {
1946  $found_value = true;
1947  }
1948  }
1949  if ($found_value && ($gappoints > 0)) {
1950  $gappoints = 0;
1951  }
1952  }
1953  $points += $gappoints;
1954  $detailed[$gap_id] = array("points" => $gappoints, "best" => ($this->getMaximumGapPoints($gap_id) == $gappoints) ? true : false, "positive" => ($gappoints > 0) ? true : false);
1955  array_push($solution_values_numeric, $value["value"]);
1956  break;
1957  case CLOZE_SELECT:
1958  if ($value["value"] >= 0) {
1959  for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++) {
1960  $answer = $this->gaps[$gap_id]->getItem($order);
1961  if ($value["value"] == $answer->getOrder()) {
1962  $answerpoints = $answer->getPoints();
1963  if (!$this->getIdenticalScoring()) {
1964  // check if the same solution value was already entered
1965  if ((in_array($answer->getAnswertext(), $solution_values_select)) && ($answerpoints > 0)) {
1966  $answerpoints = 0;
1967  }
1968  }
1969  $points += $answerpoints;
1970  $detailed[$gap_id] = array("points" => $answerpoints, "best" => ($this->getMaximumGapPoints($gap_id) == $answerpoints) ? true : false, "positive" => ($answerpoints > 0) ? true : false);
1971  array_push($solution_values_select, $answer->getAnswertext());
1972  }
1973  }
1974  }
1975  break;
1976  }
1977  }
1978  }
1979 
1980  return $points;
1981  }
getMaximumGapPoints($gap_index)
Returns the maximum points for a gap.
const CLOZE_TEXT
Cloze question constants.
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...
const CLOZE_SELECT
const CLOZE_NUMERIC
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  $previewSession)

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

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

1984  {
1985  $userSolution = array();
1986 
1987  foreach ($previewSession->getParticipantsSolution() as $key => $val) {
1988  $userSolution[$key] = array('gap_id' => $key, 'value' => $val);
1989  }
1990 
1991  $reachedPoints = $this->calculateReachedPointsForSolution($userSolution);
1992  $reachedPoints = $this->deductHintPointsFromReachedPoints($previewSession, $reachedPoints);
1993 
1994  return $this->ensureNonNegativePoints($reachedPoints);
1995  }
ensureNonNegativePoints($points)
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
calculateReachedPointsForSolution($user_result, &$detailed=null)
+ Here is the call graph for this function:

◆ checkForValidFormula()

assClozeTest::checkForValidFormula (   $value)
Parameters
$value
Returns
int

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

1253  {
1254  return preg_match("/^-?(\\d*)(,|\\.|\\/){0,1}(\\d*)$/", $value, $matches);
1255  }

◆ 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 159 of file class.assClozeTest.php.

Referenced by loadFromDb(), and setClozeText().

160  {
161  // fau: fixGapReplace - mask dollars for replacement
162  $text = str_replace('$', 'GAPMASKEDDOLLAR', $text);
163  $text = preg_replace("/\[gap[^\]]*?\]/", "[gap]", $text);
164  $text = preg_replace("/<gap([^>]*?)>/", "[gap]", $text);
165  $text = str_replace("</gap>", "[/gap]", $text);
166  $text = str_replace('GAPMASKEDDOLLAR', '$', $text);
167  // fau.
168  return $text;
169  }
+ Here is the caller graph for this function:

◆ clearGapAnswers()

assClozeTest::clearGapAnswers ( )

Removes all answers from the gaps.

public

See also
$gaps

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

730  {
731  foreach ($this->gaps as $gap_index => $gap) {
732  $this->gaps[$gap_index]->clearItems();
733  }
734  }

◆ copyGapCombination()

assClozeTest::copyGapCombination (   $orgID,
  $newID 
)

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

Referenced by copyObject(), createNewOriginalFromThisDuplicate(), and duplicate().

1066  {
1067  $assClozeGapCombinationObj = new assClozeGapCombination();
1068  $array = $assClozeGapCombinationObj->loadFromDb($orgID);
1069  $assClozeGapCombinationObj->importGapCombinationToDb($newID, $array);
1070  }
+ Here is the caller graph for this function:

◆ copyObject()

assClozeTest::copyObject (   $target_questionpool_id,
  $title = "" 
)

Copies an assClozeTest object.

public

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

References assQuestion\$original_id, assQuestion\$title, assQuestion\_getOriginalId(), copyGapCombination(), assQuestion\getId(), and assQuestion\getObjId().

992  {
993  if ($this->getId() <= 0) {
994  // The question has not been saved. It cannot be duplicated
995  return;
996  }
997 
998  $thisId = $this->getId();
999  $thisObjId = $this->getObjId();
1000 
1001  $clone = $this;
1002  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
1004  $clone->id = -1;
1005  $clone->setObjId($target_questionpool_id);
1006  if ($title) {
1007  $clone->setTitle($title);
1008  }
1009 
1010  $clone->saveToDb();
1011 
1012  if ($this->gap_combinations_exists) {
1013  $this->copyGapCombination($original_id, $clone->getId());
1014  $clone->saveToDb();
1015  }
1016 
1017  // copy question page content
1018  $clone->copyPageOfQuestion($original_id);
1019  // copy XHTML media objects
1020  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
1021 
1022  $clone->onCopy($thisObjId, $thisId, $clone->getObjId(), $clone->getId());
1023 
1024  return $clone->getId();
1025  }
getId()
Gets the id of the assQuestion object.
static _getOriginalId($question_id)
Returns the original id of a question.
copyGapCombination($orgID, $newID)
getObjId()
Get the object id of the container object.
+ 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 674 of file class.assClozeTest.php.

References CLOZE_TEXT, and getClozeText().

Referenced by setClozeText().

675  {
676  include_once "./Modules/TestQuestionPool/classes/class.assClozeGap.php";
677  include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
678  $search_pattern = "|\[gap\](.*?)\[/gap\]|i";
679  preg_match_all($search_pattern, $this->getClozeText(), $found);
680  $this->gaps = array();
681  if (count($found[0])) {
682  foreach ($found[1] as $gap_index => $answers) {
683  // create text gaps by default
684  $gap = new assClozeGap(CLOZE_TEXT);
685  $textparams = preg_split("/(?<!\\\\),/", $answers);
686  foreach ($textparams as $key => $value) {
687  $answer = new assAnswerCloze($value, 0, $key);
688  $gap->addItem($answer);
689  }
690  $this->gaps[$gap_index] = $gap;
691  }
692  }
693  }
Class for cloze question numeric answers.
const CLOZE_TEXT
Cloze question constants.
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:

◆ createNewOriginalFromThisDuplicate()

assClozeTest::createNewOriginalFromThisDuplicate (   $targetParentId,
  $targetQuestionTitle = "" 
)

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

References assQuestion\$id, copyGapCombination(), and assQuestion\getObjId().

1028  {
1029  if ($this->id <= 0) {
1030  // The question has not been saved. It cannot be duplicated
1031  return;
1032  }
1033 
1034  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
1035 
1036  $sourceQuestionId = $this->id;
1037  $sourceParentId = $this->getObjId();
1038 
1039  // duplicate the question in database
1040  $clone = $this;
1041  $clone->id = -1;
1042 
1043  $clone->setObjId($targetParentId);
1044 
1045  if ($targetQuestionTitle) {
1046  $clone->setTitle($targetQuestionTitle);
1047  }
1048 
1049  $clone->saveToDb();
1050 
1051  if ($this->gap_combinations_exists) {
1052  $this->copyGapCombination($sourceQuestionId, $clone->getId());
1053  $clone->saveToDb();
1054  }
1055  // copy question page content
1056  $clone->copyPageOfQuestion($sourceQuestionId);
1057  // copy XHTML media objects
1058  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
1059 
1060  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
1061 
1062  return $clone->id;
1063  }
copyGapCombination($orgID, $newID)
getObjId()
Get the object id of the container object.
+ Here is the call 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 1102 of file class.assClozeTest.php.

References deleteGap(), and updateClozeTextFromGaps().

1103  {
1104  if (array_key_exists($gap_index, $this->gaps)) {
1105  if ($this->gaps[$gap_index]->getItemCount() == 1) {
1106  // this is the last answer text => remove the gap
1107  $this->deleteGap($gap_index);
1108  } else {
1109  // remove the answer text
1110  $this->gaps[$gap_index]->deleteItem($answer_index);
1111  $this->updateClozeTextFromGaps();
1112  }
1113  }
1114  }
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 1124 of file class.assClozeTest.php.

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

Referenced by deleteAnswerText().

1125  {
1126  if (array_key_exists($gap_index, $this->gaps)) {
1127  $output = $this->getClozeText();
1128  foreach ($this->getGaps() as $replace_gap_index => $gap) {
1129  $answers = array();
1130  foreach ($gap->getItemsRaw() as $item) {
1131  array_push($answers, str_replace(",", "\\,", $item->getAnswerText()));
1132  }
1133  if ($replace_gap_index == $gap_index) {
1134  // fau: fixGapReplace - use replace function
1135  $output = $this->replaceFirstGap($output, '');
1136  // fau.
1137  } else {
1138  // fau: fixGapReplace - use replace function
1139  $output = $this->replaceFirstGap($output, "[_gap]" . join(",", $answers) . "[/_gap]");
1140  // fau.
1141  }
1142  }
1143  $output = str_replace("_gap]", "gap]", $output);
1144  $this->cloze_text = $output;
1145  unset($this->gaps[$gap_index]);
1146  $this->gaps = array_values($this->gaps);
1147  }
1148  }
getGaps()
Returns the array of gaps.
replaceFirstGap($gaptext, $content)
Replace the first gap in a string without treating backreferences.
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duplicate()

assClozeTest::duplicate (   $for_test = true,
  $title = "",
  $author = "",
  $owner = "",
  $testObjId = null 
)

Duplicates an assClozeTest.

public

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

References assQuestion\$author, assQuestion\$original_id, assQuestion\$owner, assQuestion\$title, assQuestion\_getOriginalId(), copyGapCombination(), assQuestion\getId(), and assQuestion\getObjId().

936  {
937  if ($this->id <= 0) {
938  // The question has not been saved. It cannot be duplicated
939  return;
940  }
941  // duplicate the question in database
942  $this_id = $this->getId();
943  $thisObjId = $this->getObjId();
944 
945  $clone = $this;
946  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
948  $clone->id = -1;
949 
950  if ((int) $testObjId > 0) {
951  $clone->setObjId($testObjId);
952  }
953 
954  if ($title) {
955  $clone->setTitle($title);
956  }
957  if ($author) {
958  $clone->setAuthor($author);
959  }
960  if ($owner) {
961  $clone->setOwner($owner);
962  }
963  if ($for_test) {
964  $clone->saveToDb($original_id);
965  } else {
966  $clone->saveToDb();
967  }
968  if ($this->gap_combinations_exists) {
969  $this->copyGapCombination($this_id, $clone->getId());
970  }
971  if ($for_test) {
972  $clone->saveToDb($original_id);
973  } else {
974  $clone->saveToDb();
975  }
976  // copy question page content
977  $clone->copyPageOfQuestion($this_id);
978  // copy XHTML media objects
979  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
980 
981  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
982 
983  return $clone->getId();
984  }
getId()
Gets the id of the assQuestion object.
static _getOriginalId($question_id)
Returns the original id of a question.
copyGapCombination($orgID, $newID)
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ fetchAnswerValueForGap()

assClozeTest::fetchAnswerValueForGap (   $userSolution,
  $gapIndex 
)

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

1998  {
1999  $answerValue = '';
2000 
2001  foreach ($userSolution as $value1 => $value2) {
2002  if ($value1 == $gapIndex) {
2003  $answerValue = $value2;
2004  break;
2005  }
2006  }
2007 
2008  return $answerValue;
2009  }

◆ fetchSolutionSubmit()

assClozeTest::fetchSolutionSubmit (   $submit)

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

References CLOZE_NUMERIC, CLOZE_SELECT, and getGap().

Referenced by getSolutionSubmit().

1329  {
1330  $solutionSubmit = array();
1331  foreach ($submit as $key => $value) {
1332  if ($value === null || is_array($value)) {
1333  continue;
1334  }
1335 
1336  $trimmed_value = trim($value);
1337  if ($trimmed_value === '') {
1338  continue;
1339  }
1340 
1341  if (preg_match("/^gap_(\d+)/", $key, $matches)) {
1342  $gap = $this->getGap($matches[1]);
1343  if (!is_object($gap)
1344  || $gap->getType() == CLOZE_SELECT && $trimmed_value == -1) {
1345  continue;
1346  }
1347 
1348  if ($gap->getType() == CLOZE_NUMERIC && !is_numeric(str_replace(",", ".", $trimmed_value))) {
1349  $trimmed_value = null;
1350  } elseif ($gap->getType() == CLOZE_NUMERIC) {
1351  $trimmed_value = str_replace(",", ".", $trimmed_value);
1352  }
1353  $solutionSubmit[trim($matches[1])] = $trimmed_value;
1354  }
1355  }
1356 
1357  return $solutionSubmit;
1358  }
getGap($gap_index=0)
Returns the gap at a given index.
const CLOZE_SELECT
const CLOZE_NUMERIC
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flushGaps()

assClozeTest::flushGaps ( )

Deletes all gaps without changing the cloze text.

public

See also
$gaps

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

539  {
540  $this->gaps = array();
541  }

◆ 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 1518 of file class.assClozeTest.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

1519  {
1520  return "qpl_qst_cloze";
1521  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assClozeTest::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name public

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

1530  {
1531  return array("qpl_a_cloze",'qpl_a_cloze_combi_res');
1532  }

◆ 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

Implements iQuestionCondition.

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

References $index, getGap(), and getGaps().

1806  {
1807  if ($index !== null) {
1808  return $this->getGap($index);
1809  } else {
1810  return $this->getGaps();
1811  }
1812  }
getGap($gap_index=0)
Returns the gap at a given index.
$index
Definition: metadata.php:128
getGaps()
Returns the array of gaps.
+ 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 571 of file class.assClozeTest.php.

References $cloze_text.

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

572  {
573  return $this->cloze_text;
574  }
+ 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 584 of file class.assClozeTest.php.

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

584  : string
585  {
586  $gaps = [];
587  preg_match_all('/\[gap\].*?\[\/gap\]/', $this->getClozeText(), $gaps);
588  $string_with_replaced_gaps = str_replace($gaps[0], '######GAP######', $this->getClozeText());
589  $cleaned_text = $this->getHtmlQuestionContentPurifier()->purify(
590  $string_with_replaced_gaps
591  );
592  $cleaned_text_with_gaps = preg_replace_callback('/######GAP######/', function ($match) use (&$gaps) {
593  return array_shift($gaps[0]);
594  }, $cleaned_text);
595 
597  || !(new ilSetting('advanced_editing'))->get('advanced_editing_javascript_editor') === 'tinymce') {
598  $cleaned_text_with_gaps = nl2br($cleaned_text_with_gaps);
599  }
600 
601  return $this->prepareTextareaOutput($cleaned_text_with_gaps, true);
602  }
isAdditionalContentEditingModePageObject()
isser for additional "pageobject" content editing mode
prepareTextareaOutput($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output in tests.
getClozeText()
Returns the cloze text.
+ 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 635 of file class.assClozeTest.php.

References $end_tag.

636  {
637  return $this->end_tag;
638  }

◆ getExpressionTypes()

assClozeTest::getExpressionTypes ( )

Get all available expression types for a specific question.

Returns
array

Implements iQuestionCondition.

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

References $data, $DIC, $ilDB, $pass, assQuestion\$points, $result, calculateReachedPoints(), iQuestionCondition\EmptyAnswerExpression, assQuestion\getId(), getMaximumPoints(), iQuestionCondition\getUserQuestionResult(), iQuestionCondition\NumberOfResultExpression, iQuestionCondition\NumericResultExpression, iQuestionCondition\PercentageResultExpression, and iQuestionCondition\StringResultExpression.

+ Here is the call graph for this function:

◆ getFeedbackMode()

assClozeTest::getFeedbackMode ( )
Returns
string

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

References $feedbackMode.

Referenced by saveAdditionalQuestionDataToDb().

656  {
657  return $this->feedbackMode;
658  }
+ 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 1551 of file class.assClozeTest.php.

References $fixedTextLength.

Referenced by saveAdditionalQuestionDataToDb().

1552  {
1553  return $this->fixedTextLength;
1554  }
+ Here is the caller graph for this function:

◆ getGap()

assClozeTest::getGap (   $gap_index = 0)

Returns the gap at a given index.

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

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

Referenced by addAnswerOptionValue(), fetchSolutionSubmit(), getAvailableAnswerOptions(), getSolutionSubmitValidation(), isAddableAnswerOptionValue(), saveWorkingData(), and validateSolutionSubmit().

782  {
783  if (array_key_exists($gap_index, $this->gaps)) {
784  return $this->gaps[$gap_index];
785  } else {
786  return null;
787  }
788  }
+ Here is the caller graph for this function:

◆ getGapCombinations()

assClozeTest::getGapCombinations ( )

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

References $gap_combinations.

1594  {
1595  return $this->gap_combinations;
1596  }

◆ getGapCombinationsExists()

assClozeTest::getGapCombinationsExists ( )

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

References $gap_combinations_exists.

1589  {
1591  }

◆ getGapCount()

assClozeTest::getGapCount ( )

Returns the number of gaps.

Returns
integer The number of gaps public
See also
$gaps

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

744  {
745  if (is_array($this->gaps)) {
746  return count($this->gaps);
747  } else {
748  return 0;
749  }
750  }

◆ getGaps()

assClozeTest::getGaps ( )

Returns the array of gaps.

Returns
array Array containing the gap objects of the cloze question gaps public

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

References $gaps.

Referenced by deleteGap(), getAvailableAnswerOptions(), isComplete(), setExportDetailsXLS(), toJSON(), and updateClozeTextFromGaps().

527  {
528  return $this->gaps;
529  }
+ 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 User interface

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

Referenced by calculateReachedPointsForSolution(), and saveAdditionalQuestionDataToDb().

1496  {
1497  return ($this->identical_scoring) ? 1 : 0;
1498  }
+ 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 1564 of file class.assClozeTest.php.

References assQuestion\$points.

Referenced by calculateReachedPointsForSolution().

1565  {
1566  $points = 0;
1567  $gap_max_points = 0;
1568  if (array_key_exists($gap_index, $this->gaps)) {
1569  $gap = &$this->gaps[$gap_index];
1570  foreach ($gap->getItems($this->getShuffler()) as $answer) {
1571  if ($answer->getPoints() > $gap_max_points) {
1572  $gap_max_points = $answer->getPoints();
1573  }
1574  }
1575  $points += $gap_max_points;
1576  }
1577  return $points;
1578  }
+ 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 888 of file class.assClozeTest.php.

References assQuestion\$points, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, and assQuestion\getId().

Referenced by getExpressionTypes(), and isComplete().

889  {
890  $assClozeGapCombinationObj = new assClozeGapCombination();
891  $points = 0;
892  $gaps_used_in_combination = array();
893  if ($assClozeGapCombinationObj->combinationExistsForQid($this->getId())) {
894  $points = $assClozeGapCombinationObj->getMaxPointsForCombination($this->getId());
895  $gaps_used_in_combination = $assClozeGapCombinationObj->getGapsWhichAreUsedInCombination($this->getId());
896  }
897  foreach ($this->gaps as $gap_index => $gap) {
898  if (!array_key_exists($gap_index, $gaps_used_in_combination)) {
899  if ($gap->getType() == CLOZE_TEXT) {
900  $gap_max_points = 0;
901  foreach ($gap->getItems($this->getShuffler()) as $item) {
902  if ($item->getPoints() > $gap_max_points) {
903  $gap_max_points = $item->getPoints();
904  }
905  }
906  $points += $gap_max_points;
907  } elseif ($gap->getType() == CLOZE_SELECT) {
908  $srpoints = 0;
909  foreach ($gap->getItems($this->getShuffler()) as $item) {
910  if ($item->getPoints() > $srpoints) {
911  $srpoints = $item->getPoints();
912  }
913  }
914  $points += $srpoints;
915  } elseif ($gap->getType() == CLOZE_NUMERIC) {
916  $numpoints = 0;
917  foreach ($gap->getItems($this->getShuffler()) as $item) {
918  if ($item->getPoints() > $numpoints) {
919  $numpoints = $item->getPoints();
920  }
921  }
922  $points += $numpoints;
923  }
924  }
925  }
926 
927  return $points;
928  }
getId()
Gets the id of the assQuestion object.
const CLOZE_TEXT
Cloze question constants.
const CLOZE_SELECT
const CLOZE_NUMERIC
+ 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
integer$max_pointsThe maximum number of points for the solution public

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

References $result.

Referenced by calculateCombinationResult(), and calculateReachedPointsForSolution().

1213  {
1214  // fau: fixGapFormula - check entered value by evalMath
1215  // if( ! $this->checkForValidFormula($a_entered) )
1216  // {
1217  // return 0;
1218  // }
1219 
1220  include_once "./Services/Math/classes/class.EvalMath.php";
1221  $eval = new EvalMath();
1222  $eval->suppress_errors = true;
1223  $result = 0;
1224 
1225  if ($eval->e($a_entered) === false) {
1226  return 0;
1227  } elseif (($eval->e($lowerBound) !== false) && ($eval->e($upperBound) !== false)) {
1228  // fau.
1229  if (($eval->e($a_entered) >= $eval->e($lowerBound)) && ($eval->e($a_entered) <= $eval->e($upperBound))) {
1230  $result = $max_points;
1231  }
1232  } elseif ($eval->e($lowerBound) !== false) {
1233  if (($eval->e($a_entered) >= $eval->e($lowerBound)) && ($eval->e($a_entered) <= $eval->e($a_original))) {
1234  $result = $max_points;
1235  }
1236  } elseif ($eval->e($upperBound) !== false) {
1237  if (($eval->e($a_entered) >= $eval->e($a_original)) && ($eval->e($a_entered) <= $eval->e($upperBound))) {
1238  $result = $max_points;
1239  }
1240  } else {
1241  if ($eval->e($a_entered) == $eval->e($a_original)) {
1242  $result = $max_points;
1243  }
1244  }
1245  return $result;
1246  }
$result
+ Here is the caller graph for this function:

◆ getOperators()

assClozeTest::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
string$expression

Implements iQuestionCondition.

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

References ilOperatorsExpressionMapping\getOperatorsByExpression().

1719  {
1720  require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1722  }
+ Here is the call graph for this function:

◆ getQuestionType()

assClozeTest::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

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

Referenced by toJSON().

1447  {
1448  return "assClozeTest";
1449  }
+ 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 1584 of file class.assClozeTest.php.

References getClozeText().

1585  {
1586  return parent::getRTETextWithMediaObjects() . $this->getClozeText();
1587  }
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:

◆ getSolutionSubmit()

assClozeTest::getSolutionSubmit ( )

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

References $_POST, and fetchSolutionSubmit().

Referenced by saveWorkingData().

1385  {
1386  return $this->fetchSolutionSubmit($_POST);
1387  }
fetchSolutionSubmit($submit)
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSolutionSubmitValidation()

assClozeTest::getSolutionSubmitValidation ( )

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

References $_POST, CLOZE_NUMERIC, CLOZE_SELECT, and getGap().

Referenced by validateSolutionSubmit().

1361  {
1362  $submit = $_POST;
1363  $solutionSubmit = array();
1364 
1365  foreach ($submit as $key => $value) {
1366  if (preg_match("/^gap_(\d+)/", $key, $matches)) {
1367  if ($value !== null && $value !== '') {
1368  $gap = $this->getGap($matches[1]);
1369  if (is_object($gap)) {
1370  if (!(($gap->getType() == CLOZE_SELECT) && ($value == -1))) {
1371  if ($gap->getType() == CLOZE_NUMERIC) {
1372  $value = str_replace(",", ".", $value);
1373  }
1374  $solutionSubmit[trim($matches[1])] = $value;
1375  }
1376  }
1377  }
1378  }
1379  }
1380 
1381  return $solutionSubmit;
1382  }
getGap($gap_index=0)
Returns the gap at a given index.
const CLOZE_SELECT
const CLOZE_NUMERIC
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller 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 611 of file class.assClozeTest.php.

References $start_tag.

612  {
613  return $this->start_tag;
614  }

◆ 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 1159 of file class.assClozeTest.php.

References $DIC, assQuestion\$refinery, $result, getTextgapRating(), ilStr\strToLower(), TEXTGAP_RATING_CASEINSENSITIVE, TEXTGAP_RATING_CASESENSITIVE, TEXTGAP_RATING_LEVENSHTEIN1, TEXTGAP_RATING_LEVENSHTEIN2, TEXTGAP_RATING_LEVENSHTEIN3, TEXTGAP_RATING_LEVENSHTEIN4, and TEXTGAP_RATING_LEVENSHTEIN5.

Referenced by calculateCombinationResult(), and calculateReachedPointsForSolution().

1160  {
1161  include_once "./Services/Utilities/classes/class.ilStr.php";
1162  global $DIC;
1163  $refinery = $DIC->refinery();
1164  $result = 0;
1165  $gaprating = $this->getTextgapRating();
1166 
1167  switch ($gaprating) {
1169  if (strcmp(ilStr::strToLower($a_original), ilStr::strToLower($a_entered)) == 0) {
1170  $result = $max_points;
1171  }
1172  break;
1174  if (strcmp($a_original, $a_entered) == 0) {
1175  $result = $max_points;
1176  }
1177  break;
1179  $transformation = $refinery->string()->levenshtein()->standard($a_original, 1);
1180  break;
1182  $transformation = $refinery->string()->levenshtein()->standard($a_original, 2);
1183  break;
1185  $transformation = $refinery->string()->levenshtein()->standard($a_original, 3);
1186  break;
1188  $transformation = $refinery->string()->levenshtein()->standard($a_original, 4);
1189  break;
1191  $transformation = $refinery->string()->levenshtein()->standard($a_original, 5);
1192  break;
1193  }
1194 
1195  // run answers against Levenshtein2 methods
1196  if (isset($transformation) && $transformation->transform($a_entered) >= 0) {
1197  $result = $max_points;
1198  }
1199  return $result;
1200  }
const TEXTGAP_RATING_LEVENSHTEIN5
$result
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
getTextgapRating()
Returns the rating option for text gaps.
static strToLower($a_string)
Definition: class.ilStr.php:87
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
global $DIC
Definition: goto.php:24
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_CASEINSENSITIVE
+ 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 User interface

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

References $textgap_rating.

Referenced by getTextgapPoints(), and saveAdditionalQuestionDataToDb().

1459  {
1460  return $this->textgap_rating;
1461  }
+ Here is the caller graph for this function:

◆ isAddableAnswerOptionValue()

assClozeTest::isAddableAnswerOptionValue (   $qIndex,
  $answerOptionValue 
)

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

References CLOZE_TEXT, and getGap().

2012  {
2013  $gap = $this->getGap($qIndex);
2014 
2015  if ($gap->getType() != CLOZE_TEXT) {
2016  return false;
2017  }
2018 
2019  foreach ($gap->getItems(new ilArrayElementOrderKeeper()) as $item) {
2020  if ($item->getAnswertext() === $answerOptionValue) {
2021  return false;
2022  }
2023  }
2024 
2025  return true;
2026  }
const CLOZE_TEXT
Cloze question constants.
getGap($gap_index=0)
Returns the gap at a given index.
+ 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 140 of file class.assClozeTest.php.

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

141  {
142  if (strlen($this->getTitle())
143  && $this->getAuthor()
144  && $this->getClozeText()
145  && count($this->getGaps())
146  && $this->getMaximumPoints() > 0) {
147  return true;
148  }
149  return false;
150  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
getGaps()
Returns the array of gaps.
getAuthor()
Gets the authors name of the assQuestion object.
getClozeText()
Returns the cloze text.
getTitle()
Gets the title string of the assQuestion object.
+ Here is the call graph for this function:

◆ isValidNumericSubmitValue()

assClozeTest::isValidNumericSubmitValue (   $submittedValue)
protected

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

Referenced by validateSolutionSubmit().

1298  {
1299  if (is_numeric($submittedValue)) {
1300  return true;
1301  }
1302 
1303  if (preg_match('/^[-+]{0,1}\d+\/\d+$/', $submittedValue)) {
1304  return true;
1305  }
1306 
1307  return false;
1308  }
+ Here is the caller graph for this function:

◆ lmMigrateQuestionTypeSpecificContent()

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

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

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

1651  {
1652  // DO NOT USE SETTER FOR CLOZE TEXT -> SETTER DOES RECREATE GAP OBJECTS without having gap type info ^^
1653  //$this->setClozeText( $migrator->migrateToLmContent($this->getClozeText()) );
1654  $this->cloze_text = $migrator->migrateToLmContent($this->getClozeText());
1655  // DO NOT USE SETTER FOR CLOZE TEXT -> SETTER DOES RECREATE GAP OBJECTS without having gap type info ^^
1656  }
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:

◆ loadFromDb()

assClozeTest::loadFromDb (   $question_id)

Loads a assClozeTest object from a database.

Parameters
integer$question_idA unique key which defines the cloze test in the database

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

References $data, $DIC, Vendor\Package\$e, $ilDB, $result, ilRTE\_replaceMediaObjectImageSrc(), cleanQuestiontext(), CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, ilAssClozeTestFeedback\FB_MODE_GAP_QUESTION, getAdditionalTableName(), ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), setClozeText(), assQuestion\setComment(), assQuestion\setEstimatedWorkingTime(), setFeedbackMode(), setFixedTextLength(), setGapCombinations(), setGapCombinationsExists(), assQuestion\setId(), setIdenticalScoring(), assQuestion\setLifecycle(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setTextgapRating(), and assQuestion\setTitle().

194  {
195  global $DIC;
196  $ilDB = $DIC['ilDB'];
197  $result = $ilDB->queryF(
198  "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",
199  array("integer"),
200  array($question_id)
201  );
202  if ($result->numRows() == 1) {
203  $data = $ilDB->fetchAssoc($result);
204  $this->setId($question_id);
205  $this->setNrOfTries($data['nr_of_tries']);
206  $this->setObjId($data["obj_fi"]);
207  $this->setTitle($data["title"]);
208  $this->setComment($data["description"]);
209  $this->setOriginalId($data["original_id"]);
210  $this->setAuthor($data["author"]);
211  $this->setPoints($data["points"]);
212  $this->setOwner($data["owner"]);
213  $this->setQuestion($this->cleanQuestiontext($data["question_text"]));
214  $this->setClozeText($data['cloze_text']);
215  $this->setFixedTextLength($data["fixed_textlen"]);
216  $this->setIdenticalScoring(($data['tstamp'] == 0) ? true : $data["identical_scoring"]);
217  $this->setFeedbackMode($data['feedback_mode'] === null ? ilAssClozeTestFeedback::FB_MODE_GAP_QUESTION : $data['feedback_mode']);
218 
219  try {
223  }
224 
225  // replacement of old syntax with new syntax
226  include_once("./Services/RTE/classes/class.ilRTE.php");
227  $this->question = ilRTE::_replaceMediaObjectImageSrc($this->question, 1);
228  $this->cloze_text = ilRTE::_replaceMediaObjectImageSrc($this->cloze_text, 1);
229  $this->setTextgapRating($data["textgap_rating"]);
230  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
231 
232  try {
233  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
234  } catch (ilTestQuestionPoolException $e) {
235  }
236 
237  // open the cloze gaps with all answers
238  include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
239  include_once "./Modules/TestQuestionPool/classes/class.assClozeGap.php";
240  $result = $ilDB->queryF(
241  "SELECT * FROM qpl_a_cloze WHERE question_fi = %s ORDER BY gap_id, aorder ASC",
242  array("integer"),
243  array($question_id)
244  );
245  if ($result->numRows() > 0) {
246  $this->gaps = array();
247  while ($data = $ilDB->fetchAssoc($result)) {
248  switch ($data["cloze_type"]) {
249  case CLOZE_TEXT:
250  if (!array_key_exists($data["gap_id"], $this->gaps)) {
251  $this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_TEXT);
252  }
253  $answer = new assAnswerCloze(
254  $data["answertext"],
255  $data["points"],
256  $data["aorder"]
257  );
258  $this->gaps[$data["gap_id"]]->setGapSize($data['gap_size']);
259 
260  $this->gaps[$data["gap_id"]]->addItem($answer);
261  break;
262  case CLOZE_SELECT:
263  if (!array_key_exists($data["gap_id"], $this->gaps)) {
264  $this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_SELECT);
265  $this->gaps[$data["gap_id"]]->setShuffle($data["shuffle"]);
266  }
267  $answer = new assAnswerCloze(
268  $data["answertext"],
269  $data["points"],
270  $data["aorder"]
271  );
272  $this->gaps[$data["gap_id"]]->addItem($answer);
273  break;
274  case CLOZE_NUMERIC:
275  if (!array_key_exists($data["gap_id"], $this->gaps)) {
276  $this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_NUMERIC);
277  }
278  $answer = new assAnswerCloze(
279  $data["answertext"],
280  $data["points"],
281  $data["aorder"]
282  );
283  $this->gaps[$data["gap_id"]]->setGapSize($data['gap_size']);
284  $answer->setLowerBound($data["lowerlimit"]);
285  $answer->setUpperBound($data["upperlimit"]);
286  $this->gaps[$data["gap_id"]]->addItem($answer);
287  break;
288  }
289  }
290  }
291  }
292  $assClozeGapCombinationObj = new assClozeGapCombination();
293  $check_for_gap_combinations = $assClozeGapCombinationObj->loadFromDb($question_id);
294  if (count($check_for_gap_combinations) != 0) {
295  $this->setGapCombinationsExists(true);
296  $this->setGapCombinations($check_for_gap_combinations);
297  }
298  parent::loadFromDb($question_id);
299  }
Class for cloze question numeric answers.
$data
Definition: storeScorm.php:23
getAdditionalTableName()
Returns the name of the additional question data table in the database.
$result
const CLOZE_TEXT
Cloze question constants.
setId($id=-1)
Sets the id of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second. ...
Class for cloze question gaps.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setGapCombinationsExists($value)
setAuthor($author="")
Sets the authors name of the assQuestion object.
const CLOZE_SELECT
setFixedTextLength($a_text_len)
Sets a fixed text length for all text fields in the cloze question.
global $DIC
Definition: goto.php:24
setClozeText($cloze_text="")
Evaluates the text gap solutions from the cloze text.
cleanQuestiontext($text)
Cleans cloze question text to remove attributes or tags from older ILIAS versions.
setPoints($a_points)
Sets the maximum available points for the question.
setFeedbackMode($feedbackMode)
setTextgapRating($a_textgap_rating)
Sets the rating option for text gaps.
setQuestion($question="")
Sets the question string of the question object.
global $ilDB
setOriginalId($original_id)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
const CLOZE_NUMERIC
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setIdenticalScoring($a_identical_scoring)
Sets the identical scoring option for cloze questions.
setComment($comment="")
Sets the comment string of the assQuestion object.
const FB_MODE_GAP_QUESTION
constants for different feedback modes (per gap or per gap-answers/options)
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
+ Here is the call graph for this function:

◆ replaceFirstGap()

assClozeTest::replaceFirstGap (   $gaptext,
  $content 
)

Replace the first gap in a string without treating backreferences.

Parameters
string$gaptexttext with gap tags
string$contentcontent for the first gap
Returns
string

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

Referenced by deleteGap(), and updateClozeTextFromGaps().

179  {
180  $content = str_replace('$', 'GAPMASKEDDOLLAR', $content);
181  $output = preg_replace("/\[gap\].*?\[\/gap\]/", $content, $gaptext, 1);
182  $output = str_replace('GAPMASKEDDOLLAR', '$', $output);
183 
184  return $output;
185  }
+ Here is the caller graph for this function:

◆ saveAdditionalQuestionDataToDb()

assClozeTest::saveAdditionalQuestionDataToDb ( )

Saves the data for the additional data table.

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

Implements ilObjQuestionScoringAdjustable.

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

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

Referenced by saveToDb().

346  {
347  global $DIC; /* @var ILIAS\DI\Container $DIC */
348 
349 
350  $DIC->database()->manipulateF(
351  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
352  array( "integer" ),
353  array( $this->getId() )
354  );
355 
356  $DIC->database()->insert($this->getAdditionalTableName(), array(
357  'question_fi' => array('integer', $this->getId()),
358  'textgap_rating' => array('text', $this->getTextgapRating()),
359  'identical_scoring' => array('text', $this->getIdenticalScoring()),
360  'fixed_textlen' => array('integer', $this->getFixedTextLength() ? $this->getFixedTextLength() : null),
361  'cloze_text' => array('text', ilRTE::_replaceMediaObjectImageSrc($this->getClozeText(), 0)),
362  'feedback_mode' => array('text', $this->getFeedbackMode())
363  ));
364  }
getId()
Gets the id of the assQuestion object.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getTextgapRating()
Returns the rating option for text gaps.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
global $DIC
Definition: goto.php:24
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 ( )

Save all gaps to the database.

Implements ilObjAnswerScoringAdjustable.

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

References $DIC, $ilDB, assQuestion\getId(), and saveClozeGapItemsToDb().

Referenced by saveToDb().

325  {
326  global $DIC;
327  $ilDB = $DIC['ilDB'];
328 
329  $ilDB->manipulateF(
330  "DELETE FROM qpl_a_cloze WHERE question_fi = %s",
331  array( "integer" ),
332  array( $this->getId() )
333  );
334 
335  foreach ($this->gaps as $key => $gap) {
336  $this->saveClozeGapItemsToDb($gap, $key);
337  }
338  }
getId()
Gets the id of the assQuestion object.
global $DIC
Definition: goto.php:24
global $ilDB
saveClozeGapItemsToDb($gap, $key)
Save all items belonging to one cloze gap to the db.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeGapItemsToDb()

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

Save all items belonging to one cloze gap to the db.

Parameters
$gap
$key

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

References $DIC, $ilDB, $query, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, saveClozeNumericGapRecordToDb(), saveClozeSelectGapRecordToDb(), and saveClozeTextGapRecordToDb().

Referenced by saveAnswerSpecificDataToDb().

373  {
374  global $DIC;
375  $ilDB = $DIC['ilDB'];
376  foreach ($gap->getItems($this->getShuffler()) as $item) {
377  $query = "";
378  $next_id = $ilDB->nextId('qpl_a_cloze');
379  switch ($gap->getType()) {
380  case CLOZE_TEXT:
381  $this->saveClozeTextGapRecordToDb($next_id, $key, $item, $gap);
382  break;
383  case CLOZE_SELECT:
384  $this->saveClozeSelectGapRecordToDb($next_id, $key, $item, $gap);
385  break;
386  case CLOZE_NUMERIC:
387  $this->saveClozeNumericGapRecordToDb($next_id, $key, $item, $gap);
388  break;
389  }
390  }
391  }
const CLOZE_TEXT
Cloze question constants.
const CLOZE_SELECT
global $DIC
Definition: goto.php:24
$query
saveClozeTextGapRecordToDb($next_id, $key, $item, $gap)
Saves a gap-item record.
saveClozeNumericGapRecordToDb($next_id, $key, $item, $gap)
Saves a gap-item record.
global $ilDB
saveClozeSelectGapRecordToDb($next_id, $key, $item, $gap)
Saves a gap-item record.
const CLOZE_NUMERIC
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeNumericGapRecordToDb()

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

Saves a gap-item record.

Parameters
$next_idint Next Id for the record.
$keyint Gap Id
$itemgap Gap item data object.
$gapgap Gap data object.

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

References $DIC, $ilDB, and assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

476  {
477  global $DIC;
478  $ilDB = $DIC['ilDB'];
479 
480  include_once "./Services/Math/classes/class.EvalMath.php";
481  $eval = new EvalMath();
482  $eval->suppress_errors = true;
483  $ilDB->manipulateF(
484  "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)",
485  array(
486  "integer",
487  "integer",
488  "integer",
489  "text",
490  "float",
491  "integer",
492  "text",
493  "text",
494  "text",
495  "integer"
496  ),
497  array(
498  $next_id,
499  $this->getId(),
500  $key,
501  strlen($item->getAnswertext()) ? $item->getAnswertext() : "",
502  $item->getPoints(),
503  $item->getOrder(),
504  $gap->getType(),
505  ($eval->e($item->getLowerBound() !== false) && strlen(
506  $item->getLowerBound()
507  ) > 0) ? $item->getLowerBound() : $item->getAnswertext(),
508  ($eval->e($item->getUpperBound() !== false) && strlen(
509  $item->getUpperBound()
510  ) > 0) ? $item->getUpperBound() : $item->getAnswertext(),
511  (int) $gap->getGapSize()
512  )
513  );
514  }
getId()
Gets the id of the assQuestion object.
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeSelectGapRecordToDb()

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

Saves a gap-item record.

Parameters
$next_idint Next Id for the record.
$keyint Gap Id
$itemgap Gap item data object.
$gapgap Gap data object.

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

References $DIC, $ilDB, and assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

439  {
440  global $DIC;
441  $ilDB = $DIC['ilDB'];
442  $ilDB->manipulateF(
443  "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)",
444  array(
445  "integer",
446  "integer",
447  "integer",
448  "text",
449  "float",
450  "integer",
451  "text",
452  "text"
453  ),
454  array(
455  $next_id,
456  $this->getId(),
457  $key,
458  strlen($item->getAnswertext()) ? $item->getAnswertext() : "",
459  $item->getPoints(),
460  $item->getOrder(),
461  $gap->getType(),
462  ($gap->getShuffle()) ? "1" : "0"
463  )
464  );
465  }
getId()
Gets the id of the assQuestion object.
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeTextGapRecordToDb()

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

Saves a gap-item record.

Parameters
$next_idint Next Id for the record.
$keyint Gap Id
$itemgap Gap item data object.
$gapgap Gap data object.

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

References $DIC, $ilDB, and assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

402  {
403  global $DIC;
404  $ilDB = $DIC['ilDB'];
405  $ilDB->manipulateF(
406  "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)",
407  array(
408  "integer",
409  "integer",
410  "integer",
411  "text",
412  "float",
413  "integer",
414  "text",
415  "integer"
416  ),
417  array(
418  $next_id,
419  $this->getId(),
420  $key,
421  strlen($item->getAnswertext()) ? $item->getAnswertext() : "",
422  $item->getPoints(),
423  $item->getOrder(),
424  $gap->getType(),
425  (int) $gap->getGapSize()
426  )
427  );
428  }
getId()
Gets the id of the assQuestion object.
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePartial()

assClozeTest::savePartial ( )

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

2039  {
2040  return true;
2041  }

◆ saveToDb()

assClozeTest::saveToDb (   $original_id = "")

Saves a assClozeTest object to a database.

Parameters
int | string$original_idID of the original question
Returns
mixed|void

public

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

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

313  {
317 
318  parent::saveToDb($original_id);
319  }
saveAnswerSpecificDataToDb()
Save all gaps to the database.
saveAdditionalQuestionDataToDb()
Saves the data for the additional data table.
saveQuestionDataToDb($original_id="")
+ Here is the call graph for this function:

◆ saveWorkingData()

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

Saves the learners input of the question to the database.

public

Parameters
integer$active_idActive id of the user
integer$passTest pass
Returns
boolean $status

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

References $DIC, $ilDB, $ilUser, $pass, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), CLOZE_SELECT, getGap(), assQuestion\getId(), assQuestion\getProcessLocker(), getSolutionSubmit(), assQuestion\logAction(), assQuestion\removeCurrentSolution(), and assQuestion\saveCurrentSolution().

1398  {
1399  global $DIC;
1400  $ilDB = $DIC['ilDB'];
1401  $ilUser = $DIC['ilUser'];
1402  if (is_null($pass)) {
1403  include_once "./Modules/Test/classes/class.ilObjTest.php";
1404  $pass = ilObjTest::_getPass($active_id);
1405  }
1406 
1407  $entered_values = 0;
1408 
1409  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $active_id, $pass, $authorized) {
1410  $this->removeCurrentSolution($active_id, $pass, $authorized);
1411 
1412  foreach ($this->getSolutionSubmit() as $key => $value) {
1413  if ($value !== null && $value !== '') {
1414  $gap = $this->getGap($key);
1415  if (is_object($gap)) {
1416  if (!(($gap->getType() == CLOZE_SELECT) && ($value == -1))) {
1417  $this->saveCurrentSolution($active_id, $pass, $key, $value, $authorized);
1418  $entered_values++;
1419  }
1420  }
1421  }
1422  }
1423  });
1424 
1425  if ($entered_values) {
1426  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1428  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1429  }
1430  } else {
1431  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1433  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1434  }
1435  }
1436 
1437  return true;
1438  }
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getId()
Gets the id of the assQuestion object.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
getGap($gap_index=0)
Returns the gap at a given index.
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
const CLOZE_SELECT
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
global $DIC
Definition: goto.php:24
removeCurrentSolution($active_id, $pass, $authorized=true)
global $ilDB
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:

◆ setClozeText()

assClozeTest::setClozeText (   $cloze_text = "")

Evaluates the text gap solutions from the cloze text.

A single or multiple text gap solutions could be entered using the following syntax in the cloze text: solution1 [, solution2, ..., solutionN] enclosed in the text gap selector gap[]

Parameters
string$cloze_textThe cloze text with all gaps and gap gaps public
See also
$cloze_text

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

References $cloze_text, cleanQuestiontext(), and createGapsFromQuestiontext().

Referenced by loadFromDb().

553  {
554  $this->gaps = [];
555  $this->cloze_text = $this->cleanQuestiontext($cloze_text);
557  }
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 559 of file class.assClozeTest.php.

References $cloze_text.

560  {
561  $this->cloze_text = $cloze_text;
562  }

◆ 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 647 of file class.assClozeTest.php.

References $end_tag.

648  {
649  $this->end_tag = $end_tag;
650  }

◆ setExportDetailsXLS()

assClozeTest::setExportDetailsXLS (   $worksheet,
  $startrow,
  $active_id,
  $pass 
)

{}

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

References $i, $pass, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, getGaps(), and assQuestion\getSolutionValues().

1612  {
1613  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
1614 
1615  $solution = $this->getSolutionValues($active_id, $pass);
1616  $i = 1;
1617  foreach ($this->getGaps() as $gap_index => $gap) {
1618  $worksheet->setCell($startrow + $i, 0, $this->lng->txt("gap") . " $i");
1619  $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
1620  $checked = false;
1621  foreach ($solution as $solutionvalue) {
1622  if ($gap_index == $solutionvalue["value1"]) {
1623  $string_escaping_org_value = $worksheet->getStringEscaping();
1624  try {
1625  $worksheet->setStringEscaping(false);
1626 
1627  switch ($gap->getType()) {
1628  case CLOZE_SELECT:
1629  $worksheet->setCell($startrow + $i, 2, $gap->getItem($solutionvalue["value2"])->getAnswertext());
1630  break;
1631  case CLOZE_NUMERIC:
1632  case CLOZE_TEXT:
1633  $worksheet->setCell($startrow + $i, 2, $solutionvalue["value2"]);
1634  break;
1635  }
1636  } finally {
1637  $worksheet->setStringEscaping($string_escaping_org_value);
1638  }
1639  }
1640  }
1641  $i++;
1642  }
1643 
1644  return $startrow + $i + 1;
1645  }
const CLOZE_TEXT
Cloze question constants.
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
getGaps()
Returns the array of gaps.
const CLOZE_SELECT
const CLOZE_NUMERIC
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ setFeedbackMode()

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

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

References $feedbackMode.

Referenced by loadFromDb().

664  {
665  $this->feedbackMode = $feedbackMode;
666  }
+ Here is the caller graph for this function:

◆ setFixedTextLength()

assClozeTest::setFixedTextLength (   $a_text_len)

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

Referenced by loadFromDb().

1541  {
1542  $this->fixedTextLength = $a_text_len;
1543  }
+ 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 858 of file class.assClozeTest.php.

859  {
860  if (array_key_exists($gap_index, $this->gaps)) {
861  $this->gaps[$gap_index]->setItemLowerBound($order, $bound);
862  }
863  }

◆ 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 807 of file class.assClozeTest.php.

References assQuestion\$points.

808  {
809  if (array_key_exists($gap_index, $this->gaps)) {
810  $this->gaps[$gap_index]->setItemPoints($order, $points);
811  }
812  }

◆ 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 875 of file class.assClozeTest.php.

876  {
877  if (array_key_exists($gap_index, $this->gaps)) {
878  $this->gaps[$gap_index]->setItemUpperBound($order, $bound);
879  }
880  }

◆ setGapCombinations()

assClozeTest::setGapCombinations (   $value)

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

Referenced by loadFromDb().

1604  {
1605  $this->gap_combinations = $value;
1606  }
+ Here is the caller graph for this function:

◆ setGapCombinationsExists()

assClozeTest::setGapCombinationsExists (   $value)

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

Referenced by loadFromDb().

1599  {
1600  $this->gap_combinations_exists = $value;
1601  }
+ 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 716 of file class.assClozeTest.php.

References assQuestion\$shuffle.

717  {
718  if (array_key_exists($gap_index, $this->gaps)) {
719  $this->gaps[$gap_index]->setShuffle($shuffle);
720  }
721  }

◆ setGapSize()

assClozeTest::setGapSize (   $gap_index,
  $order,
  $size 
)

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

References $size.

791  {
792  if (array_key_exists($gap_index, $this->gaps)) {
793  $this->gaps[$gap_index]->setGapSize($size);
794  }
795  }
$size
Definition: RandomTest.php:84

◆ setGapType()

assClozeTest::setGapType (   $gap_index,
  $gap_type 
)

Set the type of a gap with a given index.

private

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

701  {
702  if (array_key_exists($gap_index, $this->gaps)) {
703  $this->gaps[$gap_index]->setType($gap_type);
704  }
705  }

◆ setIdenticalScoring()

assClozeTest::setIdenticalScoring (   $a_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 User interface

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

Referenced by loadFromDb().

1508  {
1509  $this->identical_scoring = ($a_identical_scoring) ? 1 : 0;
1510  }
+ 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 623 of file class.assClozeTest.php.

References $start_tag.

624  {
625  $this->start_tag = $start_tag;
626  }

◆ 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 User interface

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

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

Referenced by loadFromDb().

1471  {
1472  switch ($a_textgap_rating) {
1480  $this->textgap_rating = $a_textgap_rating;
1481  break;
1482  default:
1483  $this->textgap_rating = TEXTGAP_RATING_CASEINSENSITIVE;
1484  break;
1485  }
1486  }
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_CASEINSENSITIVE
+ Here is the caller graph for this function:

◆ toJSON()

assClozeTest::toJSON ( )

Returns a JSON representation of the question.

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

References $gaps, $mobs, $result, ilObjMediaObject\_getMobsOfObject(), CLOZE_NUMERIC, CLOZE_TEXT, assQuestion\formatSAQuestion(), getClozeText(), getGaps(), assQuestion\getId(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), and assQuestion\getTitle().

1662  {
1663  include_once("./Services/RTE/classes/class.ilRTE.php");
1664  $result = array();
1665  $result['id'] = (int) $this->getId();
1666  $result['type'] = (string) $this->getQuestionType();
1667  $result['title'] = (string) $this->getTitle();
1668  $result['question'] = $this->formatSAQuestion($this->getQuestion());
1669  $result['clozetext'] = $this->formatSAQuestion($this->getClozeText());
1670  $result['nr_of_tries'] = (int) $this->getNrOfTries();
1671  $result['shuffle'] = (bool) $this->getShuffle();
1672  $result['feedback'] = array(
1673  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1674  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1675  );
1676 
1677  $gaps = array();
1678  foreach ($this->getGaps() as $key => $gap) {
1679  $items = array();
1680  foreach ($gap->getItems($this->getShuffler()) as $item) {
1681  $jitem = array();
1682  $jitem['points'] = $item->getPoints();
1683  $jitem['value'] = $this->formatSAQuestion($item->getAnswertext());
1684  $jitem['order'] = $item->getOrder();
1685  if ($gap->getType() == CLOZE_NUMERIC) {
1686  $jitem['lowerbound'] = $item->getLowerBound();
1687  $jitem['upperbound'] = $item->getUpperBound();
1688  } else {
1689  $jitem['value'] = trim($jitem['value']);
1690  }
1691  array_push($items, $jitem);
1692  }
1693 
1694  if ($gap->getGapSize() && ($gap->getType() == CLOZE_TEXT || $gap->getType() == CLOZE_NUMERIC)) {
1695  $jgap['size'] = $gap->getGapSize();
1696  }
1697 
1698  $jgap['shuffle'] = $gap->getShuffle();
1699  $jgap['type'] = $gap->getType();
1700  $jgap['item'] = $items;
1701 
1702  array_push($gaps, $jgap);
1703  }
1704  $result['gaps'] = $gaps;
1705  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1706  $result['mobs'] = $mobs;
1707  return json_encode($result);
1708  }
getId()
Gets the id of the assQuestion object.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
formatSAQuestion($a_q)
Format self assessment question.
getQuestionType()
Returns the question type of the question.
$result
$mobs
Definition: imgupload.php:54
const CLOZE_TEXT
Cloze question constants.
getShuffle()
Gets the shuffle flag.
getGaps()
Returns the array of gaps.
getQuestion()
Gets the question string of the question object.
getClozeText()
Returns the cloze text.
getTitle()
Gets the title string of the assQuestion object.
const CLOZE_NUMERIC
+ 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 1077 of file class.assClozeTest.php.

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

Referenced by deleteAnswerText().

1078  {
1079  $output = $this->getClozeText();
1080  foreach ($this->getGaps() as $gap_index => $gap) {
1081  $answers = array();
1082  foreach ($gap->getItemsRaw() as $item) {
1083  array_push($answers, str_replace([',', '['], ["\\,", '[&hairsp;'], $item->getAnswerText()));
1084  }
1085  // fau: fixGapReplace - use replace function
1086  $output = $this->replaceFirstGap($output, "[_gap]" . $this->prepareTextareaOutput(join(",", $answers), true) . "[/_gap]");
1087  // fau.
1088  }
1089  $output = str_replace("_gap]", "gap]", $output);
1090  $this->cloze_text = $output;
1091  }
getGaps()
Returns the array of gaps.
replaceFirstGap($gaptext, $content)
Replace the first gap in a string without treating backreferences.
prepareTextareaOutput($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output in tests.
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateSolutionSubmit()

assClozeTest::validateSolutionSubmit ( )

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

References CLOZE_NUMERIC, getGap(), getSolutionSubmitValidation(), isValidNumericSubmitValue(), and ilUtil\sendFailure().

1311  {
1312  foreach ($this->getSolutionSubmitValidation() as $gapIndex => $value) {
1313  $gap = $this->getGap($gapIndex);
1314 
1315  if ($gap->getType() != CLOZE_NUMERIC) {
1316  continue;
1317  }
1318 
1319  if (strlen($value) && !$this->isValidNumericSubmitValue($value)) {
1320  ilUtil::sendFailure($this->lng->txt("err_no_numeric_value"), true);
1321  return false;
1322  }
1323  }
1324 
1325  return true;
1326  }
getGap($gap_index=0)
Returns the gap at a given index.
isValidNumericSubmitValue($submittedValue)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const CLOZE_NUMERIC
+ Here is the call graph for this function:

Field Documentation

◆ $cloze_text

assClozeTest::$cloze_text

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

Referenced by getClozeText(), setClozeText(), and setClozeTextValue().

◆ $end_tag

assClozeTest::$end_tag

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

Referenced by getEndTag(), and setEndTag().

◆ $feedbackMode

assClozeTest::$feedbackMode = ilAssClozeTestFeedback::FB_MODE_GAP_QUESTION
protected

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

Referenced by getFeedbackMode(), and setFeedbackMode().

◆ $feedbackOBJ

assClozeTest::$feedbackOBJ

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

◆ $fixedTextLength

assClozeTest::$fixedTextLength

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

Referenced by getFixedTextLength().

◆ $gap_combinations

assClozeTest::$gap_combinations

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

Referenced by getGapCombinations().

◆ $gap_combinations_exists

assClozeTest::$gap_combinations_exists

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

Referenced by getGapCombinationsExists().

◆ $gaps

assClozeTest::$gaps

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

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

◆ $identical_scoring

assClozeTest::$identical_scoring

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

◆ $start_tag

assClozeTest::$start_tag

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

Referenced by getStartTag(), and setStartTag().

◆ $textgap_rating

assClozeTest::$textgap_rating

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

Referenced by getTextgapRating().


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