ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
assFormulaQuestion Class Reference

Class for single choice questions assFormulaQuestion is a class for single choice questions. More...

+ Inheritance diagram for assFormulaQuestion:
+ Collaboration diagram for assFormulaQuestion:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assFormulaQuestion constructor The constructor takes possible arguments an creates an instance of the assFormulaQuestion object. More...
 
 clearVariables ()
 
 getVariables ()
 
 getVariable ($variable)
 
 addVariable ($variable)
 
 clearResults ()
 
 getResults ()
 
 getResult ($result)
 
 addResult ($result)
 
 addResultUnits ($result, $unit_ids)
 
 addResultUnit ($result, $unit)
 
 getResultUnits ($result)
 
 hasResultUnit ($result, $unit_id)
 
 parseQuestionText ()
 
 checkForDuplicateVariables ()
 
 checkForDuplicateResults ()
 
 fetchAllResults ($questionText)
 
 fetchAllVariables ($questionText)
 
 hasRequiredVariableSolutionValues (array $userSolution)
 
 getInitialVariableSolutionValues ()
 
 substituteVariables (array $userdata, $graphicalOutput=FALSE, $forsolution=FALSE, $result_output=FALSE)
 
 canUseAdvancedRating ($result)
 Check if advanced rating can be used for a result. More...
 
 isComplete ()
 Returns true, if the question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a assFormulaQuestion object to a database public. More...
 
 loadFromDb ($question_id)
 Loads a assFormulaQuestion object from a database. More...
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates an assFormulaQuestion public. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assFormulaQuestion object public. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 calculateReachedPoints ($active_id, $pass=NULL, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question The points are calculated from the given answers. More...
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 saveWorkingData ($active_id, $pass=NULL, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 getBestSolution ($solutions)
 Returns the best solution for a given pass of a participant. More...
 
 setId ($id=-1)
 
 __get ($value)
 Object getter. More...
 
 setUnitrepository ($unitrepository)
 
 getUnitrepository ()
 
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 
 removeCurrentSolution ($active_id, $pass, $authorized=true, $ignoredSolutionIds=array())
 
 removeExistingSolutions ($activeId, $pass)
 
- 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...
 
 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, $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...
 
 saveWorkingData ($active_id, $pass=NULL, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 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...
 
 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...
 
 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, $authorizedSolution=true, $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, $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...
 
 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...
 
 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, $ignoredSolutionIds=array())
 
 saveCurrentSolution ($active_id, $pass, $value1, $value2, $authorized=true)
 
 updateCurrentSolution ($solutionId, $value1, $value2, $authorized=true)
 
 updateCurrentSolutionsAuthorization ($activeId, $pass, $authorized)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
 authorizedSolutionExists ($active_id, $pass)
 
 authorizedOrIntermediateSolutionExists ($active_id, $pass)
 
 lookupForExistingSolutions ($activeId, $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 removeExistingSolutions ($activeId, $pass)
 
 resetUsersAnswer ($activeId, $pass)
 
 removeResultRecord ($activeId, $pass)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered ($obligationsToBeConsidered)
 
 validateSolutionSubmit ()
 
 updateTimestamp ()
 
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 

Protected Member Functions

 isValidSolutionResultValue ($submittedValue)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. More...
 
 getSolutionSubmit ()
 
 getVariableSolutionIds ($active_id, $pass)
 
- Protected Member Functions inherited from assQuestion
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 Reworks the allready saved working data if neccessary. More...
 
 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...
 
 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)
 
 getSelfAssessmentFormatter ()
 

Private Attributes

 $variables
 
 $results
 
 $resultunits
 
 $unitrepository
 

Additional Inherited Members

- 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 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)
 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)
 
static missingResultRecordExists ($activeId, $pass, $questionIds)
 
static lookupResultRecordExist ($activeId, $questionId, $pass)
 
- 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'
 
- Data Fields inherited from iQuestionCondition
const StringResultExpression = '~TEXT~'
 
const PercentageResultExpression = '%n%'
 
const NumericResultExpression = '#n#'
 
const MatchingResultExpression = ';n:m;'
 
const OrderingResultExpression = '$n,m,o,p$'
 
const NumberOfResultExpression = '+n+'
 
const ExclusiveResultExpression = '*n,m,o,p*'
 
const EmptyAnswerExpression = "?"
 
- 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
 
 $shuffler
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $forcePassResultsUpdateEnabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

Class for single choice questions assFormulaQuestion is a class for single choice questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
Id
class.assFormulaQuestion.php 1236 2010-02-15 15:44:16Z hschottm

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

Constructor & Destructor Documentation

◆ __construct()

assFormulaQuestion::__construct (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $question = "" 
)

assFormulaQuestion constructor The constructor takes possible arguments an creates an instance of the assFormulaQuestion object.

Parameters
string$titleA title string to describe the question
string$commentA comment string to describe the question
string$authorA string containing the name of the questions author
integer$ownerA numerical ID to identify the owner/creator
string$questionThe question string of the single choice question public
See also
assQuestion:assQuestion()

Definition at line 41 of file class.assFormulaQuestion.php.

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

48  {
49  parent::__construct($title, $comment, $author, $owner, $question);
50  $this->variables = array();
51  $this->results = array();
52  $this->resultunits = array();
53  $this->unitrepository = new ilUnitConfigurationRepository(0);
54 
55  }
Class ilUnitConfigurationRepository.

Member Function Documentation

◆ __get()

assFormulaQuestion::__get (   $value)

Object getter.

Definition at line 1368 of file class.assFormulaQuestion.php.

References $resultunits.

1369  {
1370  switch($value)
1371  {
1372  case "resultunits":
1373  return $this->resultunits;
1374  break;
1375  default:
1376  return parent::__get($value);
1377  break;
1378  }
1379  }

◆ addResult()

assFormulaQuestion::addResult (   $result)

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

References $result.

Referenced by loadFromDb(), and parseQuestionText().

101  {
102  $this->results[$result->getResult()] = $result;
103  }
$result
+ Here is the caller graph for this function:

◆ addResultUnit()

assFormulaQuestion::addResultUnit (   $result,
  $unit 
)

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

References $result.

Referenced by loadFromDb().

116  {
117  if(is_object($result) && is_object($unit))
118  {
119  if(!is_array($this->resultunits[$result->getResult()]))
120  {
121  $this->resultunits[$result->getResult()] = array();
122  }
123  $this->resultunits[$result->getResult()][$unit->getId()] = $unit;
124 
125  }
126  }
$result
+ Here is the caller graph for this function:

◆ addResultUnits()

assFormulaQuestion::addResultUnits (   $result,
  $unit_ids 
)

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

References assQuestion\$id, $result, and getUnitrepository().

106  {
107  $this->resultunits[$result->getResult()] = array();
108  if((!is_object($result)) || (!is_array($unit_ids))) return;
109  foreach($unit_ids as $id)
110  {
111  if(is_numeric($id) && ($id > 0)) $this->resultunits[$result->getResult()][$id] = $this->getUnitrepository()->getUnit($id);
112  }
113  }
$result
+ Here is the call graph for this function:

◆ addVariable()

assFormulaQuestion::addVariable (   $variable)

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

Referenced by loadFromDb(), and parseQuestionText().

77  {
78  $this->variables[$variable->getVariable()] = $variable;
79  }
+ Here is the caller graph for this function:

◆ calculateReachedPoints()

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

Parameters
integer$user_idThe database ID of the learner
integer$test_idThe database Id of the test containing the question public

Definition at line 959 of file class.assFormulaQuestion.php.

References $pass, assQuestion\$points, $result, getResults(), assQuestion\getSolutionMaxPass(), assQuestion\getSolutionValues(), getVariable(), and getVariables().

Referenced by getExpressionTypes().

960  {
961  if(is_null($pass))
962  {
963  $pass = $this->getSolutionMaxPass($active_id);
964  }
965  $solutions =& $this->getSolutionValues($active_id, $pass, $authorizedSolution);
966  $user_solution = array();
967  foreach($solutions as $idx => $solution_value)
968  {
969  if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
970  {
971  $user_solution[$matches[1]] = $solution_value["value2"];
972  $varObj = $this->getVariable($solution_value["value1"]);
973  $varObj->setValue($solution_value["value2"]);
974  }
975  else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
976  {
977  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
978  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
979  }
980  else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
981  {
982  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
983  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
984  }
985  }
986  //vd($this->getResults());
987  $points = 0;
988  foreach($this->getResults() as $result)
989  {
990  //vd($user_solution[$result->getResult()]["value"]);
991  $points += $result->getReachedPoints($this->getVariables(), $this->getResults(), $user_solution[$result->getResult()]["value"], $user_solution[$result->getResult()]["unit"], $this->unitrepository->getUnits());
992  }
993 
994  return $points;
995  }
$result
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assFormulaQuestion::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

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

References assQuestion\$points, $result, ilAssQuestionPreviewSession\getParticipantsSolution(), getResults(), and getVariables().

998  {
999  $user_solution = $previewSession->getParticipantsSolution();
1000 
1001  $points = 0;
1002  foreach($this->getResults() as $result)
1003  {
1004  $v = isset($user_solution[$result->getResult()]) ? $user_solution[$result->getResult()] : null;
1005  $u = isset($user_solution[$result->getResult().'_unit']) ? $user_solution[$result->getResult().'_unit'] : null;
1006 
1007  $points += $result->getReachedPoints(
1008  $this->getVariables(),
1009  $this->getResults(),
1010  $v,
1011  $u,
1012  $this->unitrepository->getUnits());
1013  }
1014 
1015  return $points;
1016  }
$result
+ Here is the call graph for this function:

◆ canUseAdvancedRating()

assFormulaQuestion::canUseAdvancedRating (   $result)

Check if advanced rating can be used for a result.

This is only possible if there is exactly one possible correct unit for the result, otherwise it is impossible to determine wheather the unit is correct or the value.

Returns
boolean True if advanced rating could be used, false otherwise

Definition at line 572 of file class.assFormulaQuestion.php.

References $result, and getResultUnits().

573  {
574  $result_units = $this->getResultUnits($result);
575  $resultunit = $result->getUnit();
576  $similar_units = 0;
577  foreach($result_units as $unit)
578  {
579  if(is_object($resultunit))
580  {
581  if($resultunit->getId() != $unit->getId())
582  {
583  if($resultunit->getBaseUnit() && $unit->getBaseUnit())
584  {
585  if($resultunit->getBaseUnit() == $unit->getBaseUnit()) return false;
586  }
587  if($resultunit->getBaseUnit())
588  {
589  if($resultunit->getBaseUnit() == $unit->getId()) return false;
590  }
591  if($unit->getBaseUnit())
592  {
593  if($unit->getBaseUnit() == $resultunit->getId()) return false;
594  }
595  }
596  }
597  }
598  return true;
599  }
$result
+ Here is the call graph for this function:

◆ checkForDuplicateResults()

assFormulaQuestion::checkForDuplicateResults ( )

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

References assQuestion\getQuestion().

186  {
187  if(preg_match_all("/(\\\$r\\d+)/ims", $this->getQuestion(), $rmatches))
188  {
189  if((count(array_unique($rmatches[1]))) != count($rmatches[1])) return false;
190  }
191  return true;
192  }
getQuestion()
Gets the question string of the question object.
+ Here is the call graph for this function:

◆ checkForDuplicateVariables()

assFormulaQuestion::checkForDuplicateVariables ( )

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

References assQuestion\getQuestion().

177  {
178  if(preg_match_all("/(\\\$v\\d+)/ims", $this->getQuestion(), $matches))
179  {
180  if((count(array_unique($matches[1]))) != count($matches[1])) return false;
181  }
182  return true;
183  }
getQuestion()
Gets the question string of the question object.
+ Here is the call graph for this function:

◆ clearResults()

assFormulaQuestion::clearResults ( )

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

Referenced by parseQuestionText().

82  {
83  $this->results = array();
84  }
+ Here is the caller graph for this function:

◆ clearVariables()

assFormulaQuestion::clearVariables ( )

Definition at line 57 of file class.assFormulaQuestion.php.

Referenced by parseQuestionText().

58  {
59  $this->variables = array();
60  }
+ Here is the caller graph for this function:

◆ copyObject()

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

Copies an assFormulaQuestion object public.

Definition at line 870 of file class.assFormulaQuestion.php.

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

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

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

Definition at line 902 of file class.assFormulaQuestion.php.

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

903  {
904  if ($this->id <= 0)
905  {
906  // The question has not been saved. It cannot be duplicated
907  return;
908  }
909 
910  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
911 
912  $sourceQuestionId = $this->id;
913  $sourceParentId = $this->getObjId();
914 
915  // duplicate the question in database
916  $clone = $this;
917  $clone->id = -1;
918 
919  $clone->setObjId($targetParentId);
920 
921  if ($targetQuestionTitle)
922  {
923  $clone->setTitle($targetQuestionTitle);
924  }
925 
926  $clone->saveToDb();
927  // copy question page content
928  $clone->copyPageOfQuestion($sourceQuestionId);
929  // copy XHTML media objects
930  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
931 
932  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
933 
934  return $clone->id;
935  }
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ deleteAnswers()

assFormulaQuestion::deleteAnswers (   $question_id)

Deletes datasets from answers tables.

Parameters
integer$question_idThe question id which should be deleted in the answers table public

Definition at line 1189 of file class.assFormulaQuestion.php.

References $ilDB.

1190  {
1191  global $ilDB;
1192 
1193  $affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_var WHERE question_fi = %s",
1194  array('integer'),
1195  array($question_id)
1196  );
1197 
1198  $affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s",
1199  array('integer'),
1200  array($question_id)
1201  );
1202 
1203  $affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
1204  array('integer'),
1205  array($question_id)
1206  );
1207 
1208  $affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_ucat WHERE question_fi = %s",
1209  array('integer'),
1210  array($question_id)
1211  );
1212 
1213  $affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_unit WHERE question_fi = %s",
1214  array('integer'),
1215  array($question_id)
1216  );
1217  }
global $ilDB

◆ duplicate()

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

Duplicates an assFormulaQuestion public.

Definition at line 811 of file class.assFormulaQuestion.php.

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

