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()) {
274 $thumb_size->setValue($this->
object->getThumbSize());
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'));
286 $points->allowDecimals(
true);
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()) {
336 self::TAB_EDIT_QUESTION,
337 $this->
lng->txt(
'edit_question'),
338 $this->ctrl->getLinkTarget($this,
'editQuestion')
340 if ($this->
object->isOrderingTypeNested() && !$this->isInLearningModuleContext()) {
342 self::TAB_EDIT_NESTING,
343 $this->
lng->txt(
'tab_nest_answers'),
344 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_NESTING)
347 $tabs->setTabActive(
'edit_question');
348 $tabs->setSubTabActive($active);
352 bool $checkonly =
false,
353 ?
bool $is_save_cmd =
null
362 $this->renderEditForm($this->buildNestingForm());
363 $this->addEditSubtabs(self::TAB_EDIT_NESTING);
371 $form->setFormAction($this->
ctrl->getFormAction($this));
372 $form->setTitle($this->outQuestionType());
373 $form->setMultipart($this->
object->isImageOrderingType());
374 $form->setTableWidth(
"100%");
375 $form->setId(
"ordering");
377 $this->addBasicQuestionFormProperties($form);
378 $this->populateQuestionSpecificFormPart($form);
379 $this->populateAnswerSpecificFormPart($form);
380 $this->populateTaxonomyFormSection($form);
382 $form->addSpecificOrderingQuestionCommandButtons($this->
object);
383 $form->addGenericAssessmentQuestionCommandButtons($this->
object);
391 $form->setFormAction($this->
ctrl->getFormAction($this));
392 $form->setTitle($this->outQuestionType());
393 $form->setTableWidth(
"100%");
396 $header->setTitle($this->
lng->txt(
'oq_header_ordering_elements'));
397 $form->addItem($header);
399 $orderingElementInput = $this->
object->buildNestedOrderingElementInputGui();
400 $orderingElementInput->setStylingDisabled($this->isRenderPurposePrintPdf());
402 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
404 $list = $this->
object->getOrderingElementList();
405 foreach ($list->getElements() as $element) {
406 $element = $list->ensureValidIdentifiers($element);
409 $orderingElementInput->setElementList($list);
411 $form->addItem($orderingElementInput);
412 $form->addCommandButton(self::CMD_SAVE_NESTING, $this->
lng->txt(
"save"));
424 bool $graphical_output =
false,
425 bool $result_output =
false,
426 bool $show_question_only =
true,
427 bool $show_feedback =
false,
428 bool $show_correct_solution =
false,
429 bool $show_manual_scoring =
false,
430 bool $show_question_text =
true,
431 bool $show_inline_feedback =
true
433 $solution_ordering_list = $this->
object->getOrderingElementListForSolutionOutput(
434 $show_correct_solution,
439 $show_inline_feedback =
false;
440 return $this->renderSolutionOutput(
441 $solution_ordering_list,
448 $show_correct_solution,
449 $show_manual_scoring,
452 $show_inline_feedback,
457 mixed $user_solutions,
460 bool $graphical_output =
false,
461 bool $result_output =
false,
462 bool $show_question_only =
true,
463 bool $show_feedback =
false,
464 bool $show_correct_solution =
false,
465 bool $show_manual_scoring =
false,
466 bool $show_question_text =
true,
467 bool $show_autosave_title =
false,
468 bool $show_inline_feedback =
false,
471 $user_solutions : $this->
object->getSolutionOrderingElementList(
472 $this->
object->fetchIndexedValuesFromValuePairs($user_solutions)
474 $answers_gui = $this->
object->buildNestedOrderingElementInputGui();
476 if ($show_correct_solution) {
482 $answers_gui->setInteractionEnabled(
false);
483 $answers_gui->setElementList($solution_ordering_list);
485 if ($graphical_output) {
486 $answers_gui->setShowCorrectnessIconsEnabled(
true);
488 $answers_gui->setCorrectnessTrueElementList(
489 $solution_ordering_list->getParityTrueElementList($this->object->getOrderingElementList())
491 $solution_html = $answers_gui->getHTML();
493 $template =
new ilTemplate(
'tpl.il_as_qpl_nested_ordering_output_solution.html',
true,
true,
'components/ILIAS/TestQuestionPool');
494 $template->setVariable(
'SOLUTION_OUTPUT', $this->renderLatex($solution_html));
495 if ($show_question_text ==
true) {
496 $template->setVariable(
'QUESTIONTEXT', $this->renderLatex($this->
object->getQuestionForHTMLOutput()));
498 $questionoutput = $template->get();
500 $solutiontemplate =
new ilTemplate(
'tpl.il_as_tst_solution_output.html',
true,
true,
'components/ILIAS/TestQuestionPool');
501 $solutiontemplate->setVariable(
'SOLUTION_OUTPUT', $questionoutput);
503 if ($show_feedback) {
506 if (!$this->isTestPresentationContext()) {
507 $fb = $this->getGenericFeedbackOutput((
int) $active_id, $pass);
508 $feedback .= strlen($fb) ? $fb :
'';
511 if ($feedback !==
'') {
513 $this->hasCorrectSolution($active_id, $pass) ?
517 $solutiontemplate->setVariable(
'ILC_FB_CSS_CLASS', $cssClass);
522 if ($show_question_only) {
523 return $solutiontemplate->get();
526 return $this->getILIASPage($solutiontemplate->get());
533 bool $show_question_only =
false,
534 bool $show_inline_feedback =
false
536 if ($this->getPreviewSession() && $this->getPreviewSession()->hasParticipantSolution()) {
537 $solutionOrderingElementList = unserialize(
538 $this->getPreviewSession()->getParticipantsSolution(),
539 [
'allowed_classes' =>
true]
542 $solutionOrderingElementList = $this->
object->getShuffledOrderingElementList();
545 $answers = $this->
object->buildNestedOrderingElementInputGui();
546 $answers->setNestingEnabled($this->
object->isOrderingTypeNested());
548 $answers->setInteractionEnabled($this->isInteractivePresentation());
549 $answers->setElementList($solutionOrderingElementList);
551 $template =
new ilTemplate(
'tpl.il_as_qpl_ordering_output.html',
true,
true,
'components/ILIAS/TestQuestionPool');
553 $template->setCurrentBlock(
'nested_ordering_output');
554 $template->setVariable(
'NESTED_ORDERING', $this->renderLatex($answers->getHTML()));
555 $template->parseCurrentBlock();
556 $template->setVariable(
'QUESTIONTEXT', $this->renderLatex($this->
object->getQuestionForHTMLOutput()));
558 if ($show_question_only) {
559 return $template->get();
562 return $this->getILIASPage($template->get());
568 bool $is_question_postponed =
false,
569 array|
bool $user_post_solutions =
false,
570 bool $show_specific_inline_feedback =
false
572 $user_post_solutions = is_array($user_post_solutions) ? $user_post_solutions : [];
574 $ordering_gui = $this->
object->buildNestedOrderingElementInputGui();
575 $ordering_gui->setNestingEnabled($this->
object->isOrderingTypeNested());
577 $solutionOrderingElementList = $this->
object->getSolutionOrderingElementListForTestOutput(
579 $user_post_solutions,
584 $template =
new ilTemplate(
'tpl.il_as_qpl_ordering_output.html',
true,
true,
'components/ILIAS/TestQuestionPool');
587 $ordering_gui->setElementList($solutionOrderingElementList);
589 $template->setCurrentBlock(
'nested_ordering_output');
590 $template->setVariable(
'NESTED_ORDERING', $this->renderLatex($ordering_gui->getHTML()));
591 $template->parseCurrentBlock();
593 $template->setVariable(
'QUESTIONTEXT', $this->renderLatex($this->
object->getQuestionForHTMLOutput()));
595 $pageoutput = $this->outQuestionPage(
'', $is_question_postponed, $active_id, $template->get());
602 if ($this->isRenderPurposePlayback()) {
606 if ($this->isRenderPurposeDemoplay()) {
616 return $DIC[
'ilTabs'];
654 if ($this->
object->isImageOrderingType()) {
661 $content =
"<img src='{$src}' alt='{$alt}' title='{$alt}'/>";
676 foreach ($list as $elem) {
677 if ($elem->getIndentation() > $lastIndent) {
679 } elseif ($elem->getIndentation() < $lastIndent) {
680 $html .=
'</li></ul><li>';
681 } elseif (!$firstElem) {
682 $html .=
'</li><li>';
687 $html .= $this->getAnswerStatisticOrderingElementHtml($elem);
690 $lastIndent = $elem->getIndentation();
695 for ($i = $lastIndent; $i > 0; $i--) {
696 $html .=
'</ul></li>';
706 $answersByActiveAndPass = [];
708 foreach ($relevantAnswers as $row) {
709 $key = $row[
'active_fi'] .
':' . $row[
'pass'];
711 if (!isset($answersByActiveAndPass[$key])) {
712 $answersByActiveAndPass[$key] = [];
715 $answersByActiveAndPass[$key][$row[
'value1']] = $row[
'value2'];
720 foreach ($answersByActiveAndPass as $indexedSolutions) {
721 $solutionLists[] = $this->
object->getSolutionOrderingElementList($indexedSolutions);
727 foreach ($solutionLists as $orderingElementList) {
728 $hash = $orderingElementList->getHash();
730 if (!isset($answers[$hash])) {
731 $variantHtml = $this->getAnswerStatisticOrderingVariantHtml(
736 'answer' => $variantHtml,
'frequency' => 0
740 $answers[$hash][
'frequency']++;
743 return array_values($answers);
752 $orderingInput->prepareReprintable($this->
object);
761 $points->allowDecimals(
true);
762 $points->setValue($this->
object->getPoints());
763 $points->setRequired(
true);
765 $points->setMinValue(0);
766 $points->setMinvalueShouldBeGreater(
true);
770 $header->setTitle($this->
lng->txt(
'oq_header_ordering_elements'));
773 $orderingElementInput = $this->
object->buildNestedOrderingElementInputGui();
775 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
777 $orderingElementInput->setElementList($this->
object->getOrderingElementList());
779 $form->
addItem($orderingElementInput);
787 $this->
object->setPoints((
float) str_replace(
',',
'.', $form->
getInput(
'points')));
789 $submittedElementList = $this->fetchSolutionListFromSubmittedForm($form);
791 $curElementList = $this->
object->getOrderingElementList();
794 $newElementList->setQuestionId($this->
object->getId());
796 foreach ($submittedElementList as $submittedElement) {
797 if (!$curElementList->elementExistByRandomIdentifier($submittedElement->getRandomIdentifier())) {
801 $curElement = $curElementList->getElementByRandomIdentifier($submittedElement->getRandomIdentifier());
803 $curElement->setPosition($submittedElement->getPosition());
805 if ($this->
object->isOrderingTypeNested()) {
806 $curElement->setIndentation($submittedElement->getIndentation());
809 $newElementList->addElement($curElement);
812 $this->
object->setOrderingElementList($newElementList);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const F_NESTED_ORDER_ORDER
prepareReprintableCorrectionsForm(ilPropertyFormGUI $form)
addEditSubtabs($active=self::TAB_EDIT_QUESTION)
const F_NESTED_IDENTIFIER_PREFIX
fetchSolutionListFromSubmittedForm(ilPropertyFormGUI $form)
getAnswersFrequency($relevantAnswers, $questionIndex)
__construct($id=-1)
assOrderingQuestionGUI constructor
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object.
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
Adds the answer specific form parts to a question property form gui.
writePostData(bool $always=false)
Evaluates a posted edit form and writes the form data in the question object.
getPreview(bool $show_question_only=false, bool $show_inline_feedback=false)
getAnswerStatisticOrderingElementHtml(ilAssOrderingElement $element)
buildEditFormAfterTypeChange(array $values)
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
getTestOutput(int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from the request and applies them to the data object.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
supportsIntermediateSolutionOutput()
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
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)
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
const CMD_SWITCH_TO_PICTURESS
isInteractivePresentation()
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
const CMD_SWITCH_TO_TERMS
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,)
getAnswerStatisticOrderingVariantHtml(ilAssOrderingElementList $list)
const F_NESTED_ORDER_INDENT
getSpecificFeedbackOutput(array $userSolution)
Returns the answer specific feedback for the question.
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
Class for ordering questions.
const ORDERING_ELEMENT_FORM_FIELD_POSTVAR
isRenderPurposePrintPdf()
writeQuestionGenericPostData()
isInLearningModuleContext()
renderEditForm(ilPropertyFormGUI $form)
resetSavedPreviewSession()
saveTaxonomyAssignments()
setImagePathFs(string $image_path_fs)
setImagePathWeb($imagePathWeb)
setImageThumbnailPrefix($imageThumbnailPrefix)
getPresentationImageUrl()
const CSS_CLASS_FEEDBACK_WRONG
const CSS_CLASS_FEEDBACK_CORRECT
const IDENTIFIER_INDICATOR_PREFIX
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
static getSyntaxStylePath()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
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...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))