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

Class for multiple choice tests. More...

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

Public Member Functions

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

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 ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT = 'default'
 constant for additional content editing mode "default" More...
 
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT = 'pageobject'
 constant for additional content editing mode "pageobject" More...
 
 $feedbackOBJ = null
 
 $prevent_rte_usage = false
 
 $selfassessmenteditingmode = false
 
 $defaultnroftries = 0
 
 $questionActionCmd = 'handleQuestionAction'
 
const KEY_VALUES_IMPLOSION_SEPARATOR = ':'
 
- Data Fields inherited from iQuestionCondition
const StringResultExpression = '~TEXT~'
 
const PercentageResultExpression = '%n%'
 
const NumericResultExpression = '#n#'
 
const MatchingResultExpression = ';n:m;'
 
const OrderingResultExpression = '$n,m,o,p$'
 
const NumberOfResultExpression = '+n+'
 
const ExclusiveResultExpression = '*n,m,o,p*'
 
const EmptyAnswerExpression = "?"
 

Protected Member Functions

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

Protected Attributes

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

Additional Inherited Members

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

Detailed Description

Class for 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 27 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 106 of file class.assMultipleChoice.php.

113 {
115 $this->output_type = $output_type;
116 $this->thumb_size = 150;
117 $this->answers = array();
118 $this->shuffle = 1;
119 $this->selectionLimit = null;
120 $this->feedback_setting = 0;
121 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ 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 = "" 
)

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
See also
$answers
ASS_AnswerBinaryStateImage

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

448 {
449 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
450 $answertext = $this->getHtmlQuestionContentPurifier()->purify($answertext);
451 if (array_key_exists($order, $this->answers)) {
452 // insert answer
453 $answer = new ASS_AnswerMultipleResponseImage($answertext, $points, $order, $points_unchecked, $answerimage);
454 $newchoices = array();
455 for ($i = 0; $i < $order; $i++) {
456 array_push($newchoices, $this->answers[$i]);
457 }
458 array_push($newchoices, $answer);
459 for ($i = $order; $i < count($this->answers); $i++) {
460 $changed = $this->answers[$i];
461 $changed->setOrder($i + 1);
462 array_push($newchoices, $changed);
463 }
464 $this->answers = $newchoices;
465 } else {
466 // add answer
467 $answer = new ASS_AnswerMultipleResponseImage($answertext, $points, count($this->answers), $points_unchecked, $answerimage);
468 array_push($this->answers, $answer);
469 }
470 }
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked,...
$i
Definition: metadata.php:24

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

+ Here is the call graph for this function:

◆ buildTestPresentationConfig()

assMultipleChoice::buildTestPresentationConfig ( )
protected

build basic test question configuration instance

method can be overwritten to configure an instance use parent call for building when possible

Returns
ilTestQuestionConfig

Reimplemented from assQuestion.

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

1385 {
1386 $config = parent::buildTestPresentationConfig();
1387 $config->setUseUnchangedAnswerLabel($this->lng->txt('tst_mc_label_none_above'));
1388 return $config;
1389 }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68

References $config.

◆ 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 !!)

Reimplemented from assQuestion.

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

578 {
579 if ($returndetails) {
580 throw new ilTestException('return details not implemented for ' . __METHOD__);
581 }
582
583 global $DIC;
584 $ilDB = $DIC['ilDB'];
585
586 $found_values = array();
587 if (is_null($pass)) {
588 $pass = $this->getSolutionMaxPass($active_id);
589 }
590 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
591 while ($data = $ilDB->fetchAssoc($result)) {
592 if (strcmp($data["value1"], "") != 0) {
593 array_push($found_values, $data["value1"]);
594 }
595 }
596
597 $points = $this->calculateReachedPointsForSolution($found_values, $active_id);
598
599 return $points;
600 }
$result
calculateReachedPointsForSolution($found_values, $active_id=0)
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
global $ilDB
$data
Definition: storeScorm.php:23
$DIC
Definition: xapitoken.php:46

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

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

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

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

1277 {
1278 $points = 0;
1279 foreach ($this->answers as $key => $answer) {
1280 if (in_array($key, $found_values)) {
1281 $points += $answer->getPoints();
1282 } else {
1283 $points += $answer->getPointsUnchecked();
1284 }
1285 }
1286 if ($active_id) {
1287 include_once "./Modules/Test/classes/class.ilObjTest.php";
1288 $mc_scoring = ilObjTest::_getMCScoring($active_id);
1289 if (($mc_scoring == 0) && (count($found_values) == 0)) {
1290 $points = 0;
1291 }
1292 }
1293 return $points;
1294 }
static _getMCScoring($active_id)
Gets the scoring type for multiple choice questions.

References assQuestion\$points, and ilObjTest\_getMCScoring().

Referenced by calculateReachedPoints().

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

◆ copyImages()

assMultipleChoice::copyImages (   $question_id,
  $source_questionpool 
)

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

897 {
898 global $DIC;
899 $ilLog = $DIC['ilLog'];
900 $imagepath = $this->getImagePath();
901 $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
902 $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
903 foreach ($this->answers as $answer) {
904 $filename = $answer->getImage();
905 if (strlen($filename)) {
906 if (!file_exists($imagepath)) {
907 ilUtil::makeDirParents($imagepath);
908 }
909 if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
910 $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
911 $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
912 }
913 if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename)) {
914 if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
915 $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
916 $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
917 }
918 }
919 }
920 }
921 }
$filename
Definition: buildRTE.php:89
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static makeDirParents($a_dir)
Create a new directory and all parent directories.

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

+ Here is the call graph for this function:

◆ copyObject()

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

Copies an assMultipleChoice object.

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

343 {
344 if ($this->id <= 0) {
345 // The question has not been saved. It cannot be duplicated
346 return;
347 }
348 // duplicate the question in database
349 $clone = $this;
350 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
352 $clone->id = -1;
353 $source_questionpool_id = $this->getObjId();
354 $clone->setObjId($target_questionpool_id);
355 if ($title) {
356 $clone->setTitle($title);
357 }
358 $clone->saveToDb();
359 // copy question page content
360 $clone->copyPageOfQuestion($original_id);
361 // copy XHTML media objects
362 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
363 // duplicate the image
364 $clone->copyImages($original_id, $source_questionpool_id);
365
366 $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
367
368 return $clone->id;
369 }
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.

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

+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

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

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

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

+ 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 513 of file class.assMultipleChoice.php.

514 {
515 if ($index < 0) {
516 return;
517 }
518 if (count($this->answers) < 1) {
519 return;
520 }
521 if ($index >= count($this->answers)) {
522 return;
523 }
524 $answer = $this->answers[$index];
525 if (strlen($answer->getImage())) {
526 $this->deleteImage($answer->getImage());
527 }
528 unset($this->answers[$index]);
529 $this->answers = array_values($this->answers);
530 for ($i = 0; $i < count($this->answers); $i++) {
531 if ($this->answers[$i]->getOrder() > $index) {
532 $this->answers[$i]->setOrder($i);
533 }
534 }
535 }
deleteImage($image_filename)
Deletes an image file.
$index
Definition: metadata.php:128

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

+ 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 837 of file class.assMultipleChoice.php.

838 {
839 $imagepath = $this->getImagePath();
840 @unlink($imagepath . $image_filename);
841 $thumbpath = $imagepath . $this->getThumbPrefix() . $image_filename;
842 @unlink($thumbpath);
843 }

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

Referenced by deleteAnswer(), and removeAnswerImage().

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

◆ duplicate()

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

Duplicates an assMultipleChoiceQuestion.

Reimplemented from assQuestion.

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

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

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

+ Here is the call graph for this function:

◆ flushAnswers()

assMultipleChoice::flushAnswers ( )

Deletes all answers.

See also
$answers

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

543 {
544 $this->answers = array();
545 }

◆ generateThumbForFile()

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

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

196 {
197 $filename = $path . $file;
198 if (@file_exists($filename)) {
199 $thumbpath = $path . $this->getThumbPrefix() . $file;
200 $path_info = @pathinfo($filename);
201 $ext = "";
202 switch (strtoupper($path_info['extension'])) {
203 case 'PNG':
204 $ext = 'PNG';
205 break;
206 case 'GIF':
207 $ext = 'GIF';
208 break;
209 default:
210 $ext = 'JPEG';
211 break;
212 }
213 ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbSize());
214 }
215 }
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image

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

