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

Protected Attributes

 $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
 

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

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

113  {
114  parent::__construct($title, $comment, $author, $owner, $question);
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  }
Create styles array
The data for the language used.

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

References $changed, $i, assQuestion\$points, and array.

441  {
442  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
443  if (array_key_exists($order, $this->answers)) {
444  // insert answer
445  $answer = new ASS_AnswerMultipleResponseImage($answertext, $points, $order, $points_unchecked, $answerimage);
446  $newchoices = array();
447  for ($i = 0; $i < $order; $i++) {
448  array_push($newchoices, $this->answers[$i]);
449  }
450  array_push($newchoices, $answer);
451  for ($i = $order; $i < count($this->answers); $i++) {
452  $changed = $this->answers[$i];
453  $changed->setOrder($i+1);
454  array_push($newchoices, $changed);
455  }
456  $this->answers = $newchoices;
457  } else {
458  // add answer
459  $answer = new ASS_AnswerMultipleResponseImage($answertext, $points, count($this->answers), $points_unchecked, $answerimage);
460  array_push($this->answers, $answer);
461  }
462  }
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file.
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19

◆ buildTestPresentationConfig()

assMultipleChoice::buildTestPresentationConfig ( )
protected

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

References $config.

1373  {
1374  $config = parent::buildTestPresentationConfig();
1375  $config->setUseUnchangedAnswerLabel($this->lng->txt('tst_mc_label_none_above'));
1376  return $config;
1377  }

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

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

Referenced by getExpressionTypes().

570  {
571  if ($returndetails) {
572  throw new ilTestException('return details not implemented for ' . __METHOD__);
573  }
574 
575  global $ilDB;
576 
577  $found_values = array();
578  if (is_null($pass)) {
579  $pass = $this->getSolutionMaxPass($active_id);
580  }
581  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
582  while ($data = $ilDB->fetchAssoc($result)) {
583  if (strcmp($data["value1"], "") != 0) {
584  array_push($found_values, $data["value1"]);
585  }
586  }
587 
588  $points = $this->calculateReachedPointsForSolution($found_values, $active_id);
589 
590  return $points;
591  }
calculateReachedPointsForSolution($found_values, $active_id=0)
$result
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
Create styles array
The data for the language used.
global $ilDB
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsForSolution()

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

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

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

Referenced by calculateReachedPoints().

1266  {
1267  $points = 0;
1268  foreach ($this->answers as $key => $answer) {
1269  if (in_array($key, $found_values)) {
1270  $points += $answer->getPoints();
1271  } else {
1272  $points += $answer->getPointsUnchecked();
1273  }
1274  }
1275  if ($active_id) {
1276  include_once "./Modules/Test/classes/class.ilObjTest.php";
1277  $mc_scoring = ilObjTest::_getMCScoring($active_id);
1278  if (($mc_scoring == 0) && (count($found_values) == 0)) {
1279  $points = 0;
1280  }
1281  }
1282  return $points;
1283  }
static _getMCScoring($active_id)
Gets the scoring type for multiple choice questions.
$key
Definition: croninfo.php:18
+ 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 891 of file class.assMultipleChoice.php.

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

892  {
893  global $ilLog;
894  $imagepath = $this->getImagePath();
895  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
896  $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
897  foreach ($this->answers as $answer) {
898  $filename = $answer->getImage();
899  if (strlen($filename)) {
900  if (!file_exists($imagepath)) {
901  ilUtil::makeDirParents($imagepath);
902  }
903  if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
904  $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
905  $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
906  }
907  if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename)) {
908  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
909  $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
910  $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
911  }
912  }
913  }
914  }
915  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
+ Here is the call graph for this function:

◆ copyObject()

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

Copies an assMultipleChoice object.

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

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

336  {
337  if ($this->id <= 0) {
338  // The question has not been saved. It cannot be duplicated
339  return;
340  }
341  // duplicate the question in database
342  $clone = $this;
343  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
345  $clone->id = -1;
346  $source_questionpool_id = $this->getObjId();
347  $clone->setObjId($target_questionpool_id);
348  if ($title) {
349  $clone->setTitle($title);
350  }
351  $clone->saveToDb();
352  // copy question page content
353  $clone->copyPageOfQuestion($original_id);
354  // copy XHTML media objects
355  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
356  // duplicate the image
357  $clone->copyImages($original_id, $source_questionpool_id);
358 
359  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
360 
361  return $clone->id;
362  }
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

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

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

365  {
366  if ($this->id <= 0) {
367  // The question has not been saved. It cannot be duplicated
368  return;
369  }
370 
371  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
372 
373  $sourceQuestionId = $this->id;
374  $sourceParentId = $this->getObjId();
375 
376  // duplicate the question in database
377  $clone = $this;
378  $clone->id = -1;
379 
380  $clone->setObjId($targetParentId);
381 
382  if ($targetQuestionTitle) {
383  $clone->setTitle($targetQuestionTitle);
384  }
385 
386  $clone->saveToDb();
387  // copy question page content
388  $clone->copyPageOfQuestion($sourceQuestionId);
389  // copy XHTML media objects
390  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
391  // duplicate the image
392  $clone->copyImages($sourceQuestionId, $sourceParentId);
393 
394  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
395 
396  return $clone->id;
397  }
getObjId()
Get the object id of the container object.
+ 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 505 of file class.assMultipleChoice.php.

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

506  {
507  if ($index < 0) {
508  return;
509  }
510  if (count($this->answers) < 1) {
511  return;
512  }
513  if ($index >= count($this->answers)) {
514  return;
515  }
516  $answer = $this->answers[$index];
517  if (strlen($answer->getImage())) {
518  $this->deleteImage($answer->getImage());
519  }
520  unset($this->answers[$index]);
521  $this->answers = array_values($this->answers);
522  for ($i = 0; $i < count($this->answers); $i++) {
523  if ($this->answers[$i]->getOrder() > $index) {
524  $this->answers[$i]->setOrder($i);
525  }
526  }
527  }
$index
Definition: metadata.php:60
deleteImage($image_filename)
Deletes an image file.
$i
Definition: disco.tpl.php:19
+ 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 833 of file class.assMultipleChoice.php.

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

Referenced by deleteAnswer(), and removeAnswerImage().

834  {
835  $imagepath = $this->getImagePath();
836  @unlink($imagepath . $image_filename);
837  $thumbpath = $imagepath . $this->getThumbPrefix() . $image_filename;
838  @unlink($thumbpath);
839  }
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 (   $for_test = true,
  $title = "",
  $author = "",
  $owner = "",
  $testObjId = null 
)

Duplicates an assMultipleChoiceQuestion.

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

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

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

◆ flushAnswers()

assMultipleChoice::flushAnswers ( )

Deletes all answers.

See also
$answers

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

References array.

535  {
536  $this->answers = array();
537  }
Create styles array
The data for the language used.

◆ generateThumbForFile()

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

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

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

Referenced by rebuildThumbnails(), and setImageFile().

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
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ 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 778 of file class.assMultipleChoice.php.

Referenced by isForcedEmptySolution(), and loadFromDb().

779  {
780  return "qpl_qst_mc";
781  }
+ 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 483 of file class.assMultipleChoice.php.

References $index.

Referenced by getAvailableAnswerOptions().

484  {
485  if ($index < 0) {
486  return null;
487  }
488  if (count($this->answers) < 1) {
489  return null;
490  }
491  if ($index >= count($this->answers)) {
492  return null;
493  }
494 
495  return $this->answers[$index];
496  }
$index
Definition: metadata.php:60
+ 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 470 of file class.assMultipleChoice.php.

Referenced by validateSolutionSubmit().

471  {
472  return count($this->answers);
473  }
+ Here is the caller graph for this function:

◆ getAnswers()

& assMultipleChoice::getAnswers ( )

Returns a reference to the answers array.

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

References $answers.

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

974  {
975  return $this->answers;
976  }
+ 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 788 of file class.assMultipleChoice.php.

