ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 
 setExternalId ($external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 Return the suggested solutions. More...
 
 getReachedPoints ($active_id, $pass=null)
 Returns the points, a learner has reached answering the question This is the fast way to get the points directly from the database. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getAdjustedReachedPoints ($active_id, $pass=null, $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution ($active_id, $pass=null, $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState ($active_id, $pass=null, $obligationsEnabled=false, $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution. More...
 
 getJavaPath ()
 Returns the image path for web accessable images of a question. More...
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 buildImagePath ($questionId, $parentObjectId)
 
 getFlashPath ()
 Returns the image path for web accessable flash files of a question. More...
 
 getJavaPathWeb ()
 Returns the web image path for web accessable java applets of a question. More...
 
 getSuggestedSolutionPathWeb ()
 Returns the web path for a suggested solution. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getFlashPathWeb ()
 Returns the web image path for web accessable flash applications of a question. More...
 
 getTestOutputSolutions ($activeId, $pass)
 
 getUserSolutionPreferingIntermediate ($active_id, $pass=null)
 
 getSolutionValues ($active_id, $pass=null, $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse ($question_id="")
 Checks whether the question is in use or not. More...
 
 isClone ($question_id="")
 Checks whether the question is a clone of another question or not. More...
 
 pcArrayShuffle ($array)
 Shuffles the values of a given array. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 getTotalAnswers ()
 get total number of answers More...
 
 _getTotalAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 create page object of question More...
 
 copyPageOfQuestion ($a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 fixSvgToPng ($imageFilenameContainingString)
 
 fixUnavailableSkinImageSources ($html)
 
 loadFromDb ($question_id)
 Loads the question from the database. More...
 
 createNewQuestion ($a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb ($original_id="")
 
 saveToDb ($original_id="")
 Saves the question to the database. More...
 
 setNewOriginalId ($newId)
 
 deleteSuggestedSolutions ()
 Deletes all suggestes solutions in the database. More...
 
 getSuggestedSolution ($subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle ($subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution ($solution_id="", $subquestion_index=0, $is_import=false)
 Sets a suggested solution for the question. More...
 
 _resolveInternalLink ($internal_link)
 
 _resolveIntLinks ($question_id)
 
 syncWithOriginal ()
 
 createRandomSolution ($test_id, $user_id)
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool ($question_id)
 Returns true if the question already exists in the database and is assigned to a question pool. More...
 
 getPoints ()
 Returns the maximum available points for the question. More...
 
 setPoints ($a_points)
 Sets the maximum available points for the question. More...
 
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 deductHintPointsFromReachedPoints (ilAssQuestionPreviewSession $previewSession, $reachedPoints)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=null)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output in tests. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addQTIMaterial (&$a_xml_writer, $a_material, $close_material_tag=true, $add_mobs=true)
 Creates a QTI material tag from a plain text or xhtml text. More...
 
 buildHashedImageFilename ($plain_image_filename, $unique=false)
 
 getQuestion ()
 Gets the question string of the question object. More...
 
 setQuestion ($question="")
 Sets the question string of the question object. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 Returns the question type of the question. More...
 
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table More...
 
getInstances ()
 Gets all instances of the question. More...
 
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id. More...
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getNrOfTries ()
 
 setNrOfTries ($a_nr_of_tries)
 
 setExportImagePath ($a_path)
 
 formatSAQuestion ($a_q)
 Format self assessment question. More...
 
 setPreventRteUsage ($a_val)
 Set prevent rte usage. More...
 
 getPreventRteUsage ()
 Get prevent rte usage. More...
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode ($a_selfassessmenteditingmode)
 Set Self-Assessment Editing Mode. More...
 
 getSelfAssessmentEditingMode ()
 Get Self-Assessment Editing Mode. More...
 
 setDefaultNrOfTries ($a_defaultnroftries)
 Set Default Nr of Tries. More...
 
 getDefaultNrOfTries ()
 Get Default Nr of Tries. More...
 
 syncSkillAssignments ($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId)
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not More...
 
 isAutosaveable ()
 
 getAdditionalContentEditingMode ()
 getter for additional content editing mode for this question More...
 
 setAdditionalContentEditingMode ($additinalContentEditingMode)
 setter for additional content editing mode for this question More...
 
 isAdditionalContentEditingModePageObject ()
 isser for additional "pageobject" content editing mode More...
 
 isValidAdditionalContentEditingMode ($additionalContentEditingMode)
 returns the fact wether the passed additional content mode is valid or not More...
 
 getValidAdditionalContentEditingModes ()
 getter for valid additional content editing modes More...
 
 addQuestionChangeListener (ilQuestionChangeListener $listener)
 
 getQuestionChangeListeners ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution ($active_id, $pass)
 
 removeCurrentSolution ($active_id, $pass, $authorized=true)
 
 saveCurrentSolution ($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
 
 updateCurrentSolution ($solutionId, $value1, $value2, $authorized=true)
 
 updateCurrentSolutionsAuthorization ($activeId, $pass, $authorized, $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
 intermediateSolutionExists ($active_id, $pass)
 
 authorizedSolutionExists ($active_id, $pass)
 
 authorizedOrIntermediateSolutionExists ($active_id, $pass)
 
 removeExistingSolutions ($activeId, $pass)
 
 resetUsersAnswer ($activeId, $pass)
 
 removeResultRecord ($activeId, $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered ($obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 Get the test question configuration (initialised once) More...
 
 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)
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered, $authorized)
 {Reworks the allready saved working data if neccessary.
Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered
boolean$authorized
} More...
 
 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)
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered, $authorized)
 Reworks the allready saved working data if neccessary. More...
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID. More...
 
 onDuplicate ($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test) More...
 
 beforeSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 onCopy ($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId)
 Will be called when a question is copied (into another question pool) More...
 
 duplicateSuggestedSolutionFiles ($parent_id, $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles ($original_id)
 Syncs the files of a suggested solution if the question is synced. More...
 
 copySuggestedSolutionFiles ($source_questionpool_id, $source_question_id)
 
 ensureNonNegativePoints ($points)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 
 duplicateSkillAssignments ($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet ($active_id, $pass, $authorized=true)
 Get a restulset for the current user solution for a this question by active_id and pass. More...
 
 removeSolutionRecordById ($solutionId)
 
 getSolutionRecordById ($solutionId)
 
 deleteDummySolutionRecord ($activeId, $passIndex)
 
 deleteSolutionRecordByValues ($activeId, $passIndex, $authorized, $matchValues)
 
 duplicateIntermediateSolutionAuthorized ($activeId, $passIndex)
 
 forceExistingIntermediateSolution ($activeId, $passIndex, $considerDummyRecordCreation)
 
 buildTestPresentationConfig ()
 build basic test question configuration instance More...
 

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
 

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 {
93 parent::__construct($title, $comment, $author, $owner, $question);
94 $this->matchingpairs = array();
95 $this->matching_type = $matching_type;
96 $this->terms = array();
97 $this->definitions = array();
98 }

References assQuestion\$author, assQuestion\$comment, $matching_type, assQuestion\$owner, assQuestion\$question, and assQuestion\$title.

Member Function Documentation

◆ addDefinition()

assMatchingQuestion::addDefinition (   $definition)

Adds a definition.

Parameters
object$definitionThe definition
See also
$definitions

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

735 {
736 array_push($this->definitions, $definition);
737 }

◆ 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 568 of file class.assMatchingQuestion.php.

569 {
570 require_once './Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php';
571 require_once './Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php';
572 require_once './Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php';
573 if (is_null($term)) {
574 $term = new assAnswerMatchingTerm();
575 }
576 if (is_null($definition)) {
577 $definition = new assAnswerMatchingDefinition();
578 }
579 $pair = new assAnswerMatchingPair($term, $definition, $points);
580 array_push($this->matchingpairs, $pair);
581 }
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 723 of file class.assMatchingQuestion.php.

724 {
725 array_push($this->terms, $term);
726 }

◆ afterSyncWithOriginal()

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

{}

Reimplemented from assQuestion.

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

1592 {
1593 parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
1594
1595 $origImagePath = $this->buildImagePath($origQuestionId, $origParentObjId);
1596 $dupImagePath = $this->buildImagePath($dupQuestionId, $dupParentObjId);
1597
1598 ilUtil::delDir($origImagePath);
1599 if (is_dir($dupImagePath)) {
1600 ilUtil::makeDirParents($origImagePath);
1601 ilUtil::rCopy($dupImagePath, $origImagePath);
1602 }
1603 }
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 845 of file class.assMatchingQuestion.php.

846 {
847 if ($returndetails) {
848 throw new ilTestException('return details not implemented for ' . __METHOD__);
849 }
850
851 global $ilDB;
852
853 $found_values = array();
854 if (is_null($pass)) {
855 $pass = $this->getSolutionMaxPass($active_id);
856 }
857 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
858 while ($data = $ilDB->fetchAssoc($result)) {
859 if (strcmp($data["value1"], "") != 0) {
860 if (!isset($found_values[$data['value2']])) {
861 $found_values[$data['value2']] = array();
862 }
863
864 $found_values[$data['value2']][] = $data['value1'];
865 }
866 }
867
868 $points = $this->calculateReachedPointsForSolution($found_values);
869
870 return $points;
871 }
$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

References $data, $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 1461 of file class.assMatchingQuestion.php.

1462 {
1463 $points = 0;
1464 foreach ($found_values as $definition => $terms) {
1465 foreach ($terms as $term) {
1466 foreach ($this->matchingpairs as $pair) {
1467 if ($pair->definition->identifier == $definition && $pair->term->identifier == $term) {
1468 $points += $pair->points;
1469 }
1470 }
1471 }
1472 }
1473 return $points;
1474 }

References assQuestion\$points, and $terms.

Referenced by calculateReachedPoints().

+ Here is the caller graph for this function:

◆ checkSubmittedMatchings()

assMatchingQuestion::checkSubmittedMatchings (   $submittedMatchings)
private

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

1059 {
1060 if ($this->getMatchingMode() == self::MATCHING_MODE_N_ON_N) {
1061 return true;
1062 }
1063
1064 $handledTerms = array();
1065
1066 foreach ($submittedMatchings as $definition => $terms) {
1067 if (count($terms) > 1) {
1068 ilUtil::sendFailure($this->lng->txt("multiple_matching_values_selected"), true);
1069 return false;
1070 }
1071
1072 foreach ($terms as $i => $term) {
1073 if (isset($handledTerms[$term])) {
1074 ilUtil::sendFailure($this->lng->txt("duplicate_matching_values_selected"), true);
1075 return false;
1076 }
1077
1078 $handledTerms[$term] = $term;
1079 }
1080 }
1081
1082 return true;
1083 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$i
Definition: disco.tpl.php:19

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

484 {
485 global $ilLog;
486
487 $imagepath = $this->getImagePath();
488 $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
489 $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
490 foreach ($this->terms as $term) {
491 if (strlen($term->picture)) {
492 if (!file_exists($imagepath)) {
493 ilUtil::makeDirParents($imagepath);
494 }
495 $filename = $term->picture;
496 if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
497 $ilLog->write("matching question image could not be copied: $imagepath_original$filename");
498 }
499 if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
500 $ilLog->write("matching question image thumbnail could not be copied: $imagepath_original" . $this->getThumbPrefix() . $filename);
501 }
502 }
503 }
504 foreach ($this->definitions as $definition) {
505 if (strlen($definition->picture)) {
506 $filename = $definition->picture;
507 if (!file_exists($imagepath)) {
508 ilUtil::makeDirParents($imagepath);
509 }
510
511 if (assQuestion::isFileAvailable($imagepath_original . $filename)) {
512 copy($imagepath_original . $filename, $imagepath . $filename);
513 } else {
514 $ilLog->write("matching question image could not be copied: $imagepath_original$filename");
515 }
516
517 if (assQuestion::isFileAvailable($imagepath_original . $this->getThumbPrefix() . $filename)) {
518 copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename);
519 } else {
520 $ilLog->write("matching question image thumbnail could not be copied: $imagepath_original" . $this->getThumbPrefix() . $filename);
521 }
522 }
523 }
524 }
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static isFileAvailable($file)

References $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 375 of file class.assMatchingQuestion.php.

376 {
377 if ($this->id <= 0) {
378 // The question has not been saved. It cannot be duplicated
379 return;
380 }
381 // duplicate the question in database
382 $clone = $this;
383 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
385 $clone->id = -1;
386 $source_questionpool_id = $this->getObjId();
387 $clone->setObjId($target_questionpool_id);
388 if ($title) {
389 $clone->setTitle($title);
390 }
391 $clone->saveToDb();
392 // copy question page content
393 $clone->copyPageOfQuestion($original_id);
394 // copy XHTML media objects
395 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
396 // duplicate the image
397 $clone->copyImages($original_id, $source_questionpool_id);
398
399 $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
400
401 return $clone->id;
402 }
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 404 of file class.assMatchingQuestion.php.

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

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

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

◆ 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 995 of file class.assMatchingQuestion.php.

996 {
997 $deletename = $filename;
998 $result = @unlink($this->getImagePath() . $deletename);
999 $result = $result & @unlink($this->getImagePath() . $this->getThumbPrefix() . $deletename);
1000 return $result;
1001 }

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

639 {
640 if ($index < 0) {
641 return;
642 }
643 if (count($this->matchingpairs) < 1) {
644 return;
645 }
646 if ($index >= count($this->matchingpairs)) {
647 return;
648 }
649 unset($this->matchingpairs[$index]);
650 $this->matchingpairs = array_values($this->matchingpairs);
651 }
$index
Definition: metadata.php:60

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

806 {
807 unset($this->terms[$position]);
808 $this->terms = array_values($this->terms);
809 }

◆ duplicate()

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

Duplicates an assMatchingQuestion.

Reimplemented from assQuestion.

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

327 {
328 if ($this->id <= 0) {
329 // The question has not been saved. It cannot be duplicated
330 return;
331 }
332 // duplicate the question in database
333 $this_id = $this->getId();
334 $thisObjId = $this->getObjId();
335
336 $clone = $this;
337 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
339 $clone->id = -1;
340
341 if ((int) $testObjId > 0) {
342 $clone->setObjId($testObjId);
343 }
344
345 if ($title) {
346 $clone->setTitle($title);
347 }
348 if ($author) {
349 $clone->setAuthor($author);
350 }
351 if ($owner) {
352 $clone->setOwner($owner);
353 }
354 if ($for_test) {
355 $clone->saveToDb($original_id);
356 } else {
357 $clone->saveToDb();
358 }
359
360 // copy question page content
361 $clone->copyPageOfQuestion($this_id);
362 // copy XHTML media objects
363 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
364 // duplicate the image
365 $clone->duplicateImages($this_id, $thisObjId, $clone->getId(), $testObjId);
366
367 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
368
369 return $clone->id;
370 }
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 439 of file class.assMatchingQuestion.php.

440 {
441 global $ilLog;
442 $imagepath = $this->getImagePath();
443 $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
444
445 if ((int) $objectId > 0) {
446 $imagepath_original = str_replace("/$this->obj_id/", "/$objectId/", $imagepath_original);
447 }
448
449 foreach ($this->terms as $term) {
450 if (strlen($term->picture)) {
451 $filename = $term->picture;
452 if (!file_exists($imagepath)) {
453 ilUtil::makeDirParents($imagepath);
454 }
455 if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
456 $ilLog->write("matching question image could not be duplicated: $imagepath_original$filename");
457 }
458 if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename)) {
459 if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
460 $ilLog->write("matching question image thumbnail could not be duplicated: $imagepath_original" . $this->getThumbPrefix() . $filename);
461 }
462 }
463 }
464 }
465 foreach ($this->definitions as $definition) {
466 if (strlen($definition->picture)) {
467 $filename = $definition->picture;
468 if (!file_exists($imagepath)) {
469 ilUtil::makeDirParents($imagepath);
470 }
471 if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
472 $ilLog->write("matching question image could not be duplicated: $imagepath_original$filename");
473 }
474 if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename)) {
475 if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
476 $ilLog->write("matching question image thumbnail could not be duplicated: $imagepath_original" . $this->getThumbPrefix() . $filename);
477 }
478 }
479 }
480 }
481 }