Referenced by rebuildThumbnails(), and setImageFile().

+ 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

Reimplemented from assQuestion.

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

783 {
784 return "qpl_qst_mc";
785 }

Referenced by loadFromDb().

+ 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 491 of file class.assMultipleChoice.php.

492 {
493 if ($index < 0) {
494 return null;
495 }
496 if (count($this->answers) < 1) {
497 return null;
498 }
499 if ($index >= count($this->answers)) {
500 return null;
501 }
502
503 return $this->answers[$index];
504 }

References $index.

Referenced by getAvailableAnswerOptions().

+ 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 478 of file class.assMultipleChoice.php.

479 {
480 return count($this->answers);
481 }

◆ getAnswers()

& assMultipleChoice::getAnswers ( )

Returns a reference to the answers array.

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

981 {
982 return $this->answers;
983 }

References $answers.

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

+ 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

Reimplemented from assQuestion.

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

793 {
794 return "qpl_a_mc";
795 }

◆ 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
Returns
array|ASS_AnswerSimple

Implements iQuestionCondition.

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

1376 {
1377 if ($index !== null) {
1378 return $this->getAnswer($index);
1379 } else {
1380 return $this->getAnswers();
1381 }
1382 }
getAnswer($index=0)
Returns an answer with a given index.
& getAnswers()
Returns a reference to the answers array.

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

+ Here is the call graph for this function:

◆ getExpressionTypes()

◆ getIsSingleline()

assMultipleChoice::getIsSingleline ( )
Returns
mixed

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

References $isSingleline.

◆ getLastChange()

assMultipleChoice::getLastChange ( )
Returns
mixed

Reimplemented from assQuestion.

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

References $lastChange.

◆ getMaximumPoints()

assMultipleChoice::getMaximumPoints ( )

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

See also
$points

Reimplemented from assQuestion.

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

553 {
554 $points = 0;
555 $allpoints = 0;
556 foreach ($this->answers as $key => $value) {
557 if ($value->getPoints() > $value->getPointsUnchecked()) {
558 $allpoints += $value->getPoints();
559 } else {
560 $allpoints += $value->getPointsUnchecked();
561 }
562 }
563 return $allpoints;
564 }

References assQuestion\$points.

Referenced by isComplete().

+ Here is the caller graph for this function:

◆ getMultilineAnswerSetting()

assMultipleChoice::getMultilineAnswerSetting ( )

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

1095 {
1096 global $DIC;
1097 $ilUser = $DIC['ilUser'];
1098
1099 $multilineAnswerSetting = $ilUser->getPref("tst_multiline_answers");
1100 if ($multilineAnswerSetting != 1) {
1101 $multilineAnswerSetting = 0;
1102 }
1103 return $multilineAnswerSetting;
1104 }
$ilUser
Definition: imgupload.php:18

References $DIC, and $ilUser.

◆ getOperators()

assMultipleChoice::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
string$expression

Implements iQuestionCondition.

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

1305 {
1306 require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1308 }

References ilOperatorsExpressionMapping\getOperatorsByExpression().

+ 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

Reimplemented from assQuestion.

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

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

References $output_type.

◆ getQuestionType()

assMultipleChoice::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

Reimplemented from assQuestion.

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

773 {
774 return "assMultipleChoice";
775 }

Referenced by toJSON().

+ 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.

Reimplemented from assQuestion.

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

967 {
968 $text = parent::getRTETextWithMediaObjects();
969 foreach ($this->answers as $index => $answer) {
970 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->getId(), 0, $index);
971 $answer_obj = $this->answers[$index];
972 $text .= $answer_obj->getAnswertext();
973 }
974 return $text;
975 }

References $index, and assQuestion\getId().

+ Here is the call graph for this function:

◆ getSelectionLimit()

assMultipleChoice::getSelectionLimit ( )
Returns
int

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

References $selectionLimit.

