19 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
67 include_once
"./Modules/TestQuestionPool/classes/class.assOrderingQuestion.php";
70 $this->
object->loadFromDb(
$id);
76 $this->
object->setContentType($this->object::OQ_CT_PICTURES);
77 $this->
object->saveToDb();
79 $values = $this->request->getParsedBody();
80 $values[
'thumb_geometry'] = $this->
object->getThumbSize();
86 $ordering_element_list = $this->
object->getOrderingElementList();
87 foreach ($ordering_element_list as $element) {
88 $this->
object->dropImageFile($element->getContent());
91 $this->
object->setContentType($this->object::OQ_CT_TERMS);
92 $this->
object->saveToDb();
101 $ordering_element_list = $this->
object->getOrderingElementList();
102 $ordering_element_list->resetElements();
105 $form->setValuesByArray($values);
114 $form->setValuesByPost();
115 if ($form->checkInput()) {
116 $post = $this->request->raw(self::F_NESTED_ORDER);
117 $list = $this->
object->getOrderingElementList();
120 foreach (array_keys(
$post[self::F_NESTED_ORDER_ORDER]) as $idx => $identifier) {
121 $element_identifier = str_replace(self::F_NESTED_IDENTIFIER_PREFIX,
'', $identifier);
122 $element = $list->getElementByRandomIdentifier($element_identifier);
124 $ordered[] = $element
126 ->withIndentation(
$post[self::F_NESTED_ORDER_INDENT][$identifier]);
129 $list = $list->withElements($ordered);
130 $this->
object->setOrderingElementList($list);
131 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
133 $this->tpl->setOnScreenMessage(
'error', $this->
lng->txt(
'form_input_not_valid'),
true);
148 $form->setValuesByPost();
153 foreach ($submitted_list->getElements() as $submitted_element) {
154 if ($submitted_element->isImageUploadAvailable()) {
155 $filename = $this->
object->storeImageFile(
156 $submitted_element->getUploadImageFile(),
157 $submitted_element->getUploadImageName()
161 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'file_no_valid_file_type'));
163 $submitted_element = $submitted_element->withContent(
$filename);
167 if ($submitted_element->isImageRemovalRequest()) {
168 $this->
object->dropImageFile($submitted_element->getContent());
169 $submitted_element = $submitted_element->withContent(
'');
172 $elements[] = $submitted_element;
175 $list = $this->
object->getOrderingElementList()->withElements($elements);
176 $this->
object->setOrderingElementList($list);
186 $thumb_size = $this->request->int(
'thumb_geometry');
187 if ($thumb_size !== 0
188 && $thumb_size !== $this->
object->getThumbSize()) {
189 $this->
object->setThumbSize($thumb_size);
193 $points = (float) str_replace(
',',
'.', $this->request->raw(
'points'));
195 $this->
object->setPoints($points);
197 $use_nested = $this->request->raw(self::F_USE_NESTED) ===
'1';
198 $this->
object->setNestingType($use_nested);
205 ->getElementList($this->
object->getId());
207 $use_nested = $this->request->raw(self::F_USE_NESTED) ===
"1";
210 $existing_list = $this->
object->getOrderingElementList();
214 foreach ($list->getElements() as $element) {
215 $element = $list->ensureValidIdentifiers($element);
217 if ($existing = $existing_list->getElementByRandomIdentifier($element->getRandomIdentifier())) {
218 if ($existing->getIndentation() == $parent_indent + 1) {
220 ->withIndentation($existing->getIndentation());
223 $parent_indent = $element->getIndentation();
226 $list = $list->withElements($nu);
234 $element_list = $this->
object->getOrderingElementList();
236 foreach ($element_list->getElements() as $element) {
237 if ($element->getContent() ===
'') {
240 $filename = $this->
object->updateImageFile(
241 $element->getContent()
244 $elements[] = $element->withContent(
$filename);
247 $list = $this->
object->getOrderingElementList()->withElements($elements);
248 $this->
object->setOrderingElementList($list);
254 $this->
object->setOrderingElementList($list);
261 $header->setTitle($this->
lng->txt(
'oq_header_ordering_elements'));
264 $orderingElementInput = $this->
object->buildOrderingElementInputGui();
266 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
268 $list = $this->
object->getOrderingElementList();
269 $orderingElementInput->setElementList($list);
270 $form->
addItem($orderingElementInput);
277 if ($this->
object->isImageOrderingType()) {
280 $thumb_size->setRequired(
true);
281 $thumb_size->setMaxLength(6);
282 $thumb_size->setMinValue($this->
object->getMinimumThumbSize());
283 $thumb_size->setMaxValue($this->
object->getMaximumThumbSize());
284 $thumb_size->setSize(6);
285 $thumb_size->setInfo($this->
lng->txt(
'thumb_size_info'));
292 $points->setValue($this->
object->getPoints());
293 $points->setRequired(
true);
295 $points->setMinValue(0);
296 $points->setMinvalueShouldBeGreater(
true);
300 $this->
lng->txt(
'qst_use_nested_answers'),
303 $nested_answers_options = [
304 0 => $this->
lng->txt(
'qst_nested_nested_answers_off'),
305 1 => $this->
lng->txt(
'qst_nested_nested_answers_on')
307 $nested_answers->setOptions($nested_answers_options);
308 $nested_answers->setValue($this->
object->isOrderingTypeNested());
309 $form->
addItem($nested_answers);
323 $form->setValuesByPost();
325 if (!$form->checkInput()) {
343 self::TAB_EDIT_QUESTION,
344 $this->
lng->txt(
'edit_question'),
345 $this->
ctrl->getLinkTarget($this,
'editQuestion')
347 if ($this->
object->isOrderingTypeNested()) {
349 self::TAB_EDIT_NESTING,
350 $this->
lng->txt(
'tab_nest_answers'),
351 $this->
ctrl->getLinkTarget($this, self::CMD_EDIT_NESTING)
354 $tabs->setTabActive(
'edit_question');
355 $tabs->setSubTabActive($active);
374 require_once
'Modules/TestQuestionPool/classes/forms/class.ilAssOrderingQuestionAuthoringFormGUI.php';
376 $form->setFormAction($this->
ctrl->getFormAction($this));
378 $form->setMultipart($this->
object->isImageOrderingType());
379 $form->setTableWidth(
"100%");
380 $form->setId(
"ordering");
387 $form->addSpecificOrderingQuestionCommandButtons($this->
object);
388 $form->addGenericAssessmentQuestionCommandButtons($this->
object);
396 $form->setFormAction($this->
ctrl->getFormAction($this));
398 $form->setTableWidth(
"100%");
401 $header->setTitle($this->
lng->txt(
'oq_header_ordering_elements'));
402 $form->addItem($header);
404 $orderingElementInput = $this->
object->buildNestedOrderingElementInputGui();
407 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
409 $list = $this->
object->getOrderingElementList();
410 foreach ($list->getElements() as $element) {
411 $element = $list->ensureValidIdentifiers($element);
414 $orderingElementInput->setElementList($list);
416 $form->addItem($orderingElementInput);
417 $form->addCommandButton(self::CMD_SAVE_NESTING, $this->
lng->txt(
"save"));
448 $graphicalOutput =
false,
449 $result_output =
false,
450 $show_question_only =
true,
451 $show_feedback =
false,
452 $show_correct_solution =
false,
453 $show_manual_scoring =
false,
454 $show_question_text =
true 456 $solutionOrderingList = $this->
object->getOrderingElementListForSolutionOutput(
457 $show_correct_solution,
462 $answers_gui = $this->
object->buildNestedOrderingElementInputGui();
464 if ($show_correct_solution) {
470 $answers_gui->setInteractionEnabled(
false);
471 $answers_gui->setElementList($solutionOrderingList);
472 if ($graphicalOutput) {
473 $answers_gui->setShowCorrectnessIconsEnabled(
true);
475 $answers_gui->setCorrectnessTrueElementList(
476 $solutionOrderingList->getParityTrueElementList($this->object->getOrderingElementList())
478 $solution_html = $answers_gui->getHTML();
480 $template =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
481 $template->setVariable(
'SOLUTION_OUTPUT', $solution_html);
482 if ($show_question_text ==
true) {
483 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
485 $questionoutput = $template->get();
487 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
488 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
490 if ($show_feedback) {
495 $feedback .= strlen($fb) ? $fb :
'';
498 if (strlen($feedback)) {
504 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
505 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($feedback,
true));
509 if ($show_question_only) {
510 return $solutiontemplate->get();
519 public function getPreview($show_question_only =
false, $showInlineFeedback =
false): string
522 $solutionOrderingElementList = unserialize(
524 [
"allowed_classes" =>
true]
527 $solutionOrderingElementList = $this->
object->getShuffledOrderingElementList();
530 $answers = $this->
object->buildNestedOrderingElementInputGui();
531 $answers->setNestingEnabled($this->
object->isOrderingTypeNested());
534 $answers->setElementList($solutionOrderingElementList);
536 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output.html",
true,
true,
"Modules/TestQuestionPool");
538 $template->setCurrentBlock(
'nested_ordering_output');
539 $template->setVariable(
'NESTED_ORDERING', $answers->getHTML());
540 $template->parseCurrentBlock();
542 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
544 if ($show_question_only) {
545 return $template->get();
557 if ($DIC->http()->agent()->isMobile() || $DIC->http()->agent()->isIpad()) {
558 $files[] =
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js';
565 public function getTestOutput($activeId, $pass, $isPostponed =
false, $userSolutionPost =
false, $inlineFeedback =
false): string
569 $userSolutionPost = is_array($userSolutionPost) ? $userSolutionPost : array();
572 $orderingGUI = $this->
object->buildNestedOrderingElementInputGui();
573 $orderingGUI->setNestingEnabled($this->
object->isOrderingTypeNested());
575 $solutionOrderingElementList = $this->
object->getSolutionOrderingElementListForTestOutput(
582 $template =
new ilTemplate(
'tpl.il_as_qpl_ordering_output.html',
true,
true,
'Modules/TestQuestionPool');
585 $orderingGUI->setElementList($solutionOrderingElementList);
587 $template->setCurrentBlock(
'nested_ordering_output');
588 $template->setVariable(
'NESTED_ORDERING', $orderingGUI->getHTML());
589 $template->parseCurrentBlock();
591 $template->setVariable(
'QUESTIONTEXT', $this->
object->getQuestionForHTMLOutput());
593 $pageoutput = $this->
outQuestionPage(
'', $isPostponed, $activeId, $template->get());
614 return $DIC[
'ilTabs'];
660 $this->
object->getOrderingElementList()
666 public function aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question): array
669 foreach ($relevant_answers_chosen as $answer_chosen) {
670 $passdata[$answer_chosen[
'active_fi'] .
'-' . $answer_chosen[
'pass']][$answer_chosen[
'value2']] = $answer_chosen[
'value1'];
675 $hash = md5(implode(
'-',
$data));
677 foreach ($variants as $vkey => $variant) {
678 if ($variant[
'hash'] == $hash) {
684 $variants[
$key][
'hash'] = $hash;
685 $variants[
$key][
'count'] = 1;
689 $aggregate = array();
690 foreach ($variants as
$key => $variant_entry) {
691 $variant = $passdata[
$key];
693 foreach ($variant as $variant_key => $variant_line) {
695 $aggregated_info_for_answer[
'count'] = $variant_entry[
'count'];
696 foreach ($answers_defined_on_question as $element) {
699 if ($this->
object->isImageOrderingType()) {
700 $element->setImageThumbnailPrefix($this->
object->getThumbPrefix());
701 $element->setImagePathWeb($this->
object->getImagePathWeb());
702 $element->setImagePathFs($this->
object->getImagePath());
704 $src = $element->getPresentationImageUrl();
705 $alt = $element->getContent();
706 $content =
"<img src='{$src}' alt='{$alt}' title='{$alt}'/>";
708 $content = $element->getContent();
711 $aggregated_info_for_answer[
$i .
' - ' . $content]
715 $aggregate[] = $aggregated_info_for_answer;
727 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
729 foreach ($aggregate as $line_data) {
731 $count = array_shift($line_data);
733 foreach ($line_data as
$key => $line) {
734 $html .=
'<li>' . ++$line .
' - ' .
$key .
'</li>';
747 if ($this->
object->isImageOrderingType()) {
754 $content =
"<img src='{$src}' alt='{$alt}' title='{$alt}'/>";
769 foreach ($list as $elem) {
770 if ($elem->getIndentation() > $lastIndent) {
772 } elseif ($elem->getIndentation() < $lastIndent) {
773 $html .=
'</li></ul><li>';
774 } elseif (!$firstElem) {
775 $html .=
'</li><li>';
783 $lastIndent = $elem->getIndentation();
788 for (
$i = $lastIndent;
$i > 0;
$i--) {
789 $html .=
'</ul></li>';
799 $answersByActiveAndPass = array();
801 foreach ($relevantAnswers as $row) {
802 $key = $row[
'active_fi'] .
':' . $row[
'pass'];
804 if (!isset($answersByActiveAndPass[
$key])) {
805 $answersByActiveAndPass[
$key] = array();
808 $answersByActiveAndPass[
$key][$row[
'value1']] = $row[
'value2'];
811 $solutionLists = array();
813 foreach ($answersByActiveAndPass as $indexedSolutions) {
814 $solutionLists[] = $this->
object->getSolutionOrderingElementList($indexedSolutions);
820 foreach ($solutionLists as $orderingElementList) {
821 $hash = $orderingElementList->getHash();
823 if (!isset($answers[$hash])) {
828 $answers[$hash] = array(
829 'answer' => $variantHtml,
'frequency' => 0
833 $answers[$hash][
'frequency']++;
836 return array_values($answers);
845 $orderingInput->prepareReprintable($this->
object);
855 $points->setValue($this->
object->getPoints());
856 $points->setRequired(
true);
858 $points->setMinValue(0);
859 $points->setMinvalueShouldBeGreater(
true);
863 $header->setTitle($this->
lng->txt(
'oq_header_ordering_elements'));
866 $orderingElementInput = $this->
object->buildNestedOrderingElementInputGui();
868 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
870 $orderingElementInput->setElementList($this->
object->getOrderingElementList());
872 $form->
addItem($orderingElementInput);
880 $this->
object->setPoints((
float) str_replace(
',',
'.', $form->
getInput(
'points')));
884 $curElementList = $this->
object->getOrderingElementList();
887 $newElementList->setQuestionId($this->
object->getId());
889 foreach ($submittedElementList as $submittedElement) {
890 if (!$curElementList->elementExistByRandomIdentifier($submittedElement->getRandomIdentifier())) {
894 $curElement = $curElementList->getElementByRandomIdentifier($submittedElement->getRandomIdentifier());
896 $curElement->setPosition($submittedElement->getPosition());
898 if ($this->
object->isOrderingTypeNested()) {
899 $curElement->setIndentation($submittedElement->getIndentation());
902 $newElementList->addElement($curElement);
905 $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)
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
const IDENTIFIER_INDICATOR_PREFIX
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAnswerStatisticOrderingVariantHtml(ilAssOrderingElementList $list)
renderAggregateView($aggregate)
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
Adds the answer specific form parts to a question property form gui.
Abstract basic class which is to be extended by the concrete assessment question type classes...
getAggregatedAnswersView(array $relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
getSolutionOutput( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
Get the question solution output.
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
const F_NESTED_ORDER_INDENT
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
writePostData(bool $always=false)
{}
const CMD_SWITCH_TO_PICTURESS
const CSS_CLASS_FEEDBACK_CORRECT
ilGlobalPageTemplate $tpl
isRenderPurposePlayback()
populateTaxonomyFormSection(ilPropertyFormGUI $form)
setImagePathFs($imagePathFs)
editQuestion($checkonly=false)
setImagePathWeb($imagePathWeb)
fetchSolutionListFromSubmittedForm(ilPropertyFormGUI $form)
writeQuestionGenericPostData()
const ORDERING_ELEMENT_FORM_FIELD_POSTVAR
isInteractivePresentation()
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
isRenderPurposeDemoplay()
const CMD_SWITCH_TO_TERMS
buildEditFormAfterTypeChange(array $values)
getTestOutput($activeId, $pass, $isPostponed=false, $userSolutionPost=false, $inlineFeedback=false)
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
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)
__construct(Container $dic, ilPlugin $plugin)
getPresentationJavascripts()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPreview($show_question_only=false, $showInlineFeedback=false)
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
setVariable(string $variable, $value='')
Sets the given variable to the given value.
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
renderEditForm(ilPropertyFormGUI $form)
getGenericFeedbackOutput(int $active_id, ?int $pass)