19 declare(strict_types=1);
    68         $result = $this->db->queryF(
    73         if ($result->numRows() == 1) {
    74             $data = $this->db->fetchAssoc($result);
    75             $this->
setId($question_id);
    78             $this->
setComment((
string) $data[
"description"]);
    99         $result = $this->db->queryF(
   100             "SELECT * FROM qpl_num_range WHERE question_fi = %s ORDER BY aorder ASC",
   105         if ($result->numRows() > 0) {
   107             while (
$data = $this->db->fetchAssoc($result)) {
   114         parent::loadFromDb($question_id);
   129         $this->lower_limit = str_replace(
',', 
'.', $limit);
   134         $this->upper_limit = str_replace(
',', 
'.', $limit);
   157         bool $authorized_solution = 
true   159         if ($pass === null) {
   163         $data = $this->db->fetchAssoc($result);
   165         if (is_array(
$data) && array_key_exists(
'value1', 
$data)) {
   166             $enteredvalue = 
$data[
"value1"];
   170         if ($this->
contains($enteredvalue)) {
   190         $eval->suppress_errors = 
true;
   191         $result = $eval->e((
string) $value);
   192         if (($result === 
false) || ($result === 
true)) {
   196         if (($result >= $eval->e($this->getLowerLimit())) && ($result <= $eval->e($this->
getUpperLimit()))) {
   205             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"err_no_numeric_value"), 
true);
   214         return $this->questionpool_request->float(
'numeric_result') ?? null;
   220         $math->suppress_errors = 
true;
   221         $result = $math->evaluate($numeric_solution);
   224             ($result === 
false || $result === 
true) && strlen($numeric_solution) > 0
   231         bool $authorized = 
true   233         if (is_null($pass)) {
   239             function () use ($answer, $active_id, $pass, $authorized) {
   242                 if ($this->db->numRows($result) !== 0) {
   243                     $row = $this->db->fetchAssoc($result);
   244                     $update = $row[
'solution_id'];
   252                 if ($update !== -1) {
   257                 if ($answer !== 
'') {
   275         $this->db->manipulateF(
   281         $this->db->manipulateF(
   283             ) . 
" (question_fi, maxnumofchars) VALUES (%s, %s)",
   284             [ 
"integer", 
"integer" ],
   295         $this->db->manipulateF(
   296             "DELETE FROM qpl_num_range WHERE question_fi = %s",
   301         $next_id = $this->db->nextId(
'qpl_num_range');
   302         $this->db->manipulateF(
   303             "INSERT INTO qpl_num_range (range_id, question_fi, lowerlimit, upperlimit, points, aorder, tstamp)   304                                                          VALUES (%s, %s, %s, %s, %s, %s, %s)",
   305             [ 
'integer', 
'integer', 
'text', 
'text', 
'float', 
'integer', 
'integer' ],
   348         return "qpl_qst_numeric";
   357         return parent::getRTETextWithMediaObjects();
   362         return ilOperatorsExpressionMapping::getOperatorsByExpression($expression);
   382             $data = $this->db->queryF(
   383                 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
   384                 [
"integer", 
"integer", 
"integer",
"integer"],
   385                 [$active_id, $pass, $this->
getId(), $maxStep]
   388             $data = $this->db->queryF(
   389                 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
   390                 [
"integer", 
"integer", 
"integer"],
   391                 [$active_id, $pass, $this->
getId()]
   395         while ($row = $this->db->fetchAssoc(
$data)) {
   396             $result->addKeyValue(1, $row[
"value1"]);
   402         $result->setReachedPercentage((
$points / $max_points) * 100);
   423             AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->
getQuestionType(),
   426             AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS => $additional_info
   428             AdditionalInformationGenerator::KEY_QUESTION_MAXCHARS => $this->
getMaxChars(),
   429             AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->
getPoints(),
   430             AdditionalInformationGenerator::KEY_QUESTION_LOWER_LIMIT => $this->
getLowerLimit(),
   431             AdditionalInformationGenerator::KEY_QUESTION_UPPER_LIMIT => $this->
getUpperLimit(),
   432             AdditionalInformationGenerator::KEY_FEEDBACK => [
   433                 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), 
false)),
   434                 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), 
true))
   441         array $solution_values
   443         if (!array_key_exists(0, $solution_values) ||
   444             !array_key_exists(
'value1', $solution_values[0])) {
   447         return $solution_values[0][
'value1'];
   452         if (!array_key_exists(0, $solution_values) ||
   453             !array_key_exists(
'value1', $solution_values[0])) {
   456         return $solution_values[0][
'value1'];
   461         return "{$this->getLowerLimit()}-{$this->getUpperLimit()}";
 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...
 
setNrOfTries(int $a_nr_of_tries)
 
solutionValuesToText(array $solution_values)
 
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
 
solutionValuesToLog(AdditionalInformationGenerator $additional_info, array $solution_values)
 
loadFromDb(int $question_id)
 
static getInstance($identifier)
 
getUserQuestionResult(int $active_id, int $pass)
Get the user solution for a question by active_id and the test pass. 
 
const PercentageResultExpression
 
getAvailableAnswerOptions(int $index=null)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test. 
 
getExpressionTypes()
Get all available expression types for a specific question. 
 
getMaxChars()
Returns the maximum number of characters for the numeric input field. 
 
ensureNonNegativePoints(float $points)
 
setLowerLimit(string $limit)
 
saveWorkingData(int $active_id, ?int $pass=null, bool $authorized=true)
 
calculateReachedPointsFromPreviewSession(ilAssQuestionPreviewSession $previewSession)
 
getParticipantsSolution()
 
getQuestionType()
Returns the question type of the question. 
 
setComment(string $comment="")
 
setMaxChars($maxchars)
Sets the maximum number of characters for the numeric input field. 
 
updateCurrentSolution(int $solutionId, $value1, $value2, bool $authorized=true)
 
setParticipantsSolution($participantSolution)
 
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
getCorrectSolutionForTextOutput(int $active_id, int $pass)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
const NumericResultExpression
 
removeSolutionRecordById(int $solutionId)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $preview_session, $reached_points)
 
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table. 
 
getAdditionalTableName()
Returns the name of the additional question data table in the database. 
 
saveQuestionDataToDb(?int $original_id=null)
 
saveToDb(?int $original_id=null)
 
isValidSolutionSubmit($numeric_solution)
 
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
getSolutionMaxPass(int $active_id)
 
toLog(AdditionalInformationGenerator $additional_info)
 
Class for numeric questions. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
setUpperLimit(string $limit)
 
setOriginalId(?int $original_id)
 
setTitle(string $title="")
 
setLifecycle(ilAssQuestionLifecycle $lifecycle)
 
getOperators(string $expression)
Get all available operations for a specific question. 
 
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
 
lookupMaxStep(int $active_id, int $pass)
 
setAuthor(string $author="")
 
savePreviewData(ilAssQuestionPreviewSession $previewSession)
 
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
 
static getDraftInstance()
 
contains($value)
Checks for a given value within the range. 
 
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table. 
 
setQuestion(string $question="")
 
const EmptyAnswerExpression