ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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 ()
 
 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, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. 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 ()
 
 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...
 
 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 ()
 
 _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
_getQuestionInfo ($question_id)
 Returns question information from the database. More...
 
 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, $question_id, $pass=NULL)
 Returns the points, a learner has reached answering the question. 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...
 
 saveWorkingData ($active_id, $pass=NULL, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place. More...
 
 logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
 _logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. 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...
 
 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...
 
 getQuestionTypeFromDb ($question_id)
 get question type for question id 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...
 
 _getTitle ($a_q_id)
 Returns the title of a question. More...
 
 _getQuestionText ($a_q_id)
 Returns question text. More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 create page object of question More...
 
 copyPageOfQuestion ($a_q_id)
 
 getPageOfQuestion ()
 
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
 _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
 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)
 
 _getInternalLinkHref ($target="")
 
 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...
 
 _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution. More...
 
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
 _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not. More...
 
 calculateReachedPoints ($active_id, $pass=NULL, $authorizedSolution=true, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question. More...
 
 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...
 
 createNewImageFileName ($image_filename, $unique=false)
 
 _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...
 
 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...
 
 _needsManualScoring ($question_id)
 
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id. More...
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 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)
 
 _questionExistsInTest ($question_id, $test_id)
 
 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, $ignoredSolutionIds=array())
 
 saveCurrentSolution ($active_id, $pass, $value1, $value2, $authorized=true)
 
 updateCurrentSolution ($solutionId, $value1, $value2, $authorized=true)
 
 updateCurrentSolutionsAuthorization ($activeId, $pass, $authorized)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
 authorizedSolutionExists ($active_id, $pass)
 
 authorizedOrIntermediateSolutionExists ($active_id, $pass)
 
 lookupForExistingSolutions ($activeId, $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 removeExistingSolutions ($activeId, $pass)
 
 resetUsersAnswer ($activeId, $pass)
 
 removeResultRecord ($activeId, $pass)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered ($obligationsToBeConsidered)
 
 validateSolutionSubmit ()
 
 updateTimestamp ()
 
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 

Data Fields

 $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'
 
- 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)
 Reworks the allready saved working data if neccessary. More...
 
 generateThumbForFile ($path, $file)
 
 calculateReachedPointsForSolution ($found_values)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 {} More...
 
- Protected Member Functions inherited from assQuestion
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 Reworks the allready saved working data if neccessary. More...
 
 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)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 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)
 
 getSelfAssessmentFormatter ()
 

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
 
 $suggested_solutions
 
 $original_id
 
 $page
 
 $external_id = ''
 
 $questionChangeListeners = array()
 
 $processLocker
 
 $step = null
 
 $lastChange
 
 $shuffler
 

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 getAllowedImageFileExtensions ()
 
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 _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
static isFileAvailable ($file)
 
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 _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 _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 lookupParentObjId ($questionId)
 ilDB $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 setResultGateway ($resultGateway)
 
static getResultGateway ()
 
static sumTimesInISO8601FormatH_i_s_Extended ($time1, $time2)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds ($time)
 
static missingResultRecordExists ($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 Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
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

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

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

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

Member Function Documentation

◆ addDefinition()

assMatchingQuestion::addDefinition (   $definition)

Adds a definition.

Parameters
object$definitionThe definition
See also
$definitions

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

784  {
785  array_push($this->definitions, $definition);
786  }

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

References assQuestion\$points.

612  {
613  require_once './Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php';
614  require_once './Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php';
615  require_once './Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php';
616  if (is_null($term))
617  {
618  $term = new assAnswerMatchingTerm();
619  }
620  if (is_null($definition))
621  {
622  $definition = new assAnswerMatchingDefinition();
623  }
624  $pair = new assAnswerMatchingPair($term, $definition, $points);
625  array_push($this->matchingpairs, $pair);
626  }
Class for matching question terms.
Class for matching question pairs.
Class for matching question definitions.

◆ addTerm()

assMatchingQuestion::addTerm (   $term)

Adds a term.

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

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

773  {
774  array_push($this->terms, $term);
775  }

◆ afterSyncWithOriginal()

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

{}

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

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

1718  {
1719  parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
1720 
1721  $origImagePath = $this->buildImagePath($origQuestionId, $origParentObjId);
1722  $dupImagePath = $this->buildImagePath($dupQuestionId, $dupParentObjId);
1723 
1724  ilUtil::delDir($origImagePath);
1725  if(is_dir($dupImagePath))
1726  {
1727  ilUtil::makeDirParents($origImagePath);
1728  ilUtil::rCopy($dupImagePath, $origImagePath);
1729  }
1730  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
buildImagePath($questionId, $parentObjectId)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ 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.

public

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

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

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

Referenced by getExpressionTypes().

903  {
904  if( $returndetails )
905  {
906  throw new ilTestException('return details not implemented for '.__METHOD__);
907  }
908 
909  global $ilDB;
910 
911  $found_values = array();
912  if (is_null($pass))
913  {
914  $pass = $this->getSolutionMaxPass($active_id);
915  }
916  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
917  while ($data = $ilDB->fetchAssoc($result))
918  {
919  if (strcmp($data["value1"], "") != 0)
920  {
921  if( !isset($found_values[$data['value2']]) )
922  {
923  $found_values[$data['value2']] = array();
924  }
925 
926  $found_values[$data['value2']][] = $data['value1'];
927  }
928  }
929 
930  $points = $this->calculateReachedPointsForSolution($found_values);
931 
932  return $points;
933  }
$result
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
calculateReachedPointsForSolution($found_values)
Base Exception for all Exceptions relating to Modules/Test.
$data
global $ilDB
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsForSolution()

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

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

References assQuestion\$points, and $terms.

Referenced by calculateReachedPoints().

1574  {
1575  $points = 0;
1576  foreach($found_values as $definition => $terms)
1577  {
1578  foreach($terms as $term)
1579  {
1580  foreach($this->matchingpairs as $pair)
1581  {
1582  if($pair->definition->identifier == $definition && $pair->term->identifier == $term)
1583  {
1584  $points += $pair->points;
1585  }
1586  }
1587  }
1588  }
1589  return $points;
1590  }
+ Here is the caller graph for this function:

◆ checkSubmittedMatchings()

assMatchingQuestion::checkSubmittedMatchings (   $submittedMatchings)
private

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

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

Referenced by savePreviewData(), and saveWorkingData().

1127  {
1128  if( $this->getMatchingMode() == self::MATCHING_MODE_N_ON_N )
1129  {
1130  return true;
1131  }
1132 
1133  $handledTerms = array();
1134 
1135  foreach( $submittedMatchings as $definition => $terms )
1136  {
1137  if( count($terms) > 1 )
1138  {
1139  ilUtil::sendFailure($this->lng->txt("multiple_matching_values_selected"), true);
1140  return false;
1141  }
1142 
1143  foreach( $terms as $i => $term )
1144  {
1145  if( isset($handledTerms[$term]) )
1146  {
1147  ilUtil::sendFailure($this->lng->txt("duplicate_matching_values_selected"), true);
1148  return false;
1149  }
1150 
1151  $handledTerms[$term] = $term;
1152  }
1153  }
1154 
1155  return true;
1156  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ 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 513 of file class.assMatchingQuestion.php.

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

514  {
515  global $ilLog;
516 
517  $imagepath = $this->getImagePath();
518  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
519  $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
520  foreach ($this->terms as $term)
521  {
522  if (strlen($term->picture))
523  {
524  if (!file_exists($imagepath))
525  {
526  ilUtil::makeDirParents($imagepath);
527  }
528  $filename = $term->picture;
529  if (!@copy($imagepath_original . $filename, $imagepath . $filename))
530  {
531  $ilLog->write("matching question image could not be copied: $imagepath_original$filename");
532  }
533  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename))
534  {
535  $ilLog->write("matching question image thumbnail could not be copied: $imagepath_original" . $this->getThumbPrefix() . $filename);
536  }
537  }
538  }
539  foreach ($this->definitions as $definition)
540  {
541  if (strlen($definition->picture))
542  {
543  $filename = $definition->picture;
544  if (!file_exists($imagepath))
545  {
546  ilUtil::makeDirParents($imagepath);
547  }
548 
549  if( assQuestion::isFileAvailable($imagepath_original . $filename) )
550  {
551  copy($imagepath_original . $filename, $imagepath . $filename);
552  }
553  else
554  {
555  $ilLog->write("matching question image could not be copied: $imagepath_original$filename");
556  }
557 
558  if( assQuestion::isFileAvailable($imagepath_original . $this->getThumbPrefix() . $filename) )
559  {
560  copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename);
561  }
562  else
563  {
564  $ilLog->write("matching question image thumbnail could not be copied: $imagepath_original" . $this->getThumbPrefix() . $filename);
565  }
566  }
567  }
568  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static isFileAvailable($file)
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

◆ copyObject()

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

Copies an assMatchingQuestion.

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

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

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

◆ createNewOriginalFromThisDuplicate()

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

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

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

420  {
421  if ($this->id <= 0)
422  {
423  // The question has not been saved. It cannot be duplicated
424  return;
425  }
426 
427  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
428 
429  $sourceQuestionId = $this->id;
430  $sourceParentId = $this->getObjId();
431 
432  // duplicate the question in database
433  $clone = $this;
434  $clone->id = -1;
435 
436  $clone->setObjId($targetParentId);
437 
438  if ($targetQuestionTitle)
439  {
440  $clone->setTitle($targetQuestionTitle);
441  }
442 
443  $clone->saveToDb();
444  // copy question page content
445  $clone->copyPageOfQuestion($sourceQuestionId);
446  // copy XHTML media objects
447  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
448  // duplicate the image
449  $clone->copyImages($sourceQuestionId, $sourceParentId);
450 
451  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
452 
453  return $clone->id;
454  }
getObjId()
Get the object id of the container object.
+ 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 874 of file class.assMatchingQuestion.php.

875  {
876  unset($this->definitions[$position]);
877  $this->definitions = array_values($this->definitions);
878  }

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

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

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

1053  {
1054  $deletename = $filename;
1055  $result = @unlink($this->getImagePath().$deletename);
1056  $result = $result & @unlink($this->getImagePath().$this->getThumbPrefix() . $deletename);
1057  return $result;
1058  }
$result
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
$filename
Definition: buildRTE.php:89
+ 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 684 of file class.assMatchingQuestion.php.

685  {
686  if ($index < 0)
687  {
688  return;
689  }
690  if (count($this->matchingpairs) < 1)
691  {
692  return;
693  }
694  if ($index >= count($this->matchingpairs))
695  {
696  return;
697  }
698  unset($this->matchingpairs[$index]);
699  $this->matchingpairs = array_values($this->matchingpairs);
700  }

◆ deleteTerm()

assMatchingQuestion::deleteTerm (   $position)

Deletes a term.

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

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

863  {
864  unset($this->terms[$position]);
865  $this->terms = array_values($this->terms);
866  }

◆ duplicate()

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

Duplicates an assMatchingQuestion.

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

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

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

◆ duplicateImages()

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

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

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

457  {
458  global $ilLog;
459  $imagepath = $this->getImagePath();
460  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
461 
462  if( (int)$objectId > 0 )
463  {
464  $imagepath_original = str_replace("/$this->obj_id/", "/$objectId/", $imagepath_original);
465  }
466 
467  foreach ($this->terms as $term)
468  {
469  if (strlen($term->picture))
470  {
471  $filename = $term->picture;
472  if (!file_exists($imagepath))
473  {
474  ilUtil::makeDirParents($imagepath);
475  }
476  if (!@copy($imagepath_original . $filename, $imagepath . $filename))
477  {
478  $ilLog->write("matching question image could not be duplicated: $imagepath_original$filename");
479  }
480  if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename))
481  {
482  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename))
483  {
484  $ilLog->write("matching question image thumbnail could not be duplicated: $imagepath_original" . $this->getThumbPrefix() . $filename);
485  }
486  }
487  }
488  }
489  foreach ($this->definitions as $definition)
490  {
491  if (strlen($definition->picture))
492  {
493  $filename = $definition->picture;
494  if (!file_exists($imagepath))
495  {
496  ilUtil::makeDirParents($imagepath);
497  }
498  if (!@copy($imagepath_original . $filename, $imagepath . $filename))
499  {
500  $ilLog->write("matching question image could not be duplicated: $imagepath_original$filename");
501  }
502  if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename))
503  {
504  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename))
505  {
506  $ilLog->write("matching question image thumbnail could not be duplicated: $imagepath_original" . $this->getThumbPrefix() . $filename);
507  }
508  }
509  }
510  }
511  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

◆ fetchSubmittedMatchingsFromPost()

assMatchingQuestion::fetchSubmittedMatchingsFromPost ( )
private

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

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

Referenced by savePreviewData(), and saveWorkingData().

1099  {
1100  $postData = $_POST['matching'][$this->getId()];
1101 
1102  $matchings = array();
1103 
1104  foreach( $this->getDefinitions() as $definition )
1105  {
1106  if( isset($postData[$definition->identifier]) )
1107  {
1108  foreach( $this->getTerms() as $term )
1109  {
1110  if( isset($postData[$definition->identifier][$term->identifier]) )
1111  {
1112  if( !is_array($postData[$definition->identifier]) )
1113  {
1114  $postData[$definition->identifier] = array();
1115  }
1116 
1117  $matchings[$definition->identifier][] = $term->identifier;
1118  }
1119  }
1120  }
1121  }
1122 
1123  return $matchings;
1124  }
getId()
Gets the id of the assQuestion object.
$_POST['username']
Definition: cron.php:12
getDefinitions()
Returns the definitions of the matching question.
getTerms()
Returns the terms of the matching question.
+ 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 851 of file class.assMatchingQuestion.php.

852  {
853  $this->definitions = array();
854  }

◆ flushMatchingPairs()

assMatchingQuestion::flushMatchingPairs ( )

Deletes all matching pairs.

See also
$matchingpairs

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

707  {
708  $this->matchingpairs = array();
709  }

◆ flushTerms()

assMatchingQuestion::flushTerms ( )

Deletes all terms.

See also
$terms

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

843  {
844  $this->terms = array();
845  }

◆ generateThumbForFile()

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

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

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

Referenced by rebuildThumbnails().

1440  {
1441  $filename = $path . $file;
1442  if (@file_exists($filename))
1443  {
1444  $thumbpath = $path . $this->getThumbPrefix() . $file;
1445  $path_info = @pathinfo($filename);
1446  $ext = "";
1447  switch (strtoupper($path_info['extension']))
1448  {
1449  case 'PNG':
1450  $ext = 'PNG';
1451  break;
1452  case 'GIF':
1453  $ext = 'GIF';
1454  break;
1455  default:
1456  $ext = 'JPEG';
1457  break;
1458  }
1459  ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbGeometry());
1460  }
1461  }
getThumbGeometry()
Get the thumbnail geometry.
print $file
$filename
Definition: buildRTE.php:89
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
$path
Definition: index.php:22
+ 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

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

Referenced by saveAdditionalQuestionDataToDb().

1303  {
1304  return "qpl_qst_matching";
1305  }
+ 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

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

1313  {
1314  return array("qpl_a_matching", "qpl_a_mterm");
1315  }

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

References getMatchingPair(), and getMatchingPairs().

1703  {
1704  if($index !== null)
1705  {
1706  return $this->getMatchingPair($index);
1707  }
1708  else
1709  {
1710  return $this->getMatchingPairs();
1711  }
1712  }
getMatchingPair($index=0)
Returns a matching pair with a given index.
& getMatchingPairs()
Returns the matchingpairs array.
+ 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 761 of file class.assMatchingQuestion.php.

762  {
763  return count($this->definitions);
764  }

◆ getDefinitions()

assMatchingQuestion::getDefinitions ( )

Returns the definitions of the matching question.

Returns
array An array containing the definitions
See also
$terms

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

References $definitions.

Referenced by fetchSubmittedMatchingsFromPost(), and toJSON().

740  {
741  return $this->definitions;
742  }
+ Here is the caller graph for this function:

◆ getDefinitionWithIdentifier()

assMatchingQuestion::getDefinitionWithIdentifier (   $a_identifier)

Returns a definition with a given identifier.

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

644  {
645  foreach ($this->definitions as $definition)
646  {
647  if ($definition->identifier == $a_identifier) return $definition;
648  }
649  return null;
650  }

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

References $filename.

1016  {
1017  $extension = "";
1018  if (preg_match("/.*\\.(\\w+)$/", $filename, $matches))
1019  {
1020  $extension = $matches[1];
1021  }
1022  return md5($filename) . "." . $extension;
1023  }
$filename
Definition: buildRTE.php:89

◆ getExpressionTypes()

◆ getMatchingMode()

assMatchingQuestion::getMatchingMode ( )

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

References $matchingMode.

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

1565  {
1566  return $this->matchingMode;
1567  }
+ 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 660 of file class.assMatchingQuestion.php.

Referenced by getAvailableAnswerOptions().

661  {
662  if ($index < 0)
663  {
664  return NULL;
665  }
666  if (count($this->matchingpairs) < 1)
667  {
668  return NULL;
669  }
670  if ($index >= count($this->matchingpairs))
671  {
672  return NULL;
673  }
674  return $this->matchingpairs[$index];
675  }
+ 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 717 of file class.assMatchingQuestion.php.

718  {
719  return count($this->matchingpairs);
720  }

◆ getMatchingPairs()

& assMatchingQuestion::getMatchingPairs ( )

Returns the matchingpairs array.

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

References $matchingpairs.

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

1330  {
1331  return $this->matchingpairs;
1332  }
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assMatchingQuestion::getMaximumPoints ( )

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

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

References assQuestion\$points, and getMaximumScoringMatchingPairs().

Referenced by getExpressionTypes(), and isComplete().

939  {
940  $points = 0;
941 
942  foreach( $this->getMaximumScoringMatchingPairs() as $pair )
943  {
944  $points += $pair->points;
945  }
946 
947  return $points;
948  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMaximumScoringMatchingPairs()

assMatchingQuestion::getMaximumScoringMatchingPairs ( )

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

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

Referenced by getMaximumPoints().

951  {
952  if( $this->getMatchingMode() == self::MATCHING_MODE_N_ON_N )
953  {
954  return $this->getPositiveScoredMatchingPairs();
955  }
956  elseif( $this->getMatchingMode() == self::MATCHING_MODE_1_ON_1 )
957  {
959  }
960 
961  return array();
962  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMostPositiveScoredUniqueTermMatchingPairs()

assMatchingQuestion::getMostPositiveScoredUniqueTermMatchingPairs ( )
private

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

Referenced by getMaximumScoringMatchingPairs().

982  {
983  $matchingPairsByDefinition = array();
984 
985  foreach( $this->matchingpairs as $pair )
986  {
987  if( $pair->points <= 0 )
988  {
989  continue;
990  }
991 
992  $defId = $pair->definition->identifier;
993 
994  if( !isset($matchingPairsByDefinition[$defId]) )
995  {
996  $matchingPairsByDefinition[$defId] = $pair;
997  }
998  elseif( $pair->points > $matchingPairsByDefinition[$defId]->points )
999  {
1000  $matchingPairsByDefinition[$defId] = $pair;
1001  }
1002  }
1003 
1004  return $matchingPairsByDefinition;
1005  }
+ 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 1600 of file class.assMatchingQuestion.php.

References ilOperatorsExpressionMapping\getOperatorsByExpression().

1601  {
1602  require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1604  }
+ Here is the call graph for this function:

◆ getPositiveScoredMatchingPairs()

assMatchingQuestion::getPositiveScoredMatchingPairs ( )
private

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

Referenced by getMaximumScoringMatchingPairs().

965  {
966  $matchingPairs = array();
967 
968  foreach( $this->matchingpairs as $pair )
969  {
970  if( $pair->points <= 0 )
971  {
972  continue;
973  }
974 
975  $matchingPairs[] = $pair;
976  }
977 
978  return $matchingPairs;
979  }
+ 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

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

Referenced by toJSON().

1293  {
1294  return "assMatchingQuestion";
1295  }
+ Here is the caller graph for this function:

◆ getRandomId()

assMatchingQuestion::getRandomId ( )

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

1246  {
1247  mt_srand((double)microtime()*1000000);
1248  $random_number = mt_rand(1, 100000);
1249  $found = FALSE;
1250  while ($found)
1251  {
1252  $found = FALSE;
1253  foreach ($this->matchingpairs as $key => $pair)
1254  {
1255  if (($pair->term->identifier == $random_number) || ($pair->definition->identifier == $random_number))
1256  {
1257  $found = TRUE;
1258  $random_number++;
1259  }
1260  }
1261  }
1262  return $random_number;
1263  }

◆ getRTETextWithMediaObjects()

assMatchingQuestion::getRTETextWithMediaObjects ( )

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

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

1322  {
1323  return parent::getRTETextWithMediaObjects();
1324  }

◆ getTermCount()

assMatchingQuestion::getTermCount ( )

Returns the number of terms.

Returns
integer The number of terms
See also
$terms

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

751  {
752  return count($this->terms);
753  }

◆ getTerms()

assMatchingQuestion::getTerms ( )

Returns the terms of the matching question.

Returns
array An array containing the terms
See also
$terms

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

References $terms.

Referenced by fetchSubmittedMatchingsFromPost(), and toJSON().

729  {
730  return $this->terms;
731  }
+ Here is the caller graph for this function:

◆ getTermWithIdentifier()

assMatchingQuestion::getTermWithIdentifier (   $a_identifier)

Returns a term with a given identifier.

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

632  {
633  foreach ($this->terms as $term)
634  {
635  if ($term->identifier == $a_identifier) return $term;
636  }
637  return null;
638  }

◆ getThumbGeometry()

assMatchingQuestion::getThumbGeometry ( )

Get the thumbnail geometry.

Returns
integer Geometry

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

References $thumb_geometry.

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

1395  {
1396  return $this->thumb_geometry;
1397  }
+ Here is the caller graph for this function:

◆ getThumbPrefix()

assMatchingQuestion::getThumbPrefix ( )

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

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

1435  {
1436  return "thumb.";
1437  }
+ Here is the caller graph for this function:

◆ getThumbSize()

assMatchingQuestion::getThumbSize ( )

Get the thumbnail geometry.

Returns
integer Geometry

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

References getThumbGeometry().

1405  {
1406  return $this->getThumbGeometry();
1407  }
getThumbGeometry()
Get the thumbnail geometry.
+ 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 819 of file class.assMatchingQuestion.php.

820  {
821  if (is_null($definition))
822  {
823  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
824  $definition = new assAnswerMatchingDefinition();
825  }
826  if ($position < count($this->definitions))
827  {
828  $part1 = array_slice($this->definitions, 0, $position);
829  $part2 = array_slice($this->definitions, $position);
830  $this->definitions = array_merge($part1, array($definition), $part2);
831  }
832  else
833  {
834  array_push($this->definitions, $definition);
835  }
836  }
Class for matching question definitions.

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

References assQuestion\$points.

581  {
582  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
583  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
584  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
585  if (is_null($term)) $term = new assAnswerMatchingTerm();
586  if (is_null($definition)) $definition = new assAnswerMatchingDefinition();
587  $pair = new assAnswerMatchingPair($term, $definition, $points);
588  if ($position < count($this->matchingpairs))
589  {
590  $part1 = array_slice($this->matchingpairs, 0, $position);
591  $part2 = array_slice($this->matchingpairs, $position);
592  $this->matchingpairs = array_merge($part1, array($pair), $part2);
593  }
594  else
595  {
596  array_push($this->matchingpairs, $pair);
597  }
598  }
Class for matching question terms.
Class for matching question pairs.
Class for matching question definitions.

◆ insertTerm()

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

Inserts a term.

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

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

795  {
796  if (is_null($term))
797  {
798  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
799  $term = new assAnswerMatchingTerm();
800  }
801  if ($position < count($this->terms))
802  {
803  $part1 = array_slice($this->terms, 0, $position);
804  $part2 = array_slice($this->terms, $position);
805  $this->terms = array_merge($part1, array($term), $part2);
806  }
807  else
808  {
809  array_push($this->terms, $term);
810  }
811  }
Class for matching question terms.

◆ 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

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

References getMaximumPoints().

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

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

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

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

◆ rebuildThumbnails()

assMatchingQuestion::rebuildThumbnails ( )

Rebuild the thumbnail images with a new thumbnail size.

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

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

Referenced by saveAnswerSpecificDataToDb().

1423  {
1424  foreach ($this->terms as $term)
1425  {
1426  if (strlen($term->picture)) $this->generateThumbForFile($this->getImagePath(), $term->picture);
1427  }
1428  foreach ($this->definitions as $definition)
1429  {
1430  if (strlen($definition->picture)) $this->generateThumbForFile($this->getImagePath(), $definition->picture);
1431  }
1432  }
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeDefinitionImage()

assMatchingQuestion::removeDefinitionImage (   $index)

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

References deleteImagefile().

1036  {
1037  $definition = $this->definitions[$index];
1038  if (is_object($definition))
1039  {
1040  $this->deleteImagefile($definition->picture);
1041  $definition->picture = null;
1042  }
1043  }
deleteImagefile($filename)
Deletes an imagefile from the system if the file is deleted manually.
+ Here is the call graph for this function:

◆ removeTermImage()

assMatchingQuestion::removeTermImage (   $index)

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

References deleteImagefile().

1026  {
1027  $term = $this->terms[$index];
1028  if (is_object($term))
1029  {
1030  $this->deleteImagefile($term->picture);
1031  $term->picture = null;
1032  }
1033  }
deleteImagefile($filename)
Deletes an imagefile from the system if the file is deleted manually.
+ Here is the call graph for this function:

◆ reworkWorkingData()

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

Reworks the allready saved working data if neccessary.

protected

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered

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

1241  {
1242  // nothing to rework!
1243  }

◆ saveAdditionalQuestionDataToDb()

assMatchingQuestion::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

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

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

Referenced by saveToDb().

207  {
208  global $ilDB;
209 
210  // save additional data
211 
212  $ilDB->manipulateF(
213  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
214  array( "integer" ), 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  }
getThumbGeometry()
Get the thumbnail geometry.
getId()
Gets the id of the assQuestion object.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
global $ilDB
+ 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 138 of file class.assMatchingQuestion.php.

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

Referenced by saveToDb().

139  {
140  global $ilDB;
141  // delete old terms
142  $ilDB->manipulateF( "DELETE FROM qpl_a_mterm WHERE question_fi = %s",
143  array( 'integer' ),
144  array( $this->getId() )
145  );
146 
147  // delete old definitions
148  $ilDB->manipulateF( "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  {
157  $next_id = $ilDB->nextId( 'qpl_a_mterm' );
158  $ilDB->insert('qpl_a_mterm', array(
159  'term_id' => array('integer', $next_id),
160  'question_fi' => array('integer', $this->getId()),
161  'picture' => array('text', $term->picture),
162  'term' => array('text', $term->text),
163  'ident' => array('integer', $term->identifier)
164  ));
165  $termids[$term->identifier] = $next_id;
166  }
167 
168  $definitionids = array();
169  // write definitions
170  foreach ($this->definitions as $key => $definition)
171  {
172  $next_id = $ilDB->nextId( 'qpl_a_mdef' );
173  $ilDB->insert('qpl_a_mdef', array(
174  'def_id' => array('integer', $next_id),
175  'question_fi' => array('integer', $this->getId()),
176  'picture' => array('text', $definition->picture),
177  'definition' => array('text', $definition->text),
178  'ident' => array('integer', $definition->identifier)
179  ));
180  $definitionids[$definition->identifier] = $next_id;
181  }
182 
183  $ilDB->manipulateF( "DELETE FROM qpl_a_matching WHERE question_fi = %s",
184  array( 'integer' ),
185  array( $this->getId() )
186  );
187  $matchingpairs = $this->getMatchingPairs();
188  foreach ($matchingpairs as $key => $pair)
189  {
190  $next_id = $ilDB->nextId( 'qpl_a_matching' );
191  $ilDB->manipulateF( "INSERT INTO qpl_a_matching (answer_id, question_fi, points, term_fi, definition_fi) VALUES (%s, %s, %s, %s, %s)",
192  array( 'integer', 'integer', 'float', 'integer', 'integer' ),
193  array(
194  $next_id,
195  $this->getId(),
196  $pair->points,
197  $termids[$pair->term->identifier],
198  $definitionids[$pair->definition->identifier]
199  )
200  );
201  }
202 
203  $this->rebuildThumbnails();
204  }
getId()
Gets the id of the assQuestion object.
rebuildThumbnails()
Rebuild the thumbnail images with a new thumbnail size.
global $ilDB
& getMatchingPairs()
Returns the matchingpairs array.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePreviewData()

assMatchingQuestion::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

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

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

1223  {
1224  $submittedMatchings = $this->fetchSubmittedMatchingsFromPost();
1225 
1226  if( $this->checkSubmittedMatchings($submittedMatchings) )
1227  {
1228  $previewSession->setParticipantsSolution($submittedMatchings);
1229  }
1230  }
checkSubmittedMatchings($submittedMatchings)
+ Here is the call graph for this function:

◆ saveToDb()

assMatchingQuestion::saveToDb (   $original_id = "")

Saves a assMatchingQuestion object to a database.

Parameters
string$original_id

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

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

127  {
128  global $ilDB;
129 
132  $this->saveAnswerSpecificDataToDb( $ilDB );
133 
134 
135  parent::saveToDb($original_id);
136  }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb($original_id="")
global $ilDB
+ 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.

public

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

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

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

1167  {
1168  global $ilDB;
1169 
1170  $submittedMatchings = $this->fetchSubmittedMatchingsFromPost();
1171  $submittedMatchingsValid = $this->checkSubmittedMatchings($submittedMatchings);
1172 
1173  $matchingsExist = false;
1174 
1175  if ($submittedMatchingsValid)
1176  {
1177  if (is_null($pass))
1178  {
1179  include_once "./Modules/Test/classes/class.ilObjTest.php";
1180  $pass = ilObjTest::_getPass($active_id);
1181  }
1182 
1183  $this->getProcessLocker()->requestUserSolutionUpdateLock();
1184 
1185  $affectedRows = $this->removeCurrentSolution($active_id, $pass, $authorized);
1186 
1187  foreach( $submittedMatchings as $definition => $terms )
1188  {
1189  foreach( $terms as $i => $term )
1190  {
1191  $affectedRows = $this->saveCurrentSolution($active_id, $pass, $term, $definition, $authorized);
1192 
1193  $matchingsExist = true;
1194  }
1195  }
1196 
1197  $this->getProcessLocker()->releaseUserSolutionUpdateLock();
1198 
1199  $saveWorkingDataResult = true;
1200  }
1201  else
1202  {
1203  $saveWorkingDataResult = false;
1204  }
1205 
1206  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1208  {
1209  if( $matchingsExist )
1210  {
1211  $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1212  }
1213  else
1214  {
1215  $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1216  }
1217  }
1218 
1219  return $saveWorkingDataResult;
1220  }
getId()
Gets the id of the assQuestion object.
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true)
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
removeCurrentSolution($active_id, $pass, $authorized=true, $ignoredSolutionIds=array())
checkSubmittedMatchings($submittedMatchings)
_getLogLanguage()
retrieve the log language for assessment logging
global $ilDB
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
+ Here is the call graph for this function:

◆ setExportDetailsXLS()

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

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
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data public

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

References $pass, ilExcelUtils\_convert_text(), assQuestion\getImagePath(), getMatchingPairs(), assQuestion\getSolutionValues(), and assQuestion\getTitle().

1347  {
1348  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
1349  $solutions = $this->getSolutionValues($active_id, $pass);
1350  $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
1351  $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
1352  $imagepath = $this->getImagePath();
1353  $i = 1;
1354  foreach ($solutions as $solution)
1355  {
1356  $matches_written = FALSE;
1357  foreach ($this->getMatchingPairs() as $idx => $pair)
1358  {
1359  if (!$matches_written) $worksheet->writeString($startrow + $i, 1, ilExcelUtils::_convert_text($this->lng->txt("matches")));
1360  $matches_written = TRUE;
1361  if ($pair->definition->identifier == $solution["value2"])
1362  {
1363  if (strlen($pair->definition->text))
1364  {
1365  $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($pair->definition->text));
1366  }
1367  else
1368  {
1369  $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($pair->definition->picture));
1370  }
1371  }
1372  if ($pair->term->identifier == $solution["value1"])
1373  {
1374  if (strlen($pair->term->text))
1375  {
1376  $worksheet->writeString($startrow + $i, 2, ilExcelUtils::_convert_text($pair->term->text));
1377  }
1378  else
1379  {
1380  $worksheet->writeString($startrow + $i, 2, ilExcelUtils::_convert_text($pair->term->picture));
1381  }
1382  }
1383  }
1384  $i++;
1385  }
1386  return $startrow + $i + 1;
1387  }
_convert_text($a_text, $a_target="has been removed")
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
getTitle()
Gets the title string of the assQuestion object.
& getMatchingPairs()
Returns the matchingpairs array.
+ 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 public

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

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

1069  {
1070  $result = TRUE;
1071  if (strlen($image_tempfilename))
1072  {
1073  $image_filename = str_replace(" ", "_", $image_filename);
1074  $imagepath = $this->getImagePath();
1075  if (!file_exists($imagepath))
1076  {
1077  ilUtil::makeDirParents($imagepath);
1078  }
1079  $savename = $image_filename;
1080  if (!ilUtil::moveUploadedFile($image_tempfilename, $savename, $imagepath.$savename))
1081  {
1082  $result = FALSE;
1083  }
1084  else
1085  {
1086  // create thumbnail file
1087  $thumbpath = $imagepath . $this->getThumbPrefix() . $savename;
1088  ilUtil::convertImage($imagepath.$savename, $thumbpath, "JPEG", $this->getThumbGeometry());
1089  }
1090  if ($result && (strcmp($image_filename, $previous_filename) != 0) && (strlen($previous_filename)))
1091  {
1092  $this->deleteImagefile($previous_filename);
1093  }
1094  }
1095  return $result;
1096  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$result
deleteImagefile($filename)
Deletes an imagefile from the system if the file is deleted manually.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
+ Here is the call graph for this function:

◆ setMatchingMode()

assMatchingQuestion::setMatchingMode (   $matchingMode)

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

References $matchingMode.

Referenced by loadFromDb().

1560  {
1561  $this->matchingMode = $matchingMode;
1562  }
+ 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

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

References assQuestion\$shuffle.

Referenced by loadFromDb().

1272  {
1273  switch ($shuffle)
1274  {
1275  case 0:
1276  case 1:
1277  case 2:
1278  case 3:
1279  $this->shuffle = $shuffle;
1280  break;
1281  default:
1282  $this->shuffle = 1;
1283  break;
1284  }
1285  }
+ 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 887 of file class.assMatchingQuestion.php.

888  {
889  $this->terms[$index] = $term;
890  }

◆ setThumbGeometry()

assMatchingQuestion::setThumbGeometry (   $a_geometry)

Set the thumbnail geometry.

Parameters
integer$a_geometryGeometry

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

Referenced by loadFromDb().

1415  {
1416  $this->thumb_geometry = ($a_geometry < 1) ? 100 : $a_geometry;
1417  }
+ Here is the caller graph for this function:

◆ supportsJavascriptOutput()

assMatchingQuestion::supportsJavascriptOutput ( )

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

1550  {
1551  return true;
1552  }

◆ supportsNonJsOutput()

assMatchingQuestion::supportsNonJsOutput ( )

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

1555  {
1556  return false;
1557  }

◆ toJSON()

assMatchingQuestion::toJSON ( )

Returns a JSON representation of the question TODO.

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

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

1468  {
1469  $result = array();
1470 
1471  $result['id'] = (int) $this->getId();
1472  $result['type'] = (string) $this->getQuestionType();
1473  $result['title'] = (string) $this->getTitle();
1474  $result['question'] = $this->formatSAQuestion($this->getQuestion());
1475  $result['nr_of_tries'] = (int) $this->getNrOfTries();
1476  $result['matching_mode'] = $this->getMatchingMode();
1477  $result['shuffle'] = true;
1478  $result['feedback'] = array(
1479  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1480  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1481  );
1482 
1483  $terms = array();
1484  foreach ($this->getTerms() as $term)
1485  {
1486  $terms[] = array(
1487  "text" => $this->formatSAQuestion($term->text),
1488  "id" =>(int)$this->getId().$term->identifier
1489  );
1490  }
1491  $result['terms'] = $terms;
1492 
1493  // alex 9.9.2010 as a fix for bug 6513 I added the question id
1494  // to the "def_id" in the array. The $pair->definition->identifier is not
1495  // unique, since it gets it value from the morder table field
1496  // this value is not changed, when a question is copied.
1497  // thus copying the same question on a page results in problems
1498  // when the second one (the copy) is answered.
1499 
1500  $definitions = array();
1501  foreach ($this->getDefinitions() as $def)
1502  {
1503  $definitions[] = array(
1504  "text" => $this->formatSAQuestion((string) $def->text),
1505  "id" => (int) $this->getId().$def->identifier
1506  );
1507  }
1508  $result['definitions'] = $definitions;
1509 
1510  // #10353
1511  $matchings = array();
1512  foreach ($this->getMatchingPairs() as $pair)
1513  {
1514 // fau: fixLmMatchingPoints - ignore matching pairs with 0 or negative points
1515  if ($pair->points <= 0)
1516  {
1517  continue;
1518  }
1519 // fau.
1520 
1521  $pid = $pair->definition->identifier;
1522  if( $this->getMatchingMode() == self::MATCHING_MODE_N_ON_N )
1523  {
1524  $pid .= '::'.$pair->term->identifier;
1525  }
1526 
1527  if( !isset($matchings[$pid]) || $matchings[$pid]["points"] < $pair->points )
1528  {
1529  $matchings[$pid] = array(
1530  "term_id" => (int) $this->getId().$pair->term->identifier,
1531  "def_id" => (int) $this->getId().$pair->definition->identifier,
1532  "points" => (int) $pair->points
1533  );
1534  }
1535  }
1536 
1537  $result['matchingPairs'] = array_values($matchings);
1538 
1539  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1540  $result['mobs'] = $mobs;
1541 
1542  global $lng;
1543  $lng->loadLanguageModule('assessment');
1544  $result['reset_button_label'] = $lng->txt("reset_terms");
1545 
1546  return json_encode($result);
1547  }
getId()
Gets the id of the assQuestion object.
formatSAQuestion($a_q)
Format self assessment question.
$result
getQuestionType()
Returns the question type of the question.
getDefinitions()
Returns the definitions of the matching question.
$mobs
getQuestion()
Gets the question string of the question object.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
getTerms()
Returns the terms of the matching question.
getTitle()
Gets the title string of the assQuestion object.
& getMatchingPairs()
Returns the matchingpairs array.
+ 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(), getExpressionTypes(), 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().

◆ $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: