ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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, $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...
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not More...
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 {Creates an Excel worksheet for the detailed cumulated results of this question.
Parameters
object$worksheetReference to the parent excel worksheet
object$startrowStartrow of the output in the excel worksheet
object$active_idActive id of the participant
object$passTest pass
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data @access public
} More...
 
 moveAnswerDown ($position)
 
 moveAnswerUp ($position)
 
- Public Member Functions inherited from assQuestion
 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assQuestion constructor More...
 
 setProcessLocker ($processLocker)
 
 getProcessLocker ()
 
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 isComplete ()
 Returns true, if a question is complete for use. More...
 
 questionTitleExists ($questionpool_id, $title)
 Returns TRUE if the question title exists in the database. More...
 
 setTitle ($title="")
 Sets the title string of the assQuestion object. More...
 
 setId ($id=-1)
 Sets the id of the assQuestion object. More...
 
 setTestId ($id=-1)
 Sets the test id of the assQuestion object. More...
 
 setComment ($comment="")
 Sets the comment string of the assQuestion object. More...
 
 setOutputType ($outputType=OUTPUT_HTML)
 Sets the output type. More...
 
 setShuffle ($shuffle=true)
 Sets the shuffle flag. More...
 
 setEstimatedWorkingTime ($hour=0, $min=0, $sec=0)
 Sets the estimated working time of a question from given hour, minute and second. More...
 
 setEstimatedWorkingTimeFromDurationString ($durationString)
 Sets the estimated working time of a question from a given datetime string. More...
 
 keyInArray ($searchkey, $array)
 returns TRUE if the key occurs in an array More...
 
 setAuthor ($author="")
 Sets the authors name of the assQuestion object. More...
 
 setOwner ($owner="")
 Sets the creator/owner ID of the assQuestion object. More...
 
 getTitle ()
 Gets the title string of the assQuestion object. More...
 
 getId ()
 Gets the id of the assQuestion object. More...
 
 getShuffle ()
 Gets the shuffle flag. More...
 
 getTestId ()
 Gets the test id of the assQuestion object. More...
 
 getComment ()
 Gets the comment string of the assQuestion object. More...
 
 getOutputType ()
 Gets the output type. More...
 
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output. More...
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getEstimatedWorkingTime ()
 Gets the estimated working time of a question. More...
 
 getAuthor ()
 Gets the authors name of the assQuestion object. More...
 
 getOwner ()
 Gets the creator/owner ID of the assQuestion object. More...
 
 getObjId ()
 Get the object id of the container object. More...
 
 setObjId ($obj_id=0)
 Set the object id of the container object. More...
 
 setExternalId ($external_id)
 
 getExternalId ()
 
 _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
_getQuestionInfo ($question_id)
 Returns question information from the database. More...
 
 getSuggestedSolutionOutput ()
 
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 Return the suggested solutions. More...
 
 _getReachedPoints ($active_id, $question_id, $pass=NULL)
 Returns the points, a learner has reached answering the question. More...
 
 getReachedPoints ($active_id, $pass=NULL)
 Returns the points, a learner has reached answering the question This is the fast way to get the points directly from the database. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getAdjustedReachedPoints ($active_id, $pass=NULL)
 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)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question More...
 
 saveWorkingData ($active_id, $pass=NULL)
 Saves the learners input of the question to the database. More...
 
 _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 @TODO Move this to a proper place. More...
 
 logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
 _logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution. More...
 
 getJavaPath ()
 Returns the image path for web accessable images of a question. More...
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 buildImagePath ($questionId, $parentObjectId)
 
 getFlashPath ()
 Returns the image path for web accessable flash files of a question. More...
 
 getJavaPathWeb ()
 Returns the web image path for web accessable java applets of a question. More...
 
 getSuggestedSolutionPathWeb ()
 Returns the web path for a suggested solution. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getFlashPathWeb ()
 Returns the web image path for web accessable flash applications of a question. More...
 
getSolutionValues ($active_id, $pass=NULL)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse ($question_id="")
 Checks whether the question is in use or not. More...
 
 isClone ($question_id="")
 Checks whether the question is a clone of another question or not. More...
 
 pcArrayShuffle ($array)
 Shuffles the values of a given array. More...
 
 getQuestionTypeFromDb ($question_id)
 get question type for question id More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 getTotalAnswers ()
 get total number of answers More...
 
 _getTotalAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
 _getTitle ($a_q_id)
 Returns the title of a question. More...
 
 _getQuestionText ($a_q_id)
 Returns question text. More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 create page object of question More...
 
 copyPageOfQuestion ($a_q_id)
 
 getPageOfQuestion ()
 
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
 _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 fixSvgToPng ($imageFilenameContainingString)
 
 fixUnavailableSkinImageSources ($html)
 
 loadFromDb ($question_id)
 Loads the question from the database. More...
 
 createNewQuestion ($a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb ($original_id="")
 
 saveToDb ($original_id="")
 Saves the question to the database. More...
 
 setNewOriginalId ($newId)
 
 deleteSuggestedSolutions ()
 Deletes all suggestes solutions in the database. More...
 
 getSuggestedSolution ($subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle ($subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution ($solution_id="", $subquestion_index=0, $is_import=false)
 Sets a suggested solution for the question. More...
 
 _resolveInternalLink ($internal_link)
 
 _resolveIntLinks ($question_id)
 
 _getInternalLinkHref ($target="")
 
 syncWithOriginal ()
 
 createRandomSolution ($test_id, $user_id)
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool ($question_id)
 Returns true if the question already exists in the database and is assigned to a question pool. More...
 
 getPoints ()
 Returns the maximum available points for the question. More...
 
 setPoints ($a_points)
 Sets the maximum available points for the question. More...
 
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution. More...
 
 _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution. More...
 
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
 _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not. More...
 
 calculateReachedPoints ($active_id, $pass=NULL, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question. More...
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=NULL)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=FALSE)
 Prepares a string for a text area output in tests. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addQTIMaterial (&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE)
 Creates a QTI material tag from a plain text or xhtml text. More...
 
 createNewImageFileName ($image_filename, $unique=false)
 
 _setReachedPoints ($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
 getQuestion ()
 Gets the question string of the question object. More...
 
 setQuestion ($question="")
 Sets the question string of the question object. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 Returns the question type of the question. More...
 
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table More...
 
getInstances ()
 Gets all instances of the question. More...
 
 _needsManualScoring ($question_id)
 
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id. More...
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getNrOfTries ()
 
 setNrOfTries ($a_nr_of_tries)
 
 setExportImagePath ($a_path)
 
 _questionExistsInTest ($question_id, $test_id)
 
 formatSAQuestion ($a_q)
 Format self assessment question. More...
 
 setPreventRteUsage ($a_val)
 Set prevent rte usage. More...
 
 getPreventRteUsage ()
 Get prevent rte usage. More...
 
 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...
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not More...
 
 setObligationsToBeConsidered ($obligationsToBeConsidered=true)
 sets the flag wether obligations are to be considered or not More...
 
 areObligationsToBeConsidered ()
 gets the flag wether obligations are to be considered 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 ()
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
 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...
 

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

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'
 

Protected Member Functions

 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. More...
 
 generateThumbForFile ($path, $file)
 
 getSolutionSubmit ()
 
 calculateReachedPointsForSolution ($found_values, $active_id=0)
 
 beforeSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 cloneAnswerImages ($sourceQuestionId, $sourceParentId, $targetQuestionId, $targetParentId)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
- Protected Member Functions inherited from assQuestion
 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. More...
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID. More...
 
 onDuplicate ($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test) More...
 
 beforeSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 onCopy ($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId)
 Will be called when a question is copied (into another question pool) More...
 
 duplicateSuggestedSolutionFiles ($parent_id, $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles ($original_id)
 Syncs the files of a suggested solution if the question is synced. More...
 
 copySuggestedSolutionFiles ($source_questionpool_id, $source_question_id)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 
 buildQuestionDataQuery ()
 
 getSelfAssessmentFormatter ()
 

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...
 
- Protected Attributes inherited from assQuestion
 $id
 
 $title
 
 $comment
 
 $owner
 
 $author
 
 $question
 
 $points
 
 $est_working_time
 
 $shuffle
 
 $test_id
 
 $obj_id
 
 $ilias
 
 $tpl
 
 $lng
 
 $db
 
 $outputType
 
 $suggested_solutions
 
 $original_id
 
 $page
 
 $external_id = ''
 
 $questionChangeListeners = array()
 
 $processLocker
 
 $step = null
 
 $lastChange
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $imageSourceFixReplaceMap
 

Detailed Description

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

51 {
52 parent::__construct($title, $comment, $author, $owner, $question);
53
54 $this->shuffleAnswersEnabled = true;
55 $this->answerType = self::ANSWER_TYPE_SINGLE_LINE;
56 $this->thumbSize = self::DEFAULT_THUMB_SIZE;
57 $this->scorePartialSolutionEnabled = true;
58 $this->optionLabel = self::OPTION_LABEL_RIGHT_WRONG;
59 $this->customTrueOptionLabel = '';
60 $this->customFalseOptionLabel = '';
61
62 require_once 'Modules/TestQuestionPool/classes/feedback/class.ilAssConfigurableMultiOptionQuestionFeedback.php';
64
65 $this->answers = array();
66
67 $this->setPoints('');
68 }
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 188 of file class.assKprimChoice.php.

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

◆ afterSyncWithOriginal()

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

Reimplemented from assQuestion.

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

910 {
911 parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
912
913 $this->cloneAnswerImages($dupQuestionId, $dupParentObjId, $origQuestionId, $origParentObjId);
914 }
cloneAnswerImages($sourceQuestionId, $sourceParentId, $targetQuestionId, $targetParentId)

References cloneAnswerImages().

+ Here is the call graph for this function:

◆ beforeSyncWithOriginal()

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

Reimplemented from assQuestion.

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

898 {
899 parent::beforeSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
900
901 $question = self::_instanciateQuestion($origQuestionId);
902
903 foreach($question->getAnswers() as $answer)
904 {
905 $question->removeAnswerImage($answer->getPosition());
906 }
907 }
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,
  $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 473 of file class.assKprimChoice.php.

474 {
475 if( $returndetails )
476 {
477 throw new ilTestException('return details not implemented for '.__METHOD__);
478 }
479
480 global $ilDB;
481
482 $found_values = array();
483 if (is_null($pass))
484 {
485 $pass = $this->getSolutionMaxPass($active_id);
486 }
487 $result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
488 array('integer','integer','integer'),
489 array($active_id, $this->getId(), $pass)
490 );
491 while ($data = $ilDB->fetchAssoc($result))
492 {
493 $found_values[(int)$data['value1']] = (int)$data['value2'];
494 }
495
496 $points = $this->calculateReachedPointsForSolution($found_values, $active_id);
497
498 return $points;
499 }
$result
calculateReachedPointsForSolution($found_values, $active_id=0)
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
getId()
Gets the id of the assQuestion object.
Base Exception for all Exceptions relating to Modules/Test.
global $ilDB

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

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

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

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

729 {
730 $numCorrect = 0;
731
732 foreach($this->getAnswers() as $key => $answer)
733 {
734 if( !isset($found_values[$answer->getPosition()]) )
735 {
736 continue;
737 }
738
739 if( $found_values[$answer->getPosition()] == $answer->getCorrectness() )
740 {
741 $numCorrect++;
742 }
743 }
744
745 if( $numCorrect >= self::NUM_REQUIRED_ANSWERS )
746 {
747 $points = $this->getPoints();
748 }
749 elseif( $this->isScorePartialSolutionEnabled() && $numCorrect >= self::PARTIAL_SCORING_NUM_CORRECT_ANSWERS )
750 {
751 $points = $this->getPoints() / 2;
752 }
753 else
754 {
755 $points = 0;
756 }
757
758 if($active_id)
759 {
760 include_once "./Modules/Test/classes/class.ilObjTest.php";
761 $mc_scoring = ilObjTest::_getMCScoring($active_id);
762 if(($mc_scoring == 0) && (count($found_values) == 0))
763 {
764 $points = 0;
765 }
766 }
767 return $points;
768 }
getPoints()
Returns the maximum available points for the question.
_getMCScoring($active_id)
Gets the scoring type for multiple choice questions.

References 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:

◆ cloneAnswerImages()

assKprimChoice::cloneAnswerImages (   $sourceQuestionId,
  $sourceParentId,
  $targetQuestionId,
  $targetParentId 
)
protected

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

917 {
918 global $ilLog;
919
920 $sourcePath = $this->buildImagePath($sourceQuestionId, $sourceParentId);
921 $targetPath = $this->buildImagePath($targetQuestionId, $targetParentId);
922
923 foreach($this->getAnswers() as $answer)
924 {
925 $filename = $answer->getImageFile();
926
927 if (strlen($filename))
928 {
929 if (!file_exists($targetPath))
930 {
931 ilUtil::makeDirParents($targetPath);
932 }
933
934 if (!@copy($sourcePath.$filename, $targetPath.$filename))
935 {
936 $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
937 $ilLog->write("object: " . print_r($this, TRUE), $ilLog->ERROR);
938 }
939
940 if (@file_exists($sourcePath.$this->getThumbPrefix().$filename))
941 {
942 if (!@copy($sourcePath.$this->getThumbPrefix().$filename, $targetPath.$this->getThumbPrefix().$filename))
943 {
944 $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
945 $ilLog->write("object: " . print_r($this, TRUE), $ilLog->ERROR);
946 }
947 }
948 }
949 }
950 }
$filename
Definition: buildRTE.php:89
buildImagePath($questionId, $parentObjectId)
static makeDirParents($a_dir)
Create a new directory and all parent directories.

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

Referenced by afterSyncWithOriginal().

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

867 {
868 if ($this->id <= 0)
869 {
870 // The question has not been saved. It cannot be duplicated
871 return;
872 }
873 // duplicate the question in database
874 $clone = $this;
875 include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
877 $clone->id = -1;
878 $source_questionpool_id = $this->getObjId();
879 $clone->setObjId($target_questionpool_id);
880 if ($title)
881 {
882 $clone->setTitle($title);
883 }
884 $clone->saveToDb();
885 // copy question page content
886 $clone->copyPageOfQuestion($original_id);
887 // copy XHTML media objects
888 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
889 // duplicate the image
890 $clone->cloneAnswerImages($original_id, $source_questionpool_id, $clone->getId(), $clone->getObjId());
891
892 $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
893
894 return $clone->id;
895 }
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 826 of file class.assKprimChoice.php.

827 {
828 if ($this->id <= 0)
829 {
830 // The question has not been saved. It cannot be duplicated
831 return;
832 }
833
834 include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
835
836 $sourceQuestionId = $this->id;
837 $sourceParentId = $this->getObjId();
838
839 // duplicate the question in database
840 $clone = $this;
841 $clone->id = -1;
842
843 $clone->setObjId($targetParentId);
844
845 if ($targetQuestionTitle)
846 {
847 $clone->setTitle($targetQuestionTitle);
848 }
849
850 $clone->saveToDb();
851 // copy question page content
852 $clone->copyPageOfQuestion($sourceQuestionId);
853 // copy XHTML media objects
854 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
855 // duplicate the image
856 $clone->cloneAnswerImages($sourceQuestionId, $sourceParentId, $clone->getId(), $clone->getObjId());
857
858 $clone->onCopy($sourceParentId, $sourceQuestionId, $targetParentId, $clone->getId());
859
860 return $clone->id;
861 }

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

771 {
772 if ($this->id <= 0)
773 {
774 // The question has not been saved. It cannot be duplicated
775 return;
776 }
777 // duplicate the question in database
778 $this_id = $this->getId();
779 $thisObjId = $this->getObjId();
780
781 $clone = $this;
782 include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
784 $clone->id = -1;
785
786 if( (int)$testObjId > 0 )
787 {
788 $clone->setObjId($testObjId);
789 }
790
791 if ($title)
792 {
793 $clone->setTitle($title);
794 }
795
796 if ($author)
797 {
798 $clone->setAuthor($author);
799 }
800 if ($owner)
801 {
802 $clone->setOwner($owner);
803 }
804
805 if ($for_test)
806 {
807 $clone->saveToDb($original_id);
808 }
809 else
810 {
811 $clone->saveToDb();
812 }
813
814 // copy question page content
815 $clone->copyPageOfQuestion($this_id);
816 // copy XHTML media objects
817 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
818 // duplicate the images
819 $clone->cloneAnswerImages($this_id, $thisObjId, $clone->getId(), $clone->getObjId());
820
821 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
822
823 return $clone->id;
824 }

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

633 {
635 if (@file_exists($filename))
636 {
637 $thumbpath = $path . $this->getThumbPrefix() . $file;
638 $path_info = @pathinfo($filename);
639 $ext = "";
640 switch (strtoupper($path_info['extension']))
641 {
642 case 'PNG':
643 $ext = 'PNG';
644 break;
645 case 'GIF':
646 $ext = 'GIF';
647 break;
648 default:
649 $ext = 'JPEG';
650 break;
651 }
652 ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbSize());
653 }
654 }
print $file
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
$path
Definition: index.php:22

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

Referenced by rebuildThumbnails().

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

76 {
77 return "qpl_qst_kprim";
78 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAnswer()

assKprimChoice::getAnswer (   $position)

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

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

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

81 {
82 return "qpl_a_kprim";
83 }

Referenced by saveAnswerSpecificDataToDb().

+ Here is the caller graph for this function:

◆ getAnswerType()

assKprimChoice::getAnswerType ( )

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

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

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

522 {
523 return array(
524 self::ANSWER_TYPE_SINGLE_LINE => $lng->txt('answers_singleline'),
525 self::ANSWER_TYPE_MULTI_LINE => $lng->txt('answers_multiline')
526 );
527 }

References assQuestion\$lng.

◆ getCustomFalseOptionLabel()

assKprimChoice::getCustomFalseOptionLabel ( )

Definition at line 150 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 140 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 578 of file class.assKprimChoice.php.

579 {
580 switch($optionLabel)
581 {
583 return $lng->txt('option_label_wrong');
584
586 return $lng->txt('option_label_minus');
587
589 return $lng->txt('option_label_not_applicable');
590
592 return $lng->txt('option_label_not_adequate');
593
595 return $this->getCustomFalseOptionLabel();
596 }
597 }
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 599 of file class.assKprimChoice.php.

600 {
601 return sprintf(
602 $lng->txt('kprim_instruction_text'),
603 $this->getTrueOptionLabelTranslation($lng, $optionLabel),
604 $this->getFalseOptionLabelTranslation($lng, $optionLabel)
605 );
606 }

References assQuestion\$lng, and $optionLabel.

Referenced by toJSON().

+ Here is the caller graph for this function:

◆ getNumAllowedFailures()

assKprimChoice::getNumAllowedFailures ( )
private

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

1028 {
1029 if( $this->isScorePartialSolutionEnabled() )
1030 {
1031 return self::NUM_REQUIRED_ANSWERS - self::PARTIAL_SCORING_NUM_CORRECT_ANSWERS;
1032 }
1033
1034 return 0;
1035 }
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 130 of file class.assKprimChoice.php.

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

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

71 {
72 return 'assKprimChoice';
73 }

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

953 {
954 $combinedText = parent::getRTETextWithMediaObjects();
955
956 foreach($this->getAnswers() as $answer)
957 {
958 $combinedText .= $answer->getAnswertext();
959 }
960
961 return $combinedText;
962 }

References getAnswers().

+ Here is the call graph for this function:

◆ getSolutionSubmit()

assKprimChoice::getSolutionSubmit ( )
protected

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

711 {
712 $solutionSubmit = array();
713 foreach($_POST as $key => $value)
714 {
715 $matches = null;
716
717 if(preg_match("/^kprim_choice_result_(\d+)/", $key, $matches))
718 {
719 if(strlen($value))
720 {
721 $solutionSubmit[$matches[1]] = $value;
722 }
723 }
724 }
725 return $solutionSubmit;
726 }
$_POST['username']
Definition: cron.php:12

References $_POST.

◆ getSpecificFeedbackSetting()

assKprimChoice::getSpecificFeedbackSetting ( )

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

References $specificFeedbackSetting.

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getThumbPrefix()

assKprimChoice::getThumbPrefix ( )

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

614 {
615 return self::THUMB_PREFIX;
616 }

References THUMB_PREFIX.

Referenced by generateThumbForFile(), and loadAnswerData().

+ Here is the caller graph for this function:

◆ getThumbSize()

assKprimChoice::getThumbSize ( )

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

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

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

558 {
559 switch($optionLabel)
560 {
562 return $lng->txt('option_label_right');
563
565 return $lng->txt('option_label_plus');
566
568 return $lng->txt('option_label_applicable');
569
571 return $lng->txt('option_label_adequate');
572
574 return $this->getCustomTrueOptionLabel();
575 }
576 }

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

502 {
503 return array(self::ANSWER_TYPE_SINGLE_LINE, self::ANSWER_TYPE_MULTI_LINE);
504 }

Referenced by isValidAnswerType().

+ Here is the caller graph for this function:

◆ getValidOptionLabels()

assKprimChoice::getValidOptionLabels ( )

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

530 {
531 return array(
532 self::OPTION_LABEL_RIGHT_WRONG,
533 self::OPTION_LABEL_PLUS_MINUS,
534 self::OPTION_LABEL_APPLICABLE_OR_NOT,
535 self::OPTION_LABEL_ADEQUATE_OR_NOT,
536 self::OPTION_LABEL_CUSTOM
537 );
538 }

Referenced by isValidOptionLabel().

+ Here is the caller graph for this function:

◆ getValidOptionLabelsTranslated()

assKprimChoice::getValidOptionLabelsTranslated ( ilLanguage  $lng)

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

541 {
542 return array(
543 self::OPTION_LABEL_RIGHT_WRONG => $lng->txt('option_label_right_wrong'),
544 self::OPTION_LABEL_PLUS_MINUS => $lng->txt('option_label_plus_minus'),
545 self::OPTION_LABEL_APPLICABLE_OR_NOT => $lng->txt('option_label_applicable_or_not'),
546 self::OPTION_LABEL_ADEQUATE_OR_NOT => $lng->txt('option_label_adequate_or_not'),
547 self::OPTION_LABEL_CUSTOM => $lng->txt('option_label_custom')
548 );
549 }

References assQuestion\$lng.

◆ handleFileUpload()

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

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

672 {
673 $imagePath = $this->getImagePath();
674
675 if( !file_exists($imagePath) )
676 {
677 ilUtil::makeDirParents($imagePath);
678 }
679
680 $filename = $this->createNewImageFileName($fileData['name'], true);
681
682 $answer->setImageFsDir($imagePath);
683 $answer->setImageFile($filename);
684
685 if( !ilUtil::moveUploadedFile($fileData['tmp_name'], $fileData['name'], $answer->getImageFsPath()) )
686 {
687 return 2;
688 }
689
690 return 0;
691 }
createNewImageFileName($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

References $filename, assQuestion\createNewImageFileName(), ilAssKprimChoiceAnswer\getImageFsPath(), assQuestion\getImagePath(), ilUtil\makeDirParents(), ilUtil\moveUploadedFile(), 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 656 of file class.assKprimChoice.php.

657 {
658 foreach($answers as $answer)
659 {
660 /* @var ilAssKprimChoiceAnswer $answer */
661
662 if( !isset($files[$answer->getPosition()]) )
663 {
664 continue;
665 }
666
667 $this->handleFileUpload($answer, $files[$answer->getPosition()]);
668 }
669 }
handleFileUpload(ilAssKprimChoiceAnswer $answer, $fileData)

References $answers, 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 1042 of file class.assKprimChoice.php.

1043 {
1044 $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1045
1046 return $numExistingSolutionRecords >= 4;
1047 }
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 351 of file class.assKprimChoice.php.

352 {
353 foreach( array($this->title, $this->author, $this->question) as $text )
354 {
355 if( !strlen($text) )
356 {
357 return false;
358 }
359 }
360
361 if( $this->getMaximumPoints() <= 0 )
362 {
363 return false;
364 }
365
366 foreach( $this->getAnswers() as $answer )
367 {
368 /* @var ilAssKprimChoiceAnswer $answer */
369
370 if( is_null($answer->getCorrectness()) )
371 {
372 return false;
373 }
374
375 if( !strlen($answer->getAnswertext()) && !strlen($answer->getImageFile()) )
376 {
377 return false;
378 }
379 }
380
381 return true;
382 }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.

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

+ Here is the call graph for this function:

◆ isCustomOptionLabel()

assKprimChoice::isCustomOptionLabel (   $labelValue)

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

609 {
610 return $labelValue == self::OPTION_LABEL_CUSTOM;
611 }

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

1038 {
1039 return true;
1040 }

◆ isScorePartialSolutionEnabled()

assKprimChoice::isScorePartialSolutionEnabled ( )

Definition at line 120 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 90 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 512 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 506 of file class.assKprimChoice.php.

507 {
508 $validTypes = $this->getValidAnswerTypes();
509 return in_array($answerType, $validTypes);
510 }

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

552 {
553 $validLabels = $this->getValidOptionLabels();
554 return in_array($optionLabel, $validLabels);
555 }

References $optionLabel, and getValidOptionLabels().

Referenced by loadFromDb().

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

◆ loadAnswerData()

assKprimChoice::loadAnswerData (   $questionId)
private

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

261 {
262 global $ilDB;
263
264 $res = $this->db->queryF(
265 "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY position ASC",
266 array('integer'), array($questionId)
267 );
268
269 require_once 'Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
270 require_once 'Services/RTE/classes/class.ilRTE.php';
271
272 while($data = $ilDB->fetchAssoc($res))
273 {
274 $answer = new ilAssKprimChoiceAnswer();
275
276 $answer->setPosition($data['position']);
277
278 $answer->setAnswertext(ilRTE::_replaceMediaObjectImageSrc($data['answertext'], 1));
279
280 $answer->setImageFile($data['imagefile']);
281 $answer->setThumbPrefix($this->getThumbPrefix());
282 $answer->setImageFsDir($this->getImagePath());
283 $answer->setImageWebDir($this->getImagePathWeb());
284
285 $answer->setCorrectness($data['correctness']);
286
287 $this->answers[$answer->getPosition()] = $answer;
288 }
289
290 for( $i = count($this->answers); $i < self::NUM_REQUIRED_ANSWERS; $i++ )
291 {
292 $answer = new ilAssKprimChoiceAnswer();
293
294 $answer->setPosition($i);
295
296 $this->answers[$answer->getPosition()] = $answer;
297 }
298 }
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...

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

194 {
195 $res = $this->db->queryF($this->buildQuestionDataQuery(), array('integer'), array($questionId));
196
197 while($data = $this->db->fetchAssoc($res))
198 {
199 $this->setId($questionId);
200
201 $this->setOriginalId($data['original_id']);
202
203 $this->setObjId($data['obj_fi']);
204
205 $this->setTitle($data['title']);
206 $this->setNrOfTries($data['nr_of_tries']);
207 $this->setComment($data['description']);
208 $this->setAuthor($data['author']);
209 $this->setPoints($data['points']);
210 $this->setOwner($data['owner']);
211 $this->setEstimatedWorkingTimeFromDurationString($data['working_time']);
212 $this->setLastChange($data['tstamp']);
213 require_once 'Services/RTE/classes/class.ilRTE.php';
214 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data['question_text'], 1));
215
216 $this->setShuffleAnswersEnabled((bool)$data['shuffle_answers']);
217
218 if( $this->isValidAnswerType($data['answer_type']) )
219 {
220 $this->setAnswerType($data['answer_type']);
221 }
222
223 if( is_numeric($data['thumb_size']) )
224 {
225 $this->setThumbSize((int)$data['thumb_size']);
226 }
227
228 if( $this->isValidOptionLabel($data['opt_label']) )
229 {
230 $this->setOptionLabel($data['opt_label']);
231 }
232
233 $this->setCustomTrueOptionLabel($data['custom_true']);
234 $this->setCustomFalseOptionLabel($data['custom_false']);
235
236 if( $data['score_partsol'] !== null )
237 {
238 $this->setScorePartialSolutionEnabled((bool)$data['score_partsol']);
239 }
240
241 if( isset($data['feedback_setting']) )
242 {
243 $this->setSpecificFeedbackSetting((int)$data['feedback_setting']);
244 }
245
246 try
247 {
248 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
249 }
251 {
252 }
253 }
254
255 $this->loadAnswerData($questionId);
256
257 parent::loadFromDb($questionId);
258 }
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 1079 of file class.assKprimChoice.php.

1080 {
1081 if( $position < 0 || $position >= (self::NUM_REQUIRED_ANSWERS - 1) )
1082 {
1083 return false;
1084 }
1085
1086 for($i = 0, $max = count($this->answers); $i < $max; $i++)
1087 {
1088 if( $i == $position )
1089 {
1090 $movingAnswer = $this->answers[$i];
1091 $targetAnswer = $this->answers[ $i + 1 ];
1092
1093 $movingAnswer->setPosition( $position + 1 );
1094 $targetAnswer->setPosition( $position );
1095
1096 $this->answers[ $i + 1 ] = $movingAnswer;
1097 $this->answers[$i] = $targetAnswer;
1098 }
1099 }
1100 }

◆ moveAnswerUp()

assKprimChoice::moveAnswerUp (   $position)

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

1103 {
1104 if( $position <= 0 || $position > (self::NUM_REQUIRED_ANSWERS - 1) )
1105 {
1106 return false;
1107 }
1108
1109 for($i = 0, $max = count($this->answers); $i < $max; $i++)
1110 {
1111 if( $i == $position )
1112 {
1113 $movingAnswer = $this->answers[$i];
1114 $targetAnswer = $this->answers[ $i - 1 ];
1115
1116 $movingAnswer->setPosition( $position - 1 );
1117 $targetAnswer->setPosition( $position );
1118
1119 $this->answers[ $i - 1 ] = $movingAnswer;
1120 $this->answers[$i] = $targetAnswer;
1121 }
1122 }
1123
1124 return true;
1125 }

◆ rebuildThumbnails()

assKprimChoice::rebuildThumbnails ( )

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

619 {
620 if( $this->isSingleLineAnswerType($this->getAnswerType()) && $this->getThumbSize() )
621 {
622 foreach ($this->getAnswers() as $answer)
623 {
624 if (strlen($answer->getImageFile()))
625 {
626 $this->generateThumbForFile($answer->getImageFsDir(), $answer->getImageFile());
627 }
628 }
629 }
630 }
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 693 of file class.assKprimChoice.php.

694 {
695 $answer = $this->getAnswer($position);
696
697 if( file_exists($answer->getImageFsPath()) )
698 {
699 unlink($answer->getImageFsPath());
700 }
701
702 if( file_exists($answer->getThumbFsPath()) )
703 {
704 unlink($answer->getThumbFsPath());
705 }
706
707 $answer->setImageFile(null);
708 }

References getAnswer().

+ Here is the call graph for this function:

◆ reworkWorkingData()

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

Reworks the allready saved working data if neccessary.

@access protected

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered

Reimplemented from assQuestion.

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

459 {
460 // nothing to do
461 }

◆ saveAdditionalQuestionDataToDb()

assKprimChoice::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

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

311 {
312 $this->db->replace(
313 $this->getAdditionalTableName(),
314 array(
315 'question_fi' => array('integer', $this->getId())
316 ),
317 array(
318 'shuffle_answers' => array('integer', (int)$this->isShuffleAnswersEnabled()),
319 'answer_type' => array('text', $this->getAnswerType()),
320 'thumb_size' => array('integer', (int)$this->getThumbSize()),
321 'opt_label' => array('text', $this->getOptionLabel()),
322 'custom_true' => array('text', $this->getCustomTrueOptionLabel()),
323 'custom_false' => array('text', $this->getCustomFalseOptionLabel()),
324 'score_partsol' => array('integer', (int)$this->isScorePartialSolutionEnabled()),
325 'feedback_setting' => array('integer', (int)$this->getSpecificFeedbackSetting())
326 )
327 );
328 }
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 330 of file class.assKprimChoice.php.

331 {
332 foreach($this->getAnswers() as $answer)
333 {
334 $this->db->replace(
335 $this->getAnswerTableName(),
336 array(
337 'question_fi' => array('integer', (int)$this->getId()),
338 'position' => array('integer', (int)$answer->getPosition())
339 ),
340 array(
341 'answertext' => array('text', $answer->getAnswertext()),
342 'imagefile' => array('text', $answer->getImageFile()),
343 'correctness' => array('integer', (int)$answer->getCorrectness())
344 )
345 );
346 }
347
348 $this->rebuildThumbnails();
349 }
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 300 of file class.assKprimChoice.php.

301 {
302 $this->saveQuestionDataToDb($originalId);
303
306
307 parent::saveToDb($originalId);
308 }
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 165 of file class.assKprimChoice.php.

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

References $answers.

◆ setAnswerType()

assKprimChoice::setAnswerType (   $answerType)

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

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

References $answerType.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setCustomFalseOptionLabel()

assKprimChoice::setCustomFalseOptionLabel (   $customFalseOptionLabel)

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

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

References $customFalseOptionLabel.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setCustomTrueOptionLabel()

assKprimChoice::setCustomTrueOptionLabel (   $customTrueOptionLabel)

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

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

References $customTrueOptionLabel.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

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

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

Parameters
object$worksheetReference to the parent excel worksheet
object$startrowStartrow of the output in the excel worksheet
object$active_idActive id of the participant
object$passTest pass
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data @access public
}

Reimplemented from assQuestion.

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

1053 {
1054 require_once 'Services/Excel/classes/class.ilExcelUtils.php';
1055
1056 $solution = $this->getSolutionValues($active_id, $pass);
1057
1058 $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
1059 $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
1060 $i = 1;
1061 foreach($this->getAnswers() as $id => $answer)
1062 {
1063 $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($answer->getAnswertext()), $format_bold);
1064 $correctness = FALSE;
1065 foreach($solution as $solutionvalue)
1066 {
1067 if($id == $solutionvalue['value1'])
1068 {
1069 $correctness = $solutionvalue['value2'];
1070 break;
1071 }
1072 }
1073 $worksheet->write($startrow + $i, 1, $correctness);
1074 $i++;
1075 }
1076 return $startrow + $i + 1;
1077 }
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
getTitle()
Gets the title string of the assQuestion object.
_convert_text($a_text, $a_target="has been removed")

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

+ Here is the call graph for this function:

◆ setOptionLabel()

assKprimChoice::setOptionLabel (   $optionLabel)

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

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

References $optionLabel.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setScorePartialSolutionEnabled()

assKprimChoice::setScorePartialSolutionEnabled (   $scorePartialSolutionEnabled)

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

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

References $scorePartialSolutionEnabled.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setShuffleAnswersEnabled()

assKprimChoice::setShuffleAnswersEnabled (   $shuffleAnswersEnabled)

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

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

References $shuffleAnswersEnabled.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setSpecificFeedbackSetting()

assKprimChoice::setSpecificFeedbackSetting (   $specificFeedbackSetting)

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

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

References $specificFeedbackSetting.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setThumbSize()

assKprimChoice::setThumbSize (   $thumbSize)

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

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

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

968 {
969 $this->lng->loadLanguageModule('assessment');
970
971 require_once './Services/RTE/classes/class.ilRTE.php';
972 $result = array();
973 $result['id'] = (int) $this->getId();
974 $result['type'] = (string) $this->getQuestionType();
975 $result['title'] = (string) $this->getTitle();
976 $result['question'] = $this->formatSAQuestion($this->getQuestion());
977 $result['instruction'] = $this->getInstructionTextTranslation(
978 $this->lng, $this->getOptionLabel()
979 );
980 $result['nr_of_tries'] = (int) $this->getNrOfTries();
981 $result['shuffle'] = (bool) $this->isShuffleAnswersEnabled();
982 $result['feedback'] = array(
983 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
984 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
985 );
986
987 $result['trueOptionLabel'] = $this->getTrueOptionLabelTranslation($this->lng, $this->getOptionLabel());
988 $result['falseOptionLabel'] = $this->getFalseOptionLabelTranslation($this->lng, $this->getOptionLabel());
989
990 $result['num_allowed_failures'] = $this->getNumAllowedFailures();
991
992 $answers = array();
993 $has_image = false;
994
995 foreach( $this->getAnswers() as $key => $answer )
996 {
997 if( strlen((string)$answer->getImageFile()) )
998 {
999 $has_image = true;
1000 }
1001
1002 $answers[] = array(
1003 'answertext' => (string) $this->formatSAQuestion($answer->getAnswertext()),
1004 'correctness' => (bool) $answer->getCorrectness(),
1005 'order' => (int)$answer->getPosition(),
1006 'image' => (string)$answer->getImageFile(),
1007 'feedback' => $this->formatSAQuestion(
1008 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key)
1009 )
1010 );
1011 }
1012
1013 $result['answers'] = $answers;
1014
1015 if($has_image)
1016 {
1017 $result['path'] = $this->getImagePathWeb();
1018 $result['thumb'] = $this->getThumbSize();
1019 }
1020
1021 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1022 $result['mobs'] = $mobs;
1023
1024 return json_encode($result);
1025 }
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.
getQuestion()
Gets the question string of the question object.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
$mobs

References $answers, $mobs, $result, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getAnswers(), 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 48 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 42 of file class.assKprimChoice.php.

Referenced by getCustomTrueOptionLabel(), and setCustomTrueOptionLabel().

◆ $optionLabel

◆ $scorePartialSolutionEnabled

assKprimChoice::$scorePartialSolutionEnabled
private

◆ $shuffleAnswersEnabled

assKprimChoice::$shuffleAnswersEnabled
private

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

Referenced by isShuffleAnswersEnabled(), and setShuffleAnswersEnabled().

◆ $specificFeedbackSetting

assKprimChoice::$specificFeedbackSetting
private

◆ $thumbSize

assKprimChoice::$thumbSize
private

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

Referenced by __construct(), and isSingleLineAnswerType().

◆ DEFAULT_THUMB_SIZE

const assKprimChoice::DEFAULT_THUMB_SIZE = 150

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

Referenced by __construct().

◆ NUM_REQUIRED_ANSWERS

const assKprimChoice::NUM_REQUIRED_ANSWERS = 4

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

Referenced by getNumAllowedFailures().

◆ THUMB_PREFIX

const assKprimChoice::THUMB_PREFIX = 'thumb.'

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

Referenced by getThumbPrefix().


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