812  {
813  if ($this->id <= 0)
814  {
815  // The question has not been saved. It cannot be duplicated
816  return;
817  }
818  // duplicate the question in database
819  $this_id = $this->getId();
820  $thisObjId = $this->getObjId();
821 
822  $clone = $this;
823  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
825  $clone->id = -1;
826 
827  if( (int)$testObjId > 0 )
828  {
829  $clone->setObjId($testObjId);
830  }
831 
832  if ($title)
833  {
834  $clone->setTitle($title);
835  }
836 
837  if ($author)
838  {
839  $clone->setAuthor($author);
840  }
841  if ($owner)
842  {
843  $clone->setOwner($owner);
844  }
845 
846  if ($for_test)
847  {
848  $clone->saveToDb($original_id);
849  }
850  else
851  {
852  $clone->saveToDb();
853  }
854 
855  $clone->unitrepository->cloneUnits($this_id, $clone->getId());
856 
857  // copy question page content
858  $clone->copyPageOfQuestion($this_id);
859  // copy XHTML media objects
860  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
861  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
862 
863  return $clone->id;
864  }
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:

◆ fetchAllResults()

assFormulaQuestion::fetchAllResults (   $questionText)
Parameters
string$questionText
Returns
assFormulaQuestionResult[] $resObjects

Definition at line 198 of file class.assFormulaQuestion.php.

References getResult().

Referenced by getInitialVariableSolutionValues().

