ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
assMultipleChoice Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for assMultipleChoice:
+ Collaboration diagram for assMultipleChoice:

Public Member Functions

 setIsSingleline ($isSingleline)
 
 getIsSingleline ()
 
 __construct ( $title="", $comment="", $author="", $owner=-1, $question="", $output_type=OUTPUT_ORDER)
 assMultipleChoice constructor More...
 
 getSelectionLimit ()
 
 setSelectionLimit ($selectionLimit)
 
 isComplete ()
 Returns true, if a multiple choice question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a assMultipleChoice object to a database. More...
 
 getThumbPrefix ()
 
 loadFromDb ($question_id)
 Loads a assMultipleChoice object from a database. More...
 
 duplicate (bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
 Duplicates an assMultipleChoiceQuestion. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assMultipleChoice object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 getOutputType ()
 Gets the multiple choice output type which is either OUTPUT_ORDER (=0) or OUTPUT_RANDOM (=1). More...
 
 setOutputType ($output_type=OUTPUT_ORDER)
 Sets the output type of the assMultipleChoice object. More...
 
 addAnswer ( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="", $answer_id=-1)
 Adds a possible answer for a multiple choice question. More...
 
 getAnswerCount ()
 Returns the number of answers. More...
 
 getAnswer ($index=0)
 Returns an answer with a given index. More...
 
 deleteAnswer ($index=0)
 Deletes an answer with a given index. More...
 
 flushAnswers ()
 Deletes all answers. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 validateSolutionSubmit ()
 
 syncWithOriginal ()
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 setImageFile ($image_filename, $image_tempfilename="")
 Sets the image file and uploads the image to the object's image directory. More...
 
 copyImages ($question_id, $source_questionpool)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
getAnswers ()
 Returns a reference to the answers array. More...
 
 setExportDetailsXLS (ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
 {} More...
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 removeAnswerImage ($index)
 
 getMultilineAnswerSetting ()
 
 setMultilineAnswerSetting ($a_setting=0)
 
 setSpecificFeedbackSetting ($a_feedback_setting)
 Sets the feedback settings in effect for the question. More...
 
 getSpecificFeedbackSetting ()
 Gets the current feedback settings in effect for the question. More...
 
 getSpecificFeedbackAllCorrectOptionLabel ()
 
 isAnswered (int $active_id, int $pass)
 returns boolean wether the question is answered during test pass or not More...
 
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 
 isSingleline ()
 
- 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 ilObjQuestionScoringAdjustable
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
- Public Member Functions inherited from ilObjAnswerScoringAdjustable
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 

Data Fields

 $answers
 
 $output_type
 
 $isSingleline
 
 $lastChange
 
 $feedback_setting
 
- 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

 rebuildThumbnails ()
 Rebuild the thumbnail images with a new thumbnail size. More...
 
 generateThumbForFile ($path, $file)
 
 isForcedEmptySolution ($solutionSubmit)
 
 deleteImage ($image_filename)
 Deletes an image file. More...
 
 syncImages ()
 Sync images of a MC question on synchronisation with the original question. More...
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 getSolutionSubmit ()
 
 calculateReachedPointsForSolution ($found_values, $active_id=0)
 
 buildTestPresentationConfig ()
 
- 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

 $selectionLimit
 
- 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
 

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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class for multiple choice tests.

assMultipleChoice is a class for multiple choice 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 bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 36 of file class.assMultipleChoice.php.

Constructor & Destructor Documentation

◆ __construct()

assMultipleChoice::__construct (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $question = "",
  $output_type = OUTPUT_ORDER 
)

assMultipleChoice constructor

The constructor takes possible arguments an creates an instance of the assMultipleChoice 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 multiple choice question
int | string$output_typeThe output order of the multiple choice answers
See also
assQuestion:assQuestion()

Definition at line 96 of file class.assMultipleChoice.php.

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

103  {
105  $this->output_type = $output_type;
106  $this->answers = array();
107  $this->shuffle = 1;
108  $this->selectionLimit = null;
109  $this->feedback_setting = 0;
110  }
string $question
The question text.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswer()

assMultipleChoice::addAnswer (   $answertext = "",
  $points = 0.0,
  $points_unchecked = 0.0,
  $order = 0,
  $answerimage = "",
  $answer_id = -1 
)

Adds a possible answer for a multiple choice question.

A ASS_AnswerBinaryStateImage object will be created and assigned to the array $this->answers.

Parameters
string$answertextThe answer text
double$pointsThe points for selecting the answer (even negative points can be used)
float$points_uncheckedThe points for not selecting the answer (even positive points can be used)
integer$orderA possible display order of the answer
string$answerimage
int$answer_idThe Answer id used in the database
See also
$answers
ASS_AnswerBinaryStateImage

Definition at line 444 of file class.assMultipleChoice.php.

References $i, assQuestion\$points, and assQuestion\getHtmlQuestionContentPurifier().

451  : void {
452  $answertext = $this->getHtmlQuestionContentPurifier()->purify($answertext);
453  if (array_key_exists($order, $this->answers)) {
454  // insert answer
455  $answer = new ASS_AnswerMultipleResponseImage($answertext, $points, $order, -1, 0);
456  $answer->setPointsUnchecked($points_unchecked);
457  $answer->setImage($answerimage);
458  $newchoices = array();
459  for ($i = 0; $i < $order; $i++) {
460  $newchoices[] = $this->answers[$i];
461  }
462  $newchoices[] = $answer;
463  for ($i = $order, $iMax = count($this->answers); $i < $iMax; $i++) {
464  $changed = $this->answers[$i];
465  $changed->setOrder($i + 1);
466  $newchoices[] = $changed;
467  }
468  $this->answers = $newchoices;
469  } else {
470  $answer = new ASS_AnswerMultipleResponseImage($answertext, $points, count($this->answers), (int) $answer_id, 0);
471  $answer->setPointsUnchecked($points_unchecked);
472  $answer->setImage($answerimage);
473  $this->answers[] = $answer;
474  }
475  }
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.
$i
Definition: metadata.php:41
+ Here is the call graph for this function:

◆ buildTestPresentationConfig()

assMultipleChoice::buildTestPresentationConfig ( )
protected

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

References $config, and ILIAS\Repository\lng().

1479  {
1480  $config = parent::buildTestPresentationConfig();
1481  $config->setUseUnchangedAnswerLabel($this->lng->txt('tst_mc_label_none_above'));
1482  return $config;
1483  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
+ Here is the call graph for this function:

◆ calculateReachedPoints()

assMultipleChoice::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.

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

Definition at line 582 of file class.assMultipleChoice.php.

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

Referenced by getExpressionTypes().

583  {
584  if ($returndetails) {
585  throw new ilTestException('return details not implemented for ' . __METHOD__);
586  }
587 
588  global $DIC;
589  $ilDB = $DIC['ilDB'];
590 
591  $found_values = array();
592  if (is_null($pass)) {
593  $pass = $this->getSolutionMaxPass($active_id);
594  }
595  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
596  while ($data = $ilDB->fetchAssoc($result)) {
597  if (strcmp($data["value1"], "") != 0) {
598  array_push($found_values, $data["value1"]);
599  }
600  }
601 
602  $points = $this->calculateReachedPointsForSolution($found_values, $active_id);
603 
604  return $points;
605  }
calculateReachedPointsForSolution($found_values, $active_id=0)
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()

assMultipleChoice::calculateReachedPointsForSolution (   $found_values,
  $active_id = 0 
)
protected
Parameters
$found_values
$active_id
Returns
float

Definition at line 1372 of file class.assMultipleChoice.php.

References ILIAS\LTI\ToolProvider\$key, and assQuestion\$points.

Referenced by calculateReachedPoints().

1372  : float
1373  {
1374  if ($found_values == null) {
1375  $found_values = [];
1376  }
1377  $points = 0;
1378  foreach ($this->answers as $key => $answer) {
1379  if (in_array($key, $found_values)) {
1380  $points += $answer->getPoints();
1381  } else {
1382  $points += $answer->getPointsUnchecked();
1383  }
1384  }
1385  if ($active_id) {
1386  if (count($found_values) == 0) {
1387  $points = 0;
1388  }
1389  }
1390  return $points;
1391  }
float $points
The maximum available points for the question.
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the caller graph for this function:

◆ copyImages()

assMultipleChoice::copyImages (   $question_id,
  $source_questionpool 
)

Definition at line 1004 of file class.assMultipleChoice.php.

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

1004  : void
1005  {
1006  global $DIC;
1007  $ilLog = $DIC['ilLog'];
1008  $imagepath = $this->getImagePath();
1009  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
1010  $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
1011  foreach ($this->answers as $answer) {
1012  $filename = $answer->getImage();
1013  if (strlen($filename)) {
1014  if (!file_exists($imagepath)) {
1015  ilFileUtils::makeDirParents($imagepath);
1016  }
1017  if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
1018  $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
1019  $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
1020  }
1021  if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename)) {
1022  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
1023  $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
1024  $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
1025  }
1026  }
1027  }
1028  }
1029  }
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()

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

