19declare(strict_types=1);
66 $this->ordertext =
"";
76 if (strlen($this->title) and ($this->author) and ($this->question) and ($this->
getMaximumPoints() > 0)) {
111 $result = $this->db->queryF(
116 if ($result->numRows() == 1) {
117 $data = $this->db->fetchAssoc($result);
118 $this->
setId($question_id);
121 $this->
setComment((
string) $data[
"description"]);
143 parent::loadFromDb($question_id);
154 bool $authorized_solution =
true
156 if ($pass === null) {
162 if ($this->db->numRows($result) > 0) {
163 $data = $this->db->fetchAssoc($result);
175 $result = preg_split(
"/\\s+/", $in_string);
177 $result = explode($separator, $in_string);
180 foreach ($result as $key => $value) {
181 $result[$key] = trim($value);
189 return $this->questionpool_request->string(
'orderresult');
195 bool $authorized =
true
197 if ($this->questionpool_request->
raw(
'test_answer_changed') === null) {
201 if (is_null($pass)) {
205 $answer = $this->getSolutionSubmit();
206 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
207 function () use ($answer, $active_id, $pass, $authorized) {
208 $this->removeCurrentSolution($active_id, $pass, $authorized);
210 if ($answer ===
'') {
214 $this->saveCurrentSolution(
230 $this->db->manipulateF(
231 "DELETE FROM " . $this->getAdditionalTableName()
232 .
" WHERE question_fi = %s",
237 $this->db->manipulateF(
238 "INSERT INTO " . $this->getAdditionalTableName()
239 .
" (question_fi, ordertext, textsize) VALUES (%s, %s, %s)",
240 [
"integer",
"text",
"float" ],
243 $this->getOrderText(),
244 ($this->getTextSize() < 10) ?
null : (
float) $this->getTextSize()
256 return "assOrderingHorizontal";
266 return "qpl_qst_horder";
294 $text = parent::getRTETextWithMediaObjects();
306 return $user_solution;
316 return $this->splitAndTrimOrderElementText($this->getOrderText() ??
"", $this->separator);
326 $elements = $this->getOrderingElements();
327 $elements = $this->getShuffler()->transform($elements);
338 return $this->ordertext;
348 $this->ordertext = $a_value;
358 return $this->textsize;
368 if ($textsize ===
null || $textsize === 0.0) {
369 $textsize = self::DEFAULT_TEXT_SIZE;
371 $this->textsize = $textsize;
381 return $this->separator;
391 $this->separator = $a_value;
400 $result[
'id'] = $this->
getId();
401 $result[
'type'] = (string) $this->getQuestionType();
402 $result[
'title'] = $this->getTitleForHTMLOutput();
403 $result[
'question'] = $this->formatSAQuestion($this->getQuestion());
404 $result[
'nr_of_tries'] = $this->getNrOfTries();
405 $result[
'shuffle'] =
true;
406 $result[
'points'] = (bool) $this->getPoints();
407 $result[
'textsize'] = ((
int) $this->getTextSize())
408 ? (
int) $this->getTextSize()
409 : self::DEFAULT_TEXT_SIZE;
410 $result[
'feedback'] = [
411 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
412 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
416 foreach ($this->getOrderingElements() as $order => $answer) {
418 "answertext" => (
string) $answer,
419 "order" => (
int) $order + 1
422 $result[
'answers'] = $arr;
425 $result[
'mobs'] = $mobs;
427 return json_encode($result);
451 $maxStep = $this->lookupMaxStep($active_id, $pass);
453 $data = $this->db->queryF(
454 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
455 [
"integer",
"integer",
"integer",
"integer"],
456 [$active_id, $pass, $this->
getId(), $maxStep]
459 $data = $this->db->queryF(
460 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
461 [
"integer",
"integer",
"integer"],
462 [$active_id, $pass, $this->
getId()]
465 $row = $this->db->fetchAssoc(
$data);
467 $answer_elements = $this->splitAndTrimOrderElementText($row[
"value1"] ??
"", $this->answer_separator);
468 $elements = $this->getOrderingElements();
470 foreach ($answer_elements as $answer) {
471 foreach ($elements as $key => $element) {
472 if ($element == $answer) {
473 $result->addKeyValue($key + 1, $answer);
479 if ($this->answer_separator =
'{::}') {
482 $result->addKeyValue(
null, join($glue, $answer_elements));
484 $points = $this->calculateReachedPoints($active_id, $pass);
485 $max_points = $this->getMaximumPoints();
487 $result->setReachedPercentage(($points / $max_points) * 100);
497 $elements = $this->getOrderingElements();
498 if ($index !==
null) {
499 if (array_key_exists($index, $elements)) {
500 return $elements[$index];
514 $value = $this->splitAndTrimOrderElementText($value ??
"", $this->answer_separator);
515 $value = join($this->answer_separator, $value);
516 if (strcmp($value, join($this->answer_separator, $this->getOrderingElements())) == 0) {
517 $points = $this->getPoints();
527 return parent::buildTestPresentationConfig()
530 ->setUseUnchangedAnswerLabel($this->
lng->txt(
'tst_unchanged_order_is_correct'));
536 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
537 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
538 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
539 AdditionalInformationGenerator::KEY_QUESTION_TEXTSIZE => ((
int) $this->getTextSize()) ? (
int) $this->getTextSize() : 100,
540 AdditionalInformationGenerator::KEY_QUESTION_CORRECT_ANSWER_OPTIONS => $this->getOrderText(),
541 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->getPoints(),
542 AdditionalInformationGenerator::KEY_FEEDBACK => [
543 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
544 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
551 array $solution_values
553 if (!array_key_exists(0, $solution_values) ||
554 !array_key_exists(
'value1', $solution_values[0])) {
558 return str_replace(
"{::}",
" ", $solution_values[0][
'value1']);
563 if (!array_key_exists(0, $solution_values) ||
564 !array_key_exists(
'value1', $solution_values[0])) {
568 return str_replace(
"{::}",
" ", $solution_values[0][
'value1']);
573 return $this->getOrderText();
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for horizontal ordering questions.
saveWorkingData(int $active_id, ?int $pass=null, bool $authorized=true)
setSeparator($a_value)
Set order text separator.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
calculateReachedPointsForSolution(?string $value)
solutionValuesToText(array $solution_values)
MUST convert the given solution values into text.
splitAndTrimOrderElementText(string $in_string, string $separator)
isComplete()
Returns true, if a single choice question is complete for use.
getAvailableAnswerOptions(?int $index=null)
getOrderText()
Get order text.
setOrderText($a_value)
Set order text.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getTextSize()
Get text size.
setTextSize(?float $textsize)
Set text size.
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.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
toJSON()
Returns a JSON representation of the question.
getAnswerTableName()
Returns the name of the answer table in the database.
loadFromDb($question_id)
Loads a assOrderingHorizontal object from a database.
getRandomOrderingElements()
Get ordering elements from order text in random sequence.
getOrderingElements()
Get ordering elements from order text.
getQuestionType()
Returns the question type of the question.
getSeparator()
Get order text separator.
getOperators(string $expression)
Get all available operations for a specific question.
buildTestPresentationConfig()
getExpressionTypes()
Get all available expression types for a specific question.
deleteAnswers($question_id)
Deletes datasets from answers tables.
toLog(AdditionalInformationGenerator $additional_info)
MUST return an array of the question settings that can be stored in the log.
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assOrderingHorizontal constructor
getCorrectSolutionForTextOutput(int $active_id, int $pass)
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
const HAS_SPECIFIC_FEEDBACK
saveToDb(?int $original_id=null)
Saves a assOrderingHorizontal object to a database.
getUserQuestionResult(int $active_id, int $pass)
Get the user solution for a question by active_id and the test pass.
getBestSolution($active_id, $pass)
Returns the best solution for a given pass of a participant.
setOriginalId(?int $original_id)
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)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
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...
static strPos(string $a_haystack, string $a_needle, int $a_offset=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setIsUnchangedAnswerPossible($isUnchangedAnswerPossible)
Set if the saving of an unchanged answer is supported with an additional checkbox.
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 OrderingResultExpression
const StringResultExpression
const NumericResultExpression
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))