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 require_once
'./Modules/TestQuestionPool/classes/class.assNumeric.php';
42 $this->
object->loadFromDb($id);
48 if (substr(
$cmd, 0, 6) ==
"delete")
64 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
67 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
89 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
91 $form->setFormAction($this->ctrl->getFormAction($this));
93 $form->setMultipart(TRUE);
94 $form->setTableWidth(
"100%");
95 $form->setId(
"assnumeric");
107 $form->setValuesByPost();
108 $errors = !$form->checkInput();
109 $form->setValuesByPost();
110 if (
$errors) $checkonly =
false;
113 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
126 include_once
"./Services/Math/classes/class.EvalMath.php";
128 $eval->suppress_errors = TRUE;
129 if (($eval->e(
$_POST[
"rang_lower_limit"]) !== FALSE) AND ($eval->e(
$_POST [
"range_upper_limit"]) !== FALSE))
131 if ($eval->e(
$_POST[
"rang_lower_limit"]) < $eval->e(
$_POST[
"range_upper_limit"]))
161 $graphicalOutput = FALSE,
162 $result_output = FALSE,
163 $show_question_only = TRUE,
164 $show_feedback = FALSE,
165 $show_correct_solution = FALSE,
166 $show_manual_scoring = FALSE,
167 $show_question_text = TRUE
171 $solutions = array();
172 if (($active_id > 0) && (!$show_correct_solution))
174 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
178 array_push($solutions, array(
"value1" => sprintf($this->lng->txt(
"value_between_x_and_y"), $this->
object->getLowerLimit(), $this->
object->getUpperLimit())));
182 require_once
'./Services/UICore/classes/class.ilTemplate.php';
183 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
184 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
185 if (is_array($solutions))
187 if (($active_id > 0) && (!$show_correct_solution))
189 if ($graphicalOutput)
191 if($this->object->getStep() === NULL)
193 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
197 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
200 if ($reached_points == $this->object->getMaximumPoints())
202 $template->setCurrentBlock(
"icon_ok");
204 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
205 $template->parseCurrentBlock();
209 $template->setCurrentBlock(
"icon_ok");
211 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
212 $template->parseCurrentBlock();
216 foreach ($solutions as $solution)
218 $template->setVariable(
"NUMERIC_VALUE", $solution[
"value1"]);
220 if (count($solutions) == 0)
222 $template->setVariable(
"NUMERIC_VALUE",
" ");
225 $template->setVariable(
"NUMERIC_SIZE", $this->object->getMaxChars());
226 $questiontext = $this->
object->getQuestion();
227 if ($show_question_text==
true)
229 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
231 $questionoutput = $template->get();
235 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
236 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
238 $solutionoutput = $solutiontemplate->get();
239 if (!$show_question_only)
244 return $solutionoutput;
252 public function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
255 require_once
'./Services/UICore/classes/class.ilTemplate.php';
256 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
259 $template->setVariable(
"NUMERIC_VALUE",
" value=\"".$this->
getPreviewSession()->getParticipantsSolution().
"\"");
261 $template->setVariable(
"NUMERIC_SIZE", $this->object->getMaxChars());
262 $questiontext = $this->
object->getQuestion();
263 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
264 $questionoutput = $template->get();
265 if (!$show_question_only)
270 return $questionoutput;
281 public function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
288 require_once
'./Modules/Test/classes/class.ilObjTest.php';
293 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
297 require_once
'./Services/UICore/classes/class.ilTemplate.php';
298 $template =
new ilTemplate(
"tpl.il_as_qpl_numeric_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
299 if (is_array($solutions))
301 foreach ($solutions as $solution)
303 $template->setVariable(
"NUMERIC_VALUE",
" value=\"".$solution[
"value1"].
"\"");
306 $template->setVariable(
"NUMERIC_SIZE", $this->object->getMaxChars());
307 $questiontext = $this->
object->getQuestion();
308 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
309 $questionoutput = $template->get();
310 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
323 global $rbacsystem, $ilTabs;
325 $ilTabs->clearTargets();
327 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
328 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
329 $q_type = $this->
object->getQuestionType();
333 $classname = $q_type .
"GUI";
334 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
335 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
340 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
343 $ilTabs->addTarget(
"edit_page",
344 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
345 array(
"edit",
"insert",
"exec_pg"),
346 "",
"", $force_active);
352 $force_active =
false;
353 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
356 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
358 $ilTabs->addTarget(
"edit_question",
360 array(
"editQuestion",
"save",
"cancel",
"saveEdit",
"originalSyncForm"),
361 $classname,
"", $force_active);
376 $ilTabs->addTarget(
"statistics",
377 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
394 return $this->
object->prepareTextareaOutput($output, TRUE);
399 $this->
object->setMaxChars(
$_POST[
"maxchars"] );
404 $this->
object->setLowerLimit(
$_POST[
'lowerlimit'] );
405 $this->
object->setUpperLimit(
$_POST[
'upperlimit'] );
406 $this->
object->setPoints(
$_POST[
'points'] );
412 $maxchars =
new ilNumberInputGUI($this->lng->txt(
"maxchars" ),
"maxchars");
413 $maxchars->
setInfo($this->lng->txt(
'qpl_maxchars_info_numeric_question'));
414 $maxchars->setSize( 10 );
415 $maxchars->setDecimals( 0 );
416 $maxchars->setMinValue( 1 );
417 $maxchars->setRequired(
true );
418 if ($this->object->getMaxChars() > 0)
420 $maxchars->setValue($this->object->getMaxChars());
430 $points->setValue( $this->object->getPoints() > 0 ? $this->
object->getPoints() :
'' );
431 $points->setRequired( TRUE );
432 $points->setSize( 3 );
433 $points->setMinValue( 0.0 );
434 $points->setMinvalueShouldBeGreater(
true );
438 $header->setTitle( $this->lng->txt(
"range" ) );
442 $lower_limit =
new ilFormulaInputGUI($this->lng->txt(
"range_lower_limit" ),
"lowerlimit");
444 $lower_limit->setMaxLength( 20 );
445 $lower_limit->setRequired(
true );
446 $lower_limit->setValue( $this->object->getLowerLimit() );
447 $form->
addItem( $lower_limit );
450 $upper_limit =
new ilFormulaInputGUI($this->lng->txt(
"range_upper_limit" ),
"upperlimit");
452 $upper_limit->setMaxLength( 20 );
453 $upper_limit->setRequired(
true );
454 $upper_limit->setValue( $this->object->getUpperLimit() );
455 $form->
addItem( $upper_limit );
458 if( $this->object->getMaxChars() > 0 )
460 $lower_limit->setSize( $this->object->getMaxChars() );
461 $lower_limit->setMaxLength( $this->object->getMaxChars() );
462 $upper_limit->setSize( $this->object->getMaxChars() );
463 $upper_limit->setMaxLength( $this->object->getMaxChars() );
511 $aggregate = array();
513 foreach ($relevant_answers_chosen as $relevant_answer)
515 if ( array_key_exists($relevant_answer[
'value1'], $aggregate) )
517 $aggregate[$relevant_answer[
'value1']]++;
521 $aggregate[$relevant_answer[
'value1']] = 1;
534 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
536 foreach ($aggregate as $key => $value)
538 $tpl->setCurrentBlock(
'aggregaterow' );
539 $tpl->setVariable(
'OPTION', $key );
540 $tpl->setVariable(
'COUNT', $value );
541 $tpl->parseCurrentBlock();