19 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
69 $this->
object->loadFromDb(
$id);
75 $this->
object->setContentType($this->object::OQ_CT_PICTURES);
76 $this->
object->saveToDb();
78 $values = $this->request->getParsedBody();
79 $values[
'thumb_geometry'] = $this->
object->getThumbSize();
85 $ordering_element_list = $this->
object->getOrderingElementList();
86 foreach ($ordering_element_list as $element) {
87 $this->
object->dropImageFile($element->getContent());
90 $this->
object->setContentType($this->object::OQ_CT_TERMS);
91 $this->
object->saveToDb();
100 $ordering_element_list = $this->
object->getOrderingElementList();
101 $ordering_element_list->resetElements();
104 $form->setValuesByArray($values);
113 $form->setValuesByPost();
114 if ($form->checkInput()) {
115 $post = $this->request->raw(self::F_NESTED_ORDER);
116 $list = $this->
object->getOrderingElementList();
119 foreach (array_keys(
$post[self::F_NESTED_ORDER_ORDER]) as $idx => $identifier) {
120 $element_identifier = str_replace(self::F_NESTED_IDENTIFIER_PREFIX,
'', $identifier);
121 $element = $list->getElementByRandomIdentifier($element_identifier);
123 $ordered[] = $element
125 ->withIndentation(
$post[self::F_NESTED_ORDER_INDENT][$identifier]);
128 $list = $list->withElements($ordered);
129 $this->
object->setOrderingElementList($list);
130 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
132 $this->tpl->setOnScreenMessage(
'error', $this->
lng->txt(
'form_input_not_valid'),
true);
147 $form->setValuesByPost();
152 foreach ($submitted_list->getElements() as $submitted_element) {
153 if ($submitted_element->isImageUploadAvailable()) {
154 $filename = $this->
object->storeImageFile(
155 $submitted_element->getUploadImageFile(),
156 $submitted_element->getUploadImageName()
160 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'file_no_valid_file_type'));
162 $submitted_element = $submitted_element->withContent(
$filename);
166 if ($submitted_element->isImageRemovalRequest()) {
167 $this->
object->dropImageFile($submitted_element->getContent());
168 $submitted_element = $submitted_element->withContent(
'');
171 $elements[] = $submitted_element;
174 $list = $this->
object->getOrderingElementList()->withElements($elements);
175 $this->
object->setOrderingElementList($list);
185 $thumb_size = $this->request->int(
'thumb_geometry');
186 if ($thumb_size !== 0
187 && $thumb_size !== $this->
object->getThumbSize()) {
188 $this->
object->setThumbSize($thumb_size);
192 $points = (float) str_replace(
',',
'.', $this->request->raw(
'points'));
194 $this->
object->setPoints($points);
196 $use_nested = $this->request->raw(self::F_USE_NESTED) ===
'1';
197 $this->
object->setNestingType($use_nested);
204 ->getElementList($this->
object->getId());
206 $use_nested = $this->request->raw(self::F_USE_NESTED) ===
"1";
209 $existing_list = $this->
object->getOrderingElementList();
213 foreach ($list->getElements() as $element) {
214 $element = $list->ensureValidIdentifiers($element);
216 if ($existing = $existing_list->getElementByRandomIdentifier($element->getRandomIdentifier())) {
217 if ($existing->getIndentation() == $parent_indent + 1) {
219 ->withIndentation($existing->getIndentation());
222 $parent_indent = $element->getIndentation();
225 $list = $list->withElements($nu);
233 $element_list = $this->
object->getOrderingElementList();
235 foreach ($element_list->getElements() as $element) {
236 if ($element->getContent() ===
'') {
239 $filename = $this->
object->updateImageFile(
240 $element->getContent()
243 $elements[] = $element->withContent(
$filename);
246 $list = $this->
object->getOrderingElementList()->withElements($elements);
247 $this->
object->setOrderingElementList($list);
253 $this->
object->setOrderingElementList($list);
260 $header->setTitle($this->
lng->txt(
'oq_header_ordering_elements'));
263 $orderingElementInput = $this->
object->buildOrderingElementInputGui();
265 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
267 $list = $this->
object->getOrderingElementList();
268 $orderingElementInput->setElementList($list);
269 $form->
addItem($orderingElementInput);
276 if ($this->
object->isImageOrderingType()) {
278 $thumb_size->setValue($this->
object->getThumbSize());
279 $thumb_size->setRequired(
true);
280 $thumb_size->setMaxLength(6);
281 $thumb_size->setMinValue($this->
object->getMinimumThumbSize());
282 $thumb_size->setMaxValue($this->
object->getMaximumThumbSize());
283 $thumb_size->setSize(6);
284 $thumb_size->setInfo($this->
lng->txt(
'thumb_size_info'));
290 $points->allowDecimals(
true);
291 $points->setValue($this->
object->getPoints());
292 $points->setRequired(
true);
294 $points->setMinValue(0);
295 $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);
324 $form->setValuesByPost();
326 if (!$form->checkInput()) {
344 self::TAB_EDIT_QUESTION,
345 $this->
lng->txt(
'edit_question'),
346 $this->
ctrl->getLinkTarget($this,
'editQuestion')
350 self::TAB_EDIT_NESTING,
351 $this->
lng->txt(
'tab_nest_answers'),
352 $this->
ctrl->getLinkTarget($this, self::CMD_EDIT_NESTING)
355 $tabs->setTabActive(
'edit_question');
356 $tabs->setSubTabActive($active);
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 $show_inline_feedback =
false;
464 $solutionOrderingList,
471 $show_correct_solution,
472 $show_manual_scoring,
475 $show_inline_feedback,
480 mixed $user_solutions,
483 bool $graphical_output =
false,
484 bool $result_output =
false,
485 bool $show_question_only =
true,
486 bool $show_feedback =
false,
487 bool $show_correct_solution =
false,
488 bool $show_manual_scoring =
false,
489 bool $show_question_text =
true,
490 bool $show_autosave_title =
false,
491 bool $show_inline_feedback =
false,
494 $user_solutions : $this->
object->getSolutionOrderingElementList(
495 $this->object->fetchIndexedValuesFromValuePairs($user_solutions)
497 $answers_gui = $this->
object->buildNestedOrderingElementInputGui();
499 if ($show_correct_solution) {
505 $answers_gui->setInteractionEnabled(
false);
506 $answers_gui->setElementList($solutionOrderingList);
507 if ($graphical_output) {
508 $answers_gui->setShowCorrectnessIconsEnabled(
true);
510 $answers_gui->setCorrectnessTrueElementList(
511 $solutionOrderingList->getParityTrueElementList($this->object->getOrderingElementList())
513 $solution_html = $answers_gui->getHTML();
515 $template =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
516 $template->setVariable(
'SOLUTION_OUTPUT', $solution_html);
517 if ($show_question_text ==
true) {
518 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
520 $questionoutput = $template->get();
522 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
523 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
525 if ($show_feedback) {
530 $feedback .= strlen($fb) ? $fb :
'';
533 if (strlen($feedback)) {
539 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
544 if ($show_question_only) {
545 return $solutiontemplate->get();
554 public function getPreview($show_question_only =
false, $showInlineFeedback =
false): string
557 $solutionOrderingElementList = unserialize(
559 [
"allowed_classes" =>
true]
562 $solutionOrderingElementList = $this->
object->getShuffledOrderingElementList();
565 $answers = $this->
object->buildNestedOrderingElementInputGui();
566 $answers->setNestingEnabled($this->
object->isOrderingTypeNested());
569 $answers->setElementList($solutionOrderingElementList);
571 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output.html",
true,
true,
"Modules/TestQuestionPool");
573 $template->setCurrentBlock(
'nested_ordering_output');
574 $template->setVariable(
'NESTED_ORDERING', $answers->getHTML());
575 $template->parseCurrentBlock();
576 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
578 if ($show_question_only) {
579 return $template->get();
591 if ($DIC->http()->agent()->isMobile() || $DIC->http()->agent()->isIpad()) {
592 $files[] =
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js';
599 public function getTestOutput($activeId, $pass, $isPostponed =
false, $userSolutionPost =
false, $inlineFeedback =
false): string
603 $userSolutionPost = is_array($userSolutionPost) ? $userSolutionPost : [];
606 $orderingGUI = $this->
object->buildNestedOrderingElementInputGui();
607 $orderingGUI->setNestingEnabled($this->
object->isOrderingTypeNested());
609 $solutionOrderingElementList = $this->
object->getSolutionOrderingElementListForTestOutput(
616 $template =
new ilTemplate(
'tpl.il_as_qpl_ordering_output.html',
true,
true,
'Modules/TestQuestionPool');
619 $orderingGUI->setElementList($solutionOrderingElementList);
621 $template->setCurrentBlock(
'nested_ordering_output');
622 $template->setVariable(
'NESTED_ORDERING', $orderingGUI->getHTML());
623 $template->parseCurrentBlock();
625 $template->setVariable(
'QUESTIONTEXT', $this->
object->getQuestionForHTMLOutput());
627 $pageoutput = $this->
outQuestionPage(
'', $isPostponed, $activeId, $template->get());
648 return $DIC[
'ilTabs'];
694 $this->
object->getOrderingElementList()
700 public function aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question): array
703 foreach ($relevant_answers_chosen as $answer_chosen) {
704 $passdata[$answer_chosen[
'active_fi'] .
'-' . $answer_chosen[
'pass']][$answer_chosen[
'value2']] = $answer_chosen[
'value1'];
709 $hash = md5(implode(
'-',
$data));
711 foreach ($variants as $vkey => $variant) {
712 if ($variant[
'hash'] == $hash) {
718 $variants[
$key][
'hash'] = $hash;
719 $variants[
$key][
'count'] = 1;
724 foreach ($variants as
$key => $variant_entry) {
725 $variant = $passdata[
$key];
727 foreach ($variant as $variant_key => $variant_line) {
729 $aggregated_info_for_answer[
'count'] = $variant_entry[
'count'];
730 foreach ($answers_defined_on_question as $element) {
733 if ($this->
object->isImageOrderingType()) {
734 $element->setImageThumbnailPrefix($this->
object->getThumbPrefix());
735 $element->setImagePathWeb($this->
object->getImagePathWeb());
736 $element->setImagePathFs($this->
object->getImagePath());
738 $src = $element->getPresentationImageUrl();
739 $alt = $element->getContent();
740 $content =
"<img src='{$src}' alt='{$alt}' title='{$alt}'/>";
742 $content = $element->getContent();
745 $aggregated_info_for_answer[$i .
' - ' . $content]
746 = $passdata[
$key][$i];
749 $aggregate[] = $aggregated_info_for_answer;
761 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
763 foreach ($aggregate as $line_data) {
765 $count = array_shift($line_data);
767 foreach ($line_data as
$key => $line) {
768 $html .=
'<li>' . ++$line .
' - ' .
$key .
'</li>';
781 if ($this->
object->isImageOrderingType()) {
788 $content =
"<img src='{$src}' alt='{$alt}' title='{$alt}'/>";
803 foreach ($list as $elem) {
804 if ($elem->getIndentation() > $lastIndent) {
806 } elseif ($elem->getIndentation() < $lastIndent) {
807 $html .=
'</li></ul><li>';
808 } elseif (!$firstElem) {
809 $html .=
'</li><li>';
817 $lastIndent = $elem->getIndentation();
822 for ($i = $lastIndent; $i > 0; $i--) {
823 $html .=
'</ul></li>';
833 $answersByActiveAndPass = [];
835 foreach ($relevantAnswers as $row) {
836 $key = $row[
'active_fi'] .
':' . $row[
'pass'];
838 if (!isset($answersByActiveAndPass[
$key])) {
839 $answersByActiveAndPass[
$key] = [];
842 $answersByActiveAndPass[
$key][$row[
'value1']] = $row[
'value2'];
847 foreach ($answersByActiveAndPass as $indexedSolutions) {
848 $solutionLists[] = $this->
object->getSolutionOrderingElementList($indexedSolutions);
854 foreach ($solutionLists as $orderingElementList) {
855 $hash = $orderingElementList->getHash();
857 if (!isset($answers[$hash])) {
862 $answers[$hash] = array(
863 'answer' => $variantHtml,
'frequency' => 0
867 $answers[$hash][
'frequency']++;
870 return array_values($answers);
879 $orderingInput->prepareReprintable($this->
object);
888 $points->allowDecimals(
true);
889 $points->setValue($this->
object->getPoints());
890 $points->setRequired(
true);
892 $points->setMinValue(0);
893 $points->setMinvalueShouldBeGreater(
true);
897 $header->setTitle($this->
lng->txt(
'oq_header_ordering_elements'));
900 $orderingElementInput = $this->
object->buildNestedOrderingElementInputGui();
902 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
904 $orderingElementInput->setElementList($this->
object->getOrderingElementList());
906 $form->
addItem($orderingElementInput);
914 $this->
object->setPoints((
float) str_replace(
',',
'.', $form->
getInput(
'points')));
918 $curElementList = $this->
object->getOrderingElementList();
921 $newElementList->setQuestionId($this->
object->getId());
923 foreach ($submittedElementList as $submittedElement) {
924 if (!$curElementList->elementExistByRandomIdentifier($submittedElement->getRandomIdentifier())) {
928 $curElement = $curElementList->getElementByRandomIdentifier($submittedElement->getRandomIdentifier());
930 $curElement->setPosition($submittedElement->getPosition());
932 if ($this->
object->isOrderingTypeNested()) {
933 $curElement->setIndentation($submittedElement->getIndentation());
936 $newElementList->addElement($curElement);
939 $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
isInLearningModuleContext()
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
Basic GUI class for assessment questions.
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)
getPresentationJavascripts()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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,)
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)