ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)
 {} 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)
 
 isAddableAnswerOptionValue ($qIndex, $answerOptionValue)
 
 addAnswerOptionValue ($qIndex, $answerOptionValue, $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions ($activeId, $pass)
 
 resetUsersAnswer ($activeId, $pass)
 
 removeResultRecord ($activeId, $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered ($obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 Get the test question configuration (initialised once) More...
 
 savePartial ()
 
- Public Member Functions inherited from ilObjQuestionScoringAdjustable
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
- Public Member Functions inherited from ilObjAnswerScoringAdjustable
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 

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

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

Protected Attributes

 $thumb_size
 
 $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.

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

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  }

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

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

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

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

◆ afterSyncWithOriginal()

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

{}

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

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

1241  {
1242  parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
1243 
1244  $origImagePath = $this->buildImagePath($origQuestionId, $origParentObjId);
1245  $dupImagePath = $this->buildImagePath($dupQuestionId, $dupParentObjId);
1246 
1247  ilUtil::delDir($origImagePath);
1248  if (is_dir($dupImagePath)) {
1249  ilUtil::makeDirParents($origImagePath);
1250  ilUtil::rCopy($dupImagePath, $origImagePath);
1251  }
1252  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
buildImagePath($questionId, $parentObjectId)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

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

public

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

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

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

Referenced by getExpressionTypes().

550  {
551  if ($returndetails) {
552  throw new ilTestException('return details not implemented for ' . __METHOD__);
553  }
554 
555  global $DIC;
556  $ilDB = $DIC['ilDB'];
557 
558  $found_values = array();
559  if (is_null($pass)) {
560  $pass = $this->getSolutionMaxPass($active_id);
561  }
562  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
563  while ($data = $ilDB->fetchAssoc($result)) {
564  if (strcmp($data["value1"], "") != 0) {
565  array_push($found_values, $data["value1"]);
566  }
567  }
568  $points = 0;
569  foreach ($this->answers as $key => $answer) {
570  if (count($found_values) > 0) {
571  if (in_array($key, $found_values)) {
572  $points += $answer->getPoints();
573  }
574  }
575  }
576 
577  return $points;
578  }
$result
global $DIC
Definition: saml.php:7
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
global $ilDB
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
$key
Definition: croninfo.php:18
$data
Definition: bench.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assSingleChoice::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

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

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

581  {
582  $participantSolution = $previewSession->getParticipantsSolution();
583 
584  $points = 0;
585 
586  foreach ($this->answers as $key => $answer) {
587  if (is_numeric($participantSolution) && $key == $participantSolution) {
588  $points = $answer->getPoints();
589  }
590  }
591 
592  $reachedPoints = $this->deductHintPointsFromReachedPoints($previewSession, $points);
593 
594  return $this->ensureNonNegativePoints($reachedPoints);
595  }
ensureNonNegativePoints($points)
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ copyObject()

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

Copies an assSingleChoice object.

public

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

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

315  {
316  if ($this->id <= 0) {
317  // The question has not been saved. It cannot be duplicated
318  return;
319  }
320  // duplicate the question in database
321  $clone = $this;
322  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
324  $clone->id = -1;
325  $source_questionpool_id = $this->getObjId();
326  $clone->setObjId($target_questionpool_id);
327  if ($title) {
328  $clone->setTitle($title);
329  }
330  $clone->saveToDb();
331  // copy question page content
332  $clone->copyPageOfQuestion($original_id);
333  // copy XHTML media objects
334  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
335  // duplicate the image
336  $clone->copyImages($original_id, $source_questionpool_id);
337 
338  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
339 
340  return $clone->id;
341  }
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

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

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

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

◆ createRandomSolution()

assSingleChoice::createRandomSolution (   $active_id,
  $pass 
)

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

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

1052  {
1053  $value = rand(0, count($this->answers) - 1);
1054  $_POST["multiple_choice_result"] = (strlen($value)) ? (string) $value : '0';
1055  $this->saveWorkingData($active_id, $pass);
1056  $this->calculateResultsFromSolution($active_id, $pass);
1057  }
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.
$_POST["username"]
+ 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 public
See also
$answers

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

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

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

◆ deleteImage()

assSingleChoice::deleteImage (   $image_filename)

Deletes an image file.

Parameters
string$image_filenameName of the image file to delete private

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

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

Referenced by deleteAnswer(), and removeAnswerImage().

801  {
802  $imagepath = $this->getImagePath();
803  @unlink($imagepath . $image_filename);
804  $thumbpath = $imagepath . $this->getThumbPrefix() . $image_filename;
805  @unlink($thumbpath);
806  }
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duplicate()

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

Duplicates an assSingleChoiceQuestion.

public

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

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

262  {
263  if ($this->id <= 0) {
264  // The question has not been saved. It cannot be duplicated
265  return;
266  }
267  // duplicate the question in database
268  $this_id = $this->getId();
269  $thisObjId = $this->getObjId();
270 
271  $clone = $this;
272  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
274  $clone->id = -1;
275 
276  if ((int) $testObjId > 0) {
277  $clone->setObjId($testObjId);
278  }
279 
280  if ($title) {
281  $clone->setTitle($title);
282  }
283 
284  if ($author) {
285  $clone->setAuthor($author);
286  }
287  if ($owner) {
288  $clone->setOwner($owner);
289  }
290  if ($for_test) {
291  $clone->saveToDb($original_id);
292  } else {
293  $clone->saveToDb();
294  }
295 
296  // copy question page content
297  $clone->copyPageOfQuestion($this_id);
298 
299  // copy XHTML media objects
300  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
301  // duplicate the images
302  $clone->duplicateImages($this_id, $thisObjId);
303 
304  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
305 
306  return $clone->id;
307  }
getId()
Gets the id of the assQuestion object.
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ duplicateImages()

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

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

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

809  {
810  global $DIC;
811  $ilLog = $DIC['ilLog'];
812  $imagepath = $this->getImagePath();
813  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
814 
815  if ((int) $objectId > 0) {
816  $imagepath_original = str_replace("/$this->obj_id/", "/$objectId/", $imagepath_original);
817  }
818 
819  foreach ($this->answers as $answer) {
820  $filename = $answer->getImage();
821  if (strlen($filename)) {
822  if (!file_exists($imagepath)) {
823  ilUtil::makeDirParents($imagepath);
824  }
825  if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
826  $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
827  $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
828  }
829  if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename)) {
830  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
831  $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
832  $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
833  }
834  }
835  }
836  }
837  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
global $DIC
Definition: saml.php:7
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

◆ flushAnswers()

assSingleChoice::flushAnswers ( )

Deletes all answers.

public

See also
$answers

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

518  {
519  $this->answers = array();
520  }

◆ generateThumbForFile()

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

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

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

Referenced by rebuildThumbnails(), and setImageFile().

168  {
169  $filename = $path . $file;
170  if (@file_exists($filename)) {
171  $thumbpath = $path . $this->getThumbPrefix() . $file;
172  $path_info = @pathinfo($filename);
173  $ext = "";
174  switch (strtoupper($path_info['extension'])) {
175  case 'PNG':
176  $ext = 'PNG';
177  break;
178  case 'GIF':
179  $ext = 'GIF';
180  break;
181  default:
182  $ext = 'JPEG';
183  break;
184  }
185  ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbSize());
186  }
187  }
$path
Definition: aliased.php:25
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
$filename
Definition: buildRTE.php:89
+ 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 public

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

Referenced by isComplete(), loadFromDb(), and savePreviewData().

742  {
743  return "qpl_qst_sc";
744  }
+ 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 public
See also
$answers

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

References $index.

Referenced by getAvailableAnswerOptions().

465  {
466  if ($index < 0) {
467  return null;
468  }
469  if (count($this->answers) < 1) {
470  return null;
471  }
472  if ($index >= count($this->answers)) {
473  return null;
474  }
475 
476  return $this->answers[$index];
477  }
$index
Definition: metadata.php:60
+ 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 public
See also
$answers

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

451  {
452  return count($this->answers);
453  }

◆ getAnswers()

& assSingleChoice::getAnswers ( )

Returns a reference to the answers array.

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

References $answers.

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

941  {
942  return $this->answers;
943  }
+ 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 public

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

753  {
754  return "qpl_a_sc";
755  }

◆ 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 1228 of file class.assSingleChoice.php.

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

1229  {
1230  if ($index !== null) {
1231  return $this->getAnswer($index);
1232  } else {
1233  return $this->getAnswers();
1234  }
1235  }
& getAnswers()
Returns a reference to the answers array.
$index
Definition: metadata.php:60
getAnswer($index=0)
Returns an answer with a given index.
+ Here is the call graph for this function:

◆ getExpressionTypes()

◆ getMaximumPoints()

assSingleChoice::getMaximumPoints ( )

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

public

See also
$points

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

References $key, and assQuestion\$points.

Referenced by getExpressionTypes(), and isComplete().

529  {
530  $points = 0;
531  foreach ($this->answers as $key => $value) {
532  if ($value->getPoints() > $points) {
533  $points = $value->getPoints();
534  }
535  }
536  return $points;
537  }
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ getMultilineAnswerSetting()

assSingleChoice::getMultilineAnswerSetting ( )

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

References $DIC, and $ilUser.

1060  {
1061  global $DIC;
1062  $ilUser = $DIC['ilUser'];
1063 
1064  $multilineAnswerSetting = $ilUser->getPref("tst_multiline_answers");
1065  if ($multilineAnswerSetting != 1) {
1066  $multilineAnswerSetting = 0;
1067  }
1068  return $multilineAnswerSetting;
1069  }
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18

◆ getOperators()

assSingleChoice::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
string$expression

Implements iQuestionCondition.

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

References ilOperatorsExpressionMapping\getOperatorsByExpression().

1156  {
1157  require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1159  }
+ 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 public
See also
$output_type

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

References $output_type.

386  {
387  return $this->output_type;
388  }

◆ getQuestionType()

assSingleChoice::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

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

Referenced by toJSON().

731  {
732  return "assSingleChoice";
733  }
+ 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.

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

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

927  {
928  $text = parent::getRTETextWithMediaObjects();
929  foreach ($this->answers as $index => $answer) {
930  $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->getId(), 0, $index);
931  $answer_obj = $this->answers[$index];
932  $text .= $answer_obj->getAnswertext();
933  }
934  return $text;
935  }
getId()
Gets the id of the assQuestion object.
$index
Definition: metadata.php:60
$text
Definition: errorreport.php:18
+ Here is the call graph for this function:

◆ getSpecificFeedbackAllCorrectOptionLabel()

assSingleChoice::getSpecificFeedbackAllCorrectOptionLabel ( )

Implements ilAssSpecificFeedbackOptionLabelProvider.

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

1111  {
1112  return 'feedback_correct_sc_mc';
1113  }

◆ 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 1101 of file class.assSingleChoice.php.

References $feedback_setting.

Referenced by savePreviewData().

1102  {
1103  if ($this->feedback_setting) {
1104  return $this->feedback_setting;
1105  } else {
1106  return 1;
1107  }
1108  }
+ Here is the caller graph for this function:

◆ getThumbPrefix()

assSingleChoice::getThumbPrefix ( )

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

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

163  {
164  return "thumb.";
165  }
+ Here is the caller graph for this function:

◆ getThumbSize()

assSingleChoice::getThumbSize ( )

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

References $thumb_size.

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

974  {
975  return $this->thumb_size;
976  }
+ 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

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

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

1126  {
1127  $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1128 
1129  return $numExistingSolutionRecords > 0;
1130  }
getId()
Gets the id of the assQuestion object.
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
+ Here is the call graph for this function:

◆ isComplete()

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 public

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

References $data, $DIC, $ilDB, assQuestion\$original_id, $result, getAdditionalTableName(), assQuestion\getId(), getMaximumPoints(), getThumbSize(), ilObjQuestionScoringAdjustable\saveAdditionalQuestionDataToDb(), ilObjAnswerScoringAdjustable\saveAnswerSpecificDataToDb(), assQuestion\saveQuestionDataToDb(), and assQuestion\saveToDb().

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

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

1143  {
1144  return true;
1145  }

◆ lmMigrateQuestionTypeSpecificContent()

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

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

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

987  {
988  foreach ($this->getAnswers() as $answer) {
989  /* @var ASS_AnswerBinaryStateImage $answer */
990  $answer->setAnswertext($migrator->migrateToLmContent($answer->getAnswertext()));
991  }
992  }
& getAnswers()
Returns a reference to the answers array.
+ 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 public

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

References $data, $DIC, $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().

197  {
198  global $DIC;
199  $ilDB = $DIC['ilDB'];
200 
201  $hasimages = 0;
202 
203  $result = $ilDB->queryF(
204  "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",
205  array("integer"),
206  array($question_id)
207  );
208  if ($result->numRows() == 1) {
209  $data = $ilDB->fetchAssoc($result);
210  $this->setId($question_id);
211  $this->setObjId($data["obj_fi"]);
212  $this->setTitle($data["title"]);
213  $this->setNrOfTries($data['nr_of_tries']);
214  $this->setComment($data["description"]);
215  $this->setOriginalId($data["original_id"]);
216  $this->setAuthor($data["author"]);
217  $this->setPoints($data["points"]);
218  $this->setOwner($data["owner"]);
219  include_once("./Services/RTE/classes/class.ilRTE.php");
220  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
221  $shuffle = (is_null($data['shuffle'])) ? true : $data['shuffle'];
222  $this->setShuffle($shuffle);
223  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
224  $this->setThumbSize($data['thumb_size']);
225  $this->isSingleline = ($data['allow_images']) ? false : true;
226  $this->lastChange = $data['tstamp'];
227  $this->feedback_setting = $data['feedback_setting'];
228 
229  try {
230  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
231  } catch (ilTestQuestionPoolException $e) {
232  }
233  }
234 
235  $result = $ilDB->queryF(
236  "SELECT * FROM qpl_a_sc WHERE question_fi = %s ORDER BY aorder ASC",
237  array('integer'),
238  array($question_id)
239  );
240  include_once "./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
241  if ($result->numRows() > 0) {
242  while ($data = $ilDB->fetchAssoc($result)) {
243  $imagefilename = $this->getImagePath() . $data["imagefile"];
244  if (!@file_exists($imagefilename)) {
245  $data["imagefile"] = "";
246  }
247  include_once("./Services/RTE/classes/class.ilRTE.php");
248  $data["answertext"] = ilRTE::_replaceMediaObjectImageSrc($data["answertext"], 1);
249  array_push($this->answers, new ASS_AnswerBinaryStateImage($data["answertext"], $data["points"], $data["aorder"], 1, $data["imagefile"]));
250  }
251  }
252 
253  parent::loadFromDb($question_id);
254  }
$result
global $DIC
Definition: saml.php:7
Class for answers with a binary state indicator.
setId($id=-1)
Sets the id of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second. ...
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setShuffle($shuffle=true)
Sets the shuffle flag.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setAuthor($author="")
Sets the authors name of the assQuestion object.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setPoints($a_points)
Sets the maximum available points for the question.
setQuestion($question="")
Sets the question string of the question object.
global $ilDB
setOriginalId($original_id)
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setComment($comment="")
Sets the comment string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ rebuildThumbnails()

assSingleChoice::rebuildThumbnails ( )
protected

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

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

Referenced by savePreviewData().

152  {
153  if ($this->isSingleline && ($this->getThumbSize())) {
154  foreach ($this->getAnswers() as $answer) {
155  if (strlen($answer->getImage())) {
156  $this->generateThumbForFile($this->getImagePath(), $answer->getImage());
157  }
158  }
159  }
160  }
generateThumbForFile($path, $file)
& getAnswers()
Returns a reference to the answers array.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAnswerImage()

assSingleChoice::removeAnswerImage (   $index)

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

References $index, and deleteImage().

1043  {
1044  $answer = $this->answers[$index];
1045  if (is_object($answer)) {
1046  $this->deleteImage($answer->getImage());
1047  $answer->setImage('');
1048  }
1049  }
$index
Definition: metadata.php:60
deleteImage($image_filename)
Deletes an image file.
+ Here is the call graph for this function:

◆ savePreviewData()

assSingleChoice::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

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

References $_POST, $DIC, $ilDB, $key, ilRTE\_replaceMediaObjectImageSrc(), ilUtil\delDir(), getAdditionalTableName(), assQuestion\getId(), assQuestion\getImagePath(), assQuestion\getShuffle(), getSpecificFeedbackSetting(), getThumbSize(), rebuildThumbnails(), ilObjQuestionScoringAdjustable\saveAdditionalQuestionDataToDb(), ilObjAnswerScoringAdjustable\saveAnswerSpecificDataToDb(), and ilAssQuestionPreviewSession\setParticipantsSolution().

654  {
655  if (strlen($_POST['multiple_choice_result' . $this->getId() . 'ID'])) {
656  $previewSession->setParticipantsSolution($_POST['multiple_choice_result' . $this->getId() . 'ID']);
657  } else {
658  $previewSession->setParticipantsSolution(null);
659  }
660  }
getId()
Gets the id of the assQuestion object.
$_POST["username"]
+ 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.

public

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

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

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

Referenced by createRandomSolution().

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

◆ setExportDetailsXLS()

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

{}

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

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

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

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

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

766  {
767  $result = 0;
768  if (!empty($image_tempfilename)) {
769  $image_filename = str_replace(" ", "_", $image_filename);
770  $imagepath = $this->getImagePath();
771  if (!file_exists($imagepath)) {
772  ilUtil::makeDirParents($imagepath);
773  }
774  //if (!move_uploaded_file($image_tempfilename, $imagepath . $image_filename))
775  if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $imagepath . $image_filename)) {
776  $result = 2;
777  } else {
778  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
779  $mimetype = ilObjMediaObject::getMimeType($imagepath . $image_filename);
780  if (!preg_match("/^image/", $mimetype)) {
781  unlink($imagepath . $image_filename);
782  $result = 1;
783  } else {
784  // create thumbnail file
785  if ($this->isSingleline && ($this->getThumbSize())) {
786  $this->generateThumbForFile($imagepath, $image_filename);
787  }
788  }
789  }
790  }
791  return $result;
792  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
generateThumbForFile($path, $file)
static getMimeType($a_file, $a_external=null)
get mime type for file
$result
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
+ Here is the call graph for this function:

◆ setMultilineAnswerSetting()

assSingleChoice::setMultilineAnswerSetting (   $a_setting = 0)

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

References $DIC, and $ilUser.

1072  {
1073  global $DIC;
1074  $ilUser = $DIC['ilUser'];
1075  $ilUser->writePref("tst_multiline_answers", $a_setting);
1076  }
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18

◆ 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). public
See also
$response

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

References $output_type.

398  {
399  $this->output_type = $output_type;
400  }

◆ 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 1087 of file class.assSingleChoice.php.

1088  {
1089  $this->feedback_setting = $a_feedback_setting;
1090  }

◆ setThumbSize()

assSingleChoice::setThumbSize (   $a_size)

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

Referenced by loadFromDb().

979  {
980  $this->thumb_size = $a_size;
981  }
+ 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.

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

890  {
891  global $DIC;
892  $ilLog = $DIC['ilLog'];
893  $question_id = $this->getOriginalId();
894  $imagepath = $this->getImagePath();
895  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
896  ilUtil::delDir($imagepath_original);
897  foreach ($this->answers as $answer) {
898  $filename = $answer->getImage();
899  if (strlen($filename)) {
900  if (@file_exists($imagepath . $filename)) {
901  if (!file_exists($imagepath)) {
902  ilUtil::makeDirParents($imagepath);
903  }
904  if (!file_exists($imagepath_original)) {
905  ilUtil::makeDirParents($imagepath_original);
906  }
907  if (!@copy($imagepath . $filename, $imagepath_original . $filename)) {
908  $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
909  $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
910  }
911  }
912  if (@file_exists($imagepath . $this->getThumbPrefix() . $filename)) {
913  if (!@copy($imagepath . $this->getThumbPrefix() . $filename, $imagepath_original . $this->getThumbPrefix() . $filename)) {
914  $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
915  $ilLog->write("object: " . print_r($this, true), $ilLog->ERROR);
916  }
917  }
918  }
919  }
920  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
global $DIC
Definition: saml.php:7
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
$filename
Definition: buildRTE.php:89
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ toJSON()

assSingleChoice::toJSON ( )

Returns a JSON representation of the question.

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

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

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