199  {
200  $resObjects = array();
201  $matches = null;
202 
203  if(preg_match_all("/(\\\$r\\d+)/ims", $questionText, $matches))
204  {
205  foreach($matches[1] as $resultKey)
206  {
207  $resObjects[] = $this->getResult($resultKey);
208  }
209  }
210 
211  return $resObjects;
212  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchAllVariables()

assFormulaQuestion::fetchAllVariables (   $questionText)
Parameters
string$questionText
Returns
assFormulaQuestionVariable[] $varObjects

Definition at line 218 of file class.assFormulaQuestion.php.

References getVariable().

Referenced by getInitialVariableSolutionValues(), hasRequiredVariableSolutionValues(), and substituteVariables().

219  {
220  $varObjects = array();
221  $matches = null;
222 
223  if(preg_match_all("/(\\\$v\\d+)/ims", $questionText, $matches))
224  {
225  foreach($matches[1] as $variableKey)
226  {
227  $varObjects[] = $this->getVariable($variableKey);
228  }
229  }
230 
231  return $varObjects;
232  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdditionalTableName()

assFormulaQuestion::getAdditionalTableName ( )

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

Returns
string The additional table name

Definition at line 1170 of file class.assFormulaQuestion.php.

1171  {
1172  return "";
1173  }

◆ getAnswerTableName()

assFormulaQuestion::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name

Definition at line 1179 of file class.assFormulaQuestion.php.

1180  {
1181  return "";
1182  }

◆ getAvailableAnswerOptions()

assFormulaQuestion::getAvailableAnswerOptions (   $index = null)

If index is null, the function returns an array with all anwser options Else it returns the specific answer option.

Parameters
null | int$index
Returns
array|ASS_AnswerSimple

Implements iQuestionCondition.

Definition at line 1508 of file class.assFormulaQuestion.php.

References getResult(), and getResults().

1509  {
1510  if($index !== null)
1511  {
1512  return $this->getResult('$r'.($index+1));
1513  }
1514  else
1515  {
1516  return $this->getResults();
1517  }
1518  }
+ Here is the call graph for this function:

◆ getBestSolution()

assFormulaQuestion::getBestSolution (   $solutions)

Returns the best solution for a given pass of a participant.

Returns
array An associated array containing the best solution public

Definition at line 1280 of file class.assFormulaQuestion.php.

References $result, ilMath\_div(), assFormulaQuestionResult\convertDecimalToCoprimeFraction(), getResults(), getVariable(), getVariables(), assFormulaQuestionUnit\lookupUnitFactor(), assFormulaQuestionResult\RESULT_CO_FRAC, and assFormulaQuestionResult\RESULT_FRAC.

1281  {
1282  $user_solution = array();
1283 
1284  foreach($solutions as $idx => $solution_value)
1285  {
1286  if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
1287  {
1288  $user_solution[$matches[1]] = $solution_value["value2"];
1289  $varObj = $this->getVariable($matches[1]);
1290  $varObj->setValue($solution_value["value2"]);
1291  }
1292  else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
1293  {
1294  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1295  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
1296  }
1297  else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
1298  {
1299  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1300  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
1301  }
1302  }
1303  foreach($this->getResults() as $result)
1304  {
1305  $resVal = $result->calculateFormula($this->getVariables(), $this->getResults(), parent::getId(), false);
1306 
1307  if(is_object($result->getUnit()))
1308  {
1309  $user_solution[$result->getResult()]["unit"] = $result->getUnit()->getId();
1310  $user_solution[$result->getResult()]["value"] = $resVal;
1311  }
1312  else if($result->getUnit() == NULL)
1313  {
1314  $unit_factor = 1;
1315  // there is no fix result_unit, any "available unit" is accepted
1316 
1317  $available_units = $result->getAvailableResultUnits(parent::getId());
1318  $result_name = $result->getResult();
1319 
1320  if($available_units[$result_name] != NULL)
1321  {
1322  $check_unit = in_array($user_solution[$result_name]['unit'], $available_units[$result_name]);
1323  }
1324 
1325  if($check_unit == true)
1326  {
1327  //get unit-factor
1328  $unit_factor = assFormulaQuestionUnit::lookupUnitFactor($user_solution[$result_name]['unit']);
1329  $user_solution[$result->getResult()]["value"] = round(ilMath::_div($resVal, $unit_factor), 55);
1330  }
1331  }
1332  if($result->getResultType() == assFormulaQuestionResult::RESULT_CO_FRAC
1333  || $result->getResultType() == assFormulaQuestionResult::RESULT_FRAC)
1334  {
1336  if(is_array($value))
1337  {
1338  $user_solution[$result->getResult()]["value"] = $value[0];
1339  $user_solution[$result->getResult()]["frac_helper"] = $value[1];
1340  }
1341  else
1342  {
1343  $user_solution[$result->getResult()]["value"] = $value;
1344  $user_solution[$result->getResult()]["frac_helper"] = null;
1345  }
1346  }
1347  elseif($result->getPrecision() > 0)
1348  {
1349  $user_solution[$result->getResult()]["value"] = round($resVal, $result->getPrecision());
1350  }
1351  else
1352  {
1353  $user_solution[$result->getResult()]["value"] = round($resVal);
1354  }
1355  }
1356  return $user_solution;
1357  }
$result
static _div($left_operand, $right_operand, $scale=50)
static convertDecimalToCoprimeFraction($decimal_value, $tolerance=1.e-9)
+ Here is the call graph for this function:

◆ getExpressionTypes()

◆ getInitialVariableSolutionValues()

assFormulaQuestion::getInitialVariableSolutionValues ( )
Returns
array $initialVariableSolutionValues

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

References fetchAllResults(), fetchAllVariables(), assQuestion\getQuestion(), getResults(), and getVariables().

260  {
261  foreach($this->fetchAllResults($this->getQuestion()) as $resObj)
262  {
263  $resObj->findValidRandomVariables($this->getVariables(), $this->getResults());
264  }
265 
266  $variableSolutionValues = array();
267 
268  foreach($this->fetchAllVariables($this->getQuestion()) as $varObj)
269  {
270  $variableSolutionValues[$varObj->getVariable()] = $varObj->getValue();
271  }
272 
273  return $variableSolutionValues;
274  }
getQuestion()
Gets the question string of the question object.
+ Here is the call graph for this function:

◆ getMaximumPoints()

assFormulaQuestion::getMaximumPoints ( )

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

See also
$points

Definition at line 941 of file class.assFormulaQuestion.php.

References assQuestion\$points, and $result.

Referenced by getExpressionTypes(), and isComplete().

942  {
943  $points = 0;
944  foreach($this->results as $result)
945  {
946  $points += $result->getPoints();
947  }
948  return $points;
949  }
$result
+ Here is the caller graph for this function:

◆ getOperators()

assFormulaQuestion::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

Definition at line 1432 of file class.assFormulaQuestion.php.

References ilOperatorsExpressionMapping\getOperatorsByExpression().

1433  {
1434  require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1436  }
+ Here is the call graph for this function:

◆ getQuestionType()

assFormulaQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
string The question type of the question

Definition at line 1161 of file class.assFormulaQuestion.php.

1162  {
1163  return "assFormulaQuestion";
1164  }

◆ getResult()

assFormulaQuestion::getResult (   $result)

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

References $result.

Referenced by fetchAllResults(), getAvailableAnswerOptions(), loadFromDb(), and substituteVariables().

92  {
93  if(array_key_exists($result, $this->results))
94  {
95  return $this->results[$result];
96  }
97  return null;
98  }
$result
+ Here is the caller graph for this function:

◆ getResults()

assFormulaQuestion::getResults ( )

◆ getResultUnits()

assFormulaQuestion::getResultUnits (   $result)

Definition at line 128 of file class.assFormulaQuestion.php.

References $result, and $resultunits.

Referenced by canUseAdvancedRating(), saveToDb(), and substituteVariables().

129  {
130  if(array_key_exists($result->getResult(), $this->resultunits))
131  {
132  return $this->resultunits[$result->getResult()];
133  }
134  else
135  {
136  return array();
137  }
138  }
$result
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assFormulaQuestion::getRTETextWithMediaObjects ( )

Collects all text in the question which could contain media objects which were created with the Rich Text Editor.

Definition at line 1223 of file class.assFormulaQuestion.php.

References $text.

1224  {
1225  $text = parent::getRTETextWithMediaObjects();
1226  return $text;
1227  }
$text

◆ getSolutionSubmit()

assFormulaQuestion::getSolutionSubmit ( )
protected
Returns
array

Definition at line 1400 of file class.assFormulaQuestion.php.

References $_POST, and isValidSolutionResultValue().

Referenced by savePreviewData(), and saveWorkingData().

1401  {
1402  $solutionSubmit = array();
1403  foreach($_POST as $k => $v)
1404  {
1405  if(preg_match("/^result_(\\\$r\\d+)$/", $k))
1406  {
1407  if( $this->isValidSolutionResultValue($v) )
1408  {
1409  $solutionSubmit[$k] = $v;
1410  }
1411  else
1412  {
1413  $solutionSubmit[$k] = '';
1414  }
1415  }
1416  elseif(preg_match("/^result_(\\\$r\\d+)_unit$/", $k))
1417  {
1418  $solutionSubmit[$k] = $v;
1419  }
1420  }
1421  return $solutionSubmit;
1422  }
$_POST['username']
Definition: cron.php:12
isValidSolutionResultValue($submittedValue)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUnitrepository()

assFormulaQuestion::getUnitrepository ( )
Returns

Definition at line 1392 of file class.assFormulaQuestion.php.

References $unitrepository.

Referenced by addResultUnits(), loadFromDb(), setExportDetailsXLS(), and substituteVariables().

1393  {
1394  return $this->unitrepository;
1395  }
+ Here is the caller graph for this function:

◆ getVariable()

assFormulaQuestion::getVariable (   $variable)

Definition at line 67 of file class.assFormulaQuestion.php.

Referenced by calculateReachedPoints(), fetchAllVariables(), getBestSolution(), and setExportDetailsXLS().

68  {
69  if(array_key_exists($variable, $this->variables))
70  {
71  return $this->variables[$variable];
72  }
73  return null;
74  }
+ Here is the caller graph for this function:

◆ getVariables()

assFormulaQuestion::getVariables ( )

◆ getVariableSolutionIds()

assFormulaQuestion::getVariableSolutionIds (   $active_id,
  $pass 
)
protected
Parameters
$active_id
$pass
Returns
array

Definition at line 1525 of file class.assFormulaQuestion.php.

References $ilDB, $pass, $query, $res, $row, and assQuestion\getId().

Referenced by removeCurrentSolution().

1526  {
1527  global $ilDB;
1528 
1529  $ignoredSolutionIds = array();
1530 
1531  $query = "
1532  SELECT value1, solution_id FROM tst_solutions
1533  WHERE active_fi = %s AND question_fi = %s AND pass = %s
1534  ";
1535 
1536  $res = $ilDB->queryF(
1537  $query,
1538  array('integer', 'integer', 'integer'),
1539  array($active_id, $this->getId(), $pass)
1540  );
1541  while($row = $ilDB->fetchAssoc($res))
1542  {
1543  if(preg_match('/^\$v\d+$/', $row['value1']))
1544  {
1545  $ignoredSolutionIds[] = $row['solution_id'];
1546  }
1547  }
1548 
1549  return $ignoredSolutionIds;
1550  }
getId()
Gets the id of the assQuestion object.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasRequiredVariableSolutionValues()

assFormulaQuestion::hasRequiredVariableSolutionValues ( array  $userSolution)
Parameters
array$userSolution
Returns
bool

Definition at line 238 of file class.assFormulaQuestion.php.

References fetchAllVariables(), and assQuestion\getQuestion().

239  {
240  foreach($this->fetchAllVariables($this->getQuestion()) as $varObj)
241  {
242  if( !isset($userSolution[$varObj->getVariable()]) )
243  {
244  return false;
245  }
246 
247  if( !strlen($userSolution[$varObj->getVariable()]) )
248  {
249  return false;
250  }
251  }
252 
253  return true;
254  }
getQuestion()
Gets the question string of the question object.
+ Here is the call graph for this function:

◆ hasResultUnit()

assFormulaQuestion::hasResultUnit (   $result,
  $unit_id 
)

Definition at line 140 of file class.assFormulaQuestion.php.

References $result, and $resultunits.

141  {
142  if(array_key_exists($result->getResult(), $this->resultunits))
143  {
144  if(array_key_exists($unit_id, $this->resultunits[$result->getResult()]))
145  {
146  return TRUE;
147  }
148  }
149 
150  return FALSE;
151  }
$result

◆ isComplete()

assFormulaQuestion::isComplete ( )

Returns true, if the question is complete for use.

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

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

References getMaximumPoints().

606  {
607  if(($this->title) and ($this->author) and ($this->question) and ($this->getMaximumPoints() > 0))
608  {
609  return true;
610  }
611  else
612  {
613  return false;
614  }
615  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ isValidSolutionResultValue()

assFormulaQuestion::isValidSolutionResultValue (   $submittedValue)
protected

Definition at line 1018 of file class.assFormulaQuestion.php.

Referenced by getSolutionSubmit().

1019  {
1020  $submittedValue = str_replace(',', '.', $submittedValue);
1021 
1022  if( is_numeric($submittedValue) )
1023  {
1024  return true;
1025  }
1026 
1027  if( preg_match('/^[-+]{0,1}\d+\/\d+$/', $submittedValue) )
1028  {
1029  return true;
1030  }
1031 
1032  return false;
1033  }
+ Here is the caller graph for this function:

◆ loadFromDb()

assFormulaQuestion::loadFromDb (   $question_id)

Loads a assFormulaQuestion object from a database.

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

Definition at line 722 of file class.assFormulaQuestion.php.

References $data, $ilDB, $result, ilRTE\_replaceMediaObjectImageSrc(), addResult(), addResultUnit(), addVariable(), getResult(), getUnitrepository(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setEstimatedWorkingTime(), setId(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), assQuestion\setSuggestedSolution(), and assQuestion\setTitle().

723  {
724  global $ilDB;
725 
726  $result = $ilDB->queryF("SELECT qpl_questions.* FROM qpl_questions WHERE question_id = %s",
727  array('integer'),
728  array($question_id)
729  );
730  if($result->numRows() == 1)
731  {
732  $data = $ilDB->fetchAssoc($result);
733  $this->setId($question_id);
734  $this->setTitle($data["title"]);
735  $this->setComment($data["description"]);
736  $this->setSuggestedSolution($data["solution_hint"]);
737  $this->setPoints($data['points']);
738  $this->setOriginalId($data["original_id"]);
739  $this->setObjId($data["obj_fi"]);
740  $this->setAuthor($data["author"]);
741  $this->setOwner($data["owner"]);
742 
743  try
744  {
745  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
746  }
748  {
749  }
750 
751  $this->unitrepository = new ilUnitConfigurationRepository($question_id);
752 
753  include_once("./Services/RTE/classes/class.ilRTE.php");
754  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
755  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
756 
757  // load variables
758  $result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_var WHERE question_fi = %s",
759  array('integer'),
760  array($question_id)
761  );
762  if($result->numRows() > 0)
763  {
764  while($data = $ilDB->fetchAssoc($result))
765  {
766  $varObj = new assFormulaQuestionVariable($data["variable"], $data["range_min"], $data["range_max"], $this->getUnitrepository()->getUnit($data["unit_fi"]), $data["varprecision"], $data["intprecision"]);
767  $varObj->setRangeMinTxt($data['range_min_txt']);
768  $varObj->setRangeMaxTxt($data['range_max_txt']);
769  $this->addVariable($varObj);
770  }
771  }
772  // load results
773  $result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_res WHERE question_fi = %s",
774  array('integer'),
775  array($question_id)
776  );
777  if($result->numRows() > 0)
778  {
779  while($data = $ilDB->fetchAssoc($result))
780  {
781  $resObj = new assFormulaQuestionResult($data["result"], $data["range_min"], $data["range_max"], $data["tolerance"], $this->getUnitrepository()->getUnit($data["unit_fi"]), $data["formula"], $data["points"], $data["resprecision"], $data["rating_simple"], $data["rating_sign"], $data["rating_value"], $data["rating_unit"]);
782  $resObj->setResultType($data['result_type']);
783  $resObj->setRangeMinTxt($data['range_min_txt']);
784  $resObj->setRangeMaxTxt($data['range_max_txt']);
785  $this->addResult($resObj);
786  }
787  }
788 
789  // load result units
790  $result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
791  array('integer'),
792  array($question_id)
793  );
794  if($result->numRows() > 0)
795  {
796  while($data = $ilDB->fetchAssoc($result))
797  {
798  $unit = $this->getUnitrepository()->getUnit($data["unit_fi"]);
799  $resObj = $this->getResult($data["result"]);
800  $this->addResultUnit($resObj, $unit);
801  }
802  }
803  }
804  parent::loadFromDb($question_id);
805  }
setSuggestedSolution($solution_id="", $subquestion_index=0, $is_import=false)
Sets a suggested solution for the question.
$result
Class ilUnitConfigurationRepository.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second. ...
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this 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...
setAuthor($author="")
Sets the authors name of the assQuestion object.
$data
setPoints($a_points)
Sets the maximum available points for the question.
setQuestion($question="")
Sets the question string of the question object.
global $ilDB
setOriginalId($original_id)
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setComment($comment="")
Sets the comment string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
+ Here is the call graph for this function:

◆ parseQuestionText()

assFormulaQuestion::parseQuestionText ( )

Definition at line 153 of file class.assFormulaQuestion.php.

References $result, addResult(), addVariable(), clearResults(), clearVariables(), and assQuestion\getQuestion().

154  {
155  $this->clearResults();
156  $this->clearVariables();
157  if(preg_match_all("/(\\\$v\\d+)/ims", $this->getQuestion(), $matches))
158  {
159  foreach($matches[1] as $variable)
160  {
161  $varObj = new assFormulaQuestionVariable($variable, 0, 0, null, 0);
162  $this->addVariable($varObj);
163  }
164  }
165 
166  if(preg_match_all("/(\\\$r\\d+)/ims", $this->getQuestion(), $rmatches))
167  {
168  foreach($rmatches[1] as $result)
169  {
170  $resObj = new assFormulaQuestionResult($result, NULL, NULL, 0, -1, NULL, 1, 1, TRUE);
171  $this->addResult($resObj);
172  }
173  }
174  }
$result
getQuestion()
Gets the question string of the question object.
+ Here is the call graph for this function:

◆ removeCurrentSolution()

assFormulaQuestion::removeCurrentSolution (   $active_id,
  $pass,
  $authorized = true,
  $ignoredSolutionIds = array() 
)

Definition at line 1555 of file class.assFormulaQuestion.php.

References $pass, and getVariableSolutionIds().

1556  {
1557  return parent::removeCurrentSolution(
1558  $active_id, $pass, $authorized, $this->getVariableSolutionIds($active_id, $pass)
1559  );
1560  }
getVariableSolutionIds($active_id, $pass)
+ Here is the call graph for this function:

◆ removeExistingSolutions()

assFormulaQuestion::removeExistingSolutions (   $activeId,
  $pass 
)

Definition at line 1562 of file class.assFormulaQuestion.php.

References $ilDB, $pass, $query, and assQuestion\getId().

1563  {
1564  global $ilDB;
1565 
1566  $query = "
1567  DELETE FROM tst_solutions
1568  WHERE active_fi = " . $ilDB->quote($activeId, 'integer') ."
1569  AND question_fi = ". $ilDB->quote($this->getId(), 'integer') ."
1570  AND pass = " .$ilDB->quote($pass, 'integer') ."
1571  AND value1 like '\$r%'
1572  ";
1573 
1574  return $ilDB->manipulate($query);
1575  }
getId()
Gets the id of the assQuestion object.
global $ilDB
+ Here is the call graph for this function:

◆ reworkWorkingData()

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

Reworks the allready saved working data if neccessary.

protected

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered

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

1153  {
1154  // nothing to do
1155  }

◆ savePreviewData()

assFormulaQuestion::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

Definition at line 1122 of file class.assFormulaQuestion.php.

References ilAssQuestionPreviewSession\getParticipantsSolution(), getSolutionSubmit(), and ilAssQuestionPreviewSession\setParticipantsSolution().

1123  {
1124  $userSolution = $previewSession->getParticipantsSolution();
1125 
1126  foreach($this->getSolutionSubmit() as $key => $val)
1127  {
1128  $matches = null;
1129 
1130  if(preg_match("/^result_(\\\$r\\d+)$/", $key, $matches))
1131  {
1132  $userSolution[$matches[1]] = $val;
1133  }
1134  else if(preg_match("/^result_(\\\$r\\d+)_unit$/", $key, $matches))
1135  {
1136  $userSolution[$matches[1] . "_unit"] = $val;
1137  }
1138  }
1139 
1140  $previewSession->setParticipantsSolution($userSolution);
1141  }
+ Here is the call graph for this function:

◆ saveToDb()

assFormulaQuestion::saveToDb (   $original_id = "")

Saves a assFormulaQuestion object to a database public.

Definition at line 621 of file class.assFormulaQuestion.php.

References $ilDB, assQuestion\$original_id, $result, assQuestion\getId(), getResultUnits(), and assQuestion\saveQuestionDataToDb().

622  {
623  global $ilDB;
624 
626  // save variables
627  $affectedRows = $ilDB->manipulateF("
628  DELETE FROM il_qpl_qst_fq_var
629  WHERE question_fi = %s",
630  array("integer"),
631  array($this->getId())
632  );
633 
634  foreach($this->variables as $variable)
635  {
636  $next_id = $ilDB->nextId('il_qpl_qst_fq_var');
637  $ilDB->insert('il_qpl_qst_fq_var',
638  array(
639  'variable_id' => array('integer', $next_id),
640  'question_fi' => array('integer', $this->getId()),
641  'variable' => array('text', $variable->getVariable()),
642  'range_min' => array('float', ((strlen($variable->getRangeMin())) ? $variable->getRangeMin() : 0.0)),
643  'range_max' => array('float', ((strlen($variable->getRangeMax())) ? $variable->getRangeMax() : 0.0)),
644  'unit_fi' => array('integer', (is_object($variable->getUnit()) ? (int)$variable->getUnit()->getId() : 0)),
645  'varprecision' => array('integer', (int)$variable->getPrecision()),
646  'intprecision' => array('integer', (int)$variable->getIntprecision()),
647  'range_min_txt' => array('text', $variable->getRangeMinTxt()),
648  'range_max_txt' => array('text', $variable->getRangeMaxTxt())
649  ));
650 
651  }
652  // save results
653  $affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s",
654  array("integer"),
655  array($this->getId())
656  );
657 
658  foreach($this->results as $result)
659  {
660  $next_id = $ilDB->nextId('il_qpl_qst_fq_res');
661  if( is_object($result->getUnit()))
662  {
663  $tmp_result_unit = $result->getUnit()->getId();
664  }
665  else
666  {
667  $tmp_result_unit = NULL;
668  }
669 
670  $formula = str_replace(",", ".", $result->getFormula());
671 
672  $ilDB->insert("il_qpl_qst_fq_res", array(
673  "result_id" => array("integer", $next_id),
674  "question_fi" => array("integer", $this->getId()),
675  "result" => array("text", $result->getResult()),
676  "range_min" => array("float", ((strlen($result->getRangeMin())) ? $result->getRangeMin() : 0)),
677  "range_max" => array("float", ((strlen($result->getRangeMax())) ? $result->getRangeMax() : 0)),
678  "tolerance" => array("float", ((strlen($result->getTolerance())) ? $result->getTolerance() : 0)),
679  "unit_fi" => array("integer", (int)$tmp_result_unit),
680  "formula" => array("clob", $formula),
681  "resprecision" => array("integer", $result->getPrecision()),
682  "rating_simple" => array("integer", ($result->getRatingSimple()) ? 1 : 0),
683  "rating_sign" => array("float", ($result->getRatingSimple()) ? 0 : $result->getRatingSign()),
684  "rating_value" => array("float", ($result->getRatingSimple()) ? 0 : $result->getRatingValue()),
685  "rating_unit" => array("float", ($result->getRatingSimple()) ? 0 : $result->getRatingUnit()),
686  "points" => array("float", $result->getPoints()),
687  "result_type" => array('integer', (int)$result->getResultType()),
688  "range_min_txt" => array("text", $result->getRangeMinTxt()),
689  "range_max_txt" => array("text", $result->getRangeMaxTxt())
690 
691  ));
692  }
693  // save result units
694  $affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
695  array("integer"),
696  array($this->getId())
697  );
698  foreach($this->results as $result)
699  {
700  foreach($this->getResultUnits($result) as $unit)
701  {
702  $next_id = $ilDB->nextId('il_qpl_qst_fq_res_unit');
703  $affectedRows = $ilDB->manipulateF("INSERT INTO il_qpl_qst_fq_res_unit (result_unit_id, question_fi, result, unit_fi) VALUES (%s, %s, %s, %s)",
704  array('integer', 'integer', 'text', 'integer'),
705  array(
706  $next_id,
707  $this->getId(),
708  $result->getResult(),
709  $unit->getId()
710  )
711  );
712  }
713  }
714 
715  parent::saveToDb();
716  }
getId()
Gets the id of the assQuestion object.
$result
saveQuestionDataToDb($original_id="")
global $ilDB
+ Here is the call graph for this function:

