19 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
62 $this->ordertext =
"";
72 if (strlen($this->title) and ($this->author) and ($this->question) and ($this->
getMaximumPoints() > 0)) {
113 $ilDB = $DIC[
'ilDB'];
115 $result =
$ilDB->queryF(
120 if ($result->numRows() == 1) {
122 $this->
setId($question_id);
125 $this->
setComment((
string) $data[
"description"]);
147 parent::loadFromDb($question_id);
155 if ($this->
id <= 0) {
160 $this_id = $this->
getId();
165 $original_id = $this->questioninfo->getOriginalId($this->
id);
168 if ((
int) $testObjId > 0) {
169 $clone->setObjId($testObjId);
190 $clone->copyPageOfQuestion($this_id);
192 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
194 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
204 if ($this->
getId() <= 0) {
205 throw new RuntimeException(
'The question has not been saved. It cannot be duplicated');
210 $original_id = $this->questioninfo->getOriginalId($this->
id);
212 $source_questionpool_id = $this->
getObjId();
213 $clone->setObjId($target_questionpool_id);
223 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
230 if ($this->
getId() <= 0) {
231 throw new RuntimeException(
'The question has not been saved. It cannot be duplicated');
235 $sourceParentId = $this->
getObjId();
241 $clone->setObjId($targetParentId);
243 if ($targetQuestionTitle) {
244 $clone->setTitle($targetQuestionTitle);
249 $clone->copyPageOfQuestion($sourceQuestionId);
251 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
253 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
278 public function calculateReachedPoints($active_id, $pass = null, $authorizedSolution =
true, $returndetails =
false): float
280 if ($returndetails) {
281 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
285 $ilDB = $DIC[
'ilDB'];
288 if (is_null($pass)) {
294 if (
$ilDB->numRows($result) > 0) {
316 $result = preg_split(
"/\\s+/", $in_string);
318 $result = explode($separator, $in_string);
321 foreach ($result as
$key => $value) {
322 $result[
$key] = trim($value);
330 return $_POST[
"orderresult"];
343 if ($this->dic->testQuestionPool()->internal()->request()->raw(
'test_answer_changed') === null) {
348 $ilDB = $DIC[
'ilDB'];
349 $ilUser = $DIC[
'ilUser'];
351 if (is_null($pass)) {
355 $entered_values =
false;
357 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $active_id, $pass, $authorized) {
362 $entered_values =
false;
363 if (strlen($solutionSubmit)) {
365 $entered_values =
true;
369 if ($entered_values) {
373 "log_user_entered_values",
375 ), $active_id, $this->
getId());
381 "log_user_not_entered_values",
383 ), $active_id, $this->
getId());
393 $ilDB = $DIC[
'ilDB'];
398 .
" WHERE question_fi = %s",
400 array( $this->
getId() )
405 .
" (question_fi, ordertext, textsize) VALUES (%s, %s, %s)",
406 array(
"integer",
"text",
"float" ),
422 return "assOrderingHorizontal";
432 return "qpl_qst_horder";
460 $text = parent::getRTETextWithMediaObjects();
469 parent::setExportDetailsXLSX($worksheet, $startrow, $col, $active_id, $pass);
473 if (array_key_exists(0, $solutions)) {
474 $solutionvalue = str_replace(
"{::}",
" ", $solutions[0][
"value1"]);
477 $worksheet->
setCell($startrow + $i, $col + 2, $solutionvalue);
480 return $startrow + $i + 1;
495 public function fromXML($item,
int $questionpool_id, ?
int $tst_id, &$tst_object,
int &$question_counter, array $import_mapping, array &$solutionhints = []): array
498 return $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
507 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false): string
510 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
521 return $user_solution;
542 $elements = $this->
getShuffler()->transform($elements);
563 $this->ordertext = $a_value;
583 if ($textsize === null || $textsize === 0.0) {
584 $textsize = self::DEFAULT_TEXT_SIZE;
606 $this->separator = $a_value;
615 $result[
'id'] = $this->
getId();
620 $result[
'shuffle'] =
true;
621 $result[
'points'] = (bool) $this->
getPoints();
624 : self::DEFAULT_TEXT_SIZE;
625 $result[
'feedback'] = array(
626 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
627 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
632 array_push($arr, array(
633 "answertext" => (
string) $answer,
634 "order" => (
int) $order + 1
637 $result[
'answers'] = $arr;
640 $result[
'mobs'] = $mobs;
642 return json_encode($result);
684 $ilDB = $DIC[
'ilDB'];
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())
708 foreach ($answer_elements as $answer) {
709 foreach ($elements as
$key => $element) {
710 if ($element == $answer) {
711 $result->addKeyValue(
$key + 1, $answer);
717 if ($this->answer_separator =
'{::}') {
720 $result->addKeyValue(null, join($glue, $answer_elements));
725 $result->setReachedPercentage((
$points / $max_points) * 100);
741 if ($index !== null) {
742 if (array_key_exists($index, $elements)) {
743 return $elements[$index];
758 $value = join($this->answer_separator, $value);
776 return parent::buildTestPresentationConfig()
779 ->setUseUnchangedAnswerLabel($this->
lng->txt(
'tst_unchanged_order_is_correct'));
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...
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
fromXML($item, int $questionpool_id, ?int $tst_id, &$tst_object, int &$question_counter, array $import_mapping, array &$solutionhints=[])
Creates a question from a QTI file.
setIsUnchangedAnswerPossible($isUnchangedAnswerPossible)
Set if the saving of an unchanged answer is supported with an additional checkbox.
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
Abstract basic class which is to be extended by the concrete assessment question type classes...
setExportDetailsXLSX(ilAssExcelFormatHelper $worksheet, int $startrow, int $col, int $active_id, int $pass)
{}
static strPos(string $a_haystack, string $a_needle, int $a_offset=0)
duplicate(bool $for_test=true, string $title="", string $author="", int $owner=-1, $testObjId=null)
Duplicates an assOrderingHorizontal.
getSeparator()
Get order text separator.
copyObject($target_questionpool_id, $title="")
Copies an assOrderingHorizontal object.
setOrderText($a_value)
Set order text.
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
const StringResultExpression
setComment(string $comment="")
getOrderText()
Get order text.
getBestSolution($active_id, $pass)
Returns the best solution for a given pass of a participant.
float $points
The maximum available points for the question.
loadFromDb($question_id)
Loads a assOrderingHorizontal object from a database.
Base Exception for all Exceptions relating to Modules/Test.
getTextSize()
Get text size.
toJSON()
Returns a JSON representation of the question.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
static _enabledAssessmentLogging()
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assOrderingHorizontal constructor
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...
isComplete()
Returns true, if a single choice question is complete for use.
static logAction(string $logtext, int $active_id, int $question_id)
const NumericResultExpression
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildTestPresentationConfig()
Get the test question configuration.
setTextSize(?float $textsize)
Set text size.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $question
The question text.
const OrderingResultExpression
splitAndTrimOrderElementText(string $in_string, string $separator)
Splits the answer string either by space(s) or the separator (eg.
calculateReachedPointsForSolution($value)
static getOperatorsByExpression($expression)
toXML($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM X...
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
getRandomOrderingElements()
Get ordering elements from order text in random sequence.
setSeparator($a_value)
Set order text separator.
deleteAnswers($question_id)
Deletes datasets from answers tables.
saveQuestionDataToDb(int $original_id=-1)
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
getSolutionMaxPass(int $active_id)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setOriginalId(?int $original_id)
getQuestionType()
Returns the question type of the question.
setTitle(string $title="")
const HAS_SPECIFIC_FEEDBACK
setLifecycle(ilAssQuestionLifecycle $lifecycle)
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
getExpressionTypes()
Get all available expression types for a specific question.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
saveToDb($original_id="")
Saves a assOrderingHorizontal object to a database.
lookupMaxStep(int $active_id, int $pass)
setAuthor(string $author="")
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
static getDraftInstance()
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
getAnswerTableName()
Returns the name of the answer table in the database.
setQuestion(string $question="")
getOrderingElements()
Get ordering elements from order text.
getOperators($expression)
Get all available operations for a specific question.