ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
assKprimChoice Class Reference
+ Inheritance diagram for assKprimChoice:
+ Collaboration diagram for assKprimChoice:

Public Member Functions

 __construct ($title='', $comment='', $author='', $owner=-1, $question='')
 
 getQuestionType ()
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 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)
 
 saveToDb ($originalId='')
 
 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 ()
 
 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)
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 {} 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...
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 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 ()
 
 _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 ()
 

Static Public Member Functions

static isObligationPossible ($questionId)
 
- 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

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 ()
 
 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
 
 $lifecycle
 
- 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 = '' 
)

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

References assQuestion\$author, assQuestion\$comment, assQuestion\$owner, assQuestion\$question, assQuestion\$title, ILIAS\GlobalScreen\Provider\__construct(), ilAssConfigurableMultiOptionQuestionFeedback\FEEDBACK_SETTING_ALL, and assQuestion\setPoints().

52  {
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.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswer()

assKprimChoice::addAnswer ( ilAssKprimChoiceAnswer  $answer)

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

References ilAssKprimChoiceAnswer\getAnswertext(), assQuestion\getHtmlQuestionContentPurifier(), and ilAssKprimChoiceAnswer\setAnswertext().

197  {
198  $answer->setAnswertext(
199  $this->getHtmlQuestionContentPurifier()->purify($answer->getAnswertext())
200  );
201  $this->answers[] = $answer;
202  }
+ Here is the call graph for this function:

◆ afterSyncWithOriginal()

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

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

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

838  {
839  parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
840 
841  $this->cloneAnswerImages($dupQuestionId, $dupParentObjId, $origQuestionId, $origParentObjId);
842  }
+ Here is the call graph for this function:

◆ beforeSyncWithOriginal()

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

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

References assQuestion\$question.

827  {
828  parent::beforeSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
829 
830  $question = self::_instanciateQuestion($origQuestionId);
831 
832  foreach ($question->getAnswers() as $answer) {
833  $question->removeAnswerImage($answer->getPosition());
834  }
835  }

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

public

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

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

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

444  {
445  if ($returndetails) {
446  throw new ilTestException('return details not implemented for ' . __METHOD__);
447  }
448 
449  global $DIC;
450  $ilDB = $DIC['ilDB'];
451 
452  $found_values = array();
453  if (is_null($pass)) {
454  $pass = $this->getSolutionMaxPass($active_id);
455  }
456 
457  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
458 
459  while ($data = $ilDB->fetchAssoc($result)) {
460  $found_values[(int) $data['value1']] = (int) $data['value2'];
461  }
462 
463  $points = $this->calculateReachedPointsForSolution($found_values, $active_id);
464 
465  return $points;
466  }
$data
Definition: storeScorm.php:23
$result
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
calculateReachedPointsForSolution($found_values, $active_id=0)
global $ilDB
$DIC
Definition: xapitoken.php:46
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

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

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

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

Referenced by calculateReachedPoints().

680  {
681  $numCorrect = 0;
682 
683  foreach ($this->getAnswers() as $key => $answer) {
684  if (!isset($found_values[$answer->getPosition()])) {
685  continue;
686  }
687 
688  if ($found_values[$answer->getPosition()] == $answer->getCorrectness()) {
689  $numCorrect++;
690  }
691  }
692 
693  if ($numCorrect >= self::NUM_REQUIRED_ANSWERS) {
694  $points = $this->getPoints();
695  } elseif ($this->isScorePartialSolutionEnabled() && $numCorrect >= self::PARTIAL_SCORING_NUM_CORRECT_ANSWERS) {
696  $points = $this->getPoints() / 2;
697  } else {
698  $points = 0;
699  }
700 
701  if ($active_id) {
702  include_once "./Modules/Test/classes/class.ilObjTest.php";
703  $mc_scoring = ilObjTest::_getMCScoring($active_id);
704  if (($mc_scoring == 0) && (count($found_values) == 0)) {
705  $points = 0;
706  }
707  }
708  return $points;
709  }
getPoints()
Returns the maximum available points for the question.
static _getMCScoring($active_id)
Gets the scoring type for multiple choice questions.
+ 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 797 of file class.assKprimChoice.php.

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

798  {
799  if ($this->id <= 0) {
800  // The question has not been saved. It cannot be duplicated
801  return;
802  }
803  // duplicate the question in database
804  $clone = $this;
805  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
807  $clone->id = -1;
808  $source_questionpool_id = $this->getObjId();
809  $clone->setObjId($target_questionpool_id);
810  if ($title) {
811  $clone->setTitle($title);
812  }
813  $clone->saveToDb();
814  // copy question page content
815  $clone->copyPageOfQuestion($original_id);
816  // copy XHTML media objects
817  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
818  // duplicate the image
819  $clone->cloneAnswerImages($original_id, $source_questionpool_id, $clone->getId(), $clone->getObjId());
820 
821  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
822 
823  return $clone->id;
824  }
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()

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

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

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

760  {
761  if ($this->id <= 0) {
762  // The question has not been saved. It cannot be duplicated
763  return;
764  }
765 
766  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
767 
768  $sourceQuestionId = $this->id;
769  $sourceParentId = $this->getObjId();
770 
771  // duplicate the question in database
772  $clone = $this;
773  $clone->id = -1;
774 
775  $clone->setObjId($targetParentId);
776 
777  if ($targetQuestionTitle) {
778  $clone->setTitle($targetQuestionTitle);
779  }
780 
781  $clone->saveToDb();
782  // copy question page content
783  $clone->copyPageOfQuestion($sourceQuestionId);
784  // copy XHTML media objects
785  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
786  // duplicate the image
787  $clone->cloneAnswerImages($sourceQuestionId, $sourceParentId, $clone->getId(), $clone->getObjId());
788 
789  $clone->onCopy($sourceParentId, $sourceQuestionId, $targetParentId, $clone->getId());
790 
791  return $clone->id;
792  }
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ duplicate()

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

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

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

712  {
713  if ($this->id <= 0) {
714  // The question has not been saved. It cannot be duplicated
715  return;
716  }
717  // duplicate the question in database
718  $this_id = $this->getId();
719  $thisObjId = $this->getObjId();
720 
721  $clone = $this;
722  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
724  $clone->id = -1;
725 
726  if ((int) $testObjId > 0) {
727  $clone->setObjId($testObjId);
728  }
729 
730  if ($title) {
731  $clone->setTitle($title);
732  }
733 
734  if ($author) {
735  $clone->setAuthor($author);
736  }
737  if ($owner) {
738  $clone->setOwner($owner);
739  }
740 
741  if ($for_test) {
742  $clone->saveToDb($original_id);
743  } else {
744  $clone->saveToDb();
745  }
746 
747  // copy question page content
748  $clone->copyPageOfQuestion($this_id);
749  // copy XHTML media objects
750  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
751  // duplicate the images
752  $clone->cloneAnswerImages($this_id, $thisObjId, $clone->getId(), $clone->getObjId());
753 
754  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
755 
756  return $clone->id;
757  }
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:

◆ generateThumbForFile()

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

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

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

Referenced by rebuildThumbnails().

595  {
596  $filename = $path . $file;
597  if (@file_exists($filename)) {
598  $thumbpath = $path . $this->getThumbPrefix() . $file;
599  $path_info = @pathinfo($filename);
600  $ext = "";
601  switch (strtoupper($path_info['extension'])) {
602  case 'PNG':
603  $ext = 'PNG';
604  break;
605  case 'GIF':
606  $ext = 'GIF';
607  break;
608  default:
609  $ext = 'JPEG';
610  break;
611  }
612  ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbSize());
613  }
614  }
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()

assKprimChoice::getAdditionalTableName ( )

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

Referenced by saveAdditionalQuestionDataToDb().

77  {
78  return "qpl_qst_kprim";
79  }
+ Here is the caller graph for this function:

◆ getAnswer()

assKprimChoice::getAnswer (   $position)

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

References getAnswers().

Referenced by removeAnswerImage().

186  {
187  foreach ($this->getAnswers() as $answer) {
188  if ($answer->getPosition() == $position) {
189  return $answer;
190  }
191  }
192 
193  return null;
194  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAnswers()

◆ getAnswerTableName()

assKprimChoice::getAnswerTableName ( )

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

Referenced by saveAnswerSpecificDataToDb().

82  {
83  return "qpl_a_kprim";
84  }
+ Here is the caller graph for this function:

◆ getAnswerType()

assKprimChoice::getAnswerType ( )

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

References $answerType.

Referenced by rebuildThumbnails(), and saveAdditionalQuestionDataToDb().

102  {
103  return $this->answerType;
104  }
+ Here is the caller graph for this function:

◆ getAnswerTypeSelectOptions()

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

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

References ilLanguage\txt().

489  {
490  return array(
491  self::ANSWER_TYPE_SINGLE_LINE => $lng->txt('answers_singleline'),
492  self::ANSWER_TYPE_MULTI_LINE => $lng->txt('answers_multiline')
493  );
494  }
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:

◆ getCustomFalseOptionLabel()

assKprimChoice::getCustomFalseOptionLabel ( )

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

References $customFalseOptionLabel.

Referenced by getFalseOptionLabelTranslation(), and saveAdditionalQuestionDataToDb().

152  {
154  }
+ 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().

142  {
144  }
+ Here is the caller graph for this function:

◆ getFalseOptionLabelTranslation()

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

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

References $optionLabel, getCustomFalseOptionLabel(), and ilLanguage\txt().

Referenced by getInstructionTextTranslation(), and toJSON().

545  {
546  switch ($optionLabel) {
547  case self::OPTION_LABEL_RIGHT_WRONG:
548  return $lng->txt('option_label_wrong');
549 
550  case self::OPTION_LABEL_PLUS_MINUS:
551  return $lng->txt('option_label_minus');
552 
553  case self::OPTION_LABEL_APPLICABLE_OR_NOT:
554  return $lng->txt('option_label_not_applicable');
555 
556  case self::OPTION_LABEL_ADEQUATE_OR_NOT:
557  return $lng->txt('option_label_not_adequate');
558 
559  case self::OPTION_LABEL_CUSTOM:
560  return $this->getCustomFalseOptionLabel();
561  }
562  }
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ 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 564 of file class.assKprimChoice.php.

References $optionLabel, getFalseOptionLabelTranslation(), getTrueOptionLabelTranslation(), and ilLanguage\txt().

Referenced by toJSON().

565  {
566  return sprintf(
567  $lng->txt('kprim_instruction_text'),
570  );
571  }
getTrueOptionLabelTranslation(ilLanguage $lng, $optionLabel)
getFalseOptionLabelTranslation(ilLanguage $lng, $optionLabel)
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumAllowedFailures()

assKprimChoice::getNumAllowedFailures ( )
private

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

References isScorePartialSolutionEnabled().

Referenced by toJSON().

976  {
977  if ($this->isScorePartialSolutionEnabled()) {
978  return self::NUM_REQUIRED_ANSWERS - self::PARTIAL_SCORING_NUM_CORRECT_ANSWERS;
979  }
980 
981  return 0;
982  }
+ 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.

References $optionLabel.

Referenced by saveAdditionalQuestionDataToDb(), and toJSON().

132  {
133  return $this->optionLabel;
134  }
+ Here is the caller graph for this function:

◆ getQuestionType()

assKprimChoice::getQuestionType ( )

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

Referenced by toJSON().

72  {
73  return 'assKprimChoice';
74  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assKprimChoice::getRTETextWithMediaObjects ( )
protected

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

References getAnswers().

893  {
894  $combinedText = parent::getRTETextWithMediaObjects();
895 
896  foreach ($this->getAnswers() as $answer) {
897  $combinedText .= $answer->getAnswertext();
898  }
899 
900  return $combinedText;
901  }
+ Here is the call graph for this function:

◆ getSolutionSubmit()

assKprimChoice::getSolutionSubmit ( )
protected

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

References $_POST.

Referenced by isComplete().

665  {
666  $solutionSubmit = array();
667  foreach ($_POST as $key => $value) {
668  $matches = null;
669 
670  if (preg_match("/^kprim_choice_result_(\d+)/", $key, $matches)) {
671  if (strlen($value)) {
672  $solutionSubmit[$matches[1]] = $value;
673  }
674  }
675  }
676  return $solutionSubmit;
677  }
$_POST["username"]
+ Here is the caller graph for this function:

◆ getSpecificFeedbackAllCorrectOptionLabel()

assKprimChoice::getSpecificFeedbackAllCorrectOptionLabel ( )

Implements ilAssSpecificFeedbackOptionLabelProvider.

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

985  {
986  return 'feedback_correct_kprim';
987  }

◆ getSpecificFeedbackSetting()

assKprimChoice::getSpecificFeedbackSetting ( )

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

References $specificFeedbackSetting.

Referenced by saveAdditionalQuestionDataToDb().

162  {
164  }
+ Here is the caller graph for this function:

◆ getThumbPrefix()

assKprimChoice::getThumbPrefix ( )

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

Referenced by afterSyncWithOriginal(), generateThumbForFile(), and loadAnswerData().

579  {
580  return self::THUMB_PREFIX;
581  }
+ Here is the caller graph for this function:

◆ getThumbSize()

assKprimChoice::getThumbSize ( )

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

References $thumbSize.

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

112  {
113  return $this->thumbSize;
114  }
+ Here is the caller graph for this function:

◆ getTrueOptionLabelTranslation()

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

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

References $optionLabel, getCustomTrueOptionLabel(), and ilLanguage\txt().

Referenced by getInstructionTextTranslation(), and toJSON().

525  {
526  switch ($optionLabel) {
527  case self::OPTION_LABEL_RIGHT_WRONG:
528  return $lng->txt('option_label_right');
529 
530  case self::OPTION_LABEL_PLUS_MINUS:
531  return $lng->txt('option_label_plus');
532 
533  case self::OPTION_LABEL_APPLICABLE_OR_NOT:
534  return $lng->txt('option_label_applicable');
535 
536  case self::OPTION_LABEL_ADEQUATE_OR_NOT:
537  return $lng->txt('option_label_adequate');
538 
539  case self::OPTION_LABEL_CUSTOM:
540  return $this->getCustomTrueOptionLabel();
541  }
542  }
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidAnswerTypes()

assKprimChoice::getValidAnswerTypes ( )

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

Referenced by isValidAnswerType().

469  {
470  return array(self::ANSWER_TYPE_SINGLE_LINE, self::ANSWER_TYPE_MULTI_LINE);
471  }
+ Here is the caller graph for this function:

◆ getValidOptionLabels()

assKprimChoice::getValidOptionLabels ( )

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

Referenced by isValidOptionLabel().

497  {
498  return array(
499  self::OPTION_LABEL_RIGHT_WRONG,
500  self::OPTION_LABEL_PLUS_MINUS,
501  self::OPTION_LABEL_APPLICABLE_OR_NOT,
502  self::OPTION_LABEL_ADEQUATE_OR_NOT,
503  self::OPTION_LABEL_CUSTOM
504  );
505  }
+ Here is the caller graph for this function:

◆ getValidOptionLabelsTranslated()

assKprimChoice::getValidOptionLabelsTranslated ( ilLanguage  $lng)

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

References ilLanguage\txt().

508  {
509  return array(
510  self::OPTION_LABEL_RIGHT_WRONG => $lng->txt('option_label_right_wrong'),
511  self::OPTION_LABEL_PLUS_MINUS => $lng->txt('option_label_plus_minus'),
512  self::OPTION_LABEL_APPLICABLE_OR_NOT => $lng->txt('option_label_applicable_or_not'),
513  self::OPTION_LABEL_ADEQUATE_OR_NOT => $lng->txt('option_label_adequate_or_not'),
514  self::OPTION_LABEL_CUSTOM => $lng->txt('option_label_custom')
515  );
516  }
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:

◆ handleFileUpload()

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

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

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

Referenced by handleFileUploads().

630  {
631  $imagePath = $this->getImagePath();
632 
633  if (!file_exists($imagePath)) {
634  ilUtil::makeDirParents($imagePath);
635  }
636 
637  $filename = $this->buildHashedImageFilename($fileData['name'], true);
638 
639  $answer->setImageFsDir($imagePath);
640  $answer->setImageFile($filename);
641 
642  if (!ilUtil::moveUploadedFile($fileData['tmp_name'], $fileData['name'], $answer->getImageFsPath())) {
643  return 2;
644  }
645 
646  return 0;
647  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
buildHashedImageFilename($plain_image_filename, $unique=false)
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleFileUploads()

assKprimChoice::handleFileUploads (   $answers,
  $files 
)

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

References $answers, and handleFileUpload().

617  {
618  foreach ($answers as $answer) {
619  /* @var ilAssKprimChoiceAnswer $answer */
620 
621  if (!isset($files[$answer->getPosition()])) {
622  continue;
623  }
624 
625  $this->handleFileUpload($answer, $files[$answer->getPosition()]);
626  }
627  }
handleFileUpload(ilAssKprimChoiceAnswer $answer, $fileData)
+ Here is the call graph for this function:

◆ isAnswered()

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

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

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

995  {
996  $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
997 
998  return $numExistingSolutionRecords >= 4;
999  }
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()

assKprimChoice::isComplete ( )

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

References $GLOBALS, $ilDB, $pass, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), getAnswers(), assQuestion\getId(), assQuestion\getMaximumPoints(), assQuestion\getProcessLocker(), getSolutionSubmit(), assQuestion\logAction(), assQuestion\removeCurrentSolution(), assQuestion\saveCurrentSolution(), and assQuestion\saveWorkingData().

361  {
362  foreach (array($this->title, $this->author, $this->question) as $text) {
363  if (!strlen($text)) {
364  return false;
365  }
366  }
367 
368  if ($this->getMaximumPoints() <= 0) {
369  return false;
370  }
371 
372  foreach ($this->getAnswers() as $answer) {
373  /* @var ilAssKprimChoiceAnswer $answer */
374 
375  if (is_null($answer->getCorrectness())) {
376  return false;
377  }
378 
379  if (!strlen($answer->getAnswertext()) && !strlen($answer->getImageFile())) {
380  return false;
381  }
382  }
383 
384  return true;
385  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ isCustomOptionLabel()

assKprimChoice::isCustomOptionLabel (   $labelValue)

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

574  {
575  return $labelValue == self::OPTION_LABEL_CUSTOM;
576  }

◆ isObligationPossible()

static assKprimChoice::isObligationPossible (   $questionId)
static

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

990  {
991  return true;
992  }

◆ isScorePartialSolutionEnabled()

assKprimChoice::isScorePartialSolutionEnabled ( )

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

References $scorePartialSolutionEnabled.

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

122  {
124  }
+ 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().

92  {
94  }
+ Here is the caller graph for this function:

◆ isSingleLineAnswerType()

assKprimChoice::isSingleLineAnswerType (   $answerType)

Definition at line 479 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 473 of file class.assKprimChoice.php.

References $answerType, and getValidAnswerTypes().

Referenced by loadFromDb().

474  {
475  $validTypes = $this->getValidAnswerTypes();
476  return in_array($answerType, $validTypes);
477  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValidOptionLabel()

assKprimChoice::isValidOptionLabel (   $optionLabel)

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

References $optionLabel, and getValidOptionLabels().

Referenced by loadFromDb().

519  {
520  $validLabels = $this->getValidOptionLabels();
521  return in_array($optionLabel, $validLabels);
522  }
+ 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

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

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

907  {
908  foreach ($this->getAnswers() as $answer) {
909  /* @var ilAssKprimChoiceAnswer $answer */
910  $answer->setAnswertext($migrator->migrateToLmContent($answer->getAnswertext()));
911  }
912  }
+ Here is the call graph for this function:

◆ loadAnswerData()

assKprimChoice::loadAnswerData (   $questionId)
private

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

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

Referenced by loadFromDb().

269  {
270  global $DIC;
271  $ilDB = $DIC['ilDB'];
272 
273  $res = $this->db->queryF(
274  "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY position ASC",
275  array('integer'),
276  array($questionId)
277  );
278 
279  require_once 'Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
280  require_once 'Services/RTE/classes/class.ilRTE.php';
281 
282  while ($data = $ilDB->fetchAssoc($res)) {
283  $answer = new ilAssKprimChoiceAnswer();
284 
285  $answer->setPosition($data['position']);
286 
287  $answer->setAnswertext(ilRTE::_replaceMediaObjectImageSrc($data['answertext'], 1));
288 
289  $answer->setImageFile($data['imagefile']);
290  $answer->setThumbPrefix($this->getThumbPrefix());
291  $answer->setImageFsDir($this->getImagePath());
292  $answer->setImageWebDir($this->getImagePathWeb());
293 
294  $answer->setCorrectness($data['correctness']);
295 
296  $answers[$answer->getPosition()] = $answer;
297  }
298 
299  $this->setAnswers($answers);
300 
301  for ($i = count($this->answers); $i < self::NUM_REQUIRED_ANSWERS; $i++) {
302  $answer = new ilAssKprimChoiceAnswer();
303 
304  $answer->setPosition($i);
305 
306  $this->answers[$answer->getPosition()] = $answer;
307  }
308  }
$data
Definition: storeScorm.php:23
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...
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46
$i
Definition: metadata.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadFromDb()

assKprimChoice::loadFromDb (   $questionId)

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

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

205  {
206  $res = $this->db->queryF($this->buildQuestionDataQuery(), array('integer'), array($questionId));
207 
208  while ($data = $this->db->fetchAssoc($res)) {
209  $this->setId($questionId);
210 
211  $this->setOriginalId($data['original_id']);
212 
213  $this->setObjId($data['obj_fi']);
214 
215  $this->setTitle($data['title']);
216  $this->setNrOfTries($data['nr_of_tries']);
217  $this->setComment($data['description']);
218  $this->setAuthor($data['author']);
219  $this->setPoints($data['points']);
220  $this->setOwner($data['owner']);
221  $this->setEstimatedWorkingTimeFromDurationString($data['working_time']);
222  $this->setLastChange($data['tstamp']);
223  require_once 'Services/RTE/classes/class.ilRTE.php';
224  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data['question_text'], 1));
225 
226  $this->setShuffleAnswersEnabled((bool) $data['shuffle_answers']);
227 
228  if ($this->isValidAnswerType($data['answer_type'])) {
229  $this->setAnswerType($data['answer_type']);
230  }
231 
232  if (is_numeric($data['thumb_size'])) {
233  $this->setThumbSize((int) $data['thumb_size']);
234  }
235 
236  if ($this->isValidOptionLabel($data['opt_label'])) {
237  $this->setOptionLabel($data['opt_label']);
238  }
239 
240  $this->setCustomTrueOptionLabel($data['custom_true']);
241  $this->setCustomFalseOptionLabel($data['custom_false']);
242 
243  if ($data['score_partsol'] !== null) {
244  $this->setScorePartialSolutionEnabled((bool) $data['score_partsol']);
245  }
246 
247  if (isset($data['feedback_setting'])) {
248  $this->setSpecificFeedbackSetting((int) $data['feedback_setting']);
249  }
250 
251  try {
255  }
256 
257  try {
258  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
259  } catch (ilTestQuestionPoolException $e) {
260  }
261  }
262 
263  $this->loadAnswerData($questionId);
264 
265  parent::loadFromDb($questionId);
266  }
isValidAnswerType($answerType)
$data
Definition: storeScorm.php:23
setScorePartialSolutionEnabled($scorePartialSolutionEnabled)
setId($id=-1)
Sets the id of the assQuestion object.
setEstimatedWorkingTimeFromDurationString($durationString)
Sets the estimated working time of a question from a given datetime string.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setCustomTrueOptionLabel($customTrueOptionLabel)
isValidOptionLabel($optionLabel)
loadAnswerData($questionId)
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...
setOptionLabel($optionLabel)
setAuthor($author="")
Sets the authors name of the assQuestion object.
foreach($_POST as $key=> $value) $res
setShuffleAnswersEnabled($shuffleAnswersEnabled)
setPoints($a_points)
Sets the maximum available points for the question.
setCustomFalseOptionLabel($customFalseOptionLabel)
setQuestion($question="")
Sets the question string of the question object.
setSpecificFeedbackSetting($specificFeedbackSetting)
setOriginalId($original_id)
setLastChange($lastChange)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
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.
setAnswerType($answerType)
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
+ Here is the call graph for this function:

◆ moveAnswerDown()

assKprimChoice::moveAnswerDown (   $position)

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

References $i.

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  }
$i
Definition: metadata.php:24

◆ moveAnswerUp()

assKprimChoice::moveAnswerUp (   $position)

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

References $i.

1049  {
1050  if ($position <= 0 || $position > (self::NUM_REQUIRED_ANSWERS - 1)) {
1051  return false;
1052  }
1053 
1054  for ($i = 0, $max = count($this->answers); $i < $max; $i++) {
1055  if ($i == $position) {
1056  $movingAnswer = $this->answers[$i];
1057  $targetAnswer = $this->answers[ $i - 1 ];
1058 
1059  $movingAnswer->setPosition($position - 1);
1060  $targetAnswer->setPosition($position);
1061 
1062  $this->answers[ $i - 1 ] = $movingAnswer;
1063  $this->answers[$i] = $targetAnswer;
1064  }
1065  }
1066 
1067  return true;
1068  }
$i
Definition: metadata.php:24

◆ rebuildThumbnails()

assKprimChoice::rebuildThumbnails ( )

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

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

Referenced by saveAnswerSpecificDataToDb().

584  {
585  if ($this->isSingleLineAnswerType($this->getAnswerType()) && $this->getThumbSize()) {
586  foreach ($this->getAnswers() as $answer) {
587  if (strlen($answer->getImageFile())) {
588  $this->generateThumbForFile($answer->getImageFsDir(), $answer->getImageFile());
589  }
590  }
591  }
592  }
isSingleLineAnswerType($answerType)
generateThumbForFile($path, $file)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAnswerImage()

assKprimChoice::removeAnswerImage (   $position)

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

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

650  {
651  $answer = $this->getAnswer($position);
652 
653  if (file_exists($answer->getImageFsPath())) {
654  ilUtil::delDir($answer->getImageFsPath());
655  }
656 
657  if (file_exists($answer->getThumbFsPath())) {
658  ilUtil::delDir($answer->getThumbFsPath());
659  }
660 
661  $answer->setImageFile(null);
662  }
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:

◆ saveAdditionalQuestionDataToDb()

assKprimChoice::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

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

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

Referenced by saveToDb().

321  {
322  $this->db->replace(
323  $this->getAdditionalTableName(),
324  array(
325  'question_fi' => array('integer', $this->getId())
326  ),
327  array(
328  'shuffle_answers' => array('integer', (int) $this->isShuffleAnswersEnabled()),
329  'answer_type' => array('text', $this->getAnswerType()),
330  'thumb_size' => array('integer', (int) $this->getThumbSize()),
331  'opt_label' => array('text', $this->getOptionLabel()),
332  'custom_true' => array('text', $this->getCustomTrueOptionLabel()),
333  'custom_false' => array('text', $this->getCustomFalseOptionLabel()),
334  'score_partsol' => array('integer', (int) $this->isScorePartialSolutionEnabled()),
335  'feedback_setting' => array('integer', (int) $this->getSpecificFeedbackSetting())
336  )
337  );
338  }
getId()
Gets the id of the assQuestion object.
+ 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 340 of file class.assKprimChoice.php.

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

Referenced by saveToDb().

341  {
342  foreach ($this->getAnswers() as $answer) {
343  $this->db->replace(
344  $this->getAnswerTableName(),
345  array(
346  'question_fi' => array('integer', (int) $this->getId()),
347  'position' => array('integer', (int) $answer->getPosition())
348  ),
349  array(
350  'answertext' => array('text', $answer->getAnswertext()),
351  'imagefile' => array('text', $answer->getImageFile()),
352  'correctness' => array('integer', (int) $answer->getCorrectness())
353  )
354  );
355  }
356 
357  $this->rebuildThumbnails();
358  }
getId()
Gets the id of the assQuestion object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

assKprimChoice::saveToDb (   $originalId = '')

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

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

311  {
312  $this->saveQuestionDataToDb($originalId);
313 
316 
317  parent::saveToDb($originalId);
318  }
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb($original_id="")
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
+ Here is the call graph for this function:

◆ setAnswers()

assKprimChoice::setAnswers (   $answers)

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

References $answers, and assQuestion\getHtmlQuestionContentPurifier().

Referenced by loadAnswerData().

167  {
168  if (is_null($answers)) {
169  return;
170  }
171  $clean_answer_text = function (ilAssKprimChoiceAnswer $answer) {
172  $answer->setAnswertext(
173  $this->getHtmlQuestionContentPurifier()->purify($answer->getAnswertext())
174  );
175  return $answer;
176  };
177  $this->answers = array_map($clean_answer_text, $answers);
178  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAnswerType()

assKprimChoice::setAnswerType (   $answerType)

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

References $answerType.

Referenced by loadFromDb().

97  {
98  $this->answerType = $answerType;
99  }
+ Here is the caller graph for this function:

◆ setCustomFalseOptionLabel()

assKprimChoice::setCustomFalseOptionLabel (   $customFalseOptionLabel)

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

References $customFalseOptionLabel.

Referenced by loadFromDb().

147  {
148  $this->customFalseOptionLabel = $customFalseOptionLabel;
149  }
+ Here is the caller graph for this function:

◆ setCustomTrueOptionLabel()

assKprimChoice::setCustomTrueOptionLabel (   $customTrueOptionLabel)

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

References $customTrueOptionLabel.

Referenced by loadFromDb().

137  {
138  $this->customTrueOptionLabel = $customTrueOptionLabel;
139  }
+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

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

{}

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

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

1005  {
1006  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
1007 
1008  $solution = $this->getSolutionValues($active_id, $pass);
1009 
1010  $i = 1;
1011  foreach ($this->getAnswers() as $id => $answer) {
1012  $worksheet->setCell($startrow + $i, 0, $answer->getAnswertext());
1013  $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
1014  $correctness = false;
1015  foreach ($solution as $solutionvalue) {
1016  if ($id == $solutionvalue['value1']) {
1017  $correctness = $solutionvalue['value2'];
1018  break;
1019  }
1020  }
1021  $worksheet->setCell($startrow + $i, 1, $correctness);
1022  $i++;
1023  }
1024 
1025  return $startrow + $i + 1;
1026  }
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ setOptionLabel()

assKprimChoice::setOptionLabel (   $optionLabel)

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

References $optionLabel.

Referenced by loadFromDb().

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

◆ setScorePartialSolutionEnabled()

assKprimChoice::setScorePartialSolutionEnabled (   $scorePartialSolutionEnabled)

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

References $scorePartialSolutionEnabled.

Referenced by loadFromDb().

117  {
118  $this->scorePartialSolutionEnabled = $scorePartialSolutionEnabled;
119  }
+ Here is the caller graph for this function:

◆ setShuffleAnswersEnabled()

assKprimChoice::setShuffleAnswersEnabled (   $shuffleAnswersEnabled)

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

References $shuffleAnswersEnabled.

Referenced by loadFromDb().

87  {
88  $this->shuffleAnswersEnabled = $shuffleAnswersEnabled;
89  }
+ Here is the caller graph for this function:

◆ setSpecificFeedbackSetting()

assKprimChoice::setSpecificFeedbackSetting (   $specificFeedbackSetting)

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

References $specificFeedbackSetting.

Referenced by loadFromDb().

157  {
158  $this->specificFeedbackSetting = $specificFeedbackSetting;
159  }
+ Here is the caller graph for this function:

◆ setThumbSize()

assKprimChoice::setThumbSize (   $thumbSize)

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

References $thumbSize.

Referenced by loadFromDb().

107  {
108  $this->thumbSize = $thumbSize;
109  }
+ Here is the caller graph for this function:

◆ toJSON()

assKprimChoice::toJSON ( )

Returns a JSON representation of the question.

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

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

918  {
919  $this->lng->loadLanguageModule('assessment');
920 
921  require_once './Services/RTE/classes/class.ilRTE.php';
922  $result = array();
923  $result['id'] = (int) $this->getId();
924  $result['type'] = (string) $this->getQuestionType();
925  $result['title'] = (string) $this->getTitle();
926  $result['question'] = $this->formatSAQuestion($this->getQuestion());
927  $result['instruction'] = $this->getInstructionTextTranslation(
928  $this->lng,
929  $this->getOptionLabel()
930  );
931  $result['nr_of_tries'] = (int) $this->getNrOfTries();
932  $result['shuffle'] = (bool) $this->isShuffleAnswersEnabled();
933  $result['feedback'] = array(
934  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
935  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
936  );
937 
938  $result['trueOptionLabel'] = $this->getTrueOptionLabelTranslation($this->lng, $this->getOptionLabel());
939  $result['falseOptionLabel'] = $this->getFalseOptionLabelTranslation($this->lng, $this->getOptionLabel());
940 
941  $result['num_allowed_failures'] = $this->getNumAllowedFailures();
942 
943  $answers = array();
944  $has_image = false;
945 
946  foreach ($this->getAnswers() as $key => $answer) {
947  if (strlen((string) $answer->getImageFile())) {
948  $has_image = true;
949  }
950 
951  $answers[] = array(
952  'answertext' => (string) $this->formatSAQuestion($answer->getAnswertext()),
953  'correctness' => (bool) $answer->getCorrectness(),
954  'order' => (int) $answer->getPosition(),
955  'image' => (string) $answer->getImageFile(),
956  'feedback' => $this->formatSAQuestion(
957  $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
958  )
959  );
960  }
961 
962  $result['answers'] = $answers;
963 
964  if ($has_image) {
965  $result['path'] = $this->getImagePathWeb();
966  $result['thumb'] = $this->getThumbSize();
967  }
968 
969  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
970  $result['mobs'] = $mobs;
971 
972  return json_encode($result);
973  }
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
getImagePathWeb()
Returns the web image path for web accessable images of a question.
getTrueOptionLabelTranslation(ilLanguage $lng, $optionLabel)
$mobs
getQuestion()
Gets the question string of the question object.
getFalseOptionLabelTranslation(ilLanguage $lng, $optionLabel)
getTitle()
Gets the title string of the assQuestion object.
getInstructionTextTranslation(ilLanguage $lng, $optionLabel)
+ Here is the call graph for this function:

Field Documentation

◆ $answers

assKprimChoice::$answers
private

◆ $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 isSingleLineAnswerType().

◆ DEFAULT_THUMB_SIZE

const assKprimChoice::DEFAULT_THUMB_SIZE = 150

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

◆ NUM_REQUIRED_ANSWERS

const assKprimChoice::NUM_REQUIRED_ANSWERS = 4

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

◆ OPTION_LABEL_ADEQUATE_OR_NOT

const assKprimChoice::OPTION_LABEL_ADEQUATE_OR_NOT = 'adequate_or_not'

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

◆ OPTION_LABEL_APPLICABLE_OR_NOT

const assKprimChoice::OPTION_LABEL_APPLICABLE_OR_NOT = 'applicable_or_not'

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

◆ OPTION_LABEL_CUSTOM

const assKprimChoice::OPTION_LABEL_CUSTOM = 'customlabel'

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

◆ OPTION_LABEL_PLUS_MINUS

const assKprimChoice::OPTION_LABEL_PLUS_MINUS = 'plus_minus'

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

◆ OPTION_LABEL_RIGHT_WRONG

const assKprimChoice::OPTION_LABEL_RIGHT_WRONG = 'right_wrong'

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

◆ PARTIAL_SCORING_NUM_CORRECT_ANSWERS

const assKprimChoice::PARTIAL_SCORING_NUM_CORRECT_ANSWERS = 3

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

◆ THUMB_PREFIX

const assKprimChoice::THUMB_PREFIX = 'thumb.'

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


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