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");
153 $graphicalOutput =
false,
154 $result_output =
false,
155 $show_question_only =
true,
156 $show_feedback =
false,
157 $show_correct_solution =
false,
158 $show_manual_scoring =
false,
159 $show_question_text =
true 165 if (($active_id > 0) && (!$show_correct_solution)) {
166 $solution = $user_solution;
172 include_once
"./Services/UICore/classes/class.ilTemplate.php";
173 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
174 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
176 $solution = $this->
object->getHtmlUserSolutionPurifier()->purify($solution);
179 $template->setVariable(
"DIV_ESSAY", $this->
object->prepareTextareaOutput($solution,
true));
181 $template->setCurrentBlock(
'essay_textarea');
182 $template->setVariable(
"TA_ESSAY", $this->
object->prepareTextareaOutput($solution,
true,
true));
186 $questiontext = $this->
object->getQuestion();
188 if (!$show_correct_solution) {
189 $max_no_of_chars = $this->
object->getMaxNumOfChars();
191 if ($max_no_of_chars == 0) {
192 $max_no_of_chars = ucfirst($this->lng->txt(
'unlimited'));
195 $act_no_of_chars = $this->
object->countLetters($user_solution);
196 $template->setVariable(
"CHARACTER_INFO",
'<b>' . $max_no_of_chars .
'</b>' .
197 $this->lng->txt(
'answer_characters') .
' <b>' . $act_no_of_chars .
'</b>');
199 if (($active_id > 0) && (!$show_correct_solution)) {
200 if ($graphicalOutput) {
202 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
203 if ($reached_points == $this->
object->getMaximumPoints()) {
206 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
210 if ($reached_points > 0) {
212 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
215 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
221 if ($show_question_text==
true) {
222 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext,
true));
227 if ($show_feedback) {
230 $feedback .= strlen($fb) ? $fb :
'';
234 $feedback .= strlen($fb) ? $fb :
'';
236 if (strlen($feedback)) {
242 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
243 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($feedback,
true));
246 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
248 $solutionoutput = $solutiontemplate->get();
249 if (!$show_question_only) {
253 return $solutionoutput;
258 $answers = $this->
object->getAnswers();
259 if (!count($answers)) {
264 $tplFile =
'tpl.il_as_qpl_text_question_best_solution_html.html';
266 $tplFile =
'tpl.il_as_qpl_text_question_best_solution_ta.html';
269 $tpl =
new ilTemplate($tplFile,
true,
true,
'Modules/TestQuestionPool');
271 foreach ($answers as $answer) {
272 $keywordString = $answer->getAnswertext();
275 $keywordString .=
' ' . $this->lng->txt(
'for') .
' ';
276 $keywordString .= $answer->getPoints() .
' ' . $this->lng->txt(
'points');
279 $tpl->setCurrentBlock(
'keyword');
280 $tpl->setVariable(
'KEYWORD', $keywordString);
281 $tpl->parseCurrentBlock();
284 $tpl->setVariable(
'KEYWORD_HEADER', $this->lng->txt(
'solution_contain_keywords'));
285 $tpl->setVariable(
'SCORING_LABEL', $this->lng->txt(
'essay_scoring_mode') .
': ');
287 switch ($this->
object->getKeywordRelation()) {
289 $tpl->setVariable(
'SCORING_MODE', $this->lng->txt(
'essay_scoring_mode_keyword_relation_any'));
292 $tpl->setVariable(
'SCORING_MODE', $this->lng->txt(
'essay_scoring_mode_keyword_relation_all'));
295 $tpl->setVariable(
'SCORING_MODE', $this->lng->txt(
'essay_scoring_mode_keyword_relation_one'));
305 $solutions = $this->
object->getSolutionValues($active_id,
$pass);
306 foreach ($solutions as $idx => $solution_value) {
307 $user_solution = $solution_value[
"value1"];
309 return $user_solution;
312 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
315 include_once
"./Services/UICore/classes/class.ilTemplate.php";
316 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html",
true,
true,
"Modules/TestQuestionPool");
317 if ($this->
object->getMaxNumOfChars()) {
318 $template->setCurrentBlock(
"maximum_char_hint");
319 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
321 #mbecker: No such block. $template->setCurrentBlock("has_maxchars"); 324 $template->setCurrentBlock(
"maxchars_counter");
327 $template->setVariable(
"TEXTBOXSIZE", strlen($this->
object->getMaxNumOfChars()));
328 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
338 $questiontext = $this->
object->getQuestion();
339 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext,
true));
346 if (!$show_question_only) {
350 return $questionoutput;
353 public function getTestOutput($active_id,
$pass = null, $is_postponed =
false, $use_post_solutions =
false, $inlineFeedback =
false)
360 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 361 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 363 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 366 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id,
$pass);
367 foreach ($solutions as $idx => $solution_value) {
368 $user_solution = $solution_value[
"value1"];
373 include_once
"./Services/UICore/classes/class.ilTemplate.php";
374 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html",
true,
true,
"Modules/TestQuestionPool");
375 if ($this->
object->getMaxNumOfChars()) {
376 $template->setCurrentBlock(
"maximum_char_hint");
377 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
379 #mbecker: No such block. $template->setCurrentBlock("has_maxchars"); 382 $template->setCurrentBlock(
"maxchars_counter");
385 $template->setVariable(
"TEXTBOXSIZE", strlen($this->
object->getMaxNumOfChars()));
386 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
391 $questiontext = $this->
object->getQuestion();
392 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext,
true));
397 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
398 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
405 $tpl =
new ilTemplate(
'tpl.charcounter.html',
true,
true,
'Modules/TestQuestionPool');
407 $tpl->setCurrentBlock(
'tinymce_handler');
408 $tpl->touchBlock(
'tinymce_handler');
409 $tpl->parseCurrentBlock();
411 if ($this->
object->getMaxNumOfChars() > 0) {
412 $tpl->setCurrentBlock(
'letter_counter_js');
413 $tpl->setVariable(
"QID", $this->
object->getId());
414 $tpl->setVariable(
"MAXCHARS", $this->
object->getMaxNumOfChars());
415 $tpl->parseCurrentBlock();
424 if (
$_POST[
"cmd"][
"addSuggestedSolution"]) {
430 if (!$this->checkInput()) {
431 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
436 $this->
object->saveToDb();
437 $this->ctrl->setParameter($this,
"q_id", $this->
object->getId());
438 $this->tpl->setVariable(
"HEADER", $this->
object->getTitle());
440 parent::addSuggestedSolution();
452 global $rbacsystem, $ilTabs;
454 $ilTabs->clearTargets();
456 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
457 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
458 $q_type = $this->
object->getQuestionType();
460 if (strlen($q_type)) {
461 $classname = $q_type .
"GUI";
462 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
463 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
467 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
471 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
472 array(
"edit",
"insert",
"exec_pg"),
482 $force_active =
false;
483 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
486 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
492 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
512 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
524 $feedback =
'<table><tbody>';
525 $user_answers = $this->
object->getSolutionValues($active_id);
526 $user_answer =
' ' . $user_answers[0][
'value1'];
528 foreach ($this->
object->getAnswers() as $idx => $ans) {
529 if ($this->
object->isKeywordMatching($user_answer, $ans->getAnswertext())) {
530 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
534 $feedback .=
'<tr><td><b><i>' . $ans->getAnswertext() .
'</i></b></td><td>';
535 $feedback .= $fb .
'</td> </tr>';
539 $feedback .=
'</tbody></table>';
540 return $this->
object->prepareTextareaOutput($feedback,
true);
545 $this->
object->setMaxNumOfChars(
$_POST[
"maxchars"]);
546 $this->
object->setTextRating(
$_POST[
"text_rating"]);
547 $this->
object->setKeywordRelation(
$_POST[
'scoring_mode']);
552 switch ($this->
object->getKeywordRelation()) {
554 $this->
object->setAnswers(
array());
555 $this->
object->setPoints(
$_POST[
'non_keyword_points']);
558 $this->
object->setAnswers(
$_POST[
'any_keyword']);
559 $this->
object->setPoints($this->
object->getMaximumPoints());
562 $this->
object->setAnswers(
$_POST[
'all_keyword']);
563 $this->
object->setPoints(
$_POST[
'all_keyword_points']);
566 $this->
object->setAnswers(
$_POST[
'one_keyword']);
567 $this->
object->setPoints(
$_POST[
'one_keyword_points']);
577 if ($this->
object->getMaxNumOfChars() > 0) {
578 $maxchars->setValue($this->
object->getMaxNumOfChars());
580 $maxchars->setInfo($this->lng->txt(
"description_maxchars"));
584 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
585 $text_options =
array(
586 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
587 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
588 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
589 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
590 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
591 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
592 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
594 $textrating->setOptions($text_options);
595 $textrating->setValue($this->
object->getTextRating());
604 $this->lng->txt(
'essay_scoring_mode'),
609 $this->lng->txt(
'essay_scoring_mode_without_keywords'),
612 'essay_scoring_mode_without_keywords_desc' 616 $this->lng->txt(
'essay_scoring_mode_keyword_relation_any'),
619 'essay_scoring_mode_keyword_relation_any_desc' 623 $this->lng->txt(
'essay_scoring_mode_keyword_relation_all'),
626 'essay_scoring_mode_keyword_relation_all_desc' 630 $this->lng->txt(
'essay_scoring_mode_keyword_relation_one'),
633 'essay_scoring_mode_keyword_relation_one_desc' 637 $scoringMode->addOption($scoringOptionNone);
638 $scoringMode->addOption($scoringOptionAnyKeyword);
639 $scoringMode->addOption($scoringOptionAllKeyword);
640 $scoringMode->addOption($scoringOptionOneKeyword);
641 $scoringMode->setRequired(
true);
643 strlen($this->
object->getKeywordRelation()) ? $this->
object->getKeywordRelation(
647 if ($this->
object->getAnswerCount() == 0) {
648 $this->
object->addAnswer(
"", 1, 0, 0);
650 require_once
"./Modules/TestQuestionPool/classes/class.ilEssayKeywordWizardInputGUI.php";
653 $nonKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points"),
"non_keyword_points");
655 $nonKeywordPoints->setValue($this->
object->getPoints());
656 $nonKeywordPoints->setRequired(
true);
657 $nonKeywordPoints->setSize(3);
658 $nonKeywordPoints->setMinValue(0.0);
659 $nonKeywordPoints->setMinvalueShouldBeGreater(
true);
660 $scoringOptionNone->
addSubItem($nonKeywordPoints);
665 $anyKeyword->setQuestionObject($this->
object);
666 $anyKeyword->setSingleline(
true);
667 $anyKeyword->setValues($this->
object->getAnswers());
668 $scoringOptionAnyKeyword->
addSubItem($anyKeyword);
675 $allKeyword->setValues(self::buildAnswerTextOnlyArray($this->
object->getAnswers()));
676 $scoringOptionAllKeyword->
addSubItem($allKeyword);
677 $allKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points"),
"all_keyword_points");
679 $allKeywordPoints->setValue($this->
object->getPoints());
680 $allKeywordPoints->setRequired(
true);
681 $allKeywordPoints->setSize(3);
682 $allKeywordPoints->setMinValue(0.0);
683 $allKeywordPoints->setMinvalueShouldBeGreater(
true);
684 $scoringOptionAllKeyword->
addSubItem($allKeywordPoints);
691 $oneKeyword->setValues(self::buildAnswerTextOnlyArray($this->
object->getAnswers()));
692 $scoringOptionOneKeyword->
addSubItem($oneKeyword);
693 $oneKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points"),
"one_keyword_points");
695 $oneKeywordPoints->setValue($this->
object->getPoints());
696 $oneKeywordPoints->setRequired(
true);
697 $oneKeywordPoints->setSize(3);
698 $oneKeywordPoints->setMinValue(0.0);
699 $oneKeywordPoints->setMinvalueShouldBeGreater(
true);
700 $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.
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
__construct($id=-1)
assTextQuestionGUI constructor
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)
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()
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.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
getSpecificFeedbackOutput($active_id, $pass)
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.
Create new PHPExcel object
obj_idprivate
addBackTab(ilTabsGUI $ilTabs)
Interface ilGuiAnswerScoringAdjustable.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
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.
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
renderPurposeSupportsFormHtml()