789  {
790  return "qpl_a_mc";
791  }

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

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

1364  {
1365  if ($index !== null) {
1366  return $this->getAnswer($index);
1367  } else {
1368  return $this->getAnswers();
1369  }
1370  }
$index
Definition: metadata.php:60
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 71 of file class.assMultipleChoice.php.

References $isSingleline.

72  {
73  return $this->isSingleline;
74  }

◆ getLastChange()

assMultipleChoice::getLastChange ( )
Returns
mixed

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

References $lastChange.

88  {
89  return $this->lastChange;
90  }

◆ getMaximumPoints()

assMultipleChoice::getMaximumPoints ( )

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

See also
$points

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

References $key, and assQuestion\$points.

Referenced by getExpressionTypes(), and isComplete().

545  {
546  $points = 0;
547  $allpoints = 0;
548  foreach ($this->answers as $key => $value) {
549  if ($value->getPoints() > $value->getPointsUnchecked()) {
550  $allpoints += $value->getPoints();
551  } else {
552  $allpoints += $value->getPointsUnchecked();
553  }
554  }
555  return $allpoints;
556  }
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ getMultilineAnswerSetting()

assMultipleChoice::getMultilineAnswerSetting ( )

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

References $ilUser.

1088  {
1089  global $ilUser;
1090 
1091  $multilineAnswerSetting = $ilUser->getPref("tst_multiline_answers");
1092  if ($multilineAnswerSetting != 1) {
1093  $multilineAnswerSetting = 0;
1094  }
1095  return $multilineAnswerSetting;
1096  }
$ilUser
Definition: imgupload.php:18

◆ getOperators()

assMultipleChoice::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
string$expression

Implements iQuestionCondition.

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

References ilOperatorsExpressionMapping\getOperatorsByExpression().

1294  {
1295  require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1297  }
+ 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 405 of file class.assMultipleChoice.php.

References $output_type.

406  {
407  return $this->output_type;
408  }

◆ getQuestionType()

assMultipleChoice::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

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

Referenced by toJSON().

769  {
770  return "assMultipleChoice";
771  }
+ 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 959 of file class.assMultipleChoice.php.

References $index, $text, and assQuestion\getId().

960  {
961  $text = parent::getRTETextWithMediaObjects();
962  foreach ($this->answers as $index => $answer) {
963  $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->getId(), $index);
964  $answer_obj = $this->answers[$index];
965  $text .= $answer_obj->getAnswertext();
966  }
967  return $text;
968  }
getId()
Gets the id of the assQuestion object.
$index
Definition: metadata.php:60
$text
Definition: errorreport.php:18
+ 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 isForcedEmptySolution(), toJSON(), and validateSolutionSubmit().

127  {
128  return $this->selectionLimit;
129  }
+ Here is the caller graph for this function:

◆ getSolutionSubmit()

assMultipleChoice::getSolutionSubmit ( )
protected
Returns
array

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

References $_POST, $key, and array.

Referenced by isForcedEmptySolution(), and validateSolutionSubmit().

1248  {
1249  $solutionSubmit = array();
1250  foreach ($_POST as $key => $value) {
1251  if (preg_match("/^multiple_choice_result_(\d+)/", $key)) {
1252  if (strlen($value)) {
1253  $solutionSubmit[] = $value;
1254  }
1255  }
1256  }
1257  return $solutionSubmit;
1258  }
Create styles array
The data for the language used.
$key
Definition: croninfo.php:18
$_POST["username"]
+ Here is the caller graph for this function:

◆ getSpecificFeedbackAllCorrectOptionLabel()

assMultipleChoice::getSpecificFeedbackAllCorrectOptionLabel ( )

Implements ilAssSpecificFeedbackOptionLabelProvider.

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

1137  {
1138  return 'feedback_correct_sc_mc';
1139  }

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

References $feedback_setting.

Referenced by isForcedEmptySolution().

1128  {
1129  if ($this->feedback_setting) {
1130  return $this->feedback_setting;
1131  } else {
1132  return 1;
1133  }
1134  }
+ Here is the caller graph for this function:

◆ getThumbPrefix()

assMultipleChoice::getThumbPrefix ( )
Returns
string

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

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

187  {
188  return "thumb.";
189  }
+ Here is the caller graph for this function:

◆ getThumbSize()

assMultipleChoice::getThumbSize ( )

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

References $thumb_size.

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

1009  {
1010  return $this->thumb_size;
1011  }
+ 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

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

References $ilDB, $pass, $query, $res, $row, array, assQuestion\getId(), assQuestion\getNumExistingSolutionRecords(), and assQuestion\isObligationPossible().

1153  {
1154  $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1155 
1156  return $numExistingSolutionRecords > 0;
1157  }
getId()
Gets the id of the assQuestion object.
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
+ 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 145 of file class.assMultipleChoice.php.

References getMaximumPoints().

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.
+ Here is the call graph for this function:

◆ isForcedEmptySolution()

◆ lmMigrateQuestionTypeSpecificContent()

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

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

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

1022  {
1023  foreach ($this->getAnswers() as $answer) {
1024  /* @var ASS_AnswerBinaryStateImage $answer */
1025  $answer->setAnswertext($migrator->migrateToLmContent($answer->getAnswertext()));
1026  }
1027  }
& 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 222 of file class.assMultipleChoice.php.

References $data, $ilDB, $result, assQuestion\$shuffle, ilRTE\_replaceMediaObjectImageSrc(), array, getAdditionalTableName(), assQuestion\getImagePath(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setEstimatedWorkingTime(), assQuestion\setId(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setSelectionLimit(), assQuestion\setShuffle(), setThumbSize(), and assQuestion\setTitle().

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

◆ rebuildThumbnails()

assMultipleChoice::rebuildThumbnails ( )
protected

Rebuild the thumbnail images with a new thumbnail size.

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

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

Referenced by isForcedEmptySolution().

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)
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 1078 of file class.assMultipleChoice.php.

References $index, and deleteImage().

1079  {
1080  $answer = $this->answers[$index];
1081  if (is_object($answer)) {
1082  $this->deleteImage($answer->getImage());
1083  $answer->setImage('');
1084  }
1085  }
$index
Definition: metadata.php:60
deleteImage($image_filename)
Deletes an image file.
+ Here is the call graph for this function:

◆ reworkWorkingData()

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

{}

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

751  {
752  // nothing to rework!
753  }

◆ saveToDb()

assMultipleChoice::saveToDb (   $original_id = "")

Saves a assMultipleChoice object to a database.

Parameters
string$original_id

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

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

160  {
164 
165  $this->ensureNoInvalidObligation($this->getId());
166  parent::saveToDb($original_id);
167  }
getId()
Gets the id of the assQuestion object.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb($original_id="")
+ Here is the call graph for this function:

◆ setExportDetailsXLS()

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

{}

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

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

982  {
983  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
984 
985  $solution = $this->getSolutionValues($active_id, $pass);
986 
987  $i = 1;
988  foreach ($this->getAnswers() as $id => $answer) {
989  $worksheet->setCell($startrow + $i, 0, $answer->getAnswertext());
990  $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
991  $checked = false;
992  foreach ($solution as $solutionvalue) {
993  if ($id == $solutionvalue["value1"]) {
994  $checked = true;
995  }
996  }
997  if ($checked) {
998  $worksheet->setCell($startrow + $i, 1, 1);
999  } else {
1000  $worksheet->setCell($startrow + $i, 1, 0);
1001  }
1002  $i++;
1003  }
1004 
1005  return $startrow + $i + 1;
1006  }
$worksheet
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
& getAnswers()
Returns a reference to the answers array.
$i
Definition: disco.tpl.php:19
+ 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 800 of file class.assMultipleChoice.php.

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

801  {
802  $result = 0;
803  if (!empty($image_tempfilename)) {
804  $image_filename = str_replace(" ", "_", $image_filename);
805  $imagepath = $this->getImagePath();
806  if (!file_exists($imagepath)) {
807  ilUtil::makeDirParents($imagepath);
808  }
809  if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $imagepath . $image_filename)) {
810  $result = 2;
811  } else {
812  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
813  $mimetype = ilObjMediaObject::getMimeType($imagepath . $image_filename);
814  if (!preg_match("/^image/", $mimetype)) {
815  unlink($imagepath . $image_filename);
816  $result = 1;
817  } else {
818  // create thumbnail file
819  if ($this->isSingleline && ($this->getThumbSize())) {
820  $this->generateThumbForFile($imagepath, $image_filename);
821  }
822  }
823  }
824  }
825  return $result;
826  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static getMimeType($a_file, $a_external=null)
get mime type for file
generateThumbForFile($path, $file)
$result
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:

◆ setIsSingleline()

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

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

References $isSingleline.

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

◆ setLastChange()

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

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

References $lastChange.

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

◆ setMultilineAnswerSetting()

assMultipleChoice::setMultilineAnswerSetting (   $a_setting = 0)

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

References $ilUser.

1099  {
1100  global $ilUser;
1101  $ilUser->writePref("tst_multiline_answers", $a_setting);
1102  }
$ilUser
Definition: imgupload.php:18

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

References $output_type.

418  {
419  $this->output_type = $output_type;
420  }

◆ setSelectionLimit()

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

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

References $selectionLimit.

Referenced by loadFromDb().

135  {
136  $this->selectionLimit = $selectionLimit;
137  }
+ 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 1113 of file class.assMultipleChoice.php.

1114  {
1115  $this->feedback_setting = $a_feedback_setting;
1116  }

◆ setThumbSize()

assMultipleChoice::setThumbSize (   $a_size)

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

Referenced by loadFromDb().

1014  {
1015  $this->thumb_size = $a_size;
1016  }
+ 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 920 of file class.assMultipleChoice.php.

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

Referenced by syncWithOriginal().

921  {
922  global $ilLog;
923 
924  $imagepath = $this->getImagePath();
925 
926  $question_id = $this->getOriginalId();
927  $originalObjId = parent::lookupParentObjId($this->getOriginalId());
928  $imagepath_original = $this->getImagePath($question_id, $originalObjId);
929 
930  ilUtil::delDir($imagepath_original);
931  foreach ($this->answers as $answer) {
932  $filename = $answer->getImage();
933  if (strlen($filename)) {
934  if (@file_exists($imagepath . $filename)) {
935  if (!file_exists($imagepath)) {
936  ilUtil::makeDirParents($imagepath);
937  }
938  if (!file_exists($imagepath_original)) {
939  ilUtil::makeDirParents($imagepath_original);
940  }
941  if (!@copy($imagepath . $filename, $imagepath_original . $filename)) {
942  $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
943  $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
944  }
945  }
946  if (@file_exists($imagepath . $this->getThumbPrefix() . $filename)) {
947  if (!@copy($imagepath . $this->getThumbPrefix() . $filename, $imagepath_original . $this->getThumbPrefix() . $filename)) {
948  $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
949  $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
950  }
951  }
952  }
953  }
954  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ syncWithOriginal()

assMultipleChoice::syncWithOriginal ( )

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

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

756  {
757  if ($this->getOriginalId()) {
758  $this->syncImages();
759  parent::syncWithOriginal();
760  }
761  }
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 1032 of file class.assMultipleChoice.php.

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

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

◆ validateSolutionSubmit()

assMultipleChoice::validateSolutionSubmit ( )

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

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

594  {
595  $submit = $this->getSolutionSubmit();
596 
597  if ($this->getSelectionLimit()) {
598  if (count($submit) > $this->getSelectionLimit()) {
599  $failureMsg = sprintf(
600  $this->lng->txt('ass_mc_sel_lim_exhausted_hint'),
601  $this->getSelectionLimit(),
602  $this->getAnswerCount()
603  );
604 
605  ilUtil::sendFailure($failureMsg, true);
606  return false;
607  }
608  }
609 
610  return true;
611  }
getAnswerCount()
Returns the number of answers.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ 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: