50 $this->
object->loadFromDb(
$id);
63 $answers = $this->request_data_collector->raw(
'answers');
64 $this->answers_from_post = $answers[
'answer'] ?? [];
78 bool $checkonly =
false,
79 ?
bool $is_save_cmd =
null
84 $this->editForm = $form;
86 $form->setFormAction($this->
ctrl->getFormAction($this));
88 $form->setMultipart(
false);
89 $form->setTableWidth(
"100%");
90 $form->setId(
"asstextsubset");
100 $form->setValuesByPost();
101 $points = $form->getItemByPostVar(
'points');
102 $points->setValue($this->
object->getMaximumPoints());
103 $errors = !$form->checkInput();
104 $form->setValuesByPost();
118 $this->setAdditionalContentEditingModeFromPost();
119 $this->writePostData(
true);
120 $cmd = $this->request_data_collector->raw(
'cmd') ?? [];
121 $add_answers = in_array(
'addanswers', $cmd) && is_array($cmd[
'addanswers']) ? $cmd[
'addanswers'] : [];
122 $this->
object->addAnswer(
'', 0, key($add_answers) + 1);
123 $this->editQuestion();
128 $this->setAdditionalContentEditingModeFromPost();
129 $this->writePostData(
true);
130 $cmd = $this->request_data_collector->raw(
'cmd') ?? [];
131 $remove_answers = in_array(
'removeanswers', $cmd) && is_array($cmd[
'removeanswers']) ? $cmd[
'removeanswers'] : [];
132 $this->
object->deleteAnswer(key($remove_answers));
133 $this->editQuestion();
139 bool $graphical_output =
false,
140 bool $result_output =
false,
141 bool $show_question_only =
true,
142 bool $show_feedback =
false,
143 bool $show_correct_solution =
false,
144 bool $show_manual_scoring =
false,
145 bool $show_question_text =
true,
146 bool $show_inline_feedback =
true
150 if (($active_id > 0) && (!$show_correct_solution)) {
151 $solutions = $this->
object->getSolutionValues($active_id, $pass);
154 foreach ($this->
object->answers as $answer) {
155 $points_string_for_key = (string) $answer->getPoints();
156 if ($answer->getPoints() > 0) {
157 if (!array_key_exists($points_string_for_key, $rank)) {
158 $rank[$points_string_for_key] = [];
160 array_push($rank[$points_string_for_key], $answer->getAnswertext());
163 krsort($rank, SORT_NUMERIC);
164 foreach ($rank as $index => $bestsolutions) {
165 array_push($solutions, [
"value1" => join(
",", $bestsolutions),
"points" => $index]);
169 return $this->renderSolutionOutput(
177 $show_correct_solution,
178 $show_manual_scoring,
181 $show_inline_feedback,
186 mixed $user_solutions,
189 bool $graphical_output =
false,
190 bool $result_output =
false,
191 bool $show_question_only =
true,
192 bool $show_feedback =
false,
193 bool $show_correct_solution =
false,
194 bool $show_manual_scoring =
false,
195 bool $show_question_text =
true,
196 bool $show_autosave_title =
false,
197 bool $show_inline_feedback =
false,
199 $template = new
ilTemplate(
"tpl.il_as_qpl_textsubset_output_solution.html",
true,
true,
"components/ILIAS/TestQuestionPool");
200 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"components/ILIAS/TestQuestionPool");
202 $available_answers = $this->
object->getAvailableAnswers();
203 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++) {
204 if (!array_key_exists($i, $user_solutions) || (strcmp($user_solutions[$i][
"value1"],
"") == 0)) {
206 if (($active_id > 0) && (!$show_correct_solution)) {
207 if ($graphical_output) {
209 $index = $this->
object->isAnswerCorrect($available_answers, $user_solutions[$i][
"value1"]);
211 if ($index !==
false) {
212 unset($available_answers[$index]);
216 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
218 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
220 $template->setCurrentBlock(
"icon_ok");
221 $template->setVariable(
"ICON_OK", $correctness_icon);
222 $template->parseCurrentBlock();
225 $template->setCurrentBlock(
"textsubset_row");
226 $template->setVariable(
228 $this->escapeTemplatePlaceholders(
230 $user_solutions[$i][
'value1'],
231 ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401,
237 $template->setVariable(
"COUNTER", $i + 1);
238 if ($result_output) {
239 $points = $user_solutions[$i][
"points"];
240 $resulttext = ($points == 1) ?
"(%s " . $this->
lng->txt(
"point") .
")" :
"(%s " . $this->
lng->txt(
"points") .
")";
241 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
243 $template->parseCurrentBlock();
246 if ($show_question_text ==
true) {
247 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
249 $questionoutput = $template->get();
250 $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput((
int) $active_id, $pass) :
"";
251 if (strlen($feedback)) {
253 $this->hasCorrectSolution($active_id, $pass) ?
257 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
260 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
262 $solutionoutput = $solutiontemplate->get();
263 if (!$show_question_only) {
265 $solutionoutput = $this->getILIASPage($solutionoutput);
267 return $solutionoutput;
271 bool $show_question_only =
false,
272 bool $show_inline_feedback =
false
274 $solutions = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : [];
275 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html",
true,
true,
"components/ILIAS/TestQuestionPool");
276 $width = $this->
object->getMaxTextboxWidth();
277 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++) {
278 $template->setCurrentBlock(
"textsubset_row");
279 foreach ($solutions as $idx => $solution_value) {
281 $template->setVariable(
283 " value=\"" . htmlspecialchars(
284 $this->escapeTemplatePlaceholders($solution_value[
"value1"]),
285 ENT_QUOTES | ENT_SUBSTITUTE,
291 $template->setVariable(
"COUNTER", $i + 1);
292 $template->setVariable(
"TEXTFIELD_ID", $i);
293 $template->setVariable(
"TEXTFIELD_SIZE", $width);
294 $template->parseCurrentBlock();
296 $template->setVariable(
"QUESTIONTEXT", $this->renderLatex($this->
object->getQuestionForHTMLOutput()));
297 $questionoutput = $template->get();
298 if (!$show_question_only) {
300 $questionoutput = $this->getILIASPage($questionoutput);
302 return $questionoutput;
308 bool $is_question_postponed =
false,
309 array|
bool $user_post_solutions =
false,
310 bool $show_specific_inline_feedback =
false
313 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id, $pass);
316 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html",
true,
true,
"components/ILIAS/TestQuestionPool");
317 $width = $this->
object->getMaxTextboxWidth();
318 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++) {
319 $template->setCurrentBlock(
"textsubset_row");
320 foreach ($solutions as $idx => $solution_value) {
322 $template->setVariable(
324 " value=\"" . htmlspecialchars(
325 $this->escapeTemplatePlaceholders($solution_value[
"value1"]),
326 ENT_QUOTES | ENT_SUBSTITUTE,
332 $template->setVariable(
"COUNTER", $i + 1);
333 $template->setVariable(
"TEXTFIELD_ID", $i);
334 $template->setVariable(
"TEXTFIELD_SIZE", $width);
335 $template->parseCurrentBlock();
337 $template->setVariable(
"QUESTIONTEXT", $this->renderLatex($this->
object->getQuestionForHTMLOutput()));
338 $questionoutput = $template->get();
339 $pageoutput = $this->outQuestionPage(
"", $is_question_postponed, $active_id, $questionoutput);
351 $this->
object->setCorrectAnswers($this->request_data_collector->int(
'correctanswers'));
352 $this->
object->setTextRating($this->request_data_collector->string(
'text_rating'));
358 $this->
object->flushAnswers();
360 $answers = $this->request_data_collector->raw(
'answers', 3);
362 foreach ($this->answers_from_post as $index => $answertext) {
363 $this->
object->addAnswer(
365 $this->
refinery->kindlyTo()->float()->transform($answers[
'points'][$index]),
374 $correctanswers =
new ilNumberInputGUI($this->
lng->txt(
"nr_of_correct_answers"),
"correctanswers");
375 $correctanswers->setMinValue(1);
376 $correctanswers->setDecimals(0);
377 $correctanswers->setSize(3);
378 $correctanswers->setValue($this->
object->getCorrectAnswers());
379 $correctanswers->setRequired(
true);
380 $form->
addItem($correctanswers);
384 $points->setMinValue(0.0);
385 $points->setMinvalueShouldBeGreater(
true);
387 $points->setDisabled(
true);
388 $points->allowDecimals(
true);
389 $points->setValue($this->
object->getMaximumPoints());
390 $points->setRequired(
false);
396 "ci" => $this->
lng->txt(
"cloze_textgap_case_insensitive"),
397 "cs" => $this->
lng->txt(
"cloze_textgap_case_sensitive")
399 if (!$this->
object->getSelfAssessmentEditingMode()) {
400 $text_options[
"l1"] = sprintf($this->
lng->txt(
"cloze_textgap_levenshtein_of"),
"1");
401 $text_options[
"l2"] = sprintf($this->
lng->txt(
"cloze_textgap_levenshtein_of"),
"2");
402 $text_options[
"l3"] = sprintf($this->
lng->txt(
"cloze_textgap_levenshtein_of"),
"3");
403 $text_options[
"l4"] = sprintf($this->
lng->txt(
"cloze_textgap_levenshtein_of"),
"4");
404 $text_options[
"l5"] = sprintf($this->
lng->txt(
"cloze_textgap_levenshtein_of"),
"5");
406 $textrating->setOptions($text_options);
407 $textrating->setValue($this->
object->getTextRating());
415 $choices->setRequired(
true);
416 $choices->setQuestionObject($this->
object);
417 $choices->setSingleline(
true);
418 $choices->setAllowMove(
false);
419 $choices->setMinValue(0.0);
420 if ($this->
object->getAnswerCount() == 0) {
421 $this->
object->addAnswer(
"", 0, 0);
423 $choices->setValues(array_map(
425 $value->setAnswerText(html_entity_decode($value->getAnswerText()));
428 $this->
object->getAnswers()
467 foreach ($relevantAnswers as $ans) {
468 if (!isset($answers[$ans[
'value1']])) {
469 $answers[$ans[
'value1']] = [
470 'answer' => $ans[
'value1'],
'frequency' => 0
474 $answers[$ans[
'value1']][
'frequency']++;
476 $answers = $this->completeAddAnswerAction($answers, $questionIndex);
482 foreach ($answers as $key => $ans) {
485 foreach ($this->
object->getAnswers() as $item) {
486 if ($ans[
'answer'] !== $item->getAnswerText()) {
495 $answers[$key][
'addable'] =
true;
505 $choices->setRequired(
true);
506 $choices->setQuestionObject($this->
object);
507 $choices->setValues($this->
object->getAnswers());
517 $values = $input->getValues();
519 foreach ($this->
object->getAnswers() as $index => $answer) {
520 $points = (float) str_replace(
',',
'.', $values[$index]->getPoints());
521 $answer->setPoints($points);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Class for answers with a binary state indicator.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
writeQuestionGenericPostData()
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
renderEditForm(ilPropertyFormGUI $form)
saveTaxonomyAssignments()
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
static extendedTrim(string $value)
Trim non-printable characters from the beginning and end of a string.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
writePostData(bool $always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
getTestOutput(int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
__construct($id=-1)
assTextSubsetGUI constructor
completeAddAnswerAction($answers, $questionIndex)
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
getSpecificFeedbackOutput(array $user_solution)
Returns the answer specific feedback for the question.
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 the request and applies them to the data object.
getSolutionOutput(int $active_id, ?int $pass=null, 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_inline_feedback=true)
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object.
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,)
getPreview(bool $show_question_only=false, bool $show_inline_feedback=false)
getAnswersFrequency($relevantAnswers, $questionIndex)
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
Class for TextSubset questions.
const CSS_CLASS_FEEDBACK_WRONG
const CSS_CLASS_FEEDBACK_CORRECT
special template class to simplify handling of ITX/PEAR
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(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))