19require_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)) {
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__);
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);
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) {
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());
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);
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'));
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...
setSeparator($a_value)
Set order text separator.
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
copyObject($target_questionpool_id, $title="")
Copies an assOrderingHorizontal object.
splitAndTrimOrderElementText(string $in_string, string $separator)
Splits the answer string either by space(s) or the separator (eg.
isComplete()
Returns true, if a single choice question is complete for use.
saveToDb($original_id="")
Saves a assOrderingHorizontal object to a database.
getOrderText()
Get order text.
setOrderText($a_value)
Set order text.
setTextSize($a_value)
Set text size.
getOperators($expression)
Get all available operations for a specific question.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getTextSize()
Get text size.
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.
setExportDetailsXLS(ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
{}
calculateReachedPointsForSolution($value)
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.
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...
getSeparator()
Get order text separator.
buildTestPresentationConfig()
Get the test question configuration.
getExpressionTypes()
Get all available expression types for a specific question.
deleteAnswers($question_id)
Deletes datasets from answers tables.
duplicate(bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
Duplicates an assOrderingHorizontal.
supportsJavascriptOutput()
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.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assOrderingHorizontal constructor
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
const HAS_SPECIFIC_FEEDBACK
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
getBestSolution($active_id, $pass)
Returns the best solution for a given pass of a participant.
Abstract basic class which is to be extended by the concrete assessment question type classes.
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.
setQuestion(string $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="")
getSolutionMaxPass(int $active_id)
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
lookupMaxStep(int $active_id, int $pass)
static getDraftInstance()
static getInstance($identifier)
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...
static strPos(string $a_haystack, string $a_needle, ?int $a_offset=null)
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...
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
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
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