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();
260 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
262 $list = $this->
object->getOrderingElementList();
263 $orderingElementInput->setElementList($list);
264 $form->
addItem($orderingElementInput);
271 if ($this->
object->isImageOrderingType()) {
273 $thumb_size->setValue($this->
object->getThumbSize());
274 $thumb_size->setRequired(
true);
275 $thumb_size->setMaxLength(6);
276 $thumb_size->setMinValue($this->
object->getMinimumThumbSize());
277 $thumb_size->setMaxValue($this->
object->getMaximumThumbSize());
278 $thumb_size->setSize(6);
279 $thumb_size->setInfo($this->
lng->txt(
'thumb_size_info'));
285 $points->allowDecimals(
true);
286 $points->setValue($this->
object->getPoints());
287 $points->setRequired(
true);
289 $points->setMinValue(0);
290 $points->setMinvalueShouldBeGreater(
true);
295 $this->
lng->txt(
'qst_use_nested_answers'),
298 $nested_answers_options = [
299 0 => $this->
lng->txt(
'qst_nested_nested_answers_off'),
300 1 => $this->
lng->txt(
'qst_nested_nested_answers_on')
302 $nested_answers->setOptions($nested_answers_options);
303 $nested_answers->setValue($this->
object->isOrderingTypeNested());
304 $form->
addItem($nested_answers);
313 $form->setValuesByPost();
315 if (!$form->checkInput()) {
335 self::TAB_EDIT_QUESTION,
336 $this->
lng->txt(
'edit_question'),
337 $this->ctrl->getLinkTarget($this,
'editQuestion')
339 if ($this->
object->isOrderingTypeNested() && !$this->isInLearningModuleContext()) {
341 self::TAB_EDIT_NESTING,
342 $this->
lng->txt(
'tab_nest_answers'),
343 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_NESTING)
346 $tabs->setTabActive(
'edit_question');
347 $tabs->setSubTabActive($active);
351 bool $checkonly =
false,
352 ?
bool $is_save_cmd =
null
361 $this->renderEditForm($this->buildNestingForm());
362 $this->addEditSubtabs(self::TAB_EDIT_NESTING);
370 $form->setFormAction($this->
ctrl->getFormAction($this));
371 $form->setTitle($this->outQuestionType());
372 $form->setMultipart($this->
object->isImageOrderingType());
373 $form->setTableWidth(
"100%");
374 $form->setId(
"ordering");
376 $this->addBasicQuestionFormProperties($form);
377 $this->populateQuestionSpecificFormPart($form);
378 $this->populateAnswerSpecificFormPart($form);
379 $this->populateTaxonomyFormSection($form);
381 $form->addSpecificOrderingQuestionCommandButtons($this->
object);
382 $form->addGenericAssessmentQuestionCommandButtons($this->
object);
390 $form->setFormAction($this->
ctrl->getFormAction($this));
391 $form->setTitle($this->outQuestionType());
392 $form->setTableWidth(
"100%");
395 $header->setTitle($this->
lng->txt(
'oq_header_ordering_elements'));
396 $form->addItem($header);
398 $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;
438 return $this->renderSolutionOutput(
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', $this->renderLatex($solution_html));
493 if ($show_question_text ==
true) {
494 $template->setVariable(
'QUESTIONTEXT', $this->renderLatex($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) {
504 if (!$this->isTestPresentationContext()) {
505 $fb = $this->getGenericFeedbackOutput((
int) $active_id, $pass);
506 $feedback .= strlen($fb) ? $fb :
'';
509 if ($feedback !==
'') {
511 $this->hasCorrectSolution($active_id, $pass) ?
515 $solutiontemplate->setVariable(
'ILC_FB_CSS_CLASS', $cssClass);
520 if ($show_question_only) {
521 return $solutiontemplate->get();
524 return $this->getILIASPage($solutiontemplate->get());
531 bool $show_question_only =
false,
532 bool $show_inline_feedback =
false
534 if ($this->getPreviewSession() && $this->getPreviewSession()->hasParticipantSolution()) {
535 $solutionOrderingElementList = unserialize(
536 $this->getPreviewSession()->getParticipantsSolution(),
537 [
'allowed_classes' =>
true]
540 $solutionOrderingElementList = $this->
object->getShuffledOrderingElementList();
543 $answers = $this->
object->buildNestedOrderingElementInputGui();
544 $answers->setNestingEnabled($this->
object->isOrderingTypeNested());
546 $answers->setInteractionEnabled($this->isInteractivePresentation());
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', $this->renderLatex($answers->getHTML()));
553 $template->parseCurrentBlock();
554 $template->setVariable(
'QUESTIONTEXT', $this->renderLatex($this->
object->getQuestionForHTMLOutput()));
556 if ($show_question_only) {
557 return $template->get();
560 return $this->getILIASPage($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', $this->renderLatex($ordering_gui->getHTML()));
589 $template->parseCurrentBlock();
591 $template->setVariable(
'QUESTIONTEXT', $this->renderLatex($this->
object->getQuestionForHTMLOutput()));
593 $pageoutput = $this->outQuestionPage(
'', $is_question_postponed, $active_id, $template->get());
600 if ($this->isRenderPurposePlayback()) {
604 if ($this->isRenderPurposeDemoplay()) {
614 return $DIC[
'ilTabs'];
652 if ($this->
object->isImageOrderingType()) {
659 $content =
"<img src='{$src}' alt='{$alt}' title='{$alt}'/>";
671 $this->getAnswerStatisticOrderingElementHtml($elem) ??
'',
672 ENT_QUOTES | ENT_SUBSTITUTE,
678 return $this->
ui->renderer()->render($this->
ui->factory()->listing()->unordered($list));
683 $answersByActiveAndPass = [];
685 foreach ($relevantAnswers as $row) {
686 $key = $row[
'active_fi'] .
':' . $row[
'pass'];
688 if (!isset($answersByActiveAndPass[$key])) {
689 $answersByActiveAndPass[$key] = [];
692 $answersByActiveAndPass[$key][$row[
'value1']] = $row[
'value2'];
697 foreach ($answersByActiveAndPass as $indexedSolutions) {
698 $solutionLists[] = $this->
object->getSolutionOrderingElementList($indexedSolutions);
704 foreach ($solutionLists as $orderingElementList) {
705 $hash = $orderingElementList->getHash();
707 if (!isset($answers[$hash])) {
708 $variantHtml = $this->getAnswerStatisticOrderingVariantHtml(
713 'answer' => $variantHtml,
719 $answers[$hash][
'frequency']++;
722 return array_values($answers);
731 $orderingInput->prepareReprintable($this->
object);
740 $points->allowDecimals(
true);
741 $points->setValue($this->
object->getPoints());
742 $points->setRequired(
true);
744 $points->setMinValue(0);
745 $points->setMinvalueShouldBeGreater(
true);
749 $header->setTitle($this->
lng->txt(
'oq_header_ordering_elements'));
752 $orderingElementInput = $this->
object->buildNestedOrderingElementInputGui();
754 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
756 $orderingElementInput->setElementList($this->
object->getOrderingElementList());
758 $form->
addItem($orderingElementInput);
766 $this->
object->setPoints((
float) str_replace(
',',
'.', $form->
getInput(
'points')));
768 $submittedElementList = $this->fetchSolutionListFromSubmittedForm($form);
770 $curElementList = $this->
object->getOrderingElementList();
773 $newElementList->setQuestionId($this->
object->getId());
775 foreach ($submittedElementList as $submittedElement) {
776 if (!$curElementList->elementExistByRandomIdentifier($submittedElement->getRandomIdentifier())) {
780 $curElement = $curElementList->getElementByRandomIdentifier($submittedElement->getRandomIdentifier());
782 $curElement->setPosition($submittedElement->getPosition());
784 if ($this->
object->isOrderingTypeNested()) {
785 $curElement->setIndentation($submittedElement->getIndentation());
788 $newElementList->addElement($curElement);
791 $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
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'))