◆ saveWorkingData()

assFormulaQuestion::saveWorkingData (   $active_id,
  $pass = NULL,
  $authorized = true 
)

Saves the learners input of the question to the database.

Parameters
integer$test_idThe database id of the test containing this question
Returns
boolean Indicates the save status (true if saved successful, false otherwise) public
See also
$answers

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

References $ilDB, $pass, $result, $row, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), assQuestion\getId(), assQuestion\getProcessLocker(), getSolutionSubmit(), assQuestion\logAction(), and assQuestion\saveCurrentSolution().

1043  {
1044  global $ilDB;
1045 
1046  if(is_null($pass))
1047  {
1048  include_once "./Modules/Test/classes/class.ilObjTest.php";
1049  $pass = ilObjTest::_getPass($active_id);
1050  }
1051 
1052  $this->getProcessLocker()->requestUserSolutionUpdateLock();
1053 
1054  $solutionSubmit = $this->getSolutionSubmit();
1055  $entered_values = FALSE;
1056  foreach($solutionSubmit as $key => $value)
1057  {
1058  $matches = null;
1059  if(preg_match("/^result_(\\\$r\\d+)$/", $key, $matches))
1060  {
1061  if(strlen($value)) $entered_values = TRUE;
1062  $result = $ilDB->queryF("SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND authorized = %s AND " . $ilDB->like('value1', 'clob', $matches[1]),
1063  array('integer', 'integer', 'integer', 'integer'),
1064  array($active_id, $pass, $this->getId(), (int)$authorized)
1065  );
1066  if($result->numRows())
1067  {
1068  while($row = $ilDB->fetchAssoc($result))
1069  {
1070  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
1071  array('integer', 'integer'),
1072  array($row['solution_id'], (int)$authorized)
1073  );
1074  }
1075  }
1076 
1077  $affectedRows = $this->saveCurrentSolution($active_id,$pass,$matches[1],str_replace(",", ".", $value), $authorized);
1078  }
1079  else if(preg_match("/^result_(\\\$r\\d+)_unit$/", $key, $matches))
1080  {
1081  $result = $ilDB->queryF("SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND authorized = %s AND " . $ilDB->like('value1', 'clob', $matches[1] . "_unit"),
1082  array('integer', 'integer', 'integer', 'integer'),
1083  array($active_id, $pass, $this->getId(), (int)$authorized)
1084  );
1085  if($result->numRows())
1086  {
1087  while($row = $ilDB->fetchAssoc($result))
1088  {
1089  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
1090  array('integer', 'integer'),
1091  array($row['solution_id'], (int)$authorized)
1092  );
1093  }
1094  }
1095 
1096  $affectedRows = $this->saveCurrentSolution($active_id,$pass,$matches[1] . "_unit",$value, $authorized);
1097  }
1098  }
1099 
1100  $this->getProcessLocker()->releaseUserSolutionUpdateLock();
1101 
1102  if($entered_values)
1103  {
1104  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1106  {
1107  $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1108  }
1109  }
1110  else
1111  {
1112  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1114  {
1115  $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1116  }
1117  }
1118 
1119  return true;
1120  }
getId()
Gets the id of the assQuestion object.
$result
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true)
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
_getLogLanguage()
retrieve the log language for assessment logging
global $ilDB
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
+ Here is the call graph for this function:

