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';
33 parent::__construct();
34 include_once
"./Modules/TestQuestionPool/classes/class.assTextQuestion.php";
38 $this->
object->loadFromDb($id);
51 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
54 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
74 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
76 $form->setFormAction($this->ctrl->getFormAction($this));
78 $form->setMultipart(TRUE);
79 $form->setTableWidth(
"100%");
80 $form->setId(
"asstextquestion");
95 $form->setValuesByPost();
97 $form->setValuesByPost();
98 if (
$errors) $checkonly =
false;
101 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
107 $answerTexts = array();
109 foreach($answers as $answer)
111 $answerTexts[] = $answer->getAnswertext();
125 include_once
"./Services/RTE/classes/class.ilRTE.php";
127 include_once
"./Services/RTE/classes/class.$rtestring.php";
128 $rte =
new $rtestring();
129 include_once
"./Services/Object/classes/class.ilObject.php";
132 $rte->addUserTextEditor(
"textinput");
154 $graphicalOutput = FALSE,
155 $result_output = FALSE,
156 $show_question_only = TRUE,
157 $show_feedback = FALSE,
158 $show_correct_solution = FALSE,
159 $show_manual_scoring = FALSE,
160 $show_question_text = TRUE
167 if (($active_id > 0) && (!$show_correct_solution))
169 $solution = $user_solution;
177 include_once
"./Services/UICore/classes/class.ilTemplate.php";
178 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
179 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
181 $solution = $this->
object->getHtmlUserSolutionPurifier()->purify($solution);
184 $template->setCurrentBlock(
'essay_div');
185 $template->setVariable(
"DIV_ESSAY", $this->object->prepareTextareaOutput($solution, TRUE));
189 $template->setCurrentBlock(
'essay_textarea');
190 $template->setVariable(
"TA_ESSAY", $this->object->prepareTextareaOutput($solution, TRUE,
true));
192 $template->parseCurrentBlock();
194 $questiontext = $this->
object->getQuestion();
196 if (!$show_correct_solution)
198 $max_no_of_chars = $this->
object->getMaxNumOfChars();
200 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))
211 if ($graphicalOutput)
214 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
215 if ($reached_points == $this->object->getMaximumPoints())
217 $template->setCurrentBlock(
"icon_ok");
219 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
220 $template->parseCurrentBlock();
224 $template->setCurrentBlock(
"icon_ok");
225 if ($reached_points > 0)
228 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
233 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
235 $template->parseCurrentBlock();
239 if ($show_question_text==
true)
241 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
243 $questionoutput = $template->get();
251 $feedback .= strlen($fb) ? $fb :
'';
255 $feedback .= strlen($fb) ? $fb :
'';
257 if (strlen($feedback))
263 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
264 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
267 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
269 $solutionoutput = $solutiontemplate->get();
270 if (!$show_question_only)
275 return $solutionoutput;
280 $answers = $this->
object->getAnswers();
281 if( !count($answers) )
288 $tplFile =
'tpl.il_as_qpl_text_question_best_solution_html.html';
292 $tplFile =
'tpl.il_as_qpl_text_question_best_solution_ta.html';
295 $tpl =
new ilTemplate($tplFile,
true,
true,
'Modules/TestQuestionPool');
297 foreach ($answers as $answer)
299 $keywordString = $answer->getAnswertext();
303 $keywordString .=
' ' . $this->lng->txt(
'for') .
' ';
304 $keywordString .= $answer->getPoints() .
' ' . $this->lng->txt(
'points');
307 $tpl->setCurrentBlock(
'keyword');
308 $tpl->setVariable(
'KEYWORD', $keywordString);
309 $tpl->parseCurrentBlock();
312 $tpl->setVariable(
'KEYWORD_HEADER', $this->lng->txt(
'solution_contain_keywords'));
313 $tpl->setVariable(
'SCORING_LABEL', $this->lng->txt(
'essay_scoring_mode').
': ');
315 switch( $this->object->getKeywordRelation() )
318 $tpl->setVariable(
'SCORING_MODE', $this->lng->txt(
'essay_scoring_mode_keyword_relation_any'));
321 $tpl->setVariable(
'SCORING_MODE', $this->lng->txt(
'essay_scoring_mode_keyword_relation_all'));
324 $tpl->setVariable(
'SCORING_MODE', $this->lng->txt(
'essay_scoring_mode_keyword_relation_one'));
334 $solutions = $this->
object->getSolutionValues( $active_id,
$pass );
335 foreach ($solutions as $idx => $solution_value)
337 $user_solution = $solution_value[
"value1"];
339 return $user_solution;
342 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
345 include_once
"./Services/UICore/classes/class.ilTemplate.php";
346 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
347 if ($this->object->getMaxNumOfChars())
349 $template->setCurrentBlock(
"maximum_char_hint");
350 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
351 $template->parseCurrentBlock();
352 #mbecker: No such block. $template->setCurrentBlock("has_maxchars"); 353 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
354 $template->parseCurrentBlock();
355 $template->setCurrentBlock(
"maxchars_counter");
356 $template->setVariable(
"QID", $this->object->getId());
357 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
358 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
359 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
360 $template->parseCurrentBlock();
370 $questiontext = $this->
object->getQuestion();
371 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
372 $template->setVariable(
"QID", $this->object->getId());
374 $questionoutput = $template->get();
378 if (!$show_question_only)
383 return $questionoutput;
386 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $inlineFeedback =
false)
394 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 395 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 397 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 400 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id,
$pass);
401 foreach ($solutions as $idx => $solution_value)
403 $user_solution = $solution_value[
"value1"];
408 include_once
"./Services/UICore/classes/class.ilTemplate.php";
409 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
410 if ($this->object->getMaxNumOfChars())
412 $template->setCurrentBlock(
"maximum_char_hint");
413 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
414 $template->parseCurrentBlock();
415 #mbecker: No such block. $template->setCurrentBlock("has_maxchars"); 416 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
417 $template->parseCurrentBlock();
418 $template->setCurrentBlock(
"maxchars_counter");
419 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
420 $template->setVariable(
"QID", $this->object->getId());
421 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
422 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
423 $template->parseCurrentBlock();
425 $template->setVariable(
"QID", $this->object->getId());
427 $questiontext = $this->
object->getQuestion();
428 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
429 $questionoutput = $template->get();
433 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
434 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
441 $tpl =
new ilTemplate(
'tpl.charcounter.html',
true,
true,
'Modules/TestQuestionPool');
443 $tpl->setCurrentBlock(
'tinymce_handler');
444 $tpl->touchBlock(
'tinymce_handler');
445 $tpl->parseCurrentBlock();
447 if ($this->object->getMaxNumOfChars() > 0)
449 $tpl->setCurrentBlock(
'letter_counter_js');
450 $tpl->setVariable(
"QID", $this->object->getId());
451 $tpl->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
452 $tpl->parseCurrentBlock();
461 if (
$_POST[
"cmd"][
"addSuggestedSolution"])
469 if (!$this->checkInput())
471 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
476 $this->
object->saveToDb();
477 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
478 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
480 parent::addSuggestedSolution();
492 global $rbacsystem, $ilTabs;
494 $ilTabs->clearTargets();
496 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
497 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
498 $q_type = $this->
object->getQuestionType();
502 $classname = $q_type .
"GUI";
503 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
504 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
509 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
512 $ilTabs->addTarget(
"edit_page",
513 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
514 array(
"edit",
"insert",
"exec_pg"),
515 "",
"", $force_active);
521 $force_active =
false;
522 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
525 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
527 $ilTabs->addTarget(
"edit_question",
529 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
530 $classname,
"", $force_active);
545 $ilTabs->addTarget(
"statistics",
546 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
556 $feedback =
'<table><tbody>';
557 $user_answers = $this->
object->getSolutionValues($active_id);
558 $user_answer =
' '. $user_answers[0][
'value1'];
560 foreach ($this->object->getAnswers() as $idx => $ans)
562 if ($this->object->isKeywordMatching($user_answer, $ans->getAnswertext() ))
564 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
565 $this->object->getId(), $idx
567 $feedback .=
'<tr><td><b><i>' . $ans->getAnswertext() .
'</i></b></td><td>';
568 $feedback .= $fb .
'</td> </tr>';
572 $feedback .=
'</tbody></table>';
573 return $this->
object->prepareTextareaOutput($feedback, TRUE);
578 $this->
object->setMaxNumOfChars(
$_POST[
"maxchars"] );
579 $this->
object->setTextRating(
$_POST[
"text_rating"] );
580 $this->
object->setKeywordRelation(
$_POST[
'scoring_mode'] );
585 switch ($this->object->getKeywordRelation())
588 $this->
object->setAnswers( array() );
589 $this->
object->setPoints(
$_POST[
'non_keyword_points'] );
592 $this->
object->setAnswers(
$_POST[
'any_keyword'] );
593 $this->
object->setPoints( $this->object->getMaximumPoints() );
596 $this->
object->setAnswers(
$_POST[
'all_keyword'] );
597 $this->
object->setPoints(
$_POST[
'all_keyword_points'] );
600 $this->
object->setAnswers(
$_POST[
'one_keyword'] );
601 $this->
object->setPoints(
$_POST[
'one_keyword_points'] );
609 $maxchars =
new ilNumberInputGUI($this->lng->txt(
"maxchars" ),
"maxchars");
611 if ($this->object->getMaxNumOfChars() > 0)
612 $maxchars->setValue( $this->object->getMaxNumOfChars() );
613 $maxchars->setInfo( $this->lng->txt(
"description_maxchars" ) );
617 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
618 $text_options = array(
619 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
620 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
621 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
622 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
623 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
624 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
625 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
627 $textrating->setOptions($text_options);
628 $textrating->setValue($this->object->getTextRating());
637 $this->lng->txt(
'essay_scoring_mode' ),
'scoring_mode' 640 $scoringOptionNone =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_without_keywords' ),
641 'non', $this->lng->txt(
'essay_scoring_mode_without_keywords_desc' 644 $scoringOptionAnyKeyword =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_keyword_relation_any' ),
645 'any', $this->lng->txt(
'essay_scoring_mode_keyword_relation_any_desc' 648 $scoringOptionAllKeyword =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_keyword_relation_all' ),
649 'all', $this->lng->txt(
'essay_scoring_mode_keyword_relation_all_desc' 652 $scoringOptionOneKeyword =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_keyword_relation_one' ),
653 'one', $this->lng->txt(
'essay_scoring_mode_keyword_relation_one_desc' 657 $scoringMode->addOption( $scoringOptionNone );
658 $scoringMode->addOption( $scoringOptionAnyKeyword );
659 $scoringMode->addOption( $scoringOptionAllKeyword );
660 $scoringMode->addOption( $scoringOptionOneKeyword );
661 $scoringMode->setRequired(
true );
662 $scoringMode->
setValue( strlen( $this->object->getKeywordRelation() ) ? $this->object->getKeywordRelation(
666 if ($this->object->getAnswerCount() == 0)
668 $this->
object->addAnswer(
"", 1, 0, 0 );
670 require_once
"./Modules/TestQuestionPool/classes/class.ilEssayKeywordWizardInputGUI.php";
673 $nonKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points" ),
"non_keyword_points");
675 $nonKeywordPoints->setValue( $this->object->getPoints() );
676 $nonKeywordPoints->setRequired( TRUE );
677 $nonKeywordPoints->setSize( 3 );
678 $nonKeywordPoints->setMinValue( 0.0 );
679 $nonKeywordPoints->setMinvalueShouldBeGreater(
true );
680 $scoringOptionNone->
addSubItem( $nonKeywordPoints );
685 $anyKeyword->setQuestionObject( $this->
object );
686 $anyKeyword->setSingleline( TRUE );
687 $anyKeyword->setValues( $this->object->getAnswers() );
688 $scoringOptionAnyKeyword->
addSubItem( $anyKeyword );
695 $allKeyword->setValues( self::buildAnswerTextOnlyArray( $this->object->getAnswers() ) );
696 $scoringOptionAllKeyword->
addSubItem( $allKeyword );
697 $allKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points" ),
"all_keyword_points");
699 $allKeywordPoints->setValue( $this->object->getPoints() );
700 $allKeywordPoints->setRequired( TRUE );
701 $allKeywordPoints->setSize( 3 );
702 $allKeywordPoints->setMinValue( 0.0 );
703 $allKeywordPoints->setMinvalueShouldBeGreater(
true );
704 $scoringOptionAllKeyword->
addSubItem( $allKeywordPoints );
711 $oneKeyword->setValues( self::buildAnswerTextOnlyArray( $this->object->getAnswers() ) );
712 $scoringOptionOneKeyword->
addSubItem( $oneKeyword );
713 $oneKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points" ),
"one_keyword_points");
715 $oneKeywordPoints->setValue( $this->object->getPoints() );
716 $oneKeywordPoints->setRequired( TRUE );
717 $oneKeywordPoints->setSize( 3 );
718 $oneKeywordPoints->setMinValue( 0.0 );
719 $oneKeywordPoints->setMinvalueShouldBeGreater(
true );
720 $scoringOptionOneKeyword->
addSubItem( $oneKeywordPoints );
722 $form->
addItem( $scoringMode );
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.
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
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
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
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.
getTestOutput($active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $inlineFeedback=false)
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.
getPreview($show_question_only=FALSE, $showInlineFeedback=false)
Class for text questions.
setValue($a_value)
Set Value.
writeQuestionGenericPostData()
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
getSpecificFeedbackOutput($active_id, $pass)
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.
addBackTab(ilTabsGUI $ilTabs)
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.
Interface ilGuiAnswerScoringAdjustable.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
writePostData($always=false)
Evaluates a posted edit form and writes the form data in the question object.
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.