24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
51 include_once
"./Modules/TestQuestionPool/classes/class.assTextQuestion.php";
55 $this->
object->loadFromDb($id);
67 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
70 $this->
object->setTitle(
$_POST[
"title"]);
71 $this->
object->setAuthor(
$_POST[
"author"]);
72 $this->
object->setComment(
$_POST[
"comment"]);
73 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
74 $questiontext =
$_POST[
"question"];
75 $this->
object->setQuestion($questiontext);
76 $this->
object->setMaxNumOfChars(
$_POST[
"maxchars"]);
77 $this->
object->setTextRating(
$_POST[
"text_rating"]);
80 $this->
object->setNrOfTries(
$_POST[
'nr_of_tries']);
82 $this->
object->setEstimatedWorkingTime(
87 $this->
object->setKeywordRelation(
$_POST[
'scoring_mode']);
89 switch( $this->object->getKeywordRelation() )
94 $this->
object->setAnswers(array());
95 $this->
object->setPoints(
$_POST[
'non_keyword_points']);
100 $this->
object->setAnswers(
$_POST[
'any_keyword']);
101 $this->
object->setPoints($this->object->getMaximumPoints());
105 $this->
object->setAnswers(
$_POST[
'all_keyword']);
106 $this->
object->setPoints(
$_POST[
'all_keyword_points']);
111 $this->
object->setAnswers(
$_POST[
'one_keyword']);
112 $this->
object->setPoints(
$_POST[
'one_keyword_points']);
134 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
136 $form->setFormAction($this->ctrl->getFormAction($this));
138 $form->setMultipart(TRUE);
139 $form->setTableWidth(
"100%");
140 $form->setId(
"asstextquestion");
148 if ($this->object->getMaxNumOfChars() > 0) $maxchars->setValue($this->object->getMaxNumOfChars());
149 $maxchars->setInfo($this->lng->txt(
"description_maxchars"));
150 $form->addItem($maxchars);
153 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
154 $text_options = array(
155 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
156 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
157 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
158 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
159 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
160 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
161 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
163 $textrating->setOptions($text_options);
164 $textrating->setValue($this->object->getTextRating());
165 $form->addItem($textrating);
169 if( $this->object->getAnswerCount() == 0 )
171 $this->
object->addAnswer(
"", 1, 0, 0);
175 $this->lng->txt(
'essay_scoring_mode'),
'scoring_mode'
178 $scoringOptionNone =
new ilRadioOption( $this->lng->txt(
'essay_scoring_mode_without_keywords'),
179 'non', $this->lng->txt(
'essay_scoring_mode_without_keywords_desc')
181 $scoringOptionAnyKeyword =
new ilRadioOption( $this->lng->txt(
'essay_scoring_mode_keyword_relation_any'),
182 'any', $this->lng->txt(
'essay_scoring_mode_keyword_relation_any_desc')
184 $scoringOptionAllKeyword =
new ilRadioOption( $this->lng->txt(
'essay_scoring_mode_keyword_relation_all'),
185 'all', $this->lng->txt(
'essay_scoring_mode_keyword_relation_all_desc')
187 $scoringOptionOneKeyword =
new ilRadioOption( $this->lng->txt(
'essay_scoring_mode_keyword_relation_one'),
188 'one', $this->lng->txt(
'essay_scoring_mode_keyword_relation_one_desc')
191 $scoringMode->addOption($scoringOptionNone);
192 $scoringMode->addOption($scoringOptionAnyKeyword);
193 $scoringMode->addOption($scoringOptionAllKeyword);
194 $scoringMode->addOption($scoringOptionOneKeyword);
195 $scoringMode->setRequired(
true);
196 $scoringMode->
setValue(strlen($this->object->getKeywordRelation()) ? $this->object->getKeywordRelation() :
'non');
198 require_once
"./Modules/TestQuestionPool/classes/class.ilEssayKeywordWizardInputGUI.php";
201 $nonKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points"),
"non_keyword_points");
202 $nonKeywordPoints->
setValue($this->object->getPoints());
203 $nonKeywordPoints->setRequired(TRUE);
204 $nonKeywordPoints->setSize(3);
205 $nonKeywordPoints->setMinValue(0.0);
206 $nonKeywordPoints->setMinvalueShouldBeGreater(
true);
207 $scoringOptionNone->
addSubItem($nonKeywordPoints);
212 $anyKeyword->setQuestionObject($this->
object);
213 $anyKeyword->setSingleline(TRUE);
214 $anyKeyword->setValues($this->object->getAnswers());
215 $scoringOptionAnyKeyword->
addSubItem($anyKeyword);
222 $allKeyword->setValues(self::buildAnswerTextOnlyArray($this->object->getAnswers()));
223 $scoringOptionAllKeyword->
addSubItem($allKeyword);
224 $allKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points"),
"all_keyword_points");
225 $allKeywordPoints->
setValue($this->object->getPoints());
226 $allKeywordPoints->setRequired(TRUE);
227 $allKeywordPoints->setSize(3);
228 $allKeywordPoints->setMinValue(0.0);
229 $allKeywordPoints->setMinvalueShouldBeGreater(
true);
230 $scoringOptionAllKeyword->
addSubItem($allKeywordPoints);
237 $oneKeyword->setValues(self::buildAnswerTextOnlyArray($this->object->getAnswers()));
238 $scoringOptionOneKeyword->
addSubItem($oneKeyword);
239 $oneKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points"),
"one_keyword_points");
240 $oneKeywordPoints->
setValue($this->object->getPoints());
241 $oneKeywordPoints->setRequired(TRUE);
242 $oneKeywordPoints->setSize(3);
243 $oneKeywordPoints->setMinValue(0.0);
244 $oneKeywordPoints->setMinvalueShouldBeGreater(
true);
245 $scoringOptionOneKeyword->
addSubItem($oneKeywordPoints);
247 $form->addItem($scoringMode);
255 $form->setValuesByPost();
256 $errors = !$form->checkInput();
257 $form->setValuesByPost();
258 if (
$errors) $checkonly =
false;
261 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
267 $answerTexts = array();
269 foreach($answers as $answer)
271 $answerTexts[] = $answer->answertext;
279 if ($this->object->getMaxNumOfChars() > 0)
281 $this->tpl->addBlockFile(
"CONTENT_BLOCK",
"charcounter",
"tpl.charcounter.html",
"Modules/TestQuestionPool");
282 $this->tpl->setCurrentBlock(
"charcounter");
283 $this->tpl->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
284 $this->tpl->parseCurrentBlock();
290 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
291 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
292 $this->tpl->setVariable(
"FORMACTION", $formaction);
293 include_once
"./Services/RTE/classes/class.ilRTE.php";
295 include_once
"./Services/RTE/classes/class.$rtestring.php";
296 $rte =
new $rtestring(
'3.4.7');
297 include_once
"./Services/Object/classes/class.ilObject.php";
300 $rte->addUserTextEditor(
"textinput");
320 $graphicalOutput = FALSE,
321 $result_output = FALSE,
322 $show_question_only = TRUE,
323 $show_feedback = FALSE,
324 $show_correct_solution = FALSE,
325 $show_manual_scoring = FALSE,
326 $show_question_text = TRUE
331 if (($active_id > 0) && (!$show_correct_solution))
342 include_once
"./Services/UICore/classes/class.ilTemplate.php";
343 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
344 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
346 $solution = $this->
object->getHtmlUserSolutionPurifier()->purify($solution);
348 $template->setVariable(
"ESSAY", $this->object->prepareTextareaOutput($solution, TRUE));
349 $questiontext = $this->
object->getQuestion();
351 if (!$show_correct_solution)
353 $max_no_of_chars = $this->
object->getMaxNumOfChars();
355 if ($max_no_of_chars == 0)
357 $max_no_of_chars = ucfirst($this->lng->txt(
'unlimited'));
360 $act_no_of_chars = strlen(strip_tags($user_solution));
361 $template->setVariable(
"CHARACTER_INFO",
'<b>' . $max_no_of_chars .
'</b>' .
362 $this->lng->txt(
'answer_characters') .
' <b>' . $act_no_of_chars .
'</b>');
364 if (($active_id > 0) && (!$show_correct_solution))
366 if ($graphicalOutput)
369 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
370 if ($reached_points == $this->object->getMaximumPoints())
372 $template->setCurrentBlock(
"icon_ok");
374 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
375 $template->parseCurrentBlock();
379 $template->setCurrentBlock(
"icon_ok");
380 if ($reached_points > 0)
383 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
388 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
390 $template->parseCurrentBlock();
394 if ($show_question_text==
true)
396 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
398 $questionoutput = $template->get();
404 $feedback .= strlen($fb) ? $fb :
'';
407 $feedback .= strlen($fb) ? $fb :
'';
409 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
411 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
413 $solutionoutput = $solutiontemplate->get();
414 if (!$show_question_only)
417 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
419 return $solutionoutput;
424 $answers = $this->
object->getAnswers();
425 if (count( $answers ))
427 $user_solution = $this->lng->txt(
"solution_contain_keywords" ) .
"<ul>";
429 foreach ($answers as $answer)
431 $user_solution .=
'<li>'. $answer->getAnswertext();
435 $user_solution .=
' ' . $this->lng->txt(
'for') .
' ';
436 $user_solution .= $answer->getPoints() .
' ' . $this->lng->txt(
'points') .
'</li>';
439 $user_solution .=
'</ul>';
441 $user_solution .= $this->lng->txt(
'essay_scoring_mode') .
': ';
443 switch( $this->object->getKeywordRelation() )
446 $user_solution .= $this->lng->txt(
'essay_scoring_mode_keyword_relation_any');
449 $user_solution .= $this->lng->txt(
'essay_scoring_mode_keyword_relation_all');
452 $user_solution .= $this->lng->txt(
'essay_scoring_mode_keyword_relation_one');
456 return $user_solution;
462 $solutions = $this->
object->getSolutionValues( $active_id,
$pass );
463 foreach ($solutions as $idx => $solution_value)
465 $user_solution = $solution_value[
"value1"];
467 return $user_solution;
473 include_once
"./Services/UICore/classes/class.ilTemplate.php";
474 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
475 if ($this->object->getMaxNumOfChars())
477 $template->setCurrentBlock(
"maximum_char_hint");
478 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
479 $template->parseCurrentBlock();
480 #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
481 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
482 $template->parseCurrentBlock();
483 $template->setCurrentBlock(
"maxchars_counter");
484 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
485 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
486 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
487 $template->parseCurrentBlock();
489 $questiontext = $this->
object->getQuestion();
490 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
491 $questionoutput = $template->get();
492 if (!$show_question_only)
497 return $questionoutput;
507 include_once
"./Modules/Test/classes/class.ilObjTest.php";
512 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
513 foreach ($solutions as $idx => $solution_value)
515 $user_solution = $solution_value[
"value1"];
520 include_once
"./Services/UICore/classes/class.ilTemplate.php";
521 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
522 if ($this->object->getMaxNumOfChars())
524 $template->setCurrentBlock(
"maximum_char_hint");
525 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
526 $template->parseCurrentBlock();
527 #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
528 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
529 $template->parseCurrentBlock();
530 $template->setCurrentBlock(
"maxchars_counter");
531 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
532 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
533 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
534 $template->parseCurrentBlock();
537 $questiontext = $this->
object->getQuestion();
538 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
539 $questionoutput = $template->get();
540 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
541 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
549 if (
$_POST[
"cmd"][
"addSuggestedSolution"])
557 if (!$this->checkInput())
559 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
564 $this->
object->saveToDb();
565 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
566 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
578 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
580 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
581 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
582 foreach ($this->object->getAnswers() as $index => $answer)
584 $this->
object->saveFeedbackSingleAnswer($index,
$_POST[
"feedback_answer_$index"]);
587 $this->
object->cleanupMediaObjectUsage();
600 global $rbacsystem, $ilTabs;
602 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
603 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
604 $q_type = $this->
object->getQuestionType();
608 $classname = $q_type .
"GUI";
609 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
610 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
615 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
618 $ilTabs->addTarget(
"edit_page",
619 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
620 array(
"edit",
"insert",
"exec_pg"),
621 "",
"", $force_active);
625 $ilTabs->addTarget(
"preview",
626 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
628 "ilPageObjectGUI",
"", $force_active);
631 $force_active =
false;
632 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
635 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
637 $ilTabs->addTarget(
"edit_question",
639 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
640 $classname,
"", $force_active);
645 $ilTabs->addTarget(
"feedback",
646 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
647 array(
"feedback",
"saveFeedback"),
656 $ilTabs->addTarget(
"solution_hint",
657 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
658 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
659 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
669 $ilTabs->addTarget(
"statistics",
670 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
675 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
680 global $___test_express_mode;
682 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
683 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
687 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
692 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
698 $feedback =
'<table><tbody>';
699 $user_answers = $this->
object->getSolutionValues($active_id);
700 $user_answer =
' '. $user_answers[0][
'value1'];
702 foreach ($this->object->getAnswers() as $idx => $ans)
704 if ($this->object->isKeywordMatching($user_answer, $ans->getAnswertext() ))
706 $feedback .=
'<tr><td><b><i>' . $ans->getAnswertext() .
'</i></b></td><td>';
707 $feedback .= $this->
object->getFeedbackSingleAnswer($idx) .
'</td> </tr>';
711 $feedback .=
'</tbody></table>';
712 return $this->
object->prepareTextareaOutput($feedback, TRUE);
721 $save = (strcmp($this->ctrl->getCmd(),
"saveFeedback") == 0) ? TRUE : FALSE;
722 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
724 $form->setFormAction($this->ctrl->getFormAction($this));
725 $form->setTitle($this->lng->txt(
'feedback_answers'));
726 $form->setTableWidth(
"98%");
727 $form->setId(
"feedback");
729 $complete =
new ilTextAreaInputGUI($this->lng->txt(
"feedback_complete_solution"),
"feedback_complete");
730 $complete->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)));
731 $complete->setRequired(
false);
732 $complete->setRows(10);
733 $complete->setCols(80);
736 $complete->setUseRte(
true);
738 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
740 $complete->addPlugin(
"latex");
741 $complete->addButton(
"latex");
742 $complete->addButton(
"pastelatex");
743 $complete->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
744 $form->addItem($complete);
746 $incomplete =
new ilTextAreaInputGUI($this->lng->txt(
"feedback_incomplete_solution"),
"feedback_incomplete");
747 $incomplete->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)));
748 $incomplete->setRequired(
false);
749 $incomplete->setRows(10);
750 $incomplete->setCols(80);
753 $incomplete->setUseRte(
true);
755 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
757 $incomplete->addPlugin(
"latex");
758 $incomplete->addButton(
"latex");
759 $incomplete->addButton(
"pastelatex");
760 $incomplete->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
761 $form->addItem($incomplete);
765 foreach ($this->object->getAnswers() as $index => $answer)
767 $caption = $ordinal = $index+1;
768 $caption .=
'. ' . $answer->getAnswertext();
770 $answerobj =
new ilTextAreaInputGUI($this->object->prepareTextareaOutput($caption,
true),
"feedback_answer_$index");
771 $answerobj->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackSingleAnswer($index)));
772 $answerobj->setRequired(
false);
773 $answerobj->setRows(10);
774 $answerobj->setCols(80);
775 $answerobj->setUseRte(
true);
776 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
778 $answerobj->addPlugin(
"latex");
779 $answerobj->addButton(
"latex");
780 $answerobj->addButton(
"pastelatex");
781 $answerobj->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
782 $form->addItem($answerobj);
789 $form->addCommandButton(
"saveFeedback", $this->lng->txt(
"save"));
793 $form->setValuesByPost();
794 $errors = !$form->checkInput();
795 $form->setValuesByPost();
797 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());