ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 
 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...
 
 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)
 
 getSolutionSubmit ()
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getTextgapRating ()
 Returns the rating option for text gaps. More...
 
 setTextgapRating ($a_textgap_rating)
 Sets the rating option for text gaps. More...
 
 getIdenticalScoring ()
 Returns the identical scoring status of the question. More...
 
 setIdenticalScoring ($a_identical_scoring)
 Sets the identical scoring option for cloze questions. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 setFixedTextLength ($a_text_len)
 Sets a fixed text length for all text fields in the cloze question. More...
 
 getFixedTextLength ()
 Gets the fixed text length for all text fields in the cloze question. More...
 
 getMaximumGapPoints ($gap_index)
 Returns the maximum points for a gap. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 getGapCombinationsExists ()
 
 getGapCombinations ()
 
 setGapCombinationsExists ($value)
 
 setGapCombinations ($value)
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 {} More...
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 
 calculateCombinationResult ($user_result)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
- 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...
 
 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 ()
 
 createRandomSolution ($test_id, $user_id)
 
 _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)
 
 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...
 
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 

Data Fields

 $gaps
 
 $gap_combinations
 
 $gap_combinations_exists
 
 $start_tag
 
 $end_tag
 
 $textgap_rating
 
 $identical_scoring
 
 $fixedTextLength
 
 $cloze_text
 
- 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)
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered, $authorized)
 {} More...
 
 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)
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered, $authorized)
 Reworks the allready saved working data if neccessary. More...
 
 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)
 
 deleteSolutionRecordByValues ($activeId, $passIndex, $authorized, $matchValues)
 
 duplicateIntermediateSolutionAuthorized ($activeId, $passIndex)
 
 forceExistingIntermediateSolution ($activeId, $passIndex, $considerDummyRecordCreation)
 
 buildTestPresentationConfig ()
 build basic test question configuration instance More...
 

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ __construct()

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

assClozeTest constructor

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

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

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

References assQuestion\$author, assQuestion\$comment, assQuestion\$owner, assQuestion\$question, assQuestion\$title, array, and assQuestion\setQuestion().

115  {
116  parent::__construct($title, $comment, $author, $owner, $question);
117  $this->start_tag = "[gap]";
118  $this->end_tag = "[/gap]";
119  $this->gaps = array();
120  $this->setQuestion($question); // @TODO: Should this be $question?? See setter for why this is not trivial.
121  $this->fixedTextLength = "";
122  $this->identical_scoring = 1;
123  $this->gap_combinations_exists = false;
124  $this->gap_combinations = array();
125  }
Create styles array
The data for the language used.
setQuestion($question="")
Sets the question string of the question object.
+ Here is the call graph for this function:

Member Function Documentation

◆ addGapAnswer()

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

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

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

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

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

References CLOZE_NUMERIC.

687  {
688  if (array_key_exists($gap_index, $this->gaps)) {
689  if ($this->gaps[$gap_index]->getType() == CLOZE_NUMERIC) {
690  // only allow notation with "." for real numbers
691  $answer = str_replace(",", ".", $answer);
692  }
693  $this->gaps[$gap_index]->addItem(new assAnswerCloze($answer, 0, $order));
694  }
695  }
Class for cloze question numeric answers.
const CLOZE_NUMERIC

◆ addGapAtIndex()

assClozeTest::addGapAtIndex (   $gap,
  $index 
)

Adds a ClozeGap object at a given index.

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

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

References $index.

768  {
769  $this->gaps[$index] = $gap;
770  }
$index
Definition: metadata.php:60

◆ addGapText()

assClozeTest::addGapText (   $gap_index)

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

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

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

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

747  {
748  if (array_key_exists($gap_index, $this->gaps)) {
749  include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
750  $answer = new assAnswerCloze(
751  "",
752  0,
753  $this->gaps[$gap_index]->getItemCount()
754  );
755  $this->gaps[$gap_index]->addItem($answer);
756  }
757  }
Class for cloze question numeric answers.

◆ calculateCombinationResult()

assClozeTest::calculateCombinationResult (   $user_result)

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

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

Referenced by calculateReachedPointsForSolution().

1708  {
1709  $points = 0;
1710 
1711  $assClozeGapCombinationObj = new assClozeGapCombination();
1712 
1713  if ($assClozeGapCombinationObj->combinationExistsForQid($this->getId())) {
1714  $combinations_for_question = $assClozeGapCombinationObj->getCleanCombinationArray($this->getId());
1715  $gap_answers = array();
1716  $gap_used_in_combination = array();
1717  foreach ($user_result as $user_result_build_list) {
1718  if (is_array($user_result_build_list)) {
1719  $gap_answers[$user_result_build_list['gap_id']] = $user_result_build_list['value'];
1720  }
1721  }
1722 
1723  foreach ($combinations_for_question as $combination) {
1724  foreach ($combination as $row_key => $row_answers) {
1725  $combination_fulfilled = true;
1726  $points_for_combination = $row_answers['points'];
1727  foreach ($row_answers as $gap_key => $combination_gap_answer) {
1728  if ($gap_key !== 'points') {
1729  $gap_used_in_combination[$gap_key]= $gap_key;
1730  }
1731  if ($combination_fulfilled && array_key_exists($gap_key, $gap_answers)) {
1732  switch ($combination_gap_answer['type']) {
1733  case CLOZE_TEXT:
1734  $is_text_gap_correct = $this->getTextgapPoints($gap_answers[$gap_key], $combination_gap_answer['answer'], 1);
1735  if ($is_text_gap_correct != 1) {
1736  $combination_fulfilled = false;
1737  }
1738  break;
1739  case CLOZE_SELECT:
1740  $answer = $this->gaps[$gap_key]->getItem($gap_answers[$gap_key]);
1741  $answertext = $answer->getAnswertext();
1742  if ($answertext != $combination_gap_answer['answer']) {
1743  $combination_fulfilled = false;
1744  }
1745  break;
1746  case CLOZE_NUMERIC:
1747  $answer = $this->gaps[$gap_key]->getItem(0);
1748  if ($combination_gap_answer['answer'] != 'out_of_bound') {
1749  $is_numeric_gap_correct = $this->getNumericgapPoints($answer->getAnswertext(), $gap_answers[$gap_key], 1, $answer->getLowerBound(), $answer->getUpperBound());
1750  if ($is_numeric_gap_correct != 1) {
1751  $combination_fulfilled = false;
1752  }
1753  } else {
1754  $wrong_is_the_new_right = $this->getNumericgapPoints($answer->getAnswertext(), $gap_answers[$gap_key], 1, $answer->getLowerBound(), $answer->getUpperBound());
1755  if ($wrong_is_the_new_right == 1) {
1756  $combination_fulfilled = false;
1757  }
1758  }
1759  break;
1760  }
1761  } else {
1762  if ($gap_key !== 'points') {
1763  $combination_fulfilled = false;
1764  }
1765  }
1766  }
1767  if ($combination_fulfilled) {
1768  $points += $points_for_combination;
1769  }
1770  }
1771  }
1772  }
1773  return array($points, $gap_used_in_combination);
1774  }
getId()
Gets the id of the assQuestion object.
const CLOZE_TEXT
Cloze question constants.
getNumericgapPoints($a_original, $a_entered, $max_points, $lowerBound, $upperBound)
Returns the points for a text gap and compares the given solution with the entered solution using the...
getTextgapPoints($a_original, $a_entered, $max_points)
Returns the points for a text gap and compares the given solution with the entered solution using the...
const CLOZE_SELECT
Create styles array
The data for the language used.
const CLOZE_NUMERIC
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPoints()

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

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

The points are calculated from the given answers.

public

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

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

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

Referenced by getExpressionTypes().

1186  {
1187  global $ilDB;
1188 
1189  if (is_null($pass)) {
1190  $pass = $this->getSolutionMaxPass($active_id);
1191  }
1192 
1193  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized);
1194  $user_result = array();
1195  while ($data = $ilDB->fetchAssoc($result)) {
1196  if (strcmp($data["value2"], "") != 0) {
1197  $user_result[$data["value1"]] = array(
1198  "gap_id" => $data["value1"],
1199  "value" => $data["value2"]
1200  );
1201  }
1202  }
1203 
1204  ksort($user_result); // this is required when identical scoring for same solutions is disabled
1205 
1206  if ($returndetails) {
1207  $detailed = array();
1208  $this->calculateReachedPointsForSolution($user_result, $detailed);
1209  return $detailed;
1210  }
1211 
1212  return $this->calculateReachedPointsForSolution($user_result);
1213  }
$result
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Create styles array
The data for the language used.
global $ilDB
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
calculateReachedPointsForSolution($user_result, &$detailed=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsForSolution()

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

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

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

Referenced by calculateReachedPoints(), and calculateReachedPointsFromPreviewSession().

1781  {
1782  if ($detailed === null) {
1783  $detailed = array();
1784  }
1785 
1786  $assClozeGapCombinationObj = new assClozeGapCombination();
1787  $combinations[1] = array();
1788  if ($assClozeGapCombinationObj->combinationExistsForQid($this->getId())) {
1789  $combinations = $this->calculateCombinationResult($user_result);
1790  $points = $combinations[0];
1791  }
1792  $counter = 0;
1793  $solution_values_text = array(); // for identical scoring checks
1794  $solution_values_select = array(); // for identical scoring checks
1795  $solution_values_numeric = array(); // for identical scoring checks
1796  foreach ($user_result as $gap_id => $value) {
1797  if (is_string($value)) {
1798  $value = array("value" => $value);
1799  }
1800 
1801  if (array_key_exists($gap_id, $this->gaps) && !array_key_exists($gap_id, $combinations[1])) {
1802  switch ($this->gaps[$gap_id]->getType()) {
1803  case CLOZE_TEXT:
1804  $gappoints = 0;
1805  for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++) {
1806  $answer = $this->gaps[$gap_id]->getItem($order);
1807  $gotpoints = $this->getTextgapPoints($answer->getAnswertext(), $value["value"], $answer->getPoints());
1808  if ($gotpoints > $gappoints) {
1809  $gappoints = $gotpoints;
1810  }
1811  }
1812  if (!$this->getIdenticalScoring()) {
1813  // check if the same solution text was already entered
1814  if ((in_array($value["value"], $solution_values_text)) && ($gappoints > 0)) {
1815  $gappoints = 0;
1816  }
1817  }
1818  $points += $gappoints;
1819  $detailed[$gap_id] = array("points" => $gappoints, "best" => ($this->getMaximumGapPoints($gap_id) == $gappoints) ? true : false, "positive" => ($gappoints > 0) ? true : false);
1820  array_push($solution_values_text, $value["value"]);
1821  break;
1822  case CLOZE_NUMERIC:
1823  $gappoints = 0;
1824  for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++) {
1825  $answer = $this->gaps[$gap_id]->getItem($order);
1826  $gotpoints = $this->getNumericgapPoints($answer->getAnswertext(), $value["value"], $answer->getPoints(), $answer->getLowerBound(), $answer->getUpperBound());
1827  if ($gotpoints > $gappoints) {
1828  $gappoints = $gotpoints;
1829  }
1830  }
1831  if (!$this->getIdenticalScoring()) {
1832  // check if the same solution value was already entered
1833  include_once "./Services/Math/classes/class.EvalMath.php";
1834  $eval = new EvalMath();
1835  $eval->suppress_errors = true;
1836  $found_value = false;
1837  foreach ($solution_values_numeric as $solval) {
1838  if ($eval->e($solval) == $eval->e($value["value"])) {
1839  $found_value = true;
1840  }
1841  }
1842  if ($found_value && ($gappoints > 0)) {
1843  $gappoints = 0;
1844  }
1845  }
1846  $points += $gappoints;
1847  $detailed[$gap_id] = array("points" => $gappoints, "best" => ($this->getMaximumGapPoints($gap_id) == $gappoints) ? true : false, "positive" => ($gappoints > 0) ? true : false);
1848  array_push($solution_values_numeric, $value["value"]);
1849  break;
1850  case CLOZE_SELECT:
1851  if ($value["value"] >= 0) {
1852  for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++) {
1853  $answer = $this->gaps[$gap_id]->getItem($order);
1854  if ($value["value"] == $answer->getOrder()) {
1855  $answerpoints = $answer->getPoints();
1856  if (!$this->getIdenticalScoring()) {
1857  // check if the same solution value was already entered
1858  if ((in_array($answer->getAnswertext(), $solution_values_select)) && ($answerpoints > 0)) {
1859  $answerpoints = 0;
1860  }
1861  }
1862  $points += $answerpoints;
1863  $detailed[$gap_id] = array("points" => $answerpoints, "best" => ($this->getMaximumGapPoints($gap_id) == $answerpoints) ? true : false, "positive" => ($answerpoints > 0) ? true : false);
1864  array_push($solution_values_select, $answer->getAnswertext());
1865  }
1866  }
1867  }
1868  break;
1869  }
1870  }
1871  }
1872 
1873  return $points;
1874  }
getMaximumGapPoints($gap_index)
Returns the maximum points for a gap.
const CLOZE_TEXT
Cloze question constants.
calculateCombinationResult($user_result)
getNumericgapPoints($a_original, $a_entered, $max_points, $lowerBound, $upperBound)
Returns the points for a text gap and compares the given solution with the entered solution using the...
$counter
getTextgapPoints($a_original, $a_entered, $max_points)
Returns the points for a text gap and compares the given solution with the entered solution using the...
const CLOZE_SELECT
Create styles array
The data for the language used.
const CLOZE_NUMERIC
getIdenticalScoring()
Returns the identical scoring status of the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assClozeTest::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

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

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

1877  {
1878  $userSolution = array();
1879 
1880  foreach ($previewSession->getParticipantsSolution() as $key => $val) {
1881  // fau: fixEmptyGapPreview - add the gap_id as array index
1882  $userSolution[$key] = array('gap_id' => $key, 'value' => $val);
1883  // fau.
1884  }
1885 
1886  $reachedPoints = $this->calculateReachedPointsForSolution($userSolution);
1887  $reachedPoints = $this->deductHintPointsFromReachedPoints($previewSession, $reachedPoints);
1888 
1889  return $this->ensureNonNegativePoints($reachedPoints);
1890  }
ensureNonNegativePoints($points)
Create styles array
The data for the language used.
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
$key
Definition: croninfo.php:18
calculateReachedPointsForSolution($user_result, &$detailed=null)
+ Here is the call graph for this function:

◆ checkForValidFormula()

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

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

1172  {
1173  return preg_match("/^-?(\\d*)(,|\\.|\\/){0,1}(\\d*)$/", $value, $matches);
1174  }

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

References $text.

Referenced by loadFromDb(), and setClozeText().

152  {
153  $text = preg_replace("/\[gap[^\]]*?\]/", "[gap]", $text);
154  $text = preg_replace("/<gap([^>]*?)>/", "[gap]", $text);
155  $text = str_replace("</gap>", "[/gap]", $text);
156  return $text;
157  }
$text
Definition: errorreport.php:18
+ Here is the caller graph for this function:

◆ clearGapAnswers()

assClozeTest::clearGapAnswers ( )

Removes all answers from the gaps.

public

See also
$gaps

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

654  {
655  foreach ($this->gaps as $gap_index => $gap) {
656  $this->gaps[$gap_index]->clearItems();
657  }
658  }

◆ copyGapCombination()

assClozeTest::copyGapCombination (   $orgID,
  $newID 
)

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

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

990  {
991  $assClozeGapCombinationObj = new assClozeGapCombination();
992  $array = $assClozeGapCombinationObj->loadFromDb($orgID);
993  $assClozeGapCombinationObj->importGapCombinationToDb($newID, $array);
994  }
+ Here is the caller graph for this function:

◆ copyObject()

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

Copies an assClozeTest object.

public

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

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

916  {
917  if ($this->getId() <= 0) {
918  // The question has not been saved. It cannot be duplicated
919  return;
920  }
921 
922  $thisId = $this->getId();
923  $thisObjId = $this->getObjId();
924 
925  $clone = $this;
926  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
928  $clone->id = -1;
929  $clone->setObjId($target_questionpool_id);
930  if ($title) {
931  $clone->setTitle($title);
932  }
933 
934  $clone->saveToDb();
935 
936  if ($this->gap_combinations_exists) {
937  $this->copyGapCombination($original_id, $clone->getId());
938  $clone->saveToDb();
939  }
940 
941  // copy question page content
942  $clone->copyPageOfQuestion($original_id);
943  // copy XHTML media objects
944  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
945 
946  $clone->onCopy($thisObjId, $thisId, $clone->getObjId(), $clone->getId());
947 
948  return $clone->getId();
949  }
getId()
Gets the id of the assQuestion object.
static _getOriginalId($question_id)
Returns the original id of a question.
copyGapCombination($orgID, $newID)
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ createGapsFromQuestiontext()

assClozeTest::createGapsFromQuestiontext ( )

Create gap entries by parsing the question text.

public

See also
$gaps

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

References $key, array, CLOZE_TEXT, and getClozeText().

Referenced by setClozeText().

599  {
600  include_once "./Modules/TestQuestionPool/classes/class.assClozeGap.php";
601  include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
602  $search_pattern = "|\[gap\](.*?)\[/gap\]|i";
603  preg_match_all($search_pattern, $this->getClozeText(), $found);
604  $this->gaps = array();
605  if (count($found[0])) {
606  foreach ($found[1] as $gap_index => $answers) {
607  // create text gaps by default
608  $gap = new assClozeGap(CLOZE_TEXT);
609  $textparams = preg_split("/(?<!\\\\),/", $answers);
610  foreach ($textparams as $key => $value) {
611  $answer = new assAnswerCloze($value, 0, $key);
612  $gap->addItem($answer);
613  }
614  $this->gaps[$gap_index] = $gap;
615  }
616  }
617  }
Class for cloze question numeric answers.
const CLOZE_TEXT
Cloze question constants.
Class for cloze question gaps.
Create styles array
The data for the language used.
getClozeText()
Returns the cloze text.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

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

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

952  {
953  if ($this->id <= 0) {
954  // The question has not been saved. It cannot be duplicated
955  return;
956  }
957 
958  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
959 
960  $sourceQuestionId = $this->id;
961  $sourceParentId = $this->getObjId();
962 
963  // duplicate the question in database
964  $clone = $this;
965  $clone->id = -1;
966 
967  $clone->setObjId($targetParentId);
968 
969  if ($targetQuestionTitle) {
970  $clone->setTitle($targetQuestionTitle);
971  }
972 
973  $clone->saveToDb();
974 
975  if ($this->gap_combinations_exists) {
976  $this->copyGapCombination($sourceQuestionId, $clone->getId());
977  $clone->saveToDb();
978  }
979  // copy question page content
980  $clone->copyPageOfQuestion($sourceQuestionId);
981  // copy XHTML media objects
982  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
983 
984  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
985 
986  return $clone->id;
987  }
copyGapCombination($orgID, $newID)
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ deleteAnswerText()

assClozeTest::deleteAnswerText (   $gap_index,
  $answer_index 
)

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

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

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

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

References deleteGap(), and updateClozeTextFromGaps().

1025  {
1026  if (array_key_exists($gap_index, $this->gaps)) {
1027  if ($this->gaps[$gap_index]->getItemCount() == 1) {
1028  // this is the last answer text => remove the gap
1029  $this->deleteGap($gap_index);
1030  } else {
1031  // remove the answer text
1032  $this->gaps[$gap_index]->deleteItem($answer_index);
1033  $this->updateClozeTextFromGaps();
1034  }
1035  }
1036  }
deleteGap($gap_index)
Deletes a gap with a given index.
updateClozeTextFromGaps()
Updates the gap parameters in the cloze text from the form input.
+ Here is the call graph for this function:

◆ deleteGap()

assClozeTest::deleteGap (   $gap_index)

Deletes a gap with a given index.

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

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

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

References $output, array, getClozeText(), and getGaps().

Referenced by deleteAnswerText().

1047  {
1048  if (array_key_exists($gap_index, $this->gaps)) {
1049  $output = $this->getClozeText();
1050  foreach ($this->getGaps() as $replace_gap_index => $gap) {
1051  $answers = array();
1052  foreach ($gap->getItemsRaw() as $item) {
1053  array_push($answers, str_replace(",", "\\,", $item->getAnswerText()));
1054  }
1055  if ($replace_gap_index == $gap_index) {
1056  $output = preg_replace("/\[gap\].*?\[\/gap\]/", "", $output, 1);
1057  } else {
1058  $output = preg_replace("/\[gap\].*?\[\/gap\]/", "[_gap]" . join(",", $answers) . "[/_gap]", $output, 1);
1059  }
1060  }
1061  $output = str_replace("_gap]", "gap]", $output);
1062  $this->cloze_text = $output;
1063  unset($this->gaps[$gap_index]);
1064  $this->gaps = array_values($this->gaps);
1065  }
1066  }
getGaps()
Returns the array of gaps.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
Create styles array
The data for the language used.
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duplicate()

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

Duplicates an assClozeTest.

public

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

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

860  {
861  if ($this->id <= 0) {
862  // The question has not been saved. It cannot be duplicated
863  return;
864  }
865  // duplicate the question in database
866  $this_id = $this->getId();
867  $thisObjId = $this->getObjId();
868 
869  $clone = $this;
870  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
872  $clone->id = -1;
873 
874  if ((int) $testObjId > 0) {
875  $clone->setObjId($testObjId);
876  }
877 
878  if ($title) {
879  $clone->setTitle($title);
880  }
881  if ($author) {
882  $clone->setAuthor($author);
883  }
884  if ($owner) {
885  $clone->setOwner($owner);
886  }
887  if ($for_test) {
888  $clone->saveToDb($original_id);
889  } else {
890  $clone->saveToDb();
891  }
892  if ($this->gap_combinations_exists) {
893  $this->copyGapCombination($this_id, $clone->getId());
894  }
895  if ($for_test) {
896  $clone->saveToDb($original_id);
897  } else {
898  $clone->saveToDb();
899  }
900  // copy question page content
901  $clone->copyPageOfQuestion($this_id);
902  // copy XHTML media objects
903  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
904 
905  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
906 
907  return $clone->getId();
908  }
getId()
Gets the id of the assQuestion object.
static _getOriginalId($question_id)
Returns the original id of a question.
copyGapCombination($orgID, $newID)
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ fetchSolutionSubmit()

