ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
assMatchingQuestion Class Reference

Class for matching questions. More...

+ Inheritance diagram for assMatchingQuestion:
+ Collaboration diagram for assMatchingQuestion:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="", $matching_type=MT_TERMS_DEFINITIONS)
 assMatchingQuestion constructor More...
 
 isComplete ()
 Returns true, if a matching question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a assMatchingQuestion object to a database. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 loadFromDb ($question_id)
 Loads a assMatchingQuestion object from a database. More...
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates an assMatchingQuestion. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assMatchingQuestion. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 duplicateImages ($question_id, $objectId=null)
 
 copyImages ($question_id, $source_questionpool)
 
 insertMatchingPair ($position, $term=null, $definition=null, $points=0.0)
 Inserts a matching pair for an matching choice question. More...
 
 addMatchingPair ($term=null, $definition=null, $points=0.0)
 Adds an matching pair for an matching choice question. More...
 
 getTermWithIdentifier ($a_identifier)
 Returns a term with a given identifier. More...
 
 getDefinitionWithIdentifier ($a_identifier)
 Returns a definition with a given identifier. More...
 
 getMatchingPair ($index=0)
 Returns a matching pair with a given index. More...
 
 deleteMatchingPair ($index=0)
 Deletes a matching pair with a given index. More...
 
 flushMatchingPairs ()
 Deletes all matching pairs. More...
 
 getMatchingPairCount ()
 Returns the number of matching pairs. More...
 
 getTerms ()
 Returns the terms of the matching question. More...
 
 getDefinitions ()
 Returns the definitions of the matching question. More...
 
 getTermCount ()
 Returns the number of terms. More...
 
 getDefinitionCount ()
 Returns the number of definitions. More...
 
 addTerm ($term)
 Adds a term. More...
 
 addDefinition ($definition)
 Adds a definition. More...
 
 insertTerm ($position, $term=null)
 Inserts a term. More...
 
 insertDefinition ($position, $definition=null)
 Inserts a definition. More...
 
 flushTerms ()
 Deletes all terms. More...
 
 flushDefinitions ()
 Deletes all definitions. More...
 
 deleteTerm ($position)
 Deletes a term. More...
 
 deleteDefinition ($position)
 Deletes a definition. More...
 
 setTerm ($term, $index)
 Sets a specific term. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 getMaximumPoints ()
 Calculates and Returns the maximum points, a learner can reach answering the question. More...
 
 getMaximumScoringMatchingPairs ()
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 getEncryptedFilename ($filename)
 Returns the encrypted save filename of a matching picture Images are saved with an encrypted filename to prevent users from cheating by guessing the solution from the image filename. More...
 
 removeTermImage ($index)
 
 removeDefinitionImage ($index)
 
 deleteImagefile ($filename)
 Deletes an imagefile from the system if the file is deleted manually. More...
 
 setImageFile ($image_tempfilename, $image_filename, $previous_filename='')
 Sets the image file and uploads the image to the object's image directory. More...
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 getRandomId ()
 
 setShuffle ($shuffle=true)
 Sets the shuffle flag. More...
 
 getQuestionType ()
 Returns the question type of the question. 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...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
getMatchingPairs ()
 Returns the matchingpairs array. More...
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 {Creates an Excel worksheet for the detailed cumulated results of this question.
Parameters
object$worksheetReference to the parent excel worksheet
object$startrowStartrow of the output in the excel worksheet
object$active_idActive id of the participant
object$passTest pass
Returns
object
} More...
 
 getThumbGeometry ()
 Get the thumbnail geometry. More...
 
 getThumbSize ()
 Get the thumbnail geometry. More...
 
 setThumbGeometry ($a_geometry)
 Set the thumbnail geometry. More...
 
 rebuildThumbnails ()
 Rebuild the thumbnail images with a new thumbnail size. More...
 
 getThumbPrefix ()
 
 toJSON ()
 Returns a JSON representation of the question TODO. More...
 
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output. More...
 
 supportsNonJsOutput ()
 
 setMatchingMode ($matchingMode)
 
 getMatchingMode ()
 
 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...
 
- Public Member Functions inherited from assQuestion
 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assQuestion constructor More...
 
 getShuffler ()
 
 setShuffler (ilArrayElementShuffler $shuffler)
 
 setProcessLocker ($processLocker)
 
 getProcessLocker ()
 
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 isComplete ()
 Returns true, if a question is complete for use. More...
 
 questionTitleExists ($questionpool_id, $title)
 Returns TRUE if the question title exists in the database. More...
 
 setTitle ($title="")
 Sets the title string of the assQuestion object. More...
 
 setId ($id=-1)
 Sets the id of the assQuestion object. More...
 
 setTestId ($id=-1)
 Sets the test id of the assQuestion object. More...
 
 setComment ($comment="")
 Sets the comment string of the assQuestion object. More...
 
 setOutputType ($outputType=OUTPUT_HTML)
 Sets the output type. More...
 
 setShuffle ($shuffle=true)
 Sets the shuffle flag. More...
 
 setEstimatedWorkingTime ($hour=0, $min=0, $sec=0)
 Sets the estimated working time of a question from given hour, minute and second. More...
 
 setEstimatedWorkingTimeFromDurationString ($durationString)
 Sets the estimated working time of a question from a given datetime string. More...
 
 keyInArray ($searchkey, $array)
 returns TRUE if the key occurs in an array More...
 
 setAuthor ($author="")
 Sets the authors name of the assQuestion object. More...
 
 setOwner ($owner="")
 Sets the creator/owner ID of the assQuestion object. More...
 
 getTitle ()
 Gets the title string of the assQuestion object. More...
 
 getTitleFilenameCompliant ()
 returns the object title prepared to be used as a filename More...
 
 getId ()
 Gets the id of the assQuestion object. More...
 
 getShuffle ()
 Gets the shuffle flag. More...
 
 getTestId ()
 Gets the test id of the assQuestion object. More...
 
 getComment ()
 Gets the comment string of the assQuestion object. More...
 
 getOutputType ()
 Gets the output type. More...
 
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output. More...
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getEstimatedWorkingTime ()
 Gets the estimated working time of a question. More...
 
 getAuthor ()
 Gets the authors name of the assQuestion object. More...
 
 getOwner ()
 Gets the creator/owner ID of the assQuestion object. More...
 
 getObjId ()
 Get the object id of the container object. More...
 
 setObjId ($obj_id=0)
 Set the object id of the container object. More...
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId ($external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 Return the suggested solutions. More...
 
 getReachedPoints ($active_id, $pass=null)
 Returns the points, a learner has reached answering the question This is the fast way to get the points directly from the database. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getAdjustedReachedPoints ($active_id, $pass=null, $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution ($active_id, $pass=null, $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState ($active_id, $pass=null, $obligationsEnabled=false, $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution. More...
 
 getJavaPath ()
 Returns the image path for web accessable images of a question. More...
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 buildImagePath ($questionId, $parentObjectId)
 
 getFlashPath ()
 Returns the image path for web accessable flash files of a question. More...
 
 getJavaPathWeb ()
 Returns the web image path for web accessable java applets of a question. More...
 
 getSuggestedSolutionPathWeb ()
 Returns the web path for a suggested solution. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getFlashPathWeb ()
 Returns the web image path for web accessable flash applications of a question. More...
 
 getTestOutputSolutions ($activeId, $pass)
 
 getUserSolutionPreferingIntermediate ($active_id, $pass=null)
 
 getSolutionValues ($active_id, $pass=null, $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse ($question_id="")
 Checks whether the question is in use or not. More...
 
 isClone ($question_id="")
 Checks whether the question is a clone of another question or not. More...
 
 pcArrayShuffle ($array)
 Shuffles the values of a given array. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 getTotalAnswers ()
 get total number of answers More...
 
 _getTotalAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 create page object of question More...
 
 copyPageOfQuestion ($a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 fixSvgToPng ($imageFilenameContainingString)
 
 fixUnavailableSkinImageSources ($html)
 
 loadFromDb ($question_id)
 Loads the question from the database. More...
 
 createNewQuestion ($a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb ($original_id="")
 
 saveToDb ($original_id="")
 Saves the question to the database. More...
 
 setNewOriginalId ($newId)
 
 deleteSuggestedSolutions ()
 Deletes all suggestes solutions in the database. More...
 
 getSuggestedSolution ($subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle ($subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution ($solution_id="", $subquestion_index=0, $is_import=false)
 Sets a suggested solution for the question. More...
 
 _resolveInternalLink ($internal_link)
 
 _resolveIntLinks ($question_id)
 
 syncWithOriginal ()
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool ($question_id)
 Returns true if the question already exists in the database and is assigned to a question pool. More...
 
 getPoints ()
 Returns the maximum available points for the question. More...
 
 setPoints ($a_points)
 Sets the maximum available points for the question. More...
 
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 deductHintPointsFromReachedPoints (ilAssQuestionPreviewSession $previewSession, $reachedPoints)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=null)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output in tests. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addQTIMaterial (&$a_xml_writer, $a_material, $close_material_tag=true, $add_mobs=true)
 Creates a QTI material tag from a plain text or xhtml text. More...
 
 buildHashedImageFilename ($plain_image_filename, $unique=false)
 
 getQuestion ()
 Gets the question string of the question object. More...
 
 setQuestion ($question="")
 Sets the question string of the question object. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 Returns the question type of the question. More...
 
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table More...
 
getInstances ()
 Gets all instances of the question. More...
 
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id. More...
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getNrOfTries ()
 
 setNrOfTries ($a_nr_of_tries)
 
 setExportImagePath ($a_path)
 
 formatSAQuestion ($a_q)
 Format self assessment question. More...
 
 setPreventRteUsage ($a_val)
 Set prevent rte usage. More...
 
 getPreventRteUsage ()
 Get prevent rte usage. More...
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode ($a_selfassessmenteditingmode)
 Set Self-Assessment Editing Mode. More...
 
 getSelfAssessmentEditingMode ()
 Get Self-Assessment Editing Mode. More...
 
 setDefaultNrOfTries ($a_defaultnroftries)
 Set Default Nr of Tries. More...
 
 getDefaultNrOfTries ()
 Get Default Nr of Tries. More...
 
 syncSkillAssignments ($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId)
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not More...
 
 isAutosaveable ()
 
 getAdditionalContentEditingMode ()
 getter for additional content editing mode for this question More...
 
 setAdditionalContentEditingMode ($additinalContentEditingMode)
 setter for additional content editing mode for this question More...
 
 isAdditionalContentEditingModePageObject ()
 isser for additional "pageobject" content editing mode More...
 
 isValidAdditionalContentEditingMode ($additionalContentEditingMode)
 returns the fact wether the passed additional content mode is valid or not More...
 
 getValidAdditionalContentEditingModes ()
 getter for valid additional content editing modes More...
 
 addQuestionChangeListener (ilQuestionChangeListener $listener)
 
 getQuestionChangeListeners ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution ($active_id, $pass)
 
 removeCurrentSolution ($active_id, $pass, $authorized=true)
 
 saveCurrentSolution ($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
 
 updateCurrentSolution ($solutionId, $value1, $value2, $authorized=true)
 
 updateCurrentSolutionsAuthorization ($activeId, $pass, $authorized, $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
 intermediateSolutionExists ($active_id, $pass)
 
 authorizedSolutionExists ($active_id, $pass)
 
 authorizedOrIntermediateSolutionExists ($active_id, $pass)
 
 isAddableAnswerOptionValue ($qIndex, $answerOptionValue)
 
 addAnswerOptionValue ($qIndex, $answerOptionValue, $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions ($activeId, $pass)
 
 resetUsersAnswer ($activeId, $pass)
 
 removeResultRecord ($activeId, $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered ($obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 Get the test question configuration (initialised once) More...
 
 savePartial ()
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
- Public Member Functions inherited from iQuestionCondition
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 

Data Fields

 $matchingpairs
 
 $matching_type
 
 $thumb_geometry = 100
 
 $element_height
 
const MATCHING_MODE_1_ON_1 = '1:1'
 
const MATCHING_MODE_N_ON_N = 'n:n'
 
- 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

 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 generateThumbForFile ($path, $file)
 
 calculateReachedPointsForSolution ($found_values)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 {} More...
 
- Protected Member Functions inherited from assQuestion
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission ($postSubmissionFieldname)
 
 ensureCurrentTestPass ($active_id, $pass)
 
 lookupCurrentTestPass ($active_id, $pass)
 
 lookupTestId ($active_id)
 
 log ($active_id, $langVar)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID. More...
 
 onDuplicate ($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test) More...
 
 beforeSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 onCopy ($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId)
 Will be called when a question is copied (into another question pool) More...
 
 duplicateSuggestedSolutionFiles ($parent_id, $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles ($original_id)
 Syncs the files of a suggested solution if the question is synced. More...
 
 copySuggestedSolutionFiles ($source_questionpool_id, $source_question_id)
 
 ensureNonNegativePoints ($points)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 
 duplicateSkillAssignments ($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet ($active_id, $pass, $authorized=true)
 Get a restulset for the current user solution for a this question by active_id and pass. More...
 
 removeSolutionRecordById ($solutionId)
 
 getSolutionRecordById ($solutionId)
 
 deleteDummySolutionRecord ($activeId, $passIndex)
 
 isDummySolutionRecord ($solutionRecord)
 
 deleteSolutionRecordByValues ($activeId, $passIndex, $authorized, $matchValues)
 
 duplicateIntermediateSolutionAuthorized ($activeId, $passIndex)
 
 forceExistingIntermediateSolution ($activeId, $passIndex, $considerDummyRecordCreation)
 
 buildTestPresentationConfig ()
 build basic test question configuration instance More...
 

Protected Attributes

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

Private Member Functions

 getPositiveScoredMatchingPairs ()
 
 getMostPositiveScoredUniqueTermMatchingPairs ()
 
 fetchSubmittedMatchingsFromPost ()
 
 checkSubmittedMatchings ($submittedMatchings)
 

Additional Inherited Members

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

Detailed Description

Class for matching questions.

assMatchingQuestion is a class for matching questions.

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

Definition at line 24 of file class.assMatchingQuestion.php.

Constructor & Destructor Documentation

◆ __construct()

assMatchingQuestion::__construct (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $question = "",
  $matching_type = MT_TERMS_DEFINITIONS 
)

assMatchingQuestion constructor

The constructor takes possible arguments an creates an instance of the assMatchingQuestion 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$questionThe question string of the matching question
int$matching_type
Returns
\assMatchingQuestion

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

92 {
94 $this->matchingpairs = array();
95 $this->matching_type = $matching_type;
96 $this->terms = array();
97 $this->definitions = array();
98 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addDefinition()

assMatchingQuestion::addDefinition (   $definition)

Adds a definition.

Parameters
object$definitionThe definition
See also
$definitions

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

747 {
748 array_push($this->definitions, $definition);
749 }

◆ addMatchingPair()

assMatchingQuestion::addMatchingPair (   $term = null,
  $definition = null,
  $points = 0.0 
)

Adds an matching pair for an matching choice question.

The students have to fill in an order for the matching pair. The matching pair is an ASS_AnswerMatching object that will be created and assigned to the array $this->matchingpairs.

Parameters
assAnswerMatchingTerm | null$termA matching term
assAnswerMatchingDefinition | null$definitionA matching definition
float$pointsThe points for selecting the matching pair, incl. negative.
See also
$matchingpairs

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

581 {
582 require_once './Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php';
583 require_once './Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php';
584 require_once './Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php';
585 if (is_null($term)) {
586 $term = new assAnswerMatchingTerm();
587 }
588 if (is_null($definition)) {
589 $definition = new assAnswerMatchingDefinition();
590 }
591 $pair = new assAnswerMatchingPair($term, $definition, $points);
592 array_push($this->matchingpairs, $pair);
593 }
Class for matching question definitions.
Class for matching question pairs.
Class for matching question terms.

References assQuestion\$points.

◆ addTerm()

assMatchingQuestion::addTerm (   $term)

Adds a term.

Parameters
string$termThe text of the term
See also
$terms

Definition at line 735 of file class.assMatchingQuestion.php.

736 {
737 array_push($this->terms, $term);
738 }

◆ afterSyncWithOriginal()

assMatchingQuestion::afterSyncWithOriginal (   $origQuestionId,
  $dupQuestionId,
  $origParentObjId,
  $dupParentObjId 
)
protected

{}

Reimplemented from assQuestion.

Definition at line 1599 of file class.assMatchingQuestion.php.

1600 {
1601 parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
1602
1603 $origImagePath = $this->buildImagePath($origQuestionId, $origParentObjId);
1604 $dupImagePath = $this->buildImagePath($dupQuestionId, $dupParentObjId);
1605
1606 ilUtil::delDir($origImagePath);
1607 if (is_dir($dupImagePath)) {
1608 ilUtil::makeDirParents($origImagePath);
1609 ilUtil::rCopy($dupImagePath, $origImagePath);
1610 }
1611 }
buildImagePath($questionId, $parentObjectId)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References assQuestion\buildImagePath(), ilUtil\delDir(), ilUtil\makeDirParents(), and ilUtil\rCopy().

+ Here is the call graph for this function:

◆ calculateReachedPoints()

assMatchingQuestion::calculateReachedPoints (   $active_id,
  $pass = null,
  $authorizedSolution = true,
  $returndetails = false 
)

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

The points are calculated from the given answers.

@access public

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

Reimplemented from assQuestion.

Definition at line 857 of file class.assMatchingQuestion.php.

858 {
859 if ($returndetails) {
860 throw new ilTestException('return details not implemented for ' . __METHOD__);
861 }
862
863 global $DIC;
864 $ilDB = $DIC['ilDB'];
865
866 $found_values = array();
867 if (is_null($pass)) {
868 $pass = $this->getSolutionMaxPass($active_id);
869 }
870 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
871 while ($data = $ilDB->fetchAssoc($result)) {
872 if (strcmp($data["value1"], "") != 0) {
873 if (!isset($found_values[$data['value2']])) {
874 $found_values[$data['value2']] = array();
875 }
876
877 $found_values[$data['value2']][] = $data['value1'];
878 }
879 }
880
881 $points = $this->calculateReachedPointsForSolution($found_values);
882
883 return $points;
884 }
$result
calculateReachedPointsForSolution($found_values)
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
global $ilDB
$data
Definition: storeScorm.php:23
$DIC
Definition: xapitoken.php:46

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

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assMatchingQuestion::calculateReachedPointsForSolution (   $found_values)
protected
Parameters
$found_values
Returns
int

Definition at line 1468 of file class.assMatchingQuestion.php.

1469 {
1470 $points = 0;
1471 foreach ($found_values as $definition => $terms) {
1472 foreach ($terms as $term) {
1473 foreach ($this->matchingpairs as $pair) {
1474 if ($pair->definition->identifier == $definition && $pair->term->identifier == $term) {
1475 $points += $pair->points;
1476 }
1477 }
1478 }
1479 }
1480 return $points;
1481 }

References assQuestion\$points, and $terms.

Referenced by calculateReachedPoints().

+ Here is the caller graph for this function:

◆ checkSubmittedMatchings()

assMatchingQuestion::checkSubmittedMatchings (   $submittedMatchings)
private

Definition at line 1071 of file class.assMatchingQuestion.php.

1072 {
1073 if ($this->getMatchingMode() == self::MATCHING_MODE_N_ON_N) {
1074 return true;
1075 }
1076
1077 $handledTerms = array();
1078
1079 foreach ($submittedMatchings as $definition => $terms) {
1080 if (count($terms) > 1) {
1081 ilUtil::sendFailure($this->lng->txt("multiple_matching_values_selected"), true);
1082 return false;
1083 }
1084
1085 foreach ($terms as $i => $term) {
1086 if (isset($handledTerms[$term])) {
1087 ilUtil::sendFailure($this->lng->txt("duplicate_matching_values_selected"), true);
1088 return false;
1089 }
1090
1091 $handledTerms[$term] = $term;
1092 }
1093 }
1094
1095 return true;
1096 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$i
Definition: metadata.php:24

References $i, $terms, getMatchingMode(), and ilUtil\sendFailure().

Referenced by savePreviewData(), and saveWorkingData().

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

◆ copyImages()

assMatchingQuestion::copyImages (   $question_id,
  $source_questionpool 
)

Definition at line 494 of file class.assMatchingQuestion.php.

495 {
496 global $DIC;
497 $ilLog = $DIC['ilLog'];
498
499 $imagepath = $this->getImagePath();
500 $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
501 $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
502 foreach ($this->terms as $term) {
503 if (strlen($term->picture)) {
504 if (!file_exists($imagepath)) {
505 ilUtil::makeDirParents($imagepath);
506 }
507 $filename = $term->picture;
508 if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
509 $ilLog->write("matching question image could not be copied: $imagepath_original$filename");
510 }
511 if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
512 $ilLog->write("matching question image thumbnail could not be copied: $imagepath_original" . $this->getThumbPrefix() . $filename);
513 }
514 }
515 }
516 foreach ($this->definitions as $definition) {
517 if (strlen($definition->picture)) {
518 $filename = $definition->picture;
519 if (!file_exists($imagepath)) {
520 ilUtil::makeDirParents($imagepath);
521 }
522
523 if (assQuestion::isFileAvailable($imagepath_original . $filename)) {
524 copy($imagepath_original . $filename, $imagepath . $filename);
525 } else {
526 $ilLog->write("matching question image could not be copied: $imagepath_original$filename");
527 }
528
529 if (assQuestion::isFileAvailable($imagepath_original . $this->getThumbPrefix() . $filename)) {
530 copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename);
531 } else {
532 $ilLog->write("matching question image thumbnail could not be copied: $imagepath_original" . $this->getThumbPrefix() . $filename);
533 }
534 }
535 }
536 }
$filename
Definition: buildRTE.php:89
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static isFileAvailable($file)

References $DIC, $filename, $ilLog, assQuestion\getImagePath(), getThumbPrefix(), assQuestion\isFileAvailable(), and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ copyObject()

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

Copies an assMatchingQuestion.

Definition at line 385 of file class.assMatchingQuestion.php.

386 {
387 if ($this->id <= 0) {
388 // The question has not been saved. It cannot be duplicated
389 return;
390 }
391 // duplicate the question in database
392 $clone = $this;
393 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
395 $clone->id = -1;
396 $source_questionpool_id = $this->getObjId();
397 $clone->setObjId($target_questionpool_id);
398 if ($title) {
399 $clone->setTitle($title);
400 }
401 $clone->saveToDb();
402 // copy question page content
403 $clone->copyPageOfQuestion($original_id);
404 // copy XHTML media objects
405 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
406 // duplicate the image
407 $clone->copyImages($original_id, $source_questionpool_id);
408
409 $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
410
411 return $clone->id;
412 }
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.

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

+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

Definition at line 414 of file class.assMatchingQuestion.php.

415 {
416 if ($this->id <= 0) {
417 // The question has not been saved. It cannot be duplicated
418 return;
419 }
420
421 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
422
423 $sourceQuestionId = $this->id;
424 $sourceParentId = $this->getObjId();
425
426 // duplicate the question in database
427 $clone = $this;
428 $clone->id = -1;
429
430 $clone->setObjId($targetParentId);
431
432 if ($targetQuestionTitle) {
433 $clone->setTitle($targetQuestionTitle);
434 }
435
436 $clone->saveToDb();
437 // copy question page content
438 $clone->copyPageOfQuestion($sourceQuestionId);
439 // copy XHTML media objects
440 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
441 // duplicate the image
442 $clone->copyImages($sourceQuestionId, $sourceParentId);
443
444 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
445
446 return $clone->id;
447 }

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

+ Here is the call graph for this function:

◆ deleteDefinition()

assMatchingQuestion::deleteDefinition (   $position)

Deletes a definition.

Parameters
integer$positionThe position of the definition in the definition array
See also
$definitions

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

830 {
831 unset($this->definitions[$position]);
832 $this->definitions = array_values($this->definitions);
833 }

◆ deleteImagefile()

assMatchingQuestion::deleteImagefile (   $filename)

Deletes an imagefile from the system if the file is deleted manually.

Parameters
string$filenameImage file filename
Returns
boolean Success

Definition at line 1008 of file class.assMatchingQuestion.php.

1009 {
1010 $deletename = $filename;
1011 $result = @unlink($this->getImagePath() . $deletename);
1012 $result = $result & @unlink($this->getImagePath() . $this->getThumbPrefix() . $deletename);
1013 return $result;
1014 }

References $filename, $result, assQuestion\getImagePath(), and getThumbPrefix().

Referenced by removeDefinitionImage(), removeTermImage(), and setImageFile().

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

◆ deleteMatchingPair()

assMatchingQuestion::deleteMatchingPair (   $index = 0)

Deletes a matching pair with a given index.

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

Parameters
integer$indexA nonnegative index of the n-th matching pair
See also
$matchingpairs

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

651 {
652 if ($index < 0) {
653 return;
654 }
655 if (count($this->matchingpairs) < 1) {
656 return;
657 }
658 if ($index >= count($this->matchingpairs)) {
659 return;
660 }
661 unset($this->matchingpairs[$index]);
662 $this->matchingpairs = array_values($this->matchingpairs);
663 }
$index
Definition: metadata.php:128

References $index.

◆ deleteTerm()

assMatchingQuestion::deleteTerm (   $position)

Deletes a term.

Parameters
string$term_idThe id of the term to delete
See also
$terms

Definition at line 817 of file class.assMatchingQuestion.php.

818 {
819 unset($this->terms[$position]);
820 $this->terms = array_values($this->terms);
821 }

◆ duplicate()

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

Duplicates an assMatchingQuestion.

Reimplemented from assQuestion.

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

337 {
338 if ($this->id <= 0) {
339 // The question has not been saved. It cannot be duplicated
340 return;
341 }
342 // duplicate the question in database
343 $this_id = $this->getId();
344 $thisObjId = $this->getObjId();
345
346 $clone = $this;
347 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
349 $clone->id = -1;
350
351 if ((int) $testObjId > 0) {
352 $clone->setObjId($testObjId);
353 }
354
355 if ($title) {
356 $clone->setTitle($title);
357 }
358 if ($author) {
359 $clone->setAuthor($author);
360 }
361 if ($owner) {
362 $clone->setOwner($owner);
363 }
364 if ($for_test) {
365 $clone->saveToDb($original_id);
366 } else {
367 $clone->saveToDb();
368 }
369
370 // copy question page content
371 $clone->copyPageOfQuestion($this_id);
372 // copy XHTML media objects
373 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
374 // duplicate the image
375 $clone->duplicateImages($this_id, $thisObjId, $clone->getId(), $testObjId);
376
377 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
378
379 return $clone->id;
380 }
getId()
Gets the id of the assQuestion object.

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

+ Here is the call graph for this function:

◆ duplicateImages()

assMatchingQuestion::duplicateImages (   $question_id,
  $objectId = null 
)

Definition at line 449 of file class.assMatchingQuestion.php.

450 {
451 global $DIC;
452 $ilLog = $DIC['ilLog'];
453 $imagepath = $this->getImagePath();
454 $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
455
456 if ((int) $objectId > 0) {
457 $imagepath_original = str_replace("/$this->obj_id/", "/$objectId/", $imagepath_original);
458 }
459
460 foreach ($this->terms as $term) {
461 if (strlen($term->picture)) {
462 $filename = $term->picture;
463 if (!file_exists($imagepath)) {
464 ilUtil::makeDirParents($imagepath);
465 }
466 if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
467 $ilLog->write("matching question image could not be duplicated: $imagepath_original$filename");
468 }
469 if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename)) {
470 if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
471 $ilLog->write("matching question image thumbnail could not be duplicated: $imagepath_original" . $this->getThumbPrefix() . $filename);
472 }
473 }
474 }
475 }
476 foreach ($this->definitions as $definition) {
477 if (strlen($definition->picture)) {
478 $filename = $definition->picture;
479 if (!file_exists($imagepath)) {
480 ilUtil::makeDirParents($imagepath);
481 }
482 if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
483 $ilLog->write("matching question image could not be duplicated: $imagepath_original$filename");
484 }
485 if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename)) {
486 if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
487 $ilLog->write("matching question image thumbnail could not be duplicated: $imagepath_original" . $this->getThumbPrefix() . $filename);
488 }
489 }
490 }
491 }
492 }

References $DIC, $filename, $ilLog, assQuestion\getImagePath(), getThumbPrefix(), and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ fetchIndexedValuesFromValuePairs()

assMatchingQuestion::fetchIndexedValuesFromValuePairs ( array  $valuePairs)
Parameters
array$valuePairs
Returns
array $indexedValues

Reimplemented from assQuestion.

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

952 {
953 $indexedValues = array();
954
955 foreach ($valuePairs as $valuePair) {
956 if (!isset($indexedValues[$valuePair['value2']])) {
957 $indexedValues[$valuePair['value2']] = array();
958 }
959
960 $indexedValues[$valuePair['value2']][] = $valuePair['value1'];
961 }
962
963 return $indexedValues;
964 }

◆ fetchSubmittedMatchingsFromPost()

assMatchingQuestion::fetchSubmittedMatchingsFromPost ( )
private

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

1049 {
1050 $postData = $_POST['matching'][$this->getId()];
1051
1052 $matchings = array();
1053
1054 foreach ($this->getDefinitions() as $definition) {
1055 if (isset($postData[$definition->identifier])) {
1056 foreach ($this->getTerms() as $term) {
1057 if (isset($postData[$definition->identifier][$term->identifier])) {
1058 if (!is_array($postData[$definition->identifier])) {
1059 $postData[$definition->identifier] = array();
1060 }
1061
1062 $matchings[$definition->identifier][] = $term->identifier;
1063 }
1064 }
1065 }
1066 }
1067
1068 return $matchings;
1069 }
$_POST["username"]
getDefinitions()
Returns the definitions of the matching question.
getTerms()
Returns the terms of the matching question.

References $_POST, getDefinitions(), assQuestion\getId(), and getTerms().

Referenced by savePreviewData(), and saveWorkingData().

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

◆ flushDefinitions()

assMatchingQuestion::flushDefinitions ( )

Deletes all definitions.

See also
$definitions

Definition at line 806 of file class.assMatchingQuestion.php.

807 {
808 $this->definitions = array();
809 }

◆ flushMatchingPairs()

assMatchingQuestion::flushMatchingPairs ( )

Deletes all matching pairs.

See also
$matchingpairs

Definition at line 669 of file class.assMatchingQuestion.php.

670 {
671 $this->matchingpairs = array();
672 }

◆ flushTerms()

assMatchingQuestion::flushTerms ( )

Deletes all terms.

See also
$terms

Definition at line 797 of file class.assMatchingQuestion.php.

798 {
799 $this->terms = array();
800 }

◆ generateThumbForFile()

assMatchingQuestion::generateThumbForFile (   $path,
  $file 
)
protected

Definition at line 1335 of file class.assMatchingQuestion.php.

1336 {
1337 $filename = $path . $file;
1338 if (@file_exists($filename)) {
1339 $thumbpath = $path . $this->getThumbPrefix() . $file;
1340 $path_info = @pathinfo($filename);
1341 $ext = "";
1342 switch (strtoupper($path_info['extension'])) {
1343 case 'PNG':
1344 $ext = 'PNG';
1345 break;
1346 case 'GIF':
1347 $ext = 'GIF';
1348 break;
1349 default:
1350 $ext = 'JPEG';
1351 break;
1352 }
1353 ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbGeometry());
1354 }
1355 }
getThumbGeometry()
Get the thumbnail geometry.
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image

References $filename, ilUtil\convertImage(), getThumbGeometry(), and getThumbPrefix().

Referenced by rebuildThumbnails().

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

◆ getAdditionalTableName()

assMatchingQuestion::getAdditionalTableName ( )

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

Returns
string The additional table name

Reimplemented from assQuestion.

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

1213 {
1214 return "qpl_qst_matching";
1215 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAnswerTableName()

assMatchingQuestion::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name

Reimplemented from assQuestion.

Definition at line 1222 of file class.assMatchingQuestion.php.

1223 {
1224 return array("qpl_a_matching", "qpl_a_mterm");
1225 }

◆ getAvailableAnswerOptions()

assMatchingQuestion::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 1587 of file class.assMatchingQuestion.php.

1588 {
1589 if ($index !== null) {
1590 return $this->getMatchingPair($index);
1591 } else {
1592 return $this->getMatchingPairs();
1593 }
1594 }
getMatchingPair($index=0)
Returns a matching pair with a given index.
& getMatchingPairs()
Returns the matchingpairs array.

References $index, getMatchingPair(), and getMatchingPairs().

+ Here is the call graph for this function:

◆ getDefinitionCount()

assMatchingQuestion::getDefinitionCount ( )

Returns the number of definitions.

Returns
integer The number of definitions
See also
$definitions

Definition at line 724 of file class.assMatchingQuestion.php.

725 {
726 return count($this->definitions);
727 }

◆ getDefinitions()

assMatchingQuestion::getDefinitions ( )

Returns the definitions of the matching question.

Returns
array An array containing the definitions
See also
$terms

Definition at line 702 of file class.assMatchingQuestion.php.

References $definitions.

Referenced by fetchSubmittedMatchingsFromPost(), and toJSON().

+ Here is the caller graph for this function:

◆ getDefinitionWithIdentifier()

assMatchingQuestion::getDefinitionWithIdentifier (   $a_identifier)

Returns a definition with a given identifier.

Definition at line 611 of file class.assMatchingQuestion.php.

612 {
613 foreach ($this->definitions as $definition) {
614 if ($definition->identifier == $a_identifier) {
615 return $definition;
616 }
617 }
618 return null;
619 }

◆ getEncryptedFilename()

assMatchingQuestion::getEncryptedFilename (   $filename)

Returns the encrypted save filename of a matching picture Images are saved with an encrypted filename to prevent users from cheating by guessing the solution from the image filename.

Parameters
string$filenameOriginal filename
Returns
string Encrypted filename

Definition at line 974 of file class.assMatchingQuestion.php.

975 {
976 $extension = "";
977 if (preg_match("/.*\\.(\\w+)$/", $filename, $matches)) {
978 $extension = $matches[1];
979 }
980 return md5($filename) . "." . $extension;
981 }

References $filename.

◆ getExpressionTypes()

◆ getMatchingMode()

assMatchingQuestion::getMatchingMode ( )

Definition at line 1459 of file class.assMatchingQuestion.php.

References $matchingMode.

Referenced by checkSubmittedMatchings(), getMaximumScoringMatchingPairs(), saveAdditionalQuestionDataToDb(), and toJSON().

+ Here is the caller graph for this function:

◆ getMatchingPair()

assMatchingQuestion::getMatchingPair (   $index = 0)

Returns a matching pair with a given index.

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

Parameters
integer$indexA nonnegative index of the n-th matching pair
Returns
object ASS_AnswerMatching-Object
See also
$matchingpairs

Definition at line 629 of file class.assMatchingQuestion.php.

630 {
631 if ($index < 0) {
632 return null;
633 }
634 if (count($this->matchingpairs) < 1) {
635 return null;
636 }
637 if ($index >= count($this->matchingpairs)) {
638 return null;
639 }
640 return $this->matchingpairs[$index];
641 }

References $index.

Referenced by getAvailableAnswerOptions().

+ Here is the caller graph for this function:

◆ getMatchingPairCount()

assMatchingQuestion::getMatchingPairCount ( )

Returns the number of matching pairs.

Returns
integer The number of matching pairs of the matching question
See also
$matchingpairs

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

681 {
682 return count($this->matchingpairs);
683 }

◆ getMatchingPairs()

& assMatchingQuestion::getMatchingPairs ( )

Returns the matchingpairs array.

Definition at line 1239 of file class.assMatchingQuestion.php.

References $matchingpairs.

Referenced by getAvailableAnswerOptions(), saveAnswerSpecificDataToDb(), setExportDetailsXLS(), and toJSON().

+ Here is the caller graph for this function:

◆ getMaximumPoints()

assMatchingQuestion::getMaximumPoints ( )

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

Reimplemented from assQuestion.

Definition at line 889 of file class.assMatchingQuestion.php.

890 {
891 $points = 0;
892
893 foreach ($this->getMaximumScoringMatchingPairs() as $pair) {
894 $points += $pair->points;
895 }
896
897 return $points;
898 }

References assQuestion\$points, and getMaximumScoringMatchingPairs().

Referenced by isComplete().

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

◆ getMaximumScoringMatchingPairs()

assMatchingQuestion::getMaximumScoringMatchingPairs ( )

Definition at line 900 of file class.assMatchingQuestion.php.

901 {
902 if ($this->getMatchingMode() == self::MATCHING_MODE_N_ON_N) {
903 return $this->getPositiveScoredMatchingPairs();
904 } elseif ($this->getMatchingMode() == self::MATCHING_MODE_1_ON_1) {
906 }
907
908 return array();
909 }

References getMatchingMode(), getMostPositiveScoredUniqueTermMatchingPairs(), and getPositiveScoredMatchingPairs().

Referenced by getMaximumPoints().

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

◆ getMostPositiveScoredUniqueTermMatchingPairs()

assMatchingQuestion::getMostPositiveScoredUniqueTermMatchingPairs ( )
private

Definition at line 926 of file class.assMatchingQuestion.php.

927 {
928 $matchingPairsByDefinition = array();
929
930 foreach ($this->matchingpairs as $pair) {
931 if ($pair->points <= 0) {
932 continue;
933 }
934
935 $defId = $pair->definition->identifier;
936
937 if (!isset($matchingPairsByDefinition[$defId])) {
938 $matchingPairsByDefinition[$defId] = $pair;
939 } elseif ($pair->points > $matchingPairsByDefinition[$defId]->points) {
940 $matchingPairsByDefinition[$defId] = $pair;
941 }
942 }
943
944 return $matchingPairsByDefinition;
945 }

Referenced by getMaximumScoringMatchingPairs().

+ Here is the caller graph for this function:

◆ getOperators()

assMatchingQuestion::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

Definition at line 1491 of file class.assMatchingQuestion.php.

1492 {
1493 require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1495 }

References ilOperatorsExpressionMapping\getOperatorsByExpression().

+ Here is the call graph for this function:

◆ getPositiveScoredMatchingPairs()

assMatchingQuestion::getPositiveScoredMatchingPairs ( )
private

Definition at line 911 of file class.assMatchingQuestion.php.

912 {
913 $matchingPairs = array();
914
915 foreach ($this->matchingpairs as $pair) {
916 if ($pair->points <= 0) {
917 continue;
918 }
919
920 $matchingPairs[] = $pair;
921 }
922
923 return $matchingPairs;
924 }

Referenced by getMaximumScoringMatchingPairs().

+ Here is the caller graph for this function:

◆ getQuestionType()

assMatchingQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

Reimplemented from assQuestion.

Definition at line 1202 of file class.assMatchingQuestion.php.

1203 {
1204 return "assMatchingQuestion";
1205 }

Referenced by toJSON().

+ Here is the caller graph for this function:

◆ getRandomId()

assMatchingQuestion::getRandomId ( )

Definition at line 1159 of file class.assMatchingQuestion.php.

1160 {
1161 mt_srand((double) microtime() * 1000000);
1162 $random_number = mt_rand(1, 100000);
1163 $found = false;
1164 while ($found) {
1165 $found = false;
1166 foreach ($this->matchingpairs as $key => $pair) {
1167 if (($pair->term->identifier == $random_number) || ($pair->definition->identifier == $random_number)) {
1168 $found = true;
1169 $random_number++;
1170 }
1171 }
1172 }
1173 return $random_number;
1174 }

◆ getRTETextWithMediaObjects()

assMatchingQuestion::getRTETextWithMediaObjects ( )

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

Reimplemented from assQuestion.

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

1232 {
1233 return parent::getRTETextWithMediaObjects();
1234 }

◆ getTermCount()

assMatchingQuestion::getTermCount ( )

Returns the number of terms.

Returns
integer The number of terms
See also
$terms

Definition at line 713 of file class.assMatchingQuestion.php.

714 {
715 return count($this->terms);
716 }

◆ getTerms()

assMatchingQuestion::getTerms ( )

Returns the terms of the matching question.

Returns
array An array containing the terms
See also
$terms

Definition at line 691 of file class.assMatchingQuestion.php.

692 {
693 return $this->terms;
694 }

References $terms.

Referenced by fetchSubmittedMatchingsFromPost(), and toJSON().

+ Here is the caller graph for this function:

◆ getTermWithIdentifier()

assMatchingQuestion::getTermWithIdentifier (   $a_identifier)

Returns a term with a given identifier.

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

599 {
600 foreach ($this->terms as $term) {
601 if ($term->identifier == $a_identifier) {
602 return $term;
603 }
604 }
605 return null;
606 }

◆ getThumbGeometry()

assMatchingQuestion::getThumbGeometry ( )

Get the thumbnail geometry.

Returns
integer Geometry

Definition at line 1288 of file class.assMatchingQuestion.php.

References $thumb_geometry.

Referenced by generateThumbForFile(), getThumbSize(), saveAdditionalQuestionDataToDb(), and setImageFile().

+ Here is the caller graph for this function:

◆ getThumbPrefix()

assMatchingQuestion::getThumbPrefix ( )

Definition at line 1330 of file class.assMatchingQuestion.php.

1331 {
1332 return "thumb.";
1333 }

Referenced by copyImages(), deleteImagefile(), duplicateImages(), generateThumbForFile(), and setImageFile().

+ Here is the caller graph for this function:

◆ getThumbSize()

assMatchingQuestion::getThumbSize ( )

Get the thumbnail geometry.

Returns
integer Geometry

Definition at line 1298 of file class.assMatchingQuestion.php.

1299 {
1300 return $this->getThumbGeometry();
1301 }

References getThumbGeometry().

+ Here is the call graph for this function:

◆ insertDefinition()

assMatchingQuestion::insertDefinition (   $position,
  $definition = null 
)

Inserts a definition.

Parameters
object$definitionThe definition
See also
$definitions

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

779 {
780 if (is_null($definition)) {
781 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
782 $definition = new assAnswerMatchingDefinition();
783 }
784 if ($position < count($this->definitions)) {
785 $part1 = array_slice($this->definitions, 0, $position);
786 $part2 = array_slice($this->definitions, $position);
787 $this->definitions = array_merge($part1, array($definition), $part2);
788 } else {
789 array_push($this->definitions, $definition);
790 }
791 }

◆ insertMatchingPair()

assMatchingQuestion::insertMatchingPair (   $position,
  $term = null,
  $definition = null,
  $points = 0.0 
)

Inserts a matching pair for an matching choice question.

The students have to fill in an order for the matching pair. The matching pair is an ASS_AnswerMatching object that will be created and assigned to the array $this->matchingpairs.

Parameters
integer$positionThe insert position in the matching pairs array
object$termA matching term
object$definitionA matching definition
double$pointsThe points for selecting the matching pair (even negative points can be used)
See also
$matchingpairs

Definition at line 548 of file class.assMatchingQuestion.php.

549 {
550 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
551 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
552 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
553 if (is_null($term)) {
554 $term = new assAnswerMatchingTerm();
555 }
556 if (is_null($definition)) {
557 $definition = new assAnswerMatchingDefinition();
558 }
559 $pair = new assAnswerMatchingPair($term, $definition, $points);
560 if ($position < count($this->matchingpairs)) {
561 $part1 = array_slice($this->matchingpairs, 0, $position);
562 $part2 = array_slice($this->matchingpairs, $position);
563 $this->matchingpairs = array_merge($part1, array($pair), $part2);
564 } else {
565 array_push($this->matchingpairs, $pair);
566 }
567 }

References assQuestion\$points.

◆ insertTerm()

assMatchingQuestion::insertTerm (   $position,
  $term = null 
)

Inserts a term.

Parameters
string$termThe text of the term
See also
$terms

Definition at line 757 of file class.assMatchingQuestion.php.

758 {
759 if (is_null($term)) {
760 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
761 $term = new assAnswerMatchingTerm();
762 }
763 if ($position < count($this->terms)) {
764 $part1 = array_slice($this->terms, 0, $position);
765 $part2 = array_slice($this->terms, $position);
766 $this->terms = array_merge($part1, array($term), $part2);
767 } else {
768 array_push($this->terms, $term);
769 }
770 }

◆ isComplete()

assMatchingQuestion::isComplete ( )

Returns true, if a matching question is complete for use.

Returns
boolean True, if the matching question is complete for use, otherwise false

Reimplemented from assQuestion.

Definition at line 105 of file class.assMatchingQuestion.php.

106 {
107 if (strlen($this->title)
108 && $this->author
109 && $this->question
110 && count($this->matchingpairs)
111 && $this->getMaximumPoints() > 0
112 ) {
113 return true;
114 }
115 return false;
116 }
getMaximumPoints()
Calculates and Returns the maximum points, a learner can reach answering the question.

References getMaximumPoints().

+ Here is the call graph for this function:

◆ loadFromDb()

assMatchingQuestion::loadFromDb (   $question_id)

Loads a assMatchingQuestion object from a database.

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

Reimplemented from assQuestion.

Definition at line 235 of file class.assMatchingQuestion.php.

236 {
237 global $DIC;
238 $ilDB = $DIC['ilDB'];
239
240 $query = "
241 SELECT qpl_questions.*,
242 {$this->getAdditionalTableName()}.*
243 FROM qpl_questions
244 LEFT JOIN {$this->getAdditionalTableName()}
245 ON {$this->getAdditionalTableName()}.question_fi = qpl_questions.question_id
246 WHERE qpl_questions.question_id = %s
247 ";
248
249 $result = $ilDB->queryF(
250 $query,
251 array('integer'),
252 array($question_id)
253 );
254
255 if ($result->numRows() == 1) {
256 $data = $ilDB->fetchAssoc($result);
257 $this->setId($question_id);
258 $this->setObjId($data["obj_fi"]);
259 $this->setTitle($data["title"]);
260 $this->setComment($data["description"]);
261 $this->setOriginalId($data["original_id"]);
262 $this->setNrOfTries($data['nr_of_tries']);
263 $this->setAuthor($data["author"]);
264 $this->setPoints($data["points"]);
265 $this->setOwner($data["owner"]);
266 include_once("./Services/RTE/classes/class.ilRTE.php");
267 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
268 $this->setThumbGeometry($data["thumb_geometry"]);
269 $this->setShuffle($data["shuffle"]);
270 $this->setMatchingMode($data['matching_mode'] === null ? self::MATCHING_MODE_1_ON_1 : $data['matching_mode']);
271 $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
272
273 try {
277 }
278
279 try {
280 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
282 }
283 }
284
285 $termids = array();
286 $result = $ilDB->queryF(
287 "SELECT * FROM qpl_a_mterm WHERE question_fi = %s ORDER BY term_id ASC",
288 array('integer'),
289 array($question_id)
290 );
291 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
292 $this->terms = array();
293 if ($result->numRows() > 0) {
294 while ($data = $ilDB->fetchAssoc($result)) {
295 $term = new assAnswerMatchingTerm($data['term'], $data['picture'], $data['ident']);
296 array_push($this->terms, $term);
297 $termids[$data['term_id']] = $term;
298 }
299 }
300
301 $definitionids = array();
302 $result = $ilDB->queryF(
303 "SELECT * FROM qpl_a_mdef WHERE question_fi = %s ORDER BY def_id ASC",
304 array('integer'),
305 array($question_id)
306 );
307 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
308 $this->definitions = array();
309 if ($result->numRows() > 0) {
310 while ($data = $ilDB->fetchAssoc($result)) {
311 $definition = new assAnswerMatchingDefinition($data['definition'], $data['picture'], $data['ident']);
312 array_push($this->definitions, $definition);
313 $definitionids[$data['def_id']] = $definition;
314 }
315 }
316
317 $this->matchingpairs = array();
318 $result = $ilDB->queryF(
319 "SELECT * FROM qpl_a_matching WHERE question_fi = %s ORDER BY answer_id",
320 array('integer'),
321 array($question_id)
322 );
323 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
324 if ($result->numRows() > 0) {
325 while ($data = $ilDB->fetchAssoc($result)) {
326 array_push($this->matchingpairs, new assAnswerMatchingPair($termids[$data['term_fi']], $definitionids[$data['definition_fi']], $data['points']));
327 }
328 }
329 parent::loadFromDb($question_id);
330 }
setThumbGeometry($a_geometry)
Set the thumbnail geometry.
setShuffle($shuffle=true)
Sets the shuffle flag.
setId($id=-1)
Sets the id of the assQuestion object.
setOriginalId($original_id)
setObjId($obj_id=0)
Set the object id of the container object.
setTitle($title="")
Sets the title string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second.
setAuthor($author="")
Sets the authors name of the assQuestion object.
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setPoints($a_points)
Sets the maximum available points for the question.
setComment($comment="")
Sets the comment string of the assQuestion object.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setQuestion($question="")
Sets the question string of the question object.
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...
$query

References $data, $DIC, Vendor\Package\$e, $ilDB, $query, $result, ilRTE\_replaceMediaObjectImageSrc(), ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setEstimatedWorkingTime(), assQuestion\setId(), assQuestion\setLifecycle(), setMatchingMode(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setShuffle(), setThumbGeometry(), and assQuestion\setTitle().

+ Here is the call graph for this function:

◆ rebuildThumbnails()

assMatchingQuestion::rebuildThumbnails ( )

Rebuild the thumbnail images with a new thumbnail size.

Definition at line 1316 of file class.assMatchingQuestion.php.

1317 {
1318 foreach ($this->terms as $term) {
1319 if (strlen($term->picture)) {
1320 $this->generateThumbForFile($this->getImagePath(), $term->picture);
1321 }
1322 }
1323 foreach ($this->definitions as $definition) {
1324 if (strlen($definition->picture)) {
1325 $this->generateThumbForFile($this->getImagePath(), $definition->picture);
1326 }
1327 }
1328 }

References generateThumbForFile(), and assQuestion\getImagePath().

Referenced by saveAnswerSpecificDataToDb().

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

◆ removeDefinitionImage()

assMatchingQuestion::removeDefinitionImage (   $index)

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

993 {
994 $definition = $this->definitions[$index];
995 if (is_object($definition)) {
996 $this->deleteImagefile($definition->picture);
997 $definition->picture = null;
998 }
999 }
deleteImagefile($filename)
Deletes an imagefile from the system if the file is deleted manually.

References $index, and deleteImagefile().

+ Here is the call graph for this function:

◆ removeTermImage()

assMatchingQuestion::removeTermImage (   $index)

Definition at line 983 of file class.assMatchingQuestion.php.

984 {
985 $term = $this->terms[$index];
986 if (is_object($term)) {
987 $this->deleteImagefile($term->picture);
988 $term->picture = null;
989 }
990 }

References $index, and deleteImagefile().

+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assMatchingQuestion::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

Definition at line 207 of file class.assMatchingQuestion.php.

208 {
209 global $DIC;
210 $ilDB = $DIC['ilDB'];
211
212 // save additional data
213
214 $ilDB->manipulateF(
215 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
216 array( "integer" ),
217 array( $this->getId() )
218 );
219
220 $ilDB->insert($this->getAdditionalTableName(), array(
221 'question_fi' => array('integer', $this->getId()),
222 'shuffle' => array('text', $this->shuffle),
223 'matching_type' => array('text', $this->matching_type),
224 'thumb_geometry' => array('integer', $this->getThumbGeometry()),
225 'matching_mode' => array('text', $this->getMatchingMode())
226 ));
227 }
getAdditionalTableName()
Returns the name of the additional question data table in the database.

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

Referenced by saveToDb().

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

◆ saveAnswerSpecificDataToDb()

assMatchingQuestion::saveAnswerSpecificDataToDb ( )

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

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

Definition at line 137 of file class.assMatchingQuestion.php.

138 {
139 global $DIC;
140 $ilDB = $DIC['ilDB'];
141 // delete old terms
142 $ilDB->manipulateF(
143 "DELETE FROM qpl_a_mterm WHERE question_fi = %s",
144 array( 'integer' ),
145 array( $this->getId() )
146 );
147
148 // delete old definitions
149 $ilDB->manipulateF(
150 "DELETE FROM qpl_a_mdef WHERE question_fi = %s",
151 array( 'integer' ),
152 array( $this->getId() )
153 );
154
155 $termids = array();
156 // write terms
157 foreach ($this->terms as $key => $term) {
158 $next_id = $ilDB->nextId('qpl_a_mterm');
159 $ilDB->insert('qpl_a_mterm', array(
160 'term_id' => array('integer', $next_id),
161 'question_fi' => array('integer', $this->getId()),
162 'picture' => array('text', $term->picture),
163 'term' => array('text', $term->text),
164 'ident' => array('integer', $term->identifier)
165 ));
166 $termids[$term->identifier] = $next_id;
167 }
168
169 $definitionids = array();
170 // write definitions
171 foreach ($this->definitions as $key => $definition) {
172 $next_id = $ilDB->nextId('qpl_a_mdef');
173 $ilDB->insert('qpl_a_mdef', array(
174 'def_id' => array('integer', $next_id),
175 'question_fi' => array('integer', $this->getId()),
176 'picture' => array('text', $definition->picture),
177 'definition' => array('text', $definition->text),
178 'ident' => array('integer', $definition->identifier)
179 ));
180 $definitionids[$definition->identifier] = $next_id;
181 }
182
183 $ilDB->manipulateF(
184 "DELETE FROM qpl_a_matching WHERE question_fi = %s",
185 array( 'integer' ),
186 array( $this->getId() )
187 );
189 foreach ($matchingpairs as $key => $pair) {
190 $next_id = $ilDB->nextId('qpl_a_matching');
191 $ilDB->manipulateF(
192 "INSERT INTO qpl_a_matching (answer_id, question_fi, points, term_fi, definition_fi) VALUES (%s, %s, %s, %s, %s)",
193 array( 'integer', 'integer', 'float', 'integer', 'integer' ),
194 array(
195 $next_id,
196 $this->getId(),
197 $pair->points,
198 $termids[$pair->term->identifier],
199 $definitionids[$pair->definition->identifier]
200 )
201 );
202 }
203
204 $this->rebuildThumbnails();
205 }
rebuildThumbnails()
Rebuild the thumbnail images with a new thumbnail size.

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

Referenced by saveToDb().

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

◆ savePreviewData()

assMatchingQuestion::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

Reimplemented from assQuestion.

Definition at line 1150 of file class.assMatchingQuestion.php.

1151 {
1152 $submittedMatchings = $this->fetchSubmittedMatchingsFromPost();
1153
1154 if ($this->checkSubmittedMatchings($submittedMatchings)) {
1155 $previewSession->setParticipantsSolution($submittedMatchings);
1156 }
1157 }
checkSubmittedMatchings($submittedMatchings)

References checkSubmittedMatchings(), fetchSubmittedMatchingsFromPost(), and ilAssQuestionPreviewSession\setParticipantsSolution().

+ Here is the call graph for this function:

◆ saveToDb()

assMatchingQuestion::saveToDb (   $original_id = "")

Saves a assMatchingQuestion object to a database.

Parameters
string$original_id

Reimplemented from assQuestion.

Definition at line 124 of file class.assMatchingQuestion.php.

125 {
126 global $DIC;
127 $ilDB = $DIC['ilDB'];
128
132
133
134 parent::saveToDb($original_id);
135 }
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb($original_id="")

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

+ Here is the call graph for this function:

◆ saveWorkingData()

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

Saves the learners input of the question to the database.

@access public

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

Reimplemented from assQuestion.

Definition at line 1106 of file class.assMatchingQuestion.php.

1107 {
1108 global $DIC;
1109 $ilDB = $DIC['ilDB'];
1110
1111 $submittedMatchings = $this->fetchSubmittedMatchingsFromPost();
1112 $submittedMatchingsValid = $this->checkSubmittedMatchings($submittedMatchings);
1113
1114 $matchingsExist = false;
1115
1116 if ($submittedMatchingsValid) {
1117 if (is_null($pass)) {
1118 include_once "./Modules/Test/classes/class.ilObjTest.php";
1119 $pass = ilObjTest::_getPass($active_id);
1120 }
1121
1122 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$matchingsExist, $submittedMatchings, $active_id, $pass, $authorized) {
1123 $this->removeCurrentSolution($active_id, $pass, $authorized);
1124
1125 foreach ($submittedMatchings as $definition => $terms) {
1126 foreach ($terms as $i => $term) {
1127 $this->saveCurrentSolution($active_id, $pass, $term, $definition, $authorized);
1128 $matchingsExist = true;
1129 }
1130 }
1131 });
1132
1133 $saveWorkingDataResult = true;
1134 } else {
1135 $saveWorkingDataResult = false;
1136 }
1137
1138 include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1140 if ($matchingsExist) {
1141 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1142 } else {
1143 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1144 }
1145 }
1146
1147 return $saveWorkingDataResult;
1148 }
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
removeCurrentSolution($active_id, $pass, $authorized=true)
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.

References $DIC, $i, $ilDB, $pass, $terms, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), checkSubmittedMatchings(), fetchSubmittedMatchingsFromPost(), assQuestion\getProcessLocker(), assQuestion\logAction(), assQuestion\removeCurrentSolution(), and assQuestion\saveCurrentSolution().

+ Here is the call graph for this function:

◆ setExportDetailsXLS()

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

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

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

Reimplemented from assQuestion.

Definition at line 1247 of file class.assMatchingQuestion.php.

1248 {
1249 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
1250
1251 $solutions = $this->getSolutionValues($active_id, $pass);
1252
1253 $imagepath = $this->getImagePath();
1254 $i = 1;
1255 foreach ($solutions as $solution) {
1256 $matches_written = false;
1257 foreach ($this->getMatchingPairs() as $idx => $pair) {
1258 if (!$matches_written) {
1259 $worksheet->setCell($startrow + $i, 1, $this->lng->txt("matches"));
1260 }
1261 $matches_written = true;
1262 if ($pair->definition->identifier == $solution["value2"]) {
1263 if (strlen($pair->definition->text)) {
1264 $worksheet->setCell($startrow + $i, 0, $pair->definition->text);
1265 } else {
1266 $worksheet->setCell($startrow + $i, 0, $pair->definition->picture);
1267 }
1268 }
1269 if ($pair->term->identifier == $solution["value1"]) {
1270 if (strlen($pair->term->text)) {
1271 $worksheet->setCell($startrow + $i, 2, $pair->term->text);
1272 } else {
1273 $worksheet->setCell($startrow + $i, 2, $pair->term->picture);
1274 }
1275 }
1276 }
1277 $i++;
1278 }
1279
1280 return $startrow + $i + 1;
1281 }
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.

References $i, $pass, assQuestion\getImagePath(), getMatchingPairs(), and assQuestion\getSolutionValues().

+ Here is the call graph for this function:

◆ setImageFile()

assMatchingQuestion::setImageFile (   $image_tempfilename,
  $image_filename,
  $previous_filename = '' 
)

Sets the image file and uploads the image to the object's image directory.

Parameters
string$image_filenameName of the original image file
string$image_tempfilenameName of the temporary uploaded image file
Returns
integer An errorcode if the image upload fails, 0 otherwise @access public

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

1025 {
1026 $result = true;
1027 if (strlen($image_tempfilename)) {
1028 $image_filename = str_replace(" ", "_", $image_filename);
1029 $imagepath = $this->getImagePath();
1030 if (!file_exists($imagepath)) {
1031 ilUtil::makeDirParents($imagepath);
1032 }
1033 $savename = $image_filename;
1034 if (!ilUtil::moveUploadedFile($image_tempfilename, $savename, $imagepath . $savename)) {
1035 $result = false;
1036 } else {
1037 // create thumbnail file
1038 $thumbpath = $imagepath . $this->getThumbPrefix() . $savename;
1039 ilUtil::convertImage($imagepath . $savename, $thumbpath, "JPEG", $this->getThumbGeometry());
1040 }
1041 if ($result && (strcmp($image_filename, $previous_filename) != 0) && (strlen($previous_filename))) {
1042 $this->deleteImagefile($previous_filename);
1043 }
1044 }
1045 return $result;
1046 }
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

References $result, ilUtil\convertImage(), deleteImagefile(), assQuestion\getImagePath(), getThumbGeometry(), getThumbPrefix(), ilUtil\makeDirParents(), and ilUtil\moveUploadedFile().

+ Here is the call graph for this function:

◆ setMatchingMode()

assMatchingQuestion::setMatchingMode (   $matchingMode)

Definition at line 1454 of file class.assMatchingQuestion.php.

1455 {
1456 $this->matchingMode = $matchingMode;
1457 }

References $matchingMode.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setShuffle()

assMatchingQuestion::setShuffle (   $shuffle = true)

Sets the shuffle flag.

Parameters
integer$shuffleA flag indicating whether the answers are shuffled or not
See also
$shuffle

Reimplemented from assQuestion.

Definition at line 1182 of file class.assMatchingQuestion.php.

1183 {
1184 switch ($shuffle) {
1185 case 0:
1186 case 1:
1187 case 2:
1188 case 3:
1189 $this->shuffle = $shuffle;
1190 break;
1191 default:
1192 $this->shuffle = 1;
1193 break;
1194 }
1195 }

References assQuestion\$shuffle.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setTerm()

assMatchingQuestion::setTerm (   $term,
  $index 
)

Sets a specific term.

Parameters
string$termThe text of the term
string$indexThe index of the term
See also
$terms

Definition at line 842 of file class.assMatchingQuestion.php.

843 {
844 $this->terms[$index] = $term;
845 }

References $index.

◆ setThumbGeometry()

assMatchingQuestion::setThumbGeometry (   $a_geometry)

Set the thumbnail geometry.

Parameters
integer$a_geometryGeometry

Definition at line 1308 of file class.assMatchingQuestion.php.

1309 {
1310 $this->thumb_geometry = ($a_geometry < 1) ? 100 : $a_geometry;
1311 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ supportsJavascriptOutput()

assMatchingQuestion::supportsJavascriptOutput ( )

Returns true if the question type supports JavaScript output.

Returns
boolean TRUE if the question type supports JavaScript output, FALSE otherwise @access public

Reimplemented from assQuestion.

Definition at line 1444 of file class.assMatchingQuestion.php.

1445 {
1446 return true;
1447 }

◆ supportsNonJsOutput()

assMatchingQuestion::supportsNonJsOutput ( )

Reimplemented from assQuestion.

Definition at line 1449 of file class.assMatchingQuestion.php.

1450 {
1451 return false;
1452 }

◆ toJSON()

assMatchingQuestion::toJSON ( )

Returns a JSON representation of the question TODO.

Reimplemented from assQuestion.

Definition at line 1361 of file class.assMatchingQuestion.php.

1362 {
1363 $result = array();
1364
1365 $result['id'] = (int) $this->getId();
1366 $result['type'] = (string) $this->getQuestionType();
1367 $result['title'] = (string) $this->getTitle();
1368 $result['question'] = $this->formatSAQuestion($this->getQuestion());
1369 $result['nr_of_tries'] = (int) $this->getNrOfTries();
1370 $result['matching_mode'] = $this->getMatchingMode();
1371 $result['shuffle'] = true;
1372 $result['feedback'] = array(
1373 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1374 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1375 );
1376
1377 require_once 'Services/Randomization/classes/class.ilArrayElementShuffler.php';
1378 $this->setShuffler(new ilArrayElementShuffler());
1379 $seed = $this->getShuffler()->getSeed();
1380
1381 $terms = array();
1382 $this->getShuffler()->setSeed($this->getShuffler()->buildSeedFromString($seed . 'terms'));
1383 foreach ($this->getShuffler()->shuffle($this->getTerms()) as $term) {
1384 $terms[] = array(
1385 "text" => $this->formatSAQuestion($term->text),
1386 "id" => (int) $this->getId() . $term->identifier
1387 );
1388 }
1389 $result['terms'] = $terms;
1390
1391 // alex 9.9.2010 as a fix for bug 6513 I added the question id
1392 // to the "def_id" in the array. The $pair->definition->identifier is not
1393 // unique, since it gets it value from the morder table field
1394 // this value is not changed, when a question is copied.
1395 // thus copying the same question on a page results in problems
1396 // when the second one (the copy) is answered.
1397
1398 $definitions = array();
1399 $this->getShuffler()->setSeed($this->getShuffler()->buildSeedFromString($seed . 'definitions'));
1400 foreach ($this->getShuffler()->shuffle($this->getDefinitions()) as $def) {
1401 $definitions[] = array(
1402 "text" => $this->formatSAQuestion((string) $def->text),
1403 "id" => (int) $this->getId() . $def->identifier
1404 );
1405 }
1406 $result['definitions'] = $definitions;
1407
1408 // #10353
1409 $matchings = array();
1410 foreach ($this->getMatchingPairs() as $pair) {
1411 // fau: fixLmMatchingPoints - ignore matching pairs with 0 or negative points
1412 if ($pair->points <= 0) {
1413 continue;
1414 }
1415 // fau.
1416
1417 $pid = $pair->definition->identifier;
1418 if ($this->getMatchingMode() == self::MATCHING_MODE_N_ON_N) {
1419 $pid .= '::' . $pair->term->identifier;
1420 }
1421
1422 if (!isset($matchings[$pid]) || $matchings[$pid]["points"] < $pair->points) {
1423 $matchings[$pid] = array(
1424 "term_id" => (int) $this->getId() . $pair->term->identifier,
1425 "def_id" => (int) $this->getId() . $pair->definition->identifier,
1426 "points" => (int) $pair->points
1427 );
1428 }
1429 }
1430
1431 $result['matchingPairs'] = array_values($matchings);
1432
1433 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1434 $result['mobs'] = $mobs;
1435
1436 global $DIC;
1437 $lng = $DIC['lng'];
1438 $lng->loadLanguageModule('assessment');
1439 $result['reset_button_label'] = $lng->txt("reset_terms");
1440
1441 return json_encode($result);
1442 }
getQuestionType()
Returns the question type of the question.
formatSAQuestion($a_q)
Format self assessment question.
setShuffler(ilArrayElementShuffler $shuffler)
getTitle()
Gets the title string of the assQuestion object.
getQuestion()
Gets the question string of the question object.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
$mobs

References $definitions, $DIC, assQuestion\$lng, $mobs, $result, $terms, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getDefinitions(), assQuestion\getId(), getMatchingMode(), getMatchingPairs(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffler(), getTerms(), assQuestion\getTitle(), and assQuestion\setShuffler().

+ Here is the call graph for this function:

Field Documentation

◆ $definitions

assMatchingQuestion::$definitions
protected

Definition at line 51 of file class.assMatchingQuestion.php.

Referenced by getDefinitions(), and toJSON().

◆ $element_height

assMatchingQuestion::$element_height

Definition at line 64 of file class.assMatchingQuestion.php.

◆ $matching_type

assMatchingQuestion::$matching_type

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

Referenced by __construct().

◆ $matchingMode

assMatchingQuestion::$matchingMode = self::MATCHING_MODE_1_ON_1
protected

Definition at line 69 of file class.assMatchingQuestion.php.

Referenced by getMatchingMode(), and setMatchingMode().

◆ $matchingpairs

assMatchingQuestion::$matchingpairs

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

Referenced by getMatchingPairs(), and saveAnswerSpecificDataToDb().

◆ $terms

assMatchingQuestion::$terms
protected

◆ $thumb_geometry

assMatchingQuestion::$thumb_geometry = 100

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

Referenced by getThumbGeometry().

◆ MATCHING_MODE_1_ON_1

const assMatchingQuestion::MATCHING_MODE_1_ON_1 = '1:1'

◆ MATCHING_MODE_N_ON_N

const assMatchingQuestion::MATCHING_MODE_N_ON_N = 'n:n'

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