ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assKprimChoice Class Reference
+ Inheritance diagram for assKprimChoice:
+ Collaboration diagram for assKprimChoice:

Public Member Functions

 __construct ($title='', $comment='', $author='', $owner=-1, $question='')
 assQuestion constructor 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...
 
 setShuffleAnswersEnabled ($shuffleAnswersEnabled)
 
 isShuffleAnswersEnabled ()
 
 setAnswerType ($answerType)
 
 getAnswerType ()
 
 setThumbSize ($thumbSize)
 
 getThumbSize ()
 
 setScorePartialSolutionEnabled ($scorePartialSolutionEnabled)
 
 isScorePartialSolutionEnabled ()
 
 setOptionLabel ($optionLabel)
 
 getOptionLabel ()
 
 setCustomTrueOptionLabel ($customTrueOptionLabel)
 
 getCustomTrueOptionLabel ()
 
 setCustomFalseOptionLabel ($customFalseOptionLabel)
 
 getCustomFalseOptionLabel ()
 
 setSpecificFeedbackSetting ($specificFeedbackSetting)
 
 getSpecificFeedbackSetting ()
 
 setAnswers ($answers)
 
 getAnswers ()
 
 getAnswer ($position)
 
 addAnswer (ilAssKprimChoiceAnswer $answer)
 
 loadFromDb ($questionId)
 Loads the question from the database. More...
 
 saveToDb ($originalId='')
 Saves the question to the database. More...
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 isComplete ()
 Returns true, if a question is complete for use. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 getValidAnswerTypes ()
 
 isValidAnswerType ($answerType)
 
 isSingleLineAnswerType ($answerType)
 
 getAnswerTypeSelectOptions (ilLanguage $lng)
 
 getValidOptionLabels ()
 
 getValidOptionLabelsTranslated (ilLanguage $lng)
 
 isValidOptionLabel ($optionLabel)
 
 getTrueOptionLabelTranslation (ilLanguage $lng, $optionLabel)
 
 getFalseOptionLabelTranslation (ilLanguage $lng, $optionLabel)
 
 getInstructionTextTranslation (ilLanguage $lng, $optionLabel)
 
 isCustomOptionLabel ($labelValue)
 
 getThumbPrefix ()
 
 rebuildThumbnails ()
 
 handleFileUploads ($answers, $files)
 
 removeAnswerImage ($position)
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assMultipleChoice object. More...
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getSpecificFeedbackAllCorrectOptionLabel ()
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not 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...
 
 moveAnswerDown ($position)
 
 moveAnswerUp ($position)
 
- 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 ()
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. 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

const NUM_REQUIRED_ANSWERS = 4
 
const PARTIAL_SCORING_NUM_CORRECT_ANSWERS = 3
 
const ANSWER_TYPE_SINGLE_LINE = 'singleLine'
 
const ANSWER_TYPE_MULTI_LINE = 'multiLine'
 
const OPTION_LABEL_RIGHT_WRONG = 'right_wrong'
 
const OPTION_LABEL_PLUS_MINUS = 'plus_minus'
 
const OPTION_LABEL_APPLICABLE_OR_NOT = 'applicable_or_not'
 
const OPTION_LABEL_ADEQUATE_OR_NOT = 'adequate_or_not'
 
const OPTION_LABEL_CUSTOM = 'customlabel'
 
const DEFAULT_THUMB_SIZE = 150
 
const THUMB_PREFIX = 'thumb.'
 
- 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 = ':'
 

Protected Member Functions

 generateThumbForFile ($path, $file)
 
 getSolutionSubmit ()
 
 calculateReachedPointsForSolution ($found_values, $active_id=0)
 
 beforeSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
- 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...
 

Private Member Functions

 loadAnswerData ($questionId)
 
 handleFileUpload (ilAssKprimChoiceAnswer $answer, $fileData)
 
 getNumAllowedFailures ()
 

Private Attributes

 $shuffleAnswersEnabled
 
 $answerType
 
 $thumbSize
 
 $scorePartialSolutionEnabled
 
 $optionLabel
 
 $customTrueOptionLabel
 
 $customFalseOptionLabel
 
 $specificFeedbackSetting
 
 $answers
 

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 ()
 
- 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
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $allowedImageMaterialFileExtensionsByMimeType
 
static $forcePassResultsUpdateEnabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

Definition at line 15 of file class.assKprimChoice.php.

Constructor & Destructor Documentation

◆ __construct()

assKprimChoice::__construct (   $title = '',
  $comment = '',
  $author = '',
  $owner = -1,
  $question = '' 
)

assQuestion constructor

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$questionQuestion text @access public

Reimplemented from assQuestion.

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

52 {
53 parent::__construct($title, $comment, $author, $owner, $question);
54
55 $this->shuffleAnswersEnabled = true;
56 $this->answerType = self::ANSWER_TYPE_SINGLE_LINE;
57 $this->thumbSize = self::DEFAULT_THUMB_SIZE;
58 $this->scorePartialSolutionEnabled = true;
59 $this->optionLabel = self::OPTION_LABEL_RIGHT_WRONG;
60 $this->customTrueOptionLabel = '';
61 $this->customFalseOptionLabel = '';
62
63 require_once 'Modules/TestQuestionPool/classes/feedback/class.ilAssConfigurableMultiOptionQuestionFeedback.php';
65
66 $this->answers = array();
67
68 $this->setPoints('');
69 }
setPoints($a_points)
Sets the maximum available points for the question.

References assQuestion\$author, assQuestion\$comment, assQuestion\$owner, assQuestion\$question, assQuestion\$title, ANSWER_TYPE_SINGLE_LINE, DEFAULT_THUMB_SIZE, ilAssConfigurableMultiOptionQuestionFeedback\FEEDBACK_SETTING_ALL, OPTION_LABEL_RIGHT_WRONG, and assQuestion\setPoints().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswer()

assKprimChoice::addAnswer ( ilAssKprimChoiceAnswer  $answer)

Definition at line 187 of file class.assKprimChoice.php.

188 {
189 $this->answers[] = $answer;
190 }

◆ afterSyncWithOriginal()

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

Reimplemented from assQuestion.

Definition at line 817 of file class.assKprimChoice.php.

818 {
819 parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
820
821 $this->cloneAnswerImages($dupQuestionId, $dupParentObjId, $origQuestionId, $origParentObjId);
822 }

◆ beforeSyncWithOriginal()

assKprimChoice::beforeSyncWithOriginal (   $origQuestionId,
  $dupQuestionId,
  $origParentObjId,
  $dupParentObjId 
)
protected

Reimplemented from assQuestion.

Definition at line 806 of file class.assKprimChoice.php.

807 {
808 parent::beforeSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
809
810 $question = self::_instanciateQuestion($origQuestionId);
811
812 foreach ($question->getAnswers() as $answer) {
813 $question->removeAnswerImage($answer->getPosition());
814 }
815 }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.

References assQuestion\$question, and assQuestion\_instanciateQuestion().

+ Here is the call graph for this function:

◆ calculateReachedPoints()

assKprimChoice::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 423 of file class.assKprimChoice.php.

424 {
425 if ($returndetails) {
426 throw new ilTestException('return details not implemented for ' . __METHOD__);
427 }
428
429 global $DIC;
430 $ilDB = $DIC['ilDB'];
431
432 $found_values = array();
433 if (is_null($pass)) {
434 $pass = $this->getSolutionMaxPass($active_id);
435 }
436
437 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
438
439 while ($data = $ilDB->fetchAssoc($result)) {
440 $found_values[(int) $data['value1']] = (int) $data['value2'];
441 }
442
443 $points = $this->calculateReachedPointsForSolution($found_values, $active_id);
444
445 return $points;
446 }
$result
calculateReachedPointsForSolution($found_values, $active_id=0)
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
global $DIC
Definition: saml.php:7
global $ilDB
$data
Definition: bench.php:6

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

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assKprimChoice::calculateReachedPointsForSolution (   $found_values,
  $active_id = 0 
)
protected

Definition at line 659 of file class.assKprimChoice.php.

660 {
661 $numCorrect = 0;
662
663 foreach ($this->getAnswers() as $key => $answer) {
664 if (!isset($found_values[$answer->getPosition()])) {
665 continue;
666 }
667
668 if ($found_values[$answer->getPosition()] == $answer->getCorrectness()) {
669 $numCorrect++;
670 }
671 }
672
673 if ($numCorrect >= self::NUM_REQUIRED_ANSWERS) {
674 $points = $this->getPoints();
675 } elseif ($this->isScorePartialSolutionEnabled() && $numCorrect >= self::PARTIAL_SCORING_NUM_CORRECT_ANSWERS) {
676 $points = $this->getPoints() / 2;
677 } else {
678 $points = 0;
679 }
680
681 if ($active_id) {
682 include_once "./Modules/Test/classes/class.ilObjTest.php";
683 $mc_scoring = ilObjTest::_getMCScoring($active_id);
684 if (($mc_scoring == 0) && (count($found_values) == 0)) {
685 $points = 0;
686 }
687 }
688 return $points;
689 }
getPoints()
Returns the maximum available points for the question.
static _getMCScoring($active_id)
Gets the scoring type for multiple choice questions.
$key
Definition: croninfo.php:18

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

Referenced by calculateReachedPoints().

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

◆ copyObject()

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

Copies an assMultipleChoice object.

Definition at line 777 of file class.assKprimChoice.php.

778 {
779 if ($this->id <= 0) {
780 // The question has not been saved. It cannot be duplicated
781 return;
782 }
783 // duplicate the question in database
784 $clone = $this;
785 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
787 $clone->id = -1;
788 $source_questionpool_id = $this->getObjId();
789 $clone->setObjId($target_questionpool_id);
790 if ($title) {
791 $clone->setTitle($title);
792 }
793 $clone->saveToDb();
794 // copy question page content
795 $clone->copyPageOfQuestion($original_id);
796 // copy XHTML media objects
797 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
798 // duplicate the image
799 $clone->cloneAnswerImages($original_id, $source_questionpool_id, $clone->getId(), $clone->getObjId());
800
801 $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
802
803 return $clone->id;
804 }
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()

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

Definition at line 739 of file class.assKprimChoice.php.

740 {
741 if ($this->id <= 0) {
742 // The question has not been saved. It cannot be duplicated
743 return;
744 }
745
746 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
747
748 $sourceQuestionId = $this->id;
749 $sourceParentId = $this->getObjId();
750
751 // duplicate the question in database
752 $clone = $this;
753 $clone->id = -1;
754
755 $clone->setObjId($targetParentId);
756
757 if ($targetQuestionTitle) {
758 $clone->setTitle($targetQuestionTitle);
759 }
760
761 $clone->saveToDb();
762 // copy question page content
763 $clone->copyPageOfQuestion($sourceQuestionId);
764 // copy XHTML media objects
765 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
766 // duplicate the image
767 $clone->cloneAnswerImages($sourceQuestionId, $sourceParentId, $clone->getId(), $clone->getObjId());
768
769 $clone->onCopy($sourceParentId, $sourceQuestionId, $targetParentId, $clone->getId());
770
771 return $clone->id;
772 }

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

+ Here is the call graph for this function:

◆ duplicate()

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

Reimplemented from assQuestion.

Definition at line 691 of file class.assKprimChoice.php.

692 {
693 if ($this->id <= 0) {
694 // The question has not been saved. It cannot be duplicated
695 return;
696 }
697 // duplicate the question in database
698 $this_id = $this->getId();
699 $thisObjId = $this->getObjId();
700
701 $clone = $this;
702 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
704 $clone->id = -1;
705
706 if ((int) $testObjId > 0) {
707 $clone->setObjId($testObjId);
708 }
709
710 if ($title) {
711 $clone->setTitle($title);
712 }
713
714 if ($author) {
715 $clone->setAuthor($author);
716 }
717 if ($owner) {
718 $clone->setOwner($owner);
719 }
720
721 if ($for_test) {
722 $clone->saveToDb($original_id);
723 } else {
724 $clone->saveToDb();
725 }
726
727 // copy question page content
728 $clone->copyPageOfQuestion($this_id);
729 // copy XHTML media objects
730 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
731 // duplicate the images
732 $clone->cloneAnswerImages($this_id, $thisObjId, $clone->getId(), $clone->getObjId());
733
734 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
735
736 return $clone->id;
737 }
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:

◆ generateThumbForFile()

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

Definition at line 574 of file class.assKprimChoice.php.

575 {
576 $filename = $path . $file;
577 if (@file_exists($filename)) {
578 $thumbpath = $path . $this->getThumbPrefix() . $file;
579 $path_info = @pathinfo($filename);
580 $ext = "";
581 switch (strtoupper($path_info['extension'])) {
582 case 'PNG':
583 $ext = 'PNG';
584 break;
585 case 'GIF':
586 $ext = 'GIF';
587 break;
588 default:
589 $ext = 'JPEG';
590 break;
591 }
592 ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbSize());
593 }
594 }
$path
Definition: aliased.php:25
$filename
Definition: buildRTE.php:89
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image

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

Referenced by rebuildThumbnails().

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

◆ getAdditionalTableName()

assKprimChoice::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 76 of file class.assKprimChoice.php.

77 {
78 return "qpl_qst_kprim";
79 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAnswer()

assKprimChoice::getAnswer (   $position)

Definition at line 176 of file class.assKprimChoice.php.

177 {
178 foreach ($this->getAnswers() as $answer) {
179 if ($answer->getPosition() == $position) {
180 return $answer;
181 }
182 }
183
184 return null;
185 }

References getAnswers().

Referenced by removeAnswerImage().

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

◆ getAnswers()

assKprimChoice::getAnswers ( )

◆ getAnswerTableName()

assKprimChoice::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 81 of file class.assKprimChoice.php.

82 {
83 return "qpl_a_kprim";
84 }

Referenced by saveAnswerSpecificDataToDb().

+ Here is the caller graph for this function:

◆ getAnswerType()

assKprimChoice::getAnswerType ( )

Definition at line 101 of file class.assKprimChoice.php.

102 {
103 return $this->answerType;
104 }

References $answerType.

Referenced by rebuildThumbnails(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAnswerTypeSelectOptions()

assKprimChoice::getAnswerTypeSelectOptions ( ilLanguage  $lng)
Parameters
ilLanguage$lng
Returns
array

Definition at line 468 of file class.assKprimChoice.php.

469 {
470 return array(
471 self::ANSWER_TYPE_SINGLE_LINE => $lng->txt('answers_singleline'),
472 self::ANSWER_TYPE_MULTI_LINE => $lng->txt('answers_multiline')
473 );
474 }

References assQuestion\$lng.

◆ getCustomFalseOptionLabel()

assKprimChoice::getCustomFalseOptionLabel ( )

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

References $customFalseOptionLabel.

Referenced by getFalseOptionLabelTranslation(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getCustomTrueOptionLabel()

assKprimChoice::getCustomTrueOptionLabel ( )

Definition at line 141 of file class.assKprimChoice.php.

References $customTrueOptionLabel.

Referenced by getTrueOptionLabelTranslation(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getFalseOptionLabelTranslation()

assKprimChoice::getFalseOptionLabelTranslation ( ilLanguage  $lng,
  $optionLabel 
)

Definition at line 524 of file class.assKprimChoice.php.

525 {
526 switch ($optionLabel) {
528 return $lng->txt('option_label_wrong');
529
531 return $lng->txt('option_label_minus');
532
534 return $lng->txt('option_label_not_applicable');
535
537 return $lng->txt('option_label_not_adequate');
538
540 return $this->getCustomFalseOptionLabel();
541 }
542 }
const OPTION_LABEL_APPLICABLE_OR_NOT

References assQuestion\$lng, $optionLabel, getCustomFalseOptionLabel(), OPTION_LABEL_ADEQUATE_OR_NOT, OPTION_LABEL_APPLICABLE_OR_NOT, OPTION_LABEL_CUSTOM, OPTION_LABEL_PLUS_MINUS, and OPTION_LABEL_RIGHT_WRONG.

Referenced by toJSON().

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

◆ getInstructionTextTranslation()

assKprimChoice::getInstructionTextTranslation ( ilLanguage  $lng,
  $optionLabel 
)

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

545 {
546 return sprintf(
547 $lng->txt('kprim_instruction_text'),
548 $this->getTrueOptionLabelTranslation($lng, $optionLabel),
549 $this->getFalseOptionLabelTranslation($lng, $optionLabel)
550 );
551 }

References assQuestion\$lng, and $optionLabel.

Referenced by toJSON().

+ Here is the caller graph for this function:

◆ getNumAllowedFailures()

assKprimChoice::getNumAllowedFailures ( )
private

Definition at line 955 of file class.assKprimChoice.php.

956 {
957 if ($this->isScorePartialSolutionEnabled()) {
958 return self::NUM_REQUIRED_ANSWERS - self::PARTIAL_SCORING_NUM_CORRECT_ANSWERS;
959 }
960
961 return 0;
962 }
const PARTIAL_SCORING_NUM_CORRECT_ANSWERS

References isScorePartialSolutionEnabled(), and PARTIAL_SCORING_NUM_CORRECT_ANSWERS.

Referenced by toJSON().

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

◆ getOptionLabel()

assKprimChoice::getOptionLabel ( )

Definition at line 131 of file class.assKprimChoice.php.

132 {
133 return $this->optionLabel;
134 }

References $optionLabel.

Referenced by saveAdditionalQuestionDataToDb(), and toJSON().

+ Here is the caller graph for this function:

◆ getQuestionType()

assKprimChoice::getQuestionType ( )

Returns the question type of the question.

Returns
string The question type of the question

Reimplemented from assQuestion.

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

72 {
73 return 'assKprimChoice';
74 }

Referenced by toJSON().

+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assKprimChoice::getRTETextWithMediaObjects ( )
protected

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 872 of file class.assKprimChoice.php.

873 {
874 $combinedText = parent::getRTETextWithMediaObjects();
875
876 foreach ($this->getAnswers() as $answer) {
877 $combinedText .= $answer->getAnswertext();
878 }
879
880 return $combinedText;
881 }

References getAnswers().

+ Here is the call graph for this function:

◆ getSolutionSubmit()

assKprimChoice::getSolutionSubmit ( )
protected

Definition at line 644 of file class.assKprimChoice.php.

645 {
646 $solutionSubmit = array();
647 foreach ($_POST as $key => $value) {
648 $matches = null;
649
650 if (preg_match("/^kprim_choice_result_(\d+)/", $key, $matches)) {
651 if (strlen($value)) {
652 $solutionSubmit[$matches[1]] = $value;
653 }
654 }
655 }
656 return $solutionSubmit;
657 }
$_POST["username"]

References $_POST, and $key.

◆ getSpecificFeedbackAllCorrectOptionLabel()

assKprimChoice::getSpecificFeedbackAllCorrectOptionLabel ( )

Implements ilAssSpecificFeedbackOptionLabelProvider.

Definition at line 964 of file class.assKprimChoice.php.

965 {
966 return 'feedback_correct_kprim';
967 }

◆ getSpecificFeedbackSetting()

assKprimChoice::getSpecificFeedbackSetting ( )

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

References $specificFeedbackSetting.

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getThumbPrefix()

assKprimChoice::getThumbPrefix ( )

Definition at line 558 of file class.assKprimChoice.php.

559 {
560 return self::THUMB_PREFIX;
561 }

References THUMB_PREFIX.

Referenced by generateThumbForFile(), and loadAnswerData().

+ Here is the caller graph for this function:

◆ getThumbSize()

assKprimChoice::getThumbSize ( )

Definition at line 111 of file class.assKprimChoice.php.

112 {
113 return $this->thumbSize;
114 }

References $thumbSize.

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

+ Here is the caller graph for this function:

◆ getTrueOptionLabelTranslation()

assKprimChoice::getTrueOptionLabelTranslation ( ilLanguage  $lng,
  $optionLabel 
)

Definition at line 504 of file class.assKprimChoice.php.

505 {
506 switch ($optionLabel) {
508 return $lng->txt('option_label_right');
509
511 return $lng->txt('option_label_plus');
512
514 return $lng->txt('option_label_applicable');
515
517 return $lng->txt('option_label_adequate');
518
520 return $this->getCustomTrueOptionLabel();
521 }
522 }

References assQuestion\$lng, $optionLabel, getCustomTrueOptionLabel(), OPTION_LABEL_ADEQUATE_OR_NOT, OPTION_LABEL_APPLICABLE_OR_NOT, OPTION_LABEL_CUSTOM, OPTION_LABEL_PLUS_MINUS, and OPTION_LABEL_RIGHT_WRONG.

Referenced by toJSON().

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

◆ getValidAnswerTypes()

assKprimChoice::getValidAnswerTypes ( )

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

449 {
450 return array(self::ANSWER_TYPE_SINGLE_LINE, self::ANSWER_TYPE_MULTI_LINE);
451 }

Referenced by isValidAnswerType().

+ Here is the caller graph for this function:

◆ getValidOptionLabels()

assKprimChoice::getValidOptionLabels ( )

Definition at line 476 of file class.assKprimChoice.php.

477 {
478 return array(
479 self::OPTION_LABEL_RIGHT_WRONG,
480 self::OPTION_LABEL_PLUS_MINUS,
481 self::OPTION_LABEL_APPLICABLE_OR_NOT,
482 self::OPTION_LABEL_ADEQUATE_OR_NOT,
483 self::OPTION_LABEL_CUSTOM
484 );
485 }

Referenced by isValidOptionLabel().

+ Here is the caller graph for this function:

◆ getValidOptionLabelsTranslated()

assKprimChoice::getValidOptionLabelsTranslated ( ilLanguage  $lng)

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

488 {
489 return array(
490 self::OPTION_LABEL_RIGHT_WRONG => $lng->txt('option_label_right_wrong'),
491 self::OPTION_LABEL_PLUS_MINUS => $lng->txt('option_label_plus_minus'),
492 self::OPTION_LABEL_APPLICABLE_OR_NOT => $lng->txt('option_label_applicable_or_not'),
493 self::OPTION_LABEL_ADEQUATE_OR_NOT => $lng->txt('option_label_adequate_or_not'),
494 self::OPTION_LABEL_CUSTOM => $lng->txt('option_label_custom')
495 );
496 }

References assQuestion\$lng.

◆ handleFileUpload()

assKprimChoice::handleFileUpload ( ilAssKprimChoiceAnswer  $answer,
  $fileData 
)
private

Definition at line 609 of file class.assKprimChoice.php.

610 {
611 $imagePath = $this->getImagePath();
612
613 if (!file_exists($imagePath)) {
614 ilUtil::makeDirParents($imagePath);
615 }
616
617 $filename = $this->buildHashedImageFilename($fileData['name'], true);
618
619 $answer->setImageFsDir($imagePath);
620 $answer->setImageFile($filename);
621
622 if (!ilUtil::moveUploadedFile($fileData['tmp_name'], $fileData['name'], $answer->getImageFsPath())) {
623 return 2;
624 }
625
626 return 0;
627 }
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
buildHashedImageFilename($plain_image_filename, $unique=false)
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References $filename, assQuestion\buildHashedImageFilename(), ilAssKprimChoiceAnswer\getImageFsPath(), assQuestion\getImagePath(), ilUtil\makeDirParents(), ilAssKprimChoiceAnswer\setImageFile(), and ilAssKprimChoiceAnswer\setImageFsDir().

Referenced by handleFileUploads().

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

◆ handleFileUploads()

assKprimChoice::handleFileUploads (   $answers,
  $files 
)

Definition at line 596 of file class.assKprimChoice.php.

597 {
598 foreach ($answers as $answer) {
599 /* @var ilAssKprimChoiceAnswer $answer */
600
601 if (!isset($files[$answer->getPosition()])) {
602 continue;
603 }
604
605 $this->handleFileUpload($answer, $files[$answer->getPosition()]);
606 }
607 }
handleFileUpload(ilAssKprimChoiceAnswer $answer, $fileData)
$files
Definition: metarefresh.php:49

References $answers, $files, and handleFileUpload().

+ Here is the call graph for this function:

◆ isAnswered()

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

returns boolean wether the question is answered during test pass or not

method can be overwritten in derived classes, but be aware of also overwrite the method assQuestion::isObligationPossible()

Parameters
integer$active_id
integer$pass
Returns
boolean $answered

Reimplemented from assQuestion.

Definition at line 974 of file class.assKprimChoice.php.

975 {
976 $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
977
978 return $numExistingSolutionRecords >= 4;
979 }
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()

assKprimChoice::isComplete ( )

Returns true, if a question is complete for use.

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

Reimplemented from assQuestion.

Definition at line 340 of file class.assKprimChoice.php.

341 {
342 foreach (array($this->title, $this->author, $this->question) as $text) {
343 if (!strlen($text)) {
344 return false;
345 }
346 }
347
348 if ($this->getMaximumPoints() <= 0) {
349 return false;
350 }
351
352 foreach ($this->getAnswers() as $answer) {
353 /* @var ilAssKprimChoiceAnswer $answer */
354
355 if (is_null($answer->getCorrectness())) {
356 return false;
357 }
358
359 if (!strlen($answer->getAnswertext()) && !strlen($answer->getImageFile())) {
360 return false;
361 }
362 }
363
364 return true;
365 }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
$text
Definition: errorreport.php:18

References $text, getAnswers(), and assQuestion\getMaximumPoints().

+ Here is the call graph for this function:

◆ isCustomOptionLabel()

assKprimChoice::isCustomOptionLabel (   $labelValue)

Definition at line 553 of file class.assKprimChoice.php.

554 {
555 return $labelValue == self::OPTION_LABEL_CUSTOM;
556 }

References OPTION_LABEL_CUSTOM.

◆ isObligationPossible()

static assKprimChoice::isObligationPossible (   $questionId)
static

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

method can be overwritten in derived classes, but be aware of also overwrite the method assQuestion::isAnswered()

Parameters
integer$questionId
Returns
boolean $obligationPossible

Reimplemented from assQuestion.

Definition at line 969 of file class.assKprimChoice.php.

970 {
971 return true;
972 }

◆ isScorePartialSolutionEnabled()

assKprimChoice::isScorePartialSolutionEnabled ( )

Definition at line 121 of file class.assKprimChoice.php.

References $scorePartialSolutionEnabled.

Referenced by calculateReachedPointsForSolution(), getNumAllowedFailures(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ isShuffleAnswersEnabled()

assKprimChoice::isShuffleAnswersEnabled ( )

Definition at line 91 of file class.assKprimChoice.php.

References $shuffleAnswersEnabled.

Referenced by saveAdditionalQuestionDataToDb(), and toJSON().

+ Here is the caller graph for this function:

◆ isSingleLineAnswerType()

assKprimChoice::isSingleLineAnswerType (   $answerType)

Definition at line 459 of file class.assKprimChoice.php.

References $answerType, and ANSWER_TYPE_SINGLE_LINE.

Referenced by rebuildThumbnails().

+ Here is the caller graph for this function:

◆ isValidAnswerType()

assKprimChoice::isValidAnswerType (   $answerType)

Definition at line 453 of file class.assKprimChoice.php.

454 {
455 $validTypes = $this->getValidAnswerTypes();
456 return in_array($answerType, $validTypes);
457 }

References $answerType, and getValidAnswerTypes().

Referenced by loadFromDb().

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

◆ isValidOptionLabel()

assKprimChoice::isValidOptionLabel (   $optionLabel)

Definition at line 498 of file class.assKprimChoice.php.

499 {
500 $validLabels = $this->getValidOptionLabels();
501 return in_array($optionLabel, $validLabels);
502 }

References $optionLabel, and getValidOptionLabels().

Referenced by loadFromDb().

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

◆ lmMigrateQuestionTypeSpecificContent()

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

Reimplemented from assQuestion.

Definition at line 886 of file class.assKprimChoice.php.

887 {
888 foreach ($this->getAnswers() as $answer) {
889 /* @var ilAssKprimChoiceAnswer $answer */
890 $answer->setAnswertext($migrator->migrateToLmContent($answer->getAnswertext()));
891 }
892 }

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

+ Here is the call graph for this function:

◆ loadAnswerData()

assKprimChoice::loadAnswerData (   $questionId)
private

Definition at line 250 of file class.assKprimChoice.php.

251 {
252 global $DIC;
253 $ilDB = $DIC['ilDB'];
254
255 $res = $this->db->queryF(
256 "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY position ASC",
257 array('integer'),
258 array($questionId)
259 );
260
261 require_once 'Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
262 require_once 'Services/RTE/classes/class.ilRTE.php';
263
264 while ($data = $ilDB->fetchAssoc($res)) {
265 $answer = new ilAssKprimChoiceAnswer();
266
267 $answer->setPosition($data['position']);
268
269 $answer->setAnswertext(ilRTE::_replaceMediaObjectImageSrc($data['answertext'], 1));
270
271 $answer->setImageFile($data['imagefile']);
272 $answer->setThumbPrefix($this->getThumbPrefix());
273 $answer->setImageFsDir($this->getImagePath());
274 $answer->setImageWebDir($this->getImagePathWeb());
275
276 $answer->setCorrectness($data['correctness']);
277
278 $this->answers[$answer->getPosition()] = $answer;
279 }
280
281 for ($i = count($this->answers); $i < self::NUM_REQUIRED_ANSWERS; $i++) {
282 $answer = new ilAssKprimChoiceAnswer();
283
284 $answer->setPosition($i);
285
286 $this->answers[$answer->getPosition()] = $answer;
287 }
288 }
getImagePathWeb()
Returns the web image path for web accessable images of a question.
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...
$i
Definition: disco.tpl.php:19
foreach($_POST as $key=> $value) $res

References $data, $DIC, $i, $ilDB, $res, ilRTE\_replaceMediaObjectImageSrc(), assQuestion\getImagePath(), assQuestion\getImagePathWeb(), getThumbPrefix(), and NUM_REQUIRED_ANSWERS.

Referenced by loadFromDb().

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

◆ loadFromDb()

assKprimChoice::loadFromDb (   $question_id)

Loads the question from the database.

Parameters
integer$question_idA unique key which defines the question in the database @access public

Reimplemented from assQuestion.

Definition at line 192 of file class.assKprimChoice.php.

193 {
194 $res = $this->db->queryF($this->buildQuestionDataQuery(), array('integer'), array($questionId));
195
196 while ($data = $this->db->fetchAssoc($res)) {
197 $this->setId($questionId);
198
199 $this->setOriginalId($data['original_id']);
200
201 $this->setObjId($data['obj_fi']);
202
203 $this->setTitle($data['title']);
204 $this->setNrOfTries($data['nr_of_tries']);
205 $this->setComment($data['description']);
206 $this->setAuthor($data['author']);
207 $this->setPoints($data['points']);
208 $this->setOwner($data['owner']);
209 $this->setEstimatedWorkingTimeFromDurationString($data['working_time']);
210 $this->setLastChange($data['tstamp']);
211 require_once 'Services/RTE/classes/class.ilRTE.php';
212 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data['question_text'], 1));
213
214 $this->setShuffleAnswersEnabled((bool) $data['shuffle_answers']);
215
216 if ($this->isValidAnswerType($data['answer_type'])) {
217 $this->setAnswerType($data['answer_type']);
218 }
219
220 if (is_numeric($data['thumb_size'])) {
221 $this->setThumbSize((int) $data['thumb_size']);
222 }
223
224 if ($this->isValidOptionLabel($data['opt_label'])) {
225 $this->setOptionLabel($data['opt_label']);
226 }
227
228 $this->setCustomTrueOptionLabel($data['custom_true']);
229 $this->setCustomFalseOptionLabel($data['custom_false']);
230
231 if ($data['score_partsol'] !== null) {
232 $this->setScorePartialSolutionEnabled((bool) $data['score_partsol']);
233 }
234
235 if (isset($data['feedback_setting'])) {
236 $this->setSpecificFeedbackSetting((int) $data['feedback_setting']);
237 }
238
239 try {
240 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
241 } catch (ilTestQuestionPoolException $e) {
242 }
243 }
244
245 $this->loadAnswerData($questionId);
246
247 parent::loadFromDb($questionId);
248 }
setCustomTrueOptionLabel($customTrueOptionLabel)
setCustomFalseOptionLabel($customFalseOptionLabel)
loadAnswerData($questionId)
setSpecificFeedbackSetting($specificFeedbackSetting)
setAnswerType($answerType)
isValidOptionLabel($optionLabel)
isValidAnswerType($answerType)
setOptionLabel($optionLabel)
setShuffleAnswersEnabled($shuffleAnswersEnabled)
setScorePartialSolutionEnabled($scorePartialSolutionEnabled)
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.
setEstimatedWorkingTimeFromDurationString($durationString)
Sets the estimated working time of a question from a given datetime string.
setAuthor($author="")
Sets the authors name of the assQuestion object.
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.
setLastChange($lastChange)

References $data, $res, ilRTE\_replaceMediaObjectImageSrc(), assQuestion\buildQuestionDataQuery(), isValidAnswerType(), isValidOptionLabel(), loadAnswerData(), assQuestion\setAdditionalContentEditingMode(), setAnswerType(), assQuestion\setAuthor(), assQuestion\setComment(), setCustomFalseOptionLabel(), setCustomTrueOptionLabel(), assQuestion\setEstimatedWorkingTimeFromDurationString(), assQuestion\setId(), assQuestion\setLastChange(), assQuestion\setNrOfTries(), assQuestion\setObjId(), setOptionLabel(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setScorePartialSolutionEnabled(), setShuffleAnswersEnabled(), setSpecificFeedbackSetting(), setThumbSize(), and assQuestion\setTitle().

+ Here is the call graph for this function:

◆ moveAnswerDown()

assKprimChoice::moveAnswerDown (   $position)

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

1009 {
1010 if ($position < 0 || $position >= (self::NUM_REQUIRED_ANSWERS - 1)) {
1011 return false;
1012 }
1013
1014 for ($i = 0, $max = count($this->answers); $i < $max; $i++) {
1015 if ($i == $position) {
1016 $movingAnswer = $this->answers[$i];
1017 $targetAnswer = $this->answers[ $i + 1 ];
1018
1019 $movingAnswer->setPosition($position + 1);
1020 $targetAnswer->setPosition($position);
1021
1022 $this->answers[ $i + 1 ] = $movingAnswer;
1023 $this->answers[$i] = $targetAnswer;
1024 }
1025 }
1026 }

References $i.

◆ moveAnswerUp()

assKprimChoice::moveAnswerUp (   $position)

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

1029 {
1030 if ($position <= 0 || $position > (self::NUM_REQUIRED_ANSWERS - 1)) {
1031 return false;
1032 }
1033
1034 for ($i = 0, $max = count($this->answers); $i < $max; $i++) {
1035 if ($i == $position) {
1036 $movingAnswer = $this->answers[$i];
1037 $targetAnswer = $this->answers[ $i - 1 ];
1038
1039 $movingAnswer->setPosition($position - 1);
1040 $targetAnswer->setPosition($position);
1041
1042 $this->answers[ $i - 1 ] = $movingAnswer;
1043 $this->answers[$i] = $targetAnswer;
1044 }
1045 }
1046
1047 return true;
1048 }

References $i.

◆ rebuildThumbnails()

assKprimChoice::rebuildThumbnails ( )

Definition at line 563 of file class.assKprimChoice.php.

564 {
565 if ($this->isSingleLineAnswerType($this->getAnswerType()) && $this->getThumbSize()) {
566 foreach ($this->getAnswers() as $answer) {
567 if (strlen($answer->getImageFile())) {
568 $this->generateThumbForFile($answer->getImageFsDir(), $answer->getImageFile());
569 }
570 }
571 }
572 }
isSingleLineAnswerType($answerType)
generateThumbForFile($path, $file)

References generateThumbForFile(), getAnswers(), getAnswerType(), getThumbSize(), and isSingleLineAnswerType().

Referenced by saveAnswerSpecificDataToDb().

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

◆ removeAnswerImage()

assKprimChoice::removeAnswerImage (   $position)

Definition at line 629 of file class.assKprimChoice.php.

630 {
631 $answer = $this->getAnswer($position);
632
633 if (file_exists($answer->getImageFsPath())) {
634 ilUtil::delDir($answer->getImageFsPath());
635 }
636
637 if (file_exists($answer->getThumbFsPath())) {
638 ilUtil::delDir($answer->getThumbFsPath());
639 }
640
641 $answer->setImageFile(null);
642 }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilUtil\delDir(), and getAnswer().

+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assKprimChoice::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

Definition at line 300 of file class.assKprimChoice.php.

301 {
302 $this->db->replace(
303 $this->getAdditionalTableName(),
304 array(
305 'question_fi' => array('integer', $this->getId())
306 ),
307 array(
308 'shuffle_answers' => array('integer', (int) $this->isShuffleAnswersEnabled()),
309 'answer_type' => array('text', $this->getAnswerType()),
310 'thumb_size' => array('integer', (int) $this->getThumbSize()),
311 'opt_label' => array('text', $this->getOptionLabel()),
312 'custom_true' => array('text', $this->getCustomTrueOptionLabel()),
313 'custom_false' => array('text', $this->getCustomFalseOptionLabel()),
314 'score_partsol' => array('integer', (int) $this->isScorePartialSolutionEnabled()),
315 'feedback_setting' => array('integer', (int) $this->getSpecificFeedbackSetting())
316 )
317 );
318 }
getAdditionalTableName()
Returns the name of the additional question data table in the database.

References getAdditionalTableName(), getAnswerType(), getCustomFalseOptionLabel(), getCustomTrueOptionLabel(), assQuestion\getId(), getOptionLabel(), getSpecificFeedbackSetting(), getThumbSize(), isScorePartialSolutionEnabled(), and isShuffleAnswersEnabled().

Referenced by saveToDb().

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

◆ saveAnswerSpecificDataToDb()

assKprimChoice::saveAnswerSpecificDataToDb ( )

Saves the answer specific records into a question types answer table.

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

Definition at line 320 of file class.assKprimChoice.php.

321 {
322 foreach ($this->getAnswers() as $answer) {
323 $this->db->replace(
324 $this->getAnswerTableName(),
325 array(
326 'question_fi' => array('integer', (int) $this->getId()),
327 'position' => array('integer', (int) $answer->getPosition())
328 ),
329 array(
330 'answertext' => array('text', $answer->getAnswertext()),
331 'imagefile' => array('text', $answer->getImageFile()),
332 'correctness' => array('integer', (int) $answer->getCorrectness())
333 )
334 );
335 }
336
337 $this->rebuildThumbnails();
338 }
getAnswerTableName()
Returns the name of the answer table in the database.

References getAnswers(), getAnswerTableName(), assQuestion\getId(), and rebuildThumbnails().

Referenced by saveToDb().

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

◆ saveToDb()

assKprimChoice::saveToDb (   $original_id = '')

Saves the question to the database.

Parameters
integer$original_id@access public

Reimplemented from assQuestion.

Definition at line 290 of file class.assKprimChoice.php.

291 {
292 $this->saveQuestionDataToDb($originalId);
293
296
297 parent::saveToDb($originalId);
298 }
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb($original_id="")

References saveAdditionalQuestionDataToDb(), saveAnswerSpecificDataToDb(), and assQuestion\saveQuestionDataToDb().

+ Here is the call graph for this function:

◆ setAnswers()

assKprimChoice::setAnswers (   $answers)

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

167 {
168 $this->answers = $answers;
169 }

References $answers.

◆ setAnswerType()

assKprimChoice::setAnswerType (   $answerType)

Definition at line 96 of file class.assKprimChoice.php.

97 {
98 $this->answerType = $answerType;
99 }

References $answerType.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setCustomFalseOptionLabel()

assKprimChoice::setCustomFalseOptionLabel (   $customFalseOptionLabel)

Definition at line 146 of file class.assKprimChoice.php.

147 {
148 $this->customFalseOptionLabel = $customFalseOptionLabel;
149 }

References $customFalseOptionLabel.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setCustomTrueOptionLabel()

assKprimChoice::setCustomTrueOptionLabel (   $customTrueOptionLabel)

Definition at line 136 of file class.assKprimChoice.php.

137 {
138 $this->customTrueOptionLabel = $customTrueOptionLabel;
139 }

References $customTrueOptionLabel.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

assKprimChoice::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 984 of file class.assKprimChoice.php.

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

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

+ Here is the call graph for this function:

◆ setOptionLabel()

assKprimChoice::setOptionLabel (   $optionLabel)

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

127 {
128 $this->optionLabel = $optionLabel;
129 }

References $optionLabel.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setScorePartialSolutionEnabled()

assKprimChoice::setScorePartialSolutionEnabled (   $scorePartialSolutionEnabled)

Definition at line 116 of file class.assKprimChoice.php.

117 {
118 $this->scorePartialSolutionEnabled = $scorePartialSolutionEnabled;
119 }

References $scorePartialSolutionEnabled.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setShuffleAnswersEnabled()

assKprimChoice::setShuffleAnswersEnabled (   $shuffleAnswersEnabled)

Definition at line 86 of file class.assKprimChoice.php.

87 {
88 $this->shuffleAnswersEnabled = $shuffleAnswersEnabled;
89 }

References $shuffleAnswersEnabled.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setSpecificFeedbackSetting()

assKprimChoice::setSpecificFeedbackSetting (   $specificFeedbackSetting)

Definition at line 156 of file class.assKprimChoice.php.

157 {
158 $this->specificFeedbackSetting = $specificFeedbackSetting;
159 }

References $specificFeedbackSetting.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setThumbSize()

assKprimChoice::setThumbSize (   $thumbSize)

Definition at line 106 of file class.assKprimChoice.php.

107 {
108 $this->thumbSize = $thumbSize;
109 }

References $thumbSize.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ toJSON()

assKprimChoice::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

Definition at line 897 of file class.assKprimChoice.php.

898 {
899 $this->lng->loadLanguageModule('assessment');
900
901 require_once './Services/RTE/classes/class.ilRTE.php';
902 $result = array();
903 $result['id'] = (int) $this->getId();
904 $result['type'] = (string) $this->getQuestionType();
905 $result['title'] = (string) $this->getTitle();
906 $result['question'] = $this->formatSAQuestion($this->getQuestion());
907 $result['instruction'] = $this->getInstructionTextTranslation(
908 $this->lng,
909 $this->getOptionLabel()
910 );
911 $result['nr_of_tries'] = (int) $this->getNrOfTries();
912 $result['shuffle'] = (bool) $this->isShuffleAnswersEnabled();
913 $result['feedback'] = array(
914 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
915 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
916 );
917
918 $result['trueOptionLabel'] = $this->getTrueOptionLabelTranslation($this->lng, $this->getOptionLabel());
919 $result['falseOptionLabel'] = $this->getFalseOptionLabelTranslation($this->lng, $this->getOptionLabel());
920
921 $result['num_allowed_failures'] = $this->getNumAllowedFailures();
922
923 $answers = array();
924 $has_image = false;
925
926 foreach ($this->getAnswers() as $key => $answer) {
927 if (strlen((string) $answer->getImageFile())) {
928 $has_image = true;
929 }
930
931 $answers[] = array(
932 'answertext' => (string) $this->formatSAQuestion($answer->getAnswertext()),
933 'correctness' => (bool) $answer->getCorrectness(),
934 'order' => (int) $answer->getPosition(),
935 'image' => (string) $answer->getImageFile(),
936 'feedback' => $this->formatSAQuestion(
937 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
938 )
939 );
940 }
941
942 $result['answers'] = $answers;
943
944 if ($has_image) {
945 $result['path'] = $this->getImagePathWeb();
946 $result['thumb'] = $this->getThumbSize();
947 }
948
949 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
950 $result['mobs'] = $mobs;
951
952 return json_encode($result);
953 }
getQuestionType()
Returns the question type of the question.
getTrueOptionLabelTranslation(ilLanguage $lng, $optionLabel)
getFalseOptionLabelTranslation(ilLanguage $lng, $optionLabel)
getInstructionTextTranslation(ilLanguage $lng, $optionLabel)
formatSAQuestion($a_q)
Format self assessment question.
getTitle()
Gets the title string of the assQuestion object.
getQuestion()
Gets the question string of the question object.
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(), getFalseOptionLabelTranslation(), assQuestion\getId(), assQuestion\getImagePathWeb(), getInstructionTextTranslation(), assQuestion\getNrOfTries(), getNumAllowedFailures(), getOptionLabel(), assQuestion\getQuestion(), getQuestionType(), getThumbSize(), assQuestion\getTitle(), getTrueOptionLabelTranslation(), and isShuffleAnswersEnabled().

+ Here is the call graph for this function:

Field Documentation

◆ $answers

assKprimChoice::$answers
private

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

Referenced by getAnswers(), handleFileUploads(), setAnswers(), and toJSON().

◆ $answerType

assKprimChoice::$answerType
private

◆ $customFalseOptionLabel

assKprimChoice::$customFalseOptionLabel
private

◆ $customTrueOptionLabel

assKprimChoice::$customTrueOptionLabel
private

Definition at line 43 of file class.assKprimChoice.php.

Referenced by getCustomTrueOptionLabel(), and setCustomTrueOptionLabel().

◆ $optionLabel

◆ $scorePartialSolutionEnabled

assKprimChoice::$scorePartialSolutionEnabled
private

◆ $shuffleAnswersEnabled

assKprimChoice::$shuffleAnswersEnabled
private

Definition at line 33 of file class.assKprimChoice.php.

Referenced by isShuffleAnswersEnabled(), and setShuffleAnswersEnabled().

◆ $specificFeedbackSetting

assKprimChoice::$specificFeedbackSetting
private

◆ $thumbSize

assKprimChoice::$thumbSize
private

Definition at line 37 of file class.assKprimChoice.php.

Referenced by getThumbSize(), and setThumbSize().

◆ ANSWER_TYPE_MULTI_LINE

const assKprimChoice::ANSWER_TYPE_MULTI_LINE = 'multiLine'

◆ ANSWER_TYPE_SINGLE_LINE

const assKprimChoice::ANSWER_TYPE_SINGLE_LINE = 'singleLine'

Definition at line 21 of file class.assKprimChoice.php.

Referenced by __construct(), and isSingleLineAnswerType().

◆ DEFAULT_THUMB_SIZE

const assKprimChoice::DEFAULT_THUMB_SIZE = 150

Definition at line 30 of file class.assKprimChoice.php.

Referenced by __construct().

◆ NUM_REQUIRED_ANSWERS

const assKprimChoice::NUM_REQUIRED_ANSWERS = 4

Definition at line 17 of file class.assKprimChoice.php.

Referenced by loadAnswerData().

◆ OPTION_LABEL_ADEQUATE_OR_NOT

const assKprimChoice::OPTION_LABEL_ADEQUATE_OR_NOT = 'adequate_or_not'

◆ OPTION_LABEL_APPLICABLE_OR_NOT

const assKprimChoice::OPTION_LABEL_APPLICABLE_OR_NOT = 'applicable_or_not'

◆ OPTION_LABEL_CUSTOM

const assKprimChoice::OPTION_LABEL_CUSTOM = 'customlabel'

◆ OPTION_LABEL_PLUS_MINUS

const assKprimChoice::OPTION_LABEL_PLUS_MINUS = 'plus_minus'

◆ OPTION_LABEL_RIGHT_WRONG

const assKprimChoice::OPTION_LABEL_RIGHT_WRONG = 'right_wrong'

◆ PARTIAL_SCORING_NUM_CORRECT_ANSWERS

const assKprimChoice::PARTIAL_SCORING_NUM_CORRECT_ANSWERS = 3

Definition at line 19 of file class.assKprimChoice.php.

Referenced by getNumAllowedFailures().

◆ THUMB_PREFIX

const assKprimChoice::THUMB_PREFIX = 'thumb.'

Definition at line 31 of file class.assKprimChoice.php.

Referenced by getThumbPrefix().


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