4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
7 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
49 parent::__construct();
50 include_once
"./Modules/TestQuestionPool/classes/class.assOrderingQuestion.php";
53 $this->
object->loadFromDb(
$id);
55 $this->clearAnswersOnWritingPostDataEnabled =
false;
81 $form->setValuesByPost();
85 $this->
object->saveToDb();
87 $form->ensureReprintableFormStructure($this->
object);
98 $form->setValuesByPost();
101 $this->
object->setOrderingType(
OQ_TERMS);
102 $this->
object->saveToDb();
104 $form->ensureReprintableFormStructure($this->
object);
112 $this->
object->saveToDb();
121 $this->
object->saveToDb();
128 $orderingInput = $this->
object->buildOrderingImagesInputGui();
129 $this->
object->initOrderingElementAuthoringProperties($orderingInput);
132 $form->replaceFormItemByPostVar($orderingInput);
133 $form->setValuesByPost();
136 $this->object->getId(),
140 $storedElementList = $this->
object->getOrderingElementList();
142 foreach ($orderingInput->getElementList($this->object->getId()) as $submittedElement) {
143 if ($submittedElement->isImageRemovalRequest()) {
144 if ($this->object->isImageFileStored($submittedElement->getContent())) {
145 $this->
object->dropImageFile($submittedElement->getContent());
148 $submittedElement->setContent(null);
151 if ($storedElementList->elementExistByRandomIdentifier($submittedElement->getRandomIdentifier())) {
152 $storedElement = $storedElementList->getElementByRandomIdentifier(
153 $submittedElement->getRandomIdentifier()
156 $submittedElement->setSolutionIdentifier($storedElement->getSolutionIdentifier());
157 $submittedElement->setIndentation($storedElement->getIndentation());
160 $replacementElemList->addElement($submittedElement);
163 $replacementElemList->saveToDb();
165 $orderingInput->setElementList($replacementElemList);
171 $orderingInput = $this->
object->buildOrderingImagesInputGui();
172 $this->
object->initOrderingElementAuthoringProperties($orderingInput);
175 $form->replaceFormItemByPostVar($orderingInput);
176 $form->setValuesByPost();
178 if (!$orderingInput->checkInput()) {
183 $this->
object->getOrderingElementList()->saveToDb();
184 $orderingInput->setElementList($this->object->getOrderingElementList());
191 $this->
object->setThumbGeometry(
$_POST[
"thumb_geometry"]);
192 $this->
object->setElementHeight(
$_POST[
"element_height"]);
194 $this->
object->setPoints(
$_POST[
"points"]);
203 #$submittedElementList = $this->object->fetchSolutionListFromFormSubmissionData($_POST); 204 $submittedElementList = $this->
object->fetchSolutionListFromSubmittedForm($form);
207 $replacementElementList->setQuestionId($this->object->getId());
209 $currentElementList = $this->
object->getOrderingElementList();
211 foreach ($submittedElementList as $submittedElement) {
212 if ($this->object->hasOrderingTypeUploadSupport()) {
213 if ($submittedElement->isImageUploadAvailable()) {
214 $suffix = strtolower(array_pop(explode(
".", $submittedElement->getUploadImageName())));
215 if (in_array($suffix, array(
"jpg",
"jpeg",
"png",
"gif"))) {
216 $submittedElement->setUploadImageName($this->object->buildHashedImageFilename(
217 $submittedElement->getUploadImageName(),
221 $wasImageFileStored = $this->
object->storeImageFile(
222 $submittedElement->getUploadImageFile(),
223 $submittedElement->getUploadImageName()
226 if ($wasImageFileStored) {
227 if ($this->object->isImageFileStored($submittedElement->getContent())) {
228 $this->
object->dropImageFile($submittedElement->getContent());
231 $submittedElement->setContent($submittedElement->getUploadImageName());
237 if ($currentElementList->elementExistByRandomIdentifier($submittedElement->getRandomIdentifier())) {
238 $storedElement = $currentElementList->getElementByRandomIdentifier(
239 $submittedElement->getRandomIdentifier()
242 $submittedElement->setSolutionIdentifier($storedElement->getSolutionIdentifier());
245 $submittedElement->setContent($storedElement->getContent());
248 if (!$this->object->isOrderingTypeNested()) {
249 $submittedElement->setIndentation($storedElement->getIndentation());
252 if ($this->object->isImageReplaced($submittedElement, $storedElement)) {
253 $this->
object->dropImageFile($storedElement->getContent());
257 $replacementElementList->addElement($submittedElement);
260 if ($this->object->isImageOrderingType()) {
261 $this->
object->handleThumbnailCreation($replacementElementList);
265 $replacementElementList->clearElementContents();
268 if ($this->object->hasOrderingTypeUploadSupport()) {
269 $obsoleteElementList = $currentElementList->getDifferenceElementList($replacementElementList);
271 foreach ($obsoleteElementList as $obsoleteElement) {
272 $this->
object->dropImageFile($obsoleteElement->getContent());
276 $this->
object->setOrderingElementList($replacementElementList);
282 $header->setTitle($this->lng->txt(
'oq_header_ordering_elements'));
286 $orderingElementInput = $this->
object->buildNestedOrderingElementInputGui();
288 $orderingElementInput = $this->
object->buildOrderingElementInputGui();
292 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
294 $orderingElementInput->setElementList($this->object->getOrderingElementList());
296 $form->
addItem($orderingElementInput);
303 if (!$this->object->getSelfAssessmentEditingMode()) {
304 $element_height =
new ilNumberInputGUI($this->lng->txt(
"element_height"),
"element_height");
305 $element_height->
setValue($this->object->getElementHeight());
306 $element_height->setRequired(
false);
307 $element_height->setMaxLength(6);
308 $element_height->setMinValue(20);
309 $element_height->setSize(6);
310 $element_height->setInfo($this->lng->txt(
"element_height_info"));
311 $form->
addItem($element_height);
314 if ($this->object->isImageOrderingType()) {
315 $geometry =
new ilNumberInputGUI($this->lng->txt(
"thumb_geometry"),
"thumb_geometry");
316 $geometry->
setValue($this->object->getThumbGeometry());
317 $geometry->setRequired(
true);
318 $geometry->setMaxLength(6);
319 $geometry->setMinValue(20);
320 $geometry->setSize(6);
321 $geometry->setInfo($this->lng->txt(
"thumb_geometry_info"));
328 $points->setValue($this->object->getPoints());
329 $points->setRequired(
true);
331 $points->setMinValue(0);
332 $points->setMinvalueShouldBeGreater(
true);
343 $savingAllowed =
true;
351 $form->setValuesByPost();
353 if (!
$form->checkInput()) {
354 $form->prepareValuesReprintable($this->
object);
358 $savingAllowed =
false;
365 $form->setValuesByPost();
369 if ($savingAllowed) {
391 require_once
'Modules/TestQuestionPool/classes/forms/class.ilAssOrderingQuestionAuthoringFormGUI.php';
393 $this->editForm =
$form;
395 $form->setFormAction($this->ctrl->getFormAction($this));
397 $form->setMultipart(($this->object->getOrderingType() ==
OQ_PICTURES) ?
true :
false);
398 $form->setTableWidth(
"100%");
399 $form->setId(
"ordering");
407 $form->addSpecificOrderingQuestionCommandButtons($this->
object);
408 $form->addGenericAssessmentQuestionCommandButtons($this->
object);
441 $graphicalOutput =
false,
442 $result_output =
false,
443 $show_question_only =
true,
444 $show_feedback =
false,
445 $forceCorrectSolution =
false,
446 $show_manual_scoring =
false,
447 $show_question_text =
true 449 $solutionOrderingList = $this->
object->getOrderingElementListForSolutionOutput(
450 $forceCorrectSolution,
456 $answers_gui = $this->
object->buildNestedOrderingElementInputGui();
458 if ($forceCorrectSolution) {
464 $answers_gui->setInteractionEnabled(
false);
466 $answers_gui->setElementList($solutionOrderingList);
468 $answers_gui->setCorrectnessTrueElementList(
469 $solutionOrderingList->getParityTrueElementList($this->object->getOrderingElementList())
472 $solution_html = $answers_gui->getHTML();
474 $template =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
475 $template->setVariable(
'SOLUTION_OUTPUT', $solution_html);
476 if ($show_question_text ==
true) {
477 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
481 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
482 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
484 if ($show_feedback) {
489 $feedback .= strlen($fb) ? $fb :
'';
493 $feedback .= strlen($fb) ? $fb :
'';
495 if (strlen($feedback)) {
501 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
502 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
506 if ($show_question_only) {
507 return $solutiontemplate->get();
516 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
519 $solutionOrderingElementList = unserialize(
523 $solutionOrderingElementList = $this->
object->getShuffledOrderingElementList();
526 $answers = $this->
object->buildNestedOrderingElementInputGui();
527 $answers->setNestingEnabled($this->object->isOrderingTypeNested());
530 $answers->setElementList($solutionOrderingElementList);
532 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output.html",
true,
true,
"Modules/TestQuestionPool");
534 $template->setCurrentBlock(
'nested_ordering_output');
535 $template->setVariable(
'NESTED_ORDERING', $answers->getHTML());
538 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
540 if ($show_question_only) {
550 public function getTestOutput($activeId,
$pass, $isPostponed =
false, $userSolutionPost =
false, $inlineFeedback =
false)
554 $userSolutionPost = is_array($userSolutionPost) ? $userSolutionPost : array();
557 $orderingGUI = $this->
object->buildNestedOrderingElementInputGui();
558 $orderingGUI->setNestingEnabled($this->object->isOrderingTypeNested());
560 $solutionOrderingElementList = $this->
object->getSolutionOrderingElementListForTestOutput(
567 $template =
new ilTemplate(
'tpl.il_as_qpl_ordering_output.html',
true,
true,
'Modules/TestQuestionPool');
570 $orderingGUI->setElementList($solutionOrderingElementList);
572 $template->setCurrentBlock(
'nested_ordering_output');
573 $template->setVariable(
'NESTED_ORDERING', $orderingGUI->getHTML());
576 $template->setVariable(
'QUESTIONTEXT', $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
606 $rbacsystem = $DIC[
'rbacsystem'];
607 $ilTabs = $DIC[
'ilTabs'];
609 $ilTabs->clearTargets();
611 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
612 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
613 $q_type = $this->
object->getQuestionType();
615 if (strlen($q_type)) {
616 $classname = $q_type .
"GUI";
617 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
618 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
622 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
626 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
627 array(
"edit",
"insert",
"exec_pg"),
637 $force_active =
false;
638 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
641 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
643 $commands =
$_POST[
"cmd"];
644 if (is_array($commands)) {
645 foreach ($commands as
$key => $value) {
646 if (preg_match(
"/^delete_.*/",
$key, $matches)) {
647 $force_active =
true;
655 array(
"orderNestedTerms",
"orderNestedPictures",
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"changeToPictures",
"uploadElementImage",
"changeToText",
"upanswers",
"downanswers",
"originalSyncForm"),
675 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
687 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
691 $tpl =
new ilTemplate(
'tpl.il_as_qpl_ordering_elem_fb.html',
true,
true,
'Modules/TestQuestionPool');
693 foreach ($this->object->getOrderingElementList() as $element) {
694 $feedback = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
695 $this->object->getId(),
697 $element->getPosition()
700 if ($this->object->isImageOrderingType()) {
701 $imgSrc = $this->
object->getImagePathWeb() . $element->getContent();
702 $tpl->setCurrentBlock(
'image');
703 $tpl->setVariable(
'IMG_SRC', $imgSrc);
705 $tpl->setCurrentBlock(
'text');
707 $tpl->setVariable(
'CONTENT', $element->getContent());
708 $tpl->parseCurrentBlock();
710 $tpl->setCurrentBlock(
'element');
711 $tpl->setVariable(
'FEEDBACK', $feedback);
712 $tpl->parseCurrentBlock();
715 return $this->
object->prepareTextareaOutput(
$tpl->get(),
true);
733 $ilDB = $DIC[
'ilDB'];
736 'SELECT depth FROM qpl_a_ordering WHERE question_fi = %s ORDER BY solution_key ASC',
738 array($this->object->getId())
741 $this->old_ordering_depth[] =
$row[
'depth'];
786 $this->object->getOrderingElementList()
795 foreach ($relevant_answers_chosen as $answer_chosen) {
796 $passdata[$answer_chosen[
'active_fi'] .
'-' . $answer_chosen[
'pass']][$answer_chosen[
'value2']] = $answer_chosen[
'value1'];
801 $hash = md5(implode(
'-',
$data));
803 foreach ($variants as $vkey => $variant) {
804 if ($variant[
'hash'] == $hash) {
810 $variants[
$key][
'hash'] = $hash;
811 $variants[
$key][
'count'] = 1;
815 $aggregate = array();
816 foreach ($variants as
$key => $variant_entry) {
817 $variant = $passdata[
$key];
819 foreach ($variant as $variant_key => $variant_line) {
821 $aggregated_info_for_answer[
'count'] = $variant_entry[
'count'];
822 foreach ($answers_defined_on_question as $element) {
825 if ($this->object->isImageOrderingType()) {
826 $element->setImageThumbnailPrefix($this->object->getThumbPrefix());
827 $element->setImagePathWeb($this->object->getImagePathWeb());
828 $element->setImagePathFs($this->object->getImagePath());
830 $src = $element->getPresentationImageUrl();
831 $alt = $element->getContent();
832 $content =
"<img src='{$src}' alt='{$alt}' title='{$alt}'/>";
834 $content = $element->getContent();
837 $aggregated_info_for_answer[
$i .
' - ' . $content]
841 $aggregate[] = $aggregated_info_for_answer;
853 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
855 foreach ($aggregate as $line_data) {
856 $tpl->setCurrentBlock(
'aggregaterow');
857 $count = array_shift($line_data);
859 foreach ($line_data as
$key => $line) {
860 $html .=
'<li>' . ++$line .
' - ' .
$key .
'</li>';
863 $tpl->setVariable(
'COUNT', $count);
866 $tpl->parseCurrentBlock();
873 if ($this->object->isImageOrderingType()) {
880 $content =
"<img src='{$src}' alt='{$alt}' title='{$alt}'/>";
895 foreach ($list as $elem) {
896 if ($elem->getIndentation() > $lastIndent) {
898 } elseif ($elem->getIndentation() < $lastIndent) {
899 $html .=
'</li></ul><li>';
900 } elseif (!$firstElem) {
901 $html .=
'</li><li>';
909 $lastIndent = $elem->getIndentation();
914 for (
$i = $lastIndent;
$i > 0;
$i--) {
915 $html .=
'</ul></li>';
925 $answersByActiveAndPass = array();
927 foreach ($relevantAnswers as
$row) {
928 $key = $row[
'active_fi'] .
':' . $row[
'pass'];
930 if (!isset($answersByActiveAndPass[
$key])) {
931 $answersByActiveAndPass[
$key] = array();
934 $answersByActiveAndPass[
$key][$row[
'value1']] = $row[
'value2'];
937 $solutionLists = array();
939 foreach ($answersByActiveAndPass as $indexedSolutions) {
940 $solutionLists[] = $this->
object->getSolutionOrderingElementList($indexedSolutions);
946 foreach ($solutionLists as $orderingElementList) {
947 $hash = $orderingElementList->getHash();
949 if (!isset($answers[$hash])) {
954 $answers[$hash] = array(
955 'answer' => $variantHtml,
'frequency' => 0
959 $answers[$hash][
'frequency']++;
962 return array_values($answers);
971 $orderingInput->prepareReprintable($this->
object);
981 $points->setValue($this->object->getPoints());
982 $points->setRequired(
true);
984 $points->setMinValue(0);
985 $points->setMinvalueShouldBeGreater(
true);
989 $header->setTitle($this->lng->txt(
'oq_header_ordering_elements'));
992 $orderingElementInput = $this->
object->buildNestedOrderingElementInputGui();
994 $this->
object->initOrderingElementAuthoringProperties($orderingElementInput);
996 $orderingElementInput->setElementList($this->object->getOrderingElementList());
998 $form->
addItem($orderingElementInput);
1006 $this->
object->setPoints((
float) $form->
getInput(
'points'));
1008 $submittedElementList = $this->
object->fetchSolutionListFromSubmittedForm($form);
1010 $curElementList = $this->
object->getOrderingElementList();
1013 $newElementList->setQuestionId($this->object->getId());
1015 foreach ($submittedElementList as $submittedElement) {
1016 if (!$curElementList->elementExistByRandomIdentifier($submittedElement->getRandomIdentifier())) {
1020 $curElement = $curElementList->getElementByRandomIdentifier($submittedElement->getRandomIdentifier());
1022 $curElement->setPosition($submittedElement->getPosition());
1024 if ($this->object->isOrderingTypeNested()) {
1025 $curElement->setIndentation($submittedElement->getIndentation());
1028 $newElementList->addElement($curElement);
1031 $this->
object->setOrderingElementList($newElementList);
isTestPresentationContext()
__construct($id=-1)
assOrderingQuestionGUI constructor
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
if(isset($_REQUEST['delete'])) $list
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
prepareReprintableCorrectionsForm(ilPropertyFormGUI $form)
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
getAnswerStatisticOrderingVariantHtml(ilAssOrderingElementList $list)
renderAggregateView($aggregate)
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
Adds the answer specific form parts to a question property form gui.
if(!array_key_exists('StateId', $_REQUEST)) $id
static buildInstance($questionId, $orderingElements=array())
const CSS_CLASS_FEEDBACK_CORRECT
isRenderPurposePlayback()
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
getSolutionOutput( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $forceCorrectSolution=false, $show_manual_scoring=false, $show_question_text=true)
Get the question solution output.
setClearAnswersOnWritingPostDataEnabled($clearAnswersOnWritingPostDataEnabled)
$clearAnswersOnWritingPostDataEnabled
setImagePathFs($imagePathFs)
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
setImagePathWeb($imagePathWeb)
getSpecificFeedbackOutput($userSolution)
writeQuestionGenericPostData()
const ORDERING_ELEMENT_FORM_FIELD_POSTVAR
foreach($_POST as $key=> $value) $res
isInteractivePresentation()
const OQ_PICTURES
Ordering question constants.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
if(isset($_POST['submit'])) $form
isRenderPurposeDemoplay()
getILIASPage($html="")
Returns the ILIAS Page around a question.
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...
special template class to simplify handling of ITX/PEAR
isAdjustmentEditContext()
getPresentationImageUrl()
isClearAnswersOnWritingPostDataEnabled()
Ordering question GUI representation.
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
const CSS_CLASS_FEEDBACK_WRONG
Basic GUI class for assessment questions.
setQuestionTabs()
Sets the ILIAS tabs for this question type.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
setImageThumbnailPrefix($imageThumbnailPrefix)
persistAuthoringForm($form)
saveTaxonomyAssignments()
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
addBackTab(ilTabsGUI $ilTabs)
writePostData($forceSaving=false)
{}
Class for ordering questions.
getPreview($show_question_only=false, $showInlineFeedback=false)
isRenderPurposePrintPdf()
Interface ilGuiAnswerScoringAdjustable.
getAnswersFrequency($relevantAnswers, $questionIndex)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
getAnswerStatisticOrderingElementHtml(ilAssOrderingElement $element)
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.