ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assSingleChoice Class Reference

Class for single choice questions. More...

+ Inheritance diagram for assSingleChoice:
+ Collaboration diagram for assSingleChoice:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="", $output_type=OUTPUT_ORDER)
 assSingleChoice constructor More...
 
 isComplete ()
 Returns true, if a single choice question is complete for use. More...
 
 getThumbPrefix ()
 
 loadFromDb ($question_id)
 Loads a assSingleChoice object from a database. More...
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates an assSingleChoiceQuestion. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assSingleChoice object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 getOutputType ()
 Gets the single 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 assSingleChoice object. More...
 
 addAnswer ( $answertext="", $points=0.0, $order=0, $answerimage="")
 Adds a possible answer for a single 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...
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 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...
 
 deleteImage ($image_filename)
 Deletes an image file. More...
 
 duplicateImages ($question_id, $objectId=null)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
getAnswers ()
 Returns a reference to the answers array. More...
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 {Creates an Excel worksheet for the detailed cumulated results of this question.
Parameters
object$worksheetReference to the parent excel worksheet
object$startrowStartrow of the output in the excel worksheet
object$active_idActive id of the participant
object$passTest pass
Returns
object
} More...
 
 getThumbSize ()
 
 setThumbSize ($a_size)
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 removeAnswerImage ($index)
 
 createRandomSolution ($active_id, $pass)
 
 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
 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 ()
 

Static Public Member Functions

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

Data Fields

 $answers
 
 $output_type
 
- 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 ()
 
 generateThumbForFile ($path, $file)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered, $authorized)
 {Reworks the allready saved working data if neccessary.
Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered
boolean$authorized
} More...
 
 syncImages ()
 Sync images of a MC question on synchronisation with the original question. More...
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 {} More...
 
- Protected Member Functions inherited from assQuestion
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission ($postSubmissionFieldname)
 
 ensureCurrentTestPass ($active_id, $pass)
 
 lookupCurrentTestPass ($active_id, $pass)
 
 lookupTestId ($active_id)
 
 log ($active_id, $langVar)
 
 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
 
 $feedback_setting
 
- 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 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 single choice questions.

assSingleChoice is a class for single 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 mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 25 of file class.assSingleChoice.php.

Constructor & Destructor Documentation

◆ __construct()

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

assSingleChoice constructor

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

Definition at line 75 of file class.assSingleChoice.php.

82 {
83 parent::__construct($title, $comment, $author, $owner, $question);
84 $this->thumb_size = 150;
85 $this->output_type = $output_type;
86 $this->answers = array();
87 $this->shuffle = 1;
88 $this->feedback_setting = 2;
89 }

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

Member Function Documentation

◆ addAnswer()

assSingleChoice::addAnswer (   $answertext = "",
  $points = 0.0,
  $order = 0,
  $answerimage = "" 
)

Adds a possible answer for a single 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)
boolean$stateDefines the answer as correct (TRUE) or incorrect (FALSE)
integer$orderA possible display order of the answer
double$pointsThe points for not selecting the answer (even negative points can be used) @access public
See also
$answers
ASS_AnswerBinaryStateImage

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

418 {
419 include_once "./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
420 if (array_key_exists($order, $this->answers)) {
421 // insert answer
422 $answer = new ASS_AnswerBinaryStateImage($answertext, $points, $order, 1, $answerimage);
423 $newchoices = array();
424 for ($i = 0; $i < $order; $i++) {
425 array_push($newchoices, $this->answers[$i]);
426 }
427 array_push($newchoices, $answer);
428 for ($i = $order; $i < count($this->answers); $i++) {
429 $changed = $this->answers[$i];
430 $changed->setOrder($i+1);
431 array_push($newchoices, $changed);
432 }
433 $this->answers = $newchoices;
434 } else {
435 // add answer
436 $answer = new ASS_AnswerBinaryStateImage($answertext, $points, count($this->answers), 1, $answerimage);
437 array_push($this->answers, $answer);
438 }
439 }
Class for answers with a binary state indicator.
$i
Definition: disco.tpl.php:19

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

◆ afterSyncWithOriginal()

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

{}

Reimplemented from assQuestion.

Definition at line 1236 of file class.assSingleChoice.php.

1237 {
1238 parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
1239
1240 $origImagePath = $this->buildImagePath($origQuestionId, $origParentObjId);
1241 $dupImagePath = $this->buildImagePath($dupQuestionId, $dupParentObjId);
1242
1243 ilUtil::delDir($origImagePath);
1244 if (is_dir($dupImagePath)) {
1245 ilUtil::makeDirParents($origImagePath);
1246 ilUtil::rCopy($dupImagePath, $origImagePath);
1247 }
1248 }
buildImagePath($questionId, $parentObjectId)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static makeDirParents($a_dir)
Create a new directory and all parent directories.

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

+ Here is the call graph for this function:

◆ calculateReachedPoints()

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

@access public

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

Reimplemented from assQuestion.

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

548 {
549 if ($returndetails) {
550 throw new ilTestException('return details not implemented for ' . __METHOD__);
551 }
552
553 global $ilDB;
554
555 $found_values = array();
556 if (is_null($pass)) {
557 $pass = $this->getSolutionMaxPass($active_id);
558 }
559 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
560 while ($data = $ilDB->fetchAssoc($result)) {
561 if (strcmp($data["value1"], "") != 0) {
562 array_push($found_values, $data["value1"]);
563 }
564 }
565 $points = 0;
566 foreach ($this->answers as $key => $answer) {
567 if (count($found_values) > 0) {
568 if (in_array($key, $found_values)) {
569 $points += $answer->getPoints();
570 }
571 }
572 }
573
574 return $points;
575 }
$result
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.
$key
Definition: croninfo.php:18
global $ilDB

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

+ Here is the call graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assSingleChoice::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

Reimplemented from assQuestion.

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

578 {
579 $participantSolution = $previewSession->getParticipantsSolution();
580
581 $points = 0;
582
583 foreach ($this->answers as $key => $answer) {
584 if (is_numeric($participantSolution) && $key == $participantSolution) {
585 $points = $answer->getPoints();
586 }
587 }
588
589 $reachedPoints = $this->deductHintPointsFromReachedPoints($previewSession, $points);
590
591 return $this->ensureNonNegativePoints($reachedPoints);
592 }
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
ensureNonNegativePoints($points)

References $key, assQuestion\$points, assQuestion\deductHintPointsFromReachedPoints(), assQuestion\ensureNonNegativePoints(), and ilAssQuestionPreviewSession\getParticipantsSolution().

+ Here is the call graph for this function:

◆ copyObject()

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

Copies an assSingleChoice object.

@access public

Definition at line 312 of file class.assSingleChoice.php.

313 {
314 if ($this->id <= 0) {
315 // The question has not been saved. It cannot be duplicated
316 return;
317 }
318 // duplicate the question in database
319 $clone = $this;
320 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
322 $clone->id = -1;
323 $source_questionpool_id = $this->getObjId();
324 $clone->setObjId($target_questionpool_id);
325 if ($title) {
326 $clone->setTitle($title);
327 }
328 $clone->saveToDb();
329 // copy question page content
330 $clone->copyPageOfQuestion($original_id);
331 // copy XHTML media objects
332 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
333 // duplicate the image
334 $clone->copyImages($original_id, $source_questionpool_id);
335
336 $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
337
338 return $clone->id;
339 }
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()

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

Definition at line 341 of file class.assSingleChoice.php.

342 {
343 if ($this->id <= 0) {
344 // The question has not been saved. It cannot be duplicated
345 return;
346 }
347
348 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
349
350 $sourceQuestionId = $this->id;
351 $sourceParentId = $this->getObjId();
352
353 // duplicate the question in database
354 $clone = $this;
355 $clone->id = -1;
356
357 $clone->setObjId($targetParentId);
358
359 if ($targetQuestionTitle) {
360 $clone->setTitle($targetQuestionTitle);
361 }
362
363 $clone->saveToDb();
364 // copy question page content
365 $clone->copyPageOfQuestion($sourceQuestionId);
366 // copy XHTML media objects
367 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
368 // duplicate the image
369 $clone->copyImages($sourceQuestionId, $sourceParentId);
370
371 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
372
373 return $clone->id;
374 }

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

+ Here is the call graph for this function:

◆ createRandomSolution()

assSingleChoice::createRandomSolution (   $active_id,
  $pass 
)

Reimplemented from assQuestion.

Definition at line 1050 of file class.assSingleChoice.php.

1051 {
1052 $value = rand(0, count($this->answers)-1);
1053 $_POST["multiple_choice_result"] = (strlen($value)) ? (string) $value : '0';
1054 $this->saveWorkingData($active_id, $pass);
1055 $this->calculateResultsFromSolution($active_id, $pass);
1056 }
$_POST["username"]
calculateResultsFromSolution($active_id, $pass=null, $obligationsEnabled=false)
Calculates the question results from a previously saved question solution.
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.

References $_POST, $pass, assQuestion\calculateResultsFromSolution(), and saveWorkingData().

+ Here is the call graph for this function:

◆ deleteAnswer()

assSingleChoice::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 @access public
See also
$answers

Definition at line 485 of file class.assSingleChoice.php.

486 {
487 if ($index < 0) {
488 return;
489 }
490 if (count($this->answers) < 1) {
491 return;
492 }
493 if ($index >= count($this->answers)) {
494 return;
495 }
496 $answer = $this->answers[$index];
497 if (strlen($answer->getImage())) {
498 $this->deleteImage($answer->getImage());
499 }
500 unset($this->answers[$index]);
501 $this->answers = array_values($this->answers);
502 for ($i = 0; $i < count($this->answers); $i++) {
503 if ($this->answers[$i]->getOrder() > $index) {
504 $this->answers[$i]->setOrder($i);
505 }
506 }
507 }
deleteImage($image_filename)
Deletes an image file.
$index
Definition: metadata.php:60

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

+ Here is the call graph for this function:

◆ deleteImage()

assSingleChoice::deleteImage (   $image_filename)

Deletes an image file.

Parameters
string$image_filenameName of the image file to delete @access private

Definition at line 802 of file class.assSingleChoice.php.

803 {
804 $imagepath = $this->getImagePath();
805 @unlink($imagepath . $image_filename);
806 $thumbpath = $imagepath . $this->getThumbPrefix() . $image_filename;
807 @unlink($thumbpath);
808 }
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.

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

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

Duplicates an assSingleChoiceQuestion.

@access public

Reimplemented from assQuestion.

Definition at line 259 of file class.assSingleChoice.php.

260 {
261 if ($this->id <= 0) {
262 // The question has not been saved. It cannot be duplicated
263 return;
264 }
265 // duplicate the question in database
266 $this_id = $this->getId();
267 $thisObjId = $this->getObjId();
268
269 $clone = $this;
270 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
272 $clone->id = -1;
273
274 if ((int) $testObjId > 0) {
275 $clone->setObjId($testObjId);
276 }
277
278 if ($title) {
279 $clone->setTitle($title);
280 }
281
282 if ($author) {
283 $clone->setAuthor($author);
284 }
285 if ($owner) {
286 $clone->setOwner($owner);
287 }
288 if ($for_test) {
289 $clone->saveToDb($original_id);
290 } else {
291 $clone->saveToDb();
292 }
293
294 // copy question page content
295 $clone->copyPageOfQuestion($this_id);
296
297 // copy XHTML media objects
298 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
299 // duplicate the images
300 $clone->duplicateImages($this_id, $thisObjId);
301
302 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
303
304 return $clone->id;
305 }
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:

◆ duplicateImages()

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

Definition at line 810 of file class.assSingleChoice.php.

811 {
812 global $ilLog;
813 $imagepath = $this->getImagePath();
814 $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
815
816 if ((int) $objectId > 0) {
817 $imagepath_original = str_replace("/$this->obj_id/", "/$objectId/", $imagepath_original);
818 }
819
820 foreach ($this->answers as $answer) {
821 $filename = $answer->getImage();
822 if (strlen($filename)) {
823 if (!file_exists($imagepath)) {
824 ilUtil::makeDirParents($imagepath);
825 }
826 if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
827 $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
828 $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
829 }
830 if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename)) {
831 if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
832 $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
833 $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
834 }
835 }
836 }
837 }
838 }

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

+ Here is the call graph for this function:

◆ flushAnswers()

assSingleChoice::flushAnswers ( )

Deletes all answers.

@access public

See also
$answers

Definition at line 515 of file class.assSingleChoice.php.

516 {
517 $this->answers = array();
518 }

◆ generateThumbForFile()

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

Definition at line 166 of file class.assSingleChoice.php.

167 {
169 if (@file_exists($filename)) {
170 $thumbpath = $path . $this->getThumbPrefix() . $file;
171 $path_info = @pathinfo($filename);
172 $ext = "";
173 switch (strtoupper($path_info['extension'])) {
174 case 'PNG':
175 $ext = 'PNG';
176 break;
177 case 'GIF':
178 $ext = 'GIF';
179 break;
180 default:
181 $ext = 'JPEG';
182 break;
183 }
184 ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbSize());
185 }
186 }
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

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

assSingleChoice::getAdditionalTableName ( )

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

Returns
string The additional table name @access public

Reimplemented from assQuestion.

Definition at line 743 of file class.assSingleChoice.php.

744 {
745 return "qpl_qst_sc";
746 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ getAnswer()

assSingleChoice::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 @access public
See also
$answers

Definition at line 462 of file class.assSingleChoice.php.

463 {
464 if ($index < 0) {
465 return null;
466 }
467 if (count($this->answers) < 1) {
468 return null;
469 }
470 if ($index >= count($this->answers)) {
471 return null;
472 }
473
474 return $this->answers[$index];
475 }

References $index.

Referenced by getAvailableAnswerOptions().

+ Here is the caller graph for this function:

◆ getAnswerCount()

assSingleChoice::getAnswerCount ( )

Returns the number of answers.

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

Definition at line 448 of file class.assSingleChoice.php.

449 {
450 return count($this->answers);
451 }

◆ getAnswers()

& assSingleChoice::getAnswers ( )

Returns a reference to the answers array.

Definition at line 939 of file class.assSingleChoice.php.

940 {
941 return $this->answers;
942 }

References $answers.

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

+ Here is the caller graph for this function:

◆ getAnswerTableName()

assSingleChoice::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name @access public

Reimplemented from assQuestion.

Definition at line 754 of file class.assSingleChoice.php.

755 {
756 return "qpl_a_sc";
757 }

◆ getAvailableAnswerOptions()

assSingleChoice::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 1224 of file class.assSingleChoice.php.

1225 {
1226 if ($index !== null) {
1227 return $this->getAnswer($index);
1228 } else {
1229 return $this->getAnswers();
1230 }
1231 }
& getAnswers()
Returns a reference to the answers array.
getAnswer($index=0)
Returns an answer with a given index.

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

+ Here is the call graph for this function:

◆ getExpressionTypes()

assSingleChoice::getExpressionTypes ( )

◆ getMaximumPoints()

assSingleChoice::getMaximumPoints ( )

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

@access public

See also
$points

Reimplemented from assQuestion.

Definition at line 526 of file class.assSingleChoice.php.

527 {
528 $points = 0;
529 foreach ($this->answers as $key => $value) {
530 if ($value->getPoints() > $points) {
531 $points = $value->getPoints();
532 }
533 }
534 return $points;
535 }

References $key, and assQuestion\$points.

Referenced by isComplete().

+ Here is the caller graph for this function:

◆ getMultilineAnswerSetting()

assSingleChoice::getMultilineAnswerSetting ( )

Definition at line 1058 of file class.assSingleChoice.php.

1059 {
1060 global $ilUser;
1061
1062 $multilineAnswerSetting = $ilUser->getPref("tst_multiline_answers");
1063 if ($multilineAnswerSetting != 1) {
1064 $multilineAnswerSetting = 0;
1065 }
1066 return $multilineAnswerSetting;
1067 }
$ilUser
Definition: imgupload.php:18

References $ilUser.

◆ getOperators()

assSingleChoice::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
string$expression

Implements iQuestionCondition.

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

1153 {
1154 require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1156 }

References ilOperatorsExpressionMapping\getOperatorsByExpression().

+ Here is the call graph for this function:

◆ getOutputType()

assSingleChoice::getOutputType ( )

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

Returns
integer The output type of the assSingleChoice object @access public
See also
$output_type

Reimplemented from assQuestion.

Definition at line 383 of file class.assSingleChoice.php.

384 {
385 return $this->output_type;
386 }

References $output_type.

◆ getQuestionType()

assSingleChoice::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question @access public

Reimplemented from assQuestion.

Definition at line 732 of file class.assSingleChoice.php.

733 {
734 return "assSingleChoice";
735 }

Referenced by toJSON().

+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assSingleChoice::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 925 of file class.assSingleChoice.php.

926 {
927 $text = parent::getRTETextWithMediaObjects();
928 foreach ($this->answers as $index => $answer) {
929 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->getId(), $index);
930 $answer_obj = $this->answers[$index];
931 $text .= $answer_obj->getAnswertext();
932 }
933 return $text;
934 }
$text
Definition: errorreport.php:18

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

+ Here is the call graph for this function:

◆ getSpecificFeedbackAllCorrectOptionLabel()

assSingleChoice::getSpecificFeedbackAllCorrectOptionLabel ( )

Implements ilAssSpecificFeedbackOptionLabelProvider.

Definition at line 1107 of file class.assSingleChoice.php.

1108 {
1109 return 'feedback_correct_sc_mc';
1110 }

◆ getSpecificFeedbackSetting()

assSingleChoice::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 1098 of file class.assSingleChoice.php.

1099 {
1100 if ($this->feedback_setting) {
1102 } else {
1103 return 1;
1104 }
1105 }

References $feedback_setting.

◆ getThumbPrefix()

assSingleChoice::getThumbPrefix ( )

Definition at line 161 of file class.assSingleChoice.php.

162 {
163 return "thumb.";
164 }

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

+ Here is the caller graph for this function:

◆ getThumbSize()

assSingleChoice::getThumbSize ( )

Definition at line 972 of file class.assSingleChoice.php.

973 {
974 return $this->thumb_size;
975 }

References $thumb_size.

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

+ Here is the caller graph for this function:

◆ isAnswered()

assSingleChoice::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 1122 of file class.assSingleChoice.php.

1123 {
1124 $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1125
1126 return $numExistingSolutionRecords > 0;
1127 }
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()

assSingleChoice::isComplete ( )

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

Returns
boolean True, if the single choice question is complete for use, otherwise false @access public

Reimplemented from assQuestion.

Definition at line 97 of file class.assSingleChoice.php.

98 {
99 if (strlen($this->title) and ($this->author) and ($this->question) and (count($this->answers)) and ($this->getMaximumPoints() > 0)) {
100 foreach ($this->answers as $answer) {
101 if ((strlen($answer->getAnswertext()) == 0) && (strlen($answer->getImage()) == 0)) {
102 return false;
103 }
104 }
105 return true;
106 } else {
107 return false;
108 }
109 }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.

References getMaximumPoints().

+ Here is the call graph for this function:

◆ isObligationPossible()

static assSingleChoice::isObligationPossible (   $questionId)
static

returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration

(overwrites method in class assQuestion)

Parameters
integer$questionId
Returns
boolean $obligationPossible

Reimplemented from assQuestion.

Definition at line 1139 of file class.assSingleChoice.php.

1140 {
1141 return true;
1142 }

◆ lmMigrateQuestionTypeSpecificContent()

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

Reimplemented from assQuestion.

Definition at line 985 of file class.assSingleChoice.php.

986 {
987 foreach ($this->getAnswers() as $answer) {
988 /* @var ASS_AnswerBinaryStateImage $answer */
989 $answer->setAnswertext($migrator->migrateToLmContent($answer->getAnswertext()));
990 }
991 }

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

+ Here is the call graph for this function:

◆ loadFromDb()

assSingleChoice::loadFromDb (   $question_id)

Loads a assSingleChoice object from a database.

Parameters
object$dbA pear DB object
integer$question_idA unique key which defines the multiple choice test in the database @access public

Reimplemented from assQuestion.

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

196 {
197 global $ilDB;
198
199 $hasimages = 0;
200
201 $result = $ilDB->queryF(
202 "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",
203 array("integer"),
204 array($question_id)
205 );
206 if ($result->numRows() == 1) {
207 $data = $ilDB->fetchAssoc($result);
208 $this->setId($question_id);
209 $this->setObjId($data["obj_fi"]);
210 $this->setTitle($data["title"]);
211 $this->setNrOfTries($data['nr_of_tries']);
212 $this->setComment($data["description"]);
213 $this->setOriginalId($data["original_id"]);
214 $this->setAuthor($data["author"]);
215 $this->setPoints($data["points"]);
216 $this->setOwner($data["owner"]);
217 include_once("./Services/RTE/classes/class.ilRTE.php");
218 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
219 $shuffle = (is_null($data['shuffle'])) ? true : $data['shuffle'];
220 $this->setShuffle($shuffle);
221 $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
222 $this->setThumbSize($data['thumb_size']);
223 $this->isSingleline = ($data['allow_images']) ? false : true;
224 $this->lastChange = $data['tstamp'];
225 $this->feedback_setting = $data['feedback_setting'];
226
227 try {
228 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
229 } catch (ilTestQuestionPoolException $e) {
230 }
231 }
232
233 $result = $ilDB->queryF(
234 "SELECT * FROM qpl_a_sc WHERE question_fi = %s ORDER BY aorder ASC",
235 array('integer'),
236 array($question_id)
237 );
238 include_once "./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
239 if ($result->numRows() > 0) {
240 while ($data = $ilDB->fetchAssoc($result)) {
241 $imagefilename = $this->getImagePath() . $data["imagefile"];
242 if (!@file_exists($imagefilename)) {
243 $data["imagefile"] = "";
244 }
245 include_once("./Services/RTE/classes/class.ilRTE.php");
246 $data["answertext"] = ilRTE::_replaceMediaObjectImageSrc($data["answertext"], 1);
247 array_push($this->answers, new ASS_AnswerBinaryStateImage($data["answertext"], $data["points"], $data["aorder"], 1, $data["imagefile"]));
248 }
249 }
250
251 parent::loadFromDb($question_id);
252 }
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.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
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()

assSingleChoice::rebuildThumbnails ( )
protected

Definition at line 150 of file class.assSingleChoice.php.

151 {
152 if ($this->isSingleline && ($this->getThumbSize())) {
153 foreach ($this->getAnswers() as $answer) {
154 if (strlen($answer->getImage())) {
155 $this->generateThumbForFile($this->getImagePath(), $answer->getImage());
156 }
157 }
158 }
159 }
generateThumbForFile($path, $file)

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

+ Here is the call graph for this function:

◆ removeAnswerImage()

assSingleChoice::removeAnswerImage (   $index)

Definition at line 1041 of file class.assSingleChoice.php.

1042 {
1043 $answer = $this->answers[$index];
1044 if (is_object($answer)) {
1045 $this->deleteImage($answer->getImage());
1046 $answer->setImage('');
1047 }
1048 }

References $index, and deleteImage().

+ Here is the call graph for this function:

◆ reworkWorkingData()

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

{Reworks the allready saved working data if neccessary.

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered
boolean$authorized
}

Reimplemented from assQuestion.

Definition at line 721 of file class.assSingleChoice.php.

722 {
723 // nothing to rework!
724 }

◆ savePreviewData()

assSingleChoice::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

Reimplemented from assQuestion.

Definition at line 649 of file class.assSingleChoice.php.

650 {
651 if (strlen($_POST['multiple_choice_result' . $this->getId() . 'ID'])) {
652 $previewSession->setParticipantsSolution($_POST['multiple_choice_result' . $this->getId() . 'ID']);
653 } else {
654 $previewSession->setParticipantsSolution(null);
655 }
656 }

References $_POST, assQuestion\getId(), and ilAssQuestionPreviewSession\setParticipantsSolution().

+ Here is the call graph for this function:

◆ saveWorkingData()

assSingleChoice::saveWorkingData (   $active_id,
  $pass = null,
  $authorized = true 
)

Saves the learners input of the question to the database.

@access public

Parameters
integer$active_idActive id of the user
integer$passTest pass
Returns
boolean $status

Reimplemented from assQuestion.

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

603 {
604 global $ilDB;
605 global $ilUser;
606
607 if (is_null($pass)) {
608 include_once "./Modules/Test/classes/class.ilObjTest.php";
609 $pass = ilObjTest::_getPass($active_id);
610 }
611
612 $entered_values = 0;
613
614 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $ilDB, $active_id, $pass, $authorized) {
615 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized);
616 $row = $ilDB->fetchAssoc($result);
617 $update = $row["solution_id"];
618
619 if ($update) {
620 if (strlen($_POST["multiple_choice_result"])) {
621 $this->updateCurrentSolution($update, $_POST["multiple_choice_result"], null, $authorized);
622 $entered_values++;
623 } else {
624 $this->removeSolutionRecordById($update);
625 }
626 } else {
627 if (strlen($_POST["multiple_choice_result"])) {
628 $this->saveCurrentSolution($active_id, $pass, $_POST['multiple_choice_result'], null, $authorized);
629 $entered_values++;
630 }
631 }
632 });
633
634 if ($entered_values) {
635 include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
637 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
638 }
639 } else {
640 include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
642 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
643 }
644 }
645
646 return true;
647 }
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
updateCurrentSolution($solutionId, $value1, $value2, $authorized=true)
removeSolutionRecordById($solutionId)
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.

References $_POST, $ilDB, $ilUser, $pass, $result, $row, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), assQuestion\getCurrentSolutionResultSet(), assQuestion\getProcessLocker(), assQuestion\logAction(), assQuestion\removeSolutionRecordById(), assQuestion\saveCurrentSolution(), and assQuestion\updateCurrentSolution().

Referenced by createRandomSolution().

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

◆ setExportDetailsXLS()

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

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

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

Reimplemented from assQuestion.

Definition at line 947 of file class.assSingleChoice.php.

948 {
949 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
950
951 $solution = $this->getSolutionValues($active_id, $pass);
952 $i = 1;
953 foreach ($this->getAnswers() as $id => $answer) {
954 $worksheet->setCell($startrow + $i, 0, $answer->getAnswertext());
955 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
956 if (
957 count($solution) > 0 &&
958 isset($solution[0]) &&
959 is_array($solution[0]) &&
960 strlen($solution[0]['value1']) > 0 && $id == $solution[0]['value1']
961 ) {
962 $worksheet->setCell($startrow + $i, 1, 1);
963 } else {
964 $worksheet->setCell($startrow + $i, 1, 0);
965 }
966 $i++;
967 }
968
969 return $startrow + $i + 1;
970 }
$worksheet
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.

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

+ Here is the call graph for this function:

◆ setImageFile()

assSingleChoice::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 @access public

Definition at line 767 of file class.assSingleChoice.php.

768 {
769 $result = 0;
770 if (!empty($image_tempfilename)) {
771 $image_filename = str_replace(" ", "_", $image_filename);
772 $imagepath = $this->getImagePath();
773 if (!file_exists($imagepath)) {
774 ilUtil::makeDirParents($imagepath);
775 }
776 //if (!move_uploaded_file($image_tempfilename, $imagepath . $image_filename))
777 if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $imagepath . $image_filename)) {
778 $result = 2;
779 } else {
780 include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
781 $mimetype = ilObjMediaObject::getMimeType($imagepath . $image_filename);
782 if (!preg_match("/^image/", $mimetype)) {
783 unlink($imagepath . $image_filename);
784 $result = 1;
785 } else {
786 // create thumbnail file
787 if ($this->isSingleline && ($this->getThumbSize())) {
788 $this->generateThumbForFile($imagepath, $image_filename);
789 }
790 }
791 }
792 }
793 return $result;
794 }
static getMimeType($a_file, $a_external=null)
get mime type for file

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

+ Here is the call graph for this function:

◆ setMultilineAnswerSetting()

assSingleChoice::setMultilineAnswerSetting (   $a_setting = 0)

Definition at line 1069 of file class.assSingleChoice.php.

1070 {
1071 global $ilUser;
1072 $ilUser->writePref("tst_multiline_answers", $a_setting);
1073 }

References $ilUser.

◆ setOutputType()

assSingleChoice::setOutputType (   $output_type = OUTPUT_ORDER)

Sets the output type of the assSingleChoice object.

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

Reimplemented from assQuestion.

Definition at line 395 of file class.assSingleChoice.php.

396 {
397 $this->output_type = $output_type;
398 }

References $output_type.

◆ setSpecificFeedbackSetting()

assSingleChoice::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 1084 of file class.assSingleChoice.php.

1085 {
1086 $this->feedback_setting = $a_feedback_setting;
1087 }

◆ setThumbSize()

assSingleChoice::setThumbSize (   $a_size)

Definition at line 977 of file class.assSingleChoice.php.

978 {
979 $this->thumb_size = $a_size;
980 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ syncImages()

assSingleChoice::syncImages ( )
protected

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

Definition at line 889 of file class.assSingleChoice.php.

890 {
891 global $ilLog;
892 $question_id = $this->getOriginalId();
893 $imagepath = $this->getImagePath();
894 $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
895 ilUtil::delDir($imagepath_original);
896 foreach ($this->answers as $answer) {
897 $filename = $answer->getImage();
898 if (strlen($filename)) {
899 if (@file_exists($imagepath . $filename)) {
900 if (!file_exists($imagepath)) {
901 ilUtil::makeDirParents($imagepath);
902 }
903 if (!file_exists($imagepath_original)) {
904 ilUtil::makeDirParents($imagepath_original);
905 }
906 if (!@copy($imagepath . $filename, $imagepath_original . $filename)) {
907 $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
908 $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
909 }
910 }
911 if (@file_exists($imagepath . $this->getThumbPrefix() . $filename)) {
912 if (!@copy($imagepath . $this->getThumbPrefix() . $filename, $imagepath_original . $this->getThumbPrefix() . $filename)) {
913 $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
914 $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
915 }
916 }
917 }
918 }
919 }

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

+ Here is the call graph for this function:

◆ toJSON()

assSingleChoice::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

Definition at line 996 of file class.assSingleChoice.php.

997 {
998 include_once("./Services/RTE/classes/class.ilRTE.php");
999 $result = array();
1000 $result['id'] = (int) $this->getId();
1001 $result['type'] = (string) $this->getQuestionType();
1002 $result['title'] = (string) $this->getTitle();
1003 $result['question'] = $this->formatSAQuestion($this->getQuestion());
1004 $result['nr_of_tries'] = (int) $this->getNrOfTries();
1005 $result['shuffle'] = (bool) $this->getShuffle();
1006
1007 $result['feedback'] = array(
1008 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1009 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1010 );
1011
1012 $answers = array();
1013 $has_image = false;
1014 foreach ($this->getAnswers() as $key => $answer_obj) {
1015 if ((string) $answer_obj->getImage()) {
1016 $has_image = true;
1017 }
1018 array_push($answers, array(
1019 "answertext" => (string) $this->formatSAQuestion($answer_obj->getAnswertext()),
1020 'html_id' => (int) $this->getId() . '_' . $key,
1021 "points" => (float) $answer_obj->getPoints(),
1022 "order" => (int) $answer_obj->getOrder(),
1023 "image" => (string) $answer_obj->getImage(),
1024 "feedback" => $this->formatSAQuestion(
1025 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key)
1026 )
1027 ));
1028 }
1029 $result['answers'] = $answers;
1030 if ($has_image) {
1031 $result['path'] = $this->getImagePathWeb();
1032 $result['thumb'] = $this->getThumbSize();
1033 }
1034
1035 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1036 $result['mobs'] = $mobs;
1037
1038 return json_encode($result);
1039 }
formatSAQuestion($a_q)
Format self assessment question.
getShuffle()
Gets the shuffle flag.
getTitle()
Gets the title string of the assQuestion object.
getQuestion()
Gets the question string of the question object.
getImagePathWeb()
Returns the web image path for web accessable images of a question.
getQuestionType()
Returns the question type of the question.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
$mobs

References $answers, $key, $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

assSingleChoice::$answers

Definition at line 34 of file class.assSingleChoice.php.

Referenced by getAnswers(), and toJSON().

◆ $feedback_setting

assSingleChoice::$feedback_setting
protected

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

Referenced by getSpecificFeedbackSetting().

◆ $output_type

assSingleChoice::$output_type

Definition at line 44 of file class.assSingleChoice.php.

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

◆ $thumb_size

assSingleChoice::$thumb_size
protected

Definition at line 51 of file class.assSingleChoice.php.

Referenced by getThumbSize().


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