ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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...
 
 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...
 
 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, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. 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...
 
 getId ()
 Gets the id of the assQuestion object. More...
 
 getShuffle ()
 Gets the shuffle flag. More...
 
 getTestId ()
 Gets the test id of the assQuestion object. More...
 
 getComment ()
 Gets the comment string of the assQuestion object. More...
 
 getOutputType ()
 Gets the output type. More...
 
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output. More...
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getEstimatedWorkingTime ()
 Gets the estimated working time of a question. More...
 
 getAuthor ()
 Gets the authors name of the assQuestion object. More...
 
 getOwner ()
 Gets the creator/owner ID of the assQuestion object. More...
 
 getObjId ()
 Get the object id of the container object. More...
 
 setObjId ($obj_id=0)
 Set the object id of the container object. More...
 
 setExternalId ($external_id)
 
 getExternalId ()
 
 _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
_getQuestionInfo ($question_id)
 Returns question information from the database. More...
 
 getSuggestedSolutionOutput ()
 
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 Return the suggested solutions. More...
 
 _getReachedPoints ($active_id, $question_id, $pass=NULL)
 Returns the points, a learner has reached answering the question. More...
 
 getReachedPoints ($active_id, $pass=NULL)
 Returns the points, a learner has reached answering the question This is the fast way to get the points directly from the database. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getAdjustedReachedPoints ($active_id, $pass=NULL, $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution ($active_id, $pass=NULL, $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState ($active_id, $pass=NULL, $obligationsEnabled=false, $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question More...
 
 saveWorkingData ($active_id, $pass=NULL, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 @TODO Move this to a proper place. More...
 
 logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
 _logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution. More...
 
 getJavaPath ()
 Returns the image path for web accessable images of a question. More...
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 buildImagePath ($questionId, $parentObjectId)
 
 getFlashPath ()
 Returns the image path for web accessable flash files of a question. More...
 
 getJavaPathWeb ()
 Returns the web image path for web accessable java applets of a question. More...
 
 getSuggestedSolutionPathWeb ()
 Returns the web path for a suggested solution. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getFlashPathWeb ()
 Returns the web image path for web accessable flash applications of a question. More...
 
 getUserSolutionPreferingIntermediate ($active_id, $pass=NULL)
 
 getSolutionValues ($active_id, $pass=NULL, $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse ($question_id="")
 Checks whether the question is in use or not. More...
 
 isClone ($question_id="")
 Checks whether the question is a clone of another question or not. More...
 
 pcArrayShuffle ($array)
 Shuffles the values of a given array. More...
 
 getQuestionTypeFromDb ($question_id)
 get question type for question id More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 getTotalAnswers ()
 get total number of answers More...
 
 _getTotalAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
 _getTitle ($a_q_id)
 Returns the title of a question. More...
 
 _getQuestionText ($a_q_id)
 Returns question text. More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 create page object of question More...
 
 copyPageOfQuestion ($a_q_id)
 
 getPageOfQuestion ()
 
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
 _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 fixSvgToPng ($imageFilenameContainingString)
 
 fixUnavailableSkinImageSources ($html)
 
 loadFromDb ($question_id)
 Loads the question from the database. More...
 
 createNewQuestion ($a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb ($original_id="")
 
 saveToDb ($original_id="")
 Saves the question to the database. More...
 
 setNewOriginalId ($newId)
 
 deleteSuggestedSolutions ()
 Deletes all suggestes solutions in the database. More...
 
 getSuggestedSolution ($subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle ($subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution ($solution_id="", $subquestion_index=0, $is_import=false)
 Sets a suggested solution for the question. More...
 
 _resolveInternalLink ($internal_link)
 
 _resolveIntLinks ($question_id)
 
 _getInternalLinkHref ($target="")
 
 syncWithOriginal ()
 
 createRandomSolution ($test_id, $user_id)
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool ($question_id)
 Returns true if the question already exists in the database and is assigned to a question pool. More...
 
 getPoints ()
 Returns the maximum available points for the question. More...
 
 setPoints ($a_points)
 Sets the maximum available points for the question. More...
 
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution. More...
 
 _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution. More...
 
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
 _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not. More...
 
 calculateReachedPoints ($active_id, $pass=NULL, $authorizedSolution=true, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question. More...
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=NULL)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=FALSE, $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output in tests. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addQTIMaterial (&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE)
 Creates a QTI material tag from a plain text or xhtml text. More...
 
 createNewImageFileName ($image_filename, $unique=false)
 
 _setReachedPoints ($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
 getQuestion ()
 Gets the question string of the question object. More...
 
 setQuestion ($question="")
 Sets the question string of the question object. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 Returns the question type of the question. More...
 
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table More...
 
getInstances ()
 Gets all instances of the question. More...
 
 _needsManualScoring ($question_id)
 
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id. More...
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getNrOfTries ()
 
 setNrOfTries ($a_nr_of_tries)
 
 setExportImagePath ($a_path)
 
 _questionExistsInTest ($question_id, $test_id)
 
 formatSAQuestion ($a_q)
 Format self assessment question. More...
 
 setPreventRteUsage ($a_val)
 Set prevent rte usage. More...
 
 getPreventRteUsage ()
 Get prevent rte usage. More...
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode ($a_selfassessmenteditingmode)
 Set Self-Assessment Editing Mode. More...
 
 getSelfAssessmentEditingMode ()
 Get Self-Assessment Editing Mode. More...
 
 setDefaultNrOfTries ($a_defaultnroftries)
 Set Default Nr of Tries. More...
 
 getDefaultNrOfTries ()
 Get Default Nr of Tries. More...
 
 syncSkillAssignments ($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId)
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not More...
 
 isAutosaveable ()
 
 getAdditionalContentEditingMode ()
 getter for additional content editing mode for this question More...
 
 setAdditionalContentEditingMode ($additinalContentEditingMode)
 setter for additional content editing mode for this question More...
 
 isAdditionalContentEditingModePageObject ()
 isser for additional "pageobject" content editing mode More...
 
 isValidAdditionalContentEditingMode ($additionalContentEditingMode)
 returns the fact wether the passed additional content mode is valid or not More...
 
 getValidAdditionalContentEditingModes ()
 getter for valid additional content editing modes More...
 
 addQuestionChangeListener (ilQuestionChangeListener $listener)
 
 getQuestionChangeListeners ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution ($active_id, $pass)
 
 removeCurrentSolution ($active_id, $pass, $authorized=true, $ignoredSolutionIds=array())
 
 saveCurrentSolution ($active_id, $pass, $value1, $value2, $authorized=true)
 
 updateCurrentSolution ($solutionId, $value1, $value2, $authorized=true)
 
 updateCurrentSolutionsAuthorization ($activeId, $pass, $authorized)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
 authorizedSolutionExists ($active_id, $pass)
 
 authorizedOrIntermediateSolutionExists ($active_id, $pass)
 
 lookupForExistingSolutions ($activeId, $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 removeExistingSolutions ($activeId, $pass)
 
 resetUsersAnswer ($activeId, $pass)
 
 removeResultRecord ($activeId, $pass)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered ($obligationsToBeConsidered)
 
 validateSolutionSubmit ()
 
 updateTimestamp ()
 
- Public Member Functions inherited from 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'
 
- 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)
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. 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)
 
- Protected Member Functions inherited from assQuestion
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 Reworks the allready saved working data if neccessary. More...
 
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID. More...
 
 onDuplicate ($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test) More...
 
 beforeSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 onCopy ($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId)
 Will be called when a question is copied (into another question pool) More...
 
 duplicateSuggestedSolutionFiles ($parent_id, $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles ($original_id)
 Syncs the files of a suggested solution if the question is synced. More...
 
 copySuggestedSolutionFiles ($source_questionpool_id, $source_question_id)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 
 duplicateSkillAssignments ($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet ($active_id, $pass, $authorized=true)
 Get a restulset for the current user solution for a this question by active_id and pass. More...
 
 removeSolutionRecordById ($solutionId)
 
 getSelfAssessmentFormatter ()
 

Protected Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled ($forcePassResultsUpdateEnabled)
 
static isForcePassResultUpdateEnabled ()
 
static isAllowedImageMimeType ($mimeType)
 
static fetchMimeTypeIdentifier ($contentTypeString)
 
static getAllowedFileExtensionsForMimeType ($mimeType)
 
static isAllowedImageFileExtension ($mimeType, $fileExtension)
 
static getAllowedImageFileExtensions ()
 
static _getSuggestedSolutionCount ($question_id)
 Returns the number of suggested solutions associated with a question. More...
 
static _getSuggestedSolutionOutput ($question_id)
 Returns the output of the suggested solution. More...
 
static _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
static isFileAvailable ($file)
 
static _getOriginalId ($question_id)
 Returns the original id of a question. More...
 
static originalQuestionExists ($questionId)
 
static _instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id. More...
 
static _instantiateQuestion ($question_id)
 
static _isWorkedThrough ($active_id, $question_id, $pass=NULL)
 Returns true if the question was worked through in the given pass Worked through means that the user entered at least one value. More...
 
static _areAnswered ($a_user_id, $a_question_ids)
 Checks if an array of question ids is answered by an user or not. More...
 
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type. More...
 
static getGuiClassNameByQuestionType ($questionType)
 
static getObjectClassNameByQuestionType ($questionType)
 
static getFeedbackClassNameByQuestionType ($questionType)
 
static isCoreQuestionType ($questionType)
 
static includeCoreClass ($questionType, $withGuiClass)
 
static includePluginClass ($questionType, $withGuiClass)
 
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag. More...
 
static & _instanciateQuestionGUI ($question_id)
 Creates an instance of a question gui with a given question id. More...
 
static instantiateQuestionGUI ($a_question_id)
 Creates an instance of a question gui with a given question id. More...
 
static lookupParentObjId ($questionId)
 @global ilDB $ilDB More...
 
static lookupOriginalParentObjId ($originalQuestionId)
 returns the parent object id for given original question id (should be a qpl id, but theoretically it can be a tst id, too) More...
 
static isObligationPossible ($questionId)
 returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration More...
 
static setResultGateway ($resultGateway)
 
static getResultGateway ()
 
static sumTimesInISO8601FormatH_i_s_Extended ($time1, $time2)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds ($time)
 
static missingResultRecordExists ($activeId, $pass, $questionIds)
 
static lookupResultRecordExist ($activeId, $questionId, $pass)
 
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords ($activeId, $pass, $questionId)
 returns the number of existing solution records for the given test active / pass and given question id More...
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $forcePassResultsUpdateEnabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

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

109 {
110 parent::__construct($title, $comment, $author, $owner, $question);
111 $this->output_type = $output_type;
112 $this->thumb_size = 150;
113 $this->answers = array();
114 $this->shuffle = 1;
115 }

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

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

444 {
445 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
446 if (array_key_exists($order, $this->answers))
447 {
448 // insert answer
449 $answer = new ASS_AnswerMultipleResponseImage($answertext, $points, $order, $points_unchecked, $answerimage);
450 $newchoices = array();
451 for ($i = 0; $i < $order; $i++)
452 {
453 array_push($newchoices, $this->answers[$i]);
454 }
455 array_push($newchoices, $answer);
456 for ($i = $order; $i < count($this->answers); $i++)
457 {
458 $changed = $this->answers[$i];
459 $changed->setOrder($i+1);
460 array_push($newchoices, $changed);
461 }
462 $this->answers = $newchoices;
463 }
464 else
465 {
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,...

References $changed, and assQuestion\$points.

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

570 {
571 if( $returndetails )
572 {
573 throw new ilTestException('return details not implemented for '.__METHOD__);
574 }
575
576 global $ilDB;
577
578 $found_values = array();
579 if (is_null($pass))
580 {
581 $pass = $this->getSolutionMaxPass($active_id);
582 }
583 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
584 while ($data = $ilDB->fetchAssoc($result))
585 {
586 if (strcmp($data["value1"], "") != 0)
587 {
588 array_push($found_values, $data["value1"]);
589 }
590 }
591
592 $points = $this->calculateReachedPointsForSolution($found_values, $active_id);
593
594 return $points;
595 }
$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.
$data
global $ilDB

References $data, $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 1294 of file class.assMultipleChoice.php.

1295 {
1296 $points = 0;
1297 foreach($this->answers as $key => $answer)
1298 {
1299 if(in_array($key, $found_values))
1300 {
1301 $points += $answer->getPoints();
1302 } else
1303 {
1304 $points += $answer->getPointsUnchecked();
1305 }
1306 }
1307 if($active_id)
1308 {
1309 include_once "./Modules/Test/classes/class.ilObjTest.php";
1310 $mc_scoring = ilObjTest::_getMCScoring($active_id);
1311 if(($mc_scoring == 0) && (count($found_values) == 0))
1312 {
1313 $points = 0;
1314 }
1315 }
1316 return $points;
1317 }
_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 881 of file class.assMultipleChoice.php.

882 {
883 global $ilLog;
884 $imagepath = $this->getImagePath();
885 $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
886 $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
887 foreach ($this->answers as $answer)
888 {
889 $filename = $answer->getImage();
890 if (strlen($filename))
891 {
892 if (!file_exists($imagepath))
893 {
894 ilUtil::makeDirParents($imagepath);
895 }
896 if (!@copy($imagepath_original . $filename, $imagepath . $filename))
897 {
898 $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
899 $ilLog->write("object: " . print_r($this, TRUE), $ilLog->ERROR);
900 }
901 if (@file_exists($imagepath_original. $this->getThumbPrefix(). $filename))
902 {
903 if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename))
904 {
905 $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
906 $ilLog->write("object: " . print_r($this, TRUE), $ilLog->ERROR);
907 }
908 }
909 }
910 }
911 }
$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 $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 333 of file class.assMultipleChoice.php.

334 {
335 if ($this->id <= 0)
336 {
337 // The question has not been saved. It cannot be duplicated
338 return;
339 }
340 // duplicate the question in database
341 $clone = $this;
342 include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
344 $clone->id = -1;
345 $source_questionpool_id = $this->getObjId();
346 $clone->setObjId($target_questionpool_id);
347 if ($title)
348 {
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.

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

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

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

508 {
509 if ($index < 0) return;
510 if (count($this->answers) < 1) return;
511 if ($index >= count($this->answers)) return;
512 $answer = $this->answers[$index];
513 if (strlen($answer->getImage())) $this->deleteImage($answer->getImage());
514 unset($this->answers[$index]);
515 $this->answers = array_values($this->answers);
516 for ($i = 0; $i < count($this->answers); $i++)
517 {
518 if ($this->answers[$i]->getOrder() > $index)
519 {
520 $this->answers[$i]->setOrder($i);
521 }
522 }
523 }
deleteImage($image_filename)
Deletes an image file.

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

829 {
830 $imagepath = $this->getImagePath();
831 @unlink($imagepath . $image_filename);
832 $thumbpath = $imagepath . $this->getThumbPrefix() . $image_filename;
833 @unlink($thumbpath);
834 }

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

275 {
276 if ($this->id <= 0)
277 {
278 // The question has not been saved. It cannot be duplicated
279 return;
280 }
281 // duplicate the question in database
282 $this_id = $this->getId();
283 $thisObjId = $this->getObjId();
284
285 $clone = $this;
286 include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
288 $clone->id = -1;
289
290 if( (int)$testObjId > 0 )
291 {
292 $clone->setObjId($testObjId);
293 }
294
295 if ($title)
296 {
297 $clone->setTitle($title);
298 }
299
300 if ($author)
301 {
302 $clone->setAuthor($author);
303 }
304 if ($owner)
305 {
306 $clone->setOwner($owner);
307 }
308
309 if ($for_test)
310 {
311 $clone->saveToDb($original_id);
312 }
313 else
314 {
315 $clone->saveToDb();
316 }
317
318 // copy question page content
319 $clone->copyPageOfQuestion($this_id);
320 // copy XHTML media objects
321 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
322 // duplicate the images
323 $clone->duplicateImages($this_id, $thisObjId);
324
325 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
326
327 return $clone->id;
328 }
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 530 of file class.assMultipleChoice.php.

531 {
532 $this->answers = array();
533 }

◆ generateThumbForFile()

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

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

180 {
182 if (@file_exists($filename))
183 {
184 $thumbpath = $path . $this->getThumbPrefix() . $file;
185 $path_info = @pathinfo($filename);
186 $ext = "";
187 switch (strtoupper($path_info['extension']))
188 {
189 case 'PNG':
190 $ext = 'PNG';
191 break;
192 case 'GIF':
193 $ext = 'GIF';
194 break;
195 default:
196 $ext = 'JPEG';
197 break;
198 }
199 ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbSize());
200 }
201 }
print $file
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
$path
Definition: index.php:22

References $file, $filename, $path, 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 764 of file class.assMultipleChoice.php.

765 {
766 return "qpl_qst_mc";
767 }

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) return NULL;
494 if (count($this->answers) < 1) return NULL;
495 if ($index >= count($this->answers)) return NULL;
496
497 return $this->answers[$index];
498 }

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

979 {
980 return $this->answers;
981 }

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

775 {
776 return "qpl_a_mc";
777 }

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

1402 {
1403 if($index !== null)
1404 {
1405 return $this->getAnswer($index);
1406 }
1407 else
1408 {
1409 return $this->getAnswers();
1410 }
1411 }
getAnswer($index=0)
Returns an answer with a given index.
& getAnswers()
Returns a reference to the answers array.

References getAnswer(), and getAnswers().

+ Here is the call graph for this function:

◆ getExpressionTypes()

◆ getIsSingleline()

assMultipleChoice::getIsSingleline ( )
Returns
mixed

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

References $isSingleline.

◆ getLastChange()

assMultipleChoice::getLastChange ( )
Returns
mixed

Reimplemented from assQuestion.

Definition at line 82 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 540 of file class.assMultipleChoice.php.

541 {
542 $points = 0;
543 $allpoints = 0;
544 foreach ($this->answers as $key => $value)
545 {
546 if ($value->getPoints() > $value->getPointsUnchecked())
547 {
548 $allpoints += $value->getPoints();
549 }
550 else
551 {
552 $allpoints += $value->getPointsUnchecked();
553 }
554 }
555 return $allpoints;
556 }

References assQuestion\$points.

Referenced by isComplete().

+ Here is the caller graph for this function:

◆ getMultilineAnswerSetting()

assMultipleChoice::getMultilineAnswerSetting ( )

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

1110 {
1111 global $ilUser;
1112
1113 $multilineAnswerSetting = $ilUser->getPref("tst_multiline_answers");
1114 if ($multilineAnswerSetting != 1)
1115 {
1116 $multilineAnswerSetting = 0;
1117 }
1118 return $multilineAnswerSetting;
1119 }
global $ilUser
Definition: imgupload.php:15

References $ilUser.

◆ getOperators()

assMultipleChoice::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
string$expression

Implements iQuestionCondition.

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

1328 {
1329 require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1331 }

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

408 {
409 return $this->output_type;
410 }

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

755 {
756 return "assMultipleChoice";
757 }

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

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

References $text, and assQuestion\getId().

+ Here is the call graph for this function:

◆ getSolutionSubmit()

assMultipleChoice::getSolutionSubmit ( )
protected
Returns
array

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

1274 {
1275 $solutionSubmit = array();
1276 foreach($_POST as $key => $value)
1277 {
1278 if(preg_match("/^multiple_choice_result_(\d+)/", $key))
1279 {
1280 if(strlen($value))
1281 {
1282 $solutionSubmit[] = $value;
1283 }
1284 }
1285 }
1286 return $solutionSubmit;
1287 }
$_POST['username']
Definition: cron.php:12

References $_POST.

◆ getSpecificFeedbackAllCorrectOptionLabel()

assMultipleChoice::getSpecificFeedbackAllCorrectOptionLabel ( )

Implements ilAssSpecificFeedbackOptionLabelProvider.

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

1163 {
1164 return 'feedback_correct_sc_mc';
1165 }

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

1151 {
1152 if ($this->feedback_setting)
1153 {
1155 }
1156 else
1157 {
1158 return 1;
1159 }
1160 }

References $feedback_setting.

◆ getThumbPrefix()

assMultipleChoice::getThumbPrefix ( )
Returns
string

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

171 {
172 return "thumb.";
173 }

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

+ Here is the caller graph for this function:

◆ getThumbSize()

assMultipleChoice::getThumbSize ( )

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

1027 {
1028 return $this->thumb_size;
1029 }

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

1179 {
1180 $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1181
1182 return $numExistingSolutionRecords > 0;
1183 }
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 123 of file class.assMultipleChoice.php.

124 {
125 if (strlen($this->title) and ($this->author) and ($this->question) and (count($this->answers)) and ($this->getMaximumPoints() > 0))
126 {
127 return true;
128 }
129 else
130 {
131 return false;
132 }
133 }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.

References getMaximumPoints().

+ Here is the call graph for this function:

◆ lmMigrateQuestionTypeSpecificContent()

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

Reimplemented from assQuestion.

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

1040 {
1041 foreach($this->getAnswers() as $answer)
1042 {
1043 /* @var ASS_AnswerBinaryStateImage $answer */
1044 $answer->setAnswertext( $migrator->migrateToLmContent($answer->getAnswertext()) );
1045 }
1046 }

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

209 {
210 global $ilDB;
211 $hasimages = 0;
212
213 $result = $ilDB->queryF("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",
214 array("integer"),
215 array($question_id)
216 );
217 if ($result->numRows() == 1)
218 {
219 $data = $ilDB->fetchAssoc($result);
220 $this->setId($question_id);
221 $this->setObjId($data["obj_fi"]);
222 $this->setTitle($data["title"]);
223 $this->setNrOfTries($data['nr_of_tries']);
224 $this->setComment($data["description"]);
225 $this->setOriginalId($data["original_id"]);
226 $this->setAuthor($data["author"]);
227 $this->setPoints($data["points"]);
228 $this->setOwner($data["owner"]);
229 include_once("./Services/RTE/classes/class.ilRTE.php");
230 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
231 $shuffle = (is_null($data['shuffle'])) ? true : $data['shuffle'];
232 $this->setShuffle($shuffle);
233 $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
234 $this->setThumbSize($data['thumb_size']);
235 $this->isSingleline = ($data['allow_images']) ? false : true;
236 $this->lastChange = $data['tstamp'];
237 $this->feedback_setting = $data['feedback_setting'];
238
239 try
240 {
241 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
242 }
244 {
245 }
246 }
247
248 $result = $ilDB->queryF("SELECT * FROM qpl_a_mc WHERE question_fi = %s ORDER BY aorder ASC",
249 array('integer'),
250 array($question_id)
251 );
252 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
253 if ($result->numRows() > 0)
254 {
255 while ($data = $ilDB->fetchAssoc($result))
256 {
257 $imagefilename = $this->getImagePath() . $data["imagefile"];
258 if (!@file_exists($imagefilename))
259 {
260 $data["imagefile"] = "";
261 }
262 include_once("./Services/RTE/classes/class.ilRTE.php");
263 $data["answertext"] = ilRTE::_replaceMediaObjectImageSrc($data["answertext"], 1);
264 array_push($this->answers, new ASS_AnswerMultipleResponseImage($data["answertext"], $data["points"], $data["aorder"], $data["points_unchecked"], $data["imagefile"]));
265 }
266 }
267
268 parent::loadFromDb($question_id);
269 }
getAdditionalTableName()
Returns the name of the additional question data table in the database.
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.
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, $ilDB, $result, assQuestion\$shuffle, ilRTE\_replaceMediaObjectImageSrc(), 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(), 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 153 of file class.assMultipleChoice.php.

154 {
155 if ($this->isSingleline && ($this->getThumbSize()))
156 {
157 foreach ($this->getAnswers() as $answer)
158 {
159 if (strlen($answer->getImage()))
160 {
161 $this->generateThumbForFile($this->getImagePath(), $answer->getImage());
162 }
163 }
164 }
165 }
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 1099 of file class.assMultipleChoice.php.

1100 {
1101 $answer = $this->answers[$index];
1102 if (is_object($answer))
1103 {
1104 $this->deleteImage($answer->getImage());
1105 $answer->setImage('');
1106 }
1107 }

References deleteImage().

+ Here is the call graph for this function:

◆ reworkWorkingData()

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

Reworks the allready saved working data if neccessary.

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered

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

736 {
737 // nothing to rework!
738 }

◆ saveToDb()

assMultipleChoice::saveToDb (   $original_id = "")

Saves a assMultipleChoice object to a database.

Parameters
string$original_id

Reimplemented from assQuestion.

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

141 {
145
146 $this->ensureNoInvalidObligation($this->getId());
147 parent::saveToDb($original_id);
148 }
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,
$format_title,
$format_bold 
)

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

Parameters
object$worksheetReference to the parent excel worksheet
object$startrowStartrow of the output in the excel worksheet
object$active_idActive id of the participant
object$passTest pass
object$format_titleExcel title format
object$format_boldExcel bold format
Returns
object

Reimplemented from assQuestion.

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

996 {
997 include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
998 $solution = $this->getSolutionValues($active_id, $pass);
999 $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
1000 $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
1001 $i = 1;
1002 foreach ($this->getAnswers() as $id => $answer)
1003 {
1004 $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($answer->getAnswertext()), $format_bold);
1005 $checked = FALSE;
1006 foreach ($solution as $solutionvalue)
1007 {
1008 if ($id == $solutionvalue["value1"])
1009 {
1010 $checked = TRUE;
1011 }
1012 }
1013 if ($checked)
1014 {
1015 $worksheet->write($startrow + $i, 1, 1);
1016 }
1017 else
1018 {
1019 $worksheet->write($startrow + $i, 1, 0);
1020 }
1021 $i++;
1022 }
1023 return $startrow + $i + 1;
1024 }
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
getTitle()
Gets the title string of the assQuestion object.
_convert_text($a_text, $a_target="has been removed")

References assQuestion\$id, $pass, ilExcelUtils\_convert_text(), getAnswers(), assQuestion\getSolutionValues(), and assQuestion\getTitle().

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

787 {
788 $result = 0;
789 if (!empty($image_tempfilename))
790 {
791 $image_filename = str_replace(" ", "_", $image_filename);
792 $imagepath = $this->getImagePath();
793 if (!file_exists($imagepath))
794 {
795 ilUtil::makeDirParents($imagepath);
796 }
797 if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $imagepath.$image_filename))
798 {
799 $result = 2;
800 }
801 else
802 {
803 include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
804 $mimetype = ilObjMediaObject::getMimeType($imagepath . $image_filename);
805 if (!preg_match("/^image/", $mimetype))
806 {
807 unlink($imagepath . $image_filename);
808 $result = 1;
809 }
810 else
811 {
812 // create thumbnail file
813 if ($this->isSingleline && ($this->getThumbSize()))
814 {
815 $this->generateThumbForFile($imagepath, $image_filename);
816 }
817 }
818 }
819 }
820 return $result;
821 }
static getMimeType($a_file, $a_external=false)
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 58 of file class.assMultipleChoice.php.

59 {
60 $this->isSingleline = $isSingleline;
61 }

References $isSingleline.

◆ setLastChange()

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

Reimplemented from assQuestion.

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

75 {
76 $this->lastChange = $lastChange;
77 }

References $lastChange.

◆ setMultilineAnswerSetting()

assMultipleChoice::setMultilineAnswerSetting (   $a_setting = 0)

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

1122 {
1123 global $ilUser;
1124 $ilUser->writePref("tst_multiline_answers", $a_setting);
1125 }

References $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 419 of file class.assMultipleChoice.php.

420 {
421 $this->output_type = $output_type;
422 }

References $output_type.

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

1137 {
1138 $this->feedback_setting = $a_feedback_setting;
1139 }

◆ setThumbSize()

assMultipleChoice::setThumbSize (   $a_size)

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

1032 {
1033 $this->thumb_size = $a_size;
1034 }

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

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

References $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 740 of file class.assMultipleChoice.php.

741 {
742 if ($this->getOriginalId())
743 {
744 $this->syncImages();
745 parent::syncWithOriginal();
746 }
747 }
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 1051 of file class.assMultipleChoice.php.

1052 {
1053 require_once './Services/RTE/classes/class.ilRTE.php';
1054 $result = array();
1055 $result['id'] = (int) $this->getId();
1056 $result['type'] = (string) $this->getQuestionType();
1057 $result['title'] = (string) $this->getTitle();
1058 $result['question'] = $this->formatSAQuestion($this->getQuestion());
1059 $result['nr_of_tries'] = (int) $this->getNrOfTries();
1060 $result['shuffle'] = (bool) $this->getShuffle();
1061 $result['feedback'] = array(
1062 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1063 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1064 );
1065
1066 $answers = array();
1067 $has_image = false;
1068 foreach ($this->getAnswers() as $key => $answer_obj)
1069 {
1070 if((string) $answer_obj->getImage())
1071 {
1072 $has_image = true;
1073 }
1074 array_push($answers, array(
1075 "answertext" => (string) $this->formatSAQuestion($answer_obj->getAnswertext()),
1076 "points_checked" => (float) $answer_obj->getPointsChecked(),
1077 "points_unchecked" => (float) $answer_obj->getPointsUnchecked(),
1078 "order" => (int) $answer_obj->getOrder(),
1079 "image" => (string) $answer_obj->getImage(),
1080 "feedback" => $this->formatSAQuestion(
1081 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key)
1082 )
1083 ));
1084 }
1085 $result['answers'] = $answers;
1086
1087 if($has_image)
1088 {
1089 $result['path'] = $this->getImagePathWeb();
1090 $result['thumb'] = $this->getThumbSize();
1091 }
1092
1093 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1094 $result['mobs'] = $mobs;
1095
1096 return json_encode($result);
1097 }
getQuestionType()
Returns the question type of the question.
formatSAQuestion($a_q)
Format self assessment question.
getShuffle()
Gets the shuffle flag.
getQuestion()
Gets the question string of the question object.
getImagePathWeb()
Returns the web image path for web accessable images of a question.
_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(), assQuestion\getShuffle(), getThumbSize(), and assQuestion\getTitle().

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

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