19 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
61 $this->ordertext =
"";
71 if (strlen($this->title) and ($this->author) and ($this->question) and ($this->
getMaximumPoints() > 0)) {
112 $ilDB = $DIC[
'ilDB'];
114 $result =
$ilDB->queryF(
119 if ($result->numRows() == 1) {
121 $this->
setId($question_id);
124 $this->
setComment((
string) $data[
"description"]);
130 include_once(
"./Services/RTE/classes/class.ilRTE.php");
147 parent::loadFromDb($question_id);
155 if ($this->
id <= 0) {
160 $this_id = $this->
getId();
164 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
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');
209 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
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');
234 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
237 $sourceParentId = $this->
getObjId();
243 $clone->setObjId($targetParentId);
245 if ($targetQuestionTitle) {
246 $clone->setTitle($targetQuestionTitle);
251 $clone->copyPageOfQuestion($sourceQuestionId);
253 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
255 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
282 if ($returndetails) {
283 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
287 $ilDB = $DIC[
'ilDB'];
289 $found_values = array();
290 if (is_null($pass)) {
296 if (
$ilDB->numRows($result) > 0) {
316 include_once
"./Services/Utilities/classes/class.ilStr.php";
319 $result = preg_split(
"/\\s+/", $in_string);
321 $result = explode($separator, $in_string);
324 foreach ($result as
$key => $value) {
325 $result[
$key] = trim($value);
333 return $_POST[
"orderresult"];
347 if ($DIC->testQuestionPool()->internal()->request()->raw(
'test_answer_changed') === null) {
352 $ilDB = $DIC[
'ilDB'];
355 if (is_null($pass)) {
356 include_once
"./Modules/Test/classes/class.ilObjTest.php";
360 $entered_values =
false;
362 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $active_id, $pass, $authorized) {
367 $entered_values =
false;
368 if (strlen($solutionSubmit)) {
370 $entered_values =
true;
374 if ($entered_values) {
375 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
379 "log_user_entered_values",
381 ), $active_id, $this->
getId());
384 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
388 "log_user_not_entered_values",
390 ), $active_id, $this->
getId());
400 $ilDB = $DIC[
'ilDB'];
405 .
" WHERE question_fi = %s",
407 array( $this->
getId() )
412 .
" (question_fi, ordertext, textsize) VALUES (%s, %s, %s)",
413 array(
"integer",
"text",
"float" ),
429 return "assOrderingHorizontal";
439 return "qpl_qst_horder";
467 $text = parent::getRTETextWithMediaObjects();
476 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
480 if (array_key_exists(0, $solutions)) {
481 $solutionvalue = str_replace(
"{::}",
" ", $solutions[0][
"value1"]);
484 $worksheet->
setCell($startrow +
$i, 2, $solutionvalue);
487 return $startrow +
$i + 1;
502 public function fromXML($item,
int $questionpool_id, ?
int $tst_id, &$tst_object,
int &$question_counter, array $import_mapping, array &$solutionhints = []): array
504 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class.assOrderingHorizontalImport.php";
506 return $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
515 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false): string
517 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assOrderingHorizontalExport.php";
519 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
529 $user_solution = array();
530 return $user_solution;
551 $elements = $this->
getShuffler()->transform($elements);
572 $this->ordertext = $a_value;
592 if ($a_value >= 10) {
593 $this->textsize = $a_value;
614 $this->separator = $a_value;
632 include_once(
"./Services/RTE/classes/class.ilRTE.php");
634 $result[
'id'] = $this->
getId();
639 $result[
'shuffle'] =
true;
640 $result[
'points'] = (bool) $this->
getPoints();
644 $result[
'feedback'] = array(
645 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
646 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
651 array_push($arr, array(
652 "answertext" => (
string) $answer,
653 "order" => (
int) $order + 1
656 $result[
'answers'] = $arr;
659 $result[
'mobs'] =
$mobs;
661 return json_encode($result);
703 $ilDB = $DIC[
'ilDB'];
708 if ($maxStep !== null) {
710 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
711 array(
"integer",
"integer",
"integer",
"integer"),
712 array($active_id, $pass, $this->
getId(), $maxStep)
716 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
717 array(
"integer",
"integer",
"integer"),
718 array($active_id, $pass, $this->
getId())
725 $solutions = array();
727 foreach ($answer_elements as $answer) {
728 foreach ($elements as
$key => $element) {
729 if ($element == $answer) {
730 $result->addKeyValue(
$key + 1, $answer);
736 if ($this->answer_separator =
'{::}') {
739 $result->addKeyValue(null, join($glue, $answer_elements));
744 $result->setReachedPercentage((
$points / $max_points) * 100);
761 if (array_key_exists(
$index, $elements)) {
777 $value = join($this->answer_separator, $value);
795 return parent::buildTestPresentationConfig()
798 ->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.
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...
getSeparator()
Get order text separator.
copyObject($target_questionpool_id, $title="")
Copies an assOrderingHorizontal object.
static strPos(string $a_haystack, string $a_needle, ?int $a_offset=null)
static _getOriginalId(int $question_id)
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.
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="", string $owner="", $testObjId=null)
Duplicates an assOrderingHorizontal.
getTextSize()
Get text size.
toJSON()
Returns a JSON representation of the question.
setExportDetailsXLS(ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
{}
supportsJavascriptOutput()
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...
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.
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)
setTextSize($a_value)
Set text size.
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...
__construct(Container $dic, ilPlugin $plugin)
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.