18 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
48 require_once
'./Modules/TestQuestionPool/classes/class.assNumeric.php';
51 $this->
object->loadFromDb(
$id);
57 if (substr($cmd, 0, 6) ==
"delete") {
68 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
70 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
92 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
94 $this->editForm = $form;
96 $form->setFormAction($this->
ctrl->getFormAction($this));
98 $form->setMultipart(
true);
99 $form->setTableWidth(
"100%");
100 $form->setId(
"assnumeric");
111 $form->setValuesByPost();
112 $errors = !$form->checkInput();
113 $form->setValuesByPost();
115 $lower = $form->getItemByPostVar(
'lowerlimit');
116 $upper = $form->getItemByPostVar(
'upperlimit');
118 if (!$this->
checkRange($lower->getValue(), $upper->getValue())) {
120 $lower->setAlert($DIC->language()->txt(
'qpl_numeric_lower_needs_valid_lower_alert'));
121 $upper->setAlert($DIC->language()->txt(
'qpl_numeric_upper_needs_valid_upper_alert'));
122 $this->tpl->setOnScreenMessage(
'failure', $DIC->language()->txt(
"form_input_not_valid"));
132 $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
146 include_once
"./Services/Math/classes/class.EvalMath.php";
148 $eval->suppress_errors =
true;
149 if (($eval->e($lower) !==
false) and ($eval->e($upper) !==
false)) {
150 if ($eval->e($lower) <= $eval->e($upper)) {
175 $graphicalOutput =
false,
176 $result_output =
false,
177 $show_question_only =
true,
178 $show_feedback =
false,
179 $show_correct_solution =
false,
180 $show_manual_scoring =
false,
181 $show_question_text =
true 184 $solutions = array();
185 if (($active_id > 0) && (!$show_correct_solution)) {
186 $solutions = $this->
object->getSolutionValues($active_id, $pass);
188 array_push($solutions, array(
"value1" => sprintf($this->
lng->txt(
"value_between_x_and_y"), $this->
object->getLowerLimit(), $this->
object->getUpperLimit())));
192 require_once
'./Services/UICore/classes/class.ilTemplate.php';
193 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
194 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
195 if (is_array($solutions)) {
196 if (($active_id > 0) && (!$show_correct_solution)) {
197 if ($graphicalOutput) {
198 if ($this->
object->getStep() === null) {
199 $reached_points = $this->
object->getReachedPoints($active_id, $pass);
201 $reached_points = $this->
object->calculateReachedPoints($active_id, $pass);
205 if ($reached_points == $this->
object->getMaximumPoints()) {
208 $template->setCurrentBlock(
"icon_ok");
209 $template->setVariable(
"ICON_OK", $correctness_icon);
210 $template->parseCurrentBlock();
213 foreach ($solutions as $solution) {
214 $template->setVariable(
"NUMERIC_VALUE", $solution[
"value1"]);
216 if (count($solutions) == 0) {
217 $template->setVariable(
"NUMERIC_VALUE",
" ");
220 $template->setVariable(
"NUMERIC_SIZE", $this->
object->getMaxChars());
221 if ($show_question_text ==
true) {
222 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
224 $questionoutput = $template->get();
228 if (strlen($feedback)) {
234 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
235 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($feedback,
true));
237 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
239 $solutionoutput = $solutiontemplate->get();
240 if (!$show_question_only) {
244 return $solutionoutput;
252 public function getPreview($show_question_only =
false, $showInlineFeedback =
false): string
255 require_once
'./Services/UICore/classes/class.ilTemplate.php';
256 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output.html",
true,
true,
"Modules/TestQuestionPool");
258 $template->setVariable(
"NUMERIC_VALUE",
" value=\"" . $this->
getPreviewSession()->getParticipantsSolution() .
"\"");
260 $template->setVariable(
"NUMERIC_SIZE", $this->
object->getMaxChars());
261 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
262 $questionoutput = $template->get();
263 if (!$show_question_only) {
267 return $questionoutput;
279 public function getTestOutput($active_id, $pass, $is_postponed =
false, $use_post_solutions =
false, $inlineFeedback =
false): string
284 if ($use_post_solutions !==
false) {
287 array(
'value1' => $use_post_solutions[
'numeric_result'])
289 } elseif ($active_id) {
290 $solutions = $this->
object->getTestOutputSolutions($active_id, $pass);
294 require_once
'./Services/UICore/classes/class.ilTemplate.php';
295 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output.html",
true,
true,
"Modules/TestQuestionPool");
296 if (is_array($solutions)) {
297 foreach ($solutions as $solution) {
298 $template->setVariable(
"NUMERIC_VALUE",
" value=\"" . $solution[
"value1"] .
"\"");
301 $template->setVariable(
"NUMERIC_SIZE", $this->
object->getMaxChars());
302 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
303 $questionoutput = $template->get();
304 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
316 return $this->
object->prepareTextareaOutput($output,
true);
321 $this->
object->setMaxChars($_POST[
"maxchars"]);
326 $this->
object->setLowerLimit($_POST[
'lowerlimit']);
327 $this->
object->setUpperLimit($_POST[
'upperlimit']);
328 $this->
object->setPoints((
float) str_replace(
',',
'.', $_POST[
'points']));
335 $maxchars->
setInfo($this->
lng->txt(
'qpl_maxchars_info_numeric_question'));
336 $maxchars->setSize(10);
337 $maxchars->setDecimals(0);
338 $maxchars->setMinValue(1);
339 $maxchars->setRequired(
true);
340 if ($this->
object->getMaxChars() > 0) {
341 $maxchars->setValue($this->
object->getMaxChars());
352 $points->setValue($this->
object->getPoints() > 0 ? $this->
object->getPoints() :
'');
353 $points->setRequired(
true);
355 $points->setMinValue(0.0);
356 $points->setMinvalueShouldBeGreater(
true);
360 $header->setTitle($this->
lng->txt(
"range"));
366 $lower_limit->setMaxLength(20);
367 $lower_limit->setRequired(
true);
368 $lower_limit->setValue((
string) $this->
object->getLowerLimit());
374 $upper_limit->setMaxLength(20);
375 $upper_limit->setRequired(
true);
376 $upper_limit->setValue((
string) $this->
object->getUpperLimit());
380 if ($this->
object->getMaxChars() > 0) {
381 $lower_limit->setSize($this->
object->getMaxChars());
382 $lower_limit->setMaxLength($this->
object->getMaxChars());
383 $upper_limit->setSize($this->
object->getMaxChars());
384 $upper_limit->setMaxLength($this->
object->getMaxChars());
432 $aggregate = array();
434 foreach ($relevant_answers_chosen as $relevant_answer) {
435 if (array_key_exists($relevant_answer[
'value1'], $aggregate)) {
436 $aggregate[$relevant_answer[
'value1']]++;
438 $aggregate[$relevant_answer[
'value1']] = 1;
451 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
461 foreach ($aggregate as
$key => $value) {
474 foreach ($relevantAnswers as $ans) {
475 if (!isset($answers[$ans[
'value1']])) {
476 $answers[$ans[
'value1']] = array(
477 'answer' => $ans[
'value1'],
'frequency' => 0
481 $answers[$ans[
'value1']][
'frequency']++;
492 $points->setValue($this->
object->getPoints() > 0 ? $this->
object->getPoints() :
'');
493 $points->setRequired(
true);
495 $points->setMinValue(0.0);
496 $points->setMinvalueShouldBeGreater(
true);
500 $header->setTitle($this->
lng->txt(
"range"));
506 $lower_limit->setMaxLength(20);
507 $lower_limit->setRequired(
true);
508 $lower_limit->setValue($this->
object->getLowerLimit());
514 $upper_limit->setMaxLength(20);
515 $upper_limit->setRequired(
true);
516 $upper_limit->setValue($this->
object->getUpperLimit());
520 if ($this->
object->getMaxChars() > 0) {
521 $lower_limit->setSize($this->
object->getMaxChars());
522 $lower_limit->setMaxLength($this->
object->getMaxChars());
523 $upper_limit->setSize($this->
object->getMaxChars());
524 $upper_limit->setMaxLength($this->
object->getMaxChars());
533 $this->
object->setPoints((
float) str_replace(
',',
'.', $form->
getInput(
'points')));
534 $this->
object->setLowerLimit((
float) str_replace(
',',
'.', $form->
getInput(
'lowerlimit')));
535 $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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
__construct(Container $dic, ilPlugin $plugin)
$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...
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
getGenericFeedbackOutput(int $active_id, ?int $pass)