assClozeTest::fetchSolutionSubmit (   $submit)

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

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

Referenced by getSolutionSubmit().

1247  {
1248  $solutionSubmit = array();
1249 
1250  foreach ($submit as $key => $value) {
1251  if (preg_match("/^gap_(\d+)/", $key, $matches)) {
1252  $value = ilUtil::stripSlashes($value, false);
1253  if (strlen($value)) {
1254  $gap = $this->getGap($matches[1]);
1255  if (is_object($gap)) {
1256  if (!(($gap->getType() == CLOZE_SELECT) && ($value == -1))) {
1257  if ($gap->getType() == CLOZE_NUMERIC) {
1258  $value = str_replace(",", ".", $value);
1259  }
1260  $solutionSubmit[trim($matches[1])] = $value;
1261  }
1262  }
1263  }
1264  }
1265  }
1266 
1267  return $solutionSubmit;
1268  }
getGap($gap_index=0)
Returns the gap at a given index.
const CLOZE_SELECT
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
const CLOZE_NUMERIC
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flushGaps()

assClozeTest::flushGaps ( )

Deletes all gaps without changing the cloze text.

public

See also
$gaps

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

References array.

506  {
507  $this->gaps = array();
508  }
Create styles array
The data for the language used.

◆ getAdditionalTableName()

assClozeTest::getAdditionalTableName ( )

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

Returns
string The additional table name public

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

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

1413  {
1414  return "qpl_qst_cloze";
1415  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assClozeTest::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name public

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

References array.

1424  {
1425  return array("qpl_a_cloze",'qpl_a_cloze_combi_res');
1426  }
Create styles array
The data for the language used.

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

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

1699  {
1700  if ($index !== null) {
1701  return $this->getGap($index);
1702  } else {
1703  return $this->getGaps();
1704  }
1705  }
getGap($gap_index=0)
Returns the gap at a given index.
$index
Definition: metadata.php:60
getGaps()
Returns the array of gaps.
+ Here is the call graph for this function:

◆ getClozeText()

assClozeTest::getClozeText ( )

Returns the cloze text.

Returns
string The cloze text string public
See also
$cloze_text

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

References $cloze_text.

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

540  {
541  return $this->cloze_text;
542  }
+ 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 public
See also
$end_tag

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

References $end_tag.

576  {
577  return $this->end_tag;
578  }

◆ getExpressionTypes()

assClozeTest::getExpressionTypes ( )

Get all available expression types for a specific question.

Returns
array

Implements iQuestionCondition.

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

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

+ Here is the call graph for this function:

◆ getFixedTextLength()

assClozeTest::getFixedTextLength ( )

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

Returns
integer The text field length public

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

References $fixedTextLength.

Referenced by saveAdditionalQuestionDataToDb().

1446  {
1447  return $this->fixedTextLength;
1448  }
+ Here is the caller graph for this function:

◆ getGap()

assClozeTest::getGap (   $gap_index = 0)

Returns the gap at a given index.

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

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

Referenced by fetchSolutionSubmit(), getAvailableAnswerOptions(), saveWorkingData(), and validateSolutionSubmit().

706  {
707  if (array_key_exists($gap_index, $this->gaps)) {
708  return $this->gaps[$gap_index];
709  } else {
710  return null;
711  }
712  }
+ Here is the caller graph for this function:

◆ getGapCombinations()

assClozeTest::getGapCombinations ( )

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

References $gap_combinations.

1488  {
1489  return $this->gap_combinations;
1490  }

◆ getGapCombinationsExists()

assClozeTest::getGapCombinationsExists ( )

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

References $gap_combinations_exists.

1483  {
1485  }

◆ getGapCount()

assClozeTest::getGapCount ( )

Returns the number of gaps.

Returns
integer The number of gaps public
See also
$gaps

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

668  {
669  if (is_array($this->gaps)) {
670  return count($this->gaps);
671  } else {
672  return 0;
673  }
674  }

◆ getGaps()

assClozeTest::getGaps ( )

Returns the array of gaps.

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

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

References $gaps.

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

494  {
495  return $this->gaps;
496  }
+ Here is the caller graph for this function:

◆ getIdenticalScoring()

assClozeTest::getIdenticalScoring ( )

Returns the identical scoring status of the question.

Returns
boolean The identical scoring status
See also
$identical_scoring User interface

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

Referenced by calculateReachedPointsForSolution(), and saveAdditionalQuestionDataToDb().

1390  {
1391  return ($this->identical_scoring) ? 1 : 0;
1392  }
+ Here is the caller graph for this function:

◆ getMaximumGapPoints()

assClozeTest::getMaximumGapPoints (   $gap_index)

Returns the maximum points for a gap.

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

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

References assQuestion\$points.

Referenced by calculateReachedPointsForSolution().

1459  {
1460  $points = 0;
1461  $gap_max_points = 0;
1462  if (array_key_exists($gap_index, $this->gaps)) {
1463  $gap =&$this->gaps[$gap_index];
1464  foreach ($gap->getItems($this->getShuffler()) as $answer) {
1465  if ($answer->getPoints() > $gap_max_points) {
1466  $gap_max_points = $answer->getPoints();
1467  }
1468  }
1469  $points += $gap_max_points;
1470  }
1471  return $points;
1472  }
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assClozeTest::getMaximumPoints ( )

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

public

See also
$points

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

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

Referenced by getExpressionTypes(), and isComplete().

813  {
814  $assClozeGapCombinationObj = new assClozeGapCombination();
815  $points = 0;
816  $gaps_used_in_combination = array();
817  if ($assClozeGapCombinationObj->combinationExistsForQid($this->getId())) {
818  $points = $assClozeGapCombinationObj->getMaxPointsForCombination($this->getId());
819  $gaps_used_in_combination = $assClozeGapCombinationObj->getGapsWhichAreUsedInCombination($this->getId());
820  }
821  foreach ($this->gaps as $gap_index => $gap) {
822  if (!array_key_exists($gap_index, $gaps_used_in_combination)) {
823  if ($gap->getType() == CLOZE_TEXT) {
824  $gap_max_points = 0;
825  foreach ($gap->getItems($this->getShuffler()) as $item) {
826  if ($item->getPoints() > $gap_max_points) {
827  $gap_max_points = $item->getPoints();
828  }
829  }
830  $points += $gap_max_points;
831  } elseif ($gap->getType() == CLOZE_SELECT) {
832  $srpoints = 0;
833  foreach ($gap->getItems($this->getShuffler()) as $item) {
834  if ($item->getPoints() > $srpoints) {
835  $srpoints = $item->getPoints();
836  }
837  }
838  $points += $srpoints;
839  } elseif ($gap->getType() == CLOZE_NUMERIC) {
840  $numpoints = 0;
841  foreach ($gap->getItems($this->getShuffler()) as $item) {
842  if ($item->getPoints() > $numpoints) {
843  $numpoints = $item->getPoints();
844  }
845  }
846  $points += $numpoints;
847  }
848  }
849  }
850 
851  return $points;
852  }
getId()
Gets the id of the assQuestion object.
const CLOZE_TEXT
Cloze question constants.
const CLOZE_SELECT
Create styles array
The data for the language used.
const CLOZE_NUMERIC
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumericgapPoints()

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

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

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

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

References $result.

Referenced by calculateCombinationResult(), and calculateReachedPointsForSolution().

1132  {
1133  // fau: fixGapFormula - check entered value by evalMath
1134  // if( ! $this->checkForValidFormula($a_entered) )
1135  // {
1136  // return 0;
1137  // }
1138 
1139  include_once "./Services/Math/classes/class.EvalMath.php";
1140  $eval = new EvalMath();
1141  $eval->suppress_errors = true;
1142  $result = 0;
1143 
1144  if ($eval->e($a_entered) === false) {
1145  return 0;
1146  } elseif (($eval->e($lowerBound) !== false) && ($eval->e($upperBound) !== false)) {
1147  // fau.
1148  if (($eval->e($a_entered) >= $eval->e($lowerBound)) && ($eval->e($a_entered) <= $eval->e($upperBound))) {
1149  $result = $max_points;
1150  }
1151  } elseif ($eval->e($lowerBound) !== false) {
1152  if (($eval->e($a_entered) >= $eval->e($lowerBound)) && ($eval->e($a_entered) <= $eval->e($a_original))) {
1153  $result = $max_points;
1154  }
1155  } elseif ($eval->e($upperBound) !== false) {
1156  if (($eval->e($a_entered) >= $eval->e($a_original)) && ($eval->e($a_entered) <= $eval->e($upperBound))) {
1157  $result = $max_points;
1158  }
1159  } else {
1160  if ($eval->e($a_entered) == $eval->e($a_original)) {
1161  $result = $max_points;
1162  }
1163  }
1164  return $result;
1165  }
$result
+ Here is the caller graph for this function:

◆ getOperators()

assClozeTest::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
string$expression

Implements iQuestionCondition.

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

References ilOperatorsExpressionMapping\getOperatorsByExpression().

1613  {
1614  require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1616  }
+ Here is the call graph for this function:

◆ getQuestionType()

assClozeTest::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

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

Referenced by toJSON().

1341  {
1342  return "assClozeTest";
1343  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assClozeTest::getRTETextWithMediaObjects ( )

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

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

References getClozeText().

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

◆ getSolutionSubmit()

assClozeTest::getSolutionSubmit ( )

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

References $_POST, and fetchSolutionSubmit().

Referenced by saveWorkingData(), and validateSolutionSubmit().

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

◆ getStartTag()

assClozeTest::getStartTag ( )

Returns the start tag of a cloze gap.

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

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

References $start_tag.

552  {
553  return $this->start_tag;
554  }

◆ getTextgapPoints()

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

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

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

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

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

1078  {
1079  include_once "./Services/Utilities/classes/class.ilStr.php";
1080  $result = 0;
1081  $gaprating = $this->getTextgapRating();
1082  switch ($gaprating) {
1084  if (strcmp(ilStr::strToLower($a_original), ilStr::strToLower($a_entered)) == 0) {
1085  $result = $max_points;
1086  }
1087  break;
1089  if (strcmp($a_original, $a_entered) == 0) {
1090  $result = $max_points;
1091  }
1092  break;
1094  if (levenshtein($a_original, $a_entered) <= 1) {
1095  $result = $max_points;
1096  }
1097  break;
1099  if (levenshtein($a_original, $a_entered) <= 2) {
1100  $result = $max_points;
1101  }
1102  break;
1104  if (levenshtein($a_original, $a_entered) <= 3) {
1105  $result = $max_points;
1106  }
1107  break;
1109  if (levenshtein($a_original, $a_entered) <= 4) {
1110  $result = $max_points;
1111  }
1112  break;
1114  if (levenshtein($a_original, $a_entered) <= 5) {
1115  $result = $max_points;
1116  }
1117  break;
1118  }
1119  return $result;
1120  }
const TEXTGAP_RATING_LEVENSHTEIN5
$result
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
getTextgapRating()
Returns the rating option for text gaps.
static strToLower($a_string)
Definition: class.ilStr.php:87
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_CASEINSENSITIVE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextgapRating()

assClozeTest::getTextgapRating ( )

Returns the rating option for text gaps.

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

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

References $textgap_rating.

Referenced by getTextgapPoints(), and saveAdditionalQuestionDataToDb().

1353  {
1354  return $this->textgap_rating;
1355  }
+ Here is the caller graph for this function:

◆ isComplete()

assClozeTest::isComplete ( )

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

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

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

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

133  {
134  if (strlen($this->getTitle())
135  && $this->getAuthor()
136  && $this->getClozeText()
137  && count($this->getGaps())
138  && $this->getMaximumPoints() > 0) {
139  return true;
140  }
141  return false;
142  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
getGaps()
Returns the array of gaps.
getAuthor()
Gets the authors name of the assQuestion object.
getClozeText()
Returns the cloze text.
getTitle()
Gets the title string of the assQuestion object.
+ Here is the call graph for this function:

◆ isValidNumericSubmitValue()

assClozeTest::isValidNumericSubmitValue (   $submittedValue)
protected

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

Referenced by validateSolutionSubmit().

1216  {
1217  if (is_numeric($submittedValue)) {
1218  return true;
1219  }
1220 
1221  if (preg_match('/^[-+]{0,1}\d+\/\d+$/', $submittedValue)) {
1222  return true;
1223  }
1224 
1225  return false;
1226  }
+ Here is the caller graph for this function:

◆ lmMigrateQuestionTypeSpecificContent()

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

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

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

1545  {
1546  // DO NOT USE SETTER FOR CLOZE TEXT -> SETTER DOES RECREATE GAP OBJECTS without having gap type info ^^
1547  //$this->setClozeText( $migrator->migrateToLmContent($this->getClozeText()) );
1548  $this->cloze_text = $migrator->migrateToLmContent($this->getClozeText());
1549  // DO NOT USE SETTER FOR CLOZE TEXT -> SETTER DOES RECREATE GAP OBJECTS without having gap type info ^^
1550  }
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:

◆ loadFromDb()

assClozeTest::loadFromDb (   $question_id)

Loads a assClozeTest object from a database.

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

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

References $data, $ilDB, $result, ilRTE\_replaceMediaObjectImageSrc(), array, cleanQuestiontext(), CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, getAdditionalTableName(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), setClozeText(), assQuestion\setComment(), assQuestion\setEstimatedWorkingTime(), setFixedTextLength(), setGapCombinations(), setGapCombinationsExists(), assQuestion\setId(), setIdenticalScoring(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setTextgapRating(), and assQuestion\setTitle().

166  {
167  global $ilDB;
168  $result = $ilDB->queryF(
169  "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",
170  array("integer"),
171  array($question_id)
172  );
173  if ($result->numRows() == 1) {
174  $data = $ilDB->fetchAssoc($result);
175  $this->setId($question_id);
176  $this->setNrOfTries($data['nr_of_tries']);
177  $this->setObjId($data["obj_fi"]);
178  $this->setTitle($data["title"]);
179  $this->setComment($data["description"]);
180  $this->setOriginalId($data["original_id"]);
181  $this->setAuthor($data["author"]);
182  $this->setPoints($data["points"]);
183  $this->setOwner($data["owner"]);
184  $this->setQuestion($this->cleanQuestiontext($data["question_text"]));
185  $this->setClozeText($data['cloze_text']);
186  $this->setFixedTextLength($data["fixed_textlen"]);
187  $this->setIdenticalScoring(($data['tstamp'] == 0) ? true : $data["identical_scoring"]);
188  // replacement of old syntax with new syntax
189  include_once("./Services/RTE/classes/class.ilRTE.php");
190  $this->question = ilRTE::_replaceMediaObjectImageSrc($this->question, 1);
191  $this->cloze_text = ilRTE::_replaceMediaObjectImageSrc($this->cloze_text, 1);
192  $this->setTextgapRating($data["textgap_rating"]);
193  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
194 
195  try {
196  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
197  } catch (ilTestQuestionPoolException $e) {
198  }
199 
200  // open the cloze gaps with all answers
201  include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
202  include_once "./Modules/TestQuestionPool/classes/class.assClozeGap.php";
203  $result = $ilDB->queryF(
204  "SELECT * FROM qpl_a_cloze WHERE question_fi = %s ORDER BY gap_id, aorder ASC",
205  array("integer"),
206  array($question_id)
207  );
208  if ($result->numRows() > 0) {
209  $this->gaps = array();
210  while ($data = $ilDB->fetchAssoc($result)) {
211  switch ($data["cloze_type"]) {
212  case CLOZE_TEXT:
213  if (!array_key_exists($data["gap_id"], $this->gaps)) {
214  $this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_TEXT);
215  }
216  $answer = new assAnswerCloze(
217  $data["answertext"],
218  $data["points"],
219  $data["aorder"]
220  );
221  $this->gaps[$data["gap_id"]]->setGapSize($data['gap_size']);
222 
223  $this->gaps[$data["gap_id"]]->addItem($answer);
224  break;
225  case CLOZE_SELECT:
226  if (!array_key_exists($data["gap_id"], $this->gaps)) {
227  $this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_SELECT);
228  $this->gaps[$data["gap_id"]]->setShuffle($data["shuffle"]);
229  }
230  $answer = new assAnswerCloze(
231  $data["answertext"],
232  $data["points"],
233  $data["aorder"]
234  );
235  $this->gaps[$data["gap_id"]]->addItem($answer);
236  break;
237  case CLOZE_NUMERIC:
238  if (!array_key_exists($data["gap_id"], $this->gaps)) {
239  $this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_NUMERIC);
240  }
241  $answer = new assAnswerCloze(
242  $data["answertext"],
243  $data["points"],
244  $data["aorder"]
245  );
246  $this->gaps[$data["gap_id"]]->setGapSize($data['gap_size']);
247  $answer->setLowerBound($data["lowerlimit"]);
248  $answer->setUpperBound($data["upperlimit"]);
249  $this->gaps[$data["gap_id"]]->addItem($answer);
250  break;
251  }
252  }
253  }
254  }
255  $assClozeGapCombinationObj = new assClozeGapCombination();
256  $check_for_gap_combinations = $assClozeGapCombinationObj->loadFromDb($question_id);
257  if (count($check_for_gap_combinations) != 0) {
258  $this->setGapCombinationsExists(true);
259  $this->setGapCombinations($check_for_gap_combinations);
260  }
261  parent::loadFromDb($question_id);
262  }
Class for cloze question numeric answers.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
$result
const CLOZE_TEXT
Cloze question constants.
setId($id=-1)
Sets the id of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second. ...
Class for cloze question gaps.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setGapCombinationsExists($value)
setAuthor($author="")
Sets the authors name of the assQuestion object.
const CLOZE_SELECT
setFixedTextLength($a_text_len)
Sets a fixed text length for all text fields in the cloze question.
Create styles array
The data for the language used.
setClozeText($cloze_text="")
Evaluates the text gap solutions from the cloze text.
cleanQuestiontext($text)
Cleans cloze question text to remove attributes or tags from older ILIAS versions.
setPoints($a_points)
Sets the maximum available points for the question.
setTextgapRating($a_textgap_rating)
Sets the rating option for text gaps.
setQuestion($question="")
Sets the question string of the question object.
global $ilDB
setOriginalId($original_id)
const CLOZE_NUMERIC
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setIdenticalScoring($a_identical_scoring)
Sets the identical scoring option for cloze questions.
setComment($comment="")
Sets the comment string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
+ Here is the call graph for this function:

◆ reworkWorkingData()

assClozeTest::reworkWorkingData (   $active_id,
  $pass,
  $obligationsAnswered,
  $authorized 
)
protected

{}

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

1330  {
1331  // nothing to rework!
1332  }

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

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

Referenced by saveToDb().

308  {
309  global $ilDB;
310 
311  $ilDB->manipulateF(
312  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
313  array( "integer" ),
314  array( $this->getId() )
315  );
316 
317  $ilDB->manipulateF(
318  "INSERT INTO " . $this->getAdditionalTableName()
319  . " (question_fi, textgap_rating, identical_scoring, fixed_textlen, cloze_text) VALUES (%s, %s, %s, %s, %s)",
320  array(
321  "integer",
322  "text",
323  "text",
324  "integer",
325  "text"
326  ),
327  array(
328  $this->getId(),
329  $this->getTextgapRating(),
330  $this->getIdenticalScoring(),
331  $this->getFixedTextLength() ? $this->getFixedTextLength() : null,
333  )
334  );
335  }
getId()
Gets the id of the assQuestion object.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getTextgapRating()
Returns the rating option for text gaps.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
Create styles array
The data for the language used.
getFixedTextLength()
Gets the fixed text length for all text fields in the cloze question.
global $ilDB
getClozeText()
Returns the cloze text.
getIdenticalScoring()
Returns the identical scoring status of the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAnswerSpecificDataToDb()

assClozeTest::saveAnswerSpecificDataToDb ( )

Save all gaps to the database.

Implements ilObjAnswerScoringAdjustable.

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

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

Referenced by saveToDb().

288  {
289  global $ilDB;
290 
291  $ilDB->manipulateF(
292  "DELETE FROM qpl_a_cloze WHERE question_fi = %s",
293  array( "integer" ),
294  array( $this->getId() )
295  );
296 
297  foreach ($this->gaps as $key => $gap) {
298  $this->saveClozeGapItemsToDb($gap, $key);
299  }
300  }
getId()
Gets the id of the assQuestion object.
Create styles array
The data for the language used.
global $ilDB
$key
Definition: croninfo.php:18
saveClozeGapItemsToDb($gap, $key)
Save all items belonging to one cloze gap to the db.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeGapItemsToDb()

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

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

Parameters
$gap
$key

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

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

Referenced by saveAnswerSpecificDataToDb().

344  {
345  global $ilDB;
346  foreach ($gap->getItems($this->getShuffler()) as $item) {
347  $query = "";
348  $next_id = $ilDB->nextId('qpl_a_cloze');
349  switch ($gap->getType()) {
350  case CLOZE_TEXT:
351  $this->saveClozeTextGapRecordToDb($next_id, $key, $item, $gap);
352  break;
353  case CLOZE_SELECT:
354  $this->saveClozeSelectGapRecordToDb($next_id, $key, $item, $gap);
355  break;
356  case CLOZE_NUMERIC:
357  $this->saveClozeNumericGapRecordToDb($next_id, $key, $item, $gap);
358  break;
359  }
360  }
361  }
const CLOZE_TEXT
Cloze question constants.
const CLOZE_SELECT
$query
saveClozeTextGapRecordToDb($next_id, $key, $item, $gap)
Saves a gap-item record.
saveClozeNumericGapRecordToDb($next_id, $key, $item, $gap)
Saves a gap-item record.
global $ilDB
saveClozeSelectGapRecordToDb($next_id, $key, $item, $gap)
Saves a gap-item record.
const CLOZE_NUMERIC
$key
Definition: croninfo.php:18
+ 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 443 of file class.assClozeTest.php.

References $ilDB, $key, array, and assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

444  {
445  global $ilDB;
446 
447  include_once "./Services/Math/classes/class.EvalMath.php";
448  $eval = new EvalMath();
449  $eval->suppress_errors = true;
450  $ilDB->manipulateF(
451  "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)",
452  array(
453  "integer",
454  "integer",
455  "integer",
456  "text",
457  "float",
458  "integer",
459  "text",
460  "text",
461  "text",
462  "integer"
463  ),
464  array(
465  $next_id,
466  $this->getId(),
467  $key,
468  strlen($item->getAnswertext()) ? $item->getAnswertext() : "",
469  $item->getPoints(),
470  $item->getOrder(),
471  $gap->getType(),
472  ($eval->e($item->getLowerBound() !== false) && strlen(
473  $item->getLowerBound()
474  ) > 0) ? $item->getLowerBound() : $item->getAnswertext(),
475  ($eval->e($item->getUpperBound() !== false) && strlen(
476  $item->getUpperBound()
477  ) > 0) ? $item->getUpperBound() : $item->getAnswertext(),
478  (int) $gap->getGapSize()
479  )
480  );
481  }
getId()
Gets the id of the assQuestion object.
Create styles array
The data for the language used.
global $ilDB
$key
Definition: croninfo.php:18
+ 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 407 of file class.assClozeTest.php.

References $ilDB, $key, array, and assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

408  {
409  global $ilDB;
410  $ilDB->manipulateF(
411  "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)",
412  array(
413  "integer",
414  "integer",
415  "integer",
416  "text",
417  "float",
418  "integer",
419  "text",
420  "text"
421  ),
422  array(
423  $next_id,
424  $this->getId(),
425  $key,
426  strlen($item->getAnswertext()) ? $item->getAnswertext() : "",
427  $item->getPoints(),
428  $item->getOrder(),
429  $gap->getType(),
430  ($gap->getShuffle()) ? "1" : "0"
431  )
432  );
433  }
getId()
Gets the id of the assQuestion object.
Create styles array
The data for the language used.
global $ilDB
$key
Definition: croninfo.php:18
+ 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 371 of file class.assClozeTest.php.

References $ilDB, $key, array, and assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

372  {
373  global $ilDB;
374  $ilDB->manipulateF(
375  "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)",
376  array(
377  "integer",
378  "integer",
379  "integer",
380  "text",
381  "float",
382  "integer",
383  "text",
384  "integer"
385  ),
386  array(
387  $next_id,
388  $this->getId(),
389  $key,
390  strlen($item->getAnswertext()) ? $item->getAnswertext() : "",
391  $item->getPoints(),
392  $item->getOrder(),
393  $gap->getType(),
394  (int) $gap->getGapSize()
395  )
396  );
397  }
getId()
Gets the id of the assQuestion object.
Create styles array
The data for the language used.
global $ilDB
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

assClozeTest::saveToDb (   $original_id = "")

Saves a assClozeTest object to a database.

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

public

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

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

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

◆ saveWorkingData()

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

Saves the learners input of the question to the database.

public

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

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

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

1284  {
1285  global $ilDB;
1286  global $ilUser;
1287  if (is_null($pass)) {
1288  include_once "./Modules/Test/classes/class.ilObjTest.php";
1289  $pass = ilObjTest::_getPass($active_id);
1290  }
1291 
1292  $entered_values = 0;
1293 
1294  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $active_id, $pass, $authorized) {
1295  $this->removeCurrentSolution($active_id, $pass, $authorized);
1296 
1297  foreach ($this->getSolutionSubmit() as $val1 => $val2) {
1298  $value = trim(ilUtil::stripSlashes($val2, false));
1299  if (strlen($value)) {
1300  $gap = $this->getGap(trim(ilUtil::stripSlashes($val1)));
1301  if (is_object($gap)) {
1302  if (!(($gap->getType() == CLOZE_SELECT) && ($value == -1))) {
1303  $this->saveCurrentSolution($active_id, $pass, $val1, $value, $authorized);
1304  $entered_values++;
1305  }
1306  }
1307  }
1308  }
1309  });
1310 
1311  if ($entered_values) {
1312  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1314  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1315  }
1316  } else {
1317  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1319  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1320  }
1321  }
1322 
1323  return true;
1324  }
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getId()
Gets the id of the assQuestion object.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
getGap($gap_index=0)
Returns the gap at a given index.
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
const CLOZE_SELECT
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
$ilUser
Definition: imgupload.php:18
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
removeCurrentSolution($active_id, $pass, $authorized=true)
global $ilDB
+ Here is the call graph for this function:

◆ setClozeText()

assClozeTest::setClozeText (   $cloze_text = "")

Evaluates the text gap solutions from the cloze text.

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

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

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

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

Referenced by loadFromDb().

520  {
521  $this->gaps = array();
523  $this->cloze_text = $cloze_text;
525  }
createGapsFromQuestiontext()
Create gap entries by parsing the question text.
Create styles array
The data for the language used.
cleanQuestiontext($text)
Cleans cloze question text to remove attributes or tags from older ILIAS versions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setClozeTextValue()

assClozeTest::setClozeTextValue (   $cloze_text = "")

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

References $cloze_text.

528  {
529  $this->cloze_text = $cloze_text;
530  }

◆ setEndTag()

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

Sets the end tag of a cloze gap.

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

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

References $end_tag.

588  {
589  $this->end_tag = $end_tag;
590  }

◆ setExportDetailsXLS()

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

{}

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

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

1506  {
1507  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
1508 
1509  $solution = $this->getSolutionValues($active_id, $pass);
1510  $i = 1;
1511  foreach ($this->getGaps() as $gap_index => $gap) {
1512  $worksheet->setCell($startrow + $i, 0, $this->lng->txt("gap") . " $i");
1513  $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
1514  $checked = false;
1515  foreach ($solution as $solutionvalue) {
1516  if ($gap_index == $solutionvalue["value1"]) {
1517  $string_escaping_org_value = $worksheet->getStringEscaping();
1518  try {
1519  $worksheet->setStringEscaping(false);
1520 
1521  switch ($gap->getType()) {
1522  case CLOZE_SELECT:
1523  $worksheet->setCell($startrow + $i, 1, $gap->getItem($solutionvalue["value2"])->getAnswertext());
1524  break;
1525  case CLOZE_NUMERIC:
1526  case CLOZE_TEXT:
1527  $worksheet->setCell($startrow + $i, 1, $solutionvalue["value2"]);
1528  break;
1529  }
1530  } finally {
1531  $worksheet->setStringEscaping($string_escaping_org_value);
1532  }
1533  }
1534  }
1535  $i++;
1536  }
1537 
1538  return $startrow + $i + 1;
1539  }
$worksheet
const CLOZE_TEXT
Cloze question constants.
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
getGaps()
Returns the array of gaps.
const CLOZE_SELECT
$i
Definition: disco.tpl.php:19
const CLOZE_NUMERIC
+ Here is the call graph for this function:

◆ setFixedTextLength()

assClozeTest::setFixedTextLength (   $a_text_len)

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

Parameters
integer$a_text_lenThe text field length public

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

Referenced by loadFromDb().

1435  {
1436  $this->fixedTextLength = $a_text_len;
1437  }
+ Here is the caller graph for this function:

◆ setGapAnswerLowerBound()

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

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

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

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

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

783  {
784  if (array_key_exists($gap_index, $this->gaps)) {
785  $this->gaps[$gap_index]->setItemLowerBound($order, $bound);
786  }
787  }

◆ setGapAnswerPoints()

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

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

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

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

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

References assQuestion\$points.

732  {
733  if (array_key_exists($gap_index, $this->gaps)) {
734  $this->gaps[$gap_index]->setItemPoints($order, $points);
735  }
736  }

◆ setGapAnswerUpperBound()

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

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

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

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

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

800  {
801  if (array_key_exists($gap_index, $this->gaps)) {
802  $this->gaps[$gap_index]->setItemUpperBound($order, $bound);
803  }
804  }

◆ setGapCombinations()

assClozeTest::setGapCombinations (   $value)

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

Referenced by loadFromDb().

1498  {
1499  $this->gap_combinations = $value;
1500  }
+ Here is the caller graph for this function:

◆ setGapCombinationsExists()

assClozeTest::setGapCombinationsExists (   $value)

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

Referenced by loadFromDb().

1493  {
1494  $this->gap_combinations_exists = $value;
1495  }
+ Here is the caller graph for this function:

◆ setGapShuffle()

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

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

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

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

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

References assQuestion\$shuffle.

641  {
642  if (array_key_exists($gap_index, $this->gaps)) {
643  $this->gaps[$gap_index]->setShuffle($shuffle);
644  }
645  }

◆ setGapSize()

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

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

References $size.

715  {
716  if (array_key_exists($gap_index, $this->gaps)) {
717  $this->gaps[$gap_index]->setGapSize($size);
718  }
719  }
$size
Definition: RandomTest.php:84

◆ setGapType()

assClozeTest::setGapType (   $gap_index,
  $gap_type 
)

Set the type of a gap with a given index.

private

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

625  {
626  if (array_key_exists($gap_index, $this->gaps)) {
627  $this->gaps[$gap_index]->setType($gap_type);
628  }
629  }

◆ setIdenticalScoring()

assClozeTest::setIdenticalScoring (   $a_identical_scoring)

Sets the identical scoring option for cloze questions.

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

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

Referenced by loadFromDb().

1402  {
1403  $this->identical_scoring = ($a_identical_scoring) ? 1 : 0;
1404  }
+ Here is the caller graph for this function:

◆ setStartTag()

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

Sets the start tag of a cloze gap.

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

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

References $start_tag.

564  {
565  $this->start_tag = $start_tag;
566  }

◆ setTextgapRating()

assClozeTest::setTextgapRating (   $a_textgap_rating)

Sets the rating option for text gaps.

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

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

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

Referenced by loadFromDb().

1365  {
1366  switch ($a_textgap_rating) {
1374  $this->textgap_rating = $a_textgap_rating;
1375  break;
1376  default:
1377  $this->textgap_rating = TEXTGAP_RATING_CASEINSENSITIVE;
1378  break;
1379  }
1380  }
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_CASEINSENSITIVE
+ Here is the caller graph for this function:

◆ toJSON()

assClozeTest::toJSON ( )

Returns a JSON representation of the question.

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

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

1556  {
1557  include_once("./Services/RTE/classes/class.ilRTE.php");
1558  $result = array();
1559  $result['id'] = (int) $this->getId();
1560  $result['type'] = (string) $this->getQuestionType();
1561  $result['title'] = (string) $this->getTitle();
1562  $result['question'] = $this->formatSAQuestion($this->getQuestion());
1563  $result['clozetext'] = $this->formatSAQuestion($this->getClozeText());
1564  $result['nr_of_tries'] = (int) $this->getNrOfTries();
1565  $result['shuffle'] = (bool) $this->getShuffle();
1566  $result['feedback'] = array(
1567  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1568  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1569  );
1570 
1571  $gaps = array();
1572  foreach ($this->getGaps() as $key => $gap) {
1573  $items = array();
1574  foreach ($gap->getItems($this->getShuffler()) as $item) {
1575  $jitem = array();
1576  $jitem['points'] = $item->getPoints();
1577  $jitem['value'] = $this->formatSAQuestion($item->getAnswertext());
1578  $jitem['order'] = $item->getOrder();
1579  if ($gap->getType() == CLOZE_NUMERIC) {
1580  $jitem['lowerbound'] = $item->getLowerBound();
1581  $jitem['upperbound'] = $item->getUpperBound();
1582  } else {
1583  $jitem['value'] = trim($jitem['value']);
1584  }
1585  array_push($items, $jitem);
1586  }
1587 
1588  if ($gap->getGapSize() && ($gap->getType() == CLOZE_TEXT || $gap->getType() == CLOZE_NUMERIC)) {
1589  $jgap['size'] = $gap->getGapSize();
1590  }
1591 
1592  $jgap['shuffle'] = $gap->getShuffle();
1593  $jgap['type'] = $gap->getType();
1594  $jgap['item'] = $items;
1595 
1596  array_push($gaps, $jgap);
1597  }
1598  $result['gaps'] = $gaps;
1599  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1600  $result['mobs'] = $mobs;
1601  return json_encode($result);
1602  }
getId()
Gets the id of the assQuestion object.
Add rich text string
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
formatSAQuestion($a_q)
Format self assessment question.
getQuestionType()
Returns the question type of the question.
$result
const CLOZE_TEXT
Cloze question constants.
getShuffle()
Gets the shuffle flag.
getGaps()
Returns the array of gaps.
$mobs
getQuestion()
Gets the question string of the question object.
Create styles array
The data for the language used.
getClozeText()
Returns the cloze text.
getTitle()
Gets the title string of the assQuestion object.
const CLOZE_NUMERIC
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ updateClozeTextFromGaps()

assClozeTest::updateClozeTextFromGaps ( )

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

private

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

References $output, array, getClozeText(), getGaps(), and assQuestion\prepareTextareaOutput().

Referenced by deleteAnswerText().

1002  {
1003  $output = $this->getClozeText();
1004  foreach ($this->getGaps() as $gap_index => $gap) {
1005  $answers = array();
1006  foreach ($gap->getItemsRaw() as $item) {
1007  array_push($answers, str_replace(",", "\\,", $item->getAnswerText()));
1008  }
1009  $output = preg_replace("/\[gap\].*?\[\/gap\]/", "[_gap]" . $this->prepareTextareaOutput(join(",", $answers), true) . "[/_gap]", $output, 1);
1010  }
1011  $output = str_replace("_gap]", "gap]", $output);
1012  $this->cloze_text = $output;
1013  }
getGaps()
Returns the array of gaps.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
Create styles array
The data for the language used.
prepareTextareaOutput($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output in tests.
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateSolutionSubmit()

assClozeTest::validateSolutionSubmit ( )

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

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

1229  {
1230  foreach ($this->getSolutionSubmit() as $gapIndex => $value) {
1231  $gap = $this->getGap($gapIndex);
1232 
1233  if ($gap->getType() != CLOZE_NUMERIC) {
1234  continue;
1235  }
1236 
1237  if (strlen($value) && !$this->isValidNumericSubmitValue($value)) {
1238  ilUtil::sendFailure($this->lng->txt("err_no_numeric_value"), true);
1239  return false;
1240  }
1241  }
1242 
1243  return true;
1244  }
getGap($gap_index=0)
Returns the gap at a given index.
isValidNumericSubmitValue($submittedValue)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const CLOZE_NUMERIC
+ Here is the call graph for this function:

Field Documentation

◆ $cloze_text

assClozeTest::$cloze_text

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

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

◆ $end_tag

assClozeTest::$end_tag

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

Referenced by getEndTag(), and setEndTag().

◆ $fixedTextLength

assClozeTest::$fixedTextLength

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

Referenced by getFixedTextLength().

◆ $gap_combinations

assClozeTest::$gap_combinations

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

Referenced by getGapCombinations().

◆ $gap_combinations_exists

assClozeTest::$gap_combinations_exists

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

Referenced by getGapCombinationsExists().

◆ $gaps

assClozeTest::$gaps

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

Referenced by getGaps(), and toJSON().

◆ $identical_scoring

assClozeTest::$identical_scoring

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

◆ $start_tag

assClozeTest::$start_tag

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

Referenced by getStartTag(), and setStartTag().

◆ $textgap_rating

assClozeTest::$textgap_rating

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

Referenced by getTextgapRating().


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