ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
assNumeric Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for assNumeric:
+ Collaboration diagram for assNumeric:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assNumeric constructor More...
 
 isComplete ()
 Returns true, if a numeric question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a assNumeric object to a database. More...
 
 duplicate (bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
 Duplicates an assNumericQuestion. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assNumeric object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 getLowerLimit ()
 
 getUpperLimit ()
 
 setLowerLimit ($a_limit)
 
 setUpperLimit ($a_limit)
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 contains ($value)
 Checks for a given value within the range. More...
 
 validateSolutionSubmit ()
 
 getSolutionSubmit ()
 
 isValidSolutionSubmit ($numeric_solution)
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getMaxChars ()
 Returns the maximum number of characters for the numeric input field. More...
 
 setMaxChars ($maxchars)
 Sets the maximum number of characters for the numeric input field. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 setExportDetailsXLS (ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
 {} More...
 
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 
- Public Member Functions inherited from assQuestion
 __construct (string $title="", string $comment="", string $author="", int $owner=-1, string $question="")
 assQuestion constructor More...
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML ($item, int $questionpool_id, ?int $tst_id, &$tst_object, int &$question_counter, array $import_mapping, array &$solutionhints=[])
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $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 (int $questionpool_id, string $title)
 Returns TRUE if the question title exists in a question pool in the database. More...
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 setOutputType (int $outputType=OUTPUT_HTML)
 
 setShuffle (?bool $shuffle=true)
 
 setAuthor (string $author="")
 
 setOwner (int $owner=-1)
 
 getTitle ()
 
 getTitleForHTMLOutput ()
 
 getTitleFilenameCompliant ()
 
 getId ()
 
 getShuffle ()
 
 getTestId ()
 
 getComment ()
 
 getDescriptionForHTMLOutput ()
 
 getThumbSize ()
 
 setThumbSize (int $a_size)
 
 getMinimumThumbSize ()
 
 getMaximumThumbSize ()
 
 getOutputType ()
 
 supportsJavascriptOutput ()
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 _getSuggestedSolution (int $question_id, int $subquestion_index=0)
 
 loadSuggestedSolution (int $question_id, int $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution (int $active_id, int $pass, bool $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $obligationsEnabled=false, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 saveWorkingData (int $active_id, int $pass, bool $authorized=true)
 Saves the learners input of the question to the database. More...
 
 moveUploadedMediaFile (string $file, string $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 
 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...
 
 getSuggestedSolutionPathWeb ()
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getTestOutputSolutions (int $activeId, int $pass)
 
 getUserSolutionPreferingIntermediate (int $active_id, $pass=null)
 
 getSolutionValues ($active_id, $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse (int $question_id=0)
 Checks whether the question is in use or not in pools or tests. More...
 
 usageNumber (int $question_id=0)
 Returns the number of place the question is in use in pools or tests. More...
 
 isClone (int $question_id=0)
 Checks whether the question is a clone of another question or not. More...
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 copyXHTMLMediaObjectsOfQuestion (int $a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 
 copyPageOfQuestion (int $a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
 fixSvgToPng (string $imageFilenameContainingString)
 
 fixUnavailableSkinImageSources (string $html)
 
 loadFromDb (int $question_id)
 
 createNewQuestion (bool $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 (int $original_id=-1)
 
 saveToDb ()
 
 setNewOriginalId (int $newId)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle (int $subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution (string $solution_id="", int $subquestion_index=0, bool $is_import=false)
 Sets a suggested solution for the question. More...
 
 updateSuggestedSolutions (int $original_id=-1, int $original_obj_id=-1)
 
 _resolveInternalLink (string $internal_link)
 
 _resolveIntLinks (int $question_id)
 
 syncWithOriginal ()
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool (int $question_id)
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 deductHintPointsFromReachedPoints (ilAssQuestionPreviewSession $previewSession, $reachedPoints)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=null)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 prepareTextareaOutput (string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
 
 QTIMaterialToString (ilQTIMaterial $a_material)
 Reads an QTI material tag and creates a text or XHTML string. More...
 
 addQTIMaterial (ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 
 syncHints ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 setExportDetailsXLS (ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 __isset ($key)
 Object issetter. More...
 
 getNrOfTries ()
 
 setNrOfTries (int $a_nr_of_tries)
 
 setExportImagePath (string $path)
 
 formatSAQuestion ($a_q)
 
 setPreventRteUsage (bool $prevent_rte_usage)
 
 getPreventRteUsage ()
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode (bool $selfassessmenteditingmode)
 
 getSelfAssessmentEditingMode ()
 
 setDefaultNrOfTries (int $defaultnroftries)
 
 getDefaultNrOfTries ()
 
 syncSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 ensureHintPageObjectExists ($pageObjectId)
 
 isAnswered (int $active_id, int $pass)
 
 isAutosaveable ()
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 removeCurrentSolution (int $active_id, int $pass, bool $authorized=true)
 
 saveCurrentSolution (int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
 updateCurrentSolution (int $solutionId, $value1, $value2, bool $authorized=true)
 
 updateCurrentSolutionsAuthorization (int $activeId, int $pass, bool $authorized, bool $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate (bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
 
 intermediateSolutionExists (int $active_id, int $pass)
 
 authorizedSolutionExists (int $active_id, ?int $pass)
 
 authorizedOrIntermediateSolutionExists (int $active_id, int $pass)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions (int $activeId, int $pass)
 
 resetUsersAnswer (int $activeId, int $pass)
 
 removeResultRecord (int $activeId, int $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered (bool $obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
 savePartial ()
 
 isInActiveTest ()
 
- Public Member Functions inherited from ilObjQuestionScoringAdjustable
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
- Public Member Functions inherited from ilObjAnswerScoringAdjustable
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 

Data Fields

 $maxchars
 
- 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 TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
ilAssQuestionFeedback $feedbackOBJ
 
bool $prevent_rte_usage = false
 
bool $selfassessmenteditingmode = false
 
int $defaultnroftries = 0
 
string $questionActionCmd = 'handleQuestionAction'
 
const KEY_VALUES_IMPLOSION_SEPARATOR = ':'
 
- Data Fields inherited from iQuestionCondition
const StringResultExpression = '~TEXT~'
 
const PercentageResultExpression = '%n%'
 
const NumericResultExpression = '#n#'
 
const MatchingResultExpression = ';n:m;'
 
const OrderingResultExpression = '$n,m,o,p$'
 
const NumberOfResultExpression = '+n+'
 
const ExclusiveResultExpression = '*n,m,o,p*'
 
const EmptyAnswerExpression = "?"
 

Protected Member Functions

 isValidNumericSubmitValue ($submittedValue)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
- Protected Member Functions inherited from assQuestion
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $postSubmissionFieldname)
 
 ensureCurrentTestPass (int $active_id, int $pass)
 
 lookupCurrentTestPass (int $active_id, int $pass)
 
 lookupTestId (int $active_id)
 Move to ilObjTest or similar More...
 
 log (int $active_id, string $langVar)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 deletePageOfQuestion (int $question_id)
 
 onDuplicate (int $originalParentId, int $originalQuestionId, int $duplicateParentId, int $duplicateQuestionId)
 
 beforeSyncWithOriginal (int $origQuestionId, int $dupQuestionId, int $origParentObjId, int $dupParentObjId)
 
 afterSyncWithOriginal (int $origQuestionId, int $dupQuestionId, int $origParentObjId, int $dupParentObjId)
 
 onCopy (int $sourceParentId, int $sourceQuestionId, int $targetParentId, int $targetQuestionId)
 
 duplicateSuggestedSolutionFiles (int $parent_id, int $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles (int $target_question_id, int $target_obj_id)
 
 copySuggestedSolutionFiles (int $source_questionpool_id, int $source_question_id)
 
 ensureNonNegativePoints ($points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints (int $originalQuestionId, int $duplicateQuestionId)
 
 duplicateSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet (int $active_id, int $pass, bool $authorized=true)
 
 removeSolutionRecordById (int $solutionId)
 
 getSolutionRecordById (int $solutionId)
 
 deleteDummySolutionRecord (int $activeId, int $passIndex)
 
 isDummySolutionRecord (array $solutionRecord)
 
 deleteSolutionRecordByValues (int $activeId, int $passIndex, bool $authorized, array $matchValues)
 
 duplicateIntermediateSolutionAuthorized (int $activeId, int $passIndex)
 
 forceExistingIntermediateSolution (int $activeId, int $passIndex, bool $considerDummyRecordCreation)
 
 lookupMaxStep (int $active_id, int $pass)
 
 buildTestPresentationConfig ()
 build basic test question configuration instance More...
 

Protected Attributes

 $lower_limit
 
 $upper_limit
 
- Protected Attributes inherited from assQuestion
const HAS_SPECIFIC_FEEDBACK = true
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
ILIAS DI LoggingServices $ilLog
 
int $id
 
string $title
 
string $comment
 
string $owner
 
string $author
 
int $thumb_size
 
string $question
 The question text. More...
 
float $points
 The maximum available points for the question. More...
 
bool $shuffle
 Indicates whether the answers will be shuffled or not. More...
 
int $test_id
 The database id of a test in which the question is contained. More...
 
int $obj_id = 0
 Object id of the container object. More...
 
 $ilias
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
ilDBInterface $db
 
Container $dic
 
int $outputType = OUTPUT_JAVASCRIPT
 Contains the output type of a question. More...
 
array $suggested_solutions
 
int $original_id = null
 
 $page
 
string $external_id = null
 
ilAssQuestionProcessLocker $processLocker
 
 $step
 
 $lastChange
 
Transformation $shuffler
 
ilTestQuestionConfig $testQuestionConfig
 
ilAssQuestionLifecycle $lifecycle
 
ilObjUser $current_user
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $forcePassResultsUpdateEnabled)
 
static isForcePassResultUpdateEnabled ()
 
static isAllowedImageMimeType ($mimeType)
 
static fetchMimeTypeIdentifier (string $contentType)
 
static getAllowedFileExtensionsForMimeType (string $mimeType)
 
static isAllowedImageFileExtension (string $mimeType, string $fileExtension)
 
static getAllowedImageMaterialFileExtensions ()
 
static _getMaximumPoints (int $question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
static _getQuestionInfo (int $question_id)
 
static _getSuggestedSolutionCount (int $question_id)
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static _updateTestResultCache (int $active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place. More...
 
static logAction (string $logtext, int $active_id, int $question_id)
 
static getQuestionTypeFromDb (int $question_id)
 
static _getTotalRightAnswers (int $a_q_id)
 
static _getTitle (int $a_q_id)
 
static _getQuestionText (int $a_q_id)
 
static isFileAvailable (string $file)
 
static _getQuestionType (int $question_id)
 
static _getQuestionTitle (int $question_id)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static _getInternalLinkHref (string $target="")
 
static _getOriginalId (int $question_id)
 
static originalQuestionExists (int $questionId)
 
static _instanciateQuestion (int $question_id)
 
static _instantiateQuestion (int $question_id)
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static _isWriteable (int $question_id, int $user_id)
 
static _isUsedInRandomTest (int $question_id)
 
static _isWorkedThrough (int $active_id, int $question_id, int $pass)
 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 (int $a_user_id, array $a_question_ids)
 Checks if an array of question ids is answered by a user or not. More...
 
static _setReachedPoints (int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring, bool $obligationsEnabled)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static _needsManualScoring (int $question_id)
 
static _includeClass (string $question_type, int $gui=0)
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static isCoreQuestionType (string $questionType)
 
static includeCoreClass ($questionType, $withGuiClass)
 
static _getQuestionTypeName ($type_tag)
 
static _instanciateQuestionGUI (int $question_id)
 
static instantiateQuestionGUI (int $a_question_id)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $questionId)
 
static lookupOriginalParentObjId (int $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 (int $questionId)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
static missingResultRecordExists (int $activeId, int $pass, array $questionIds)
 
static getQuestionsMissingResultRecord (int $activeId, int $pass, array $questionIds)
 
static lookupResultRecordExist (int $activeId, int $questionId, int $pass)
 
static extendedTrim (string $value)
 Trim non-printable characters from the beginning and end of a string. More...
 
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $allowedImageMaterialFileExtensionsByMimeType
 
static $forcePassResultsUpdateEnabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class for numeric questions

assNumeric is a class for numeric questions. To solve a numeric question, a learner has to enter a numerical value in a defined range.

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
Nina Gharib nina@.nosp@m.wgse.nosp@m.rve.d.nosp@m.e
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 36 of file class.assNumeric.php.

Constructor & Destructor Documentation

◆ __construct()

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

assNumeric constructor

The constructor takes possible arguments an creates an instance of the assNumeric 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 numeric question

Definition at line 55 of file class.assNumeric.php.

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

61  {
63  $this->maxchars = 6;
64  }
string $question
The question text.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ calculateReachedPointsFromPreviewSession()

assNumeric::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

Definition at line 321 of file class.assNumeric.php.

References $data, $DIC, $ilDB, assQuestion\$points, assQuestion\calculateReachedPoints(), contains(), assQuestion\deductHintPointsFromReachedPoints(), assQuestion\ensureNonNegativePoints(), assQuestion\getCurrentSolutionResultSet(), ilAssQuestionPreviewSession\getParticipantsSolution(), assQuestion\getPoints(), and assQuestion\getSolutionMaxPass().

322  {
323  $points = 0;
324  if ($this->contains($previewSession->getParticipantsSolution())) {
325  $points = $this->getPoints();
326  }
327 
328  $reachedPoints = $this->deductHintPointsFromReachedPoints($previewSession, $points);
329 
330  return $this->ensureNonNegativePoints($reachedPoints);
331  }
ensureNonNegativePoints($points)
float $points
The maximum available points for the question.
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
contains($value)
Checks for a given value within the range.
+ Here is the call graph for this function:

◆ contains()

assNumeric::contains (   $value)

Checks for a given value within the range.

See also
$upperlimit
$lowerlimit
Parameters
double$valueThe value to check
Returns
boolean TRUE if the value is in the range, FALSE otherwise

Definition at line 384 of file class.assNumeric.php.

References getUpperLimit().

Referenced by calculateReachedPointsFromPreviewSession().

384  : bool
385  {
386  require_once './Services/Math/classes/class.EvalMath.php';
387  $eval = new EvalMath();
388  $eval->suppress_errors = true;
389  $result = $eval->e($value);
390  if (($result === false) || ($result === true)) {
391  return false;
392  }
393 
394  if (($result >= $eval->e($this->getLowerLimit())) && ($result <= $eval->e($this->getUpperLimit()))) {
395  return true;
396  }
397  return false;
398  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyObject()

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

Copies an assNumeric object.

Parameters
integer$target_questionpool_id
string$title
Returns
void|integer Id of the clone or nothing.

Definition at line 229 of file class.assNumeric.php.

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

230  {
231  if ($this->id <= 0) {
232  // The question has not been saved. It cannot be duplicated
233  return;
234  }
235  // duplicate the question in database
236  $clone = $this;
237  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
239  $clone->id = -1;
240  $source_questionpool_id = $this->getObjId();
241  $clone->setObjId($target_questionpool_id);
242  if ($title) {
243  $clone->setTitle($title);
244  }
245  $clone->saveToDb();
246 
247  // copy question page content
248  $clone->copyPageOfQuestion($original_id);
249  // copy XHTML media objects
250  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
251 
252  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
253 
254  return $clone->id;
255  }
static _getOriginalId(int $question_id)
+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

Definition at line 257 of file class.assNumeric.php.

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

257  : int
258  {
259  if ($this->getId() <= 0) {
260  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
261  }
262 
263  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
264 
265  $sourceQuestionId = $this->id;
266  $sourceParentId = $this->getObjId();
267 
268  // duplicate the question in database
269  $clone = $this;
270  $clone->id = -1;
271 
272  $clone->setObjId($targetParentId);
273 
274  if ($targetQuestionTitle) {
275  $clone->setTitle($targetQuestionTitle);
276  }
277 
278  $clone->saveToDb();
279  // copy question page content
280  $clone->copyPageOfQuestion($sourceQuestionId);
281  // copy XHTML media objects
282  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
283 
284  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
285 
286  return $clone->id;
287  }
+ Here is the call graph for this function:

◆ duplicate()

assNumeric::duplicate ( bool  $for_test = true,
string  $title = "",
string  $author = "",
string  $owner = "",
  $testObjId = null 
)

Duplicates an assNumericQuestion.

Parameters
bool$for_test
string$title
string$author
string$owner
integer | null$testObjId
Returns
void|integer Id of the clone or nothing.

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

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

175  : int
176  {
177  if ($this->id <= 0) {
178  // The question has not been saved. It cannot be duplicated
179  return -1;
180  }
181  // duplicate the question in database
182  $this_id = $this->getId();
183  $thisObjId = $this->getObjId();
184 
185  $clone = $this;
186  require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
188  $clone->id = -1;
189 
190  if ((int) $testObjId > 0) {
191  $clone->setObjId($testObjId);
192  }
193 
194  if ($title) {
195  $clone->setTitle($title);
196  }
197 
198  if ($author) {
199  $clone->setAuthor($author);
200  }
201  if ($owner) {
202  $clone->setOwner($owner);
203  }
204 
205  if ($for_test) {
206  $clone->saveToDb($original_id);
207  } else {
208  $clone->saveToDb();
209  }
210 
211  // copy question page content
212  $clone->copyPageOfQuestion($this_id);
213  // copy XHTML media objects
214  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
215 
216  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
217 
218  return $clone->id;
219  }
static _getOriginalId(int $question_id)
+ Here is the call graph for this function:

◆ getAdditionalTableName()

assNumeric::getAdditionalTableName ( )

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

Returns
string The additional table name

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

Referenced by savePreviewData(), and saveToDb().

608  : string
609  {
610  return "qpl_qst_numeric";
611  }
+ Here is the caller graph for this function:

◆ getAvailableAnswerOptions()

assNumeric::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 723 of file class.assNumeric.php.

References getLowerLimit(), and getUpperLimit().

724  {
725  return array(
726  "lower" => $this->getLowerLimit(),
727  "upper" => $this->getUpperLimit()
728  );
729  }
+ Here is the call graph for this function:

◆ getExpressionTypes()

◆ getLowerLimit()

assNumeric::getLowerLimit ( )

Definition at line 289 of file class.assNumeric.php.

References $lower_limit.

Referenced by getAvailableAnswerOptions(), and savePreviewData().

290  {
291  return $this->lower_limit;
292  }
+ Here is the caller graph for this function:

◆ getMaxChars()

assNumeric::getMaxChars ( )

Returns the maximum number of characters for the numeric input field.

Returns
integer The maximum number of characters

Definition at line 588 of file class.assNumeric.php.

References $maxchars.

Referenced by savePreviewData().

589  {
590  return $this->maxchars;
591  }
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assNumeric::getMaximumPoints ( )

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

See also
$points

Definition at line 316 of file class.assNumeric.php.

References assQuestion\getPoints().

Referenced by getExpressionTypes(), and isComplete().

316  : float
317  {
318  return $this->getPoints();
319  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOperators()

assNumeric::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

Definition at line 654 of file class.assNumeric.php.

References ilOperatorsExpressionMapping\getOperatorsByExpression().

654  : array
655  {
657  }
+ Here is the call graph for this function:

◆ getQuestionType()

assNumeric::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

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

578  : string
579  {
580  return "assNumeric";
581  }

◆ getRTETextWithMediaObjects()

assNumeric::getRTETextWithMediaObjects ( )

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

Definition at line 617 of file class.assNumeric.php.

617  : string
618  {
619  return parent::getRTETextWithMediaObjects();
620  }

◆ getSolutionSubmit()

assNumeric::getSolutionSubmit ( )

Definition at line 423 of file class.assNumeric.php.

Referenced by isValidSolutionSubmit(), savePreviewData(), and validateSolutionSubmit().

423  : string
424  {
425  return trim(str_replace(",", ".", $_POST["numeric_result"]));
426  }
+ Here is the caller graph for this function:

◆ getUpperLimit()

assNumeric::getUpperLimit ( )

Definition at line 294 of file class.assNumeric.php.

References $upper_limit.

Referenced by contains(), getAvailableAnswerOptions(), and savePreviewData().

295  {
296  return $this->upper_limit;
297  }
+ Here is the caller graph for this function:

◆ isComplete()

assNumeric::isComplete ( )

Returns true, if a numeric question is complete for use.

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

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

References getMaximumPoints().

71  : bool
72  {
73  if (
74  strlen($this->title)
75  && $this->author
76  && $this->question
77  && $this->getMaximumPoints() > 0
78  ) {
79  return true;
80  }
81  return false;
82  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ isValidNumericSubmitValue()

assNumeric::isValidNumericSubmitValue (   $submittedValue)
protected

Definition at line 400 of file class.assNumeric.php.

Referenced by validateSolutionSubmit().

400  : bool
401  {
402  if (is_numeric($submittedValue)) {
403  return true;
404  }
405 
406  if (preg_match('/^[-+]{0,1}\d+\/\d+$/', $submittedValue)) {
407  return true;
408  }
409 
410  return false;
411  }
+ Here is the caller graph for this function:

◆ isValidSolutionSubmit()

assNumeric::isValidSolutionSubmit (   $numeric_solution)

Definition at line 428 of file class.assNumeric.php.

References $DIC, $ilDB, $update, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), assQuestion\getCurrentSolutionResultSet(), assQuestion\getId(), assQuestion\getProcessLocker(), getSolutionSubmit(), ILIAS\Repository\lng(), assQuestion\logAction(), assQuestion\removeSolutionRecordById(), assQuestion\saveCurrentSolution(), assQuestion\saveWorkingData(), and assQuestion\updateCurrentSolution().

428  : bool
429  {
430  require_once './Services/Math/classes/class.EvalMath.php';
431  $math = new EvalMath();
432  $math->suppress_errors = true;
433  $result = $math->evaluate($numeric_solution);
434 
435  return !(
436  ($result === false || $result === true) && strlen($numeric_solution) > 0
437  );
438  }
+ Here is the call graph for this function:

◆ savePreviewData()

assNumeric::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

◆ saveToDb()

assNumeric::saveToDb (   $original_id = "")

Saves a assNumeric object to a database.

Parameters
string$original_id

Definition at line 89 of file class.assNumeric.php.

References $data, $DIC, Vendor\Package\$e, $ilDB, assQuestion\$original_id, ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), assQuestion\loadFromDb(), ilObjQuestionScoringAdjustable\saveAdditionalQuestionDataToDb(), ilObjAnswerScoringAdjustable\saveAnswerSpecificDataToDb(), assQuestion\saveQuestionDataToDb(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setId(), assQuestion\setLifecycle(), setLowerLimit(), setMaxChars(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), assQuestion\setTitle(), and setUpperLimit().

89  : void
90  {
91  if ($original_id == "") {
92  $this->saveQuestionDataToDb();
93  } else {
95  }
96 
99  parent::saveToDb($original_id);
100  }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb(int $original_id=-1)
+ Here is the call graph for this function:

◆ setExportDetailsXLS()

assNumeric::setExportDetailsXLS ( ilAssExcelFormatHelper  $worksheet,
int  $startrow,
int  $active_id,
int  $pass 
)

{}

Definition at line 625 of file class.assNumeric.php.

References $i, ilExcel\getColumnCoord(), assQuestion\getSolutionValues(), ILIAS\Repository\lng(), ilExcel\setBold(), and ilAssExcelFormatHelper\setCell().

625  : int
626  {
627  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
628 
629  $solutions = $this->getSolutionValues($active_id, $pass);
630 
631  $i = 1;
632  $worksheet->setCell($startrow + $i, 0, $this->lng->txt("result"));
633  $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
634 
635  $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
636  if (array_key_exists(0, $solutions) &&
637  array_key_exists('value1', $solutions[0]) &&
638  strlen($solutions[0]["value1"])) {
639  $worksheet->setCell($startrow + $i, 2, $solutions[0]["value1"]);
640  }
641  $i++;
642 
643  return $startrow + $i + 1;
644  }
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
getColumnCoord(int $a_col)
Get column "name" from number.
setCell($a_row, $a_col, $a_value, $datatype=null)
setBold(string $a_coords)
Set cell(s) to bold.
$i
Definition: metadata.php:41
+ Here is the call graph for this function:

◆ setLowerLimit()

assNumeric::setLowerLimit (   $a_limit)

Definition at line 299 of file class.assNumeric.php.

Referenced by saveToDb().

299  : void
300  {
301  $a_limit = str_replace(',', '.', $a_limit);
302  $this->lower_limit = $a_limit;
303  }
+ Here is the caller graph for this function:

◆ setMaxChars()

assNumeric::setMaxChars (   $maxchars)

Sets the maximum number of characters for the numeric input field.

Parameters
integer$maxcharsThe maximum number of characters

Definition at line 598 of file class.assNumeric.php.

References $maxchars.

Referenced by saveToDb().

598  : void
599  {
600  $this->maxchars = $maxchars;
601  }
+ Here is the caller graph for this function:

◆ setUpperLimit()

assNumeric::setUpperLimit (   $a_limit)

Definition at line 305 of file class.assNumeric.php.

Referenced by saveToDb().

305  : void
306  {
307  $a_limit = str_replace(',', '.', $a_limit);
308  $this->upper_limit = $a_limit;
309  }
+ Here is the caller graph for this function:

◆ validateSolutionSubmit()

assNumeric::validateSolutionSubmit ( )

Definition at line 413 of file class.assNumeric.php.

References getSolutionSubmit(), isValidNumericSubmitValue(), and ILIAS\Repository\lng().

413  : bool
414  {
415  if (strlen($this->getSolutionSubmit()) && !$this->isValidNumericSubmitValue($this->getSolutionSubmit())) {
416  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("err_no_numeric_value"), true);
417  return false;
418  }
419 
420  return true;
421  }
isValidNumericSubmitValue($submittedValue)
+ Here is the call graph for this function:

Field Documentation

◆ $lower_limit

assNumeric::$lower_limit
protected

Definition at line 38 of file class.assNumeric.php.

Referenced by getLowerLimit().

◆ $maxchars

assNumeric::$maxchars

Definition at line 42 of file class.assNumeric.php.

Referenced by getMaxChars(), and setMaxChars().

◆ $upper_limit

assNumeric::$upper_limit
protected

Definition at line 39 of file class.assNumeric.php.

Referenced by getUpperLimit().


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