Referenced by toJSON(), and validateSolutionSubmit().

+ Here is the caller graph for this function:

◆ getSolutionSubmit()

assMultipleChoice::getSolutionSubmit ( )
protected
Returns
array

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

1259 {
1260 $solutionSubmit = array();
1261 foreach ($_POST as $key => $value) {
1262 if (preg_match("/^multiple_choice_result_(\d+)/", $key)) {
1263 if (strlen($value)) {
1264 $solutionSubmit[] = $value;
1265 }
1266 }
1267 }
1268 return $solutionSubmit;
1269 }
$_POST["username"]

References $_POST.

Referenced by validateSolutionSubmit().

+ Here is the caller graph for this function:

◆ getSpecificFeedbackAllCorrectOptionLabel()

assMultipleChoice::getSpecificFeedbackAllCorrectOptionLabel ( )

Implements ilAssSpecificFeedbackOptionLabelProvider.

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

1146 {
1147 return 'feedback_correct_sc_mc';
1148 }

◆ 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 1136 of file class.assMultipleChoice.php.

1137 {
1138 if ($this->feedback_setting) {
1140 } else {
1141 return 1;
1142 }
1143 }

References $feedback_setting.

◆ getThumbPrefix()

assMultipleChoice::getThumbPrefix ( )
Returns
string

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

187 {
188 return "thumb.";
189 }

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

+ Here is the caller graph for this function:

◆ getThumbSize()

assMultipleChoice::getThumbSize ( )

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

1016 {
1017 return $this->thumb_size;
1018 }

References $thumb_size.

Referenced by generateThumbForFile(), rebuildThumbnails(), setImageFile(), and toJSON().

+ Here is the caller graph for this function:

◆ isAnswered()

assMultipleChoice::isAnswered (   $active_id,
  $pass = null 
)

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

Reimplemented from assQuestion.

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

1162 {
1163 $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1164
1165 return $numExistingSolutionRecords > 0;
1166 }
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...

References $pass, assQuestion\getId(), and assQuestion\getNumExistingSolutionRecords().

+ 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 @access public

Reimplemented from assQuestion.

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

146 {
147 if (strlen($this->title) and ($this->author) and ($this->question) and (count($this->answers)) and ($this->getMaximumPoints() > 0)) {
148 return true;
149 } else {
150 return false;
151 }
152 }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.

References getMaximumPoints().

+ Here is the call graph for this function:

◆ isForcedEmptySolution()

assMultipleChoice::isForcedEmptySolution (   $solutionSubmit)
protected

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

623 {
624 if (!count($solutionSubmit) && !empty($_POST['tst_force_form_diff_input'])) {
625 return true;
626 }
627
628 return false;
629 }

References $_POST.

◆ lmMigrateQuestionTypeSpecificContent()

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

Reimplemented from assQuestion.

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

1029 {
1030 foreach ($this->getAnswers() as $answer) {
1031 /* @var ASS_AnswerBinaryStateImage $answer */
1032 $answer->setAnswertext($migrator->migrateToLmContent($answer->getAnswertext()));
1033 }
1034 }

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

+ 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

Reimplemented from assQuestion.

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

223 {
224 global $DIC;
225 $ilDB = $DIC['ilDB'];
226 $hasimages = 0;
227
228 $result = $ilDB->queryF(
229 "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",
230 array("integer"),
231 array($question_id)
232 );
233 if ($result->numRows() == 1) {
234 $data = $ilDB->fetchAssoc($result);
235 $this->setId($question_id);
236 $this->setObjId($data["obj_fi"]);
237 $this->setTitle($data["title"]);
238 $this->setNrOfTries($data['nr_of_tries']);
239 $this->setComment($data["description"]);
240 $this->setOriginalId($data["original_id"]);
241 $this->setAuthor($data["author"]);
242 $this->setPoints($data["points"]);
243 $this->setOwner($data["owner"]);
244 include_once("./Services/RTE/classes/class.ilRTE.php");
245 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
246 $shuffle = (is_null($data['shuffle'])) ? true : $data['shuffle'];
247 $this->setShuffle($shuffle);
248 $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
249 $this->setThumbSize($data['thumb_size']);
250 $this->isSingleline = ($data['allow_images']) ? false : true;
251 $this->lastChange = $data['tstamp'];
252 $this->setSelectionLimit((int) $data['selection_limit'] > 0 ? (int) $data['selection_limit'] : null);
253 $this->feedback_setting = $data['feedback_setting'];
254
255 try {
259 }
260
261 try {
262 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
264 }
265 }
266
267 $result = $ilDB->queryF(
268 "SELECT * FROM qpl_a_mc WHERE question_fi = %s ORDER BY aorder ASC",
269 array('integer'),
270 array($question_id)
271 );
272 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
273 if ($result->numRows() > 0) {
274 while ($data = $ilDB->fetchAssoc($result)) {
275 $imagefilename = $this->getImagePath() . $data["imagefile"];
276 if (!@file_exists($imagefilename)) {
277 $data["imagefile"] = "";
278 }
279 include_once("./Services/RTE/classes/class.ilRTE.php");
280 $data["answertext"] = ilRTE::_replaceMediaObjectImageSrc($data["answertext"], 1);
281 array_push($this->answers, new ASS_AnswerMultipleResponseImage($data["answertext"], $data["points"], $data["aorder"], $data["points_unchecked"], $data["imagefile"]));
282 }
283 }
284
285 parent::loadFromDb($question_id);
286 }
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setSelectionLimit($selectionLimit)
setShuffle($shuffle=true)
Sets the shuffle flag.
setId($id=-1)
Sets the id of the assQuestion object.
setOriginalId($original_id)
setObjId($obj_id=0)
Set the object id of the container object.
setTitle($title="")
Sets the title string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second.
setAuthor($author="")
Sets the authors name of the assQuestion object.
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setPoints($a_points)
Sets the maximum available points for the question.
setComment($comment="")
Sets the comment string of the assQuestion object.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setQuestion($question="")
Sets the question string of the question object.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...

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

+ Here is the call graph for this function:

◆ rebuildThumbnails()

assMultipleChoice::rebuildThumbnails ( )
protected

Rebuild the thumbnail images with a new thumbnail size.

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

173 {
174 if ($this->isSingleline && ($this->getThumbSize())) {
175 foreach ($this->getAnswers() as $answer) {
176 if (strlen($answer->getImage())) {
177 $this->generateThumbForFile($this->getImagePath(), $answer->getImage());
178 }
179 }
180 }
181 }
generateThumbForFile($path, $file)

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

+ Here is the call graph for this function:

◆ removeAnswerImage()

assMultipleChoice::removeAnswerImage (   $index)

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

1086 {
1087 $answer = $this->answers[$index];
1088 if (is_object($answer)) {
1089 $this->deleteImage($answer->getImage());
1090 $answer->setImage('');
1091 }
1092 }

References $index, and deleteImage().

+ Here is the call graph for this function:

◆ saveToDb()

assMultipleChoice::saveToDb (   $original_id = "")

Saves a assMultipleChoice object to a database.

Parameters
string$original_id

Reimplemented from assQuestion.

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

160 {
164
165 $this->ensureNoInvalidObligation($this->getId());
166 parent::saveToDb($original_id);
167 }
saveQuestionDataToDb($original_id="")
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.

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

+ Here is the call graph for this function:

◆ setExportDetailsXLS()

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

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

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

Reimplemented from assQuestion.

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

989 {
990 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
991
992 $solution = $this->getSolutionValues($active_id, $pass);
993
994 $i = 1;
995 foreach ($this->getAnswers() as $id => $answer) {
996 $worksheet->setCell($startrow + $i, 0, $answer->getAnswertext());
997 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
998 $checked = false;
999 foreach ($solution as $solutionvalue) {
1000 if ($id == $solutionvalue["value1"]) {
1001 $checked = true;
1002 }
1003 }
1004 if ($checked) {
1005 $worksheet->setCell($startrow + $i, 1, 1);
1006 } else {
1007 $worksheet->setCell($startrow + $i, 1, 0);
1008 }
1009 $i++;
1010 }
1011
1012 return $startrow + $i + 1;
1013 }
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.

References $i, assQuestion\$id, $pass, getAnswers(), and assQuestion\getSolutionValues().

+ 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 804 of file class.assMultipleChoice.php.

805 {
806 $result = 0;
807 if (!empty($image_tempfilename)) {
808 $image_filename = str_replace(" ", "_", $image_filename);
809 $imagepath = $this->getImagePath();
810 if (!file_exists($imagepath)) {
811 ilUtil::makeDirParents($imagepath);
812 }
813 if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $imagepath . $image_filename)) {
814 $result = 2;
815 } else {
816 include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
817 $mimetype = ilObjMediaObject::getMimeType($imagepath . $image_filename);
818 if (!preg_match("/^image/", $mimetype)) {
819 unlink($imagepath . $image_filename);
820 $result = 1;
821 } else {
822 // create thumbnail file
823 if ($this->isSingleline && ($this->getThumbSize())) {
824 $this->generateThumbForFile($imagepath, $image_filename);
825 }
826 }
827 }
828 }
829 return $result;
830 }
static getMimeType($a_file, $a_external=null)
get mime type for file
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

References $result, generateThumbForFile(), assQuestion\getImagePath(), ilObjMediaObject\getMimeType(), getThumbSize(), ilUtil\makeDirParents(), and ilUtil\moveUploadedFile().

+ Here is the call graph for this function:

◆ setIsSingleline()

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

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

64 {
65 $this->isSingleline = $isSingleline;
66 }

References $isSingleline.

◆ setLastChange()

assMultipleChoice::setLastChange (   $lastChange)
Parameters
mixed$lastChange

Reimplemented from assQuestion.

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

80 {
81 $this->lastChange = $lastChange;
82 }

References $lastChange.

◆ setMultilineAnswerSetting()

assMultipleChoice::setMultilineAnswerSetting (   $a_setting = 0)

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

1107 {
1108 global $DIC;
1109 $ilUser = $DIC['ilUser'];
1110 $ilUser->writePref("tst_multiline_answers", $a_setting);
1111 }

References $DIC, and $ilUser.

◆ 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

Reimplemented from assQuestion.

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

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

References $output_type.

◆ setSelectionLimit()

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

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

135 {
136 $this->selectionLimit = $selectionLimit;
137 }

References $selectionLimit.

Referenced by loadFromDb().

+ 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 1122 of file class.assMultipleChoice.php.

1123 {
1124 $this->feedback_setting = $a_feedback_setting;
1125 }

◆ setThumbSize()

assMultipleChoice::setThumbSize (   $a_size)

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

1021 {
1022 $this->thumb_size = $a_size;
1023 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ syncImages()

assMultipleChoice::syncImages ( )
protected

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

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

927 {
928 global $DIC;
929 $ilLog = $DIC['ilLog'];
930
931 $imagepath = $this->getImagePath();
932
933 $question_id = $this->getOriginalId();
934 $originalObjId = parent::lookupParentObjId($this->getOriginalId());
935 $imagepath_original = $this->getImagePath($question_id, $originalObjId);
936
937 ilUtil::delDir($imagepath_original);
938 foreach ($this->answers as $answer) {
939 $filename = $answer->getImage();
940 if (strlen($filename)) {
941 if (@file_exists($imagepath . $filename)) {
942 if (!file_exists($imagepath)) {
943 ilUtil::makeDirParents($imagepath);
944 }
945 if (!file_exists($imagepath_original)) {
946 ilUtil::makeDirParents($imagepath_original);
947 }
948 if (!@copy($imagepath . $filename, $imagepath_original . $filename)) {
949 $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
950 $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
951 }
952 }
953 if (@file_exists($imagepath . $this->getThumbPrefix() . $filename)) {
954 if (!@copy($imagepath . $this->getThumbPrefix() . $filename, $imagepath_original . $this->getThumbPrefix() . $filename)) {
955 $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
956 $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
957 }
958 }
959 }
960 }
961 }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

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

Referenced by syncWithOriginal().

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

◆ syncWithOriginal()

assMultipleChoice::syncWithOriginal ( )

Reimplemented from assQuestion.

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

760 {
761 if ($this->getOriginalId()) {
762 $this->syncImages();
763 parent::syncWithOriginal();
764 }
765 }
syncImages()
Sync images of a MC question on synchronisation with the original question.

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

+ Here is the call graph for this function:

◆ toJSON()

assMultipleChoice::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

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

1040 {
1041 require_once './Services/RTE/classes/class.ilRTE.php';
1042 $result = array();
1043 $result['id'] = (int) $this->getId();
1044 $result['type'] = (string) $this->getQuestionType();
1045 $result['title'] = (string) $this->getTitle();
1046 $result['question'] = $this->formatSAQuestion($this->getQuestion());
1047 $result['nr_of_tries'] = (int) $this->getNrOfTries();
1048 $result['shuffle'] = (bool) $this->getShuffle();
1049 $result['selection_limit'] = (int) $this->getSelectionLimit();
1050 $result['feedback'] = array(
1051 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1052 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1053 );
1054
1055 $answers = array();
1056 $has_image = false;
1057 foreach ($this->getAnswers() as $key => $answer_obj) {
1058 if ((string) $answer_obj->getImage()) {
1059 $has_image = true;
1060 }
1061 array_push($answers, array(
1062 "answertext" => (string) $this->formatSAQuestion($answer_obj->getAnswertext()),
1063 "points_checked" => (float) $answer_obj->getPointsChecked(),
1064 "points_unchecked" => (float) $answer_obj->getPointsUnchecked(),
1065 "order" => (int) $answer_obj->getOrder(),
1066 "image" => (string) $answer_obj->getImage(),
1067 "feedback" => $this->formatSAQuestion(
1068 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
1069 )
1070 ));
1071 }
1072 $result['answers'] = $answers;
1073
1074 if ($has_image) {
1075 $result['path'] = $this->getImagePathWeb();
1076 $result['thumb'] = $this->getThumbSize();
1077 }
1078
1079 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1080 $result['mobs'] = $mobs;
1081
1082 return json_encode($result);
1083 }
getQuestionType()
Returns the question type of the question.
formatSAQuestion($a_q)
Format self assessment question.
getShuffle()
Gets the shuffle flag.
getTitle()
Gets the title string of the assQuestion object.
getQuestion()
Gets the question string of the question object.
getImagePathWeb()
Returns the web image path for web accessable images of a question.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
$mobs

References $answers, $mobs, $result, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getAnswers(), assQuestion\getId(), assQuestion\getImagePathWeb(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), getSelectionLimit(), assQuestion\getShuffle(), getThumbSize(), and assQuestion\getTitle().

+ Here is the call graph for this function:

◆ validateSolutionSubmit()

assMultipleChoice::validateSolutionSubmit ( )

Reimplemented from assQuestion.

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

603 {
604 $submit = $this->getSolutionSubmit();
605
606 if ($this->getSelectionLimit()) {
607 if (count($submit) > $this->getSelectionLimit()) {
608 $failureMsg = sprintf(
609 $this->lng->txt('ass_mc_sel_lim_exhausted_hint'),
610 $this->getSelectionLimit(),
611 $this->getAnswerCount()
612 );
613
614 ilUtil::sendFailure($failureMsg, true);
615 return false;
616 }
617 }
618
619 return true;
620 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References getSelectionLimit(), getSolutionSubmit(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

Field Documentation

◆ $answers

assMultipleChoice::$answers

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

Referenced by getAnswers(), and toJSON().

◆ $feedback_setting

assMultipleChoice::$feedback_setting

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

Referenced by getSpecificFeedbackSetting().

◆ $isSingleline

assMultipleChoice::$isSingleline

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

Referenced by getIsSingleline(), and setIsSingleline().

◆ $lastChange

assMultipleChoice::$lastChange

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

Referenced by getLastChange(), and setLastChange().

◆ $output_type

assMultipleChoice::$output_type

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

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

◆ $selectionLimit

assMultipleChoice::$selectionLimit
protected

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

Referenced by getSelectionLimit(), and setSelectionLimit().

◆ $thumb_size

assMultipleChoice::$thumb_size
protected

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

Referenced by getThumbSize().


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