19declare(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()))) {
202 if ($this->getSolutionSubmit() ===
null) {
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)) {
235 $answer = $this->getSolutionSubmit();
236 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
237 function () use ($answer, $active_id, $pass, $authorized) {
238 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized);
240 if ($this->db->numRows($result) !== 0) {
241 $row = $this->db->fetchAssoc($result);
242 $update = $row[
'solution_id'];
247 $this->removeSolutionRecordById($update);
250 if ($update !== -1) {
251 $this->updateCurrentSolution($update, $answer,
null, $authorized);
255 if ($answer !==
'') {
256 $this->saveCurrentSolution($active_id, $pass, $answer,
null, $authorized);
266 $numericSolution = $this->getSolutionSubmit();
273 $this->db->manipulateF(
274 "DELETE FROM " . $this->getAdditionalTableName() .
" WHERE question_fi = %s",
279 $this->db->manipulateF(
280 "INSERT INTO " . $this->getAdditionalTableName(
281 ) .
" (question_fi, maxnumofchars) VALUES (%s, %s)",
282 [
"integer",
"integer" ],
285 ($this->getMaxChars()) ? $this->getMaxChars() : 0
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' ],
304 [ $next_id, $this->
id, $this->getLowerLimit(), $this->getUpperLimit(
305 ), $this->getPoints(), 0, time() ]
326 return $this->maxchars;
336 $this->maxchars = $maxchars;
346 return "qpl_qst_numeric";
355 return parent::getRTETextWithMediaObjects();
378 $maxStep = $this->lookupMaxStep($active_id, $pass);
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"]);
397 $points = $this->calculateReachedPoints($active_id, $pass);
398 $max_points = $this->getMaximumPoints();
400 $result->setReachedPercentage(($points / $max_points) * 100);
408 "lower" => $this->getLowerLimit(),
409 "upper" => $this->getUpperLimit()
421 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
422 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
423 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
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()}";
Class for numeric questions.
getExpressionTypes()
Get all available expression types for a specific question.
contains($value)
Checks for a given value within the range.
solutionValuesToText(array $solution_values)
MUST convert the given solution values into text.
setMaxChars($maxchars)
Sets the maximum number of characters for the numeric input field.
getOperators(string $expression)
Get all available operations for a specific question.
toLog(AdditionalInformationGenerator $additional_info)
MUST return an array of the question settings that can be stored in the log.
getUserQuestionResult(int $active_id, int $pass)
Get the user solution for a question by active_id and the test pass.
getQuestionType()
Returns the question type of the question.
getCorrectSolutionForTextOutput(int $active_id, int $pass)
savePreviewData(ilAssQuestionPreviewSession $previewSession)
calculateReachedPointsFromPreviewSession(ilAssQuestionPreviewSession $previewSession)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getMaxChars()
Returns the maximum number of characters for the numeric input field.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
setLowerLimit(string $limit)
isValidSolutionSubmit($numeric_solution)
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
setUpperLimit(string $limit)
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
getAvailableAnswerOptions(?int $index=null)
If index is null, the function returns an array with all anwser options else it returns the specific ...
saveToDb(?int $original_id=null)
loadFromDb(int $question_id)
saveWorkingData(int $active_id, ?int $pass=null, bool $authorized=true)
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.
setOriginalId(?int $original_id)
ensureNonNegativePoints(float $points)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
setAuthor(string $author="")
setComment(string $comment="")
getSolutionMaxPass(int $active_id)
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
saveQuestionDataToDb(?int $original_id=null)
static getDraftInstance()
static getInstance($identifier)
getParticipantsSolution()
setParticipantsSolution($participantSolution)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static getOperatorsByExpression(string $expression)
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const PercentageResultExpression
const NumericResultExpression
const EmptyAnswerExpression
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))