19 require_once 
'./Modules/Test/classes/inc.AssessmentConstants.php';
    52             $this->
object->loadFromDb(
$id);
    65         $this->answers_from_post = $_POST[
'answers'][
'answer'];
    66         $hasErrors = (!$always) ? $this->
editQuestion(
true) : 
false;
    86         $this->editForm = $form;
    88         $form->setFormAction($this->
ctrl->getFormAction($this));
    90         $form->setMultipart(
false);
    91         $form->setTableWidth(
"100%");
    92         $form->setId(
"asstextsubset");
   102             $form->setValuesByPost();
   103             $points = $form->getItemByPostVar(
'points');
   104             $points->setValue($this->
object->getMaximumPoints());
   105             $errors = !$form->checkInput();
   106             $form->setValuesByPost(); 
   113             $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
   124         $position = key($_POST[
'cmd'][
'addanswers']);
   125         $this->
object->addAnswer(
"", 0, $position + 1);
   135         $position = key($_POST[
'cmd'][
'removeanswers']);
   136         $this->
object->deleteAnswer($position);
   155         $graphicalOutput = 
false,
   156         $result_output = 
false,
   157         $show_question_only = 
true,
   158         $show_feedback = 
false,
   159         $show_correct_solution = 
false,
   160         $show_manual_scoring = 
false,
   161         $show_question_text = 
