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->getNumericQuestionSolutionSubmit();
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 $pass ??=
ilObjTest::_getPass($active_id);
233 $answer = $this->getSolutionSubmit();
234 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
235 function () use ($answer, $active_id, $pass, $authorized):
void {
236 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized);
238 if ($this->db->numRows($result) !== 0) {
239 $update = $this->db->fetchAssoc($result)[
'solution_id'];
242 if ($update === -1 && $answer ===
null) {
246 if ($update === -1) {
247 $this->saveCurrentSolution(
257 if ($answer ===
null) {
258 $this->removeSolutionRecordById($update);
262 $this->updateCurrentSolution($update, $answer,
null, $authorized);
271 $numericSolution = $this->getSolutionSubmit();
278 $this->db->manipulateF(
279 "DELETE FROM " . $this->getAdditionalTableName() .
" WHERE question_fi = %s",
284 $this->db->manipulateF(
285 "INSERT INTO " . $this->getAdditionalTableName(
286 ) .
" (question_fi, maxnumofchars) VALUES (%s, %s)",
287 [
"integer",
"integer" ],
290 ($this->getMaxChars()) ? $this->getMaxChars() : 0
298 $this->db->manipulateF(
299 "DELETE FROM qpl_num_range WHERE question_fi = %s",
304 $next_id = $this->db->nextId(
'qpl_num_range');
305 $this->db->manipulateF(
306 "INSERT INTO qpl_num_range (range_id, question_fi, lowerlimit, upperlimit, points, aorder, tstamp)
307 VALUES (%s, %s, %s, %s, %s, %s, %s)",
308 [
'integer',
'integer',
'text',
'text',
'float',
'integer',
'integer' ],
309 [ $next_id, $this->
id, $this->getLowerLimit(), $this->getUpperLimit(
310 ), $this->getPoints(), 0, time() ]
331 return $this->maxchars;
341 $this->maxchars = $maxchars;
351 return "qpl_qst_numeric";
360 return parent::getRTETextWithMediaObjects();
383 $maxStep = $this->lookupMaxStep($active_id, $pass);
385 $data = $this->db->queryF(
386 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
387 [
"integer",
"integer",
"integer",
"integer"],
388 [$active_id, $pass, $this->
getId(), $maxStep]
391 $data = $this->db->queryF(
392 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
393 [
"integer",
"integer",
"integer"],
394 [$active_id, $pass, $this->
getId()]
398 while ($row = $this->db->fetchAssoc(
$data)) {
399 $result->addKeyValue(1, $row[
"value1"]);
402 $points = $this->calculateReachedPoints($active_id, $pass);
403 $max_points = $this->getMaximumPoints();
405 $result->setReachedPercentage(($points / $max_points) * 100);
413 "lower" => $this->getLowerLimit(),
414 "upper" => $this->getUpperLimit()
426 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
427 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
428 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
429 AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS => $additional_info
431 AdditionalInformationGenerator::KEY_QUESTION_MAXCHARS => $this->getMaxChars(),
432 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->getPoints(),
433 AdditionalInformationGenerator::KEY_QUESTION_LOWER_LIMIT => $this->getLowerLimit(),
434 AdditionalInformationGenerator::KEY_QUESTION_UPPER_LIMIT => $this->getUpperLimit(),
435 AdditionalInformationGenerator::KEY_FEEDBACK => [
436 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
437 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
444 array $solution_values
446 if (!array_key_exists(0, $solution_values) ||
447 !array_key_exists(
'value1', $solution_values[0])) {
450 return $solution_values[0][
'value1'];
455 if (!array_key_exists(0, $solution_values) ||
456 !array_key_exists(
'value1', $solution_values[0])) {
459 return $solution_values[0][
'value1'];
464 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 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'))