19 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
107 public function loadFromDb($question_id):
void 111 $ilDB = $DIC[
'ilDB'];
113 $result =
$ilDB->queryF(
118 if ($result->numRows() == 1) {
120 $this->
setId($question_id);
123 $this->
setComment((
string) $data[
"description"]);
144 $result =
$ilDB->queryF(
145 "SELECT * FROM qpl_num_range WHERE question_fi = %s ORDER BY aorder ASC",
150 if ($result->numRows() > 0) {
159 parent::loadFromDb($question_id);
175 if ($this->
id <= 0) {
180 $this_id = $this->
getId();
185 $original_id = $this->questioninfo->getOriginalId($this->
id);
188 if ((
int) $testObjId > 0) {
189 $clone->setObjId($testObjId);
210 $clone->copyPageOfQuestion($this_id);
212 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
214 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
229 if ($this->
id <= 0) {
236 $original_id = $this->questioninfo->getOriginalId($this->
id);
238 $source_questionpool_id = $this->
getObjId();
239 $clone->setObjId($target_questionpool_id);
250 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
257 if ($this->
getId() <= 0) {
258 throw new RuntimeException(
'The question has not been saved. It cannot be duplicated');
262 $sourceParentId = $this->
getObjId();
268 $clone->setObjId($targetParentId);
270 if ($targetQuestionTitle) {
271 $clone->setTitle($targetQuestionTitle);
276 $clone->copyPageOfQuestion($sourceQuestionId);
278 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
280 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
297 $a_limit = str_replace(
',',
'.', $a_limit);
298 $this->lower_limit = $a_limit;
303 $a_limit = str_replace(
',',
'.', $a_limit);
304 $this->upper_limit = $a_limit;
341 public function calculateReachedPoints($active_id, $pass = null, $authorizedSolution =
true, $returndetails =
false):
float 343 if ($returndetails) {
344 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
349 $ilDB = $DIC[
'ilDB'];
351 $found_values = array();
352 if (is_null($pass)) {
358 if (is_array(
$data) && array_key_exists(
'value1',
$data)) {
359 $enteredvalue =
$data[
"value1"];
363 if ($this->
contains($enteredvalue)) {
383 $eval->suppress_errors =
true;
384 $result = $eval->e($value);
385 if (($result ===
false) || ($result ===
true)) {
389 if (($result >= $eval->e($this->getLowerLimit())) && ($result <= $eval->e($this->
getUpperLimit()))) {
397 if (is_numeric($submittedValue)) {
401 if (preg_match(
'/^[-+]{0,1}\d+\/\d+$/', $submittedValue)) {
411 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"err_no_numeric_value"),
true);
420 return trim(str_replace(
",",
".", $_POST[
"numeric_result"]));
426 $math->suppress_errors =
true;
427 $result = $math->evaluate($numeric_solution);
430 ($result ===
false || $result ===
true) && strlen($numeric_solution) > 0
442 public function saveWorkingData($active_id, $pass = null, $authorized =
true):
bool 446 $ilDB = $DIC[
'ilDB'];
448 if (is_null($pass)) {
458 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $numeric_result,
$ilDB, $active_id, $pass, $authorized) {
462 if (
$ilDB->numRows($result) != 0) {
463 $row =
$ilDB->fetchAssoc($result);
464 $update = $row[
"solution_id"];
468 if (strlen($numeric_result)) {
475 if (strlen($numeric_result)) {
482 if ($entered_values) {
487 "log_user_entered_values",
499 "log_user_not_entered_values",
521 $ilDB = $DIC[
'ilDB'];
527 array( $this->
getId() )
532 ) .
" (question_fi, maxnumofchars) VALUES (%s, %s)",
533 array(
"integer",
"integer" ),
545 $ilDB = $DIC[
'ilDB'];
549 "DELETE FROM qpl_num_range WHERE question_fi = %s",
551 array( $this->
getId() )
554 $next_id =
$ilDB->nextId(
'qpl_num_range');
556 "INSERT INTO qpl_num_range (range_id, question_fi, lowerlimit, upperlimit, points, aorder, tstamp) 557 VALUES (%s, %s, %s, %s, %s, %s, %s)",
558 array(
'integer',
'integer',
'text',
'text',
'float',
'integer',
'integer' ),
601 return "qpl_qst_numeric";
610 return parent::getRTETextWithMediaObjects();
618 parent::setExportDetailsXLSX($worksheet, $startrow, $col, $active_id, $pass);
623 $worksheet->
setCell($startrow + $i, $col, $this->
lng->txt(
"result"));
627 if (array_key_exists(0, $solutions) &&
628 array_key_exists(
'value1', $solutions[0]) &&
629 strlen($solutions[0][
"value1"])) {
630 $worksheet->
setCell($startrow + $i, $col + 2, $solutions[0][
"value1"]);
634 return $startrow + $i + 1;
675 $ilDB = $DIC[
'ilDB'];
682 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
683 array(
"integer",
"integer",
"integer",
"integer"),
684 array($active_id, $pass, $this->
getId(), $maxStep)
688 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
689 array(
"integer",
"integer",
"integer"),
690 array($active_id, $pass, $this->
getId())
695 $result->addKeyValue(1, $row[
"value1"]);
701 $result->setReachedPercentage((
$points / $max_points) * 100);
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...
loadFromDb(int $question_id)
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
setNrOfTries(int $a_nr_of_tries)
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
static getInstance($identifier)
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assNumeric constructor
getExpressionTypes()
Get all available expression types for a specific question.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
getMaxChars()
Returns the maximum number of characters for the numeric input field.
Abstract basic class which is to be extended by the concrete assessment question type classes...
saveWorkingData(int $active_id, int $pass, bool $authorized=true)
Saves the learners input of the question to the database.
getColumnCoord(int $a_col)
Get column "name" from number.
ensureNonNegativePoints($points)
calculateReachedPointsFromPreviewSession(ilAssQuestionPreviewSession $previewSession)
getParticipantsSolution()
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
getQuestionType()
Returns the question type of the question.
setComment(string $comment="")
isValidNumericSubmitValue($submittedValue)
float $points
The maximum available points for the question.
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
Base Exception for all Exceptions relating to Modules/Test.
setMaxChars($maxchars)
Sets the maximum number of characters for the numeric input field.
updateCurrentSolution(int $solutionId, $value1, $value2, bool $authorized=true)
setParticipantsSolution($participantSolution)
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
setExportDetailsXLSX(ilAssExcelFormatHelper $worksheet, int $startrow, int $col, int $active_id, int $pass)
{}
setBold(string $a_coords)
Set cell(s) to bold.
static _enabledAssessmentLogging()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static logAction(string $logtext, int $active_id, int $question_id)
const NumericResultExpression
removeSolutionRecordById(int $solutionId)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
duplicate(bool $for_test=true, string $title="", string $author="", int $owner=-1, $testObjId=null)
Duplicates an assNumericQuestion.
saveToDb($original_id="")
Saves a assNumeric object to a database.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
string $question
The question text.
getOperators($expression)
Get all available operations for a specific question.
static getOperatorsByExpression($expression)
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
copyObject($target_questionpool_id, $title="")
Copies an assNumeric object.
isValidSolutionSubmit($numeric_solution)
saveQuestionDataToDb(int $original_id=-1)
getSolutionMaxPass(int $active_id)
isComplete()
Returns true, if a numeric question is complete for use.
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...
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
setOriginalId(?int $original_id)
setTitle(string $title="")
setLifecycle(ilAssQuestionLifecycle $lifecycle)
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
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.
setQuestion(string $question="")
const EmptyAnswerExpression