ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
assNumeric Class Reference

Class for numeric questions. More...

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

Public Member Functions

 isComplete ()
 
 saveToDb (?int $original_id=null)
 
 loadFromDb (int $question_id)
 
 getLowerLimit ()
 
 getUpperLimit ()
 
 setLowerLimit (string $limit)
 
 setUpperLimit (string $limit)
 
 getMaximumPoints ()
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 contains ($value)
 Checks for a given value within the range. More...
 
 validateSolutionSubmit ()
 
 isValidSolutionSubmit ($numeric_solution)
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 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...
 
 getOperators (string $expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getUserQuestionResult (int $active_id, int $pass)
 Get the user solution for a question by active_id and the test pass. More...
 
 getAvailableAnswerOptions (?int $index=null)
 If index is null, the function returns an array with all anwser options else it returns the specific answer option. More...
 
 getAnswerTableName ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 solutionValuesToText (array $solution_values)
 MUST convert the given solution values into text. More...
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
 toNormalized (Transformations $transformations, array $context=[])
 
 fromNormalized (array $normalized, Transformations $transformations)
 
- Public Member Functions inherited from assQuestion
 getQuestionType ()
 
 isComplete ()
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 getCurrentUser ()
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML (string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping)
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $force_image_references=false)
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 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 ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorized_solution=true)
 
 calculateResultsFromSolution (int $active_id, int $pass)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $preview_session)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 getSuggestedSolutionPath ()
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images 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, ?int $pass=null)
 
 getSolutionValues (int $active_id, ?int $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 cloneXHTMLMediaObjectsOfQuestion (int $source_question_id)
 
 createPageObject ()
 
 clonePageOfQuestion (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=null)
 
 updateOriginalId (?int $original_id=null)
 
 duplicate (bool $set_original_id=true, string $title='', string $author='', int $owner=-1, $test_obj_id=null)
 
 copyObject (int $target_parent_id, string $title='')
 
 createNewOriginalFromThisDuplicate (int $target_parent_id, string $target_question_title='')
 
 saveToDb (?int $original_id=null)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 
 resolveInternalLink (string $internal_link)
 
 resolveSuggestedSolutionLinks ()
 
 getInternalLinkHref (string $target)
 
 syncWithOriginal ()
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 isWriteable ()
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $preview_session)
 
 adjustReachedPointsByScoringOptions (float $points, int $active_id)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionTypeID ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 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)
 
 isAnswered (int $active_id, int $pass)
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange (int $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 ()
 
 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 $value_pairs)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
 hasWritableOriginalInQuestionPool ()
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 getSolutionForTextOutput (int $active_id, int $pass)
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
 getVariablesAsTextArray (int $active_id, int $pass)
 
 toNormalized (Transformations $transformations, array $context=[])
 
 fromNormalized (array $normalized, Transformations $transformations)
 
 validateSolutionSubmit ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 getOperators (string $expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getUserQuestionResult (int $active_id, int $pass)
 Get the user solution for a question by active_id and the test pass. More...
 
 getAvailableAnswerOptions (?int $index=null)
 If index is null, the function returns an array with all anwser options else it returns the specific answer option. More...
 
 toNormalized (Transformations $transformations, array $context=[])
 Convert the internal state of the implementing object into a language-neutral array structure. More...
 
 fromNormalized (array $normalized, Transformations $transformations)
 Restore the object from its normalized representation. More...
 

Data Fields

 $maxchars = 6
 
- Data Fields inherited from assQuestion
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
const TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
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

 getSolutionSubmit ()
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 solutionValuesToLog (AdditionalInformationGenerator $additional_info, array $solution_values)
 MUST convert the given solution values into an array or a string that can be stored in the log. More...
 
- Protected Member Functions inherited from assQuestion
 solutionValuesToLog (AdditionalInformationGenerator $additional_info, array $solution_values)
 MUST convert the given solution values into an array or a string that can be stored in the log. More...
 
 solutionValuesToText (array $solution_values)
 MUST convert the given solution values into text. More...
 
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $post_submission_field_name)
 
 savePreviewData (ilAssQuestionPreviewSession $preview_session)
 
 deletePageOfQuestion (int $question_id)
 
 cloneQuestionTypeSpecificProperties (self $target)
 
 removeAllImageFiles (string $image_target_path)
 
 onDuplicate (int $original_parent_id, int $original_question_id, int $duplicate_parent_id, int $duplicate_question_id)
 
 afterSyncWithOriginal (int $original_question_id, int $clone_question_id, int $original_parent_id, int $clone_parent_id)
 
 onCopy (int $sourceParentId, int $sourceQuestionId, int $targetParentId, int $targetQuestionId)
 
 duplicateComments (int $parent_source_id, int $source_id, int $parent_target_id, int $target_id)
 
 deleteComments ()
 
 getNotesManager ()
 
 getNotesDataService ()
 
 getNotesRepo ()
 
 cloneSuggestedSolutions (int $source_question_id, int $target_question_id)
 
 duplicateSuggestedSolutionFiles (int $parent_id, int $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 cloneSuggestedSolutionFiles (int $source_question_id, int $target_question_id)
 
 copySuggestedSolutions (int $target_question_id)
 
 ensureNonNegativePoints (float $points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 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 ()
 
 getSuggestedSolutionsRepo ()
 
 loadSuggestedSolutions ()
 
 answerToLog (AdditionalInformationGenerator $additional_info, int $active_id, int $pass)
 

Protected Attributes

 $lower_limit
 
 $upper_limit
 
- Protected Attributes inherited from assQuestion
const HAS_SPECIFIC_FEEDBACK = true
 
GeneralQuestionPropertiesRepository $questionrepository
 
RequestDataCollector $questionpool_request
 
QuestionFiles $question_files
 
ilAssQuestionProcessLocker $processLocker
 
ilTestQuestionConfig $testQuestionConfig
 
SuggestedSolutionsDatabaseRepository $suggestedsolution_repo
 
ILIAS $ilias
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
ilDBInterface $db
 
ilObjUser $current_user
 
SkillUsageService $skillUsageService
 
HTTPServices $http
 
Refinery $refinery
 
Transformation $shuffler
 
LoggingServices $log
 
Container $dic
 
ilAssQuestionLifecycle $lifecycle
 
ilAssQuestionPage $page
 
TestResultRepository $test_result_repository
 
int $id
 
string $title
 
string $comment
 
int $owner
 
string $author
 
int $thumb_size
 
string $question
 
float $points = 0.0
 
bool $shuffle = true
 
int $test_id
 
int $obj_id = 0
 
int $original_id = null
 
int $lastChange = null
 
string $external_id = null
 
int $step = null
 
array $suggested_solutions
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $force_pass_results_update_enabled)
 
static isForcePassResultUpdateEnabled ()
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static isFileAvailable (string $file)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $question_id)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
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 $force_pass_results_update_enabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

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

Member Function Documentation

◆ calculateReachedPoints()

assNumeric::calculateReachedPoints ( int  $active_id,
?int  $pass = null,
bool  $authorized_solution = true 
)

Reimplemented from assQuestion.

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

159 : float {
160 if ($pass === null) {
161 $pass = $this->getSolutionMaxPass($active_id);
162 }
163 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
164 $data = $this->db->fetchAssoc($result);
165 $enteredvalue = '';
166 if (is_array($data) && array_key_exists('value1', $data)) {
167 $enteredvalue = $data["value1"];
168 }
169
170 $points = 0.0;
171 if ($this->contains($enteredvalue)) {
172 $points = $this->getPoints();
173 }
174
175 return $points;
176 }
contains($value)
Checks for a given value within the range.
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
getSolutionMaxPass(int $active_id)
$data
Definition: storeScorm.php:45

References assQuestion\getSolutionMaxPass().

+ Here is the call graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assNumeric::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

Reimplemented from assQuestion.

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

145 : float
146 {
147 $points = 0;
148 if ($this->contains($previewSession->getParticipantsSolution())) {
149 $points = $this->getPoints();
150 }
151
152 return $this->ensureNonNegativePoints($points);
153 }
ensureNonNegativePoints(float $points)

References assQuestion\$points, contains(), assQuestion\ensureNonNegativePoints(), ilAssQuestionPreviewSession\getParticipantsSolution(), and assQuestion\getPoints().

+ 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 188 of file class.assNumeric.php.

188 : bool
189 {
190 $eval = new EvalMath();
191 $eval->suppress_errors = true;
192 $result = $eval->e((string) $value);
193 if (($result === false) || ($result === true)) {
194 return false;
195 }
196
197 if (($result >= $eval->e($this->getLowerLimit())) && ($result <= $eval->e($this->getUpperLimit()))) {
198 return true;
199 }
200 return false;
201 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by calculateReachedPointsFromPreviewSession().

+ Here is the caller graph for this function:

◆ fromNormalized()

assNumeric::fromNormalized ( array  $normalized,
Transformations  $transformations 
)
Parameters
array<array-key,mixed>$normalized

Reimplemented from assQuestion.

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

488 : static
489 {
490 $clone = parent::fromNormalized($normalized, $transformations);
491 $clone->lower_limit = $transformations->string($normalized['lower_limit']);
492 $clone->upper_limit = $transformations->string($normalized['upper_limit']);
493 $clone->maxchars = $transformations->int($normalized['maxchars']);
494
495 return $clone;
496 }

References ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\int(), and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\string().

+ 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

Reimplemented from assQuestion.

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

352 : string
353 {
354 return "qpl_qst_numeric";
355 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ getAnswerTableName()

assNumeric::getAnswerTableName ( )

Reimplemented from assQuestion.

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

421 : string
422 {
423 return '';
424 }

◆ getAvailableAnswerOptions()

assNumeric::getAvailableAnswerOptions ( ?int  $index = null)

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

Implements iQuestionCondition.

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

413 : array
414 {
415 return [
416 "lower" => $this->getLowerLimit(),
417 "upper" => $this->getUpperLimit()
418 ];
419 }

◆ getCorrectSolutionForTextOutput()

assNumeric::getCorrectSolutionForTextOutput ( int  $active_id,
int  $pass 
)

Reimplemented from assQuestion.

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

465 : string
466 {
467 return "{$this->getLowerLimit()}-{$this->getUpperLimit()}";
468 }

◆ getExpressionTypes()

assNumeric::getExpressionTypes ( )

◆ getLowerLimit()

assNumeric::getLowerLimit ( )

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

121 {
122 return $this->lower_limit;
123 }

References $lower_limit.

◆ getMaxChars()

assNumeric::getMaxChars ( )

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

Returns
integer The maximum number of characters

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

333 {
334 return $this->maxchars;
335 }

◆ getMaximumPoints()

assNumeric::getMaximumPoints ( )

Reimplemented from assQuestion.

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

140 : float
141 {
142 return $this->getPoints();
143 }

References assQuestion\getPoints().

Referenced by isComplete().

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

◆ getOperators()

assNumeric::getOperators ( string  $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

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

366 : array
367 {
369 }
static getOperatorsByExpression(string $expression)

References ilOperatorsExpressionMapping\getOperatorsByExpression().

+ 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

Reimplemented from assQuestion.

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

322 : string
323 {
324 return "assNumeric";
325 }

◆ getRTETextWithMediaObjects()

assNumeric::getRTETextWithMediaObjects ( )

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

Reimplemented from assQuestion.

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

361 : string
362 {
363 return parent::getRTETextWithMediaObjects();
364 }

◆ getSolutionSubmit()

assNumeric::getSolutionSubmit ( )
protected

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

213 : ?float
214 {
215 return $this->questionpool_request->getNumericQuestionSolutionSubmit();
216 }

◆ getUpperLimit()

assNumeric::getUpperLimit ( )

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

126 {
127 return $this->upper_limit;
128 }

References $upper_limit.

◆ getUserQuestionResult()

assNumeric::getUserQuestionResult ( int  $active_id,
int  $pass 
)

Get the user solution for a question by active_id and the test pass.

Implements iQuestionCondition.

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

384 $result = new ilUserQuestionResult($this, $active_id, $pass);
385
386 $maxStep = $this->lookupMaxStep($active_id, $pass);
387 if ($maxStep > 0) {
388 $data = $this->db->queryF(
389 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
390 ["integer", "integer", "integer","integer"],
391 [$active_id, $pass, $this->getId(), $maxStep]
392 );
393 } else {
394 $data = $this->db->queryF(
395 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
396 ["integer", "integer", "integer"],
397 [$active_id, $pass, $this->getId()]
398 );
399 }
400
401 while ($row = $this->db->fetchAssoc($data)) {
402 $result->addKeyValue(1, $row["value1"]);
403 }
404
405 $points = $this->calculateReachedPoints($active_id, $pass);
406 $max_points = $this->getMaximumPoints();
407
408 $result->setReachedPercentage(($points / $max_points) * 100);
409
410 return $result;
411 }
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
lookupMaxStep(int $active_id, int $pass)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ isComplete()

assNumeric::isComplete ( )

Reimplemented from assQuestion.

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

48 : bool
49 {
50 if (
51 strlen($this->title)
52 && $this->author
53 && $this->question
54 && $this->getMaximumPoints() > 0
55 ) {
56 return true;
57 }
58 return false;
59 }

References getMaximumPoints().

+ Here is the call graph for this function:

◆ isValidSolutionSubmit()

assNumeric::isValidSolutionSubmit (   $numeric_solution)

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

218 : bool
219 {
220 $math = new EvalMath();
221 $math->suppress_errors = true;
222 $result = $math->evaluate($numeric_solution);
223
224 return !(
225 ($result === false || $result === true) && strlen($numeric_solution) > 0
226 );
227 }

◆ loadFromDb()

assNumeric::loadFromDb ( int  $question_id)

@noinspection PhpAssignmentInConditionInspection

Reimplemented from assQuestion.

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

69 : void
70 {
71 $result = $this->db->queryF(
72 "SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s",
73 ["integer"],
74 [$question_id]
75 );
76 if ($result->numRows() == 1) {
77 $data = $this->db->fetchAssoc($result);
78 $this->setId($question_id);
79 $this->setObjId($data["obj_fi"]);
80 $this->setTitle((string) $data["title"]);
81 $this->setComment((string) $data["description"]);
82 $this->setNrOfTries($data['nr_of_tries']);
83 $this->setOriginalId($data["original_id"]);
84 $this->setAuthor($data["author"]);
85 $this->setPoints($data["points"]);
86 $this->setOwner($data["owner"]);
87 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
88 $this->setMaxChars($data["maxnumofchars"]);
89
90 try {
91 $this->setLifecycle(new ilAssQuestionLifecycle($data['lifecycle']));
94 }
95
96 try {
97 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
99 }
100 }
101
102 $result = $this->db->queryF(
103 "SELECT * FROM qpl_num_range WHERE question_fi = %s ORDER BY aorder ASC",
104 ['integer'],
105 [$question_id]
106 );
107
108 if ($result->numRows() > 0) {
110 while ($data = $this->db->fetchAssoc($result)) {
111 $this->setPoints($data['points']);
112 $this->setLowerLimit($data['lowerlimit']);
113 $this->setUpperLimit($data['upperlimit']);
114 }
115 }
116
117 parent::loadFromDb($question_id);
118 }
setMaxChars($maxchars)
Sets the maximum number of characters for the numeric input field.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setLowerLimit(string $limit)
setUpperLimit(string $limit)
setOriginalId(?int $original_id)
setId(int $id=-1)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
setAuthor(string $author="")
setComment(string $comment="")
setObjId(int $obj_id=0)
setOwner(int $owner=-1)
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
setPoints(float $points)
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...

References $data, Vendor\Package\$e, ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), 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().

+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assNumeric::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

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

279 {
280 // save additional data
281 $this->db->manipulateF(
282 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
283 [ "integer" ],
284 [ $this->getId() ]
285 );
286
287 $this->db->manipulateF(
288 "INSERT INTO " . $this->getAdditionalTableName(
289 ) . " (question_fi, maxnumofchars) VALUES (%s, %s)",
290 [ "integer", "integer" ],
291 [
292 $this->getId(),
293 ($this->getMaxChars()) ? $this->getMaxChars() : 0
294 ]
295 );
296 }
getMaxChars()
Returns the maximum number of characters for the numeric input field.

References ILIAS\Survey\Mode\getId().

Referenced by saveToDb().

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

◆ saveAnswerSpecificDataToDb()

assNumeric::saveAnswerSpecificDataToDb ( )

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

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

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

299 {
300 // Write range to the database
301 $this->db->manipulateF(
302 "DELETE FROM qpl_num_range WHERE question_fi = %s",
303 [ 'integer' ],
304 [ $this->getId() ]
305 );
306
307 $next_id = $this->db->nextId('qpl_num_range');
308 $this->db->manipulateF(
309 "INSERT INTO qpl_num_range (range_id, question_fi, lowerlimit, upperlimit, points, aorder, tstamp)
310 VALUES (%s, %s, %s, %s, %s, %s, %s)",
311 [ 'integer', 'integer', 'text', 'text', 'float', 'integer', 'integer' ],
312 [ $next_id, $this->id, $this->getLowerLimit(), $this->getUpperLimit(
313 ), $this->getPoints(), 0, time() ]
314 );
315 }

References ILIAS\Survey\Mode\getId().

Referenced by saveToDb().

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

◆ savePreviewData()

assNumeric::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

Reimplemented from assQuestion.

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

272 : void
273 {
274 $numericSolution = $this->getSolutionSubmit();
275 $previewSession->setParticipantsSolution($numericSolution);
276 }

References ilAssQuestionPreviewSession\setParticipantsSolution().

+ Here is the call graph for this function:

◆ saveToDb()

assNumeric::saveToDb ( ?int  $original_id = null)

Reimplemented from assQuestion.

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

61 : void
62 {
66 parent::saveToDb($original_id);
67 }
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb(?int $original_id=null)

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

+ Here is the call graph for this function:

◆ saveWorkingData()

assNumeric::saveWorkingData ( int  $active_id,
?int  $pass = null,
bool  $authorized = true 
)

Reimplemented from assQuestion.

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

233 : bool {
234 $pass ??= ilObjTest::_getPass($active_id);
235
236 $answer = $this->getSolutionSubmit();
237 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
238 function () use ($answer, $active_id, $pass, $authorized): void {
239 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized);
240 $update = -1;
241 if ($this->db->numRows($result) !== 0) {
242 $update = $this->db->fetchAssoc($result)['solution_id'];
243 }
244
245 if ($update === -1 && $answer === null) {
246 return;
247 }
248
249 if ($update === -1) {
250 $this->saveCurrentSolution(
251 $active_id,
252 $pass,
253 $answer,
254 null,
255 $authorized
256 );
257 return;
258 }
259
260 if ($answer === null) {
261 $this->removeSolutionRecordById($update);
262 return;
263 }
264
265 $this->updateCurrentSolution($update, $answer, null, $authorized);
266 }
267 );
268
269 return true;
270 }
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
updateCurrentSolution(int $solutionId, $value1, $value2, bool $authorized=true)
removeSolutionRecordById(int $solutionId)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.

◆ setLowerLimit()

assNumeric::setLowerLimit ( string  $limit)

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

130 : void
131 {
132 $this->lower_limit = str_replace(',', '.', $limit);
133 }

Referenced by loadFromDb().

+ 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 342 of file class.assNumeric.php.

342 : void
343 {
344 $this->maxchars = $maxchars;
345 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setUpperLimit()

assNumeric::setUpperLimit ( string  $limit)

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

135 : void
136 {
137 $this->upper_limit = str_replace(',', '.', $limit);
138 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ solutionValuesToLog()

assNumeric::solutionValuesToLog ( AdditionalInformationGenerator  $additional_info,
array  $solution_values 
)
protected

MUST convert the given solution values into an array or a string that can be stored in the log.

Language variables must be generated through the corresponding functions in the AdditionalInformationGenerator. If an array is returned it will be rendered into a line per array entry in the format "key: value". If the key exists as a language variable, it will be translated.

Reimplemented from assQuestion.

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

448 : string {
449 if (!array_key_exists(0, $solution_values) ||
450 !array_key_exists('value1', $solution_values[0])) {
451 return '';
452 }
453 return $solution_values[0]['value1'];
454 }

◆ solutionValuesToText()

assNumeric::solutionValuesToText ( array  $solution_values)

MUST convert the given solution values into text.

If the text has multiple lines each line MUST be placed as an entry in an array.

Reimplemented from assQuestion.

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

456 : string
457 {
458 if (!array_key_exists(0, $solution_values) ||
459 !array_key_exists('value1', $solution_values[0])) {
460 return '';
461 }
462 return $solution_values[0]['value1'];
463 }

◆ toLog()

assNumeric::toLog ( AdditionalInformationGenerator  $additional_info)

MUST return an array of the question settings that can be stored in the log.

Language variables must be generated through the corresponding functions in the AdditionalInformationGenerator. If an array is returned it will be rendered into a line per array entry in the format "key: value". If the key exists as a language variable, it will be translated.

Reimplemented from assQuestion.

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

426 : array
427 {
428 return [
429 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
430 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
431 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
432 AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS => $additional_info
434 AdditionalInformationGenerator::KEY_QUESTION_MAXCHARS => $this->getMaxChars(),
435 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->getPoints(),
436 AdditionalInformationGenerator::KEY_QUESTION_LOWER_LIMIT => $this->getLowerLimit(),
437 AdditionalInformationGenerator::KEY_QUESTION_UPPER_LIMIT => $this->getUpperLimit(),
438 AdditionalInformationGenerator::KEY_FEEDBACK => [
439 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
440 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
441 ]
442 ];
443 }
getQuestionType()
Returns the question type of the question.

References ILIAS\Test\Logging\AdditionalInformationGenerator\getTrueFalseTagForBool().

+ Here is the call graph for this function:

◆ toNormalized()

assNumeric::toNormalized ( Transformations  $transformations,
array  $context = [] 
)
Parameters
array<string,mixed>$context
Returns
array<array-key, mixed>|float|bool|int|string|null

Reimplemented from assQuestion.

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

474 : array|float|bool|int|string|null
475 {
476 return [
477 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
478 'lower_limit' => $this->lower_limit,
479 'upper_limit' => $this->upper_limit,
480 'maxchars' => $this->maxchars,
481 ];
482 }

◆ validateSolutionSubmit()

assNumeric::validateSolutionSubmit ( )

Reimplemented from assQuestion.

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

203 : bool
204 {
205 if ($this->getSolutionSubmit() === null) {
206 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_no_numeric_value'), true);
207 return false;
208 }
209
210 return true;
211 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $lower_limit

assNumeric::$lower_limit
protected

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

Referenced by getLowerLimit().

◆ $maxchars

assNumeric::$maxchars = 6

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

◆ $upper_limit

assNumeric::$upper_limit
protected

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

Referenced by getUpperLimit().


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