24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
53 include_once
"./Modules/TestQuestionPool/classes/class.assNumeric.php";
57 $this->
object->loadFromDb($id);
63 if (substr(
$cmd, 0, 6) ==
"delete")
81 $this->tpl->addJavascript(
"./Services/JavaScript/js/Basic.js");
82 $javascript =
"<script type=\"text/javascript\">ilAddOnLoad(initialSelect);\n".
83 "function initialSelect() {\n%s\n}</script>";
85 $this->tpl->addBlockFile(
"QUESTION_DATA",
"question_data",
"tpl.il_as_qpl_numeric.html",
"Modules/TestQuestionPool");
89 $internallinks = array(
90 "lm" => $this->lng->txt(
"obj_lm"),
91 "st" => $this->lng->txt(
"obj_st"),
92 "pg" => $this->lng->txt(
"obj_pg"),
93 "glo" => $this->lng->txt(
"glossary_term")
95 foreach ($internallinks as $key => $value)
97 $this->tpl->setCurrentBlock(
"internallink");
98 $this->tpl->setVariable(
"TYPE_INTERNAL_LINK", $key);
99 $this->tpl->setVariable(
"TEXT_INTERNAL_LINK", $value);
100 $this->tpl->parseCurrentBlock();
103 if ($this->object->getRangeCount() == 0)
105 $this->
object->addRange(0.0, 0.0, 0);
109 foreach ($this->object->ranges as $range)
111 $this->tpl->setCurrentBlock(
"ranges");
112 $this->tpl->setVariable(
"COUNTER", $counter);
113 $this->tpl->setVariable(
"TEXT_RANGE", $this->lng->txt(
"range"));
114 if (strlen($range->getPoints())) $this->tpl->setVariable(
"VALUE_POINTS",
" value=\"" . $range->getPoints() .
"\"");
115 if (strlen($range->getLowerLimit())) $this->tpl->setVariable(
"VALUE_LOWER_LIMIT",
" value=\"" . $range->getLowerLimit() .
"\"");
116 if (strlen($range->getUpperLimit())) $this->tpl->setVariable(
"VALUE_UPPER_LIMIT",
" value=\"" . $range->getUpperLimit() .
"\"");
117 $this->tpl->setVariable(
"TEXT_RANGE_LOWER_LIMIT", $this->lng->txt(
"range_lower_limit"));
118 $this->tpl->setVariable(
"TEXT_RANGE_UPPER_LIMIT", $this->lng->txt(
"range_upper_limit"));
119 $this->tpl->setVariable(
"TEXT_POINTS", $this->lng->txt(
"points"));
120 $this->tpl->parseCurrentBlock();
124 $this->tpl->setCurrentBlock(
"question_data");
125 $this->tpl->setVariable(
"NUMERIC_ID", $this->object->getId());
129 $questiontext = $this->
object->getQuestion();
130 $this->tpl->setVariable(
"VALUE_QUESTION",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
131 $this->tpl->setVariable(
"TEXT_TITLE", $this->lng->txt(
"title"));
132 $this->tpl->setVariable(
"TEXT_AUTHOR", $this->lng->txt(
"author"));
133 $this->tpl->setVariable(
"TEXT_COMMENT", $this->lng->txt(
"description"));
134 $this->tpl->setVariable(
"TEXT_QUESTION", $this->lng->txt(
"question"));
135 $this->tpl->setVariable(
"TEXT_SOLUTION_HINT", $this->lng->txt(
"solution_hint"));
136 $this->tpl->setVariable(
"TEXT_MAXCHARS", $this->lng->txt(
"maxchars"));
137 $this->tpl->setVariable(
"VALUE_MAXCHARS", $this->object->getMaxChars());
138 if (count($this->object->suggested_solutions))
140 $solution_array = $this->
object->getSuggestedSolution(0);
141 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
143 $this->tpl->setVariable(
"TEXT_VALUE_SOLUTION_HINT",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"solution_hint").
"</a> ");
144 $this->tpl->setVariable(
"BUTTON_REMOVE_SOLUTION", $this->lng->txt(
"remove"));
145 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"change"));
146 $this->tpl->setVariable(
"VALUE_SOLUTION_HINT", $solution_array[
"internal_link"]);
150 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"add"));
152 $this->tpl->setVariable(
"SAVE",$this->lng->txt(
"save"));
153 $this->tpl->setVariable(
"SAVE_EDIT", $this->lng->txt(
"save_edit"));
154 $this->tpl->setVariable(
"CANCEL",$this->lng->txt(
"cancel"));
155 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
156 $this->ctrl->setParameter($this,
"sel_question_types",
"assNumeric");
157 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
158 $this->tpl->setVariable(
"TEXT_QUESTION_TYPE", $this->
outQuestionType());
159 include_once
"./Services/RTE/classes/class.ilRTE.php";
161 include_once
"./Services/RTE/classes/class.$rtestring.php";
162 $rte =
new $rtestring();
163 $rte->addPlugin(
"latex");
164 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
165 include_once
"./classes/class.ilObject.php";
166 $obj_id =
$_GET[
"q_id"];
168 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
170 $this->tpl->parseCurrentBlock();
171 $this->tpl->setCurrentBlock(
"adm_content");
173 $this->tpl->parseCurrentBlock();
181 $cmd = $this->ctrl->getCmd();
183 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]))
188 foreach ($_POST as $key => $value)
190 if (preg_match(
"/range_(\d+)/", $key, $matches))
214 include_once
"./Services/Math/classes/class.EvalMath.php";
216 $eval->suppress_errors = TRUE;
217 if (($eval->e($_POST[
"rang_lower_limit"]) !== FALSE) AND ($eval->e($_POST [
"range_upper_limit"]) !== FALSE))
219 if ($eval->e($_POST[
"rang_lower_limit"]) < $eval->e($_POST[
"range_upper_limit"]))
244 include_once
"./Services/Math/classes/class.EvalMath.php";
246 $eval->suppress_errors = TRUE;
250 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]) or (!$_POST[
"maxchars"]))
258 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
260 $this->
object->setQuestion($questiontext);
261 $this->
object->setSuggestedSolution($_POST[
"solution_hint"], 0);
262 $this->
object->setShuffle($_POST[
"shuffle"]);
263 $this->
object->setMaxChars($_POST[
"maxchars"]);
269 $this->
object->flushRanges();
274 foreach ($_POST as $key => $value)
276 if (preg_match(
"/lowerlimit_(\d+)/", $key, $matches))
278 $points = $_POST[
"points_$matches[1]"];
282 $this->
setErrorMessage($this->lng->txt(
"negative_points_not_allowed"));
284 $lowerlimit = str_replace(
",",
".", $_POST[
"lowerlimit_".$matches[1]]);
285 if (strlen($lowerlimit) == 0) $lowerlimit = 0.0;
286 if ($eval->e($lowerlimit) === FALSE)
288 $this->
setErrorMessage($this->lng->txt(
"value_is_not_a_numeric_value"));
291 $upperlimit = str_replace(
",",
".", $_POST[
"upperlimit_".$matches[1]]);
292 if (strlen($upperlimit) == 0) $upperlimit = 0.0;
293 if ($eval->e($upperlimit) === FALSE)
295 $this->
setErrorMessage($this->lng->txt(
"value_is_not_a_numeric_value"));
298 $this->
object->addRange(
313 $this->
object->saveToDb();
314 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
322 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
323 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
324 $this->tpl->setVariable(
"FORMACTION", $formaction);
327 function getSolutionOutput($active_id,
$pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE)
330 $solutions = array();
331 if (($active_id > 0) && (!$show_correct_solution))
333 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
337 foreach ($this->object->ranges as $key => $range)
339 array_push($solutions, array(
"value1" => sprintf($this->lng->txt(
"value_between_x_and_y"), $range->getLowerLimit(), $range->getUpperLimit())));
344 include_once
"./classes/class.ilTemplate.php";
345 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
346 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
347 if (is_array($solutions))
349 if (($active_id > 0) && (!$show_correct_solution))
351 if ($graphicalOutput)
354 if ($this->object->getReachedPoints($active_id,
$pass) == $this->
object->getMaximumPoints())
356 $template->setCurrentBlock(
"icon_ok");
358 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
359 $template->parseCurrentBlock();
363 $template->setCurrentBlock(
"icon_ok");
365 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
366 $template->parseCurrentBlock();
370 foreach ($solutions as $solution)
372 $template->setVariable(
"NUMERIC_VALUE", $solution[
"value1"]);
374 if (count($solutions) == 0)
376 $template->setVariable(
"NUMERIC_VALUE",
" ");
379 $template->setVariable(
"NUMERIC_SIZE", $this->object->getMaxChars());
380 $questiontext = $this->
object->getQuestion();
381 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
382 $questionoutput = $template->get();
384 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
385 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
387 $solutionoutput = $solutiontemplate->get();
388 if (!$show_question_only)
393 return $solutionoutput;
399 include_once
"./classes/class.ilTemplate.php";
400 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
401 $template->setVariable(
"NUMERIC_SIZE", $this->object->getMaxChars());
402 $questiontext = $this->
object->getQuestion();
403 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
404 $questionoutput = $template->get();
405 if (!$show_question_only)
410 return $questionoutput;
419 include_once
"./Modules/Test/classes/class.ilObjTest.php";
424 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
428 include_once
"./classes/class.ilTemplate.php";
429 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
430 if (is_array($solutions))
432 foreach ($solutions as $solution)
434 $template->setVariable(
"NUMERIC_VALUE",
" value=\"".$solution[
"value1"].
"\"");
437 $template->setVariable(
"NUMERIC_SIZE", $this->object->getMaxChars());
438 $questiontext = $this->
object->getQuestion();
439 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
440 $questionoutput = $template->get();
441 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
448 if ($_POST[
"cmd"][
"addSuggestedSolution"])
458 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
463 $this->
object->saveToDb();
464 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
465 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
479 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
482 $this->
object->cleanupMediaObjectUsage();
495 $this->tpl->addBlockFile(
"ADM_CONTENT",
"feedback",
"tpl.il_as_qpl_numeric_feedback.html",
"Modules/TestQuestionPool");
496 $this->tpl->setVariable(
"FEEDBACK_TEXT", $this->lng->txt(
"feedback"));
497 $this->tpl->setVariable(
"FEEDBACK_COMPLETE", $this->lng->txt(
"feedback_complete_solution"));
498 $this->tpl->setVariable(
"VALUE_FEEDBACK_COMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)), FALSE));
499 $this->tpl->setVariable(
"FEEDBACK_INCOMPLETE", $this->lng->txt(
"feedback_incomplete_solution"));
500 $this->tpl->setVariable(
"VALUE_FEEDBACK_INCOMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)), FALSE));
502 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
504 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
506 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
508 include_once
"./Services/RTE/classes/class.ilRTE.php";
510 include_once
"./Services/RTE/classes/class.$rtestring.php";
511 $rte =
new $rtestring();
512 $rte->addPlugin(
"latex");
513 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
514 include_once
"./classes/class.ilObject.php";
515 $obj_id =
$_GET[
"q_id"];
517 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
529 global $rbacsystem, $ilTabs;
531 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
532 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
533 $q_type = $this->
object->getQuestionType();
537 $classname = $q_type .
"GUI";
538 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
539 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
544 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
547 $ilTabs->addTarget(
"edit_content",
548 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
549 array(
"edit",
"insert",
"exec_pg"),
550 "",
"", $force_active);
554 $ilTabs->addTarget(
"preview",
555 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
557 "ilPageObjectGUI",
"", $force_active);
560 $force_active =
false;
561 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
564 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
566 $ilTabs->addTarget(
"edit_properties",
568 array(
"editQuestion",
"save",
"cancel",
"addSuggestedSolution",
569 "cancelExplorer",
"linkChilds",
"removeSuggestedSolution",
571 $classname,
"", $force_active);
576 $ilTabs->addTarget(
"feedback",
577 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
578 array(
"feedback",
"saveFeedback"),
585 $ilTabs->addTarget(
"statistics",
586 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
591 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
595 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
599 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));