ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.assTextQuestionGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once './Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5require_once './Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6require_once './Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
7require_once './Modules/Test/classes/inc.AssessmentConstants.php';
8
24{
32 public function __construct($id = -1)
33 {
35 include_once "./Modules/TestQuestionPool/classes/class.assTextQuestion.php";
36 $this->object = new assTextQuestion();
37 if ($id >= 0) {
38 $this->object->loadFromDb($id);
39 }
40 }
41
45 protected function writePostData($always = false)
46 {
47 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
48 if (!$hasErrors) {
49 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
54 return 0;
55 }
56 return 1;
57 }
58
64 public function editQuestion($checkonly = false)
65 {
66 $save = $this->isSaveCommand();
67 $this->getQuestionTemplate();
68
69 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
70 $form = new ilPropertyFormGUI();
71 $this->editForm = $form;
72
73 $form->setFormAction($this->ctrl->getFormAction($this));
74 $form->setTitle($this->outQuestionType());
75 $form->setMultipart(true);
76 $form->setTableWidth("100%");
77 $form->setId("asstextquestion");
78
82
83
84 $this->populateTaxonomyFormSection($form);
85
87
88 $errors = false;
89
90 if ($save) {
91 $form->setValuesByPost();
92 $errors = !$form->checkInput();
93 $form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
94 if ($errors) {
95 $checkonly = false;
96 }
97 }
98
99 if (!$checkonly) {
100 $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
101 }
102 return $errors;
103 }
104
105 private static function buildAnswerTextOnlyArray($answers)
106 {
107 $answerTexts = array();
108
109 foreach ($answers as $answer) {
110 $answerTexts[] = $answer->getAnswertext();
111 }
112
113 return $answerTexts;
114 }
115
116 public function outAdditionalOutput()
117 {
118 }
119
120 public function magicAfterTestOutput()
121 {
122 // TODO - BEGIN: what exactly is done here? cant we use the parent method?
123
124 include_once "./Services/RTE/classes/class.ilRTE.php";
125 $rtestring = ilRTE::_getRTEClassname();
126 include_once "./Services/RTE/classes/class.$rtestring.php";
127 $rte = new $rtestring();
128 include_once "./Services/Object/classes/class.ilObject.php";
129 $obj_id = ilObject::_lookupObjectId($_GET["ref_id"]);
130 $obj_type = ilObject::_lookupType($_GET["ref_id"], true);
131 $rte->addUserTextEditor("textinput");
132 $this->outAdditionalOutput();
133
134 // TODO - END: what exactly is done here? cant we use the parent method?
135 }
136
143 {
144 return true;
145 }
146
160 public function getSolutionOutput(
161 $active_id,
162 $pass = null,
163 $graphicalOutput = false,
164 $result_output = false,
165 $show_question_only = true,
166 $show_feedback = false,
167 $show_correct_solution = false,
168 $show_manual_scoring = false,
169 $show_question_text = true
170 ) {
171 // get the solution of the user for the active pass or from the last pass if allowed
172
173 $user_solution = $this->getUserAnswer($active_id, $pass);
174
175 if (($active_id > 0) && (!$show_correct_solution)) {
176 $solution = $user_solution;
177 } else {
178 $solution = $this->getBestAnswer($this->renderPurposeSupportsFormHtml());
179 }
180
181 // generate the question output
182 include_once "./Services/UICore/classes/class.ilTemplate.php";
183 $template = new ilTemplate("tpl.il_as_qpl_text_question_output_solution.html", true, true, "Modules/TestQuestionPool");
184 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
185
186 $solution = $this->object->getHtmlUserSolutionPurifier()->purify($solution);
187 if ($this->renderPurposeSupportsFormHtml()) {
188 $template->setCurrentBlock('essay_div');
189 $template->setVariable("DIV_ESSAY", $this->object->prepareTextareaOutput($solution, true));
190 } else {
191 $template->setCurrentBlock('essay_textarea');
192 $template->setVariable("TA_ESSAY", $this->object->prepareTextareaOutput($solution, true, true));
193 }
194 $template->parseCurrentBlock();
195
196 $questiontext = $this->object->getQuestion();
197
198 if (!$show_correct_solution) {
199 $max_no_of_chars = $this->object->getMaxNumOfChars();
200
201 if ($max_no_of_chars == 0) {
202 $max_no_of_chars = ucfirst($this->lng->txt('unlimited'));
203 }
204
205 $act_no_of_chars = $this->object->countLetters($solution);
206 $template->setVariable("CHARACTER_INFO", '<b>' . $max_no_of_chars . '</b>' .
207 $this->lng->txt('answer_characters') . ' <b>' . $act_no_of_chars . '</b>');
208 }
209
210 if ($this->object->isWordCounterEnabled()) {
211 $template->setCurrentBlock('word_count');
212 $template->setVariable(
213 'WORD_COUNT',
214 $this->lng->txt('qst_essay_written_words') .
215 ' <b>' . $this->object->countWords($solution) . '</b>'
216 );
217 $template->parseCurrentBlock();
218 }
219
220 if (($active_id > 0) && (!$show_correct_solution)) {
221 if ($graphicalOutput) {
222 // output of ok/not ok icons for user entered solutions
223 $reached_points = $this->object->getReachedPoints($active_id, $pass);
224 if ($reached_points == $this->object->getMaximumPoints()) {
225 $template->setCurrentBlock("icon_ok");
226 $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
227 $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
228 $template->parseCurrentBlock();
229 } else {
230 $template->setCurrentBlock("icon_ok");
231 if ($reached_points > 0) {
232 $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.svg"));
233 $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive"));
234 } else {
235 $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
236 $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
237 }
238 $template->parseCurrentBlock();
239 }
240 }
241 }
242 if ($show_question_text == true) {
243 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
244 }
245 $questionoutput = $template->get();
246
247 $feedback = '';
248 if ($show_feedback) {
249 if (!$this->isTestPresentationContext()) {
250 $fb = $this->getGenericFeedbackOutput($active_id, $pass);
251 $feedback .= strlen($fb) ? $fb : '';
252 }
253
254 $fb = $this->getSpecificFeedbackOutput(
255 array($user_solution => '')
256 );
257
258 $feedback .= strlen($fb) ? $fb : '';
259 }
260 if (strlen($feedback)) {
261 $cssClass = (
262 $this->hasCorrectSolution($active_id, $pass) ?
264 );
265
266 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
267 $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
268 }
269
270 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
271
272 $solutionoutput = $solutiontemplate->get();
273 if (!$show_question_only) {
274 // get page object output
275 $solutionoutput = $this->getILIASPage($solutionoutput);
276 }
277 return $solutionoutput;
278 }
279
280
281 private function getBestAnswer($asHtml)
282 {
283 $answers = $this->object->getAnswers();
284 if (!count($answers)) {
285 return '';
286 }
287
288 if ($asHtml) {
289 $tplFile = 'tpl.il_as_qpl_text_question_best_solution_html.html';
290 } else {
291 $tplFile = 'tpl.il_as_qpl_text_question_best_solution_ta.html';
292 }
293
294 $tpl = new ilTemplate($tplFile, true, true, 'Modules/TestQuestionPool');
295
296 foreach ($answers as $answer) {
297 $keywordString = $answer->getAnswertext();
298
299 if (in_array($this->object->getKeywordRelation(), assTextQuestion::getScoringModesWithPointsByKeyword())) {
300 $keywordString .= ' ' . $this->lng->txt('for') . ' ';
301 $keywordString .= $answer->getPoints() . ' ' . $this->lng->txt('points');
302 }
303
304 $tpl->setCurrentBlock('keyword');
305 $tpl->setVariable('KEYWORD', $keywordString);
306 $tpl->parseCurrentBlock();
307 }
308
309 $tpl->setVariable('KEYWORD_HEADER', $this->lng->txt('solution_contain_keywords'));
310 $tpl->setVariable('SCORING_LABEL', $this->lng->txt('essay_scoring_mode') . ': ');
311
312 switch ($this->object->getKeywordRelation()) {
313 case 'any':
314 $tpl->setVariable('SCORING_MODE', $this->lng->txt('essay_scoring_mode_keyword_relation_any'));
315 break;
316 case 'all':
317 $tpl->setVariable('SCORING_MODE', $this->lng->txt('essay_scoring_mode_keyword_relation_all'));
318 break;
319 case 'one':
320 $tpl->setVariable('SCORING_MODE', $this->lng->txt('essay_scoring_mode_keyword_relation_one'));
321 break;
322 }
323
324 return $tpl->get();
325 }
326
327 private function getUserAnswer($active_id, $pass)
328 {
329 $user_solution = "";
330 $solutions = $this->object->getSolutionValues($active_id, $pass, !$this->getUseIntermediateSolution());
331 foreach ($solutions as $idx => $solution_value) {
332 $user_solution = $solution_value["value1"];
333 }
334 return $user_solution;
335 }
336
337 public function getPreview($show_question_only = false, $showInlineFeedback = false)
338 {
339 // generate the question output
340 include_once "./Services/UICore/classes/class.ilTemplate.php";
341 $template = new ilTemplate("tpl.il_as_qpl_text_question_output.html", true, true, "Modules/TestQuestionPool");
342 if ($this->object->getMaxNumOfChars()) {
343 $template->setCurrentBlock("maximum_char_hint");
344 $template->setVariable("MAXIMUM_CHAR_HINT", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()));
345 $template->parseCurrentBlock();
346 #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
347 $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
348 $template->parseCurrentBlock();
349 $template->setCurrentBlock("maxchars_counter");
350 $template->setVariable("QID", $this->object->getId());
351 $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
352 $template->setVariable("TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
353 $template->setVariable("CHARACTERS", $this->lng->txt("qst_essay_chars_remaining"));
354 $template->parseCurrentBlock();
355 }
356
357 if ($this->object->isWordCounterEnabled()) {
358 $template->setCurrentBlock("word_counter");
359 $template->setVariable("QID", $this->object->getId());
360 $template->setVariable("WORDCOUNTER", $this->lng->txt("qst_essay_allready_written_words"));
361 $template->parseCurrentBlock();
362 }
363
364 if (is_object($this->getPreviewSession())) {
365 $template->setVariable("ESSAY", ilUtil::prepareFormOutput(
366 $this->getPreviewSession()->getParticipantsSolution()
367 ));
368 }
369
370 $questiontext = $this->object->getQuestion();
371 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
372 $template->setVariable("QID", $this->object->getId());
373
374 $questionoutput = $template->get();
375
376 $questionoutput .= $this->getJsCode();
377
378 if (!$show_question_only) {
379 // get page object output
380 $questionoutput = $this->getILIASPage($questionoutput);
381 }
382 return $questionoutput;
383 }
384
385 public function getTestOutput($active_id, $pass = null, $is_postponed = false, $use_post_solutions = false, $inlineFeedback = false)
386 {
387 // get the solution of the user for the active pass or from the last pass if allowed
388 $user_solution = "";
389 if ($active_id) {
390 $solutions = null;
391 // hey: prevPassSolutions - obsolete due to central check
392 #include_once "./Modules/Test/classes/class.ilObjTest.php";
393 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
394 #{
395 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
396 #}
397 // hey.
398 $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
399 foreach ($solutions as $idx => $solution_value) {
400 $user_solution = $solution_value["value1"];
401 }
402 }
403
404 // generate the question output
405 include_once "./Services/UICore/classes/class.ilTemplate.php";
406 $template = new ilTemplate("tpl.il_as_qpl_text_question_output.html", true, true, "Modules/TestQuestionPool");
407 if ($this->object->getMaxNumOfChars()) {
408 $template->setCurrentBlock("maximum_char_hint");
409 $template->setVariable("MAXIMUM_CHAR_HINT", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()));
410 $template->parseCurrentBlock();
411 #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
412 $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
413 $template->parseCurrentBlock();
414 $template->setCurrentBlock("maxchars_counter");
415 $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
416 $template->setVariable("QID", $this->object->getId());
417 $template->setVariable("TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
418 $template->setVariable("CHARACTERS", $this->lng->txt("qst_essay_chars_remaining"));
419 $template->parseCurrentBlock();
420 }
421
422 if ($this->object->isWordCounterEnabled()) {
423 $template->setCurrentBlock("word_counter");
424 $template->setVariable("QID", $this->object->getId());
425 $template->setVariable("WORDCOUNTER", $this->lng->txt("qst_essay_allready_written_words"));
426 $template->parseCurrentBlock();
427 }
428
429 $template->setVariable("QID", $this->object->getId());
430 $template->setVariable("ESSAY", ilUtil::prepareFormOutput($user_solution));
431 $questiontext = $this->object->getQuestion();
432 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
433 $questionoutput = $template->get();
434
435 $questionoutput .= $this->getJsCode();
436
437 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
438 include_once "./Services/YUI/classes/class.ilYuiUtil.php";
440 return $pageoutput;
441 }
442
443 protected function getJsCode()
444 {
445 $tpl = new ilTemplate('tpl.charcounter.html', true, true, 'Modules/TestQuestionPool');
446
447 $tpl->setCurrentBlock('tinymce_handler');
448 $tpl->touchBlock('tinymce_handler');
449 $tpl->parseCurrentBlock();
450
451 if ($this->object->getMaxNumOfChars() > 0) {
452 $tpl->setCurrentBlock('letter_counter_js');
453 $tpl->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
454 $tpl->parseCurrentBlock();
455 }
456
457 if ($this->object->isWordCounterEnabled()) {
458 $tpl->setCurrentBlock('word_counter_js');
459 $tpl->touchBlock('word_counter_js');
460 $tpl->parseCurrentBlock();
461 }
462
463 $tpl->setCurrentBlock('counter_js');
464 $tpl->setVariable("QID", $this->object->getId());
465 $tpl->parseCurrentBlock();
466
467 return $tpl->get();
468 }
469
470 public function addSuggestedSolution()
471 {
472 $_SESSION["subquestion_index"] = 0;
473 if ($_POST["cmd"]["addSuggestedSolution"]) {
474 if ($this->writePostData()) {
476 $this->editQuestion();
477 return;
478 }
479 if (!$this->checkInput()) {
480 ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
481 $this->editQuestion();
482 return;
483 }
484 }
485 $this->object->saveToDb();
486 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
487 $this->tpl->setVariable("HEADER", $this->object->getTitle());
488 $this->getQuestionTemplate();
489 parent::addSuggestedSolution();
490 }
491
499 public function setQuestionTabs()
500 {
501 global $DIC;
502 $rbacsystem = $DIC['rbacsystem'];
503 $ilTabs = $DIC['ilTabs'];
504
505 $ilTabs->clearTargets();
506
507 $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
508 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
509 $q_type = $this->object->getQuestionType();
510
511 if (strlen($q_type)) {
512 $classname = $q_type . "GUI";
513 $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
514 $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
515 }
516
517 if ($_GET["q_id"]) {
518 if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
519 // edit page
520 $ilTabs->addTarget(
521 "edit_page",
522 $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
523 array("edit", "insert", "exec_pg"),
524 "",
525 "",
526 $force_active
527 );
528 }
529
530 $this->addTab_QuestionPreview($ilTabs);
531 }
532
533 $force_active = false;
534 if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
535 $url = "";
536 if ($classname) {
537 $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
538 }
539 // edit question properties
540 $ilTabs->addTarget(
541 "edit_question",
542 $url,
543 array("editQuestion", "save", "saveEdit", "originalSyncForm"),
544 $classname,
545 "",
546 $force_active
547 );
548 }
549
550 // add tab for question feedback within common class assQuestionGUI
551 $this->addTab_QuestionFeedback($ilTabs);
552
553 // add tab for question hint within common class assQuestionGUI
554 $this->addTab_QuestionHints($ilTabs);
555
556 // add tab for question's suggested solution within common class assQuestionGUI
557 $this->addTab_SuggestedSolution($ilTabs, $classname);
558
559 // Assessment of questions sub menu entry
560 if ($_GET["q_id"]) {
561 $ilTabs->addTarget(
562 "statistics",
563 $this->ctrl->getLinkTargetByClass($classname, "assessment"),
564 array("assessment"),
565 $classname,
566 ""
567 );
568 }
569
570 $this->addBackTab($ilTabs);
571 }
572
573 public function getSpecificFeedbackOutput($userSolution)
574 {
575 $firstValue1 = current($userSolution);
576
577 $feedback = '<table><tbody>';
578 $user_answer = ' ' . $firstValue1;
579
580 foreach ($this->object->getAnswers() as $idx => $ans) {
581 if ($this->object->isKeywordMatching($user_answer, $ans->getAnswertext())) {
582 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
583 $this->object->getId(),
584 0,
585 $idx
586 );
587 $feedback .= '<tr><td><b><i>' . $ans->getAnswertext() . '</i></b></td><td>';
588 $feedback .= $fb . '</td> </tr>';
589 }
590 }
591
592 $feedback .= '</tbody></table>';
593 return $this->object->prepareTextareaOutput($feedback, true);
594 }
595
597 {
598 $this->object->setWordCounterEnabled(isset($_POST['wordcounter']) && $_POST['wordcounter']);
599 $this->object->setMaxNumOfChars($_POST["maxchars"]);
600 $this->object->setTextRating($_POST["text_rating"]);
601 $this->object->setKeywordRelation($_POST['scoring_mode']);
602 }
603
605 {
606 switch ($this->object->getKeywordRelation()) {
607 case 'non':
608 $this->object->setAnswers(array());
609 $this->object->setPoints($_POST['non_keyword_points']);
610 break;
611 case 'any':
612 $this->object->setAnswers($_POST['any_keyword']);
613 $this->object->setPoints($this->object->getMaximumPoints());
614 break;
615 case 'all':
616 $this->object->setAnswers($_POST['all_keyword']);
617 $this->object->setPoints($_POST['all_keyword_points']);
618 break;
619 case 'one':
620 $this->object->setAnswers($_POST['one_keyword']);
621 $this->object->setPoints($_POST['one_keyword_points']);
622 break;
623 }
624 }
625
627 {
628 // wordcounter
629 $wordcounter = new ilCheckboxInputGUI($this->lng->txt('qst_essay_wordcounter_enabled'), 'wordcounter');
630 $wordcounter->setInfo($this->lng->txt('qst_essay_wordcounter_enabled_info'));
631 $wordcounter->setChecked($this->object->isWordCounterEnabled());
632 $form->addItem($wordcounter);
633
634 // maxchars
635 $maxchars = new ilNumberInputGUI($this->lng->txt("maxchars"), "maxchars");
636 $maxchars->setSize(5);
637 if ($this->object->getMaxNumOfChars() > 0) {
638 $maxchars->setValue($this->object->getMaxNumOfChars());
639 }
640 $maxchars->setInfo($this->lng->txt("description_maxchars"));
641 $form->addItem($maxchars);
642
643 // text rating
644 $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "text_rating");
645 $text_options = array(
646 "ci" => $this->lng->txt("cloze_textgap_case_insensitive"),
647 "cs" => $this->lng->txt("cloze_textgap_case_sensitive"),
648 "l1" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1"),
649 "l2" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2"),
650 "l3" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3"),
651 "l4" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4"),
652 "l5" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5")
653 );
654 $textrating->setOptions($text_options);
655 $textrating->setValue($this->object->getTextRating());
656 $form->addItem($textrating);
657
658 return $form;
659 }
660
662 {
663 $scoringMode = new ilRadioGroupInputGUI(
664 $this->lng->txt('essay_scoring_mode'),
665 'scoring_mode'
666 );
667
668 $scoringOptionNone = new ilRadioOption(
669 $this->lng->txt('essay_scoring_mode_without_keywords'),
670 'non',
671 $this->lng->txt(
672 'essay_scoring_mode_without_keywords_desc'
673 )
674 );
675 $scoringOptionAnyKeyword = new ilRadioOption(
676 $this->lng->txt('essay_scoring_mode_keyword_relation_any'),
677 'any',
678 $this->lng->txt(
679 'essay_scoring_mode_keyword_relation_any_desc'
680 )
681 );
682 $scoringOptionAllKeyword = new ilRadioOption(
683 $this->lng->txt('essay_scoring_mode_keyword_relation_all'),
684 'all',
685 $this->lng->txt(
686 'essay_scoring_mode_keyword_relation_all_desc'
687 )
688 );
689 $scoringOptionOneKeyword = new ilRadioOption(
690 $this->lng->txt('essay_scoring_mode_keyword_relation_one'),
691 'one',
692 $this->lng->txt(
693 'essay_scoring_mode_keyword_relation_one_desc'
694 )
695 );
696
697 $scoringMode->addOption($scoringOptionNone);
698 $scoringMode->addOption($scoringOptionAnyKeyword);
699 $scoringMode->addOption($scoringOptionAllKeyword);
700 $scoringMode->addOption($scoringOptionOneKeyword);
701 $scoringMode->setRequired(true);
702 $scoringMode->setValue(
703 strlen($this->object->getKeywordRelation()) ? $this->object->getKeywordRelation(
704 ) : 'non'
705 );
706
707 if ($this->object->getAnswerCount() == 0) {
708 $this->object->addAnswer("", 1, 0, 0);
709 }
710 require_once "./Modules/TestQuestionPool/classes/class.ilEssayKeywordWizardInputGUI.php";
711
712 // Without Keywords
713 $nonKeywordPoints = new ilNumberInputGUI($this->lng->txt("points"), "non_keyword_points");
714 $nonKeywordPoints->allowDecimals(true);
715 $nonKeywordPoints->setValue($this->object->getPoints());
716 $nonKeywordPoints->setRequired(true);
717 $nonKeywordPoints->setSize(3);
718 $nonKeywordPoints->setMinValue(0.0);
719 $nonKeywordPoints->setMinvalueShouldBeGreater(true);
720 $scoringOptionNone->addSubItem($nonKeywordPoints);
721
722 // Any Keyword
723 $anyKeyword = new ilEssayKeywordWizardInputGUI($this->lng->txt("answers"), "any_keyword");
724 $anyKeyword->setRequired(true);
725 $anyKeyword->setQuestionObject($this->object);
726 $anyKeyword->setSingleline(true);
727 $anyKeyword->setValues($this->object->getAnswers());
728 $scoringOptionAnyKeyword->addSubItem($anyKeyword);
729
730 // All Keywords
731 $allKeyword = new ilTextWizardInputGUI($this->lng->txt("answers"), "all_keyword");
732 $allKeyword->setRequired(true);
733 //$allKeyword->setQuestionObject($this->object);
734 //$allKeyword->setSingleline(TRUE);
735 $allKeyword->setValues(self::buildAnswerTextOnlyArray($this->object->getAnswers()));
736 $scoringOptionAllKeyword->addSubItem($allKeyword);
737 $allKeywordPoints = new ilNumberInputGUI($this->lng->txt("points"), "all_keyword_points");
738 $allKeywordPoints->allowDecimals(true);
739 $allKeywordPoints->setValue($this->object->getPoints());
740 $allKeywordPoints->setRequired(true);
741 $allKeywordPoints->setSize(3);
742 $allKeywordPoints->setMinValue(0.0);
743 $allKeywordPoints->setMinvalueShouldBeGreater(true);
744 $scoringOptionAllKeyword->addSubItem($allKeywordPoints);
745
746 // One Keywords
747 $oneKeyword = new ilTextWizardInputGUI($this->lng->txt("answers"), "one_keyword");
748 $oneKeyword->setRequired(true);
749 //$oneKeyword->setQuestionObject($this->object);
750 //$oneKeyword->setSingleline(TRUE);
751 $oneKeyword->setValues(self::buildAnswerTextOnlyArray($this->object->getAnswers()));
752 $scoringOptionOneKeyword->addSubItem($oneKeyword);
753 $oneKeywordPoints = new ilNumberInputGUI($this->lng->txt("points"), "one_keyword_points");
754 $oneKeywordPoints->allowDecimals(true);
755 $oneKeywordPoints->setValue($this->object->getPoints());
756 $oneKeywordPoints->setRequired(true);
757 $oneKeywordPoints->setSize(3);
758 $oneKeywordPoints->setMinValue(0.0);
759 $oneKeywordPoints->setMinvalueShouldBeGreater(true);
760 $scoringOptionOneKeyword->addSubItem($oneKeywordPoints);
761
762 $form->addItem($scoringMode);
763 }
764
775 {
776 return array();
777 }
778
789 {
790 return array();
791 }
792
801 public function getAggregatedAnswersView($relevant_answers)
802 {
803 return ''; //print_r($relevant_answers,true);
804 }
805
807 {
808 return false;
809 }
810
811 public function getAnswersFrequency($relevantAnswers, $questionIndex)
812 {
813 }
814
816 {
818 $this->populateAnswerSpecificFormPart($form);
819
820 $form->removeItemByPostVar('maxchars');
821 }
822
827 {
828 $this->writeQuestionSpecificPostData($form);
829 $this->writeAnswerSpecificPostData($form);
830 }
831}
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
Basic GUI class for assessment questions.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
getILIASPage($html="")
Returns the ILIAS Page around a question.
getQuestionTemplate()
get question template
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
addBackTab(ilTabsGUI $ilTabs)
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question,...
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Text question GUI representation.
getAnswersFrequency($relevantAnswers, $questionIndex)
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
getPreview($show_question_only=false, $showInlineFeedback=false)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
writePostData($always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
__construct($id=-1)
assTextQuestionGUI constructor
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
setQuestionTabs()
Sets the ILIAS tabs for this question type.
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
getTestOutput($active_id, $pass=null, $is_postponed=false, $use_post_solutions=false, $inlineFeedback=false)
getSpecificFeedbackOutput($userSolution)
Returns the answer specific feedback for the question.
getUserAnswer($active_id, $pass)
static buildAnswerTextOnlyArray($answers)
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.
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
Class for text questions.
static getScoringModesWithPointsByKeyword()
This class represents a checkbox property in a property form.
This class represents a number property in a property form.
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
removeItemByPostVar($a_post_var, $a_remove_unused_headers=false)
Remove Item.
static _getRTEClassname()
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
special template class to simplify handling of ITX/PEAR
This class represents a text wizard property in a property form.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
static initDomEvent(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI DomEvent.
Interface ilGuiAnswerScoringAdjustable.
Interface ilGuiQuestionScoringAdjustable.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$url
$errors
$DIC
Definition: xapitoken.php:46