true   165         if (($active_id > 0) && (!$show_correct_solution)) {
   166             $solutions = $this->
object->getSolutionValues($active_id, $pass);
   169             foreach ($this->
object->answers as $answer) {
   170                 $points_string_for_key = (string) $answer->getPoints();
   171                 if ($answer->getPoints() > 0) {
   172                     if (!array_key_exists($points_string_for_key, $rank)) {
   173                         $rank[$points_string_for_key] = array();
   175                     array_push($rank[$points_string_for_key], $answer->getAnswertext());
   178             krsort($rank, SORT_NUMERIC);
   179             foreach ($rank as $index => $bestsolutions) {
   180                 array_push($solutions, array(
"value1" => join(
",", $bestsolutions), 
"points" => $index));
   184         $show_inline_feedback = 
false;
   193             $show_correct_solution,
   194             $show_manual_scoring,
   197             $show_inline_feedback,
   202         mixed $user_solutions,
   205         bool $graphical_output = 
false,
   206         bool $result_output = 
false,
   207         bool $show_question_only = 
true,
   208         bool $show_feedback = 
false,
   209         bool $show_correct_solution = 
false,
   210         bool $show_manual_scoring = 
false,
   211         bool $show_question_text = 
true,
   212         bool $show_autosave_title = 
false,
   213         bool $show_inline_feedback = 
false,
   216         $template = 
new ilTemplate(
"tpl.il_as_qpl_textsubset_output_solution.html", 
true, 
true, 
"Modules/TestQuestionPool");
   217         $solutiontemplate = 
new ilTemplate(
"tpl.il_as_tst_solution_output.html", 
true, 
true, 
"Modules/TestQuestionPool");
   218         $available_answers = &$this->
object->getAvailableAnswers();
   219         for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++) {
   220             if (!array_key_exists($i, $user_solutions) || (strcmp($user_solutions[$i][
'value1'], 
"") == 0)) {
   222                 if (($active_id > 0) && (!$show_correct_solution)) {
   223                     if ($graphical_output) {
   225                         $index = $this->
object->isAnswerCorrect($available_answers, $user_solutions[$i][
'value1']);
   227                         if ($index !== 
false) {
   228                             unset($available_answers[$index]);
   236                         $template->setCurrentBlock(
"icon_ok");
   237                         $template->setVariable(
"ICON_OK", $correctness_icon);
   238                         $template->parseCurrentBlock();
   241                 $template->setCurrentBlock(
"textsubset_row");
   242                 $template->setVariable(
   246                             $user_solutions[$i][
'value1'],
   247                             ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401,
   253                 $template->setVariable(
"COUNTER", $i + 1);
   254                 if ($result_output) {
   255                     $points = $user_solutions[$i][
"points"];
   256                     $resulttext = ($points == 1) ? 
"(%s " . $this->
lng->txt(
"point") . 
")" : 
"(%s " . $this->
lng->txt(
"points") . 
")";
   257                     $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
   259                 $template->parseCurrentBlock();
   262         if ($show_question_text == 
true) {
   263             $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
   265         $questionoutput = $template->get();
   267         if (strlen($feedback)) {
   273             $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
   276         $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
   278         $solutionoutput = $solutiontemplate->get();
   279         if (!$show_question_only) {
   283         return $solutionoutput;
   286     public function getPreview($show_question_only = 
false, $showInlineFeedback = 
false): string
   289         $template = 
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", 
true, 
true, 
"Modules/TestQuestionPool");
   290         $width = $this->
object->getMaxTextboxWidth();
   291         for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++) {
   292             $template->setCurrentBlock(
"textsubset_row");
   293             foreach ($solutions as $idx => $solution_value) {
   295                     $template->setVariable(
"TEXTFIELD_VALUE", 
" value=\""   300             $template->setVariable(
"COUNTER", $i + 1);
   301             $template->setVariable(
"TEXTFIELD_ID", $i);
   302             $template->setVariable(
"TEXTFIELD_SIZE", $width);
   303             $template->parseCurrentBlock();
   305         $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
   306         $questionoutput = $template->get();
   307         if (!$show_question_only) {
   311         return $questionoutput;
   314     public function getTestOutput($active_id, $pass = null, $is_postponed = 
false, $use_post_solutions = 
false, $inlineFeedback = 
false): string
   319             $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id, $pass);
   322         $template = 
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", 
true, 
true, 
"Modules/TestQuestionPool");
   323         $width = $this->
object->getMaxTextboxWidth();
   324         for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++) {
   325             $template->setCurrentBlock(
"textsubset_row");
   326             foreach ($solutions as $idx => $solution_value) {
   328                     $template->setVariable(
"TEXTFIELD_VALUE", 
" value=\""   333             $template->setVariable(
"COUNTER", $i + 1);
   334             $template->setVariable(
"TEXTFIELD_ID", $i);
   335             $template->setVariable(
"TEXTFIELD_SIZE", $width);
   336             $template->parseCurrentBlock();
   338         $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
   339         $questionoutput = $template->get();
   340         $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
   352         $this->
object->setCorrectAnswers((
int) $_POST[
"correctanswers"]);
   353         $this->
object->setTextRating($_POST[
"text_rating"]);
   359         $this->
object->flushAnswers();
   360         foreach ($this->answers_from_post as $index => $answertext) {
   368         $correctanswers = 
new ilNumberInputGUI($this->
lng->txt(
"nr_of_correct_answers"), 
"correctanswers");
   369         $correctanswers->setMinValue(1);
   370         $correctanswers->setDecimals(0);
   371         $correctanswers->setSize(3);
   372         $correctanswers->setValue($this->
object->getCorrectAnswers());
   373         $correctanswers->setRequired(
true);
   374         $form->
addItem($correctanswers);
   378         $points->setMinValue(0.0);
   379         $points->setMinvalueShouldBeGreater(
true);
   381         $points->setDisabled(
true);
   382         $points->allowDecimals(
true);
   383         $points->setValue($this->
object->getMaximumPoints());
   384         $points->setRequired(
false);
   389         $text_options = array(
   390             "ci" => $this->
lng->txt(
"cloze_textgap_case_insensitive"),
   391             "cs" => $this->
lng->txt(
"cloze_textgap_case_sensitive")
   393         if (!$this->
object->getSelfAssessmentEditingMode()) {
   394             $text_options[
"l1"] = sprintf($this->
lng->txt(
"cloze_textgap_levenshtein_of"), 
"1");
   395             $text_options[
"l2"] = sprintf($this->
lng->txt(
"cloze_textgap_levenshtein_of"), 
"2");
   396             $text_options[
"l3"] = sprintf($this->
lng->txt(
"cloze_textgap_levenshtein_of"), 
"3");
   397             $text_options[
"l4"] = sprintf($this->
lng->txt(
"cloze_textgap_levenshtein_of"), 
"4");
   398             $text_options[
"l5"] = sprintf($this->
lng->txt(
"cloze_textgap_levenshtein_of"), 
"5");
   401         $textrating->setValue($this->
object->getTextRating());
   410         $choices->setQuestionObject($this->
object);
   411         $choices->setSingleline(
true);
   412         $choices->setAllowMove(
false);
   413         $choices->setMinValue(0.0);
   414         if ($this->
object->getAnswerCount() == 0) {
   415             $this->
object->addAnswer(
"", 0, 0);
   417         $choices->setValues(array_map(
   419                 $value->setAnswerText(html_entity_decode($value->getAnswerText()));
   422             $this->
object->getAnswers()
   472         $aggregate = array();
   474         foreach ($relevant_answers_chosen as $relevant_answer) {
   475             if (array_key_exists($relevant_answer[
'value1'], $aggregate)) {
   476                 $aggregate[$relevant_answer[
'value1']]++;
   478                 $aggregate[$relevant_answer[
'value1']] = 1;
   491         $tpl = 
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html', 
true, 
true, 
"Modules/TestQuestionPool");
   493         foreach ($aggregate as 
$key => $value) {
   506         foreach ($relevantAnswers as $ans) {
   507             if (!isset($answers[$ans[
'value1']])) {
   508                 $answers[$ans[
'value1']] = array(
   509                     'answer' => $ans[
'value1'], 
'frequency' => 0
   513             $answers[$ans[
'value1']][
'frequency']++;
   521         foreach ($answers as 
$key => $ans) {
   524             foreach ($this->
object->getAnswers() as $item) {
   525                 if ($ans[
'answer'] !== $item->getAnswerText()) {
   534                 $answers[
$key][
'addable'] = 
true;
   545         $choices->setQuestionObject($this->
object);
   546         $choices->setValues($this->
object->getAnswers());
   556         $values = $input->getValues();
   558         foreach ($this->
object->getAnswers() as $index => $answer) {
   559             $points = (float) str_replace(
',', 
'.', $values[$index]->getPoints());
   560             $answer->setPoints($points);
 isTestPresentationContext()
 
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
 
hasCorrectSolution($activeId, $passIndex)
 
editQuestion($checkonly=false)
Creates an output of the edit form for the question. 
 
generateCorrectnessIconsForCorrectness(int $correctness)
 
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block. 
 
getPreview($show_question_only=false, $showInlineFeedback=false)
 
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. 
 
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
 
getSpecificFeedbackOutput(array $userSolution)
 
Class for answers with a binary state indicator. 
 
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
 
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block. 
 
escapeTemplatePlaceholders(string $text)
 
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
const CSS_CLASS_FEEDBACK_CORRECT
 
ilGlobalPageTemplate $tpl
 
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
 
populateTaxonomyFormSection(ilPropertyFormGUI $form)
 
renderSolutionOutput(mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
removeanswers()
Remove an answer. 
 
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
 
getAnswersFrequency($relevantAnswers, $questionIndex)
 
writeQuestionGenericPostData()
 
renderAggregateView($aggregate)
 
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
 
const CSS_CLASS_FEEDBACK_WRONG
 
Basic GUI class for assessment questions. 
 
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
 
getTestOutput($active_id, $pass=null, $is_postponed=false, $use_post_solutions=false, $inlineFeedback=false)
 
saveTaxonomyAssignments()
 
static extendedTrim(string $value)
Trim non-printable characters from the beginning and end of a string. 
 
getILIASPage(string $html="")
Returns the ILIAS Page around a question. 
 
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getAggregatedAnswersView(array $relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
 
completeAddAnswerAction($answers, $questionIndex)
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
__construct($id=-1)
assTextSubsetGUI constructor 
 
aggregateAnswers($relevant_answers_chosen)
 
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object. 
 
setVariable(string $variable, $value='')
Sets the given variable to the given value. 
 
addanswers()
Add a new answer. 
 
writePostData(bool $always=false)
{} 
 
getGenericFeedbackOutput(int $active_id, ?int $pass)