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);
155 bool $authorized_solution =
true 157 if ($pass ===
null) {
161 $data = $this->db->fetchAssoc($result);
163 if (is_array(
$data) && array_key_exists(
'value1',
$data)) {
164 $enteredvalue =
$data[
"value1"];
168 if ($this->
contains($enteredvalue)) {
188 $eval->suppress_errors =
true;
189 $result = $eval->e((
string) $value);
190 if (($result ===
false) || ($result ===
true)) {
194 if (($result >= $eval->e($this->getLowerLimit())) && ($result <= $eval->e($this->
getUpperLimit()))) {
203 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"err_no_numeric_value"),
true);
212 return $this->questionpool_request->float(
'numeric_result') ??
null;
218 $math->suppress_errors =
true;
219 $result = $math->evaluate($numeric_solution);
222 ($result ===
false || $result ===
true) && strlen($numeric_solution) > 0
229 bool $authorized =
true 231 if (is_null($pass)) {
237 function () use ($answer, $active_id, $pass, $authorized) {
240 if ($this->db->numRows($result) !== 0) {
241 $row = $this->db->fetchAssoc($result);
242 $update = $row[
'solution_id'];
250 if ($update !== -1) {
255 if ($answer !==
'') {
273 $this->db->manipulateF(
279 $this->db->manipulateF(
281 ) .
" (question_fi, maxnumofchars) VALUES (%s, %s)",
282 [
"integer",
"integer" ],
293 $this->db->manipulateF(
294 "DELETE FROM qpl_num_range WHERE question_fi = %s",
299 $next_id = $this->db->nextId(
'qpl_num_range');
300 $this->db->manipulateF(
301 "INSERT INTO qpl_num_range (range_id, question_fi, lowerlimit, upperlimit, points, aorder, tstamp) 302 VALUES (%s, %s, %s, %s, %s, %s, %s)",
303 [
'integer',
'integer',
'text',
'text',
'float',
'integer',
'integer' ],
346 return "qpl_qst_numeric";
355 return parent::getRTETextWithMediaObjects();
360 return ilOperatorsExpressionMapping::getOperatorsByExpression($expression);
380 $data = $this->db->queryF(
381 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
382 [
"integer",
"integer",
"integer",
"integer"],
383 [$active_id, $pass, $this->
getId(), $maxStep]
386 $data = $this->db->queryF(
387 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
388 [
"integer",
"integer",
"integer"],
389 [$active_id, $pass, $this->
getId()]
393 while ($row = $this->db->fetchAssoc(
$data)) {
394 $result->addKeyValue(1, $row[
"value1"]);
400 $result->setReachedPercentage((
$points / $max_points) * 100);
421 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->
getQuestionType(),
424 AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS => $additional_info
426 AdditionalInformationGenerator::KEY_QUESTION_MAXCHARS => $this->
getMaxChars(),
427 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->
getPoints(),
428 AdditionalInformationGenerator::KEY_QUESTION_LOWER_LIMIT => $this->
getLowerLimit(),
429 AdditionalInformationGenerator::KEY_QUESTION_UPPER_LIMIT => $this->
getUpperLimit(),
430 AdditionalInformationGenerator::KEY_FEEDBACK => [
431 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
432 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
439 array $solution_values
441 if (!array_key_exists(0, $solution_values) ||
442 !array_key_exists(
'value1', $solution_values[0])) {
445 return $solution_values[0][
'value1'];
450 if (!array_key_exists(0, $solution_values) ||
451 !array_key_exists(
'value1', $solution_values[0])) {
454 return $solution_values[0][
'value1'];
459 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
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)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
getAvailableAnswerOptions(?int $index=null)
If index is null, the function returns an array with all anwser options else it returns the specific ...
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...
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