References $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 938 of file class.assMatchingQuestion.php.

939 {
940 $indexedValues = array();
941
942 foreach ($valuePairs as $valuePair) {
943 if (!isset($indexedValues[$valuePair['value2']])) {
944 $indexedValues[$valuePair['value2']] = array();
945 }
946
947 $indexedValues[$valuePair['value2']][] = $valuePair['value1'];
948 }
949
950 return $indexedValues;
951 }

◆ fetchSubmittedMatchingsFromPost()

assMatchingQuestion::fetchSubmittedMatchingsFromPost ( )
private

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

1036 {
1037 $postData = $_POST['matching'][$this->getId()];
1038
1039 $matchings = array();
1040
1041 foreach ($this->getDefinitions() as $definition) {
1042 if (isset($postData[$definition->identifier])) {
1043 foreach ($this->getTerms() as $term) {
1044 if (isset($postData[$definition->identifier][$term->identifier])) {
1045 if (!is_array($postData[$definition->identifier])) {
1046 $postData[$definition->identifier] = array();
1047 }
1048
1049 $matchings[$definition->identifier][] = $term->identifier;
1050 }
1051 }
1052 }
1053 }
1054
1055 return $matchings;
1056 }
$_POST["username"]
getDefinitions()
Returns the definitions of the matching question.
getTerms()
Returns the terms of the matching question.
if($session===NULL) $postData

