49 $this->
object->loadFromDb(
$id);
55 if (substr($cmd, 0, 6) ==
"delete") {
66 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
78 bool $checkonly =
false,
79 ?
bool $is_save_cmd =
null 84 $this->editForm = $form;
86 $form->setFormAction($this->
ctrl->getFormAction($this));
88 $form->setMultipart(
true);
89 $form->setTableWidth(
"100%");
90 $form->setId(
"assnumeric");
101 $form->setValuesByPost();
102 $errors = !$form->checkInput();
103 $form->setValuesByPost();
105 $lower = $form->getItemByPostVar(
'lowerlimit');
106 $upper = $form->getItemByPostVar(
'upperlimit');
108 $to_float_trafo = $this->
refinery->byTrying([
109 $this->
refinery->kindlyTo()->float(),
114 $to_float_trafo->transform($lower->getValue()),
115 $to_float_trafo->transform($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"));
138 $eval->suppress_errors =
true;
139 if (($eval->e($lower) !==
false) and ($eval->e($upper) !==
false)) {
140 if ($eval->e($lower) <= $eval->e($upper)) {
152 bool $graphical_output =
false,
153 bool $result_output =
false,
154 bool $show_question_only =
true,
155 bool $show_feedback =
false,
156 bool $show_correct_solution =
false,
157 bool $show_manual_scoring =
false,
158 bool $show_question_text =
true,
159 bool $show_inline_feedback =
true 163 if (($active_id > 0) && (!$show_correct_solution)) {
164 $solutions = $this->
object->getSolutionValues($active_id, $pass);
166 array_push($solutions, [
168 $this->
lng->txt(
"value_between_x_and_y"),
169 $this->
object->getLowerLimit(),
170 $this->
object->getUpperLimit()
183 $show_correct_solution,
184 $show_manual_scoring,
187 $show_inline_feedback
192 mixed $user_solutions,
195 bool $graphical_output =
false,
196 bool $result_output =
false,
197 bool $show_question_only =
true,
198 bool $show_feedback =
false,
199 bool $show_correct_solution =
false,
200 bool $show_manual_scoring =
false,
201 bool $show_question_text =
true,
202 bool $show_autosave_title =
false,
203 bool $show_inline_feedback =
false,
205 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output_solution.html",
true,
true,
"components/ILIAS/TestQuestionPool");
206 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"components/ILIAS/TestQuestionPool");
207 if (is_array($user_solutions)) {
208 if (($active_id > 0) && (!$show_correct_solution)) {
209 if ($graphical_output) {
211 $reached_points = $this->
object->getReachedPoints($active_id, $pass);
213 $reached_points = $this->
object->calculateReachedPoints($active_id, $pass);
217 if ($reached_points == $this->
object->getMaximumPoints()) {
220 $template->setCurrentBlock(
"icon_ok");
221 $template->setVariable(
"ICON_OK", $correctness_icon);
222 $template->parseCurrentBlock();
225 foreach ($user_solutions as $solution) {
226 $template->setVariable(
"NUMERIC_VALUE", $solution[
'value1']);
228 if (count($user_solutions) == 0) {
229 $template->setVariable(
"NUMERIC_VALUE",
" ");
232 $template->setVariable(
"NUMERIC_SIZE", $this->
object->getMaxChars());
233 if ($show_question_text ==
true) {
234 $template->setVariable(
"QUESTIONTEXT", $this->
renderLatex($this->
object->getQuestionForHTMLOutput()));
236 $questionoutput = $template->get();
240 if (strlen($feedback)) {
246 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
249 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
251 $solutionoutput = $solutiontemplate->get();
252 if (!$show_question_only) {
256 return $solutionoutput;
260 bool $show_question_only =
false,
261 bool $show_inline_feedback =
false 264 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output.html",
true,
true,
"components/ILIAS/TestQuestionPool");
266 $template->setVariable(
"NUMERIC_VALUE",
" value=\"" . $this->
getPreviewSession()->getParticipantsSolution() .
"\"");
268 $template->setVariable(
"NUMERIC_SIZE", $this->
object->getMaxChars());
269 $template->setVariable(
"QUESTIONTEXT", $this->
renderLatex($this->
object->getQuestionForHTMLOutput()));
270 $questionoutput = $template->get();
271 if (!$show_question_only) {
275 return $questionoutput;
281 bool $is_question_postponed =
false,
282 array|
bool $user_post_solutions =
false,
283 bool $show_specific_inline_feedback =
false 287 if ($user_post_solutions !==
false) {
290 [
'value1' => $user_post_solutions[
'numeric_result']]
292 } elseif ($active_id) {
293 $solutions = $this->
object->getTestOutputSolutions($active_id, $pass);
297 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output.html",
true,
true,
"components/ILIAS/TestQuestionPool");
298 if (is_array($solutions)) {
299 foreach ($solutions as $solution) {
300 $template->setVariable(
"NUMERIC_VALUE",
" value=\"" . $solution[
'value1'] .
"\"");
303 $template->setVariable(
"NUMERIC_SIZE", $this->
object->getMaxChars());
304 $template->setVariable(
"QUESTIONTEXT", $this->
renderLatex($this->
object->getQuestionForHTMLOutput()));
305 $questionoutput = $template->get();
306 $pageoutput = $this->
outQuestionPage(
"", $is_question_postponed, $active_id, $questionoutput);
323 $this->
object->setMaxChars($this->request_data_collector->int(
'maxchars') ?? 6);
328 $this->
object->setLowerLimit($this->request_data_collector->float(
'lowerlimit'));
329 $this->
object->setUpperLimit($this->request_data_collector->float(
'upperlimit'));
330 $this->
object->setPoints($this->request_data_collector->float(
'points'));
337 $maxchars->
setInfo($this->
lng->txt(
'qpl_maxchars_info_numeric_question'));
338 $maxchars->setSize(10);
339 $maxchars->setDecimals(0);
340 $maxchars->setMinValue(1);
341 $maxchars->setRequired(
true);
342 if ($this->
object->getMaxChars() > 0) {
343 $maxchars->setValue($this->
object->getMaxChars());
354 $points->setValue($this->
object->getPoints() > 0 ? $this->
object->getPoints() :
'');
355 $points->setRequired(
true);
357 $points->setMinValue(0.0);
358 $points->setMinvalueShouldBeGreater(
true);
362 $header->setTitle($this->
lng->txt(
"range"));
368 $lower_limit->setMaxLength(20);
369 $lower_limit->setRequired(
true);
370 $lower_limit->setValue((
string) $this->
object->getLowerLimit());
376 $upper_limit->setMaxLength(20);
377 $upper_limit->setRequired(
true);
378 $upper_limit->setValue((
string) $this->
object->getUpperLimit());
382 if ($this->
object->getMaxChars() > 0) {
383 $lower_limit->setSize($this->
object->getMaxChars());
384 $lower_limit->setMaxLength($this->
object->getMaxChars());
385 $upper_limit->setSize($this->
object->getMaxChars());
386 $upper_limit->setMaxLength($this->
object->getMaxChars());
423 foreach ($relevantAnswers as $ans) {
424 if (!isset($answers[$ans[
'value1']])) {
425 $answers[$ans[
'value1']] = [
426 'answer' => $ans[
'value1'],
'frequency' => 0
430 $answers[$ans[
'value1']][
'frequency']++;
441 $points->setValue($this->
object->getPoints() > 0 ? $this->
object->getPoints() :
'');
442 $points->setRequired(
true);
444 $points->setMinValue(0.0);
445 $points->setMinvalueShouldBeGreater(
true);
449 $header->setTitle($this->
lng->txt(
"range"));
455 $lower_limit->setMaxLength(20);
456 $lower_limit->setRequired(
true);
457 $lower_limit->setValue($this->
object->getLowerLimit());
463 $upper_limit->setMaxLength(20);
464 $upper_limit->setRequired(
true);
465 $upper_limit->setValue($this->
object->getUpperLimit());
469 if ($this->
object->getMaxChars() > 0) {
470 $lower_limit->setSize($this->
object->getMaxChars());
471 $lower_limit->setMaxLength($this->
object->getMaxChars());
472 $upper_limit->setSize($this->
object->getMaxChars());
473 $upper_limit->setMaxLength($this->
object->getMaxChars());
482 $this->
object->setPoints((
float) str_replace(
',',
'.', $form->
getInput(
'points')));
483 $this->
object->setLowerLimit((
float) str_replace(
',',
'.', $form->
getInput(
'lowerlimit')));
484 $this->
object->setUpperLimit((
float) str_replace(
',',
'.', $form->
getInput(
'upperlimit')));
isTestPresentationContext()
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
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 the request and applies them to the data object...
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
getAnswersFrequency($relevantAnswers, $questionIndex)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
getSpecificFeedbackOutput(array $userSolution)
const CSS_CLASS_FEEDBACK_CORRECT
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from the request 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...
writeQuestionGenericPostData()
getTestOutput(int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
const CSS_CLASS_FEEDBACK_WRONG
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
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)
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)
{}
getPreview(bool $show_question_only=false, bool $show_inline_feedback=false)
Class for numeric questions.
checkRange(float $lower, float $upper)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ilPlugin $plugin)
__construct($id=-1)
assNumericGUI constructor
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...
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)
renderEditForm(ilPropertyFormGUI $form)
getGenericFeedbackOutput(int $active_id, ?int $pass)