◆ setExportDetailsXLS()

assFormulaQuestion::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 public

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

References $pass, ilExcelUtils\_convert_text(), assQuestion\getSolutionValues(), assQuestion\getTitle(), getUnitrepository(), and getVariable().

1241  {
1242  require_once 'Services/Excel/classes/class.ilExcelUtils.php';
1243  $solution = $this->getSolutionValues($active_id, $pass);
1244  $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
1245  $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
1246  $i = 1;
1247  foreach($solution as $solutionvalue)
1248  {
1249  $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($solutionvalue["value1"]), $format_bold);
1250  if(strpos($solutionvalue["value1"], "_unit"))
1251  {
1252  $unit = $this->getUnitrepository()->getUnit($solutionvalue["value2"]);
1253  if(is_object($unit))
1254  {
1255  $worksheet->write($startrow + $i, 1, $unit->getUnit());
1256  }
1257  }
1258  else
1259  {
1260  $worksheet->write($startrow + $i, 1, $solutionvalue["value2"]);
1261  }
1262  if(preg_match("/(\\\$v\\d+)/", $solutionvalue["value1"], $matches))
1263  {
1264  $var = $this->getVariable($solutionvalue["value1"]);
1265  if(is_object($var) && (is_object($var->getUnit())))
1266  {
1267  $worksheet->write($startrow + $i, 2, $var->getUnit()->getUnit());
1268  }
1269  }
1270  $i++;
1271  }
1272  return $startrow + $i + 1;
1273  }
_convert_text($a_text, $a_target="has been removed")
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
getTitle()
Gets the title string of the assQuestion object.
+ Here is the call graph for this function:

◆ setId()

assFormulaQuestion::setId (   $id = -1)

Definition at line 1359 of file class.assFormulaQuestion.php.

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

Referenced by loadFromDb().

1360  {
1361  parent::setId($id);
1362  $this->unitrepository->setConsumerId($this->getId());
1363  }
getId()
Gets the id of the assQuestion object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUnitrepository()

assFormulaQuestion::setUnitrepository (   $unitrepository)
Parameters
\ilUnitConfigurationRepository$unitrepository

Definition at line 1384 of file class.assFormulaQuestion.php.

References $unitrepository.

1385  {
1386  $this->unitrepository = $unitrepository;
1387  }

◆ substituteVariables()

assFormulaQuestion::substituteVariables ( array  $userdata,
  $graphicalOutput = FALSE,
  $forsolution = FALSE,
  $result_output = FALSE 
)
Parameters
array$userdata
bool$graphicalOutput
bool$forsolution
bool$result_output
ilAssQuestionPreviewSession | null$previewSession
Returns
bool|mixed|string

Definition at line 284 of file class.assFormulaQuestion.php.

References $result, $text, assFormulaQuestionResult\convertDecimalToCoprimeFraction(), fetchAllVariables(), ilUtil\getImagePath(), assQuestion\getQuestion(), getResult(), getResults(), getResultUnits(), getUnitrepository(), getVariables(), ilUtil\prepareFormOutput(), assFormulaQuestionResult\RESULT_CO_FRAC, assFormulaQuestionResult\RESULT_DEC, assFormulaQuestionResult\RESULT_FRAC, and assFormulaQuestionResult\RESULT_NO_SELECTION.

285  {
286  if((count($this->results) == 0) && (count($this->variables) == 0))
287  return false;
288 
289  $text = $this->getQuestion();
290 
291  foreach($this->fetchAllVariables($this->getQuestion()) as $varObj)
292  {
293  if( isset($userdata[$varObj->getVariable()]) && strlen($userdata[$varObj->getVariable()]) )
294  {
295  $varObj->setValue( $userdata[$varObj->getVariable()] );
296  }
297 
298  $unit = (is_object($varObj->getUnit())) ? $varObj->getUnit()->getUnit() : "";
299  $val = (strlen($varObj->getValue()) > 8) ? strtoupper(sprintf("%e", $varObj->getValue())) : $varObj->getValue();
300 
301  $text = preg_replace("/\\$" . substr($varObj->getVariable(), 1) . "(?![0-9]+)/", $val . " " . $unit . "\\1", $text);
302  }
303 
304  if(preg_match_all("/(\\\$r\\d+)/ims", $this->getQuestion(), $rmatches))
305  {
306  foreach($rmatches[1] as $result)
307  {
308  $resObj = $this->getResult($result);
309  $value = "";
310  $frac_helper = '';
311  $user_data[$result]['result_type'] = $resObj->getResultType();
312 
313  if(
314  $resObj->getResultType() == assFormulaQuestionResult::RESULT_FRAC ||
315  $resObj->getResultType() == assFormulaQuestionResult::RESULT_CO_FRAC
316  )
317  {
318  $is_frac = true;
319  }
320  if(is_array($userdata))
321  {
322  if(is_array($userdata[$result]))
323  {
324  if($forsolution && $result_output)
325  {
326  $value_org = $resObj->calculateFormula($this->getVariables(), $this->getResults(), parent::getId());
327  $value = sprintf("%." . $resObj->getPrecision() . "f", $value_org);
328  if($is_frac)
329  {
331  if(is_array($value))
332  {
333  $frac_helper = $value[1];
334  $value = $value[0];
335  }
336  }
337  }
338  else
339  {
340  if($forsolution)
341  {
342  $value = $userdata[$result]["value"];
343  }
344  else
345  {
346  $value = ' value="' . $userdata[$result]["value"] . '"';
347  }
348  }
349  }
350  }
351  else
352  {
353  if($forsolution)
354  {
355  $value = $resObj->calculateFormula($this->getVariables(), $this->getResults(), parent::getId());
356  $value = sprintf("%." . $resObj->getPrecision() . "f", $value);
357 
358  if($is_frac)
359  {
361  if(is_array($value))
362  {
363  $frac_helper = $value[1];
364  $value = $value[0];
365  }
366  $value = ' value="' . $value . '"';
367  }
368  }
369  else
370  {
371  // Precision fix for Preview by tjoussen
372  // If all default values are set, this function is called in getPreview
373  $use_precision = !($userdata == null && $graphicalOutput == FALSE && $forsolution == FALSE && $result_output == FALSE);
374 
375  $val = $resObj->calculateFormula($this->getVariables(), $this->getResults(), parent::getId(), $use_precision);
376 
377  if($resObj->getResultType() == assFormulaQuestionResult::RESULT_FRAC
378  ||$resObj->getResultType() == assFormulaQuestionResult::RESULT_CO_FRAC)
379  {
380  $val = $resObj->convertDecimalToCoprimeFraction($val);
381  if(is_array($val))
382  {
383  $frac_helper = $val[1];
384  $val = $val[0];
385  }
386  }
387  else
388  {
389  $val = sprintf("%." . $resObj->getPrecision() . "f", $val);
390  $val = (strlen($val) > 8) ? strtoupper(sprintf("%e", $val)) : $val;
391  }
392  $value = ' value="' . $val . '"';
393  }
394  }
395 
396  if($forsolution)
397  {
398  $input = '<span class="ilc_qinput_TextInput solutionbox">' . ilUtil::prepareFormOutput($value) . '</span>';
399  }
400  else
401  {
402  $input = '<input class="ilc_qinput_TextInput" type="text" spellcheck="false" autocomplete="off" autocorrect="off" autocapitalize="off" name="result_' . $result . '"' . $value . ' />';
403  }
404 
405  $units = "";
406  if(count($this->getResultUnits($resObj)) > 0)
407  {
408  if($forsolution)
409  {
410  if(is_array($userdata))
411  {
412  foreach($this->getResultUnits($resObj) as $unit)
413  {
414  if($userdata[$result]["unit"] == $unit->getId())
415  {
416  $units = $unit->getUnit();
417  }
418  }
419  }
420  else
421  {
422  if($resObj->getUnit())
423  {
424  $units = $resObj->getUnit()->getUnit();
425  }
426  }
427  }
428  else
429  {
430  $units = '<select name="result_' . $result . '_unit">';
431  $units .= '<option value="-1">' . $this->lng->txt("select_unit") . '</option>';
432  foreach($this->getResultUnits($resObj) as $unit)
433  {
434  $units .= '<option value="' . $unit->getId() . '"';
435  if((is_array($userdata[$result])) && (strlen($userdata[$result]["unit"])))
436  {
437  if($userdata[$result]["unit"] == $unit->getId())
438  {
439  $units .= ' selected="selected"';
440  }
441  }
442  $units .= '>' . $unit->getUnit() . '</option>';
443  }
444  $units .= '</select>';
445  }
446  }
447  else
448  {
449  $units = "";
450  }
451  switch($resObj->getResultType())
452  {
454  $units .= ' ' . $this->lng->txt('expected_result_type') . ': ' . $this->lng->txt('result_dec');
455  break;
457  if(strlen($frac_helper))
458  {
459  $units .= ' &asymp; ' . $frac_helper . ', ';
460  }
461  elseif (is_array($userdata) && isset($userdata[$result]) && strlen($userdata[$result]["frac_helper"]))
462  {
463  if(!preg_match('-/-', $value))
464  {
465  $units .= ' &asymp; ' . $userdata[$result]["frac_helper"] . ', ';
466  }
467  }
468  $units .= ' ' . $this->lng->txt('expected_result_type') . ': ' . $this->lng->txt('result_frac');
469  break;
471  if(strlen($frac_helper))
472  {
473  $units .= ' &asymp; ' . $frac_helper . ', ';
474  }
475  elseif (is_array($userdata) && isset($userdata[$result]) && strlen($userdata[$result]["frac_helper"]))
476  {
477  if(!preg_match('-/-', $value))
478  {
479  $units .= ' &asymp; ' . $userdata[$result]["frac_helper"] . ', ';
480  }
481  }
482  $units .= ' ' . $this->lng->txt('expected_result_type') . ': ' . $this->lng->txt('result_co_frac');
483  break;
485  break;
486  }
487  $checkSign = "";
488  if($graphicalOutput)
489  {
490  $resunit = null;
491  $user_value = '';
492  if(is_array($userdata) && is_array($userdata[$result]))
493  {
494  if($userdata[$result]["unit"] > 0)
495  {
496  $resunit = $this->getUnitrepository()->getUnit($userdata[$result]["unit"]);
497  }
498 
499  if(isset($userdata[$result]["value"]))
500  {
501  $user_value = $userdata[$result]["value"];
502  }
503  }
504 
505  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution_image.html", true, true, 'Modules/TestQuestionPool');
506 
507  if($resObj->isCorrect($this->getVariables(), $this->getResults(), $user_value, $resunit))
508  {
509  $template->setCurrentBlock("icon_ok");
510  $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
511  $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
512  $template->parseCurrentBlock();
513  }
514  else
515  {
516  $template->setCurrentBlock("icon_not_ok");
517  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
518  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
519  $template->parseCurrentBlock();
520  }
521  $checkSign = $template->get();
522  }
523  $resultOutput = "";
524  if($result_output)
525  {
526  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution_result.html", true, true, 'Modules/TestQuestionPool');
527 
528  if(is_array($userdata))
529  {
530  $found = $resObj->getResultInfo($this->getVariables(), $this->getResults(), $userdata[$resObj->getResult()]["value"], $userdata[$resObj->getResult()]["unit"], $this->getUnitrepository()->getUnits());
531  }
532  else
533  {
534  $found = $resObj->getResultInfo($this->getVariables(), $this->getResults(), $resObj->calculateFormula($this->getVariables(), $this->getResults(), parent::getId()), is_object($resObj->getUnit()) ? $resObj->getUnit()->getId() : NULL, $this->getUnitrepository()->getUnits());
535  }
536  $resulttext = "(";
537  if($resObj->getRatingSimple())
538  {
539  if($frac_helper)
540  {
541  $resulttext .="n/a";
542  }
543  else
544  {
545  $resulttext .= $found['points'] . " " . (($found['points'] == 1) ? $this->lng->txt('point') : $this->lng->txt('points'));
546  }
547  }
548  else
549  {
550  $resulttext .= $this->lng->txt("rated_sign") . " " . (($found['sign']) ? $found['sign'] : 0) . " " . (($found['sign'] == 1) ? $this->lng->txt('point') : $this->lng->txt('points')) . ", ";
551  $resulttext .= $this->lng->txt("rated_value") . " " . (($found['value']) ? $found['value'] : 0) . " " . (($found['value'] == 1) ? $this->lng->txt('point') : $this->lng->txt('points')) . ", ";
552  $resulttext .= $this->lng->txt("rated_unit") . " " . (($found['unit']) ? $found['unit'] : 0) . " " . (($found['unit'] == 1) ? $this->lng->txt('point') : $this->lng->txt('points'));
553  }
554 
555  $resulttext .= ")";
556  $template->setVariable("RESULT_OUTPUT", $resulttext);
557 
558  $resultOutput = $template->get();
559  }
560  $text = preg_replace("/\\\$" . substr($result, 1) . "(?![0-9]+)/", $input . " " . $units . " " . $checkSign . " " . $resultOutput . " " . "\\1", $text);
561  }
562  }
563  return $text;
564  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$result
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
getQuestion()
Gets the question string of the question object.
$text
static convertDecimalToCoprimeFraction($decimal_value, $tolerance=1.e-9)
+ Here is the call graph for this function:

Field Documentation

◆ $results

assFormulaQuestion::$results
private

Definition at line 22 of file class.assFormulaQuestion.php.

Referenced by getResults().

◆ $resultunits

assFormulaQuestion::$resultunits
private

Definition at line 23 of file class.assFormulaQuestion.php.

Referenced by __get(), getResultUnits(), and hasResultUnit().

◆ $unitrepository

assFormulaQuestion::$unitrepository
private

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

Referenced by getUnitrepository(), and setUnitrepository().

◆ $variables

assFormulaQuestion::$variables
private

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

Referenced by getVariables().


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