References $_POST, $postData, 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 794 of file class.assMatchingQuestion.php.

795 {
796 $this->definitions = array();
797 }

◆ flushMatchingPairs()

assMatchingQuestion::flushMatchingPairs ( )

Deletes all matching pairs.

See also
$matchingpairs

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

658 {
659 $this->matchingpairs = array();
660 }

◆ flushTerms()

assMatchingQuestion::flushTerms ( )

Deletes all terms.

See also
$terms

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

786 {
787 $this->terms = array();
788 }

◆ generateThumbForFile()

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

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

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

References $file, $filename, $path, 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 1206 of file class.assMatchingQuestion.php.

1207 {
1208 return "qpl_qst_matching";
1209 }

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

1217 {
1218 return array("qpl_a_matching", "qpl_a_mterm");
1219 }

◆ 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 1579 of file class.assMatchingQuestion.php.

1580 {
1581 if ($index !== null) {
1582 return $this->getMatchingPair($index);
1583 } else {
1584 return $this->getMatchingPairs();
1585 }
1586 }
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 712 of file class.assMatchingQuestion.php.

713 {
714 return count($this->definitions);
715 }

◆ getDefinitions()

assMatchingQuestion::getDefinitions ( )

Returns the definitions of the matching question.

Returns
array An array containing the definitions
See also
$terms

Definition at line 690 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 599 of file class.assMatchingQuestion.php.

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

◆ 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 961 of file class.assMatchingQuestion.php.

962 {
963 $extension = "";
964 if (preg_match("/.*\\.(\\w+)$/", $filename, $matches)) {
965 $extension = $matches[1];
966 }
967 return md5($filename) . "." . $extension;
968 }

References $filename.

◆ getExpressionTypes()

◆ getMatchingMode()

assMatchingQuestion::getMatchingMode ( )

Definition at line 1452 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 617 of file class.assMatchingQuestion.php.

618 {
619 if ($index < 0) {
620 return null;
621 }
622 if (count($this->matchingpairs) < 1) {
623 return null;
624 }
625 if ($index >= count($this->matchingpairs)) {
626 return null;
627 }
628 return $this->matchingpairs[$index];
629 }

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

669 {
670 return count($this->matchingpairs);
671 }

◆ getMatchingPairs()

& assMatchingQuestion::getMatchingPairs ( )

Returns the matchingpairs array.

Definition at line 1233 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 876 of file class.assMatchingQuestion.php.

877 {
878 $points = 0;
879
880 foreach ($this->getMaximumScoringMatchingPairs() as $pair) {
881 $points += $pair->points;
882 }
883
884 return $points;
885 }

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

