4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
7 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
38 parent::__construct();
39 require_once
'./Modules/TestQuestionPool/classes/class.assNumeric.php';
42 $this->
object->loadFromDb(
$id);
48 if (substr($cmd, 0, 6) ==
"delete") {
59 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
61 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
83 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
85 $this->editForm =
$form;
87 $form->setFormAction($this->ctrl->getFormAction($this));
89 $form->setMultipart(
true);
90 $form->setTableWidth(
"100%");
91 $form->setId(
"assnumeric");
102 $form->setValuesByPost();
104 $form->setValuesByPost();
106 $lower =
$form->getItemByPostVar(
'lowerlimit');
107 $upper =
$form->getItemByPostVar(
'upperlimit');
109 if (!$this->
checkRange($lower->getValue(), $upper->getValue())) {
111 $lower->setAlert($DIC->language()->txt(
'qpl_numeric_lower_needs_valid_lower_alert'));
112 $upper->setAlert($DIC->language()->txt(
'qpl_numeric_upper_needs_valid_upper_alert'));
123 $this->tpl->setVariable(
"QUESTION_DATA",
$form->getHTML());
137 include_once
"./Services/Math/classes/class.EvalMath.php";
139 $eval->suppress_errors =
true;
140 if (($eval->e($lower) !==
false)
and ($eval->e($upper) !==
false)) {
141 if ($eval->e($lower) <= $eval->e($upper)) {
178 $graphicalOutput =
false,
179 $result_output =
false,
180 $show_question_only =
true,
181 $show_feedback =
false,
182 $show_correct_solution =
false,
183 $show_manual_scoring =
false,
184 $show_question_text =
true 187 $solutions = array();
188 if (($active_id > 0) && (!$show_correct_solution)) {
191 array_push($solutions, array(
"value1" => sprintf($this->lng->txt(
"value_between_x_and_y"), $this->
object->getLowerLimit(), $this->
object->getUpperLimit())));
195 require_once
'./Services/UICore/classes/class.ilTemplate.php';
196 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
197 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
198 if (is_array($solutions)) {
199 if (($active_id > 0) && (!$show_correct_solution)) {
200 if ($graphicalOutput) {
201 if ($this->object->getStep() === null) {
202 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
204 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
207 if ($reached_points == $this->object->getMaximumPoints()) {
210 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
215 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
220 foreach ($solutions as $solution) {
221 $template->setVariable(
"NUMERIC_VALUE", $solution[
"value1"]);
223 if (count($solutions) == 0) {
224 $template->setVariable(
"NUMERIC_VALUE",
" ");
227 $template->setVariable(
"NUMERIC_SIZE", $this->object->getMaxChars());
228 $questiontext = $this->
object->getQuestion();
229 if ($show_question_text ==
true) {
230 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext,
true));
236 if (strlen($feedback)) {
242 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
243 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
245 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
247 $solutionoutput = $solutiontemplate->get();
248 if (!$show_question_only) {
252 return $solutionoutput;
260 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
263 require_once
'./Services/UICore/classes/class.ilTemplate.php';
264 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output.html",
true,
true,
"Modules/TestQuestionPool");
268 $template->setVariable(
"NUMERIC_SIZE", $this->object->getMaxChars());
269 $questiontext = $this->
object->getQuestion();
270 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext,
true));
272 if (!$show_question_only) {
276 return $questionoutput;
288 public function getTestOutput($active_id,
$pass, $is_postponed =
false, $use_post_solutions =
false, $inlineFeedback)
293 if ($use_post_solutions !==
false) {
295 array(
'value1' => $use_post_solutions[
'numeric_result'])
297 } elseif ($active_id) {
300 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 301 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 303 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 305 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
310 require_once
'./Services/UICore/classes/class.ilTemplate.php';
311 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output.html",
true,
true,
"Modules/TestQuestionPool");
312 if (is_array($solutions)) {
313 foreach ($solutions as $solution) {
314 $template->setVariable(
"NUMERIC_VALUE",
" value=\"" . $solution[
"value1"] .
"\"");
317 $template->setVariable(
"NUMERIC_SIZE", $this->object->getMaxChars());
318 $questiontext = $this->
object->getQuestion();
319 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext,
true));
321 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
335 $rbacsystem = $DIC[
'rbacsystem'];
336 $ilTabs = $DIC[
'ilTabs'];
338 $ilTabs->clearTargets();
340 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
341 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
342 $q_type = $this->
object->getQuestionType();
344 if (strlen($q_type)) {
345 $classname = $q_type .
"GUI";
346 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
347 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
351 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
355 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
356 array(
"edit",
"insert",
"exec_pg"),
366 $force_active =
false;
367 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
370 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
376 array(
"editQuestion",
"save",
"cancel",
"saveEdit",
"originalSyncForm"),
396 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
415 return $this->
object->prepareTextareaOutput(
$output,
true);
420 $this->
object->setMaxChars(
$_POST[
"maxchars"]);
425 $this->
object->setLowerLimit(
$_POST[
'lowerlimit']);
426 $this->
object->setUpperLimit(
$_POST[
'upperlimit']);
427 $this->
object->setPoints(
$_POST[
'points']);
434 $maxchars->
setInfo($this->lng->txt(
'qpl_maxchars_info_numeric_question'));
435 $maxchars->setSize(10);
436 $maxchars->setDecimals(0);
437 $maxchars->setMinValue(1);
438 $maxchars->setRequired(
true);
439 if ($this->object->getMaxChars() > 0) {
440 $maxchars->setValue($this->object->getMaxChars());
450 $points->setValue($this->object->getPoints() > 0 ? $this->
object->getPoints() :
'');
451 $points->setRequired(
true);
453 $points->setMinValue(0.0);
454 $points->setMinvalueShouldBeGreater(
true);
458 $header->setTitle($this->lng->txt(
"range"));
462 $lower_limit =
new ilFormulaInputGUI($this->lng->txt(
"range_lower_limit"),
"lowerlimit");
464 $lower_limit->setMaxLength(20);
465 $lower_limit->setRequired(
true);
466 $lower_limit->setValue($this->object->getLowerLimit());
470 $upper_limit =
new ilFormulaInputGUI($this->lng->txt(
"range_upper_limit"),
"upperlimit");
472 $upper_limit->setMaxLength(20);
473 $upper_limit->setRequired(
true);
474 $upper_limit->setValue($this->object->getUpperLimit());
478 if ($this->object->getMaxChars() > 0) {
479 $lower_limit->setSize($this->object->getMaxChars());
480 $lower_limit->setMaxLength($this->object->getMaxChars());
481 $upper_limit->setSize($this->object->getMaxChars());
482 $upper_limit->setMaxLength($this->object->getMaxChars());
531 $aggregate = array();
533 foreach ($relevant_answers_chosen as $relevant_answer) {
534 if (array_key_exists($relevant_answer[
'value1'], $aggregate)) {
535 $aggregate[$relevant_answer[
'value1']]++;
537 $aggregate[$relevant_answer[
'value1']] = 1;
550 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
552 $tpl->setCurrentBlock(
'headercell');
553 $tpl->setVariable(
'HEADER', $this->lng->txt(
'tst_answer_aggr_answer_header'));
554 $tpl->parseCurrentBlock();
556 $tpl->setCurrentBlock(
'headercell');
557 $tpl->setVariable(
'HEADER', $this->lng->txt(
'tst_answer_aggr_frequency_header'));
558 $tpl->parseCurrentBlock();
560 foreach ($aggregate as
$key => $value) {
561 $tpl->setCurrentBlock(
'aggregaterow');
563 $tpl->setVariable(
'COUNT', $value);
564 $tpl->parseCurrentBlock();
573 foreach ($relevantAnswers as $ans) {
574 if (!isset($answers[$ans[
'value1']])) {
575 $answers[$ans[
'value1']] = array(
576 'answer' => $ans[
'value1'],
'frequency' => 0
580 $answers[$ans[
'value1']][
'frequency']++;
591 $points->setValue($this->object->getPoints() > 0 ? $this->
object->getPoints() :
'');
592 $points->setRequired(
true);
594 $points->setMinValue(0.0);
595 $points->setMinvalueShouldBeGreater(
true);
599 $header->setTitle($this->lng->txt(
"range"));
603 $lower_limit =
new ilFormulaInputGUI($this->lng->txt(
"range_lower_limit"),
"lowerlimit");
605 $lower_limit->setMaxLength(20);
606 $lower_limit->setRequired(
true);
607 $lower_limit->setValue($this->object->getLowerLimit());
611 $upper_limit =
new ilFormulaInputGUI($this->lng->txt(
"range_upper_limit"),
"upperlimit");
613 $upper_limit->setMaxLength(20);
614 $upper_limit->setRequired(
true);
615 $upper_limit->setValue($this->object->getUpperLimit());
619 if ($this->object->getMaxChars() > 0) {
620 $lower_limit->setSize($this->object->getMaxChars());
621 $lower_limit->setMaxLength($this->object->getMaxChars());
622 $upper_limit->setSize($this->object->getMaxChars());
623 $upper_limit->setMaxLength($this->object->getMaxChars());
632 $this->
object->setPoints((
float) $form->
getInput(
'points'));
633 $this->
object->setLowerLimit((
float) $form->
getInput(
'lowerlimit'));
634 $this->
object->setUpperLimit((
float) $form->
getInput(
'upperlimit'));
isTestPresentationContext()
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
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)
getSpecificFeedbackOutput($userSolution)
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.
if(!array_key_exists('StateId', $_REQUEST)) $id
writePostData($always=false)
{}
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
checkRange($lower, $upper)
Checks the range limits.
Numeric question GUI representation.
writeQuestionGenericPostData()
if(isset($_POST['submit'])) $form
getILIASPage($html="")
Returns the ILIAS Page around a question.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
setSize($a_size)
Set Size.
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
const CSS_CLASS_FEEDBACK_WRONG
Basic GUI class for assessment questions.
getTestOutput($active_id, $pass, $is_postponed=false, $use_post_solutions=false, $inlineFeedback)
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
saveTaxonomyAssignments()
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
Class for numeric questions.
addBackTab(ilTabsGUI $ilTabs)
__construct($id=-1)
assNumericGUI constructor
Interface ilGuiAnswerScoringAdjustable.
renderAggregateView($aggregate)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.