Copies an assMultipleChoice object.

Definition at line 345 of file class.assMultipleChoice.php.

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

345  : int
346  {
347  if ($this->getId() <= 0) {
348  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
349  }
350  // duplicate the question in database
351  $clone = $this;
352  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
354  $clone->id = -1;
355  $source_questionpool_id = $this->getObjId();
356  $clone->setObjId($target_questionpool_id);
357  if ($title) {
358  $clone->setTitle($title);
359  }
360  $clone->saveToDb();
361  // copy question page content
362  $clone->copyPageOfQuestion($original_id);
363  // copy XHTML media objects
364  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
365  // duplicate the image
366  $clone->copyImages($original_id, $source_questionpool_id);
367 
368  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
369 
370  return $clone->id;
371  }
static _getOriginalId(int $question_id)
+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

Definition at line 373 of file class.assMultipleChoice.php.

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

373  : int
374  {
375  if ($this->getId() <= 0) {
376  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
377  }
378 
379  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
380 
381  $sourceQuestionId = $this->id;
382  $sourceParentId = $this->getObjId();
383 
384  // duplicate the question in database
385  $clone = $this;
386  $clone->id = -1;
387 
388  $clone->setObjId($targetParentId);
389 
390  if ($targetQuestionTitle) {
391  $clone->setTitle($targetQuestionTitle);
392  }
393 
394  $clone->saveToDb();
395  // copy question page content
396  $clone->copyPageOfQuestion($sourceQuestionId);
397  // copy XHTML media objects
398  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
399  // duplicate the image
400  $clone->copyImages($sourceQuestionId, $sourceParentId);
401 
402  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
403 
404  return $clone->id;
405  }
+ Here is the call graph for this function:

◆ deleteAnswer()

assMultipleChoice::deleteAnswer (   $index = 0)

Deletes an answer with a given index.

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

Parameters
integer$indexA nonnegative index of the n-th answer
See also
$answers

Definition at line 518 of file class.assMultipleChoice.php.

References $i, $index, and deleteImage().

518  : void
519  {
520  if ($index < 0) {
521  return;
522  }
523  if (count($this->answers) < 1) {
524  return;
525  }
526  if ($index >= count($this->answers)) {
527  return;
528  }
529  $answer = $this->answers[$index];
530  if (strlen($answer->getImage())) {
531  $this->deleteImage($answer->getImage());
532  }
533  unset($this->answers[$index]);
534  $this->answers = array_values($this->answers);
535  for ($i = 0, $iMax = count($this->answers); $i < $iMax; $i++) {
536  if ($this->answers[$i]->getOrder() > $index) {
537  $this->answers[$i]->setOrder($i);
538  }
539  }
540  }
$index
Definition: metadata.php:145
deleteImage($image_filename)
Deletes an image file.
$i
Definition: metadata.php:41
+ Here is the call graph for this function:

◆ deleteImage()

assMultipleChoice::deleteImage (   $image_filename)
protected

Deletes an image file.

Parameters
string$image_filenameName of the image file to delete

Definition at line 945 of file class.assMultipleChoice.php.

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

Referenced by deleteAnswer(), and removeAnswerImage().

945  : void
946  {
947  $imagepath = $this->getImagePath();
948  @unlink($imagepath . $image_filename);
949  $thumbpath = $imagepath . $this->getThumbPrefix() . $image_filename;
950  @unlink($thumbpath);
951  }
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:

◆ duplicate()

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

Duplicates an assMultipleChoiceQuestion.

Definition at line 294 of file class.assMultipleChoice.php.

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

294  : int
295  {
296  if ($this->id <= 0) {
297  // The question has not been saved. It cannot be duplicated
298  return -1;
299  }
300  // duplicate the question in database
301  $this_id = $this->getId();
302  $thisObjId = $this->getObjId();
303 
304  $clone = $this;
305  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
307  $clone->id = -1;
308 
309  if ((int) $testObjId > 0) {
310  $clone->setObjId($testObjId);
311  }
312 
313  if ($title) {
314  $clone->setTitle($title);
315  }
316 
317  if ($author) {
318  $clone->setAuthor($author);
319  }
320  if ($owner) {
321  $clone->setOwner($owner);
322  }
323 
324  if ($for_test) {
325  $clone->saveToDb($original_id);
326  } else {
327  $clone->saveToDb();
328  }
329 
330  // copy question page content
331  $clone->copyPageOfQuestion($this_id);
332  // copy XHTML media objects
333  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
334  // duplicate the images
335  $clone->duplicateImages($this_id, $thisObjId);
336 
337  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
338 
339  return $clone->id;
340  }
static _getOriginalId(int $question_id)
+ Here is the call graph for this function:

◆ flushAnswers()

assMultipleChoice::flushAnswers ( )

Deletes all answers.

See also
$answers

Definition at line 547 of file class.assMultipleChoice.php.

547  : void
548  {
549  $this->answers = array();
550  }

◆ generateThumbForFile()

assMultipleChoice::generateThumbForFile (   $path,
  $file 
)
protected
Parameters
$pathstring
$filestring

Definition at line 188 of file class.assMultipleChoice.php.

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

Referenced by rebuildThumbnails(), and setImageFile().

188  : void
189  {
190  $filename = $path . $file;
191  if (@file_exists($filename)) {
192  $thumbpath = $path . $this->getThumbPrefix() . $file;
193  $path_info = @pathinfo($filename);
194  $ext = "";
195  switch (strtoupper($path_info['extension'])) {
196  case 'PNG':
197  $ext = 'PNG';
198  break;
199  case 'GIF':
200  $ext = 'GIF';
201  break;
202  default:
203  $ext = 'JPEG';
204  break;
205  }
206  ilShellUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbSize());
207  }
208  }
$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()

assMultipleChoice::getAdditionalTableName ( )

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

Returns
string The additional table name

Definition at line 890 of file class.assMultipleChoice.php.

Referenced by isForcedEmptySolution(), and loadFromDb().

890  : string
891  {
892  return "qpl_qst_mc";
893  }
+ Here is the caller graph for this function:

◆ getAnswer()

assMultipleChoice::getAnswer (   $index = 0)

Returns an answer with a given index.

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

Parameters
integer$indexA nonnegative index of the n-th answer
Returns
object ASS_AnswerBinaryStateImage-Object containing the answer
See also
$answers

Definition at line 496 of file class.assMultipleChoice.php.

References $index.

Referenced by getAvailableAnswerOptions().

496  : ?object
497  {
498  if ($index < 0) {
499  return null;
500  }
501  if (count($this->answers) < 1) {
502  return null;
503  }
504  if ($index >= count($this->answers)) {
505  return null;
506  }
507 
508  return $this->answers[$index];
509  }
$index
Definition: metadata.php:145
+ Here is the caller graph for this function:

◆ getAnswerCount()

assMultipleChoice::getAnswerCount ( )

Returns the number of answers.

Returns
integer The number of answers of the multiple choice question
See also
$answers

Definition at line 483 of file class.assMultipleChoice.php.

Referenced by validateSolutionSubmit().

483  : int
484  {
485  return count($this->answers);
486  }
+ Here is the caller graph for this function:

◆ getAnswers()

& assMultipleChoice::getAnswers ( )

Returns a reference to the answers array.

Definition at line 1086 of file class.assMultipleChoice.php.

References $answers.

Referenced by getAvailableAnswerOptions(), getSolutionSubmit(), lmMigrateQuestionTypeSpecificContent(), rebuildThumbnails(), setExportDetailsXLS(), and toJSON().

1086  : array
1087  {
1088  return $this->answers;
1089  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assMultipleChoice::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name

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

900  : string
901  {
902  return "qpl_a_mc";
903  }

◆ getAvailableAnswerOptions()

assMultipleChoice::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 1469 of file class.assMultipleChoice.php.

References $index, getAnswer(), and getAnswers().

1470  {
1471  if ($index !== null) {
1472  return $this->getAnswer($index);
1473  } else {
1474  return $this->getAnswers();
1475  }
1476  }
$index
Definition: metadata.php:145
getAnswer($index=0)
Returns an answer with a given index.
& getAnswers()
Returns a reference to the answers array.
+ Here is the call graph for this function:

◆ getExpressionTypes()

◆ getIsSingleline()

assMultipleChoice::getIsSingleline ( )
Returns
mixed

Definition at line 77 of file class.assMultipleChoice.php.

References $isSingleline.

78  {
79  return $this->isSingleline;
80  }

◆ getMaximumPoints()

assMultipleChoice::getMaximumPoints ( )

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

See also
$points

Definition at line 557 of file class.assMultipleChoice.php.

References ILIAS\LTI\ToolProvider\$key, and assQuestion\$points.

Referenced by getExpressionTypes(), and isComplete().

557  : float
558  {
559  $points = 0;
560  $allpoints = 0;
561  foreach ($this->answers as $key => $value) {
562  if ($value->getPoints() > $value->getPointsUnchecked()) {
563  $allpoints += $value->getPoints();
564  } else {
565  $allpoints += $value->getPointsUnchecked();
566  }
567  }
568  return $allpoints;
569  }
float $points
The maximum available points for the question.
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the caller graph for this function:

◆ getMultilineAnswerSetting()

assMultipleChoice::getMultilineAnswerSetting ( )

Definition at line 1190 of file class.assMultipleChoice.php.

References $DIC, and $ilUser.

1190  : int
1191  {
1192  global $DIC;
1193  $ilUser = $DIC['ilUser'];
1194 
1195  $multilineAnswerSetting = $ilUser->getPref("tst_multiline_answers");
1196  if ($multilineAnswerSetting != 1) {
1197  $multilineAnswerSetting = 0;
1198  }
1199  return $multilineAnswerSetting;
1200  }
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34

◆ getOperators()

assMultipleChoice::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
string$expression

Implements iQuestionCondition.

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

References ilOperatorsExpressionMapping\getOperatorsByExpression().

1401  : array
1402  {
1404  }
+ Here is the call graph for this function:

◆ getOutputType()

assMultipleChoice::getOutputType ( )

Gets the multiple choice output type which is either OUTPUT_ORDER (=0) or OUTPUT_RANDOM (=1).

Returns
integer The output type of the assMultipleChoice object
See also
$output_type

Definition at line 413 of file class.assMultipleChoice.php.

References $output_type.

413  : int
414  {
415  return $this->output_type;
416  }

◆ getQuestionType()

assMultipleChoice::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

Definition at line 880 of file class.assMultipleChoice.php.

Referenced by toJSON().

880  : string
881  {
882  return "assMultipleChoice";
883  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assMultipleChoice::getRTETextWithMediaObjects ( )

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

Definition at line 1072 of file class.assMultipleChoice.php.

References $index, and assQuestion\getId().

1072  : string
1073  {
1074  $text = parent::getRTETextWithMediaObjects();
1075  foreach ($this->answers as $index => $answer) {
1076  $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->getId(), 0, $index);
1077  $answer_obj = $this->answers[$index];
1078  $text .= $answer_obj->getAnswertext();
1079  }
1080  return $text;
1081  }
$index
Definition: metadata.php:145
+ Here is the call graph for this function:

◆ getSelectionLimit()

assMultipleChoice::getSelectionLimit ( )
Returns
int

Definition at line 115 of file class.assMultipleChoice.php.

References $selectionLimit.

Referenced by isForcedEmptySolution(), toJSON(), and validateSolutionSubmit().

115  : ?int
116  {
117  return $this->selectionLimit;
118  }
+ Here is the caller graph for this function:

◆ getSolutionSubmit()

assMultipleChoice::getSolutionSubmit ( )
protected

Definition at line 1351 of file class.assMultipleChoice.php.

References Vendor\Package\$a, $index, $post, and getAnswers().

Referenced by isForcedEmptySolution(), and validateSolutionSubmit().

1351  : array
1352  {
1353  $solutionSubmit = [];
1354  $post = $this->dic->http()->wrapper()->post();
1355 
1356  foreach ($this->getAnswers() as $index => $a) {
1357  if ($post->has("multiple_choice_result_$index")) {
1358  $value = $post->retrieve("multiple_choice_result_$index", $this->dic->refinery()->kindlyTo()->string());
1359  if (is_numeric($value)) {
1360  $solutionSubmit[] = $value;
1361  }
1362  }
1363  }
1364  return $solutionSubmit;
1365  }
$index
Definition: metadata.php:145
& getAnswers()
Returns a reference to the answers array.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$post
Definition: ltitoken.php:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSpecificFeedbackAllCorrectOptionLabel()

assMultipleChoice::getSpecificFeedbackAllCorrectOptionLabel ( )

Implements ilAssSpecificFeedbackOptionLabelProvider.

Definition at line 1241 of file class.assMultipleChoice.php.

1241  : string
1242  {
1243  return 'feedback_correct_sc_mc';
1244  }

◆ getSpecificFeedbackSetting()

assMultipleChoice::getSpecificFeedbackSetting ( )

Gets the current feedback settings in effect for the question.

Values are: 1 - Feedback is shown for all answer options. 2 - Feedback is shown for all checked/selected options. 3 - Feedback is shown for all correct options.

Returns
integer

Definition at line 1232 of file class.assMultipleChoice.php.

References $feedback_setting.

Referenced by isForcedEmptySolution().

1232  : int
1233  {
1234  if ($this->feedback_setting) {
1235  return $this->feedback_setting;
1236  } else {
1237  return 1;
1238  }
1239  }
+ Here is the caller graph for this function:

◆ getThumbPrefix()

assMultipleChoice::getThumbPrefix ( )
Returns
string

Definition at line 179 of file class.assMultipleChoice.php.

Referenced by copyImages(), deleteImage(), generateThumbForFile(), and syncImages().

179  : string
180  {
181  return "thumb.";
182  }
+ Here is the caller graph for this function:

◆ isAnswered()

assMultipleChoice::isAnswered ( int  $active_id,
int  $pass 
)

returns boolean wether the question is answered during test pass or not

(overwrites method in class assQuestion)

Parameters
integer$active_id
integer$pass
Returns
boolean $answered

Definition at line 1257 of file class.assMultipleChoice.php.

References $DIC, $ilDB, $query, $res, assQuestion\getId(), assQuestion\getNumExistingSolutionRecords(), and assQuestion\isObligationPossible().

1257  : bool
1258  {
1259  $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1260 
1261  return $numExistingSolutionRecords > 0;
1262  }
static getNumExistingSolutionRecords(int $activeId, int $pass, int $questionId)
+ Here is the call graph for this function:

◆ isComplete()

assMultipleChoice::isComplete ( )

Returns true, if a multiple choice question is complete for use.

Returns
boolean True, if the multiple choice question is complete for use, otherwise false public

Definition at line 134 of file class.assMultipleChoice.php.

References getMaximumPoints().

134  : bool
135  {
136  if (strlen($this->title) and ($this->author) and ($this->question) and (count($this->answers)) and ($this->getMaximumPoints() > 0)) {
137  return true;
138  } else {
139  return false;
140  }
141  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ isForcedEmptySolution()

◆ isSingleline()

assMultipleChoice::isSingleline ( )

Definition at line 1485 of file class.assMultipleChoice.php.

References $isSingleline.

Referenced by isForcedEmptySolution(), loadFromDb(), rebuildThumbnails(), setImageFile(), and setIsSingleline().

1485  : bool
1486  {
1487  return (bool) $this->isSingleline;
1488  }
+ Here is the caller graph for this function:

◆ lmMigrateQuestionTypeSpecificContent()

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

Definition at line 1124 of file class.assMultipleChoice.php.

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

1124  : void
1125  {
1126  foreach ($this->getAnswers() as $answer) {
1127  /* @var ASS_AnswerBinaryStateImage $answer */
1128  $answer->setAnswertext($migrator->migrateToLmContent($answer->getAnswertext()));
1129  }
1130  }
& getAnswers()
Returns a reference to the answers array.
+ Here is the call graph for this function:

◆ loadFromDb()

assMultipleChoice::loadFromDb (   $question_id)

Loads a assMultipleChoice object from a database.

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

Definition at line 215 of file class.assMultipleChoice.php.

References $data, $DIC, Vendor\Package\$e, $ilDB, assQuestion\$shuffle, ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), ilAssQuestionLifecycle\getDraftInstance(), assQuestion\getImagePath(), ilAssQuestionLifecycle\getInstance(), assQuestion\getMinimumThumbSize(), isSingleline(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setId(), assQuestion\setLifecycle(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setSelectionLimit(), assQuestion\setShuffle(), assQuestion\setThumbSize(), and assQuestion\setTitle().

215  : void
216  {
217  global $DIC;
218  $ilDB = $DIC['ilDB'];
219  $hasimages = 0;
220 
221  $result = $ilDB->queryF(
222  "SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s",
223  array("integer"),
224  array($question_id)
225  );
226  if ($result->numRows() == 1) {
227  $data = $ilDB->fetchAssoc($result);
228  $this->setId($question_id);
229  $this->setObjId($data["obj_fi"]);
230  $this->setTitle($data["title"] ?? '');
231  $this->setNrOfTries($data['nr_of_tries']);
232  $this->setComment($data["description"] ?? '');
233  $this->setOriginalId($data["original_id"]);
234  $this->setAuthor($data["author"]);
235  $this->setPoints($data["points"]);
236  $this->setOwner($data["owner"]);
237  include_once("./Services/RTE/classes/class.ilRTE.php");
238  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"] ?? '', 1));
239  $shuffle = (is_null($data['shuffle'])) ? true : $data['shuffle'];
240  $this->setShuffle((bool) $shuffle);
241  if ($data['thumb_size'] !== null && $data['thumb_size'] >= $this->getMinimumThumbSize()) {
242  $this->setThumbSize($data['thumb_size']);
243  }
244  $this->isSingleline = $data['allow_images'] === null || $data['allow_images'] === '0';
245  $this->lastChange = $data['tstamp'];
246  $this->setSelectionLimit((int) $data['selection_limit'] > 0 ? (int) $data['selection_limit'] : null);
247  $this->feedback_setting = $data['feedback_setting'];
248 
249  try {
253  }
254 
255  try {
256  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
257  } catch (ilTestQuestionPoolException $e) {
258  }
259  }
260 
261  $result = $ilDB->queryF(
262  "SELECT * FROM qpl_a_mc WHERE question_fi = %s ORDER BY aorder ASC",
263  array('integer'),
264  array($question_id)
265  );
266  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
267  if ($result->numRows() > 0) {
268  while ($data = $ilDB->fetchAssoc($result)) {
269  $imagefilename = $this->getImagePath() . $data["imagefile"];
270  if (!@file_exists($imagefilename)) {
271  $data["imagefile"] = "";
272  }
273  include_once("./Services/RTE/classes/class.ilRTE.php");
274  $data["answertext"] = ilRTE::_replaceMediaObjectImageSrc($data["answertext"] ?? '', 1);
275 
276  $answer = new ASS_AnswerMultipleResponseImage(
277  $data["answertext"],
278  $data["points"],
279  $data["aorder"],
280  $data["answer_id"]
281  );
282  $answer->setPointsUnchecked($data["points_unchecked"]);
283  $answer->setImage($data["imagefile"]);
284  array_push($this->answers, $answer);
285  }
286  }
287 
288  parent::loadFromDb($question_id);
289  }
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)
bool $shuffle
Indicates whether the answers will be shuffled or not.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSelectionLimit($selectionLimit)
setThumbSize(int $a_size)
setComment(string $comment="")
global $DIC
Definition: feed.php:28
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
setPoints(float $points)
setObjId(int $obj_id=0)
setId(int $id=-1)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setOriginalId(?int $original_id)
setTitle(string $title="")
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setAuthor(string $author="")
setShuffle(?bool $shuffle=true)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
+ Here is the call graph for this function:

◆ rebuildThumbnails()

assMultipleChoice::rebuildThumbnails ( )
protected

Rebuild the thumbnail images with a new thumbnail size.

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

References generateThumbForFile(), getAnswers(), assQuestion\getImagePath(), assQuestion\getThumbSize(), and isSingleline().

Referenced by isForcedEmptySolution().

165  : void
166  {
167  if ($this->isSingleline && ($this->getThumbSize())) {
168  foreach ($this->getAnswers() as $answer) {
169  if (strlen($answer->getImage())) {
170  $this->generateThumbForFile($this->getImagePath(), $answer->getImage());
171  }
172  }
173  }
174  }
generateThumbForFile($path, $file)
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
& getAnswers()
Returns a reference to the answers array.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAnswerImage()

assMultipleChoice::removeAnswerImage (   $index)

Definition at line 1181 of file class.assMultipleChoice.php.

References $index, and deleteImage().

1181  : void
1182  {
1183  $answer = $this->answers[$index];
1184  if (is_object($answer)) {
1185  $this->deleteImage($answer->getImage());
1186  $answer->setImage('');
1187  }
1188  }
$index
Definition: metadata.php:145
deleteImage($image_filename)
Deletes an image file.
+ Here is the call graph for this function:

◆ saveToDb()

assMultipleChoice::saveToDb (   $original_id = "")

Saves a assMultipleChoice object to a database.

Parameters
string$original_id

Definition at line 148 of file class.assMultipleChoice.php.

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

148  : void
149  {
150  if ($original_id == "") {
151  $this->saveQuestionDataToDb();
152  } else {
154  }
157 
158  $this->ensureNoInvalidObligation($this->getId());
159  parent::saveToDb($original_id);
160  }
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:

◆ setExportDetailsXLS()

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

{}

Definition at line 1094 of file class.assMultipleChoice.php.

References $i, assQuestion\$id, getAnswers(), ilExcel\getColumnCoord(), assQuestion\getSolutionValues(), ilExcel\setBold(), and ilAssExcelFormatHelper\setCell().

1094  : int
1095  {
1096  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
1097 
1098  $solution = $this->getSolutionValues($active_id, $pass);
1099 
1100  $i = 1;
1101  foreach ($this->getAnswers() as $id => $answer) {
1102  $worksheet->setCell($startrow + $i, 0, $answer->getAnswertext());
1103  $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
1104  $checked = false;
1105  foreach ($solution as $solutionvalue) {
1106  if ($id == $solutionvalue["value1"]) {
1107  $checked = true;
1108  }
1109  }
1110  if ($checked) {
1111  $worksheet->setCell($startrow + $i, 2, 1);
1112  } else {
1113  $worksheet->setCell($startrow + $i, 2, 0);
1114  }
1115  $i++;
1116  }
1117 
1118  return $startrow + $i + 1;
1119  }
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
getColumnCoord(int $a_col)
Get column "name" from number.
setCell($a_row, $a_col, $a_value, $datatype=null)
setBold(string $a_coords)
Set cell(s) to bold.
& getAnswers()
Returns a reference to the answers array.
$i
Definition: metadata.php:41
+ Here is the call graph for this function:

◆ setImageFile()

assMultipleChoice::setImageFile (   $image_filename,
  $image_tempfilename = "" 
)

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

Definition at line 912 of file class.assMultipleChoice.php.

References generateThumbForFile(), assQuestion\getImagePath(), ilObjMediaObject\getMimeType(), assQuestion\getThumbSize(), isSingleline(), ilFileUtils\makeDirParents(), and ilFileUtils\moveUploadedFile().

912  : int
913  {
914  $result = 0;
915  if (!empty($image_tempfilename)) {
916  $image_filename = str_replace(" ", "_", $image_filename);
917  $imagepath = $this->getImagePath();
918  if (!file_exists($imagepath)) {
919  ilFileUtils::makeDirParents($imagepath);
920  }
921  if (!ilFileUtils::moveUploadedFile($image_tempfilename, $image_filename, $imagepath . $image_filename)) {
922  $result = 2;
923  } else {
924  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
925  $mimetype = ilObjMediaObject::getMimeType($imagepath . $image_filename);
926  if (!preg_match("/^image/", $mimetype)) {
927  unlink($imagepath . $image_filename);
928  $result = 1;
929  } else {
930  // create thumbnail file
931  if ($this->isSingleline && ($this->getThumbSize())) {
932  $this->generateThumbForFile($imagepath, $image_filename);
933  }
934  }
935  }
936  }
937  return $result;
938  }
generateThumbForFile($path, $file)
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.
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
+ Here is the call graph for this function:

◆ setIsSingleline()

assMultipleChoice::setIsSingleline (   $isSingleline)
Parameters
mixed$isSingleline

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

References $isSingleline, and isSingleline().

+ Here is the call graph for this function:

◆ setMultilineAnswerSetting()

assMultipleChoice::setMultilineAnswerSetting (   $a_setting = 0)

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

References $DIC, and $ilUser.

1202  : void
1203  {
1204  global $DIC;
1205  $ilUser = $DIC['ilUser'];
1206  $ilUser->writePref("tst_multiline_answers", $a_setting);
1207  }
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34

◆ setOutputType()

assMultipleChoice::setOutputType (   $output_type = OUTPUT_ORDER)

Sets the output type of the assMultipleChoice object.

Parameters
int | string$output_typeA nonnegative integer value specifying the output type. It is OUTPUT_ORDER (=0) or OUTPUT_RANDOM (=1).
See also
$response

Definition at line 425 of file class.assMultipleChoice.php.

References $output_type.

425  : void
426  {
427  $this->output_type = $output_type;
428  }

◆ setSelectionLimit()

assMultipleChoice::setSelectionLimit (   $selectionLimit)
Parameters
int$selectionLimit

Definition at line 123 of file class.assMultipleChoice.php.

References $selectionLimit.

Referenced by loadFromDb().

123  : void
124  {
125  $this->selectionLimit = $selectionLimit;
126  }
+ Here is the caller graph for this function:

◆ setSpecificFeedbackSetting()

assMultipleChoice::setSpecificFeedbackSetting (   $a_feedback_setting)

Sets the feedback settings in effect for the question.

Options are: 1 - Feedback is shown for all answer options. 2 - Feedback is shown for all checked/selected options. 3 - Feedback is shown for all correct options.

Parameters
integer$a_feedback_setting

Definition at line 1218 of file class.assMultipleChoice.php.

1218  : void
1219  {
1220  $this->feedback_setting = $a_feedback_setting;
1221  }

◆ syncImages()

assMultipleChoice::syncImages ( )
protected

Sync images of a MC question on synchronisation with the original question.

Definition at line 1034 of file class.assMultipleChoice.php.

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

Referenced by syncWithOriginal().

1034  : void
1035  {
1036  global $DIC;
1037  $ilLog = $DIC['ilLog'];
1038  $imagepath = $this->getImagePath();
1039  $question_id = $this->getOriginalId();
1040  $originalObjId = parent::lookupParentObjId($this->getOriginalId());
1041  $imagepath_original = $this->getImagePath($question_id, $originalObjId);
1042 
1043  ilFileUtils::delDir($imagepath_original);
1044  foreach ($this->answers as $answer) {
1045  $filename = $answer->getImage();
1046  if (strlen($filename)) {
1047  if (@file_exists($imagepath . $filename)) {
1048  if (!file_exists($imagepath)) {
1049  ilFileUtils::makeDirParents($imagepath);
1050  }
1051  if (!file_exists($imagepath_original)) {
1052  ilFileUtils::makeDirParents($imagepath_original);
1053  }
1054  if (!@copy($imagepath . $filename, $imagepath_original . $filename)) {
1055  $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
1056  $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
1057  }
1058  }
1059  if (@file_exists($imagepath . $this->getThumbPrefix() . $filename)) {
1060  if (!@copy($imagepath . $this->getThumbPrefix() . $filename, $imagepath_original . $this->getThumbPrefix() . $filename)) {
1061  $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
1062  $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
1063  }
1064  }
1065  }
1066  }
1067  }
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.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
$filename
Definition: buildRTE.php:78
ILIAS DI LoggingServices $ilLog
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ syncWithOriginal()

assMultipleChoice::syncWithOriginal ( )

Definition at line 867 of file class.assMultipleChoice.php.

References assQuestion\getOriginalId(), and syncImages().

867  : void
868  {
869  if ($this->getOriginalId()) {
870  $this->syncImages();
871  parent::syncWithOriginal();
872  }
873  }
syncImages()
Sync images of a MC question on synchronisation with the original question.
+ Here is the call graph for this function:

◆ toJSON()

assMultipleChoice::toJSON ( )

Returns a JSON representation of the question.

Definition at line 1135 of file class.assMultipleChoice.php.

References $answers, ILIAS\LTI\ToolProvider\$key, $mobs, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getAnswers(), assQuestion\getId(), assQuestion\getImagePathWeb(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), getSelectionLimit(), assQuestion\getShuffle(), assQuestion\getThumbSize(), assQuestion\getTitleForHTMLOutput(), and ILIAS\Repository\int().

1135  : string
1136  {
1137  require_once './Services/RTE/classes/class.ilRTE.php';
1138  $result = array();
1139  $result['id'] = $this->getId();
1140  $result['type'] = (string) $this->getQuestionType();
1141  $result['title'] = $this->getTitleForHTMLOutput();
1142  $result['question'] = $this->formatSAQuestion($this->getQuestion());
1143  $result['nr_of_tries'] = $this->getNrOfTries();
1144  $result['shuffle'] = $this->getShuffle();
1145  $result['selection_limit'] = (int) $this->getSelectionLimit();
1146  $result['feedback'] = array(
1147  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1148  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1149  );
1150 
1151  $answers = array();
1152  $has_image = false;
1153  foreach ($this->getAnswers() as $key => $answer_obj) {
1154  if ((string) $answer_obj->getImage()) {
1155  $has_image = true;
1156  }
1157  array_push($answers, array(
1158  "answertext" => $this->formatSAQuestion($answer_obj->getAnswertext()),
1159  "points_checked" => (float) $answer_obj->getPointsChecked(),
1160  "points_unchecked" => (float) $answer_obj->getPointsUnchecked(),
1161  "order" => (int) $answer_obj->getOrder(),
1162  "image" => (string) $answer_obj->getImage(),
1163  "feedback" => $this->formatSAQuestion(
1164  $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
1165  )
1166  ));
1167  }
1168  $result['answers'] = $answers;
1169 
1170  if ($has_image) {
1171  $result['path'] = $this->getImagePathWeb();
1172  $result['thumb'] = $this->getThumbSize();
1173  }
1174 
1175  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1176  $result['mobs'] = $mobs;
1177 
1178  return json_encode($result);
1179  }
$mobs
Definition: imgupload.php:70
getImagePathWeb()
Returns the web image path for web accessable images of a question.
getQuestionType()
Returns the question type of the question.
string $key
Consumer key/client ID value.
Definition: System.php:193
& getAnswers()
Returns a reference to the answers array.
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
+ Here is the call graph for this function:

◆ validateSolutionSubmit()

assMultipleChoice::validateSolutionSubmit ( )

Definition at line 607 of file class.assMultipleChoice.php.

References getAnswerCount(), getSelectionLimit(), getSolutionSubmit(), and ILIAS\Repository\lng().

607  : bool
608  {
609  $submit = $this->getSolutionSubmit();
610 
611  if ($this->getSelectionLimit()) {
612  if (count($submit) > $this->getSelectionLimit()) {
613  $failureMsg = sprintf(
614  $this->lng->txt('ass_mc_sel_lim_exhausted_hint'),
615  $this->getSelectionLimit(),
616  $this->getAnswerCount()
617  );
618 
619  $this->tpl->setOnScreenMessage('failure', $failureMsg, true);
620  return false;
621  }
622  }
623 
624  return true;
625  }
getAnswerCount()
Returns the number of answers.
+ Here is the call graph for this function:

Field Documentation

◆ $answers

assMultipleChoice::$answers

Definition at line 45 of file class.assMultipleChoice.php.

Referenced by getAnswers(), and toJSON().

◆ $feedback_setting

assMultipleChoice::$feedback_setting

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

Referenced by getSpecificFeedbackSetting().

◆ $isSingleline

assMultipleChoice::$isSingleline

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

Referenced by getIsSingleline(), isSingleline(), and setIsSingleline().

◆ $lastChange

assMultipleChoice::$lastChange

Definition at line 58 of file class.assMultipleChoice.php.

◆ $output_type

assMultipleChoice::$output_type

Definition at line 55 of file class.assMultipleChoice.php.

Referenced by __construct(), getOutputType(), and setOutputType().

◆ $selectionLimit

assMultipleChoice::$selectionLimit
protected

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

Referenced by getSelectionLimit(), and setSelectionLimit().


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