888 {
889 if ($this->getMatchingMode() == self::MATCHING_MODE_N_ON_N) {
890 return $this->getPositiveScoredMatchingPairs();
891 } elseif ($this->getMatchingMode() == self::MATCHING_MODE_1_ON_1) {
893 }
894
895 return array();
896 }

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

914 {
915 $matchingPairsByDefinition = array();
916
917 foreach ($this->matchingpairs as $pair) {
918 if ($pair->points <= 0) {
919 continue;
920 }
921
922 $defId = $pair->definition->identifier;
923
924 if (!isset($matchingPairsByDefinition[$defId])) {
925 $matchingPairsByDefinition[$defId] = $pair;
926 } elseif ($pair->points > $matchingPairsByDefinition[$defId]->points) {
927 $matchingPairsByDefinition[$defId] = $pair;
928 }
929 }
930
931 return $matchingPairsByDefinition;
932 }

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

1485 {
1486 require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1488 }

References ilOperatorsExpressionMapping\getOperatorsByExpression().

+ Here is the call graph for this function:

◆ getPositiveScoredMatchingPairs()

assMatchingQuestion::getPositiveScoredMatchingPairs ( )
private

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

899 {
900 $matchingPairs = array();
901
902 foreach ($this->matchingpairs as $pair) {
903 if ($pair->points <= 0) {
904 continue;
905 }
906
907 $matchingPairs[] = $pair;
908 }
909
910 return $matchingPairs;
911 }

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

