ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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...
 
 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)
 {Creates an Excel worksheet for the detailed cumulated results of this question.
Parameters
object$worksheetReference to the parent excel worksheet
object$startrowStartrow of the output in the excel worksheet
object$active_idActive id of the participant
object$passTest pass
Returns
object
} 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
 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assQuestion constructor More...
 
 getShuffler ()
 
 setShuffler (ilArrayElementShuffler $shuffler)
 
 setProcessLocker ($processLocker)
 
 getProcessLocker ()
 
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 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...
 
 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...
 
 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...
 
 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 ()
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
- Public Member Functions inherited from iQuestionCondition
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 

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_DEFAULT = 'default'
 constant for additional content editing mode "default" More...
 
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT = '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)
 
 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
 
 $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)
 @TODO 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)
 @global 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
\assClozeTest

Reimplemented from assQuestion.

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

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)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswerOptionValue()

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

Reimplemented from assQuestion.

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

1997 {
1998 $gap = $this->getGap($qIndex); /* @var assClozeGap $gap */
1999
2000 $item = new assAnswerCloze($answerOptionValue, $points);
2001 $item->setOrder($gap->getItemCount());
2002
2003 $gap->addItem($item);
2004 }
Class for cloze question numeric answers.
getGap($gap_index=0)
Returns the gap at a given index.

References assQuestion\$points, and getGap().

+ 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 @access public
See also
$gaps

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

734 {
735 if (array_key_exists($gap_index, $this->gaps)) {
736 if ($this->gaps[$gap_index]->getType() == CLOZE_NUMERIC) {
737 // only allow notation with "." for real numbers
738 $answer = str_replace(",", ".", $answer);
739 }
740 $this->gaps[$gap_index]->addItem(new assAnswerCloze($answer, 0, $order));
741 }
742 }
const CLOZE_NUMERIC

References 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 @access public
See also
$gaps

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

815 {
816 $this->gaps[$index] = $gap;
817 }
$index
Definition: metadata.php:128

References $index.

◆ 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 @access public
See also
$gaps

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

794 {
795 if (array_key_exists($gap_index, $this->gaps)) {
796 include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
797 $answer = new assAnswerCloze(
798 "",
799 0,
800 $this->gaps[$gap_index]->getItemCount()
801 );
802 $this->gaps[$gap_index]->addItem($answer);
803 }
804 }

◆ calculateCombinationResult()

assClozeTest::calculateCombinationResult (   $user_result)

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

1783 {
1784 $points = 0;
1785
1786 $assClozeGapCombinationObj = new assClozeGapCombination();
1787
1788 if ($assClozeGapCombinationObj->combinationExistsForQid($this->getId())) {
1789 $combinations_for_question = $assClozeGapCombinationObj->getCleanCombinationArray($this->getId());
1790 $gap_answers = array();
1791 $gap_used_in_combination = array();
1792 foreach ($user_result as $user_result_build_list) {
1793 if (is_array($user_result_build_list)) {
1794 $gap_answers[$user_result_build_list['gap_id']] = $user_result_build_list['value'];
1795 }
1796 }
1797
1798 foreach ($combinations_for_question as $combination) {
1799 foreach ($combination as $row_key => $row_answers) {
1800 $combination_fulfilled = true;
1801 $points_for_combination = $row_answers['points'];
1802 foreach ($row_answers as $gap_key => $combination_gap_answer) {
1803 if ($gap_key !== 'points') {
1804 $gap_used_in_combination[$gap_key] = $gap_key;
1805 }
1806 if ($combination_fulfilled && array_key_exists($gap_key, $gap_answers)) {
1807 switch ($combination_gap_answer['type']) {
1808 case CLOZE_TEXT:
1809 $is_text_gap_correct = $this->getTextgapPoints($gap_answers[$gap_key], $combination_gap_answer['answer'], 1);
1810 if ($is_text_gap_correct != 1) {
1811 $combination_fulfilled = false;
1812 }
1813 break;
1814 case CLOZE_SELECT:
1815 $answer = $this->gaps[$gap_key]->getItem($gap_answers[$gap_key]);
1816 $answertext = $answer->getAnswertext();
1817 if ($answertext != $combination_gap_answer['answer']) {
1818 $combination_fulfilled = false;
1819 }
1820 break;
1821 case CLOZE_NUMERIC:
1822 $answer = $this->gaps[$gap_key]->getItem(0);
1823 if ($combination_gap_answer['answer'] != 'out_of_bound') {
1824 $is_numeric_gap_correct = $this->getNumericgapPoints($answer->getAnswertext(), $gap_answers[$gap_key], 1, $answer->getLowerBound(), $answer->getUpperBound());
1825 if ($is_numeric_gap_correct != 1) {
1826 $combination_fulfilled = false;
1827 }
1828 } else {
1829 $wrong_is_the_new_right = $this->getNumericgapPoints($answer->getAnswertext(), $gap_answers[$gap_key], 1, $answer->getLowerBound(), $answer->getUpperBound());
1830 if ($wrong_is_the_new_right == 1) {
1831 $combination_fulfilled = false;
1832 }
1833 }
1834 break;
1835 }
1836 } else {
1837 if ($gap_key !== 'points') {
1838 $combination_fulfilled = false;
1839 }
1840 }
1841 }
1842 if ($combination_fulfilled) {
1843 $points += $points_for_combination;
1844 }
1845 }
1846 }
1847 }
1848 return array($points, $gap_used_in_combination);
1849 }
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...
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...
getId()
Gets the id of the assQuestion object.
const CLOZE_SELECT
const CLOZE_TEXT
Cloze question constants.

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

Referenced by calculateReachedPointsForSolution().

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

@access public

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

Reimplemented from assQuestion.

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

1239 {
1240 global $DIC;
1241 $ilDB = $DIC['ilDB'];
1242
1243 if (is_null($pass)) {
1244 $pass = $this->getSolutionMaxPass($active_id);
1245 }
1246
1247 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized);
1248 $user_result = array();
1249 while ($data = $ilDB->fetchAssoc($result)) {
1250 if (strcmp($data["value2"], "") != 0) {
1251 $user_result[$data["value1"]] = array(
1252 "gap_id" => $data["value1"],
1253 "value" => $data["value2"]
1254 );
1255 }
1256 }
1257
1258 ksort($user_result); // this is required when identical scoring for same solutions is disabled
1259
1260 if ($returndetails) {
1261 $detailed = array();
1262 $this->calculateReachedPointsForSolution($user_result, $detailed);
1263 return $detailed;
1264 }
1265
1266 return $this->calculateReachedPointsForSolution($user_result);
1267 }
$result
calculateReachedPointsForSolution($user_result, &$detailed=null)
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
global $ilDB
$data
Definition: storeScorm.php:23
$DIC
Definition: xapitoken.php:46

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

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

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

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

1856 {
1857 if ($detailed === null) {
1858 $detailed = array();
1859 }
1860
1861 $assClozeGapCombinationObj = new assClozeGapCombination();
1862 $combinations[1] = array();
1863 if ($assClozeGapCombinationObj->combinationExistsForQid($this->getId())) {
1864 $combinations = $this->calculateCombinationResult($user_result);
1865 $points = $combinations[0];
1866 }
1867 $counter = 0;
1868 $solution_values_text = array(); // for identical scoring checks
1869 $solution_values_select = array(); // for identical scoring checks
1870 $solution_values_numeric = array(); // for identical scoring checks
1871 foreach ($user_result as $gap_id => $value) {
1872 if (is_string($value)) {
1873 $value = array("value" => $value);
1874 }
1875
1876 if (array_key_exists($gap_id, $this->gaps) && !array_key_exists($gap_id, $combinations[1])) {
1877 switch ($this->gaps[$gap_id]->getType()) {
1878 case CLOZE_TEXT:
1879 $gappoints = 0;
1880 for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++) {
1881 $answer = $this->gaps[$gap_id]->getItem($order);
1882 $gotpoints = $this->getTextgapPoints($answer->getAnswertext(), $value["value"], $answer->getPoints());
1883 if ($gotpoints > $gappoints) {
1884 $gappoints = $gotpoints;
1885 }
1886 }
1887 if (!$this->getIdenticalScoring()) {
1888 // check if the same solution text was already entered
1889 if ((in_array($value["value"], $solution_values_text)) && ($gappoints > 0)) {
1890 $gappoints = 0;
1891 }
1892 }
1893 $points += $gappoints;
1894 $detailed[$gap_id] = array("points" => $gappoints, "best" => ($this->getMaximumGapPoints($gap_id) == $gappoints) ? true : false, "positive" => ($gappoints > 0) ? true : false);
1895 array_push($solution_values_text, $value["value"]);
1896 break;
1897 case CLOZE_NUMERIC:
1898 $gappoints = 0;
1899 for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++) {
1900 $answer = $this->gaps[$gap_id]->getItem($order);
1901 $gotpoints = $this->getNumericgapPoints($answer->getAnswertext(), $value["value"], $answer->getPoints(), $answer->getLowerBound(), $answer->getUpperBound());
1902 if ($gotpoints > $gappoints) {
1903 $gappoints = $gotpoints;
1904 }
1905 }
1906 if (!$this->getIdenticalScoring()) {
1907 // check if the same solution value was already entered
1908 include_once "./Services/Math/classes/class.EvalMath.php";
1909 $eval = new EvalMath();
1910 $eval->suppress_errors = true;
1911 $found_value = false;
1912 foreach ($solution_values_numeric as $solval) {
1913 if ($eval->e($solval) == $eval->e($value["value"])) {
1914 $found_value = true;
1915 }
1916 }
1917 if ($found_value && ($gappoints > 0)) {
1918 $gappoints = 0;
1919 }
1920 }
1921 $points += $gappoints;
1922 $detailed[$gap_id] = array("points" => $gappoints, "best" => ($this->getMaximumGapPoints($gap_id) == $gappoints) ? true : false, "positive" => ($gappoints > 0) ? true : false);
1923 array_push($solution_values_numeric, $value["value"]);
1924 break;
1925 case CLOZE_SELECT:
1926 if ($value["value"] >= 0) {
1927 for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++) {
1928 $answer = $this->gaps[$gap_id]->getItem($order);
1929 if ($value["value"] == $answer->getOrder()) {
1930 $answerpoints = $answer->getPoints();
1931 if (!$this->getIdenticalScoring()) {
1932 // check if the same solution value was already entered
1933 if ((in_array($answer->getAnswertext(), $solution_values_select)) && ($answerpoints > 0)) {
1934 $answerpoints = 0;
1935 }
1936 }
1937 $points += $answerpoints;
1938 $detailed[$gap_id] = array("points" => $answerpoints, "best" => ($this->getMaximumGapPoints($gap_id) == $answerpoints) ? true : false, "positive" => ($answerpoints > 0) ? true : false);
1939 array_push($solution_values_select, $answer->getAnswertext());
1940 }
1941 }
1942 }
1943 break;
1944 }
1945 }
1946 }
1947
1948 return $points;
1949 }
getMaximumGapPoints($gap_index)
Returns the maximum points for a gap.
calculateCombinationResult($user_result)
getIdenticalScoring()
Returns the identical scoring status of the question.

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

Referenced by calculateReachedPoints(), and calculateReachedPointsFromPreviewSession().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assClozeTest::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

Reimplemented from assQuestion.

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

1952 {
1953 $userSolution = array();
1954
1955 foreach ($previewSession->getParticipantsSolution() as $key => $val) {
1956 $userSolution[$key] = array('gap_id' => $key, 'value' => $val);
1957 }
1958
1959 $reachedPoints = $this->calculateReachedPointsForSolution($userSolution);
1960 $reachedPoints = $this->deductHintPointsFromReachedPoints($previewSession, $reachedPoints);
1961
1962 return $this->ensureNonNegativePoints($reachedPoints);
1963 }
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
ensureNonNegativePoints($points)

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

+ Here is the call graph for this function:

◆ checkForValidFormula()

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

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

1225 {
1226 return preg_match("/^-?(\\d*)(,|\\.|\\/){0,1}(\\d*)$/", $value, $matches);
1227 }

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

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

Referenced by loadFromDb(), and setClozeText().

+ Here is the caller graph for this function:

◆ clearGapAnswers()

assClozeTest::clearGapAnswers ( )

Removes all answers from the gaps.

@access public

See also
$gaps

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

701 {
702 foreach ($this->gaps as $gap_index => $gap) {
703 $this->gaps[$gap_index]->clearItems();
704 }
705 }

◆ copyGapCombination()

assClozeTest::copyGapCombination (   $orgID,
  $newID 
)

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

1037 {
1038 $assClozeGapCombinationObj = new assClozeGapCombination();
1039 $array = $assClozeGapCombinationObj->loadFromDb($orgID);
1040 $assClozeGapCombinationObj->importGapCombinationToDb($newID, $array);
1041 }

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

+ Here is the caller graph for this function:

◆ copyObject()

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

Copies an assClozeTest object.

@access public

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

963 {
964 if ($this->getId() <= 0) {
965 // The question has not been saved. It cannot be duplicated
966 return;
967 }
968
969 $thisId = $this->getId();
970 $thisObjId = $this->getObjId();
971
972 $clone = $this;
973 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
975 $clone->id = -1;
976 $clone->setObjId($target_questionpool_id);
977 if ($title) {
978 $clone->setTitle($title);
979 }
980
981 $clone->saveToDb();
982
983 if ($this->gap_combinations_exists) {
984 $this->copyGapCombination($original_id, $clone->getId());
985 $clone->saveToDb();
986 }
987
988 // copy question page content
989 $clone->copyPageOfQuestion($original_id);
990 // copy XHTML media objects
991 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
992
993 $clone->onCopy($thisObjId, $thisId, $clone->getObjId(), $clone->getId());
994
995 return $clone->getId();
996 }
copyGapCombination($orgID, $newID)
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.

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

+ Here is the call graph for this function:

◆ createGapsFromQuestiontext()

assClozeTest::createGapsFromQuestiontext ( )

Create gap entries by parsing the question text.

@access public

See also
$gaps

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

646 {
647 include_once "./Modules/TestQuestionPool/classes/class.assClozeGap.php";
648 include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
649 $search_pattern = "|\[gap\](.*?)\[/gap\]|i";
650 preg_match_all($search_pattern, $this->getClozeText(), $found);
651 $this->gaps = array();
652 if (count($found[0])) {
653 foreach ($found[1] as $gap_index => $answers) {
654 // create text gaps by default
655 $gap = new assClozeGap(CLOZE_TEXT);
656 $textparams = preg_split("/(?<!\\\\),/", $answers);
657 foreach ($textparams as $key => $value) {
658 $answer = new assAnswerCloze($value, 0, $key);
659 $gap->addItem($answer);
660 }
661 $this->gaps[$gap_index] = $gap;
662 }
663 }
664 }
Class for cloze question gaps.
getClozeText()
Returns the cloze text.

References CLOZE_TEXT, and getClozeText().

Referenced by setClozeText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

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

999 {
1000 if ($this->id <= 0) {
1001 // The question has not been saved. It cannot be duplicated
1002 return;
1003 }
1004
1005 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
1006
1007 $sourceQuestionId = $this->id;
1008 $sourceParentId = $this->getObjId();
1009
1010 // duplicate the question in database
1011 $clone = $this;
1012 $clone->id = -1;
1013
1014 $clone->setObjId($targetParentId);
1015
1016 if ($targetQuestionTitle) {
1017 $clone->setTitle($targetQuestionTitle);
1018 }
1019
1020 $clone->saveToDb();
1021
1022 if ($this->gap_combinations_exists) {
1023 $this->copyGapCombination($sourceQuestionId, $clone->getId());
1024 $clone->saveToDb();
1025 }
1026 // copy question page content
1027 $clone->copyPageOfQuestion($sourceQuestionId);
1028 // copy XHTML media objects
1029 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
1030
1031 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
1032
1033 return $clone->id;
1034 }

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

+ 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 @access public
See also
$gaps

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

1074 {
1075 if (array_key_exists($gap_index, $this->gaps)) {
1076 if ($this->gaps[$gap_index]->getItemCount() == 1) {
1077 // this is the last answer text => remove the gap
1078 $this->deleteGap($gap_index);
1079 } else {
1080 // remove the answer text
1081 $this->gaps[$gap_index]->deleteItem($answer_index);
1082 $this->updateClozeTextFromGaps();
1083 }
1084 }
1085 }
updateClozeTextFromGaps()
Updates the gap parameters in the cloze text from the form input.
deleteGap($gap_index)
Deletes a gap with a given index.

References deleteGap(), and updateClozeTextFromGaps().

+ 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 @access public
See also
$gaps

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

1096 {
1097 if (array_key_exists($gap_index, $this->gaps)) {
1098 $output = $this->getClozeText();
1099 foreach ($this->getGaps() as $replace_gap_index => $gap) {
1100 $answers = array();
1101 foreach ($gap->getItemsRaw() as $item) {
1102 array_push($answers, str_replace(",", "\\,", $item->getAnswerText()));
1103 }
1104 if ($replace_gap_index == $gap_index) {
1105 // fau: fixGapReplace - use replace function
1106 $output = $this->replaceFirstGap($output, '');
1107// fau.
1108 } else {
1109 // fau: fixGapReplace - use replace function
1110 $output = $this->replaceFirstGap($output, "[_gap]" . join(",", $answers) . "[/_gap]");
1111// fau.
1112 }
1113 }
1114 $output = str_replace("_gap]", "gap]", $output);
1115 $this->cloze_text = $output;
1116 unset($this->gaps[$gap_index]);
1117 $this->gaps = array_values($this->gaps);
1118 }
1119 }
getGaps()
Returns the array of gaps.
replaceFirstGap($gaptext, $content)
Replace the first gap in a string without treating backreferences.

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

Referenced by deleteAnswerText().

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

@access public

Reimplemented from assQuestion.

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

907 {
908 if ($this->id <= 0) {
909 // The question has not been saved. It cannot be duplicated
910 return;
911 }
912 // duplicate the question in database
913 $this_id = $this->getId();
914 $thisObjId = $this->getObjId();
915
916 $clone = $this;
917 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
919 $clone->id = -1;
920
921 if ((int) $testObjId > 0) {
922 $clone->setObjId($testObjId);
923 }
924
925 if ($title) {
926 $clone->setTitle($title);
927 }
928 if ($author) {
929 $clone->setAuthor($author);
930 }
931 if ($owner) {
932 $clone->setOwner($owner);
933 }
934 if ($for_test) {
935 $clone->saveToDb($original_id);
936 } else {
937 $clone->saveToDb();
938 }
939 if ($this->gap_combinations_exists) {
940 $this->copyGapCombination($this_id, $clone->getId());
941 }
942 if ($for_test) {
943 $clone->saveToDb($original_id);
944 } else {
945 $clone->saveToDb();
946 }
947 // copy question page content
948 $clone->copyPageOfQuestion($this_id);
949 // copy XHTML media objects
950 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
951
952 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
953
954 return $clone->getId();
955 }

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

+ Here is the call graph for this function:

◆ fetchAnswerValueForGap()

assClozeTest::fetchAnswerValueForGap (   $userSolution,
  $gapIndex 
)

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

1966 {
1967 $answerValue = '';
1968
1969 foreach ($userSolution as $value1 => $value2) {
1970 if ($value1 == $gapIndex) {
1971 $answerValue = $value2;
1972 break;
1973 }
1974 }
1975
1976 return $answerValue;
1977 }

◆ fetchSolutionSubmit()

assClozeTest::fetchSolutionSubmit (   $submit)

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

1301 {
1302 $solutionSubmit = array();
1303
1304 foreach ($submit as $key => $value) {
1305 if (preg_match("/^gap_(\d+)/", $key, $matches)) {
1306 $value = ilUtil::stripSlashes($value, false);
1307 if (strlen($value)) {
1308 $gap = $this->getGap($matches[1]);
1309 if (is_object($gap)) {
1310 if (!(($gap->getType() == CLOZE_SELECT) && ($value == -1))) {
1311 if ($gap->getType() == CLOZE_NUMERIC && !is_numeric(str_replace(",", ".", $value))) {
1312 $value = null;
1313 } else if ($gap->getType() == CLOZE_NUMERIC) {
1314 $value = str_replace(",", ".", $value);
1315 }
1316 $solutionSubmit[trim($matches[1])] = $value;
1317 }
1318 }
1319 }
1320 }
1321 }
1322
1323 return $solutionSubmit;
1324 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References CLOZE_NUMERIC, CLOZE_SELECT, getGap(), and ilUtil\stripSlashes().

Referenced by getSolutionSubmit().

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

@access public

See also
$gaps

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

537 {
538 $this->gaps = array();
539 }

◆ getAdditionalTableName()

assClozeTest::getAdditionalTableName ( )

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

Returns
string The additional table name @access public

Reimplemented from assQuestion.

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

1487 {
1488 return "qpl_qst_cloze";
1489 }

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

+ 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 @access public

Reimplemented from assQuestion.

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

1498 {
1499 return array("qpl_a_cloze",'qpl_a_cloze_combi_res');
1500 }

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

1774 {
1775 if ($index !== null) {
1776 return $this->getGap($index);
1777 } else {
1778 return $this->getGaps();
1779 }
1780 }

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

+ Here is the call graph for this function:

◆ getClozeText()

assClozeTest::getClozeText ( )

Returns the cloze text.

Returns
string The cloze text string @access public
See also
$cloze_text

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

571 {
572 return $this->cloze_text;
573 }

References $cloze_text.

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

+ Here is the caller graph for this function:

◆ getEndTag()

assClozeTest::getEndTag ( )

Returns the end tag of a cloze gap.

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

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

607 {
608 return $this->end_tag;
609 }

References $end_tag.

◆ getExpressionTypes()

◆ getFeedbackMode()

assClozeTest::getFeedbackMode ( )
Returns
string

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

627 {
628 return $this->feedbackMode;
629 }

References $feedbackMode.

Referenced by saveAdditionalQuestionDataToDb().

+ 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 @access public

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

1520 {
1522 }

References $fixedTextLength.

Referenced by saveAdditionalQuestionDataToDb().

+ 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 @access public
See also
$gaps

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

753 {
754 if (array_key_exists($gap_index, $this->gaps)) {
755 return $this->gaps[$gap_index];
756 } else {
757 return null;
758 }
759 }

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

+ Here is the caller graph for this function:

◆ getGapCombinations()

assClozeTest::getGapCombinations ( )

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

1562 {
1564 }

References $gap_combinations.

◆ getGapCombinationsExists()

assClozeTest::getGapCombinationsExists ( )

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

1557 {
1559 }

References $gap_combinations_exists.

◆ getGapCount()

assClozeTest::getGapCount ( )

Returns the number of gaps.

Returns
integer The number of gaps @access public
See also
$gaps

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

715 {
716 if (is_array($this->gaps)) {
717 return count($this->gaps);
718 } else {
719 return 0;
720 }
721 }

◆ getGaps()

assClozeTest::getGaps ( )

Returns the array of gaps.

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

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

525 {
526 return $this->gaps;
527 }

References $gaps.

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

+ 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 @access User interface

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

1464 {
1465 return ($this->identical_scoring) ? 1 : 0;
1466 }

Referenced by calculateReachedPointsForSolution(), and saveAdditionalQuestionDataToDb().

+ 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 @access public
See also
$points

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

1533 {
1534 $points = 0;
1535 $gap_max_points = 0;
1536 if (array_key_exists($gap_index, $this->gaps)) {
1537 $gap = &$this->gaps[$gap_index];
1538 foreach ($gap->getItems($this->getShuffler()) as $answer) {
1539 if ($answer->getPoints() > $gap_max_points) {
1540 $gap_max_points = $answer->getPoints();
1541 }
1542 }
1543 $points += $gap_max_points;
1544 }
1545 return $points;
1546 }

References assQuestion\$points.

Referenced by calculateReachedPointsForSolution().

+ Here is the caller graph for this function:

◆ getMaximumPoints()

assClozeTest::getMaximumPoints ( )

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

@access public

See also
$points

Reimplemented from assQuestion.

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

860 {
861 $assClozeGapCombinationObj = new assClozeGapCombination();
862 $points = 0;
863 $gaps_used_in_combination = array();
864 if ($assClozeGapCombinationObj->combinationExistsForQid($this->getId())) {
865 $points = $assClozeGapCombinationObj->getMaxPointsForCombination($this->getId());
866 $gaps_used_in_combination = $assClozeGapCombinationObj->getGapsWhichAreUsedInCombination($this->getId());
867 }
868 foreach ($this->gaps as $gap_index => $gap) {
869 if (!array_key_exists($gap_index, $gaps_used_in_combination)) {
870 if ($gap->getType() == CLOZE_TEXT) {
871 $gap_max_points = 0;
872 foreach ($gap->getItems($this->getShuffler()) as $item) {
873 if ($item->getPoints() > $gap_max_points) {
874 $gap_max_points = $item->getPoints();
875 }
876 }
877 $points += $gap_max_points;
878 } elseif ($gap->getType() == CLOZE_SELECT) {
879 $srpoints = 0;
880 foreach ($gap->getItems($this->getShuffler()) as $item) {
881 if ($item->getPoints() > $srpoints) {
882 $srpoints = $item->getPoints();
883 }
884 }
885 $points += $srpoints;
886 } elseif ($gap->getType() == CLOZE_NUMERIC) {
887 $numpoints = 0;
888 foreach ($gap->getItems($this->getShuffler()) as $item) {
889 if ($item->getPoints() > $numpoints) {
890 $numpoints = $item->getPoints();
891 }
892 }
893 $points += $numpoints;
894 }
895 }
896 }
897
898 return $points;
899 }

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

Referenced by isComplete().

+ 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 @access public

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

1185 {
1186 // fau: fixGapFormula - check entered value by evalMath
1187 // if( ! $this->checkForValidFormula($a_entered) )
1188 // {
1189 // return 0;
1190 // }
1191
1192 include_once "./Services/Math/classes/class.EvalMath.php";
1193 $eval = new EvalMath();
1194 $eval->suppress_errors = true;
1195 $result = 0;
1196
1197 if ($eval->e($a_entered) === false) {
1198 return 0;
1199 } elseif (($eval->e($lowerBound) !== false) && ($eval->e($upperBound) !== false)) {
1200 // fau.
1201 if (($eval->e($a_entered) >= $eval->e($lowerBound)) && ($eval->e($a_entered) <= $eval->e($upperBound))) {
1202 $result = $max_points;
1203 }
1204 } elseif ($eval->e($lowerBound) !== false) {
1205 if (($eval->e($a_entered) >= $eval->e($lowerBound)) && ($eval->e($a_entered) <= $eval->e($a_original))) {
1206 $result = $max_points;
1207 }
1208 } elseif ($eval->e($upperBound) !== false) {
1209 if (($eval->e($a_entered) >= $eval->e($a_original)) && ($eval->e($a_entered) <= $eval->e($upperBound))) {
1210 $result = $max_points;
1211 }
1212 } else {
1213 if ($eval->e($a_entered) == $eval->e($a_original)) {
1214 $result = $max_points;
1215 }
1216 }
1217 return $result;
1218 }

References $result.

Referenced by calculateCombinationResult(), and calculateReachedPointsForSolution().

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

1687 {
1688 require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1690 }

References ilOperatorsExpressionMapping\getOperatorsByExpression().

+ 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 @access public

Reimplemented from assQuestion.

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

1415 {
1416 return "assClozeTest";
1417 }

Referenced by toJSON().

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

Reimplemented from assQuestion.

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

1553 {
1554 return parent::getRTETextWithMediaObjects() . $this->getClozeText();
1555 }

References getClozeText().

+ Here is the call graph for this function:

◆ getSolutionSubmit()

assClozeTest::getSolutionSubmit ( )

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

1352 {
1353 return $this->fetchSolutionSubmit($_POST);
1354 }
$_POST["username"]
fetchSolutionSubmit($submit)

References $_POST, and fetchSolutionSubmit().

Referenced by saveWorkingData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSolutionSubmitValidation()

assClozeTest::getSolutionSubmitValidation ( )

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

1327 {
1328 $submit = $_POST;
1329 $solutionSubmit = array();
1330
1331 foreach ($submit as $key => $value) {
1332 if (preg_match("/^gap_(\d+)/", $key, $matches)) {
1333 $value = ilUtil::stripSlashes($value, false);
1334 if (strlen($value)) {
1335 $gap = $this->getGap($matches[1]);
1336 if (is_object($gap)) {
1337 if (!(($gap->getType() == CLOZE_SELECT) && ($value == -1))) {
1338 if ($gap->getType() == CLOZE_NUMERIC) {
1339 $value = str_replace(",", ".", $value);
1340 }
1341 $solutionSubmit[trim($matches[1])] = $value;
1342 }
1343 }
1344 }
1345 }
1346 }
1347
1348 return $solutionSubmit;
1349 }

References $_POST, CLOZE_NUMERIC, CLOZE_SELECT, getGap(), and ilUtil\stripSlashes().

Referenced by validateSolutionSubmit().

+ 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 @access public
See also
$start_tag

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

583 {
584 return $this->start_tag;
585 }

References $start_tag.

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

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

1131 {
1132 include_once "./Services/Utilities/classes/class.ilStr.php";
1133 $result = 0;
1134 $gaprating = $this->getTextgapRating();
1135 switch ($gaprating) {
1137 if (strcmp(ilStr::strToLower($a_original), ilStr::strToLower($a_entered)) == 0) {
1138 $result = $max_points;
1139 }
1140 break;
1142 if (strcmp($a_original, $a_entered) == 0) {
1143 $result = $max_points;
1144 }
1145 break;
1147 if (levenshtein($a_original, $a_entered) <= 1) {
1148 $result = $max_points;
1149 }
1150 break;
1152 if (levenshtein($a_original, $a_entered) <= 2) {
1153 $result = $max_points;
1154 }
1155 break;
1157 if (levenshtein($a_original, $a_entered) <= 3) {
1158 $result = $max_points;
1159 }
1160 break;
1162 if (levenshtein($a_original, $a_entered) <= 4) {
1163 $result = $max_points;
1164 }
1165 break;
1167 if (levenshtein($a_original, $a_entered) <= 5) {
1168 $result = $max_points;
1169 }
1170 break;
1171 }
1172 return $result;
1173 }
getTextgapRating()
Returns the rating option for text gaps.
static strToLower($a_string)
Definition: class.ilStr.php:87
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_CASEINSENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN1

References $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().

+ 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 @access User interface

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

1427 {
1428 return $this->textgap_rating;
1429 }

References $textgap_rating.

Referenced by getTextgapPoints(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ isAddableAnswerOptionValue()

assClozeTest::isAddableAnswerOptionValue (   $qIndex,
  $answerOptionValue 
)

Reimplemented from assQuestion.

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

1980 {
1981 $gap = $this->getGap($qIndex);
1982
1983 if ($gap->getType() != CLOZE_TEXT) {
1984 return false;
1985 }
1986
1987 foreach ($gap->getItems(new ilArrayElementOrderKeeper()) as $item) {
1988 if ($item->getAnswertext() == $answerOptionValue) {
1989 return false;
1990 }
1991 }
1992
1993 return true;
1994 }

References CLOZE_TEXT, and getGap().

+ 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

Reimplemented from assQuestion.

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

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.
getTitle()
Gets the title string of the assQuestion object.
getAuthor()
Gets the authors name of the assQuestion object.

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

+ Here is the call graph for this function:

◆ isValidNumericSubmitValue()

assClozeTest::isValidNumericSubmitValue (   $submittedValue)
protected

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

1270 {
1271 if (is_numeric($submittedValue)) {
1272 return true;
1273 }
1274
1275 if (preg_match('/^[-+]{0,1}\d+\/\d+$/', $submittedValue)) {
1276 return true;
1277 }
1278
1279 return false;
1280 }

Referenced by validateSolutionSubmit().

+ Here is the caller graph for this function:

◆ lmMigrateQuestionTypeSpecificContent()

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

Reimplemented from assQuestion.

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

1619 {
1620 // DO NOT USE SETTER FOR CLOZE TEXT -> SETTER DOES RECREATE GAP OBJECTS without having gap type info ^^
1621 //$this->setClozeText( $migrator->migrateToLmContent($this->getClozeText()) );
1622 $this->cloze_text = $migrator->migrateToLmContent($this->getClozeText());
1623 // DO NOT USE SETTER FOR CLOZE TEXT -> SETTER DOES RECREATE GAP OBJECTS without having gap type info ^^
1624 }

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

+ 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

Reimplemented from assQuestion.

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

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

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().

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

177 {
178 $content = str_replace('$','GAPMASKEDDOLLAR', $content);
179 $output = preg_replace("/\[gap\].*?\[\/gap\]/", $content, $gaptext, 1);
180 $output = str_replace('GAPMASKEDDOLLAR', '$', $output);
181
182 return $output;
183 }

Referenced by deleteGap(), and updateClozeTextFromGaps().

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

344 {
345 global $DIC; /* @var ILIAS\DI\Container $DIC */
346
347
348 $DIC->database()->manipulateF(
349 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
350 array( "integer" ),
351 array( $this->getId() )
352 );
353
354 $DIC->database()->insert($this->getAdditionalTableName(), array(
355 'question_fi' => array('integer', $this->getId()),
356 'textgap_rating' => array('text', $this->getTextgapRating()),
357 'identical_scoring' => array('text', $this->getIdenticalScoring()),
358 'fixed_textlen' => array('integer', $this->getFixedTextLength() ? $this->getFixedTextLength() : null),
359 'cloze_text' => array('text', ilRTE::_replaceMediaObjectImageSrc($this->getClozeText(), 0)),
360 'feedback_mode' => array('text', $this->getFeedbackMode())
361 ));
362 }
getFixedTextLength()
Gets the fixed text length for all text fields in the cloze question.

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

Referenced by saveToDb().

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

323 {
324 global $DIC;
325 $ilDB = $DIC['ilDB'];
326
327 $ilDB->manipulateF(
328 "DELETE FROM qpl_a_cloze WHERE question_fi = %s",
329 array( "integer" ),
330 array( $this->getId() )
331 );
332
333 foreach ($this->gaps as $key => $gap) {
334 $this->saveClozeGapItemsToDb($gap, $key);
335 }
336 }
saveClozeGapItemsToDb($gap, $key)
Save all items belonging to one cloze gap to the db.

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

Referenced by saveToDb().

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

371 {
372 global $DIC;
373 $ilDB = $DIC['ilDB'];
374 foreach ($gap->getItems($this->getShuffler()) as $item) {
375 $query = "";
376 $next_id = $ilDB->nextId('qpl_a_cloze');
377 switch ($gap->getType()) {
378 case CLOZE_TEXT:
379 $this->saveClozeTextGapRecordToDb($next_id, $key, $item, $gap);
380 break;
381 case CLOZE_SELECT:
382 $this->saveClozeSelectGapRecordToDb($next_id, $key, $item, $gap);
383 break;
384 case CLOZE_NUMERIC:
385 $this->saveClozeNumericGapRecordToDb($next_id, $key, $item, $gap);
386 break;
387 }
388 }
389 }
saveClozeTextGapRecordToDb($next_id, $key, $item, $gap)
Saves a gap-item record.
saveClozeSelectGapRecordToDb($next_id, $key, $item, $gap)
Saves a gap-item record.
saveClozeNumericGapRecordToDb($next_id, $key, $item, $gap)
Saves a gap-item record.
$query

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

Referenced by saveAnswerSpecificDataToDb().

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

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

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

Referenced by saveClozeGapItemsToDb().

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

437 {
438 global $DIC;
439 $ilDB = $DIC['ilDB'];
440 $ilDB->manipulateF(
441 "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)",
442 array(
443 "integer",
444 "integer",
445 "integer",
446 "text",
447 "float",
448 "integer",
449 "text",
450 "text"
451 ),
452 array(
453 $next_id,
454 $this->getId(),
455 $key,
456 strlen($item->getAnswertext()) ? $item->getAnswertext() : "",
457 $item->getPoints(),
458 $item->getOrder(),
459 $gap->getType(),
460 ($gap->getShuffle()) ? "1" : "0"
461 )
462 );
463 }

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

Referenced by saveClozeGapItemsToDb().

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

400 {
401 global $DIC;
402 $ilDB = $DIC['ilDB'];
403 $ilDB->manipulateF(
404 "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)",
405 array(
406 "integer",
407 "integer",
408 "integer",
409 "text",
410 "float",
411 "integer",
412 "text",
413 "integer"
414 ),
415 array(
416 $next_id,
417 $this->getId(),
418 $key,
419 strlen($item->getAnswertext()) ? $item->getAnswertext() : "",
420 $item->getPoints(),
421 $item->getOrder(),
422 $gap->getType(),
423 (int) $gap->getGapSize()
424 )
425 );
426 }

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

Referenced by saveClozeGapItemsToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePartial()

assClozeTest::savePartial ( )

Reimplemented from assQuestion.

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

2007 {
2008 return true;
2009 }

◆ saveToDb()

assClozeTest::saveToDb (   $original_id = "")

Saves a assClozeTest object to a database.

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

@access public

Reimplemented from assQuestion.

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

311 {
315
316 parent::saveToDb($original_id);
317 }
saveAnswerSpecificDataToDb()
Save all gaps to the database.
saveAdditionalQuestionDataToDb()
Saves the data for the additional data table.
saveQuestionDataToDb($original_id="")

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

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

@access public

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

Reimplemented from assQuestion.

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

1365 {
1366 global $DIC;
1367 $ilDB = $DIC['ilDB'];
1368 $ilUser = $DIC['ilUser'];
1369 if (is_null($pass)) {
1370 include_once "./Modules/Test/classes/class.ilObjTest.php";
1371 $pass = ilObjTest::_getPass($active_id);
1372 }
1373
1374 $entered_values = 0;
1375
1376 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $active_id, $pass, $authorized) {
1377 $this->removeCurrentSolution($active_id, $pass, $authorized);
1378
1379 foreach ($this->getSolutionSubmit() as $val1 => $val2) {
1380 $value = trim(ilUtil::stripSlashes($val2, false));
1381 if (strlen($value)) {
1382 $gap = $this->getGap(trim(ilUtil::stripSlashes($val1)));
1383 if (is_object($gap)) {
1384 if (!(($gap->getType() == CLOZE_SELECT) && ($value == -1))) {
1385 $this->saveCurrentSolution($active_id, $pass, $val1, $value, $authorized);
1386 $entered_values++;
1387 }
1388 }
1389 }
1390 }
1391 });
1392
1393 if ($entered_values) {
1394 include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1396 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1397 }
1398 } else {
1399 include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1401 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1402 }
1403 }
1404
1405 return true;
1406 }
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
removeCurrentSolution($active_id, $pass, $authorized=true)
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
$ilUser
Definition: imgupload.php:18

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

+ 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 @access public
See also
$cloze_text

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

551 {
552 $this->gaps = array();
554 $this->cloze_text = $cloze_text;
556 }
createGapsFromQuestiontext()
Create gap entries by parsing the question text.

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

Referenced by loadFromDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setClozeTextValue()

assClozeTest::setClozeTextValue (   $cloze_text = "")

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

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

References $cloze_text.

◆ setEndTag()

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

Sets the end tag of a cloze gap.

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

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

619 {
620 $this->end_tag = $end_tag;
621 }

References $end_tag.

◆ setExportDetailsXLS()

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

{Creates an Excel worksheet for the detailed cumulated results of this question.

Parameters
object$worksheetReference to the parent excel worksheet
object$startrowStartrow of the output in the excel worksheet
object$active_idActive id of the participant
object$passTest pass
Returns
object
}

Reimplemented from assQuestion.

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

1580 {
1581 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
1582
1583 $solution = $this->getSolutionValues($active_id, $pass);
1584 $i = 1;
1585 foreach ($this->getGaps() as $gap_index => $gap) {
1586 $worksheet->setCell($startrow + $i, 0, $this->lng->txt("gap") . " $i");
1587 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
1588 $checked = false;
1589 foreach ($solution as $solutionvalue) {
1590 if ($gap_index == $solutionvalue["value1"]) {
1591 $string_escaping_org_value = $worksheet->getStringEscaping();
1592 try {
1593 $worksheet->setStringEscaping(false);
1594
1595 switch ($gap->getType()) {
1596 case CLOZE_SELECT:
1597 $worksheet->setCell($startrow + $i, 1, $gap->getItem($solutionvalue["value2"])->getAnswertext());
1598 break;
1599 case CLOZE_NUMERIC:
1600 case CLOZE_TEXT:
1601 $worksheet->setCell($startrow + $i, 1, $solutionvalue["value2"]);
1602 break;
1603 }
1604 } finally {
1605 $worksheet->setStringEscaping($string_escaping_org_value);
1606 }
1607 }
1608 }
1609 $i++;
1610 }
1611
1612 return $startrow + $i + 1;
1613 }
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
$i
Definition: metadata.php:24

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

+ Here is the call graph for this function:

◆ setFeedbackMode()

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

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

635 {
636 $this->feedbackMode = $feedbackMode;
637 }

References $feedbackMode.

Referenced by loadFromDb().

+ 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 @access public

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

1509 {
1510 $this->fixedTextLength = $a_text_len;
1511 }

Referenced by loadFromDb().

+ 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 @access public
See also
$gaps

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

830 {
831 if (array_key_exists($gap_index, $this->gaps)) {
832 $this->gaps[$gap_index]->setItemLowerBound($order, $bound);
833 }
834 }

◆ 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 @access public
See also
$gaps

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

779 {
780 if (array_key_exists($gap_index, $this->gaps)) {
781 $this->gaps[$gap_index]->setItemPoints($order, $points);
782 }
783 }

References assQuestion\$points.

◆ 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 @access public
See also
$gaps

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

847 {
848 if (array_key_exists($gap_index, $this->gaps)) {
849 $this->gaps[$gap_index]->setItemUpperBound($order, $bound);
850 }
851 }

◆ setGapCombinations()

assClozeTest::setGapCombinations (   $value)

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

1572 {
1573 $this->gap_combinations = $value;
1574 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setGapCombinationsExists()

assClozeTest::setGapCombinationsExists (   $value)

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

1567 {
1568 $this->gap_combinations_exists = $value;
1569 }

Referenced by loadFromDb().

+ 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) @access public
See also
$gaps

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

688 {
689 if (array_key_exists($gap_index, $this->gaps)) {
690 $this->gaps[$gap_index]->setShuffle($shuffle);
691 }
692 }

References assQuestion\$shuffle.

◆ setGapSize()

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

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

762 {
763 if (array_key_exists($gap_index, $this->gaps)) {
764 $this->gaps[$gap_index]->setGapSize($size);
765 }
766 }
$size
Definition: RandomTest.php:84

References $size.

◆ setGapType()

assClozeTest::setGapType (   $gap_index,
  $gap_type 
)

Set the type of a gap with a given index.

@access private

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

672 {
673 if (array_key_exists($gap_index, $this->gaps)) {
674 $this->gaps[$gap_index]->setType($gap_type);
675 }
676 }

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

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

1476 {
1477 $this->identical_scoring = ($a_identical_scoring) ? 1 : 0;
1478 }

Referenced by loadFromDb().

+ 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 @access public
See also
$start_tag

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

595 {
596 $this->start_tag = $start_tag;
597 }

References $start_tag.

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

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

1439 {
1440 switch ($a_textgap_rating) {
1448 $this->textgap_rating = $a_textgap_rating;
1449 break;
1450 default:
1451 $this->textgap_rating = TEXTGAP_RATING_CASEINSENSITIVE;
1452 break;
1453 }
1454 }

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().

+ Here is the caller graph for this function:

◆ toJSON()

assClozeTest::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

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

1630 {
1631 include_once("./Services/RTE/classes/class.ilRTE.php");
1632 $result = array();
1633 $result['id'] = (int) $this->getId();
1634 $result['type'] = (string) $this->getQuestionType();
1635 $result['title'] = (string) $this->getTitle();
1636 $result['question'] = $this->formatSAQuestion($this->getQuestion());
1637 $result['clozetext'] = $this->formatSAQuestion($this->getClozeText());
1638 $result['nr_of_tries'] = (int) $this->getNrOfTries();
1639 $result['shuffle'] = (bool) $this->getShuffle();
1640 $result['feedback'] = array(
1641 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1642 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1643 );
1644
1645 $gaps = array();
1646 foreach ($this->getGaps() as $key => $gap) {
1647 $items = array();
1648 foreach ($gap->getItems($this->getShuffler()) as $item) {
1649 $jitem = array();
1650 $jitem['points'] = $item->getPoints();
1651 $jitem['value'] = $this->formatSAQuestion($item->getAnswertext());
1652 $jitem['order'] = $item->getOrder();
1653 if ($gap->getType() == CLOZE_NUMERIC) {
1654 $jitem['lowerbound'] = $item->getLowerBound();
1655 $jitem['upperbound'] = $item->getUpperBound();
1656 } else {
1657 $jitem['value'] = trim($jitem['value']);
1658 }
1659 array_push($items, $jitem);
1660 }
1661
1662 if ($gap->getGapSize() && ($gap->getType() == CLOZE_TEXT || $gap->getType() == CLOZE_NUMERIC)) {
1663 $jgap['size'] = $gap->getGapSize();
1664 }
1665
1666 $jgap['shuffle'] = $gap->getShuffle();
1667 $jgap['type'] = $gap->getType();
1668 $jgap['item'] = $items;
1669
1670 array_push($gaps, $jgap);
1671 }
1672 $result['gaps'] = $gaps;
1673 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1674 $result['mobs'] = $mobs;
1675 return json_encode($result);
1676 }
getQuestionType()
Returns the question type of the question.
formatSAQuestion($a_q)
Format self assessment question.
getShuffle()
Gets the shuffle flag.
getQuestion()
Gets the question string of the question object.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
$mobs

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().

+ Here is the call graph for this function:

◆ updateClozeTextFromGaps()

assClozeTest::updateClozeTextFromGaps ( )

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

@access private

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

1049 {
1050 $output = $this->getClozeText();
1051 foreach ($this->getGaps() as $gap_index => $gap) {
1052 $answers = array();
1053 foreach ($gap->getItemsRaw() as $item) {
1054 array_push($answers, str_replace(",", "\\,", $item->getAnswerText()));
1055 }
1056 // fau: fixGapReplace - use replace function
1057 $output = $this->replaceFirstGap($output, "[_gap]" . $this->prepareTextareaOutput(join(",", $answers), true) . "[/_gap]");
1058// fau.
1059 }
1060 $output = str_replace("_gap]", "gap]", $output);
1061 $this->cloze_text = $output;
1062 }
prepareTextareaOutput($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output in tests.

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

Referenced by deleteAnswerText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateSolutionSubmit()

assClozeTest::validateSolutionSubmit ( )

Reimplemented from assQuestion.

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

1283 {
1284 foreach ($this->getSolutionSubmitValidation() as $gapIndex => $value) {
1285 $gap = $this->getGap($gapIndex);
1286
1287 if ($gap->getType() != CLOZE_NUMERIC) {
1288 continue;
1289 }
1290
1291 if (strlen($value) && !$this->isValidNumericSubmitValue($value)) {
1292 ilUtil::sendFailure($this->lng->txt("err_no_numeric_value"), true);
1293 return false;
1294 }
1295 }
1296
1297 return true;
1298 }
isValidNumericSubmitValue($submittedValue)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

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

+ 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 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: