ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 
 getShuffleMode ()
 
 setShuffleMode (int $shuffle)
 
 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 (bool $for_test=true, string $title="", string $author="", string $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 (assAnswerMatchingTerm $term=null, assAnswerMatchingDefinition $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...
 
 withMatchingPairs (array $pairs)
 
 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 (assAnswerMatchingTerm $term)
 
 addDefinition ($definition)
 Adds a definition. More...
 
 insertTerm ($position, assAnswerMatchingTerm $term=null)
 Inserts a term. More...
 
 insertDefinition ($position, assAnswerMatchingDefinition $definition=null)
 Inserts a definition. More...
 
 flushTerms ()
 Deletes all terms. More...
 
 flushDefinitions ()
 Deletes all definitions. More...
 
 deleteTerm ($position)
 Deletes a term. More...
 
 deleteDefinition ($position)
 Deletes a definition. More...
 
 setTerm ($term, $index)
 Sets a specific term. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 getMaximumPoints ()
 Calculates and Returns the maximum points, a learner can reach answering the question. More...
 
 getMaximumScoringMatchingPairs ()
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 getEncryptedFilename ($filename)
 Returns the encrypted save filename of a matching picture Images are saved with an encrypted filename to prevent users from cheating by guessing the solution from the image filename. More...
 
 removeTermImage ($index)
 
 removeDefinitionImage ($index)
 
 deleteImagefile (string $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)
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 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 (ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
 {} More...
 
 getThumbGeometry ()
 Get the thumbnail geometry. More...
 
 getThumbSize ()
 Get the thumbnail geometry. More...
 
 setThumbGeometry (int $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. 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 (string $title="", string $comment="", string $author="", int $owner=-1, string $question="")
 assQuestion constructor More...
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML ($item, int $questionpool_id, ?int $tst_id, &$tst_object, int &$question_counter, array $import_mapping, array &$solutionhints=[])
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $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 (int $questionpool_id, string $title)
 Returns TRUE if the question title exists in a question pool in the database. More...
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 setOutputType (int $outputType=OUTPUT_HTML)
 
 setShuffle (?bool $shuffle=true)
 
 setAuthor (string $author="")
 
 setOwner (int $owner=-1)
 
 getTitle ()
 
 getTitleForHTMLOutput ()
 
 getTitleFilenameCompliant ()
 
 getId ()
 
 getShuffle ()
 
 getTestId ()
 
 getComment ()
 
 getDescriptionForHTMLOutput ()
 
 getThumbSize ()
 
 setThumbSize (int $a_size)
 
 getMinimumThumbSize ()
 
 getMaximumThumbSize ()
 
 getOutputType ()
 
 supportsJavascriptOutput ()
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 _getSuggestedSolution (int $question_id, int $subquestion_index=0)
 
 loadSuggestedSolution (int $question_id, int $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution (int $active_id, int $pass, bool $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $obligationsEnabled=false, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 saveWorkingData (int $active_id, int $pass, bool $authorized=true)
 Saves the learners input of the question to the database. More...
 
 moveUploadedMediaFile (string $file, string $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 
 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...
 
 getSuggestedSolutionPathWeb ()
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getTestOutputSolutions (int $activeId, int $pass)
 
 getUserSolutionPreferingIntermediate (int $active_id, $pass=null)
 
 getSolutionValues ($active_id, $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse (int $question_id=0)
 Checks whether the question is in use or not in pools or tests. More...
 
 usageNumber (int $question_id=0)
 Returns the number of place the question is in use in pools or tests. More...
 
 isClone (int $question_id=0)
 Checks whether the question is a clone of another question or not. More...
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 copyXHTMLMediaObjectsOfQuestion (int $a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 
 copyPageOfQuestion (int $a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
 fixSvgToPng (string $imageFilenameContainingString)
 
 fixUnavailableSkinImageSources (string $html)
 
 loadFromDb (int $question_id)
 
 createNewQuestion (bool $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 (int $original_id=-1)
 
 saveToDb ()
 
 setNewOriginalId (int $newId)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle (int $subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution (string $solution_id="", int $subquestion_index=0, bool $is_import=false)
 Sets a suggested solution for the question. More...
 
 updateSuggestedSolutions (int $original_id=-1, int $original_obj_id=-1)
 
 _resolveInternalLink (string $internal_link)
 
 _resolveIntLinks (int $question_id)
 
 syncWithOriginal ()
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool (int $question_id)
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 deductHintPointsFromReachedPoints (ilAssQuestionPreviewSession $previewSession, $reachedPoints)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=null)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 prepareTextareaOutput (string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
 
 QTIMaterialToString (ilQTIMaterial $a_material)
 Reads an QTI material tag and creates a text or XHTML string. More...
 
 addQTIMaterial (ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 
 syncHints ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 setExportDetailsXLS (ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 __isset ($key)
 Object issetter. More...
 
 getNrOfTries ()
 
 setNrOfTries (int $a_nr_of_tries)
 
 setExportImagePath (string $path)
 
 formatSAQuestion ($a_q)
 
 setPreventRteUsage (bool $prevent_rte_usage)
 
 getPreventRteUsage ()
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode (bool $selfassessmenteditingmode)
 
 getSelfAssessmentEditingMode ()
 
 setDefaultNrOfTries (int $defaultnroftries)
 
 getDefaultNrOfTries ()
 
 syncSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 ensureHintPageObjectExists ($pageObjectId)
 
 isAnswered (int $active_id, int $pass)
 
 isAutosaveable ()
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 removeCurrentSolution (int $active_id, int $pass, bool $authorized=true)
 
 saveCurrentSolution (int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
 updateCurrentSolution (int $solutionId, $value1, $value2, bool $authorized=true)
 
 updateCurrentSolutionsAuthorization (int $activeId, int $pass, bool $authorized, bool $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate (bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
 
 intermediateSolutionExists (int $active_id, int $pass)
 
 authorizedSolutionExists (int $active_id, ?int $pass)
 
 authorizedOrIntermediateSolutionExists (int $active_id, int $pass)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions (int $activeId, int $pass)
 
 resetUsersAnswer (int $activeId, int $pass)
 
 removeResultRecord (int $activeId, int $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered (bool $obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
 savePartial ()
 
 isInActiveTest ()
 
- 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 TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
ilAssQuestionFeedback $feedbackOBJ
 
bool $prevent_rte_usage = false
 
bool $selfassessmenteditingmode = false
 
int $defaultnroftries = 0
 
string $questionActionCmd = 'handleQuestionAction'
 
const KEY_VALUES_IMPLOSION_SEPARATOR = ':'
 
- Data Fields inherited from iQuestionCondition
const StringResultExpression = '~TEXT~'
 
const PercentageResultExpression = '%n%'
 
const NumericResultExpression = '#n#'
 
const MatchingResultExpression = ';n:m;'
 
const OrderingResultExpression = '$n,m,o,p$'
 
const NumberOfResultExpression = '+n+'
 
const ExclusiveResultExpression = '*n,m,o,p*'
 
const EmptyAnswerExpression = "?"
 

Protected Member Functions

 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 generateThumbForFile ($path, $file)
 
 calculateReachedPointsForSolution ($found_values)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 {} More...
 
 createMatchingTerm (string $term='', string $picture='', int $identifier=0)
 
 createMatchingDefinition (string $term='', string $picture='', int $identifier=0)
 
 createMatchingPair (assAnswerMatchingTerm $term=null, assAnswerMatchingDefinition $definition=null, float $points=0.0)
 
- Protected Member Functions inherited from assQuestion
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $postSubmissionFieldname)
 
 ensureCurrentTestPass (int $active_id, int $pass)
 
 lookupCurrentTestPass (int $active_id, int $pass)
 
 lookupTestId (int $active_id)
 Move to ilObjTest or similar More...
 
 log (int $active_id, string $langVar)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 deletePageOfQuestion (int $question_id)
 
 onDuplicate (int $originalParentId, int $originalQuestionId, int $duplicateParentId, int $duplicateQuestionId)
 
 beforeSyncWithOriginal (int $origQuestionId, int $dupQuestionId, int $origParentObjId, int $dupParentObjId)
 
 afterSyncWithOriginal (int $origQuestionId, int $dupQuestionId, int $origParentObjId, int $dupParentObjId)
 
 onCopy (int $sourceParentId, int $sourceQuestionId, int $targetParentId, int $targetQuestionId)
 
 duplicateSuggestedSolutionFiles (int $parent_id, int $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles (int $target_question_id, int $target_obj_id)
 
 copySuggestedSolutionFiles (int $source_questionpool_id, int $source_question_id)
 
 ensureNonNegativePoints ($points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints (int $originalQuestionId, int $duplicateQuestionId)
 
 duplicateSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet (int $active_id, int $pass, bool $authorized=true)
 
 removeSolutionRecordById (int $solutionId)
 
 getSolutionRecordById (int $solutionId)
 
 deleteDummySolutionRecord (int $activeId, int $passIndex)
 
 isDummySolutionRecord (array $solutionRecord)
 
 deleteSolutionRecordByValues (int $activeId, int $passIndex, bool $authorized, array $matchValues)
 
 duplicateIntermediateSolutionAuthorized (int $activeId, int $passIndex)
 
 forceExistingIntermediateSolution (int $activeId, int $passIndex, bool $considerDummyRecordCreation)
 
 lookupMaxStep (int $active_id, int $pass)
 
 buildTestPresentationConfig ()
 build basic test question configuration instance More...
 

Protected Attributes

array $terms = []
 
 $definitions
 
 $matchingMode = self::MATCHING_MODE_1_ON_1
 
- Protected Attributes inherited from assQuestion
const HAS_SPECIFIC_FEEDBACK = true
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
ILIAS DI LoggingServices $ilLog
 
int $id
 
string $title
 
string $comment
 
string $owner
 
string $author
 
int $thumb_size
 
string $question
 The question text. More...
 
float $points
 The maximum available points for the question. More...
 
bool $shuffle
 Indicates whether the answers will be shuffled or not. More...
 
int $test_id
 The database id of a test in which the question is contained. More...
 
int $obj_id = 0
 Object id of the container object. More...
 
 $ilias
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
ilDBInterface $db
 
Container $dic
 
int $outputType = OUTPUT_JAVASCRIPT
 Contains the output type of a question. More...
 
array $suggested_solutions
 
int $original_id = null
 
 $page
 
string $external_id = null
 
ilAssQuestionProcessLocker $processLocker
 
 $step
 
 $lastChange
 
Transformation $shuffler
 
ilTestQuestionConfig $testQuestionConfig
 
ilAssQuestionLifecycle $lifecycle
 
ilObjUser $current_user
 

Private Member Functions

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

Private Attributes

int $shufflemode = 0
 
RandomGroup $randomGroup
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $forcePassResultsUpdateEnabled)
 
static isForcePassResultUpdateEnabled ()
 
static isAllowedImageMimeType ($mimeType)
 
static fetchMimeTypeIdentifier (string $contentType)
 
static getAllowedFileExtensionsForMimeType (string $mimeType)
 
static isAllowedImageFileExtension (string $mimeType, string $fileExtension)
 
static getAllowedImageMaterialFileExtensions ()
 
static _getMaximumPoints (int $question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
static _getQuestionInfo (int $question_id)
 
static _getSuggestedSolutionCount (int $question_id)
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static _updateTestResultCache (int $active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place. More...
 
static logAction (string $logtext, int $active_id, int $question_id)
 
static getQuestionTypeFromDb (int $question_id)
 
static _getTotalRightAnswers (int $a_q_id)
 
static _getTitle (int $a_q_id)
 
static _getQuestionText (int $a_q_id)
 
static isFileAvailable (string $file)
 
static _getQuestionType (int $question_id)
 
static _getQuestionTitle (int $question_id)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static _getInternalLinkHref (string $target="")
 
static _getOriginalId (int $question_id)
 
static originalQuestionExists (int $questionId)
 
static _instanciateQuestion (int $question_id)
 
static _instantiateQuestion (int $question_id)
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static _isWriteable (int $question_id, int $user_id)
 
static _isUsedInRandomTest (int $question_id)
 
static _isWorkedThrough (int $active_id, int $question_id, int $pass)
 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 (int $a_user_id, array $a_question_ids)
 Checks if an array of question ids is answered by a user or not. More...
 
static _setReachedPoints (int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring, bool $obligationsEnabled)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static _needsManualScoring (int $question_id)
 
static _includeClass (string $question_type, int $gui=0)
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static isCoreQuestionType (string $questionType)
 
static includeCoreClass ($questionType, $withGuiClass)
 
static _getQuestionTypeName ($type_tag)
 
static _instanciateQuestionGUI (int $question_id)
 
static instantiateQuestionGUI (int $a_question_id)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $questionId)
 
static lookupOriginalParentObjId (int $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 (int $questionId)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
static missingResultRecordExists (int $activeId, int $pass, array $questionIds)
 
static getQuestionsMissingResultRecord (int $activeId, int $pass, array $questionIds)
 
static lookupResultRecordExist (int $activeId, int $questionId, int $pass)
 
static extendedTrim (string $value)
 Trim non-printable characters from the beginning and end of a string. More...
 
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $allowedImageMaterialFileExtensionsByMimeType
 
static $forcePassResultsUpdateEnabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

Class for matching questions.

assMatchingQuestion is a class for matching questions.

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

Definition at line 39 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

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

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

109  {
110  global $DIC;
111 
113  $this->matchingpairs = array();
114  $this->matching_type = $matching_type;
115  $this->terms = array();
116  $this->definitions = array();
117  $this->randomGroup = $DIC->refinery()->random();
118  }
global $DIC
Definition: feed.php:28
string $question
The question text.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addDefinition()

assMatchingQuestion::addDefinition (   $definition)

Adds a definition.

Parameters
object$definitionThe definition
See also
$definitions

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

766  : void
767  {
768  array_push($this->definitions, $definition);
769  }

◆ addMatchingPair()

assMatchingQuestion::addMatchingPair ( assAnswerMatchingTerm  $term = null,
assAnswerMatchingDefinition  $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 604 of file class.assMatchingQuestion.php.

References assQuestion\$points, and createMatchingPair().

604  : void
605  {
606  $pair = $this->createMatchingPair($term, $definition, $points);
607  array_push($this->matchingpairs, $pair);
608  }
float $points
The maximum available points for the question.
createMatchingPair(assAnswerMatchingTerm $term=null, assAnswerMatchingDefinition $definition=null, float $points=0.0)
+ Here is the call graph for this function:

◆ addTerm()

assMatchingQuestion::addTerm ( assAnswerMatchingTerm  $term)

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

755  : void
756  {
757  $this->terms[] = $term;
758  }

◆ afterSyncWithOriginal()

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

{}

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

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

1593  : void
1594  {
1595  parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
1596 
1597  $origImagePath = $this->buildImagePath($origQuestionId, $origParentObjId);
1598  $dupImagePath = $this->buildImagePath($dupQuestionId, $dupParentObjId);
1599 
1600  ilFileUtils::delDir($origImagePath);
1601  if (is_dir($dupImagePath)) {
1602  ilFileUtils::makeDirParents($origImagePath);
1603  ilFileUtils::rCopy($dupImagePath, $origImagePath);
1604  }
1605  }
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
buildImagePath($questionId, $parentObjectId)
+ 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 875 of file class.assMatchingQuestion.php.

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

Referenced by getExpressionTypes().

875  : float
876  {
877  if ($returndetails) {
878  throw new ilTestException('return details not implemented for ' . __METHOD__);
879  }
880 
881  global $DIC;
882  $ilDB = $DIC['ilDB'];
883 
884  $found_values = [];
885  if (is_null($pass)) {
886  $pass = $this->getSolutionMaxPass($active_id);
887  }
888  $result = $this->getCurrentSolutionResultSet($active_id, (int) $pass, $authorizedSolution);
889  while ($data = $ilDB->fetchAssoc($result)) {
890  if (strcmp($data["value1"], "") != 0) {
891  if (!isset($found_values[$data['value2']])) {
892  $found_values[$data['value2']] = array();
893  }
894 
895  $found_values[$data['value2']][] = $data['value1'];
896  }
897  }
898 
899  $points = $this->calculateReachedPointsForSolution($found_values);
900 
901  return $points;
902  }
calculateReachedPointsForSolution($found_values)
float $points
The maximum available points for the question.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
getSolutionMaxPass(int $active_id)
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
+ 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
float

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

References assQuestion\$points.

Referenced by calculateReachedPoints().

1459  : float
1460  {
1461  $points = 0;
1462  if (! is_array($found_values)) {
1463  return $points;
1464  }
1465  foreach ($found_values as $definition => $terms) {
1466  if (!is_array($terms)) {
1467  continue;
1468  }
1469  foreach ($terms as $term) {
1470  foreach ($this->matchingpairs as $pair) {
1471  if ($pair->getDefinition()->getIdentifier() == $definition && $pair->getTerm()->getIdentifier() == $term) {
1472  $points += $pair->getPoints();
1473  }
1474  }
1475  }
1476  }
1477  return $points;
1478  }
float $points
The maximum available points for the question.
+ Here is the caller graph for this function:

◆ checkSubmittedMatchings()

assMatchingQuestion::checkSubmittedMatchings (   $submittedMatchings)
private

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

References $i, getMatchingMode(), and ILIAS\Repository\lng().

Referenced by savePreviewData(), and saveWorkingData().

1095  : bool
1096  {
1097  if ($this->getMatchingMode() == self::MATCHING_MODE_N_ON_N) {
1098  return true;
1099  }
1100 
1101  $handledTerms = array();
1102 
1103  foreach ($submittedMatchings as $definition => $terms) {
1104  if (count($terms) > 1) {
1105  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("multiple_matching_values_selected"), true);
1106  return false;
1107  }
1108 
1109  foreach ($terms as $i => $term) {
1110  if (isset($handledTerms[$term])) {
1111  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("duplicate_matching_values_selected"), true);
1112  return false;
1113  }
1114 
1115  $handledTerms[$term] = $term;
1116  }
1117  }
1118 
1119  return true;
1120  }
$i
Definition: metadata.php:41
+ 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 526 of file class.assMatchingQuestion.php.

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

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

◆ copyObject()

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

Copies an assMatchingQuestion.

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

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

419  : int
420  {
421  if ($this->getId() <= 0) {
422  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
423  }
424  // duplicate the question in database
425  $clone = $this;
426  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
428  $clone->id = -1;
429  $source_questionpool_id = $this->getObjId();
430  $clone->setObjId($target_questionpool_id);
431  if ($title) {
432  $clone->setTitle($title);
433  }
434  $clone->saveToDb();
435  // copy question page content
436  $clone->copyPageOfQuestion($original_id);
437  // copy XHTML media objects
438  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
439  // duplicate the image
440  $clone->copyImages($original_id, $source_questionpool_id);
441 
442  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
443 
444  return $clone->id;
445  }
static _getOriginalId(int $question_id)
+ Here is the call graph for this function:

◆ createMatchingDefinition()

assMatchingQuestion::createMatchingDefinition ( string  $term = '',
string  $picture = '',
int  $identifier = 0 
)
protected

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

Referenced by createMatchingPair(), insertDefinition(), and loadFromDb().

1612  {
1613  return new assAnswerMatchingDefinition($term, $picture, $identifier);
1614  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ createMatchingPair()

assMatchingQuestion::createMatchingPair ( assAnswerMatchingTerm  $term = null,
assAnswerMatchingDefinition  $definition = null,
float  $points = 0.0 
)
protected

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

References assQuestion\$points, createMatchingDefinition(), and createMatchingTerm().

Referenced by addMatchingPair(), insertMatchingPair(), and loadFromDb().

1620  $term = $term ?? $this->createMatchingTerm();
1621  $definition = $definition ?? $this->createMatchingDefinition();
1622  return new assAnswerMatchingPair($term, $definition, $points);
1623  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
float $points
The maximum available points for the question.
createMatchingTerm(string $term='', string $picture='', int $identifier=0)
createMatchingDefinition(string $term='', string $picture='', int $identifier=0)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createMatchingTerm()

assMatchingQuestion::createMatchingTerm ( string  $term = '',
string  $picture = '',
int  $identifier = 0 
)
protected

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

Referenced by createMatchingPair(), insertTerm(), and loadFromDb().

1608  {
1609  return new assAnswerMatchingTerm($term, $picture, $identifier);
1610  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

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

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

447  : int
448  {
449  if ($this->getId() <= 0) {
450  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
451  }
452 
453  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
454 
455  $sourceQuestionId = $this->id;
456  $sourceParentId = $this->getObjId();
457 
458  // duplicate the question in database
459  $clone = $this;
460  $clone->id = -1;
461 
462  $clone->setObjId($targetParentId);
463 
464  if ($targetQuestionTitle) {
465  $clone->setTitle($targetQuestionTitle);
466  }
467 
468  $clone->saveToDb();
469  // copy question page content
470  $clone->copyPageOfQuestion($sourceQuestionId);
471  // copy XHTML media objects
472  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
473  // duplicate the image
474  $clone->copyImages($sourceQuestionId, $sourceParentId);
475 
476  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
477 
478  return $clone->id;
479  }
+ 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 847 of file class.assMatchingQuestion.php.

847  : void
848  {
849  unset($this->definitions[$position]);
850  $this->definitions = array_values($this->definitions);
851  }

◆ deleteImagefile()

assMatchingQuestion::deleteImagefile ( string  $filename)

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

Parameters
string$filenameImage file filename
Returns
boolean Success

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

References Vendor\Package\$e, $filename, assQuestion\getImagePath(), and getThumbPrefix().

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

1026  : bool
1027  {
1028  $deletename = $filename;
1029  try {
1030  $result = unlink($this->getImagePath() . $deletename)
1031  && unlink($this->getImagePath() . $this->getThumbPrefix() . $deletename);
1032  } catch (Throwable $e) {
1033  $result = false;
1034  }
1035  return $result;
1036  }
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
$filename
Definition: buildRTE.php:78
+ 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 665 of file class.assMatchingQuestion.php.

References $index.

665  : void
666  {
667  if ($index < 0) {
668  return;
669  }
670  if (count($this->matchingpairs) < 1) {
671  return;
672  }
673  if ($index >= count($this->matchingpairs)) {
674  return;
675  }
676  unset($this->matchingpairs[$index]);
677  $this->matchingpairs = array_values($this->matchingpairs);
678  }
$index
Definition: metadata.php:145

◆ deleteTerm()

assMatchingQuestion::deleteTerm (   $position)

Deletes a term.

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

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

835  : void
836  {
837  unset($this->terms[$position]);
838  $this->terms = array_values($this->terms);
839  }

◆ duplicate()

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

Duplicates an assMatchingQuestion.

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

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

370  : int
371  {
372  if ($this->id <= 0) {
373  // The question has not been saved. It cannot be duplicated
374  return -1;
375  }
376  // duplicate the question in database
377  $this_id = $this->getId();
378  $thisObjId = $this->getObjId();
379 
380  $clone = $this;
381  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
383  $clone->id = -1;
384 
385  if ((int) $testObjId > 0) {
386  $clone->setObjId($testObjId);
387  }
388 
389  if ($title) {
390  $clone->setTitle($title);
391  }
392  if ($author) {
393  $clone->setAuthor($author);
394  }
395  if ($owner) {
396  $clone->setOwner((int) $owner);
397  }
398  if ($for_test) {
399  $clone->saveToDb($original_id);
400  } else {
401  $clone->saveToDb();
402  }
403 
404  // copy question page content
405  $clone->copyPageOfQuestion($this_id);
406  // copy XHTML media objects
407  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
408  // duplicate the image
409  $clone->duplicateImages($this_id, $thisObjId, $clone->getId(), $testObjId);
410 
411  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
412 
413  return $clone->id;
414  }
static _getOriginalId(int $question_id)
+ Here is the call graph for this function:

◆ duplicateImages()

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

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

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

481  : void
482  {
483  global $DIC;
484  $ilLog = $DIC['ilLog'];
485  $imagepath = $this->getImagePath();
486  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
487 
488  if ((int) $objectId > 0) {
489  $imagepath_original = str_replace("/$this->obj_id/", "/$objectId/", $imagepath_original);
490  }
491 
492  foreach ($this->terms as $term) {
493  if (strlen($term->getPicture())) {
494  $filename = $term->getPicture();
495  if (!file_exists($imagepath)) {
496  ilFileUtils::makeDirParents($imagepath);
497  }
498  if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
499  $ilLog->write("matching question image could not be duplicated: $imagepath_original$filename");
500  }
501  if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename)) {
502  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
503  $ilLog->write("matching question image thumbnail could not be duplicated: $imagepath_original" . $this->getThumbPrefix() . $filename);
504  }
505  }
506  }
507  }
508  foreach ($this->definitions as $definition) {
509  if (strlen($definition->getPicture())) {
510  $filename = $definition->getPicture();
511  if (!file_exists($imagepath)) {
512  ilFileUtils::makeDirParents($imagepath);
513  }
514  if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
515  $ilLog->write("matching question image could not be duplicated: $imagepath_original$filename");
516  }
517  if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename)) {
518  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
519  $ilLog->write("matching question image thumbnail could not be duplicated: $imagepath_original" . $this->getThumbPrefix() . $filename);
520  }
521  }
522  }
523  }
524  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
global $DIC
Definition: feed.php:28
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
$filename
Definition: buildRTE.php:78
ILIAS DI LoggingServices $ilLog
+ Here is the call graph for this function:

◆ fetchIndexedValuesFromValuePairs()

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

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

969  : array
970  {
971  $indexedValues = array();
972 
973  foreach ($valuePairs as $valuePair) {
974  if (!isset($indexedValues[$valuePair['value2']])) {
975  $indexedValues[$valuePair['value2']] = array();
976  }
977 
978  $indexedValues[$valuePair['value2']][] = $valuePair['value1'];
979  }
980 
981  return $indexedValues;
982  }

◆ fetchSubmittedMatchingsFromPost()

assMatchingQuestion::fetchSubmittedMatchingsFromPost ( )
private

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

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

Referenced by savePreviewData(), and saveWorkingData().

1070  : array
1071  {
1072  $request = $this->dic->testQuestionPool()->internal()->request();
1073  $post = $request->getParsedBody();
1074 
1075  $matchings = array();
1076  if (array_key_exists('matching', $post)) {
1077  $postData = $post['matching'][$this->getId()];
1078  foreach ($this->getDefinitions() as $definition) {
1079  if (isset($postData[$definition->getIdentifier()])) {
1080  foreach ($this->getTerms() as $term) {
1081  if (isset($postData[$definition->getIdentifier()][$term->getIdentifier()])) {
1082  if (!is_array($postData[$definition->getIdentifier()])) {
1083  $postData[$definition->getIdentifier()] = array();
1084  }
1085  $matchings[$definition->getIdentifier()][] = $term->getIdentifier();
1086  }
1087  }
1088  }
1089  }
1090  }
1091 
1092  return $matchings;
1093  }
getDefinitions()
Returns the definitions of the matching question.
getTerms()
Returns the terms of the matching question.
$post
Definition: ltitoken.php:49
+ 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 824 of file class.assMatchingQuestion.php.

824  : void
825  {
826  $this->definitions = array();
827  }

◆ flushMatchingPairs()

assMatchingQuestion::flushMatchingPairs ( )

Deletes all matching pairs.

See also
$matchingpairs

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

684  : void
685  {
686  $this->matchingpairs = array();
687  }

◆ flushTerms()

assMatchingQuestion::flushTerms ( )

Deletes all terms.

See also
$terms

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

815  : void
816  {
817  $this->terms = array();
818  }

◆ generateThumbForFile()

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

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

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

Referenced by rebuildThumbnails().

1338  : void
1339  {
1340  $filename = $path . $file;
1341  if (@file_exists($filename)) {
1342  $thumbpath = $path . $this->getThumbPrefix() . $file;
1343  $path_info = @pathinfo($filename);
1344  $ext = "";
1345  switch (strtoupper($path_info['extension'])) {
1346  case 'PNG':
1347  $ext = 'PNG';
1348  break;
1349  case 'GIF':
1350  $ext = 'GIF';
1351  break;
1352  default:
1353  $ext = 'JPEG';
1354  break;
1355  }
1356  ilShellUtil::convertImage($filename, $thumbpath, $ext, (string) $this->getThumbGeometry());
1357  }
1358  }
getThumbGeometry()
Get the thumbnail geometry.
$path
Definition: ltiservices.php:32
static convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")
convert image
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdditionalTableName()

assMatchingQuestion::getAdditionalTableName ( )

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

Referenced by saveAdditionalQuestionDataToDb().

1220  : string
1221  {
1222  return "qpl_qst_matching";
1223  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assMatchingQuestion::getAnswerTableName ( )

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

1225  : array
1226  {
1227  return array("qpl_a_matching", "qpl_a_mterm");
1228  }

◆ 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

Implements iQuestionCondition.

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

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

1582  {
1583  if ($index !== null) {
1584  return $this->getMatchingPair($index);
1585  } else {
1586  return $this->getMatchingPairs();
1587  }
1588  }
getMatchingPair($index=0)
Returns a matching pair with a given index.
$index
Definition: metadata.php:145
& 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 750 of file class.assMatchingQuestion.php.

750  : int
751  {
752  return count($this->definitions);
753  }

◆ getDefinitions()

assMatchingQuestion::getDefinitions ( )

Returns the definitions of the matching question.

Returns
array An array containing the definitions
See also
$terms

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

References $definitions.

Referenced by fetchSubmittedMatchingsFromPost(), and toJSON().

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

◆ getDefinitionWithIdentifier()

assMatchingQuestion::getDefinitionWithIdentifier (   $a_identifier)

Returns a definition with a given identifier.

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

627  {
628  foreach ($this->definitions as $definition) {
629  if ($definition->getIdentifier() == $a_identifier) {
630  return $definition;
631  }
632  }
633  return null;
634  }

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

References $filename.

992  : string
993  {
994  $extension = "";
995  if (preg_match("/.*\\.(\\w+)$/", $filename, $matches)) {
996  $extension = $matches[1];
997  }
998  return md5($filename) . "." . $extension;
999  }
$filename
Definition: buildRTE.php:78

◆ getExpressionTypes()

◆ getMatchingMode()

assMatchingQuestion::getMatchingMode ( )

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

References $matchingMode.

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

1450  : string
1451  {
1452  return $this->matchingMode;
1453  }
+ 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 644 of file class.assMatchingQuestion.php.

References $index.

Referenced by getAvailableAnswerOptions().

644  : ?object
645  {
646  if ($index < 0) {
647  return null;
648  }
649  if (count($this->matchingpairs) < 1) {
650  return null;
651  }
652  if ($index >= count($this->matchingpairs)) {
653  return null;
654  }
655  return $this->matchingpairs[$index];
656  }
$index
Definition: metadata.php:145
+ 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 706 of file class.assMatchingQuestion.php.

706  : int
707  {
708  return count($this->matchingpairs);
709  }

◆ getMatchingPairs()

& assMatchingQuestion::getMatchingPairs ( )

Returns the matchingpairs array.

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

References $matchingpairs.

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

1242  : array
1243  {
1244  return $this->matchingpairs;
1245  }
+ 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 907 of file class.assMatchingQuestion.php.

References assQuestion\$points, and getMaximumScoringMatchingPairs().

Referenced by getExpressionTypes(), and isComplete().

907  : float
908  {
909  $points = 0;
910 
911  foreach ($this->getMaximumScoringMatchingPairs() as $pair) {
912  $points += $pair->getPoints();
913  }
914 
915  return $points;
916  }
float $points
The maximum available points for the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMaximumScoringMatchingPairs()

assMatchingQuestion::getMaximumScoringMatchingPairs ( )

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

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

Referenced by getMaximumPoints().

918  : array
919  {
920  if ($this->getMatchingMode() == self::MATCHING_MODE_N_ON_N) {
921  return $this->getPositiveScoredMatchingPairs();
922  } elseif ($this->getMatchingMode() == self::MATCHING_MODE_1_ON_1) {
924  }
925 
926  return array();
927  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMostPositiveScoredUniqueTermMatchingPairs()

assMatchingQuestion::getMostPositiveScoredUniqueTermMatchingPairs ( )
private

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

Referenced by getMaximumScoringMatchingPairs().

944  : array
945  {
946  $matchingPairsByDefinition = array();
947 
948  foreach ($this->matchingpairs as $pair) {
949  if ($pair->getPoints() <= 0) {
950  continue;
951  }
952 
953  $defId = $pair->getDefinition()->getIdentifier();
954 
955  if (!isset($matchingPairsByDefinition[$defId])) {
956  $matchingPairsByDefinition[$defId] = $pair;
957  } elseif ($pair->getPoints() > $matchingPairsByDefinition[$defId]->getPoints()) {
958  $matchingPairsByDefinition[$defId] = $pair;
959  }
960  }
961 
962  return $matchingPairsByDefinition;
963  }
+ 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 1488 of file class.assMatchingQuestion.php.

References ilOperatorsExpressionMapping\getOperatorsByExpression().

1488  : array
1489  {
1491  }
+ Here is the call graph for this function:

◆ getPositiveScoredMatchingPairs()

assMatchingQuestion::getPositiveScoredMatchingPairs ( )
private

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

Referenced by getMaximumScoringMatchingPairs().

929  : array
930  {
931  $matchingPairs = array();
932 
933  foreach ($this->matchingpairs as $pair) {
934  if ($pair->getPoints() <= 0) {
935  continue;
936  }
937 
938  $matchingPairs[] = $pair;
939  }
940 
941  return $matchingPairs;
942  }
+ 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 1215 of file class.assMatchingQuestion.php.

Referenced by toJSON().

1215  : string
1216  {
1217  return "assMatchingQuestion";
1218  }
+ Here is the caller graph for this function:

◆ getRandomId()

assMatchingQuestion::getRandomId ( )

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

References ILIAS\LTI\ToolProvider\$key.

1188  : int
1189  {
1190  mt_srand((float) microtime() * 1000000);
1191  $random_number = mt_rand(1, 100000);
1192  $found = false;
1193  while ($found) {
1194  $found = false;
1195  foreach ($this->matchingpairs as $key => $pair) {
1196  if (($pair->getTerm()->getIdentifier() == $random_number) || ($pair->getDefinition()->getIdentifier() == $random_number)) {
1197  $found = true;
1198  $random_number++;
1199  }
1200  }
1201  }
1202  return $random_number;
1203  }
string $key
Consumer key/client ID value.
Definition: System.php:193

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

1234  : string
1235  {
1236  return parent::getRTETextWithMediaObjects();
1237  }

◆ getShuffleMode()

assMatchingQuestion::getShuffleMode ( )

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

References $shufflemode.

Referenced by saveAdditionalQuestionDataToDb().

120  : int
121  {
122  return $this->shufflemode;
123  }
+ Here is the caller graph for this function:

◆ getTermCount()

assMatchingQuestion::getTermCount ( )

Returns the number of terms.

Returns
integer The number of terms
See also
$terms

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

739  : int
740  {
741  return count($this->terms);
742  }

◆ getTerms()

assMatchingQuestion::getTerms ( )

Returns the terms of the matching question.

Returns
assAnswerMatchingTerm[] An array containing the terms
See also
$terms

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

References $terms.

Referenced by fetchSubmittedMatchingsFromPost(), and toJSON().

717  : array
718  {
719  return $this->terms;
720  }
+ Here is the caller graph for this function:

◆ getTermWithIdentifier()

assMatchingQuestion::getTermWithIdentifier (   $a_identifier)

Returns a term with a given identifier.

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

614  {
615  foreach ($this->terms as $term) {
616  if ($term->getIdentifier() == $a_identifier) {
617  return $term;
618  }
619  }
620  return null;
621  }

◆ getThumbGeometry()

assMatchingQuestion::getThumbGeometry ( )

Get the thumbnail geometry.

Returns
integer Geometry

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

References $thumb_geometry.

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

1291  : int
1292  {
1293  return $this->thumb_geometry;
1294  }
+ Here is the caller graph for this function:

◆ getThumbPrefix()

assMatchingQuestion::getThumbPrefix ( )

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

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

1333  : string
1334  {
1335  return "thumb.";
1336  }
+ Here is the caller graph for this function:

◆ getThumbSize()

assMatchingQuestion::getThumbSize ( )

Get the thumbnail geometry.

Returns
integer Geometry

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

References getThumbGeometry().

1301  : int
1302  {
1303  return $this->getThumbGeometry();
1304  }
getThumbGeometry()
Get the thumbnail geometry.
+ Here is the call graph for this function:

◆ insertDefinition()

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

Inserts a definition.

Parameters
object$definitionThe definition
See also
$definitions

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

References createMatchingDefinition().

797  : void
798  {
799  if (is_null($definition)) {
800  $definition = $this->createMatchingDefinition();
801  }
802  if ($position < count($this->definitions)) {
803  $part1 = array_slice($this->definitions, 0, $position);
804  $part2 = array_slice($this->definitions, $position);
805  $this->definitions = array_merge($part1, array($definition), $part2);
806  } else {
807  array_push($this->definitions, $definition);
808  }
809  }
createMatchingDefinition(string $term='', string $picture='', int $identifier=0)
+ Here is the call graph for this function:

◆ 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, and createMatchingPair().

580  : void
581  {
582  $pair = $this->createMatchingPair($term, $definition, $points);
583 
584  if ($position < count($this->matchingpairs)) {
585  $part1 = array_slice($this->matchingpairs, 0, $position);
586  $part2 = array_slice($this->matchingpairs, $position);
587  $this->matchingpairs = array_merge($part1, array($pair), $part2);
588  } else {
589  array_push($this->matchingpairs, $pair);
590  }
591  }
float $points
The maximum available points for the question.
createMatchingPair(assAnswerMatchingTerm $term=null, assAnswerMatchingDefinition $definition=null, float $points=0.0)
+ Here is the call graph for this function:

◆ insertTerm()

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

Inserts a term.

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

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

References createMatchingTerm().

777  : void
778  {
779  if (is_null($term)) {
780  $term = $this->createMatchingTerm();
781  }
782  if ($position < count($this->terms)) {
783  $part1 = array_slice($this->terms, 0, $position);
784  $part2 = array_slice($this->terms, $position);
785  $this->terms = array_merge($part1, array($term), $part2);
786  } else {
787  array_push($this->terms, $term);
788  }
789  }
createMatchingTerm(string $term='', string $picture='', int $identifier=0)
+ Here is the call graph for this function:

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

References getMaximumPoints().

135  : bool
136  {
137  if (strlen($this->title)
138  && $this->author
139  && $this->question
140  && count($this->matchingpairs)
141  && $this->getMaximumPoints() > 0
142  ) {
143  return true;
144  }
145  return false;
146  }
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 266 of file class.assMatchingQuestion.php.

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

266  : void
267  {
268  global $DIC;
269  $ilDB = $DIC['ilDB'];
270 
271  $query = "
272  SELECT qpl_questions.*,
273  {$this->getAdditionalTableName()}.*
274  FROM qpl_questions
275  LEFT JOIN {$this->getAdditionalTableName()}
276  ON {$this->getAdditionalTableName()}.question_fi = qpl_questions.question_id
277  WHERE qpl_questions.question_id = %s
278  ";
279 
280  $result = $ilDB->queryF(
281  $query,
282  array('integer'),
283  array($question_id)
284  );
285 
286  if ($result->numRows() == 1) {
287  $data = $ilDB->fetchAssoc($result);
288  $this->setId((int) $question_id);
289  $this->setObjId((int) $data["obj_fi"]);
290  $this->setTitle((string) $data["title"]);
291  $this->setComment((string) $data["description"]);
292  $this->setOriginalId((int) $data["original_id"]);
293  $this->setNrOfTries((int) $data['nr_of_tries']);
294  $this->setAuthor($data["author"]);
295  $this->setPoints((float) $data["points"]);
296  $this->setOwner((int) $data["owner"]);
297  include_once("./Services/RTE/classes/class.ilRTE.php");
298  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
299  $this->setThumbGeometry((int) $data["thumb_geometry"]);
300  $this->setShuffle($data["shuffle"] != '0');
301  $this->setShuffleMode((int) $data['shuffle']);
302  $this->setMatchingMode($data['matching_mode'] === null ? self::MATCHING_MODE_1_ON_1 : $data['matching_mode']);
303 
304  try {
308  }
309 
310  try {
311  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
312  } catch (ilTestQuestionPoolException $e) {
313  }
314  }
315 
316  $termids = array();
317  $result = $ilDB->queryF(
318  "SELECT * FROM qpl_a_mterm WHERE question_fi = %s ORDER BY term_id ASC",
319  array('integer'),
320  array($question_id)
321  );
322  $this->terms = [];
323  if ($result->numRows() > 0) {
324  while ($data = $ilDB->fetchAssoc($result)) {
325  $term = $this->createMatchingTerm($data['term'] ?? '', $data['picture'] ?? '', (int) $data['ident']);
326  $this->terms[] = $term;
327  $termids[$data['term_id']] = $term;
328  }
329  }
330 
331  $definitionids = array();
332  $result = $ilDB->queryF(
333  "SELECT * FROM qpl_a_mdef WHERE question_fi = %s ORDER BY def_id ASC",
334  array('integer'),
335  array($question_id)
336  );
337 
338  $this->definitions = array();
339  if ($result->numRows() > 0) {
340  while ($data = $ilDB->fetchAssoc($result)) {
341  $definition = $this->createMatchingDefinition($data['definition'] ?? '', $data['picture'] ?? '', (int) $data['ident']);
342  array_push($this->definitions, $definition);
343  $definitionids[$data['def_id']] = $definition;
344  }
345  }
346 
347  $this->matchingpairs = array();
348  $result = $ilDB->queryF(
349  "SELECT * FROM qpl_a_matching WHERE question_fi = %s ORDER BY answer_id",
350  array('integer'),
351  array($question_id)
352  );
353  if ($result->numRows() > 0) {
354  while ($data = $ilDB->fetchAssoc($result)) {
355  $pair = $this->createMatchingPair(
356  $termids[$data['term_fi']],
357  $definitionids[$data['definition_fi']],
358  (float) $data['points']
359  );
360  array_push($this->matchingpairs, $pair);
361  }
362  }
363  parent::loadFromDb((int) $question_id);
364  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setNrOfTries(int $a_nr_of_tries)
setOwner(int $owner=-1)
setComment(string $comment="")
setThumbGeometry(int $a_geometry)
Set the thumbnail geometry.
global $DIC
Definition: feed.php:28
$query
setPoints(float $points)
setObjId(int $obj_id=0)
createMatchingTerm(string $term='', string $picture='', int $identifier=0)
createMatchingPair(assAnswerMatchingTerm $term=null, assAnswerMatchingDefinition $definition=null, float $points=0.0)
setId(int $id=-1)
setOriginalId(?int $original_id)
setTitle(string $title="")
createMatchingDefinition(string $term='', string $picture='', int $identifier=0)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setAuthor(string $author="")
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
+ Here is the call graph for this function:

◆ rebuildThumbnails()

assMatchingQuestion::rebuildThumbnails ( )

Rebuild the thumbnail images with a new thumbnail size.

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

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

Referenced by saveAnswerSpecificDataToDb().

1319  : void
1320  {
1321  foreach ($this->terms as $term) {
1322  if (strlen($term->getPicture())) {
1323  $this->generateThumbForFile($this->getImagePath(), $term->getPicture());
1324  }
1325  }
1326  foreach ($this->definitions as $definition) {
1327  if (strlen($definition->getPicture())) {
1328  $this->generateThumbForFile($this->getImagePath(), $definition->getPicture());
1329  }
1330  }
1331  }
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 1010 of file class.assMatchingQuestion.php.

References $index, and deleteImagefile().

1010  : void
1011  {
1012  $definition = $this->definitions[$index] ?? null;
1013  if (is_object($definition)) {
1014  $this->deleteImagefile($definition->getPicture());
1015  $definition = $definition->withPicture('');
1016  }
1017  }
$index
Definition: metadata.php:145
deleteImagefile(string $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 1001 of file class.assMatchingQuestion.php.

References $index, and deleteImagefile().

1001  : void
1002  {
1003  $term = $this->terms[$index] ?? null;
1004  if (is_object($term)) {
1005  $this->deleteImagefile($term->getPicture());
1006  $term = $term->withPicture('');
1007  }
1008  }
$index
Definition: metadata.php:145
deleteImagefile(string $filename)
Deletes an imagefile from the system if the file is deleted manually.
+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assMatchingQuestion::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

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

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

Referenced by saveToDb().

239  {
240  global $DIC;
241  $ilDB = $DIC['ilDB'];
242 
243  // save additional data
244 
245  $ilDB->manipulateF(
246  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
247  array( "integer" ),
248  array( $this->getId() )
249  );
250 
251  $ilDB->insert($this->getAdditionalTableName(), array(
252  'question_fi' => array('integer', $this->getId()),
253  'shuffle' => array('text', $this->getShuffleMode()),
254  'matching_type' => array('text', $this->matching_type),
255  'thumb_geometry' => array('integer', $this->getThumbGeometry()),
256  'matching_mode' => array('text', $this->getMatchingMode())
257  ));
258  }
getThumbGeometry()
Get the thumbnail geometry.
global $DIC
Definition: feed.php:28
+ 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 168 of file class.assMatchingQuestion.php.

References $DIC, $ilDB, ILIAS\LTI\ToolProvider\$key, $matchingpairs, assQuestion\getId(), getMatchingPairs(), and rebuildThumbnails().

Referenced by saveToDb().

169  {
170  global $DIC;
171  $ilDB = $DIC['ilDB'];
172  // delete old terms
173  $ilDB->manipulateF(
174  "DELETE FROM qpl_a_mterm WHERE question_fi = %s",
175  array( 'integer' ),
176  array( $this->getId() )
177  );
178 
179  // delete old definitions
180  $ilDB->manipulateF(
181  "DELETE FROM qpl_a_mdef WHERE question_fi = %s",
182  array( 'integer' ),
183  array( $this->getId() )
184  );
185 
186  $termids = array();
187  // write terms
188  foreach ($this->terms as $key => $term) {
189  $next_id = $ilDB->nextId('qpl_a_mterm');
190  $ilDB->insert('qpl_a_mterm', array(
191  'term_id' => array('integer', $next_id),
192  'question_fi' => array('integer', $this->getId()),
193  'picture' => array('text', $term->getPicture()),
194  'term' => array('text', $term->getText()),
195  'ident' => array('integer', $term->getIdentifier())
196  ));
197  $termids[$term->getIdentifier()] = $next_id;
198  }
199 
200  $definitionids = array();
201  // write definitions
202  foreach ($this->definitions as $key => $definition) {
203  $next_id = $ilDB->nextId('qpl_a_mdef');
204  $ilDB->insert('qpl_a_mdef', array(
205  'def_id' => array('integer', $next_id),
206  'question_fi' => array('integer', $this->getId()),
207  'picture' => array('text', $definition->getPicture()),
208  'definition' => array('text', $definition->getText()),
209  'ident' => array('integer', $definition->getIdentifier())
210  ));
211  $definitionids[$definition->getIdentifier()] = $next_id;
212  }
213 
214  $ilDB->manipulateF(
215  "DELETE FROM qpl_a_matching WHERE question_fi = %s",
216  array( 'integer' ),
217  array( $this->getId() )
218  );
219  $matchingpairs = $this->getMatchingPairs();
220  foreach ($matchingpairs as $key => $pair) {
221  $next_id = $ilDB->nextId('qpl_a_matching');
222  $ilDB->manipulateF(
223  "INSERT INTO qpl_a_matching (answer_id, question_fi, points, term_fi, definition_fi) VALUES (%s, %s, %s, %s, %s)",
224  array( 'integer', 'integer', 'float', 'integer', 'integer' ),
225  array(
226  $next_id,
227  $this->getId(),
228  $pair->getPoints(),
229  $termids[$pair->getTerm()->getIdentifier()],
230  $definitionids[$pair->getDefinition()->getIdentifier()]
231  )
232  );
233  }
234 
235  $this->rebuildThumbnails();
236  }
rebuildThumbnails()
Rebuild the thumbnail images with a new thumbnail size.
global $DIC
Definition: feed.php:28
string $key
Consumer key/client ID value.
Definition: System.php:193
& 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 1179 of file class.assMatchingQuestion.php.

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

1179  : void
1180  {
1181  $submittedMatchings = $this->fetchSubmittedMatchingsFromPost();
1182 
1183  if ($this->checkSubmittedMatchings($submittedMatchings)) {
1184  $previewSession->setParticipantsSolution($submittedMatchings);
1185  }
1186  }
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 154 of file class.assMatchingQuestion.php.

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

154  : void
155  {
156  if ($original_id == "") {
157  $this->saveQuestionDataToDb();
158  } else {
160  }
161 
164 
165  parent::saveToDb();
166  }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb(int $original_id=-1)
+ 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 1130 of file class.assMatchingQuestion.php.

References $i, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), checkSubmittedMatchings(), fetchSubmittedMatchingsFromPost(), assQuestion\getId(), assQuestion\getProcessLocker(), ILIAS\Repository\lng(), assQuestion\logAction(), assQuestion\removeCurrentSolution(), and assQuestion\saveCurrentSolution().

1130  : bool
1131  {
1132  $submittedMatchings = $this->fetchSubmittedMatchingsFromPost();
1133  $submittedMatchingsValid = $this->checkSubmittedMatchings($submittedMatchings);
1134 
1135  $matchingsExist = false;
1136 
1137  if ($submittedMatchingsValid) {
1138  if (is_null($pass)) {
1139  include_once "./Modules/Test/classes/class.ilObjTest.php";
1140  $pass = ilObjTest::_getPass($active_id);
1141  }
1142 
1143  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$matchingsExist, $submittedMatchings, $active_id, $pass, $authorized) {
1144  $this->removeCurrentSolution($active_id, $pass, $authorized);
1145 
1146  foreach ($submittedMatchings as $definition => $terms) {
1147  foreach ($terms as $i => $term) {
1148  $this->saveCurrentSolution($active_id, $pass, $term, $definition, $authorized);
1149  $matchingsExist = true;
1150  }
1151  }
1152  });
1153 
1154  $saveWorkingDataResult = true;
1155  } else {
1156  $saveWorkingDataResult = false;
1157  }
1158 
1159  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1161  if ($matchingsExist) {
1162  assQuestion::logAction($this->lng->txtlng(
1163  "assessment",
1164  "log_user_entered_values",
1166  ), $active_id, $this->getId());
1167  } else {
1168  assQuestion::logAction($this->lng->txtlng(
1169  "assessment",
1170  "log_user_not_entered_values",
1172  ), $active_id, $this->getId());
1173  }
1174  }
1175 
1176  return $saveWorkingDataResult;
1177  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
static logAction(string $logtext, int $active_id, int $question_id)
checkSubmittedMatchings($submittedMatchings)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
$i
Definition: metadata.php:41
+ Here is the call graph for this function:

◆ setExportDetailsXLS()

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

{}

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

References $i, assQuestion\getImagePath(), getMatchingPairs(), assQuestion\getSolutionValues(), ILIAS\Repository\lng(), and ilAssExcelFormatHelper\setCell().

1250  : int
1251  {
1252  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
1253 
1254  $solutions = $this->getSolutionValues($active_id, $pass);
1255 
1256  $imagepath = $this->getImagePath();
1257  $i = 1;
1258  foreach ($solutions as $solution) {
1259  $matches_written = false;
1260  foreach ($this->getMatchingPairs() as $idx => $pair) {
1261  if (!$matches_written) {
1262  $worksheet->setCell($startrow + $i, 1, $this->lng->txt("matches"));
1263  }
1264  $matches_written = true;
1265  if ($pair->getDefinition()->getIdentifier() == $solution["value2"]) {
1266  if (strlen($pair->getDefinition()->getText())) {
1267  $worksheet->setCell($startrow + $i, 0, $pair->getDefinition()->getText());
1268  } else {
1269  $worksheet->setCell($startrow + $i, 0, $pair->getDefinition()->getPicture());
1270  }
1271  }
1272  if ($pair->getTerm()->getIdentifier() == $solution["value1"]) {
1273  if (strlen($pair->getTerm()->getText())) {
1274  $worksheet->setCell($startrow + $i, 2, $pair->getTerm()->getText());
1275  } else {
1276  $worksheet->setCell($startrow + $i, 2, $pair->getTerm()->getPicture());
1277  }
1278  }
1279  }
1280  $i++;
1281  }
1282 
1283  return $startrow + $i + 1;
1284  }
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
setCell($a_row, $a_col, $a_value, $datatype=null)
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
& getMatchingPairs()
Returns the matchingpairs array.
$i
Definition: metadata.php:41
+ 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 1046 of file class.assMatchingQuestion.php.

References ilShellUtil\convertImage(), deleteImagefile(), assQuestion\getImagePath(), getThumbGeometry(), getThumbPrefix(), ilFileUtils\makeDirParents(), and ilFileUtils\moveUploadedFile().

1047  {
1048  $result = true;
1049  if (strlen($image_tempfilename)) {
1050  $image_filename = str_replace(" ", "_", $image_filename);
1051  $imagepath = $this->getImagePath();
1052  if (!file_exists($imagepath)) {
1053  ilFileUtils::makeDirParents($imagepath);
1054  }
1055  $savename = $image_filename;
1056  if (!ilFileUtils::moveUploadedFile($image_tempfilename, $savename, $imagepath . $savename)) {
1057  $result = false;
1058  } else {
1059  // create thumbnail file
1060  $thumbpath = $imagepath . $this->getThumbPrefix() . $savename;
1061  ilShellUtil::convertImage($imagepath . $savename, $thumbpath, "JPEG", (string) $this->getThumbGeometry());
1062  }
1063  if ($result && (strcmp($image_filename, $previous_filename) != 0) && (strlen($previous_filename))) {
1064  $this->deleteImagefile($previous_filename);
1065  }
1066  }
1067  return $result;
1068  }
getThumbGeometry()
Get the thumbnail geometry.
static makeDirParents(string $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.
deleteImagefile(string $filename)
Deletes an imagefile from the system if the file is deleted manually.
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")
convert image
+ Here is the call graph for this function:

◆ setMatchingMode()

assMatchingQuestion::setMatchingMode (   $matchingMode)

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

References $matchingMode.

Referenced by loadFromDb().

1445  : void
1446  {
1447  $this->matchingMode = $matchingMode;
1448  }
+ Here is the caller graph for this function:

◆ setShuffle()

assMatchingQuestion::setShuffle (   $shuffle = true)

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

References assQuestion\$shuffle.

Referenced by loadFromDb().

1205  : void
1206  {
1207  $this->shuffle = (bool) $shuffle;
1208  }
bool $shuffle
Indicates whether the answers will be shuffled or not.
+ Here is the caller graph for this function:

◆ setShuffleMode()

assMatchingQuestion::setShuffleMode ( int  $shuffle)

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

References assQuestion\$shuffle.

Referenced by loadFromDb().

126  {
127  $this->shufflemode = $shuffle;
128  }
bool $shuffle
Indicates whether the answers will be shuffled or not.
+ 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 860 of file class.assMatchingQuestion.php.

References $index.

860  : void
861  {
862  $this->terms[$index] = $term;
863  }
$index
Definition: metadata.php:145

◆ setThumbGeometry()

assMatchingQuestion::setThumbGeometry ( int  $a_geometry)

Set the thumbnail geometry.

Parameters
integer$a_geometryGeometry

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

Referenced by loadFromDb().

1311  : void
1312  {
1313  $this->thumb_geometry = ($a_geometry < 1) ? 100 : $a_geometry;
1314  }
+ Here is the caller graph for this function:

◆ supportsJavascriptOutput()

assMatchingQuestion::supportsJavascriptOutput ( )

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

1435  : bool
1436  {
1437  return true;
1438  }

◆ supportsNonJsOutput()

assMatchingQuestion::supportsNonJsOutput ( )

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

1440  : bool
1441  {
1442  return false;
1443  }

◆ toJSON()

assMatchingQuestion::toJSON ( )

Returns a JSON representation of the question.

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

References $definitions, $mobs, $terms, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getDefinitions(), assQuestion\getId(), getMatchingMode(), getMatchingPairs(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffler(), getTerms(), assQuestion\getTitleForHTMLOutput(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and assQuestion\setShuffler().

1363  : string
1364  {
1365  $result = [];
1366 
1367  $result['id'] = $this->getId();
1368  $result['type'] = (string) $this->getQuestionType();
1369  $result['title'] = $this->getTitleForHTMLOutput();
1370  $result['question'] = $this->formatSAQuestion($this->getQuestion());
1371  $result['nr_of_tries'] = $this->getNrOfTries();
1372  $result['matching_mode'] = $this->getMatchingMode();
1373  $result['shuffle'] = true;
1374  $result['feedback'] = array(
1375  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1376  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1377  );
1378 
1379  $this->setShuffler($this->randomGroup->shuffleArray(new RandomSeed()));
1380 
1381  $terms = [];
1382  foreach ($this->getShuffler()->transform($this->getTerms()) as $term) {
1383  $terms[] = [
1384  "text" => $this->formatSAQuestion($term->getText()),
1385  "id" => $this->getId() . $term->getIdentifier()
1386  ];
1387  }
1388  $result['terms'] = $terms;
1389 
1390  $this->setShuffler($this->randomGroup->shuffleArray(new RandomSeed()));
1391 
1392  $definitions = [];
1393  foreach ($this->getShuffler()->transform($this->getDefinitions()) as $def) {
1394  $definitions[] = [
1395  "text" => $this->formatSAQuestion((string) $def->getText()),
1396  "id" => $this->getId() . $def->getIdentifier()
1397  ];
1398  }
1399  $result['definitions'] = $definitions;
1400 
1401  // #10353
1402  $matchings = [];
1403  foreach ($this->getMatchingPairs() as $pair) {
1404  // fau: fixLmMatchingPoints - ignore matching pairs with 0 or negative points
1405  if ($pair->getPoints() <= 0) {
1406  continue;
1407  }
1408  // fau.
1409 
1410  $pid = $pair->getDefinition()->getIdentifier();
1411  if ($this->getMatchingMode() == self::MATCHING_MODE_N_ON_N) {
1412  $pid .= '::' . $pair->getTerm()->getIdentifier();
1413  }
1414 
1415  if (!isset($matchings[$pid]) || $matchings[$pid]["points"] < $pair->getPoints()) {
1416  $matchings[$pid] = [
1417  "term_id" => $this->getId() . $pair->getTerm()->getIdentifier(),
1418  "def_id" => $this->getId() . $pair->getDefinition()->getIdentifier(),
1419  "points" => (int) $pair->getPoints()
1420  ];
1421  }
1422  }
1423 
1424  $result['matchingPairs'] = array_values($matchings);
1425 
1426  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1427  $result['mobs'] = $mobs;
1428 
1429  $this->lng->loadLanguageModule('assessment');
1430  $result['reset_button_label'] = $this->lng->txt("reset_terms");
1431 
1432  return json_encode($result);
1433  }
$mobs
Definition: imgupload.php:70
getQuestionType()
Returns the question type of the question.
getDefinitions()
Returns the definitions of the matching question.
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
getTerms()
Returns the terms of the matching question.
setShuffler(Transformation $shuffler)
& getMatchingPairs()
Returns the matchingpairs array.
+ Here is the call graph for this function:

◆ withMatchingPairs()

assMatchingQuestion::withMatchingPairs ( array  $pairs)
Parameters
assAnswerMatchingPair[]

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

692  : self
693  {
694  $clone = clone $this;
695  $clone->matchingpairs = $pairs;
696  return $clone;
697  }

Field Documentation

◆ $definitions

assMatchingQuestion::$definitions
protected

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

Referenced by getDefinitions(), getExpressionTypes(), and toJSON().

◆ $element_height

assMatchingQuestion::$element_height

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

◆ $matching_type

assMatchingQuestion::$matching_type

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

Referenced by __construct().

◆ $matchingMode

assMatchingQuestion::$matchingMode = self::MATCHING_MODE_1_ON_1
protected

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

Referenced by getMatchingMode(), and setMatchingMode().

◆ $matchingpairs

assMatchingQuestion::$matchingpairs

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

Referenced by getMatchingPairs(), and saveAnswerSpecificDataToDb().

◆ $randomGroup

RandomGroup assMatchingQuestion::$randomGroup
private

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

◆ $shufflemode

int assMatchingQuestion::$shufflemode = 0
private

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

Referenced by getShuffleMode().

◆ $terms

array assMatchingQuestion::$terms = []
protected

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

Referenced by getTerms(), and toJSON().

◆ $thumb_geometry

assMatchingQuestion::$thumb_geometry = 100

Definition at line 74 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: