4require_once 
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
 
    5require_once 
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
 
    6require_once 
'./Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
 
    7require_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());
 
  442        $form->addItem($maxchars);
 
  449        $points->allowDecimals(
true);
 
  450        $points->setValue($this->object->getPoints() > 0 ? $this->object->getPoints() : 
'');
 
  451        $points->setRequired(
true);
 
  453        $points->setMinValue(0.0);
 
  454        $points->setMinvalueShouldBeGreater(
true);
 
  455        $form->addItem($points);
 
  458        $header->setTitle($this->lng->txt(
"range"));
 
  462        $lower_limit = 
new ilFormulaInputGUI($this->lng->txt(
"range_lower_limit"), 
"lowerlimit");
 
  463        $lower_limit->setSize(25);
 
  464        $lower_limit->setMaxLength(20);
 
  465        $lower_limit->setRequired(
true);
 
  466        $lower_limit->setValue($this->object->getLowerLimit());
 
  467        $form->addItem($lower_limit);
 
  470        $upper_limit = 
new ilFormulaInputGUI($this->lng->txt(
"range_upper_limit"), 
"upperlimit");
 
  471        $upper_limit->setSize(25);
 
  472        $upper_limit->setMaxLength(20);
 
  473        $upper_limit->setRequired(
true);
 
  474        $upper_limit->setValue($this->object->getUpperLimit());
 
  475        $form->addItem($upper_limit);
 
  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']++;
 
  590        $points->allowDecimals(
true);
 
  591        $points->setValue($this->object->getPoints() > 0 ? $this->object->getPoints() : 
'');
 
  592        $points->setRequired(
true);
 
  594        $points->setMinValue(0.0);
 
  595        $points->setMinvalueShouldBeGreater(
true);
 
  596        $form->addItem($points);
 
  599        $header->setTitle($this->lng->txt(
"range"));
 
  603        $lower_limit = 
new ilFormulaInputGUI($this->lng->txt(
"range_lower_limit"), 
"lowerlimit");
 
  604        $lower_limit->setSize(25);
 
  605        $lower_limit->setMaxLength(20);
 
  606        $lower_limit->setRequired(
true);
 
  607        $lower_limit->setValue($this->object->getLowerLimit());
 
  608        $form->addItem($lower_limit);
 
  611        $upper_limit = 
new ilFormulaInputGUI($this->lng->txt(
"range_upper_limit"), 
"upperlimit");
 
  612        $upper_limit->setSize(25);
 
  613        $upper_limit->setMaxLength(20);
 
  614        $upper_limit->setRequired(
true);
 
  615        $upper_limit->setValue($this->object->getUpperLimit());
 
  616        $form->addItem($upper_limit);
 
  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'));
 
An exception for terminatinating execution or to throw for unit testing.
Numeric question GUI representation.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
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.
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
checkRange($lower, $upper)
Checks the range limits.
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
__construct($id=-1)
assNumericGUI constructor
aggregateAnswers($relevant_answers_chosen)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
getPreview($show_question_only=false, $showInlineFeedback=false)
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
getSpecificFeedbackOutput($userSolution)
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
renderAggregateView($aggregate)
getAnswersFrequency($relevantAnswers, $questionIndex)
writePostData($always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
getTestOutput($active_id, $pass, $is_postponed=false, $use_post_solutions=false, $inlineFeedback)
Class for numeric questions.
Basic GUI class for assessment questions.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
writeQuestionGenericPostData()
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
getILIASPage($html="")
Returns the ILIAS Page around a question.
getQuestionTemplate()
get question template
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
saveTaxonomyAssignments()
addBackTab(ilTabsGUI $ilTabs)
isTestPresentationContext()
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question,...
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
const CSS_CLASS_FEEDBACK_WRONG
const CSS_CLASS_FEEDBACK_CORRECT
special template class to simplify handling of ITX/PEAR
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
if(!array_key_exists('StateId', $_REQUEST)) $id
Interface ilGuiAnswerScoringAdjustable.
Interface ilGuiQuestionScoringAdjustable.
if(isset($_POST['submit'])) $form