1197 {
1198 return "assMatchingQuestion";
1199 }

Referenced by toJSON().

+ Here is the caller graph for this function:

◆ getRandomId()

assMatchingQuestion::getRandomId ( )

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

1154 {
1155 mt_srand((double) microtime()*1000000);
1156 $random_number = mt_rand(1, 100000);
1157 $found = false;
1158 while ($found) {
1159 $found = false;
1160 foreach ($this->matchingpairs as $key => $pair) {
1161 if (($pair->term->identifier == $random_number) || ($pair->definition->identifier == $random_number)) {
1162 $found = true;
1163 $random_number++;
1164 }
1165 }
1166 }
1167 return $random_number;
1168 }
$key
Definition: croninfo.php:18

References $key.

◆ 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 1225 of file class.assMatchingQuestion.php.

1226 {
1227 return parent::getRTETextWithMediaObjects();
1228 }

◆ getTermCount()

assMatchingQuestion::getTermCount ( )

Returns the number of terms.

Returns
integer The number of terms
See also
$terms

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

702 {
703 return count($this->terms);
704 }

◆ getTerms()

assMatchingQuestion::getTerms ( )

Returns the terms of the matching question.

Returns
array An array containing the terms
See also
$terms

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

680 {
681 return $this->terms;
682 }

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

587 {
588 foreach ($this->terms as $term) {
589 if ($term->identifier == $a_identifier) {
590 return $term;
591 }
592 }
593 return null;
594 }

◆ getThumbGeometry()

assMatchingQuestion::getThumbGeometry ( )

Get the thumbnail geometry.

Returns
integer Geometry

Definition at line 1282 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 1324 of file class.assMatchingQuestion.php.

1325 {
1326 return "thumb.";
1327 }

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

1293 {
1294 return $this->getThumbGeometry();
1295 }

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

767 {
768 if (is_null($definition)) {
769 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
770 $definition = new assAnswerMatchingDefinition();
771 }
772 if ($position < count($this->definitions)) {
773 $part1 = array_slice($this->definitions, 0, $position);
774 $part2 = array_slice($this->definitions, $position);
775 $this->definitions = array_merge($part1, array($definition), $part2);
776 } else {
777 array_push($this->definitions, $definition);
778 }
779 }

◆ 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 536 of file class.assMatchingQuestion.php.

537 {
538 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
539 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
540 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
541 if (is_null($term)) {
542 $term = new assAnswerMatchingTerm();
543 }
544 if (is_null($definition)) {
545 $definition = new assAnswerMatchingDefinition();
546 }
547 $pair = new assAnswerMatchingPair($term, $definition, $points);
548 if ($position < count($this->matchingpairs)) {
549 $part1 = array_slice($this->matchingpairs, 0, $position);
550 $part2 = array_slice($this->matchingpairs, $position);
551 $this->matchingpairs = array_merge($part1, array($pair), $part2);
552 } else {
553 array_push($this->matchingpairs, $pair);
554 }
555 }

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

746 {
747 if (is_null($term)) {
748 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
749 $term = new assAnswerMatchingTerm();
750 }
751 if ($position < count($this->terms)) {
752 $part1 = array_slice($this->terms, 0, $position);
753 $part2 = array_slice($this->terms, $position);
754 $this->terms = array_merge($part1, array($term), $part2);
755 } else {
756 array_push($this->terms, $term);
757 }
758 }

◆ 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 232 of file class.assMatchingQuestion.php.

233 {
234 global $ilDB;
235
236 $query = "
237 SELECT qpl_questions.*,
238 {$this->getAdditionalTableName()}.*
239 FROM qpl_questions
240 LEFT JOIN {$this->getAdditionalTableName()}
241 ON {$this->getAdditionalTableName()}.question_fi = qpl_questions.question_id
242 WHERE qpl_questions.question_id = %s
243 ";
244
245 $result = $ilDB->queryF(
246 $query,
247 array('integer'),
248 array($question_id)
249 );
250
251 if ($result->numRows() == 1) {
252 $data = $ilDB->fetchAssoc($result);
253 $this->setId($question_id);
254 $this->setObjId($data["obj_fi"]);
255 $this->setTitle($data["title"]);
256 $this->setComment($data["description"]);
257 $this->setOriginalId($data["original_id"]);
258 $this->setNrOfTries($data['nr_of_tries']);
259 $this->setAuthor($data["author"]);
260 $this->setPoints($data["points"]);
261 $this->setOwner($data["owner"]);
262 include_once("./Services/RTE/classes/class.ilRTE.php");
263 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
264 $this->setThumbGeometry($data["thumb_geometry"]);
265 $this->setShuffle($data["shuffle"]);
266 $this->setMatchingMode($data['matching_mode'] === null ? self::MATCHING_MODE_1_ON_1 : $data['matching_mode']);
267 $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
268
269 try {
270 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
271 } catch (ilTestQuestionPoolException $e) {
272 }
273 }
274
275 $termids = array();
276 $result = $ilDB->queryF(
277 "SELECT * FROM qpl_a_mterm WHERE question_fi = %s ORDER BY term_id ASC",
278 array('integer'),
279 array($question_id)
280 );
281 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
282 $this->terms = array();
283 if ($result->numRows() > 0) {
284 while ($data = $ilDB->fetchAssoc($result)) {
285 $term = new assAnswerMatchingTerm($data['term'], $data['picture'], $data['ident']);
286 array_push($this->terms, $term);
287 $termids[$data['term_id']] = $term;
288 }
289 }
290
291 $definitionids = array();
292 $result = $ilDB->queryF(
293 "SELECT * FROM qpl_a_mdef WHERE question_fi = %s ORDER BY def_id ASC",
294 array('integer'),
295 array($question_id)
296 );
297 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
298 $this->definitions = array();
299 if ($result->numRows() > 0) {
300 while ($data = $ilDB->fetchAssoc($result)) {
301 $definition = new assAnswerMatchingDefinition($data['definition'], $data['picture'], $data['ident']);
302 array_push($this->definitions, $definition);
303 $definitionids[$data['def_id']] = $definition;
304 }
305 }
306
307 $this->matchingpairs = array();
308 $result = $ilDB->queryF(
309 "SELECT * FROM qpl_a_matching WHERE question_fi = %s ORDER BY answer_id",
310 array('integer'),
311 array($question_id)
312 );
313 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
314 if ($result->numRows() > 0) {
315 while ($data = $ilDB->fetchAssoc($result)) {
316 array_push($this->matchingpairs, new assAnswerMatchingPair($termids[$data['term_fi']], $definitionids[$data['definition_fi']], $data['points']));
317 }
318 }
319 parent::loadFromDb($question_id);
320 }
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.
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, $ilDB, $query, $result, ilRTE\_replaceMediaObjectImageSrc(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setEstimatedWorkingTime(), assQuestion\setId(), 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 1310 of file class.assMatchingQuestion.php.

1311 {
1312 foreach ($this->terms as $term) {
1313 if (strlen($term->picture)) {
1314 $this->generateThumbForFile($this->getImagePath(), $term->picture);
1315 }
1316 }
1317 foreach ($this->definitions as $definition) {
1318 if (strlen($definition->picture)) {
1319 $this->generateThumbForFile($this->getImagePath(), $definition->picture);
1320 }
1321 }
1322 }

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

980 {
981 $definition = $this->definitions[$index];
982 if (is_object($definition)) {
983 $this->deleteImagefile($definition->picture);
984 $definition->picture = null;
985 }
986 }
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 970 of file class.assMatchingQuestion.php.

971 {
972 $term = $this->terms[$index];
973 if (is_object($term)) {
974 $this->deleteImagefile($term->picture);
975 $term->picture = null;
976 }
977 }

References $index, and deleteImagefile().

+ Here is the call graph for this function:

◆ reworkWorkingData()

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

{Reworks the allready saved working data if neccessary.

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered
boolean$authorized
}

Reimplemented from assQuestion.

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

1149 {
1150 // nothing to rework!
1151 }

◆ saveAdditionalQuestionDataToDb()

assMatchingQuestion::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

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

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

References $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 136 of file class.assMatchingQuestion.php.

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

References $ilDB, $key, $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 1136 of file class.assMatchingQuestion.php.

1137 {
1138 $submittedMatchings = $this->fetchSubmittedMatchingsFromPost();
1139
1140 if ($this->checkSubmittedMatchings($submittedMatchings)) {
1141 $previewSession->setParticipantsSolution($submittedMatchings);
1142 }
1143 }
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 $ilDB;
127
130 $this->saveAnswerSpecificDataToDb($ilDB);
131
132
133 parent::saveToDb($original_id);
134 }
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 $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 1093 of file class.assMatchingQuestion.php.

1094 {
1095 global $ilDB;
1096
1097 $submittedMatchings = $this->fetchSubmittedMatchingsFromPost();
1098 $submittedMatchingsValid = $this->checkSubmittedMatchings($submittedMatchings);
1099
1100 $matchingsExist = false;
1101
1102 if ($submittedMatchingsValid) {
1103 if (is_null($pass)) {
1104 include_once "./Modules/Test/classes/class.ilObjTest.php";
1105 $pass = ilObjTest::_getPass($active_id);
1106 }
1107
1108 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$matchingsExist, $submittedMatchings, $active_id, $pass, $authorized) {
1109 $this->removeCurrentSolution($active_id, $pass, $authorized);
1110
1111 foreach ($submittedMatchings as $definition => $terms) {
1112 foreach ($terms as $i => $term) {
1113 $this->saveCurrentSolution($active_id, $pass, $term, $definition, $authorized);
1114 $matchingsExist = true;
1115 }
1116 }
1117 });
1118
1119 $saveWorkingDataResult = true;
1120 } else {
1121 $saveWorkingDataResult = false;
1122 }
1123
1124 include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1126 if ($matchingsExist) {
1127 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1128 } else {
1129 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1130 }
1131 }
1132
1133 return $saveWorkingDataResult;
1134 }
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 $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 1241 of file class.assMatchingQuestion.php.

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

References $i, $pass, $worksheet, 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 1011 of file class.assMatchingQuestion.php.

1012 {
1013 $result = true;
1014 if (strlen($image_tempfilename)) {
1015 $image_filename = str_replace(" ", "_", $image_filename);
1016 $imagepath = $this->getImagePath();
1017 if (!file_exists($imagepath)) {
1018 ilUtil::makeDirParents($imagepath);
1019 }
1020 $savename = $image_filename;
1021 if (!ilUtil::moveUploadedFile($image_tempfilename, $savename, $imagepath . $savename)) {
1022 $result = false;
1023 } else {
1024 // create thumbnail file
1025 $thumbpath = $imagepath . $this->getThumbPrefix() . $savename;
1026 ilUtil::convertImage($imagepath . $savename, $thumbpath, "JPEG", $this->getThumbGeometry());
1027 }
1028 if ($result && (strcmp($image_filename, $previous_filename) != 0) && (strlen($previous_filename))) {
1029 $this->deleteImagefile($previous_filename);
1030 }
1031 }
1032 return $result;
1033 }

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

+ Here is the call graph for this function:

◆ setMatchingMode()

assMatchingQuestion::setMatchingMode (   $matchingMode)

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

1448 {
1449 $this->matchingMode = $matchingMode;
1450 }

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

1177 {
1178 switch ($shuffle) {
1179 case 0:
1180 case 1:
1181 case 2:
1182 case 3:
1183 $this->shuffle = $shuffle;
1184 break;
1185 default:
1186 $this->shuffle = 1;
1187 break;
1188 }
1189 }

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

831 {
832 $this->terms[$index] = $term;
833 }

References $index.

◆ setThumbGeometry()

assMatchingQuestion::setThumbGeometry (   $a_geometry)

Set the thumbnail geometry.

Parameters
integer$a_geometryGeometry

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

1303 {
1304 $this->thumb_geometry = ($a_geometry < 1) ? 100 : $a_geometry;
1305 }

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

1438 {
1439 return true;
1440 }

◆ supportsNonJsOutput()

assMatchingQuestion::supportsNonJsOutput ( )

Reimplemented from assQuestion.

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

1443 {
1444 return false;
1445 }

◆ toJSON()

assMatchingQuestion::toJSON ( )

Returns a JSON representation of the question TODO.

Reimplemented from assQuestion.

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

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

References $def, $definitions, 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: