19declare(strict_types=1);
71 protected int $ordering_type = self::OQ_TERMS
79 if ($elements_list === [] && $this->element_list_for_deferred_saving !==
null) {
80 $elements_list = $this->element_list_for_deferred_saving->getElements();
82 $elements = array_filter(
84 fn($element) => trim($element->getContent()) !=
''
87 $has_at_least_two_elements = count($elements) > 1;
93 && $has_at_least_two_elements;
100 if (is_null($this->oq_repository)) {
101 $this->oq_repository =
new OQRepository($this->db);
111 if ($this->element_list_for_deferred_saving !==
null) {
125 $result = $this->db->queryF(
130 if ($result->numRows() == 1) {
131 $data = $this->db->fetchAssoc($result);
132 $this->
setId($question_id);
135 $this->
setComment((
string) $data[
"description"]);
142 $this->ordering_type =
$data[
"ordering_type"] !==
null ? (
int)
$data[
"ordering_type"] : self::OQ_TERMS;
146 $this->element_height =
$data[
"element_height"] ? (
int)
$data[
'element_height'] :
null;
160 parent::loadFromDb($question_id);
167 ->withQuestionId($target->
getId());
168 $list->distributeNewRandomIdentifiers();
169 $target->setOrderingElementList($list);
176 int $source_question_id,
177 int $source_parent_id,
178 int $target_question_id,
179 int $target_parent_id
181 if (!$this->isImageOrderingType()) {
185 $image_source_path = $this->getImagePath($source_question_id, $source_parent_id);
186 $image_target_path = $this->getImagePath($target_question_id, $target_parent_id);
188 if (!file_exists($image_target_path)) {
191 $this->removeAllImageFiles($image_target_path);
193 foreach ($this->getOrderingElementList() as $element) {
200 if (!file_exists($image_source_path .
$filename)
202 $this->log->root()->warning(
'Image could not be cloned for object for question: ' . $target_question_id);
204 if (!file_exists($image_source_path . $this->getThumbPrefix() .
$filename)
205 || !copy($image_source_path . $this->getThumbPrefix() .
$filename, $image_target_path . $this->getThumbPrefix() .
$filename)) {
206 $this->log->root()->warning(
'Image thumbnails could not be cloned for object for question: ' . $target_question_id);
216 self::OQ_NESTED_PICTURES,
217 self::OQ_NESTED_TERMS
223 if (!in_array($ordering_type, $this->getValidOrderingTypes())) {
224 throw new \InvalidArgumentException(
'Must be valid ordering type.');
226 $this->ordering_type = $ordering_type;
231 return $this->ordering_type;
237 self::OQ_NESTED_TERMS,
238 self::OQ_NESTED_PICTURES
240 return in_array($this->getOrderingType(), $nested);
247 self::OQ_NESTED_PICTURES
249 return in_array($this->getOrderingType(), $with_images);
255 self::OQ_CT_PICTURES,
258 throw new \InvalidArgumentException(
"use OQ content-type", 1);
260 if ($ct == self::OQ_CT_PICTURES) {
261 if ($this->isOrderingTypeNested()) {
262 $this->setOrderingType(self::OQ_NESTED_PICTURES);
264 $this->setOrderingType(self::OQ_PICTURES);
266 $this->setThumbSize($this->getThumbSize());
268 if ($ct == self::OQ_CT_TERMS) {
269 if ($this->isOrderingTypeNested()) {
270 $this->setOrderingType(self::OQ_NESTED_TERMS);
272 $this->setOrderingType(self::OQ_TERMS);
280 if ($this->isImageOrderingType()) {
281 $this->setOrderingType(self::OQ_NESTED_PICTURES);
283 $this->setOrderingType(self::OQ_NESTED_TERMS);
286 if ($this->isImageOrderingType()) {
287 $this->setOrderingType(self::OQ_PICTURES);
289 $this->setOrderingType(self::OQ_TERMS);
296 return $this->isImageOrderingType();
300 bool $force_correct_solution,
304 if ($force_correct_solution || !$active_id || $pass_index === null) {
305 return $this->getOrderingElementList();
308 $solution_values = $this->getSolutionValues($active_id, $pass_index);
310 if (!count($solution_values)) {
311 return $this->getShuffledOrderingElementList();
314 return $this->getSolutionOrderingElementList($this->fetchIndexedValuesFromValuePairs($solution_values));
323 if ($input_gui->isPostSubmit($last_post)) {
324 return $this->fetchSolutionListFromFormSubmissionData($last_post);
326 $indexedSolutionValues = $this->fetchIndexedValuesFromValuePairs(
328 $this->getTestOutputSolutions($active_id, $pass)
332 if (count($indexedSolutionValues)) {
333 return $this->getSolutionOrderingElementList($indexedSolutionValues);
336 return $this->getShuffledOrderingElementList();
343 $value = explode(
':', $value2);
345 $random_identifier = (
int) $value[0];
346 $selected_position = $value1;
347 $selected_indentation = (
int) $value[1];
349 $element = $this->getOrderingElementList()->getElementByRandomIdentifier($random_identifier)->
getClone();
351 $element->setPosition($selected_position);
352 $element->setIndentation($selected_indentation);
361 $solution_identifier = $value1;
362 $selected_position = ($value2 - 1);
363 $selected_indentation = 0;
365 $element = $this->getOrderingElementList()->getElementBySolutionIdentifier($solution_identifier)->
getClone();
367 $element->setPosition($selected_position);
368 $element->setIndentation($selected_indentation);
379 $solution_ordering_list->setQuestionId($this->
getId());
381 foreach ($indexed_solution_values as $value1 => $value2) {
382 if ($this->isOrderingTypeNested()) {
383 $element = $this->getSolutionValuePairBrandedOrderingElementByRandomIdentifier($value1, $value2);
385 $element = $this->getSolutionValuePairBrandedOrderingElementBySolutionIdentifier($value1, $value2);
388 $solution_ordering_list->addElement($element);
391 if (!$this->getOrderingElementList()->hasSameElementSetByRandomIdentifiers($solution_ordering_list)) {
395 return $solution_ordering_list;
405 $shuffledRandomIdentifierIndex = $this->getShuffler()->transform(
406 $this->getOrderingElementList()->getRandomIdentifierIndex()
409 $shuffledElementList = $this->getOrderingElementList()->
getClone();
410 $shuffledElementList->reorderByRandomIdentifiers($shuffledRandomIdentifierIndex);
411 $shuffledElementList->resetElementsIndentations();
413 return $shuffledElementList;
421 return $this->getRepository()->getOrderingList($this->
getId());
429 if ($this->
getId() <= 0) {
430 $this->element_list_for_deferred_saving = $list;
436 foreach ($elements as
$e) {
439 $this->getRepository()->updateOrderingList(
452 if (!$this->getOrderingElementList()->elementExistByPosition($index)) {
456 return $this->getOrderingElementList()->getElementByPosition($index);
461 $this->getOrderingElementList()->removeElement(
462 $this->getOrderingElementList()->getElementByRandomIdentifier($random_identifier)
464 $this->getOrderingElementList()->saveToDb();
469 return $this->getOrderingElementList()->countElements();
475 bool $authorized_solution =
true
477 if ($pass === null) {
478 $pass = $this->getSolutionMaxPass($active_id);
481 $solution_value_pairs = $this->getSolutionValues($active_id, $pass, $authorized_solution);
483 if ($solution_value_pairs === []) {
487 $solution_ordering_element_list = $this->getSolutionOrderingElementList(
488 $this->fetchIndexedValuesFromValuePairs($solution_value_pairs)
491 return $this->calculateReachedPointsForSolution($solution_ordering_element_list);
500 $solution_ordering_element_list = unserialize(
502 [
'allowed_classes' =>
true]
505 $reached_points = $this->calculateReachedPointsForSolution($solution_ordering_element_list);
507 return $this->ensureNonNegativePoints($reached_points);
512 return $this->getPoints();
526 if (preg_match(
"/.*\\.(\\w+)$/",
$filename, $matches)) {
527 $extension = $matches[1];
529 return md5(
$filename) .
"." . $extension;
534 if ($this->getOrderingType() == self::OQ_PICTURES) {
535 if (@file_exists($this->getImagePath())) {
537 foreach ($contents as
$f) {
538 if (strcmp(
$f[
'type'],
'file') == 0) {
540 foreach ($this->getOrderingElementList() as $orderElement) {
541 if (strcmp(
$f[
'entry'], $orderElement->getContent()) == 0) {
544 if (strcmp(
$f[
'entry'], $this->getThumbPrefix() . $orderElement->getContent()) == 0) {
549 if (@file_exists($this->getImagePath() .
$f[
'entry'])) {
550 @unlink($this->getImagePath() .
$f[
'entry']);
557 if (@file_exists($this->getImagePath())) {
571 if (!strlen($imageFilename)) {
575 $result = @unlink($this->getImagePath() . $imageFilename);
576 $result = $result && @unlink($this->getImagePath() . $this->getThumbPrefix() . $imageFilename);
583 if (!strlen($imageFilename)) {
587 if (!file_exists($this->getImagePath() . $imageFilename)) {
591 return is_file($this->getImagePath() . $imageFilename);
596 if (!$this->hasOrderingTypeUploadSupport()) {
608 public function storeImageFile(
string $upload_file,
string $upload_name): ?string
610 $name_parts = explode(
".", $upload_name);
611 $suffix = strtolower(array_pop($name_parts));
612 if (!in_array($suffix, self::VALID_UPLOAD_SUFFIXES)) {
616 $this->ensureImagePathExists();
617 $target_filename = $this->buildHashedImageFilename($upload_name,
true);
618 $target_filepath = $this->getImagePath() . $target_filename;
620 $thumb_path = $this->getImagePath() . $this->getThumbPrefix() . $target_filename;
623 return $target_filename;
631 $existing_image_path = $this->getImagePath() . $existing_image_name;
632 $target_filename = $this->buildHashedImageFilename($existing_image_name,
true);
633 $target_filepath = $this->getImagePath() . $target_filename;
635 unlink($this->getImagePath() . $this->getThumbPrefix() . $existing_image_name);
636 $thumb_path = $this->getImagePath() . $this->getThumbPrefix() . $target_filename;
639 return $target_filename;
642 return $existing_image_name;
647 $submittedSolutionList = $this->getSolutionListFromPostSubmit();
649 if (!$submittedSolutionList->hasElements()) {
653 return $this->getOrderingElementList()->hasSameElementSetByRandomIdentifiers($submittedSolutionList);
659 bool $authorized =
true
661 if ($this->questionpool_request->
raw(
'test_answer_changed') === null) {
665 if (is_null($pass)) {
669 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
670 function () use ($active_id, $pass, $authorized) {
671 $this->removeCurrentSolution($active_id, $pass, $authorized);
673 foreach ($this->getSolutionListFromPostSubmit() as $orderingElement) {
674 $value1 = $orderingElement->getStorageValue1($this->getOrderingType());
675 $value2 = $orderingElement->getStorageValue2($this->getOrderingType());
677 $this->saveCurrentSolution($active_id, $pass, $value1, trim((
string) $value2), $authorized);
687 if ($this->validateSolutionSubmit()) {
695 $this->db->manipulateF(
696 "DELETE FROM " . $this->getAdditionalTableName() .
" WHERE question_fi = %s",
701 $this->db->manipulateF(
702 "INSERT INTO " . $this->getAdditionalTableName() .
" (question_fi, ordering_type, thumb_geometry, element_height)
703 VALUES (%s, %s, %s, %s)",
704 [
"integer",
"text",
"integer",
"integer"],
707 $this->ordering_type,
708 $this->getThumbSize(),
709 ($this->getElementHeight() > 20) ? $this->getElementHeight() :
null
717 return new OQRepository($this->db);
732 return "assOrderingQuestion";
743 return "qpl_qst_ordering";
754 return "qpl_a_ordering";
763 $text = parent::getRTETextWithMediaObjects();
765 foreach ($this->getOrderingElementList() as $orderingElement) {
766 $text .= $orderingElement->getContent();
778 return $this->getOrderingElementList()->getRandomIdentifierIndexedElements();
783 return $this->element_height;
788 $this->element_height = ($a_height < 20) ?
null : $a_height;
796 if ($this->isImageOrderingType()) {
797 foreach ($this->getOrderElements() as $orderingElement) {
798 if ($orderingElement->getContent() !==
'') {
799 $this->generateThumbForFile($this->getImagePath(), $orderingElement->getContent());
814 $thumbpath =
$path . $this->getThumbPrefix() . $file;
817 switch (strtoupper($path_info[
'extension'])) {
838 $result[
'id'] = $this->
getId();
839 $result[
'type'] = (string) $this->getQuestionType();
840 $result[
'title'] = $this->getTitleForHTMLOutput();
841 $result[
'question'] = $this->formatSAQuestion($this->getQuestion());
842 $result[
'nr_of_tries'] = $this->getNrOfTries();
843 $result[
'shuffle'] =
true;
844 $result[
'points'] = $this->getPoints();
845 $result[
'feedback'] = [
846 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
847 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
849 if ($this->getOrderingType() == self::OQ_PICTURES) {
850 $result[
'path'] = $this->getImagePathWeb();
855 foreach ($this->getOrderingElementList() as $orderingElement) {
856 $answers[
$counter] = $orderingElement->getContent();
859 $answers = $this->getShuffler()->transform($answers);
861 foreach ($answers as $order => $answer) {
863 "answertext" => (
string) $answer,
864 "order" => (
int) $order
867 $result[
'answers'] = $arr;
870 $result[
'mobs'] = $mobs;
872 return json_encode($result);
881 if ($this->isImageOrderingType()) {
882 return $this->buildOrderingImagesInputGui();
884 return $this->buildOrderingTextsInputGui();
895 $formField->setInteractionEnabled(
true);
896 $formField->setNestingEnabled($this->isOrderingTypeNested());
903 $formField->setEditElementOccuranceEnabled(
true);
904 $formField->setEditElementOrderEnabled(
true);
913 $formField->
setInfo($this->
lng->txt(
'ordering_answer_sequence_info'));
922 $formDataConverter = $this->buildOrderingTextsFormDataConverter();
926 self::ORDERING_ELEMENT_FORM_FIELD_POSTVAR
929 $this->initOrderingElementFormFieldLabels($orderingElementInput);
930 $orderingElementInput->setInfo($orderingElementInput->getInfo() .
' ' . $this->lng->txt(
'latex_edit_info'));
932 return $orderingElementInput;
940 $formDataConverter = $this->buildOrderingImagesFormDataConverter();
944 self::ORDERING_ELEMENT_FORM_FIELD_POSTVAR
947 $orderingElementInput->setImageUploadCommand(self::ORDERING_ELEMENT_FORM_CMD_UPLOAD_IMG);
948 $orderingElementInput->setImageRemovalCommand(self::ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG);
950 $this->initOrderingElementFormFieldLabels($orderingElementInput);
952 return $orderingElementInput;
960 $form_data_converter = $this->buildNestedOrderingFormDataConverter();
963 $form_data_converter,
964 self::ORDERING_ELEMENT_FORM_FIELD_POSTVAR
967 $ordering_element_input->setUniquePrefix($this->
getId());
968 $ordering_element_input->setOrderingType($this->getOrderingType());
969 $ordering_element_input->setElementImagePath($this->getImagePathWeb());
970 $ordering_element_input->setThumbPrefix($this->getThumbPrefix());
972 $this->initOrderingElementFormFieldLabels($ordering_element_input);
974 return $ordering_element_input;
979 $ordering_gui = $this->buildNestedOrderingElementInputGui();
981 $ordering_gui->setValueByArray($user_solution_post);
983 if (!$ordering_gui->checkInput()) {
989 $stored_element_list = $this->getOrderingElementList();
991 foreach ($ordering_gui->getElementList($this->getId()) as $submitted_element) {
992 $solution_element = $stored_element_list->getElementByRandomIdentifier(
993 $submitted_element->getRandomIdentifier()
996 if ($solution_element ===
null) {
1000 $solution_element->setPosition($submitted_element->getPosition());
1002 if ($this->isOrderingTypeNested()) {
1003 $solution_element->setIndentation($submitted_element->getIndentation());
1006 $solution_ordering_element_list->addElement($solution_element);
1009 return $solution_ordering_element_list;
1016 if ($this->postSolutionOrderingElementList ===
null) {
1017 $list = $this->fetchSolutionListFromFormSubmissionData(
1018 $this->
http->request()->getParsedBody()
1020 $this->postSolutionOrderingElementList = $list;
1023 return $this->postSolutionOrderingElementList;
1028 $reached_points = $this->getPoints();
1030 foreach ($this->getOrderingElementList() as $correct_element) {
1031 $user_element = $solution_ordering_element_list->
getElementByPosition($correct_element->getPosition());
1032 if (!$correct_element->isSameElement($user_element)) {
1033 $reached_points = 0;
1038 return $reached_points;
1062 $maxStep = $this->lookupMaxStep($active_id, $pass);
1064 $data = $this->db->queryF(
1065 "SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s ORDER BY value1 ASC ",
1066 [
"integer",
"integer",
"integer",
"integer"],
1067 [$active_id, $pass, $this->
getId(), $maxStep]
1070 $data = $this->db->queryF(
1071 "SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s ORDER BY value1 ASC ",
1072 [
"integer",
"integer",
"integer"],
1073 [$active_id, $pass, $this->
getId()]
1078 while ($row = $this->db->fetchAssoc(
$data)) {
1079 $newKey = explode(
":", $row[
"value2"]);
1081 foreach ($this->getOrderingElementList() as $answer) {
1083 if (!$this->isOrderingTypeNested()) {
1084 if ($answer->getSolutionIdentifier() == $row[
"value1"]) {
1085 $elements[$row[
"value2"]] = $answer->getSolutionIdentifier() + 1;
1089 if ($answer->getRandomIdentifier() == $newKey[0]) {
1090 $elements[$row[
"value1"]] = $answer->getSolutionIdentifier() + 1;
1099 foreach (array_values($elements) as $element) {
1100 $result->addKeyValue($element, $element);
1103 $points = $this->calculateReachedPoints($active_id, $pass);
1104 $max_points = $this->getMaximumPoints();
1106 $result->setReachedPercentage(($points / $max_points) * 100);
1120 if ($index !==
null) {
1121 return $this->getOrderingElementList()->getElementByPosition($index);
1124 return $this->getOrderingElementList()->getElements();
1137 return parent::buildTestPresentationConfig()
1140 ->setUseUnchangedAnswerLabel($this->
lng->txt(
'tst_unchanged_order_is_correct'));
1146 if (!file_exists($this->getImagePath())) {
1156 $solution_submit = [];
1158 if (isset($form_submission_data_structure[
'orderresult'])) {
1159 $orderresult = $form_submission_data_structure[
'orderresult'];
1161 if (strlen($orderresult)) {
1162 $orderarray = explode(
":", $orderresult);
1164 foreach ($orderarray as $index) {
1166 if (preg_match(
"/id_(\\d+)/", $index, $idmatch)) {
1167 $randomid = $idmatch[1];
1168 foreach ($this->getOrderingElementList() as $answeridx => $answer) {
1169 if ($answer->getRandomIdentifier() == $randomid) {
1170 $solution_submit[$answeridx] = $ordervalue;
1177 } elseif ($this->getOrderingType() == self::OQ_NESTED_TERMS || $this->getOrderingType() == self::OQ_NESTED_PICTURES) {
1179 foreach ($form_submission_data_structure[
'content'] as $randomId => $content) {
1180 $indentation = $form_submission_data_structure[
'indentation'];
1183 $value2 = implode(
':', [$randomId, $indentation]);
1185 $solution_submit[$value1] = $value2;
1188 foreach ($form_submission_data_structure as $key => $value) {
1190 if (preg_match(
"/^order_(\d+)/", $key, $matches)) {
1191 if (!(preg_match(
"/initial_value_\d+/", $value))) {
1192 if (strlen($value)) {
1193 foreach ($this->getOrderingElementList() as $answeridx => $answer) {
1194 if ($answer->getRandomIdentifier() == $matches[1]) {
1195 $solution_submit[$answeridx] = $value;
1204 return $solution_submit;
1213 $converter->setPostVar(self::ORDERING_ELEMENT_FORM_FIELD_POSTVAR);
1223 $formDataConverter = $this->buildOrderingElementFormDataConverter();
1226 $formDataConverter->setImageRemovalCommand(self::ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG);
1227 $formDataConverter->setImageUrlPath($this->getImagePathWeb());
1228 $formDataConverter->setImageFsPath($this->getImagePath());
1230 if ($this->getThumbPrefix()) {
1231 $formDataConverter->setThumbnailPrefix($this->getThumbPrefix());
1233 return $formDataConverter;
1241 $form_data_converter = $this->buildOrderingElementFormDataConverter();
1243 return $form_data_converter;
1251 $form_data_converter = $this->buildOrderingElementFormDataConverter();
1254 if ($this->getOrderingType() === self::OQ_NESTED_PICTURES) {
1255 $form_data_converter->setImageRemovalCommand(self::ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG);
1256 $form_data_converter->setImageUrlPath($this->getImagePathWeb());
1257 $form_data_converter->setThumbnailPrefix($this->getThumbPrefix());
1260 return $form_data_converter;
1266 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
1267 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
1268 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
1269 AdditionalInformationGenerator::KEY_QUESTION_ORDERING_NESTING_TYPE => array_reduce(
1270 $this->getOrderingTypeLangVars($this->getOrderingType()),
1271 static fn(
string $string,
string $lang_var) => $string . $additional_info->
getTagForLangVar($lang_var),
1274 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->getPoints(),
1275 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION => $this->getSolutionOutputForLog(),
1276 AdditionalInformationGenerator::KEY_FEEDBACK => [
1277 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
1278 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
1285 switch ($ordering_type) {
1286 case self::OQ_PICTURES:
1287 return [
'qst_nested_nested_answers_off',
'oq_btn_use_order_pictures'];
1288 case self::OQ_TERMS:
1289 return [
'qst_nested_nested_answers_off',
'oq_btn_use_order_terms'];
1290 case self::OQ_NESTED_PICTURES:
1291 return [
'qst_nested_nested_answers_on',
'oq_btn_use_order_pictures'];
1292 case self::OQ_NESTED_TERMS:
1293 return [
'qst_nested_nested_answers_on',
'oq_btn_use_order_terms'];
1301 $solution_ordering_list = $this->getOrderingElementList();
1303 $answers_gui = $this->buildNestedOrderingElementInputGui();
1305 $answers_gui->setInteractionEnabled(
false);
1306 $answers_gui->setElementList($solution_ordering_list);
1308 return $answers_gui->getHTML();
1313 array $solution_values
1315 if ($solution_values === []) {
1318 return $this->getElementArrayWithIdentationsForTextOutput(
1319 $this->getSolutionOrderingElementList(
1320 $this->fetchIndexedValuesFromValuePairs($solution_values)
1327 if ($solution_values === []) {
1330 return $this->getElementArrayWithIdentationsForTextOutput(
1331 $this->getSolutionOrderingElementList(
1332 $this->fetchIndexedValuesFromValuePairs($solution_values)
1339 return $this->getElementArrayWithIdentationsForTextOutput(
1340 $this->getOrderingElementList()->getElements()
1354 =>
$a->getPosition() -
$b->getPosition()
1361 $indentation .=
' |';
repository for assOrderingQuestion (the answer elements within, at least...)
Class for ordering questions.
getOrderElements()
Returns the answers array.
const ORDERING_ELEMENT_FORM_CMD_UPLOAD_IMG
buildOrderingImagesFormDataConverter()
const ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG
saveWorkingData(int $active_id, ?int $pass=null, bool $authorized=true)
getShuffledOrderingElementList()
calculateReachedPointsFromPreviewSession(ilAssQuestionPreviewSession $preview_session)
fetchSolutionSubmit(array $form_submission_data_structure)
getExpressionTypes()
Get all available expression types for a specific question.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveToDb(?int $original_id=null)
getQuestionType()
Returns the question type of the question.
getOrderingElementListForSolutionOutput(bool $force_correct_solution, int $active_id, ?int $pass_index)
__construct(string $title="", string $comment="", string $author="", int $owner=-1, string $question="", protected int $ordering_type=self::OQ_TERMS)
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
initOrderingElementAuthoringProperties(ilFormPropertyGUI $formField)
const VALID_UPLOAD_SUFFIXES
getAnswerTableName()
Returns the name of the answer table in the database.
fetchSolutionListFromFormSubmissionData(array $user_solution_post)
getOperators(string $expression)
Get all available operations for a specific question.
hasOrderingTypeUploadSupport()
buildNestedOrderingElementInputGui()
getSolutionValuePairBrandedOrderingElementByRandomIdentifier(int $value1, string $value2)
toJSON()
Returns a JSON representation of the question.
setOrderingType(int $ordering_type=self::OQ_TERMS)
dropImageFile($imageFilename)
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.
getSolutionOrderingElementList(array $indexed_solution_values)
setNestingType(bool $nesting)
isImageReplaced(ilAssOrderingElement $newElement, ilAssOrderingElement $oldElement)
solutionValuesToText(array $solution_values)
MUST convert the given solution values into text.
getSolutionOrderingElementListForTestOutput(ilAssNestedOrderingElementsInputGUI $input_gui, array $last_post, int $active_id, int $pass)
buildTestPresentationConfig()
Get the test question configuration.
buildNestedOrderingFormDataConverter()
const ORDERING_ELEMENT_FORM_FIELD_POSTVAR
buildOrderingTextsInputGui()
cloneImages(int $source_question_id, int $source_parent_id, int $target_question_id, int $target_parent_id)
OQRepository $oq_repository
savePreviewData(ilAssQuestionPreviewSession $previewSession)
ilAssOrderingElementList $element_list_for_deferred_saving
const HAS_SPECIFIC_FEEDBACK
storeImageFile(string $upload_file, string $upload_name)
toLog(AdditionalInformationGenerator $additional_info)
MUST return an array of the question settings that can be stored in the log.
getUserQuestionResult(int $active_id, int $pass)
Get the user solution for a question by active_id and the test pass.
initOrderingElementFormFieldLabels(ilFormPropertyGUI $formField)
getCorrectSolutionForTextOutput(int $active_id, int $pass)
getElementArrayWithIdentationsForTextOutput(array $elements)
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
getAdditionalTableName()
Returns the name of the additional question data table in the database.
isImageFileStored($imageFilename)
getSolutionValuePairBrandedOrderingElementBySolutionIdentifier(int $value1, string $value2)
cloneQuestionTypeSpecificProperties(\assQuestion $target)
getSolutionListFromPostSubmit()
buildOrderingTextsFormDataConverter()
buildOrderingElementFormDataConverter()
loadFromDb($question_id)
Loads a assOrderingQuestion object from a database.
getEncryptedFilename($filename)
setOrderingElementList(ilAssOrderingElementList $list)
getSolutionOutputForLog()
calculateReachedPointsForSolution(ilAssOrderingElementList $solution_ordering_element_list)
deleteAnswer(int $random_identifier)
getOrderingTypeLangVars(int $ordering_type)
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
buildOrderingImagesInputGui()
setElementHeight(?int $a_height)
buildOrderingElementInputGui()
generateThumbForFile($path, $file)
updateImageFile(string $existing_image_name)
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
getAnswer(int $index=0)
Returns the ordering element from the given position.
setOriginalId(?int $original_id)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
saveToDb(?int $original_id=null)
setQuestion(string $question="")
setAuthor(string $author="")
setThumbSize(int $a_size)
setComment(string $comment="")
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
saveQuestionDataToDb(?int $original_id=null)
getElementByPosition(int $position)
static buildInstance(int $question_id, array $elements=[])
withQuestionId(int $question_id)
withElements(array $elements)
ensureValidIdentifiers(ilAssOrderingElement $element)
static getDraftInstance()
static getInstance($identifier)
getParticipantsSolution()
setParticipantsSolution($participantSolution)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory
static rename(string $a_source, string $a_target)
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
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 convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")
Base Exception for all Exceptions relating to Modules/Test.
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 NumericResultExpression
const EmptyAnswerExpression
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...
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
if(!file_exists('../ilias.ini.php'))