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';
34 parent::__construct();
35 include_once
"./Modules/TestQuestionPool/classes/class.assTextQuestion.php";
38 $this->
object->loadFromDb(
$id);
47 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
49 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
69 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
71 $this->editForm =
$form;
73 $form->setFormAction($this->ctrl->getFormAction($this));
75 $form->setMultipart(
true);
76 $form->setTableWidth(
"100%");
77 $form->setId(
"asstextquestion");
91 $form->setValuesByPost();
93 $form->setValuesByPost();
100 $this->tpl->setVariable(
"QUESTION_DATA",
$form->getHTML());
107 $answerTexts = array();
109 foreach ($answers as $answer) {
110 $answerTexts[] = $answer->getAnswertext();
124 include_once
"./Services/RTE/classes/class.ilRTE.php";
126 include_once
"./Services/RTE/classes/class.$rtestring.php";
127 $rte =
new $rtestring();
128 include_once
"./Services/Object/classes/class.ilObject.php";
131 $rte->addUserTextEditor(
"textinput");
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 175 if (($active_id > 0) && (!$show_correct_solution)) {
176 $solution = $user_solution;
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");
186 $solution = $this->
object->getHtmlUserSolutionPurifier()->purify($solution);
189 $template->setVariable(
"DIV_ESSAY", $this->object->prepareTextareaOutput($solution,
true));
191 $template->setCurrentBlock(
'essay_textarea');
192 $template->setVariable(
"TA_ESSAY", $this->object->prepareTextareaOutput($solution,
true,
true));
196 $questiontext = $this->
object->getQuestion();
198 if (!$show_correct_solution) {
199 $max_no_of_chars = $this->
object->getMaxNumOfChars();
201 if ($max_no_of_chars == 0) {
202 $max_no_of_chars = ucfirst($this->lng->txt(
'unlimited'));
205 $act_no_of_chars = $this->
object->countLetters($user_solution);
206 $template->setVariable(
"CHARACTER_INFO",
'<b>' . $max_no_of_chars .
'</b>' .
207 $this->lng->txt(
'answer_characters') .
' <b>' . $act_no_of_chars .
'</b>');
209 if (($active_id > 0) && (!$show_correct_solution)) {
210 if ($graphicalOutput) {
212 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
213 if ($reached_points == $this->object->getMaximumPoints()) {
216 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
220 if ($reached_points > 0) {
222 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
225 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
231 if ($show_question_text ==
true) {
232 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext,
true));
237 if ($show_feedback) {
240 $feedback .= strlen($fb) ? $fb :
'';
244 array($user_solution =>
'')
247 $feedback .= strlen($fb) ? $fb :
'';
249 if (strlen($feedback)) {
255 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
256 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
259 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
261 $solutionoutput = $solutiontemplate->get();
262 if (!$show_question_only) {
266 return $solutionoutput;
272 $answers = $this->
object->getAnswers();
273 if (!count($answers)) {
278 $tplFile =
'tpl.il_as_qpl_text_question_best_solution_html.html';
280 $tplFile =
'tpl.il_as_qpl_text_question_best_solution_ta.html';
283 $tpl =
new ilTemplate($tplFile,
true,
true,
'Modules/TestQuestionPool');
285 foreach ($answers as $answer) {
286 $keywordString = $answer->getAnswertext();
289 $keywordString .=
' ' . $this->lng->txt(
'for') .
' ';
290 $keywordString .= $answer->getPoints() .
' ' . $this->lng->txt(
'points');
293 $tpl->setCurrentBlock(
'keyword');
294 $tpl->setVariable(
'KEYWORD', $keywordString);
295 $tpl->parseCurrentBlock();
298 $tpl->setVariable(
'KEYWORD_HEADER', $this->lng->txt(
'solution_contain_keywords'));
299 $tpl->setVariable(
'SCORING_LABEL', $this->lng->txt(
'essay_scoring_mode') .
': ');
301 switch ($this->object->getKeywordRelation()) {
303 $tpl->setVariable(
'SCORING_MODE', $this->lng->txt(
'essay_scoring_mode_keyword_relation_any'));
306 $tpl->setVariable(
'SCORING_MODE', $this->lng->txt(
'essay_scoring_mode_keyword_relation_all'));
309 $tpl->setVariable(
'SCORING_MODE', $this->lng->txt(
'essay_scoring_mode_keyword_relation_one'));
320 foreach ($solutions as $idx => $solution_value) {
321 $user_solution = $solution_value[
"value1"];
323 return $user_solution;
326 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
329 include_once
"./Services/UICore/classes/class.ilTemplate.php";
330 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html",
true,
true,
"Modules/TestQuestionPool");
331 if ($this->object->getMaxNumOfChars()) {
332 $template->setCurrentBlock(
"maximum_char_hint");
333 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
335 #mbecker: No such block. $template->setCurrentBlock("has_maxchars"); 336 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
338 $template->setCurrentBlock(
"maxchars_counter");
339 $template->setVariable(
"QID", $this->object->getId());
340 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
341 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
342 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
352 $questiontext = $this->
object->getQuestion();
353 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext,
true));
354 $template->setVariable(
"QID", $this->object->getId());
360 if (!$show_question_only) {
364 return $questionoutput;
367 public function getTestOutput($active_id,
$pass = null, $is_postponed =
false, $use_post_solutions =
false, $inlineFeedback =
false)
374 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 375 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 377 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 380 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id,
$pass);
381 foreach ($solutions as $idx => $solution_value) {
382 $user_solution = $solution_value[
"value1"];
387 include_once
"./Services/UICore/classes/class.ilTemplate.php";
388 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html",
true,
true,
"Modules/TestQuestionPool");
389 if ($this->object->getMaxNumOfChars()) {
390 $template->setCurrentBlock(
"maximum_char_hint");
391 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
393 #mbecker: No such block. $template->setCurrentBlock("has_maxchars"); 394 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
396 $template->setCurrentBlock(
"maxchars_counter");
397 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
398 $template->setVariable(
"QID", $this->object->getId());
399 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
400 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
404 $template->setVariable(
"QID", $this->object->getId());
406 $questiontext = $this->
object->getQuestion();
407 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext,
true));
412 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
413 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
420 $tpl =
new ilTemplate(
'tpl.charcounter.html',
true,
true,
'Modules/TestQuestionPool');
422 $tpl->setCurrentBlock(
'tinymce_handler');
423 $tpl->touchBlock(
'tinymce_handler');
424 $tpl->parseCurrentBlock();
426 if ($this->object->getMaxNumOfChars() > 0) {
427 $tpl->setCurrentBlock(
'letter_counter_js');
428 $tpl->setVariable(
"QID", $this->object->getId());
429 $tpl->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
430 $tpl->parseCurrentBlock();
439 if (
$_POST[
"cmd"][
"addSuggestedSolution"]) {
445 if (!$this->checkInput()) {
446 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
451 $this->
object->saveToDb();
452 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
453 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
455 parent::addSuggestedSolution();
468 $rbacsystem = $DIC[
'rbacsystem'];
469 $ilTabs = $DIC[
'ilTabs'];
471 $ilTabs->clearTargets();
473 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
474 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
475 $q_type = $this->
object->getQuestionType();
477 if (strlen($q_type)) {
478 $classname = $q_type .
"GUI";
479 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
480 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
484 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
488 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
489 array(
"edit",
"insert",
"exec_pg"),
499 $force_active =
false;
500 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
503 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
509 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
529 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
541 $firstValue1 = current($userSolution);
543 $feedback =
'<table><tbody>';
544 $user_answer =
' ' . $firstValue1;
546 foreach ($this->object->getAnswers() as $idx => $ans) {
547 if ($this->object->isKeywordMatching($user_answer, $ans->getAnswertext())) {
548 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
549 $this->object->getId(),
553 $feedback .=
'<tr><td><b><i>' . $ans->getAnswertext() .
'</i></b></td><td>';
554 $feedback .= $fb .
'</td> </tr>';
558 $feedback .=
'</tbody></table>';
559 return $this->
object->prepareTextareaOutput($feedback,
true);
564 $this->
object->setMaxNumOfChars(
$_POST[
"maxchars"]);
565 $this->
object->setTextRating(
$_POST[
"text_rating"]);
566 $this->
object->setKeywordRelation(
$_POST[
'scoring_mode']);
571 switch ($this->object->getKeywordRelation()) {
573 $this->
object->setAnswers(array());
574 $this->
object->setPoints(
$_POST[
'non_keyword_points']);
577 $this->
object->setAnswers(
$_POST[
'any_keyword']);
578 $this->
object->setPoints($this->object->getMaximumPoints());
581 $this->
object->setAnswers(
$_POST[
'all_keyword']);
582 $this->
object->setPoints(
$_POST[
'all_keyword_points']);
585 $this->
object->setAnswers(
$_POST[
'one_keyword']);
586 $this->
object->setPoints(
$_POST[
'one_keyword_points']);
596 if ($this->object->getMaxNumOfChars() > 0) {
597 $maxchars->setValue($this->object->getMaxNumOfChars());
599 $maxchars->setInfo($this->lng->txt(
"description_maxchars"));
603 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
604 $text_options = array(
605 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
606 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
607 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
608 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
609 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
610 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
611 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
613 $textrating->setOptions($text_options);
614 $textrating->setValue($this->object->getTextRating());
623 $this->lng->txt(
'essay_scoring_mode'),
628 $this->lng->txt(
'essay_scoring_mode_without_keywords'),
631 'essay_scoring_mode_without_keywords_desc' 635 $this->lng->txt(
'essay_scoring_mode_keyword_relation_any'),
638 'essay_scoring_mode_keyword_relation_any_desc' 642 $this->lng->txt(
'essay_scoring_mode_keyword_relation_all'),
645 'essay_scoring_mode_keyword_relation_all_desc' 649 $this->lng->txt(
'essay_scoring_mode_keyword_relation_one'),
652 'essay_scoring_mode_keyword_relation_one_desc' 656 $scoringMode->addOption($scoringOptionNone);
657 $scoringMode->addOption($scoringOptionAnyKeyword);
658 $scoringMode->addOption($scoringOptionAllKeyword);
659 $scoringMode->addOption($scoringOptionOneKeyword);
660 $scoringMode->setRequired(
true);
662 strlen($this->object->getKeywordRelation()) ? $this->object->getKeywordRelation(
666 if ($this->object->getAnswerCount() == 0) {
667 $this->
object->addAnswer(
"", 1, 0, 0);
669 require_once
"./Modules/TestQuestionPool/classes/class.ilEssayKeywordWizardInputGUI.php";
672 $nonKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points"),
"non_keyword_points");
674 $nonKeywordPoints->setValue($this->object->getPoints());
675 $nonKeywordPoints->setRequired(
true);
676 $nonKeywordPoints->setSize(3);
677 $nonKeywordPoints->setMinValue(0.0);
678 $nonKeywordPoints->setMinvalueShouldBeGreater(
true);
679 $scoringOptionNone->
addSubItem($nonKeywordPoints);
684 $anyKeyword->setQuestionObject($this->
object);
685 $anyKeyword->setSingleline(
true);
686 $anyKeyword->setValues($this->object->getAnswers());
687 $scoringOptionAnyKeyword->
addSubItem($anyKeyword);
694 $allKeyword->setValues(self::buildAnswerTextOnlyArray($this->object->getAnswers()));
695 $scoringOptionAllKeyword->
addSubItem($allKeyword);
696 $allKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points"),
"all_keyword_points");
698 $allKeywordPoints->setValue($this->object->getPoints());
699 $allKeywordPoints->setRequired(
true);
700 $allKeywordPoints->setSize(3);
701 $allKeywordPoints->setMinValue(0.0);
702 $allKeywordPoints->setMinvalueShouldBeGreater(
true);
703 $scoringOptionAllKeyword->
addSubItem($allKeywordPoints);
710 $oneKeyword->setValues(self::buildAnswerTextOnlyArray($this->object->getAnswers()));
711 $scoringOptionOneKeyword->
addSubItem($oneKeyword);
712 $oneKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points"),
"one_keyword_points");
714 $oneKeywordPoints->setValue($this->object->getPoints());
715 $oneKeywordPoints->setRequired(
true);
716 $oneKeywordPoints->setSize(3);
717 $oneKeywordPoints->setMinValue(0.0);
718 $oneKeywordPoints->setMinvalueShouldBeGreater(
true);
719 $scoringOptionOneKeyword->
addSubItem($oneKeywordPoints);
static _getRTEClassname()
isTestPresentationContext()
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
This class represents an option in a radio group.
getAnswersFrequency($relevantAnswers, $questionIndex)
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
static getScoringModesWithPointsByKeyword()
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
getSpecificFeedbackOutput($userSolution)
__construct($id=-1)
assTextQuestionGUI constructor
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
getPreview($show_question_only=false, $showInlineFeedback=false)
if(!array_key_exists('StateId', $_REQUEST)) $id
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
Text question GUI representation.
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
static _lookupObjectId($a_ref_id)
lookup object id
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Class for text questions.
setValue($a_value)
Set Value.
writeQuestionGenericPostData()
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
if(isset($_POST['submit'])) $form
addSubItem($a_item)
Add Subitem.
getILIASPage($html="")
Returns the ILIAS Page around a question.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getUserAnswer($active_id, $pass)
special template class to simplify handling of ITX/PEAR
static initDomEvent()
Init YUI DomEvent.
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
const CSS_CLASS_FEEDBACK_WRONG
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
Basic GUI class for assessment questions.
static _lookupType($a_id, $a_reference=false)
lookup object type
getTestOutput($active_id, $pass=null, $is_postponed=false, $use_post_solutions=false, $inlineFeedback=false)
static buildAnswerTextOnlyArray($answers)
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
saveTaxonomyAssignments()
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
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.
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
addBackTab(ilTabsGUI $ilTabs)
Interface ilGuiAnswerScoringAdjustable.
writePostData($always=false)
{}
This class represents a text wizard property in a property form.
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
setQuestionTabs()
Sets the ILIAS tabs for this question type.
isAnswerFreuqencyStatisticSupported()
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
renderPurposeSupportsFormHtml()