19require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
107 public function loadFromDb($question_id): void
113 $result =
$ilDB->queryF(
118 if ($result->numRows() == 1) {
120 $this->
setId($question_id);
129 require_once
'./Services/RTE/classes/class.ilRTE.php';
145 $result =
$ilDB->queryF(
146 "SELECT * FROM qpl_num_range WHERE question_fi = %s ORDER BY aorder ASC",
151 require_once
'./Modules/TestQuestionPool/classes/class.assNumericRange.php';
152 if ($result->numRows() > 0) {
161 parent::loadFromDb($question_id);
177 if ($this->
id <= 0) {
182 $this_id = $this->
getId();
186 require_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
190 if ((
int) $testObjId > 0) {
191 $clone->setObjId($testObjId);
212 $clone->copyPageOfQuestion($this_id);
214 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
216 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
231 if ($this->
id <= 0) {
237 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
240 $source_questionpool_id = $this->
getObjId();
241 $clone->setObjId($target_questionpool_id);
252 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
259 if ($this->
getId() <= 0) {
260 throw new RuntimeException(
'The question has not been saved. It cannot be duplicated');
263 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
266 $sourceParentId = $this->
getObjId();
272 $clone->setObjId($targetParentId);
274 if ($targetQuestionTitle) {
275 $clone->setTitle($targetQuestionTitle);
280 $clone->copyPageOfQuestion($sourceQuestionId);
282 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
284 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
301 $a_limit = str_replace(
',',
'.', $a_limit);
302 $this->lower_limit = $a_limit;
307 $a_limit = str_replace(
',',
'.', $a_limit);
308 $this->upper_limit = $a_limit;
345 public function calculateReachedPoints($active_id, $pass =
null, $authorizedSolution =
true, $returndetails =
false)
347 if ($returndetails) {
348 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
355 $found_values = array();
356 if (is_null($pass)) {
362 if (is_array(
$data) && array_key_exists(
'value1',
$data)) {
363 $enteredvalue =
$data[
"value1"];
367 if ($this->
contains($enteredvalue)) {
386 require_once
'./Services/Math/classes/class.EvalMath.php';
388 $eval->suppress_errors =
true;
389 $result = $eval->e($value);
390 if (($result ===
false) || ($result ===
true)) {
394 if (($result >= $eval->e($this->getLowerLimit())) && ($result <= $eval->e($this->
getUpperLimit()))) {
402 if (is_numeric($submittedValue)) {
406 if (preg_match(
'/^[-+]{0,1}\d+\/\d+$/', $submittedValue)) {
416 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"err_no_numeric_value"),
true);
425 return trim(str_replace(
",",
".", $_POST[
"numeric_result"]));
430 require_once
'./Services/Math/classes/class.EvalMath.php';
432 $math->suppress_errors =
true;
433 $result = $math->evaluate($numeric_solution);
436 ($result ===
false || $result ===
true) && strlen($numeric_solution) > 0
448 public function saveWorkingData($active_id, $pass =
null, $authorized =
true): bool
454 if (is_null($pass)) {
455 require_once
'./Modules/Test/classes/class.ilObjTest.php';
465 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $numeric_result,
$ilDB, $active_id, $pass, $authorized) {
469 if (
$ilDB->numRows($result) != 0) {
470 $row =
$ilDB->fetchAssoc($result);
475 if (strlen($numeric_result)) {
482 if (strlen($numeric_result)) {
489 if ($entered_values) {
490 require_once
'./Modules/Test/classes/class.ilObjAssessmentFolder.php';
495 "log_user_entered_values",
503 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
508 "log_user_not_entered_values",
536 array( $this->
getId() )
541 ) .
" (question_fi, maxnumofchars) VALUES (%s, %s)",
542 array(
"integer",
"integer" ),
558 "DELETE FROM qpl_num_range WHERE question_fi = %s",
560 array( $this->
getId() )
563 $next_id =
$ilDB->nextId(
'qpl_num_range');
565 "INSERT INTO qpl_num_range (range_id, question_fi, lowerlimit, upperlimit, points, aorder, tstamp)
566 VALUES (%s, %s, %s, %s, %s, %s, %s)",
567 array(
'integer',
'integer',
'text',
'text',
'float',
'integer',
'integer' ),
610 return "qpl_qst_numeric";
619 return parent::getRTETextWithMediaObjects();
627 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
632 $worksheet->
setCell($startrow +
$i, 0, $this->
lng->txt(
"result"));
636 if (array_key_exists(0, $solutions) &&
637 array_key_exists(
'value1', $solutions[0]) &&
638 strlen($solutions[0][
"value1"])) {
639 $worksheet->
setCell($startrow +
$i, 2, $solutions[0][
"value1"]);
643 return $startrow +
$i + 1;
689 if ($maxStep !==
null) {
691 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
692 array(
"integer",
"integer",
"integer",
"integer"),
693 array($active_id, $pass, $this->
getId(), $maxStep)
697 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
698 array(
"integer",
"integer",
"integer"),
699 array($active_id, $pass, $this->
getId())
704 $result->addKeyValue(1, $row[
"value1"]);
710 $result->setReachedPercentage((
$points / $max_points) * 100);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getExpressionTypes()
Get all available expression types for a specific question.
copyObject($target_questionpool_id, $title="")
Copies an assNumeric object.
contains($value)
Checks for a given value within the range.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
setMaxChars($maxchars)
Sets the maximum number of characters for the numeric input field.
isValidNumericSubmitValue($submittedValue)
saveToDb($original_id="")
Saves a assNumeric object to a database.
getQuestionType()
Returns the question type of the question.
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assNumeric constructor
savePreviewData(ilAssQuestionPreviewSession $previewSession)
duplicate(bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
Duplicates an assNumericQuestion.
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 ...
getOperators($expression)
Get all available operations for a specific question.
isValidSolutionSubmit($numeric_solution)
setExportDetailsXLS(ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
{}
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
isComplete()
Returns true, if a numeric question is complete for use.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
Abstract basic class which is to be extended by the concrete assessment question type classes.
loadFromDb(int $question_id)
float $points
The maximum available points for the question.
setOriginalId(?int $original_id)
string $question
The question text.
static logAction(string $logtext, int $active_id, int $question_id)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
updateCurrentSolution(int $solutionId, $value1, $value2, bool $authorized=true)
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
setQuestion(string $question="")
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
static _getOriginalId(int $question_id)
saveQuestionDataToDb(int $original_id=-1)
setAuthor(string $author="")
setComment(string $comment="")
removeSolutionRecordById(int $solutionId)
getSolutionMaxPass(int $active_id)
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
saveWorkingData(int $active_id, int $pass, bool $authorized=true)
Saves the learners input of the question to the database.
setTitle(string $title="")
lookupMaxStep(int $active_id, int $pass)
ensureNonNegativePoints($points)
static getDraftInstance()
static getInstance($identifier)
getParticipantsSolution()
setParticipantsSolution($participantSolution)
setBold(string $a_coords)
Set cell(s) to bold.
getColumnCoord(int $a_col)
Get column "name" from number.
static _enabledAssessmentLogging()
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static getOperatorsByExpression($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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const PercentageResultExpression
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
const NumericResultExpression
const EmptyAnswerExpression
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc