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';
34 parent::__construct();
35 include_once
"./Modules/TestQuestionPool/classes/class.assTextQuestion.php";
39 $this->
object->loadFromDb($id);
48 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
51 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
71 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
73 $this->editForm = $form;
75 $form->setFormAction($this->ctrl->getFormAction($this));
77 $form->setMultipart(TRUE);
78 $form->setTableWidth(
"100%");
79 $form->setId(
"asstextquestion");
94 $form->setValuesByPost();
96 $form->setValuesByPost();
97 if (
$errors) $checkonly =
false;
100 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
106 $answerTexts = array();
108 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
166 if (($active_id > 0) && (!$show_correct_solution))
168 $solution = $user_solution;
176 include_once
"./Services/UICore/classes/class.ilTemplate.php";
177 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
178 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
180 $solution = $this->
object->getHtmlUserSolutionPurifier()->purify($solution);
183 $template->setCurrentBlock(
'essay_div');
184 $template->setVariable(
"DIV_ESSAY", $this->object->prepareTextareaOutput($solution, TRUE));
188 $template->setCurrentBlock(
'essay_textarea');
189 $template->setVariable(
"TA_ESSAY", $this->object->prepareTextareaOutput($solution, TRUE,
true));
191 $template->parseCurrentBlock();
193 $questiontext = $this->
object->getQuestion();
195 if (!$show_correct_solution)
197 $max_no_of_chars = $this->
object->getMaxNumOfChars();
199 if ($max_no_of_chars == 0)
201 $max_no_of_chars = ucfirst($this->lng->txt(
'unlimited'));
203 $act_no_of_chars = $this->
object->countLetters($user_solution);
204 $template->setVariable(
"CHARACTER_INFO",
'<b>' . $max_no_of_chars .
'</b>' .
205 $this->lng->txt(
'answer_characters') .
' <b>' . $act_no_of_chars .
'</b>');
207 if (($active_id > 0) && (!$show_correct_solution))
209 if ($graphicalOutput)
212 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
213 if ($reached_points == $this->object->getMaximumPoints())
215 $template->setCurrentBlock(
"icon_ok");
217 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
218 $template->parseCurrentBlock();
222 $template->setCurrentBlock(
"icon_ok");
223 if ($reached_points > 0)
226 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
231 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
233 $template->parseCurrentBlock();
237 if ($show_question_text==
true)
239 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
241 $questionoutput = $template->get();
249 $feedback .= strlen($fb) ? $fb :
'';
253 $feedback .= strlen($fb) ? $fb :
'';
255 if (strlen($feedback))
261 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
262 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
265 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
267 $solutionoutput = $solutiontemplate->get();
268 if (!$show_question_only)
273 return $solutionoutput;
278 $answers = $this->
object->getAnswers();
279 if( !count($answers) )
286 $tplFile =
'tpl.il_as_qpl_text_question_best_solution_html.html';
290 $tplFile =
'tpl.il_as_qpl_text_question_best_solution_ta.html';
293 $tpl =
new ilTemplate($tplFile,
true,
true,
'Modules/TestQuestionPool');
295 foreach ($answers as $answer)
297 $keywordString = $answer->getAnswertext();
301 $keywordString .=
' ' . $this->lng->txt(
'for') .
' ';
302 $keywordString .= $answer->getPoints() .
' ' . $this->lng->txt(
'points');
305 $tpl->setCurrentBlock(
'keyword');
306 $tpl->setVariable(
'KEYWORD', $keywordString);
307 $tpl->parseCurrentBlock();
310 $tpl->setVariable(
'KEYWORD_HEADER', $this->lng->txt(
'solution_contain_keywords'));
311 $tpl->setVariable(
'SCORING_LABEL', $this->lng->txt(
'essay_scoring_mode').
': ');
313 switch( $this->object->getKeywordRelation() )
316 $tpl->setVariable(
'SCORING_MODE', $this->lng->txt(
'essay_scoring_mode_keyword_relation_any'));
319 $tpl->setVariable(
'SCORING_MODE', $this->lng->txt(
'essay_scoring_mode_keyword_relation_all'));
322 $tpl->setVariable(
'SCORING_MODE', $this->lng->txt(
'essay_scoring_mode_keyword_relation_one'));
332 $solutions = $this->
object->getSolutionValues( $active_id,
$pass );
333 foreach ($solutions as $idx => $solution_value)
335 $user_solution = $solution_value[
"value1"];
337 return $user_solution;
340 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
343 include_once
"./Services/UICore/classes/class.ilTemplate.php";
344 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
345 if ($this->object->getMaxNumOfChars())
347 $template->setCurrentBlock(
"maximum_char_hint");
348 $template->setVariable(
"MAXIMUM_CHAR_HINT",
sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()));
349 $template->parseCurrentBlock();
350 #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
351 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
352 $template->parseCurrentBlock();
353 $template->setCurrentBlock(
"maxchars_counter");
354 $template->setVariable(
"QID", $this->object->getId());
355 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
356 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
357 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
358 $template->parseCurrentBlock();
368 $questiontext = $this->
object->getQuestion();
369 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
370 $template->setVariable(
"QID", $this->object->getId());
372 $questionoutput = $template->get();
376 if (!$show_question_only)
381 return $questionoutput;
384 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $inlineFeedback =
false)
392 #include_once "./Modules/Test/classes/class.ilObjTest.php";
393 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
395 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
398 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id,
$pass);
399 foreach ($solutions as $idx => $solution_value)
401 $user_solution = $solution_value[
"value1"];
406 include_once
"./Services/UICore/classes/class.ilTemplate.php";
407 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
408 if ($this->object->getMaxNumOfChars())
410 $template->setCurrentBlock(
"maximum_char_hint");
411 $template->setVariable(
"MAXIMUM_CHAR_HINT",
sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()));
412 $template->parseCurrentBlock();
413 #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
414 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
415 $template->parseCurrentBlock();
416 $template->setCurrentBlock(
"maxchars_counter");
417 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
418 $template->setVariable(
"QID", $this->object->getId());
419 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
420 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
421 $template->parseCurrentBlock();
423 $template->setVariable(
"QID", $this->object->getId());
425 $questiontext = $this->
object->getQuestion();
426 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
427 $questionoutput = $template->get();
431 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
432 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
439 $tpl =
new ilTemplate(
'tpl.charcounter.html',
true,
true,
'Modules/TestQuestionPool');
441 $tpl->setCurrentBlock(
'tinymce_handler');
442 $tpl->touchBlock(
'tinymce_handler');
443 $tpl->parseCurrentBlock();
445 if ($this->object->getMaxNumOfChars() > 0)
447 $tpl->setCurrentBlock(
'letter_counter_js');
448 $tpl->setVariable(
"QID", $this->object->getId());
449 $tpl->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
450 $tpl->parseCurrentBlock();
459 if (
$_POST[
"cmd"][
"addSuggestedSolution"])
467 if (!$this->checkInput())
469 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
474 $this->
object->saveToDb();
475 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
476 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
478 parent::addSuggestedSolution();
490 global $rbacsystem, $ilTabs;
492 $ilTabs->clearTargets();
494 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
495 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
496 $q_type = $this->
object->getQuestionType();
500 $classname = $q_type .
"GUI";
501 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
502 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
507 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
510 $ilTabs->addTarget(
"edit_page",
511 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
512 array(
"edit",
"insert",
"exec_pg"),
513 "",
"", $force_active);
519 $force_active =
false;
520 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
523 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
525 $ilTabs->addTarget(
"edit_question",
527 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
528 $classname,
"", $force_active);
543 $ilTabs->addTarget(
"statistics",
544 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
554 $feedback =
'<table><tbody>';
555 $user_answers = $this->
object->getSolutionValues($active_id);
556 $user_answer =
' '. $user_answers[0][
'value1'];
558 foreach ($this->object->getAnswers() as $idx => $ans)
560 if ($this->object->isKeywordMatching($user_answer, $ans->getAnswertext() ))
562 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
563 $this->object->getId(), $idx
565 $feedback .=
'<tr><td><b><i>' . $ans->getAnswertext() .
'</i></b></td><td>';
566 $feedback .= $fb .
'</td> </tr>';
570 $feedback .=
'</tbody></table>';
571 return $this->
object->prepareTextareaOutput($feedback, TRUE);
576 $this->
object->setMaxNumOfChars(
$_POST[
"maxchars"] );
577 $this->
object->setTextRating(
$_POST[
"text_rating"] );
578 $this->
object->setKeywordRelation(
$_POST[
'scoring_mode'] );
583 switch ($this->object->getKeywordRelation())
586 $this->
object->setAnswers( array() );
587 $this->
object->setPoints(
$_POST[
'non_keyword_points'] );
590 $this->
object->setAnswers(
$_POST[
'any_keyword'] );
591 $this->
object->setPoints( $this->object->getMaximumPoints() );
594 $this->
object->setAnswers(
$_POST[
'all_keyword'] );
595 $this->
object->setPoints(
$_POST[
'all_keyword_points'] );
598 $this->
object->setAnswers(
$_POST[
'one_keyword'] );
599 $this->
object->setPoints(
$_POST[
'one_keyword_points'] );
607 $maxchars =
new ilNumberInputGUI($this->lng->txt(
"maxchars" ),
"maxchars");
608 $maxchars->setSize( 5 );
609 if ($this->object->getMaxNumOfChars() > 0)
610 $maxchars->setValue( $this->object->getMaxNumOfChars() );
611 $maxchars->setInfo( $this->lng->txt(
"description_maxchars" ) );
615 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
616 $text_options = array(
617 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
618 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
619 "l1" =>
sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
620 "l2" =>
sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
621 "l3" =>
sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
622 "l4" =>
sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
623 "l5" =>
sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
625 $textrating->setOptions($text_options);
626 $textrating->setValue($this->object->getTextRating());
635 $this->lng->txt(
'essay_scoring_mode' ),
'scoring_mode'
638 $scoringOptionNone =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_without_keywords' ),
639 'non', $this->lng->txt(
'essay_scoring_mode_without_keywords_desc'
642 $scoringOptionAnyKeyword =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_keyword_relation_any' ),
643 'any', $this->lng->txt(
'essay_scoring_mode_keyword_relation_any_desc'
646 $scoringOptionAllKeyword =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_keyword_relation_all' ),
647 'all', $this->lng->txt(
'essay_scoring_mode_keyword_relation_all_desc'
650 $scoringOptionOneKeyword =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_keyword_relation_one' ),
651 'one', $this->lng->txt(
'essay_scoring_mode_keyword_relation_one_desc'
655 $scoringMode->addOption( $scoringOptionNone );
656 $scoringMode->addOption( $scoringOptionAnyKeyword );
657 $scoringMode->addOption( $scoringOptionAllKeyword );
658 $scoringMode->addOption( $scoringOptionOneKeyword );
659 $scoringMode->setRequired(
true );
660 $scoringMode->setValue( strlen( $this->object->getKeywordRelation() ) ? $this->object->getKeywordRelation(
664 if ($this->object->getAnswerCount() == 0)
666 $this->
object->addAnswer(
"", 1, 0, 0 );
668 require_once
"./Modules/TestQuestionPool/classes/class.ilEssayKeywordWizardInputGUI.php";
671 $nonKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points" ),
"non_keyword_points");
672 $nonKeywordPoints->allowDecimals(
true);
673 $nonKeywordPoints->setValue( $this->object->getPoints() );
674 $nonKeywordPoints->setRequired( TRUE );
675 $nonKeywordPoints->setSize( 3 );
676 $nonKeywordPoints->setMinValue( 0.0 );
677 $nonKeywordPoints->setMinvalueShouldBeGreater(
true );
678 $scoringOptionNone->addSubItem( $nonKeywordPoints );
682 $anyKeyword->setRequired( TRUE );
683 $anyKeyword->setQuestionObject( $this->
object );
684 $anyKeyword->setSingleline( TRUE );
685 $anyKeyword->setValues( $this->object->getAnswers() );
686 $scoringOptionAnyKeyword->addSubItem( $anyKeyword );
690 $allKeyword->setRequired( TRUE );
693 $allKeyword->setValues( self::buildAnswerTextOnlyArray( $this->object->getAnswers() ) );
694 $scoringOptionAllKeyword->addSubItem( $allKeyword );
695 $allKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points" ),
"all_keyword_points");
696 $allKeywordPoints->allowDecimals(
true);
697 $allKeywordPoints->setValue( $this->object->getPoints() );
698 $allKeywordPoints->setRequired( TRUE );
699 $allKeywordPoints->setSize( 3 );
700 $allKeywordPoints->setMinValue( 0.0 );
701 $allKeywordPoints->setMinvalueShouldBeGreater(
true );
702 $scoringOptionAllKeyword->addSubItem( $allKeywordPoints );
706 $oneKeyword->setRequired( TRUE );
709 $oneKeyword->setValues( self::buildAnswerTextOnlyArray( $this->object->getAnswers() ) );
710 $scoringOptionOneKeyword->addSubItem( $oneKeyword );
711 $oneKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points" ),
"one_keyword_points");
712 $oneKeywordPoints->allowDecimals(
true);
713 $oneKeywordPoints->setValue( $this->object->getPoints() );
714 $oneKeywordPoints->setRequired( TRUE );
715 $oneKeywordPoints->setSize( 3 );
716 $oneKeywordPoints->setMinValue( 0.0 );
717 $oneKeywordPoints->setMinvalueShouldBeGreater(
true );
718 $scoringOptionOneKeyword->addSubItem( $oneKeywordPoints );
720 $form->
addItem( $scoringMode );
sprintf('%.4f', $callTime)
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
writeQuestionGenericPostData()
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)
renderPurposeSupportsFormHtml()
saveTaxonomyAssignments()
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
addBackTab(ilTabsGUI $ilTabs)
isTestPresentationContext()
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.
getPreview($show_question_only=FALSE, $showInlineFeedback=false)
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
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.
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question 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)
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
getSpecificFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
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.
getUserAnswer($active_id, $pass)
static buildAnswerTextOnlyArray($answers)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
Class for text questions.
static getScoringModesWithPointsByKeyword()
const CSS_CLASS_FEEDBACK_WRONG
const CSS_CLASS_FEEDBACK_CORRECT
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getRTEClassname()
This class represents an option in a radio group.
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()
Init YUI DomEvent.
Interface ilGuiAnswerScoringAdjustable.
Interface ilGuiQuestionScoringAdjustable.