19 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
51 $this->
object->loadFromDb(
$id);
57 if (substr($cmd, 0, 6) ==
"delete") {
68 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
92 $this->editForm = $form;
94 $form->setFormAction($this->
ctrl->getFormAction($this));
96 $form->setMultipart(
true);
97 $form->setTableWidth(
"100%");
98 $form->setId(
"assnumeric");
109 $form->setValuesByPost();
110 $errors = !$form->checkInput();
111 $form->setValuesByPost();
113 $lower = $form->getItemByPostVar(
'lowerlimit');
114 $upper = $form->getItemByPostVar(
'upperlimit');
116 if (!$this->
checkRange($lower->getValue(), $upper->getValue())) {
118 $lower->setAlert($DIC->language()->txt(
'qpl_numeric_lower_needs_valid_lower_alert'));
119 $upper->setAlert($DIC->language()->txt(
'qpl_numeric_upper_needs_valid_upper_alert'));
120 $this->tpl->setOnScreenMessage(
'failure', $DIC->language()->txt(
"form_input_not_valid"));
130 $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
145 $eval->suppress_errors =
true;
146 if (($eval->e($lower) !==
false) and ($eval->e($upper) !==
false)) {
147 if ($eval->e($lower) <= $eval->e($upper)) {
172 $graphicalOutput =
false,
173 $result_output =
false,
174 $show_question_only =
true,
175 $show_feedback =
false,
176 $show_correct_solution =
false,
177 $show_manual_scoring =
false,
178 $show_question_text =
true 182 if (($active_id > 0) && (!$show_correct_solution)) {
183 $solutions = $this->
object->getSolutionValues($active_id, $pass);
185 array_push($solutions, [
187 $this->
lng->txt(
"value_between_x_and_y"),
188 $this->
object->getLowerLimit(),
189 $this->
object->getUpperLimit()
202 $show_correct_solution,
203 $show_manual_scoring,
211 mixed $user_solutions,
214 bool $graphical_output =
false,
215 bool $result_output =
false,
216 bool $show_question_only =
true,
217 bool $show_feedback =
false,
218 bool $show_correct_solution =
false,
219 bool $show_manual_scoring =
false,
220 bool $show_question_text =
true,
221 bool $show_autosave_title =
false,
222 bool $show_inline_feedback =
false,
224 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
225 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
226 if (is_array($user_solutions)) {
227 if (($active_id > 0) && (!$show_correct_solution)) {
228 if ($graphical_output) {
229 if ($this->
object->getStep() === null) {
230 $reached_points = $this->
object->getReachedPoints($active_id, $pass);
232 $reached_points = $this->
object->calculateReachedPoints($active_id, $pass);
236 if ($reached_points == $this->
object->getMaximumPoints()) {
239 $template->setCurrentBlock(
"icon_ok");
240 $template->setVariable(
"ICON_OK", $correctness_icon);
241 $template->parseCurrentBlock();
244 foreach ($user_solutions as $solution) {
245 $template->setVariable(
"NUMERIC_VALUE", $solution[
'value1']);
247 if (count($user_solutions) == 0) {
248 $template->setVariable(
"NUMERIC_VALUE",
" ");
251 $template->setVariable(
"NUMERIC_SIZE", $this->
object->getMaxChars());
252 if ($show_question_text ==
true) {
253 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
255 $questionoutput = $template->get();
259 if (strlen($feedback)) {
265 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
268 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
270 $solutionoutput = $solutiontemplate->get();
271 if (!$show_question_only) {
275 return $solutionoutput;
283 public function getPreview($show_question_only =
false, $showInlineFeedback =
false): string
286 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output.html",
true,
true,
"Modules/TestQuestionPool");
288 $template->setVariable(
"NUMERIC_VALUE",
" value=\"" . $this->
getPreviewSession()->getParticipantsSolution() .
"\"");
290 $template->setVariable(
"NUMERIC_SIZE", $this->
object->getMaxChars());
291 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
292 $questionoutput = $template->get();
293 if (!$show_question_only) {
297 return $questionoutput;
309 public function getTestOutput($active_id, $pass, $is_postponed =
false, $use_post_solutions =
false, $inlineFeedback =
false): string
314 if ($use_post_solutions !==
false) {
317 array(
'value1' => $use_post_solutions[
'numeric_result'])
319 } elseif ($active_id) {
320 $solutions = $this->
object->getTestOutputSolutions($active_id, $pass);
324 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output.html",
true,
true,
"Modules/TestQuestionPool");
325 if (is_array($solutions)) {
326 foreach ($solutions as $solution) {
327 $template->setVariable(
"NUMERIC_VALUE",
" value=\"" . $solution[
'value1'] .
"\"");
330 $template->setVariable(
"NUMERIC_SIZE", $this->
object->getMaxChars());
331 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
332 $questionoutput = $template->get();
333 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
350 $this->
object->setMaxChars($_POST[
"maxchars"]);
355 $this->
object->setLowerLimit($_POST[
'lowerlimit']);
356 $this->
object->setUpperLimit($_POST[
'upperlimit']);
357 $this->
object->setPoints((
float) str_replace(
',',
'.', $_POST[
'points']));
364 $maxchars->setInfo($this->
lng->txt(
'qpl_maxchars_info_numeric_question'));
365 $maxchars->setSize(10);
366 $maxchars->setDecimals(0);
367 $maxchars->setMinValue(1);
368 $maxchars->setRequired(
true);
369 if ($this->
object->getMaxChars() > 0) {
370 $maxchars->setValue($this->
object->getMaxChars());
380 $points->allowDecimals(
true);
381 $points->setValue($this->
object->getPoints() > 0 ? $this->
object->getPoints() :
'');
382 $points->setRequired(
true);
384 $points->setMinValue(0.0);
385 $points->setMinvalueShouldBeGreater(
true);
389 $header->setTitle($this->
lng->txt(
"range"));
395 $lower_limit->setMaxLength(20);
396 $lower_limit->setRequired(
true);
397 $lower_limit->setValue((
string) $this->
object->getLowerLimit());
403 $upper_limit->setMaxLength(20);
404 $upper_limit->setRequired(
true);
405 $upper_limit->setValue((
string) $this->
object->getUpperLimit());
409 if ($this->
object->getMaxChars() > 0) {
410 $lower_limit->setSize($this->
object->getMaxChars());
411 $lower_limit->setMaxLength($this->
object->getMaxChars());
412 $upper_limit->setSize($this->
object->getMaxChars());
413 $upper_limit->setMaxLength($this->
object->getMaxChars());
463 foreach ($relevant_answers_chosen as $relevant_answer) {
464 if (array_key_exists($relevant_answer[
'value1'], $aggregate)) {
465 $aggregate[$relevant_answer[
'value1']]++;
467 $aggregate[$relevant_answer[
'value1']] = 1;
480 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
490 foreach ($aggregate as
$key => $value) {
503 foreach ($relevantAnswers as $ans) {
504 if (!isset($answers[$ans[
'value1']])) {
505 $answers[$ans[
'value1']] = array(
506 'answer' => $ans[
'value1'],
'frequency' => 0
510 $answers[$ans[
'value1']][
'frequency']++;
520 $points->allowDecimals(
true);
521 $points->setValue($this->
object->getPoints() > 0 ? $this->
object->getPoints() :
'');
522 $points->setRequired(
true);
524 $points->setMinValue(0.0);
525 $points->setMinvalueShouldBeGreater(
true);
529 $header->setTitle($this->
lng->txt(
"range"));
535 $lower_limit->setMaxLength(20);
536 $lower_limit->setRequired(
true);
537 $lower_limit->setValue($this->
object->getLowerLimit());
543 $upper_limit->setMaxLength(20);
544 $upper_limit->setRequired(
true);
545 $upper_limit->setValue($this->
object->getUpperLimit());
549 if ($this->
object->getMaxChars() > 0) {
550 $lower_limit->setSize($this->
object->getMaxChars());
551 $lower_limit->setMaxLength($this->
object->getMaxChars());
552 $upper_limit->setSize($this->
object->getMaxChars());
553 $upper_limit->setMaxLength($this->
object->getMaxChars());
562 $this->
object->setPoints((
float) str_replace(
',',
'.', $form->
getInput(
'points')));
563 $this->
object->setLowerLimit((
float) str_replace(
',',
'.', $form->
getInput(
'lowerlimit')));
564 $this->
object->setUpperLimit((
float) str_replace(
',',
'.', $form->
getInput(
'upperlimit')));
isTestPresentationContext()
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
getPreview($show_question_only=false, $showInlineFeedback=false)
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
getAnswersFrequency($relevantAnswers, $questionIndex)
aggregateAnswers($relevant_answers_chosen)
addBasicQuestionFormProperties(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.
getSpecificFeedbackOutput(array $userSolution)
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
const CSS_CLASS_FEEDBACK_CORRECT
ilGlobalPageTemplate $tpl
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
checkRange($lower, $upper)
Checks the range limits.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
writeQuestionGenericPostData()
getTestOutput($active_id, $pass, $is_postponed=false, $use_post_solutions=false, $inlineFeedback=false)
const CSS_CLASS_FEEDBACK_WRONG
Basic GUI class for assessment questions.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
getAggregatedAnswersView(array $relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
saveTaxonomyAssignments()
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
writePostData(bool $always=false)
{}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct($id=-1)
assNumericGUI constructor
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
renderAggregateView($aggregate)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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,)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
getGenericFeedbackOutput(int $active_id, ?int $pass)