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();
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");
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");
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));
398 $form->setTableWidth(
"100%");
399 $form->setId(
"ordering");
407 $form->addSpecificOrderingQuestionCommandButtons($this->
object);
408 $form->addGenericAssessmentQuestionCommandButtons($this->
object);
431 $graphicalOutput =
false,
432 $result_output =
false,
433 $show_question_only =
true,
434 $show_feedback =
false,
435 $forceCorrectSolution =
false,
436 $show_manual_scoring =
false,
437 $show_question_text =
true 439 $solutionOrderingList = $this->
object->getOrderingElementListForSolutionOutput(
440 $forceCorrectSolution,
445 $answers_gui = $this->
object->buildNestedOrderingElementInputGui();
447 if ($forceCorrectSolution) {
453 $answers_gui->setInteractionEnabled(
false);
455 $answers_gui->setElementList($solutionOrderingList);
457 $answers_gui->setCorrectnessTrueElementList(
458 $solutionOrderingList->getParityTrueElementList($this->object->getOrderingElementList())
461 $solution_html = $answers_gui->getHTML();
463 $template =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
464 $template->setVariable(
'SOLUTION_OUTPUT', $solution_html);
465 if ($show_question_text==
true) {
466 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(),
true));
470 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
471 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
473 if ($show_feedback) {
478 $feedback .= strlen($fb) ? $fb :
'';
482 $feedback .= strlen($fb) ? $fb :
'';
484 if (strlen($feedback)) {
490 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
491 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($feedback,
true));
495 if ($show_question_only) {
496 return $solutiontemplate->get();
505 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
508 $solutionOrderingElementList = unserialize(
512 $solutionOrderingElementList = $this->
object->getShuffledOrderingElementList();
515 $answers = $this->
object->buildNestedOrderingElementInputGui();
516 $answers->setNestingEnabled($this->
object->isOrderingTypeNested());
519 $answers->setElementList($solutionOrderingElementList);
521 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output.html",
true,
true,
"Modules/TestQuestionPool");
523 $template->setCurrentBlock(
'nested_ordering_output');
524 $template->setVariable(
'NESTED_ORDERING', $answers->getHTML());
527 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(),
true));
529 if ($show_question_only) {
539 public function getTestOutput($activeId,
$pass, $isPostponed =
false, $userSolutionPost =
false, $inlineFeedback =
false)
543 $userSolutionPost = is_array($userSolutionPost) ? $userSolutionPost :
array();
546 $orderingGUI = $this->
object->buildNestedOrderingElementInputGui();
547 $orderingGUI->setNestingEnabled($this->
object->isOrderingTypeNested());
549 $solutionOrderingElementList = $this->
object->getSolutionOrderingElementListForTestOutput(
556 $template =
new ilTemplate(
'tpl.il_as_qpl_ordering_output.html',
true,
true,
'Modules/TestQuestionPool');
559 $orderingGUI->setElementList($solutionOrderingElementList);
561 $template->setCurrentBlock(
'nested_ordering_output');
562 $template->setVariable(
'NESTED_ORDERING', $orderingGUI->getHTML());
565 $template->setVariable(
'QUESTIONTEXT', $this->
object->prepareTextareaOutput($this->object->getQuestion(),
true));
594 global $rbacsystem, $ilTabs;
596 $ilTabs->clearTargets();
598 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
599 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
600 $q_type = $this->
object->getQuestionType();
602 if (strlen($q_type)) {
603 $classname = $q_type .
"GUI";
604 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
605 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
609 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
613 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
614 array(
"edit",
"insert",
"exec_pg"),
624 $force_active =
false;
625 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
628 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
630 $commands =
$_POST[
"cmd"];
631 if (is_array($commands)) {
632 foreach ($commands as
$key => $value) {
633 if (preg_match(
"/^delete_.*/",
$key, $matches)) {
634 $force_active =
true;
642 array(
"orderNestedTerms",
"orderNestedPictures",
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"changeToPictures",
"uploadElementImage",
"changeToText",
"upanswers",
"downanswers",
"originalSyncForm"),
662 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
674 if (!$this->
object->feedbackOBJ->specificAnswerFeedbackExists($this->object->getOrderingElementList())) {
678 $tpl =
new ilTemplate(
'tpl.il_as_qpl_ordering_elem_fb.html',
true,
true,
'Modules/TestQuestionPool');
680 foreach ($this->
object->getOrderingElementList() as $element) {
681 $feedback = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
683 $element->getPosition()
686 if ($this->
object->isImageOrderingType()) {
687 $imgSrc = $this->
object->getImagePathWeb() . $element->getContent();
688 $tpl->setCurrentBlock(
'image');
689 $tpl->setVariable(
'IMG_SRC', $imgSrc);
691 $tpl->setCurrentBlock(
'text');
693 $tpl->setVariable(
'CONTENT', $element->getContent());
694 $tpl->parseCurrentBlock();
696 $tpl->setCurrentBlock(
'element');
697 $tpl->setVariable(
'FEEDBACK', $feedback);
698 $tpl->parseCurrentBlock();
701 return $this->
object->prepareTextareaOutput(
$tpl->get(),
true);
720 $res = $ilDB->queryF(
721 'SELECT depth FROM qpl_a_ordering WHERE question_fi = %s ORDER BY solution_key ASC',
725 while (
$row = $ilDB->fetchAssoc(
$res)) {
726 $this->old_ordering_depth[] =
$row[
'depth'];
771 $this->
object->getOrderingElementList()
780 foreach ($relevant_answers_chosen as $answer_chosen) {
781 $passdata[$answer_chosen[
'active_fi'] .
'-' . $answer_chosen[
'pass']][$answer_chosen[
'value2']] = $answer_chosen[
'value1'];
786 $hash = md5(implode(
'-',
$data));
788 foreach ($variants as $vkey => $variant) {
789 if ($variant[
'hash'] == $hash) {
795 $variants[
$key][
'hash'] = $hash;
796 $variants[
$key][
'count'] = 1;
800 $aggregate =
array();
801 foreach ($variants as
$key => $variant_entry) {
802 $variant = $passdata[
$key];
804 foreach ($variant as $variant_key => $variant_line) {
806 $aggregated_info_for_answer[
'count'] = $variant_entry[
'count'];
807 foreach ($answers_defined_on_question as $element) {
810 if ($this->
object->isImageOrderingType()) {
811 $element->setImageThumbnailPrefix($this->
object->getThumbPrefix());
812 $element->setImagePathWeb($this->
object->getImagePathWeb());
813 $element->setImagePathFs($this->
object->getImagePath());
815 $src = $element->getPresentationImageUrl();
816 $alt = $element->getContent();
817 $content =
"<img src='{$src}' alt='{$alt}' title='{$alt}'/>";
819 $content = $element->getContent();
822 $aggregated_info_for_answer[
$i .
' - ' . $content]
826 $aggregate[] = $aggregated_info_for_answer;
838 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
840 foreach ($aggregate as $line_data) {
841 $tpl->setCurrentBlock(
'aggregaterow');
842 $count = array_shift($line_data);
844 foreach ($line_data as
$key => $line) {
845 $html .=
'<li>' . ++$line .
' - ' .
$key .
'</li>';
848 $tpl->setVariable(
'COUNT', $count);
851 $tpl->parseCurrentBlock();
isTestPresentationContext()
__construct($id=-1)
assOrderingQuestionGUI constructor
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
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
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)
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
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
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()
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.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
persistAuthoringForm($form)
saveTaxonomyAssignments()
Create new PHPExcel object
obj_idprivate
addBackTab(ilTabsGUI $ilTabs)
writePostData($forceSaving=false)
{}
getSpecificFeedbackOutput($active_id, $pass)
Class for ordering questions.
getPreview($show_question_only=false, $showInlineFeedback=false)
isRenderPurposePrintPdf()
Interface ilGuiAnswerScoringAdjustable.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.