67 $this->
object->loadFromDb(
$id);
73 $this->
object->setContentType($this->object::OQ_CT_PICTURES);
74 $this->
object->saveToDb();
76 $values = $this->request_data_collector->getParsedBody();
77 $values[
'thumb_geometry'] = $this->
object->getThumbSize();
83 $ordering_element_list = $this->
object->getOrderingElementList();
84 foreach ($ordering_element_list as $element) {
85 $this->
object->dropImageFile($element->getContent());
88 $this->
object->setContentType($this->object::OQ_CT_TERMS);
89 $this->
object->saveToDb();
98 $ordering_element_list = $this->
object->getOrderingElementList();
99 $ordering_element_list->resetElements();
102 $form->setValuesByArray($values);
111 $form->setValuesByPost();
112 if ($form->checkInput()) {
113 $post = $this->request_data_collector->raw(self::F_NESTED_ORDER);
114 $list = $this->
object->getOrderingElementList();
117 foreach (array_keys(
$post[self::F_NESTED_ORDER_ORDER]) as $idx => $identifier) {
118 $element_identifier = str_replace(self::F_NESTED_IDENTIFIER_PREFIX,
'', $identifier);
119 $element = $list->getElementByRandomIdentifier($element_identifier);
121 $ordered[] = $element
123 ->withIndentation(
$post[self::F_NESTED_ORDER_INDENT][$identifier]);
126 $list = $list->withElements($ordered);
127 $this->
object->setOrderingElementList($list);
128 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
130 $this->tpl->setOnScreenMessage(
'error', $this->
lng->txt(
'form_input_not_valid'),
true);
145 $form->setValuesByPost();
150 foreach ($submitted_list->getElements() as $submitted_element) {
151 if ($submitted_element->isImageUploadAvailable()) {
152 $filename = $this->
object->storeImageFile(
153 $submitted_element->getUploadImageFile(),
154 $submitted_element->getUploadImageName()
158 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'file_no_valid_file_type'));
160 $submitted_element = $submitted_element->withContent(
$filename);
164 if ($submitted_element->isImageRemovalRequest()) {
165 $this->
object->dropImageFile($submitted_element->getContent());
166 $submitted_element = $submitted_element->withContent(
'');
169 $elements[] = $submitted_element;
172 $list = $this->
object->getOrderingElementList()->withElements($elements);
173 $this->
object->setOrderingElementList($list);
183 $thumb_size = $this->request_data_collector->int(
'thumb_geometry');
184 if ($thumb_size !== 0
185 && $thumb_size !== $this->
object->getThumbSize()) {
186 $this->
object->setThumbSize($thumb_size);
190 $this->
object->setPoints($this->request_data_collector->float(
'points'));
192 $use_nested = $this->request_data_collector->int(self::F_USE_NESTED) === 1;
193 $this->
object->setNestingType($use_nested);
200 ->getElementList($this->
object->getId());
202 $use_nested = $this->request_data_collector->int(self::F_USE_NESTED) === 1;
205 $existing_list = $this->
object->getOrderingElementList();
209 foreach ($list->getElements() as $element) {
210 $element = $list->ensureValidIdentifiers($element);
212 if ($existing = $existing_list->getElementByRandomIdentifier($element->getRandomIdentifier())) {
213 if ($existing->getIndentation() == $parent_indent + 1) {
215 ->withIndentation($existing->getIndentation());
218 $parent_indent = $element->getIndentation();
221 $list = $list->withElements($nu);
229 $element_list = $this->
object->getOrderingElementList();
231 foreach ($element_list->getElements() as $element) {
232 if ($element->getContent() ===
'') {
235 $filename = $this->
object->updateImageFile(
236 $element->getContent()
239 $elements[] = $element->withContent(
$filename);
242 $list = $this->
object->getOrderingElementList()->withElements($elements);
243 $this->
object->setOrderingElementList($list);
248 $this->
object->setOrderingElementList(
256 $header->setTitle($this->
lng->txt(
'oq_header_ordering_elements'));
259 $orderingElementInput = $this->
object->buildOrderingElementInputGui();
261 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
263 $list = $this->
object->getOrderingElementList();
264 $orderingElementInput->setElementList($list);
265 $form->
addItem($orderingElementInput);
272 if ($this->
object->isImageOrderingType()) {
275 $thumb_size->setRequired(
true);
276 $thumb_size->setMaxLength(6);
277 $thumb_size->setMinValue($this->
object->getMinimumThumbSize());
278 $thumb_size->setMaxValue($this->
object->getMaximumThumbSize());
279 $thumb_size->setSize(6);
280 $thumb_size->setInfo($this->
lng->txt(
'thumb_size_info'));
287 $points->setValue($this->
object->getPoints());
288 $points->setRequired(
true);
290 $points->setMinValue(0);
291 $points->setMinvalueShouldBeGreater(
true);
296 $this->
lng->txt(
'qst_use_nested_answers'),
299 $nested_answers_options = [
300 0 => $this->
lng->txt(
'qst_nested_nested_answers_off'),
301 1 => $this->
lng->txt(
'qst_nested_nested_answers_on')
303 $nested_answers->
setOptions($nested_answers_options);
304 $nested_answers->setValue($this->
object->isOrderingTypeNested());
305 $form->
addItem($nested_answers);
314 $form->setValuesByPost();
316 if (!$form->checkInput()) {
334 self::TAB_EDIT_QUESTION,
335 $this->
lng->txt(
'edit_question'),
336 $this->
ctrl->getLinkTarget($this,
'editQuestion')
340 self::TAB_EDIT_NESTING,
341 $this->
lng->txt(
'tab_nest_answers'),
342 $this->
ctrl->getLinkTarget($this, self::CMD_EDIT_NESTING)
345 $tabs->setTabActive(
'edit_question');
346 $tabs->setSubTabActive($active);
350 bool $checkonly =
false,
351 ?
bool $is_save_cmd =
null 369 $form->setFormAction($this->
ctrl->getFormAction($this));
371 $form->setMultipart($this->
object->isImageOrderingType());
372 $form->setTableWidth(
"100%");
373 $form->setId(
"ordering");
380 $form->addSpecificOrderingQuestionCommandButtons($this->
object);
381 $form->addGenericAssessmentQuestionCommandButtons($this->
object);
389 $form->setFormAction($this->
ctrl->getFormAction($this));
391 $form->setTableWidth(
"100%");
394 $header->setTitle($this->
lng->txt(
'oq_header_ordering_elements'));
395 $form->addItem($header);
397 $orderingElementInput = $this->
object->buildNestedOrderingElementInputGui();
400 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
402 $list = $this->
object->getOrderingElementList();
403 foreach ($list->getElements() as $element) {
404 $element = $list->ensureValidIdentifiers($element);
407 $orderingElementInput->setElementList($list);
409 $form->addItem($orderingElementInput);
410 $form->addCommandButton(self::CMD_SAVE_NESTING, $this->
lng->txt(
"save"));
422 bool $graphical_output =
false,
423 bool $result_output =
false,
424 bool $show_question_only =
true,
425 bool $show_feedback =
false,
426 bool $show_correct_solution =
false,
427 bool $show_manual_scoring =
false,
428 bool $show_question_text =
true,
429 bool $show_inline_feedback =
true 431 $solution_ordering_list = $this->
object->getOrderingElementListForSolutionOutput(
432 $show_correct_solution,
437 $show_inline_feedback =
false;
439 $solution_ordering_list,
446 $show_correct_solution,
447 $show_manual_scoring,
450 $show_inline_feedback,
455 mixed $user_solutions,
458 bool $graphical_output =
false,
459 bool $result_output =
false,
460 bool $show_question_only =
true,
461 bool $show_feedback =
false,
462 bool $show_correct_solution =
false,
463 bool $show_manual_scoring =
false,
464 bool $show_question_text =
true,
465 bool $show_autosave_title =
false,
466 bool $show_inline_feedback =
false,
469 $user_solutions : $this->
object->getSolutionOrderingElementList(
470 $this->object->fetchIndexedValuesFromValuePairs($user_solutions)
472 $answers_gui = $this->
object->buildNestedOrderingElementInputGui();
474 if ($show_correct_solution) {
480 $answers_gui->setInteractionEnabled(
false);
481 $answers_gui->setElementList($solution_ordering_list);
483 if ($graphical_output) {
484 $answers_gui->setShowCorrectnessIconsEnabled(
true);
486 $answers_gui->setCorrectnessTrueElementList(
487 $solution_ordering_list->getParityTrueElementList($this->object->getOrderingElementList())
489 $solution_html = $answers_gui->getHTML();
491 $template =
new ilTemplate(
'tpl.il_as_qpl_nested_ordering_output_solution.html',
true,
true,
'components/ILIAS/TestQuestionPool');
492 $template->setVariable(
'SOLUTION_OUTPUT', $solution_html);
493 if ($show_question_text ==
true) {
494 $template->setVariable(
'QUESTIONTEXT', $this->
object->getQuestionForHTMLOutput());
496 $questionoutput = $template->get();
498 $solutiontemplate =
new ilTemplate(
'tpl.il_as_tst_solution_output.html',
true,
true,
'components/ILIAS/TestQuestionPool');
499 $solutiontemplate->setVariable(
'SOLUTION_OUTPUT', $questionoutput);
501 if ($show_feedback) {
506 $feedback .= strlen($fb) ? $fb :
'';
509 if ($feedback !==
'') {
515 $solutiontemplate->setVariable(
'ILC_FB_CSS_CLASS', $cssClass);
520 if ($show_question_only) {
521 return $solutiontemplate->get();
531 bool $show_question_only =
false,
532 bool $show_inline_feedback =
false 535 $solutionOrderingElementList = unserialize(
537 [
'allowed_classes' =>
true]
540 $solutionOrderingElementList = $this->
object->getShuffledOrderingElementList();
543 $answers = $this->
object->buildNestedOrderingElementInputGui();
544 $answers->setNestingEnabled($this->
object->isOrderingTypeNested());
547 $answers->setElementList($solutionOrderingElementList);
549 $template =
new ilTemplate(
'tpl.il_as_qpl_ordering_output.html',
true,
true,
'components/ILIAS/TestQuestionPool');
551 $template->setCurrentBlock(
'nested_ordering_output');
552 $template->setVariable(
'NESTED_ORDERING', $answers->getHTML());
553 $template->parseCurrentBlock();
554 $template->setVariable(
'QUESTIONTEXT', $this->
object->getQuestionForHTMLOutput());
556 if ($show_question_only) {
557 return $template->get();
566 bool $is_question_postponed =
false,
567 array|
bool $user_post_solutions =
false,
568 bool $show_specific_inline_feedback =
false 570 $user_post_solutions = is_array($user_post_solutions) ? $user_post_solutions : [];
572 $ordering_gui = $this->
object->buildNestedOrderingElementInputGui();
573 $ordering_gui->setNestingEnabled($this->
object->isOrderingTypeNested());
575 $solutionOrderingElementList = $this->
object->getSolutionOrderingElementListForTestOutput(
577 $user_post_solutions,
582 $template =
new ilTemplate(
'tpl.il_as_qpl_ordering_output.html',
true,
true,
'components/ILIAS/TestQuestionPool');
585 $ordering_gui->setElementList($solutionOrderingElementList);
587 $template->setCurrentBlock(
'nested_ordering_output');
588 $template->setVariable(
'NESTED_ORDERING', $ordering_gui->getHTML());
589 $template->parseCurrentBlock();
591 $template->setVariable(
'QUESTIONTEXT', $this->
object->getQuestionForHTMLOutput());
593 $pageoutput = $this->
outQuestionPage(
'', $is_question_postponed, $active_id, $template->get());
614 return $DIC[
'ilTabs'];
652 if ($this->
object->isImageOrderingType()) {
659 $content =
"<img src='{$src}' alt='{$alt}' title='{$alt}'/>";
674 foreach ($list as $elem) {
675 if ($elem->getIndentation() > $lastIndent) {
677 } elseif ($elem->getIndentation() < $lastIndent) {
678 $html .=
'</li></ul><li>';
679 } elseif (!$firstElem) {
680 $html .=
'</li><li>';
688 $lastIndent = $elem->getIndentation();
693 for ($i = $lastIndent; $i > 0; $i--) {
694 $html .=
'</ul></li>';
704 $answersByActiveAndPass = [];
706 foreach ($relevantAnswers as $row) {
707 $key = $row[
'active_fi'] .
':' . $row[
'pass'];
709 if (!isset($answersByActiveAndPass[$key])) {
710 $answersByActiveAndPass[$key] = [];
713 $answersByActiveAndPass[$key][$row[
'value1']] = $row[
'value2'];
718 foreach ($answersByActiveAndPass as $indexedSolutions) {
719 $solutionLists[] = $this->
object->getSolutionOrderingElementList($indexedSolutions);
725 foreach ($solutionLists as $orderingElementList) {
726 $hash = $orderingElementList->getHash();
728 if (!isset($answers[$hash])) {
734 'answer' => $variantHtml,
'frequency' => 0
738 $answers[$hash][
'frequency']++;
741 return array_values($answers);
750 $orderingInput->prepareReprintable($this->
object);
760 $points->setValue($this->
object->getPoints());
761 $points->setRequired(
true);
763 $points->setMinValue(0);
764 $points->setMinvalueShouldBeGreater(
true);
768 $header->setTitle($this->
lng->txt(
'oq_header_ordering_elements'));
771 $orderingElementInput = $this->
object->buildNestedOrderingElementInputGui();
773 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
775 $orderingElementInput->setElementList($this->
object->getOrderingElementList());
777 $form->
addItem($orderingElementInput);
785 $this->
object->setPoints((
float) str_replace(
',',
'.', $form->
getInput(
'points')));
789 $curElementList = $this->
object->getOrderingElementList();
792 $newElementList->setQuestionId($this->
object->getId());
794 foreach ($submittedElementList as $submittedElement) {
795 if (!$curElementList->elementExistByRandomIdentifier($submittedElement->getRandomIdentifier())) {
799 $curElement = $curElementList->getElementByRandomIdentifier($submittedElement->getRandomIdentifier());
801 $curElement->setPosition($submittedElement->getPosition());
803 if ($this->
object->isOrderingTypeNested()) {
804 $curElement->setIndentation($submittedElement->getIndentation());
807 $newElementList->addElement($curElement);
810 $this->
object->setOrderingElementList($newElementList);
isTestPresentationContext()
__construct($id=-1)
assOrderingQuestionGUI constructor
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
const F_NESTED_ORDER_ORDER
hasCorrectSolution($activeId, $passIndex)
getSpecificFeedbackOutput(array $userSolution)
prepareReprintableCorrectionsForm(ilPropertyFormGUI $form)
const IDENTIFIER_INDICATOR_PREFIX
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAnswerStatisticOrderingVariantHtml(ilAssOrderingElementList $list)
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
Adds the answer specific form parts to a question property form gui.
getPreview(bool $show_question_only=false, bool $show_inline_feedback=false)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
const F_NESTED_ORDER_INDENT
writePostData(bool $always=false)
const CMD_SWITCH_TO_PICTURESS
const CSS_CLASS_FEEDBACK_CORRECT
isInLearningModuleContext()
isRenderPurposePlayback()
populateTaxonomyFormSection(ilPropertyFormGUI $form)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setImagePathWeb($imagePathWeb)
fetchSolutionListFromSubmittedForm(ilPropertyFormGUI $form)
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writeQuestionGenericPostData()
const ORDERING_ELEMENT_FORM_FIELD_POSTVAR
isInteractivePresentation()
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from the request and applies them to the data object...
isRenderPurposeDemoplay()
const CMD_SWITCH_TO_TERMS
buildEditFormAfterTypeChange(array $values)
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
addEditSubtabs($active=self::TAB_EDIT_QUESTION)
getPresentationImageUrl()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
static getSyntaxStylePath()
const CSS_CLASS_FEEDBACK_WRONG
setImagePathFs(string $image_path_fs)
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
getSolutionOutput(int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
supportsIntermediateSolutionOutput()
setImageThumbnailPrefix($imageThumbnailPrefix)
saveTaxonomyAssignments()
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ilPlugin $plugin)
renderSolutionOutput(mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
Class for ordering questions.
isRenderPurposePrintPdf()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAnswersFrequency($relevantAnswers, $questionIndex)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAnswerStatisticOrderingElementHtml(ilAssOrderingElement $element)
const F_NESTED_IDENTIFIER_PREFIX
getTestOutput(int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object...
renderEditForm(ilPropertyFormGUI $form)
getGenericFeedbackOutput(int $active_id, ?int $pass)