4 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
5 include_once
"./Modules/TestQuestionPool/classes/class.assFormulaQuestion.php";
6 include_once
"./Modules/TestQuestionPool/classes/class.assFormulaQuestionResult.php";
7 include_once
"./Modules/TestQuestionPool/classes/class.assFormulaQuestionVariable.php";
8 include_once
"./Modules/TestQuestionPool/classes/class.assFormulaQuestionUnit.php";
9 include_once
"./Modules/TestQuestionPool/classes/class.assFormulaQuestionUnitCategory.php";
10 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
11 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
32 parent::__construct();
34 $this->newUnitId = null;
37 $this->
object->loadFromDb($id);
48 global $rbacsystem, $ilTabs;
50 $ilTabs->clearTargets();
52 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
53 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
54 $q_type = $this->
object->getQuestionType();
58 $classname = $q_type .
"GUI";
59 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
60 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
65 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
68 $ilTabs->addTarget(
"edit_page",
69 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
70 array(
"edit",
"insert",
"exec_pg"),
71 "",
"", $force_active);
77 $force_active =
false;
78 if($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
82 if($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
84 if(is_array($commands))
86 foreach($commands as $key => $value)
88 if(preg_match(
"/^suggestrange_.*/", $key, $matches))
95 $ilTabs->addTarget(
"edit_properties",
98 "editQuestion",
"save",
"cancel",
"addSuggestedSolution",
99 "cancelExplorer",
"linkChilds",
"removeSuggestedSolution",
100 "parseQuestion",
"saveEdit",
"suggestRange" 102 $classname,
"", $force_active);
121 $this->addTab_Units($ilTabs);
127 $ilTabs->addTarget(
"statistics",
128 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
138 if(preg_match(
"/suggestrange_(.*?)/",
$cmd, $matches))
140 $cmd =
"suggestRange";
155 $this->editQuestion();
163 $hasErrors = (!$always) ? $this->editQuestion(
true) :
false;
167 $this->
object->setTitle(
$_POST[
"title"]);
168 $this->
object->setAuthor(
$_POST[
"author"]);
169 $this->
object->setComment(
$_POST[
"comment"]);
170 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
172 $this->
object->setQuestion($questiontext);
173 $this->
object->setEstimatedWorkingTime(
174 $_POST[
"Estimated"][
"hh"],
175 $_POST[
"Estimated"][
"mm"],
179 $this->
object->parseQuestionText();
180 $found_vars =
array();
181 $found_results =
array();
184 foreach(
$_POST as $key => $value)
186 if(preg_match(
"/^unit_(\\\$v\d+)$/", $key, $matches))
188 array_push($found_vars, $matches[1]);
190 if(preg_match(
"/^unit_(\\\$r\d+)$/", $key, $matches))
192 array_push($found_results, $matches[1]);
202 if(!$this->
object->checkForDuplicateResults())
208 foreach($found_vars as $variable)
210 if($this->
object->getVariable($variable) != null)
214 $varObj->setRangeMaxTxt(
$_POST[
"range_max_$variable"]);
215 $this->
object->addVariable($varObj);
219 $tmp_form_vars =
array();
220 $tmp_quest_vars =
array();
221 foreach($found_results as
$result)
223 $tmp_res_match = preg_match_all(
"/([$][v][0-9]*)/",
$_POST[
"formula_$result"], $form_vars);
224 $tmp_form_vars = array_merge($tmp_form_vars,$form_vars[0]);
226 $tmp_que_match = preg_match_all(
"/([$][v][0-9]*)/",
$_POST[
'question'] , $quest_vars);
227 $tmp_quest_vars= array_merge($tmp_quest_vars,$quest_vars[0]);
229 $result_has_undefined_vars = array_diff($tmp_form_vars, $found_vars);
230 $question_has_unused_vars = array_diff($tmp_quest_vars, $tmp_form_vars);
232 if(count($result_has_undefined_vars) > 0 || count($question_has_unused_vars) > 0)
235 if(count($result_has_undefined_vars) > 0)
237 $error_message .= $this->lng->txt(
"res_contains_undef_var").
'<br>';
239 if(count($question_has_unused_vars) > 0)
241 $error_message .= $this->lng->txt(
"que_contains_unused_var");
249 foreach($found_results as $result)
251 if(is_object($this->
object->getUnitrepository()->getUnit(
$_POST[
"unit_$result"])))
253 $tmp_result_unit = $this->
object->getUnitrepository()->getUnit(
$_POST[
"unit_$result"]);
257 $tmp_result_unit = NULL;
260 if($this->
object->getResult($result) != null)
262 $use_simple_rating = (
$_POST[
"rating_advanced_$result"] == 1) ? FALSE : TRUE;
265 $_POST[
"range_min_$result"],
266 $_POST[
"range_max_$result"],
267 $_POST[
"tolerance_$result"],
270 $_POST[
"formula_$result"],
272 $_POST[
"precision_$result"],
274 (
$_POST[
"rating_advanced_$result"] == 1) ?
$_POST[
"rating_sign_$result"] :
"",
275 (
$_POST[
"rating_advanced_$result"] == 1) ?
$_POST[
"rating_value_$result"] :
"",
276 (
$_POST[
"rating_advanced_$result"] == 1) ?
$_POST[
"rating_unit_$result"] :
"",
277 $_POST[
"result_type_$result"] != 0 ?
$_POST[
"result_type_$result"] : 0
279 $resObj->setRangeMinTxt(
$_POST[
"range_min_$result"]);
280 $resObj->setRangeMaxTxt(
$_POST[
"range_max_$result"]);
281 $this->
object->addResult($resObj);
282 $this->
object->addResultUnits($resObj,
$_POST[
"units_$result"]);
285 if($checked ==
false)
304 $user_id = $ilUser->getId();
305 $question_id = $this->
object->getId();
306 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewSession.php';
308 $ilAssQuestionPreviewSession->setParticipantsSolution(
array());
313 return in_array($this->ctrl->getCmd(),
array(
'saveFQ',
'saveEdit',
'saveReturnFQ'));
321 public function editQuestion($checkonly = FALSE)
327 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
329 $this->editForm = $form;
331 $form->setFormAction($this->ctrl->getFormAction($this));
333 $form->setMultipart(FALSE);
334 $form->setTableWidth(
'100%');
335 $form->setId(
'assformulaquestion');
341 $question = $form->getItemByPostVar(
'question');
342 $question->setInfo($this->lng->txt(
'fq_question_desc'));
344 $variables = $this->
object->getVariables();
345 $categorized_units = $this->
object->getUnitrepository()->getCategorizedUnits();
346 $result_units = $this->
object->__get(
'resultunits');
348 $unit_options =
array();
350 $new_category =
false;
351 foreach((
array)$categorized_units as $item)
358 if($category_name != $item->getDisplayString())
360 $new_category =
true;
361 $category_name = $item->getDisplayString();
365 $unit_options[$item->getId()] = $item->getDisplayString() . ($new_category ?
' (' . $category_name .
')' :
'');
366 $new_category =
false;
369 if(count($variables))
374 if($num_v1 > $num_v2)
378 else if($num_v1 < $num_v2)
386 foreach($variables as $variable)
392 $variable_header->setTitle(sprintf($this->lng->txt(
'variable_x'), $variable->getVariable()));
394 $range_min =
new ilNumberInputGUI($this->lng->txt(
'range_min'),
'range_min_' . $variable->getVariable());
396 $range_min->setSize(3);
397 $range_min->setRequired(
true);
398 $range_min->setValue($variable->getRangeMin());
400 $range_max =
new ilNumberInputGUI($this->lng->txt(
'range_max'),
'range_max_' . $variable->getVariable());
402 $range_max->setSize(3);
403 $range_max->setRequired(
true);
404 $range_max->setValue($variable->getRangeMax());
406 $units =
new ilSelectInputGUI($this->lng->txt(
'unit'),
'unit_' . $variable->getVariable());
407 $units->
setOptions(
array(0 => $this->lng->txt(
'no_selection')) + $unit_options);
408 if(is_object($variable->getUnit()))
410 $units->setValue($variable->getUnit()->getId());
413 $precision =
new ilNumberInputGUI($this->lng->txt(
'precision'),
'precision_' . $variable->getVariable());
415 $precision->setSize(3);
416 $precision->setMinValue(0);
417 $precision->setValue($variable->getPrecision());
418 $precision->setInfo($this->lng->txt(
'fq_precision_info'));
420 $intprecision =
new ilNumberInputGUI($this->lng->txt(
'intprecision'),
'intprecision_' . $variable->getVariable());
422 $intprecision->setMinValue(1);
423 $intprecision->setValue($variable->getIntprecision());
424 $intprecision->setInfo($this->lng->txt(
'intprecision_info'));
426 $form->addItem($variable_header);
427 $form->addItem($range_min);
428 $form->addItem($range_max);
429 $form->addItem($units);
430 $form->addItem($precision);
431 $form->addItem($intprecision);
435 $results = $this->
object->getResults();
438 require_once
'Services/Form/classes/class.ilMultiSelectInputGUI.php';
441 $num_r1 = (int)substr($r1->
getResult(), 2);
442 $num_r2 = (int)substr($r2->
getResult(), 2);
443 if($num_r1 > $num_r2)
447 else if($num_r1 < $num_r2)
461 $result_header->setTitle(sprintf($this->lng->txt(
'result_x'), $result->getResult()));
463 $formula =
new ilTextInputGUI($this->lng->txt(
'formula'),
'formula_' . $result->getResult());
464 $formula->
setInfo($this->lng->txt(
'fq_formula_desc'));
465 $formula->setRequired(
true);
466 $formula->setSize(50);
467 $formula->setValue($result->getFormula());
468 $formula->setSuffix(
' = ' . $result->getResult());
471 preg_match(
"/suggestrange_(.*)/", $this->ctrl->getCmd(), $matches) &&
472 strcmp($matches[1], $result->getResult()) == 0
476 if(strlen($result->substituteFormula($variables,
$results)))
478 $result->suggestRange($variables,
$results);
482 $range_min =
new ilNumberInputGUI($this->lng->txt(
'range_min'),
'range_min_' . $result->getResult());
484 $range_min->setSize(3);
485 $range_min->setRequired(
true);
486 $range_min->setValue($result->getRangeMin());
488 $range_max =
new ilNumberInputGUI($this->lng->txt(
'range_max'),
'range_max_' . $result->getResult());
490 $range_max->setSize(3);
491 $range_max->setRequired(
true);
492 $range_max->setValue($result->getRangeMax());
496 $precision =
new ilNumberInputGUI($this->lng->txt(
'precision'),
'precision_' . $result->getResult());
498 $precision->setSize(3);
499 $precision->setMinValue(0);
500 $precision->setInfo($this->lng->txt(
'fq_precision_info'));
501 $precision->setValue($result->getPrecision());
503 $tolerance =
new ilNumberInputGUI($this->lng->txt(
'tolerance'),
'tolerance_' . $result->getResult());
505 $tolerance->setMinValue(0);
506 $tolerance->setMaxValue(100);
507 $tolerance->allowDecimals(
false);
508 $tolerance->setInfo($this->lng->txt(
'tolerance_info'));
509 $tolerance->setValue($result->getTolerance());
512 $suggest_range_button->setHtml(
'<input type="submit" class="btn btn-default" name="cmd[suggestrange_'.$result->getResult().
']" value="'.$this->lng->txt(
"suggest_range").
'" />');
514 $sel_result_units =
new ilSelectInputGUI($this->lng->txt(
'unit'),
'unit_' . $result->getResult());
515 $sel_result_units->
setOptions(
array(0 => $this->lng->txt(
'no_selection')) + $unit_options);
516 $sel_result_units->setInfo($this->lng->txt(
'result_unit_info'));
517 if(is_object($result->getUnit()))
519 $sel_result_units->setValue($result->getUnit()->getId());
522 $mc_result_units =
new ilMultiSelectInputGUI($this->lng->txt(
'result_units'),
'units_' . $result->getResult());
524 $mc_result_units->setInfo($this->lng->txt(
'result_units_info'));
525 $selectedvalues =
array();
526 foreach($unit_options as $unit_id =>
$txt)
530 $selectedvalues[] = $unit_id;
533 $mc_result_units->setValue($selectedvalues);
535 $result_type =
new ilRadioGroupInputGUI($this->lng->txt(
'result_type_selection'),
'result_type_' . $result->getResult());
538 $no_type =
new ilRadioOption($this->lng->txt(
'no_result_type'), 0);
539 $no_type->
setInfo($this->lng->txt(
'fq_no_restriction_info'));
541 $result_dec =
new ilRadioOption($this->lng->txt(
'result_dec'), 1);
542 $result_dec->
setInfo($this->lng->txt(
'result_dec_info'));
544 $result_frac =
new ilRadioOption($this->lng->txt(
'result_frac'), 2);
545 $result_frac->
setInfo($this->lng->txt(
'result_frac_info'));
547 $result_co_frac =
new ilRadioOption($this->lng->txt(
'result_co_frac'), 3);
548 $result_co_frac->
setInfo($this->lng->txt(
'result_co_frac_info'));
550 $result_type->addOption($no_type);
551 $result_type->addOption($result_dec);
552 $result_type->addOption($result_frac);
553 $result_type->addOption($result_co_frac);
554 $result_type->setValue(strlen($result->getResultType()) ? $result->getResultType() : 0);
556 $points =
new ilNumberInputGUI($this->lng->txt(
'points'),
'points_' . $result->getResult());
558 $points->setRequired(
true);
560 $points->setMinValue(0);
561 $points->setValue(strlen($result->getPoints()) ? $result->getPoints() : 1);
563 $rating_type =
new ilCheckboxInputGUI($this->lng->txt(
'advanced_rating'),
'rating_advanced_' . $result->getResult());
565 $rating_type->setInfo($this->lng->txt(
'advanced_rating_info'));
570 if(!$advanced_rating)
572 $rating_type->setDisabled(
true);
573 $rating_type->setChecked(
false);
577 $rating_type->setChecked(strlen($result->getRatingSimple()) && $result->getRatingSimple() ? false :
true);
581 $sign =
new ilNumberInputGUI($this->lng->txt(
'rating_sign'),
'rating_sign_' . $result->getResult());
584 $sign->setMinValue(0);
585 $sign->setValue($result->getRatingSign());
586 $rating_type->addSubItem($sign);
588 $value =
new ilNumberInputGUI($this->lng->txt(
'rating_value'),
'rating_value_' . $result->getResult());
591 $value->setMinValue(0);
592 $value->setValue($result->getRatingValue());
593 $rating_type->addSubItem($value);
595 $unit =
new ilNumberInputGUI($this->lng->txt(
'rating_unit'),
'rating_unit_' . $result->getResult());
598 $unit->setMinValue(0);
599 $unit->setValue($result->getRatingUnit());
600 $rating_type->addSubItem($unit);
605 $form->addItem($result_header);
606 $form->addItem($formula);
607 $form->addItem($range_min);
608 $form->addItem($range_max);
609 $form->addItem($suggest_range_button);
610 $form->addItem($precision);
611 $form->addItem($tolerance);
612 $form->addItem($sel_result_units);
613 $form->addItem($mc_result_units);
614 $form->addItem($result_type);
615 $form->addItem($points);
616 $form->addItem($rating_type);
619 $defined_result_vars =
array();
620 $quest_vars =
array();
622 $defined_result_res =
array();
623 $result_vars =
array();
625 foreach($variables as $key =>
$object)
627 $quest_vars[$key] = $key;
632 $result_vars[$key] = $key;
640 $formula = $tmp_result->getFormula();
642 preg_match_all(
"/([$][v][0-9]*)/", $formula, $form_vars);
643 preg_match_all(
"/([$][r][0-9]*)/", $formula, $form_res);
644 foreach($form_vars[0] as $res_var)
646 $defined_result_vars[$res_var] = $res_var;
649 foreach($form_res[0] as $res_res)
651 $defined_result_res[$res_res] = $res_res;
656 $result_has_undefined_vars =
array();
657 $question_has_unused_vars =
array();
659 if(is_array($quest_vars) && count($quest_vars) > 0)
661 $result_has_undefined_vars = array_diff($defined_result_vars, $quest_vars);
662 $question_has_unused_vars = array_diff($quest_vars, $defined_result_vars);
665 if(is_array($result_vars) && count($result_vars) > 0)
667 $result_has_undefined_res = array_diff($defined_result_res, $result_vars);
672 if(count($result_has_undefined_vars) > 0 || count($question_has_unused_vars) > 0)
674 if(count($result_has_undefined_vars) > 0)
676 $error_message .= $this->lng->txt(
"res_contains_undef_var").
'<br>';
678 if(count($question_has_unused_vars) > 0)
680 $error_message .= $this->lng->txt(
"que_contains_unused_var").
'<br>';
690 if(count($result_has_undefined_res) > 0)
692 $error_message .= $this->lng->txt(
"res_contains_undef_res").
'<br>';
696 if($save && !$checked)
701 if($this->
object->getId())
704 $hidden->setValue($this->
object->getId());
705 $form->addItem($hidden);
710 $form->addCommandButton(
'parseQuestion', $this->lng->txt(
"parseQuestion"));
711 $form->addCommandButton(
'saveReturnFQ', $this->lng->txt(
"save_return"));
712 $form->addCommandButton(
'saveFQ', $this->lng->txt(
"save"));
718 $found_vars =
array();
719 $found_results =
array();
722 if(preg_match(
"/^unit_(\\\$v\d+)$/", $key, $matches))
724 array_push($found_vars, $matches[1]);
726 if(preg_match(
"/^unit_(\\\$r\d+)$/", $key, $matches))
728 array_push($found_results, $matches[1]);
732 $form->setValuesByPost();
733 $errors = !$form->checkInput();
735 $custom_errors =
false;
736 if(count($variables))
738 foreach($variables as $variable)
743 $min_range = $form->getItemByPostVar(
'range_min_' . $variable->getVariable());
744 $max_range = $form->getItemByPostVar(
'range_max_' . $variable->getVariable());
745 if($min_range->getValue() > $max_range->getValue())
747 $min_range->setAlert($this->lng->txt(
'err_range'));
748 $max_range->setAlert($this->lng->txt(
'err_range'));
749 $custom_errors =
true;
761 $min_range = $form->getItemByPostVar(
'range_min_' . $result->getResult());
762 $max_range = $form->getItemByPostVar(
'range_max_' . $result->getResult());
763 if($min_range->getValue() > $max_range->getValue())
765 $min_range->setAlert($this->lng->txt(
'err_range'));
766 $max_range->setAlert($this->lng->txt(
'err_range'));
767 $custom_errors =
true;
771 $formula = $form->getItemByPostVar(
'formula_' . $result->getResult());
772 if(strpos($formula->getValue(), $result->getResult()) !== FALSE)
774 $formula->setAlert($this->lng->txt(
'errRecursionInResult'));
775 $custom_errors =
true;
778 $result_unit = $form->getItemByPostVar(
'unit_' . $result->getResult());
779 $rating_advanced = $form->getItemByPostVar(
'rating_advanced_' . $result->getResult());
780 if(((
int)$result_unit->getValue() <= 0) && $rating_advanced->getChecked())
782 unset(
$_POST[
'rating_advanced_' . $result->getResult()]);
783 $rating_advanced->setDisabled(
true);
784 $rating_advanced->setChecked(
false);
785 $rating_advanced->setAlert($this->lng->txt(
'err_rating_advanced_not_allowed'));
786 $custom_errors =
true;
788 else if($rating_advanced->getChecked())
790 $rating_sign = $form->getItemByPostVar(
'rating_sign_' . $result->getResult());
791 $rating_value = $form->getItemByPostVar(
'rating_value_' . $result->getResult());
792 $rating_unit = $form->getItemByPostVar(
'rating_unit_' . $result->getResult());
794 $percentage = $rating_sign->getValue() + $rating_value->getValue() + $rating_unit->getValue();
795 if($percentage != 100)
797 $rating_advanced->setAlert($this->lng->txt(
'err_wrong_rating_advanced'));
798 $custom_errors =
true;
802 preg_match_all(
"/([$][v][0-9]*)/", $formula->getValue(), $form_vars);
803 $result_has_undefined_vars = array_diff($form_vars[0], (
array)$found_vars);
804 if(count($result_has_undefined_vars))
817 $form->setValuesByPost();
826 $this->tpl->setVariable(
'QUESTION_DATA', $form->getHTML());
833 if (array_key_exists(
$result->getResult(), $resultunits))
835 if (array_key_exists($unit_id, $resultunits[
$result->getResult()]))
return TRUE;
849 $resultunit =
$result->getUnit();
857 if(is_object($resultunit))
870 $this->editQuestion();
876 $old_id =
$_GET[
"q_id"];
880 $ilUser->setPref(
"tst_lastquestiontype", $this->
object->getQuestionType());
881 $ilUser->writePref(
"tst_lastquestiontype", $this->
object->getQuestionType());
883 $this->
object->saveToDb();
884 $originalexists = $this->
object->_questionExistsInPool($this->
object->original_id);
885 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
888 $this->ctrl->redirect($this,
"originalSyncForm");
891 elseif ($_GET[
"calling_test"])
893 require_once
'Modules/Test/classes/class.ilObjTest.php';
895 #var_dump(assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId())); 896 $q_id = $this->
object->getId();
899 global $tree,
$ilDB, $ilPluginAdmin;
901 include_once(
"./Modules/Test/classes/class.ilObjTest.php");
902 $_GET[
"ref_id"] = $_GET[
"calling_test"];
905 require_once
'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
908 $new_id =
$test->insertQuestion(
909 $testQuestionSetConfigFactory->getQuestionSetConfig(), $this->
object->getId()
913 if(isset($_REQUEST[
'prev_qid']))
915 $test->moveQuestionAfter($this->
object->getId() + 1, $_REQUEST[
'prev_qid']);
918 $this->ctrl->setParameter($this,
'q_id', $new_id);
919 $this->ctrl->setParameter($this,
'calling_test', $_GET[
'calling_test']);
920 #$this->ctrl->setParameter($this, 'test_ref_id', false); 924 if($_REQUEST[
'test_express_mode'])
930 ilUtil::redirect(
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=" . $_GET[
"calling_test"]);
935 if ($this->
object->getId() != $old_id)
939 $this->ctrl->redirectByClass(
"ilobjquestionpoolgui",
"questions");
949 $this->ctrl->redirectByClass(
"ilobjquestionpoolgui",
"questions");
954 $ilUser->setPref(
"tst_lastquestiontype", $this->
object->getQuestionType());
955 $ilUser->writePref(
"tst_lastquestiontype", $this->
object->getQuestionType());
956 $this->
object->saveToDb();
957 $this->editQuestion();
967 $this->editQuestion();
982 $this->
addErrorMessage($this->lng->txt(
"fill_out_all_required_fields"));
1005 $graphicalOutput = FALSE,
1006 $result_output = FALSE,
1007 $show_question_only = TRUE,
1008 $show_feedback = FALSE,
1009 $show_correct_solution = FALSE,
1010 $show_manual_scoring = FALSE,
1011 $show_question_text = TRUE
1015 $user_solution =
array();
1016 if(($active_id > 0) && (!$show_correct_solution))
1018 $solutions =
array();
1019 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1024 $user_solution[
"active_id"] = $active_id;
1025 $user_solution[
"pass"] =
$pass;
1026 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
1027 foreach($solutions as $idx => $solution_value)
1029 if(preg_match(
"/^(\\\$v\\d+)$/", $solution_value[
"value1"], $matches))
1031 $user_solution[$matches[1]] = $solution_value[
"value2"];
1033 else if(preg_match(
"/^(\\\$r\\d+)$/", $solution_value[
"value1"], $matches))
1035 if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] =
array();
1036 $user_solution[$matches[1]][
"value"] = $solution_value[
"value2"];
1038 else if(preg_match(
"/^(\\\$r\\d+)_unit$/", $solution_value[
"value1"], $matches))
1040 if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] =
array();
1041 $user_solution[$matches[1]][
"unit"] = $solution_value[
"value2"];
1048 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1053 $user_solution = (
array)$this->
object->getBestSolution($this->object->getSolutionValues($active_id,
$pass));
1057 $solutionValues =
array();
1059 foreach($this->
getPreviewSession()->getParticipantsSolution() as $val1 => $val2)
1061 $solutionValues[] =
array(
'value1' => $val1,
'value2' => $val2);
1064 $user_solution = (
array)$this->
object->getBestSolution($solutionValues);
1067 $template =
new ilTemplate(
"tpl.il_as_qpl_formulaquestion_output_solution.html",
true,
true,
'Modules/TestQuestionPool');
1068 $questiontext = $this->
object->substituteVariables($user_solution, $graphicalOutput, TRUE, $result_output);
1070 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext, TRUE));
1071 $questionoutput = $template->get();
1072 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1074 if (strlen($feedback))
1080 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
1081 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput( $feedback,
true ));
1083 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
1085 $solutionoutput = $solutiontemplate->get();
1086 if(!$show_question_only)
1089 $solutionoutput = $this->
getILIASPage($solutionoutput);
1091 return $solutionoutput;
1094 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
1096 $user_solution =
array();
1102 foreach($solutions as $val1 => $val2)
1104 if(preg_match(
"/^(\\\$v\\d+)$/", $val1, $matches))
1106 $user_solution[$matches[1]] = $val2;
1108 else if(preg_match(
"/^(\\\$r\\d+)$/", $val1, $matches))
1111 if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] =
array();
1112 $user_solution[$matches[1]][
"value"] = $val2;
1114 else if(preg_match(
"/^(\\\$r\\d+)_unit$/", $val1, $matches))
1116 if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] =
array();
1117 $user_solution[$matches[1]][
"unit"] = $val2;
1120 if(preg_match(
"/^(\\\$r\\d+)/", $val1, $matches) && $user_solution[$matches[1]][
"result_type"] == 0)
1127 if( !$this->
object->hasRequiredVariableSolutionValues($user_solution) )
1129 $user_solution = $this->
object->getInitialVariableSolutionValues();
1137 $template =
new ilTemplate(
"tpl.il_as_qpl_formulaquestion_output.html",
true,
true,
'Modules/TestQuestionPool');
1140 $questiontext = $this->
object->substituteVariables($user_solution,
false,
false,
false);
1144 $questiontext = $this->
object->substituteVariables(
array());
1146 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext, TRUE));
1147 $questionoutput = $template->get();
1148 if(!$show_question_only)
1151 $questionoutput = $this->
getILIASPage($questionoutput);
1153 return $questionoutput;
1157 function getTestOutput($active_id,
$pass, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
1162 $user_solution =
array();
1165 $solutions = (
array)$this->
object->getTestOutputSolutions($active_id,
$pass);
1167 $actualPassIndex = null;
1168 if( $this->
object->getTestPresentationConfig()->isSolutionInitiallyPrefilled() )
1170 require_once
'Modules/Test/classes/class.ilObjTest.php';
1174 foreach($solutions as $idx => $solution_value)
1176 if(preg_match(
"/^(\\\$v\\d+)$/", $solution_value[
"value1"], $matches))
1178 if( $this->
object->getTestPresentationConfig()->isSolutionInitiallyPrefilled() )
1180 $this->
object->saveCurrentSolution($active_id, $actualPassIndex, $matches[1], $solution_value[
"value2"],
true);
1183 $user_solution[$matches[1]] = $solution_value[
"value2"];
1185 else if(preg_match(
"/^(\\\$r\\d+)$/", $solution_value[
"value1"], $matches))
1188 if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] =
array();
1189 $user_solution[$matches[1]][
"value"] = $solution_value[
"value2"];
1191 else if(preg_match(
"/^(\\\$r\\d+)_unit$/", $solution_value[
"value1"], $matches))
1193 if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] =
array();
1194 $user_solution[$matches[1]][
"unit"] = $solution_value[
"value2"];
1197 if(preg_match(
"/^(\\\$r\\d+)/", $solution_value[
"value1"], $matches) && $user_solution[$matches[1]][
"result_type"] == 0)
1205 $solutions = $this->
object->getSolutionValues($active_id,
$pass,
true);
1206 foreach($solutions as $idx => $solution_value)
1208 if (preg_match(
"/^(\\\$v\\d+)$/", $solution_value[
"value1"], $matches))
1210 $user_solution[$matches[1]] = $solution_value[
"value2"];
1215 if( !$this->
object->hasRequiredVariableSolutionValues($user_solution) )
1217 foreach($this->
object->getInitialVariableSolutionValues() as $val1 => $val2)
1219 $this->
object->saveCurrentSolution($active_id,
$pass, $val1, $val2,
true);
1224 $template =
new ilTemplate(
"tpl.il_as_qpl_formulaquestion_output.html",
true,
true,
'Modules/TestQuestionPool');
1226 $questiontext = $this->
object->substituteVariables($user_solution);
1228 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext, TRUE));
1230 $questionoutput = $template->get();
1231 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
This class represents an option in a radio group.
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
addErrorMessage($errormessage)
callNewIdListeners($a_new_id)
Call the new id listeners.
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
setInfo($a_info)
Set Info.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
static stripOnlySlashes($a_str)
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getReturnToPageLink($q_id=null)
getILIASPage($html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
const CSS_CLASS_FEEDBACK_WRONG
Basic GUI class for assessment questions.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static _questionExistsInTest($question_id, $test_id)
saveTaxonomyAssignments()
This class represents a non editable value in a property form.
Create new PHPExcel object
obj_idprivate
addBackTab(ilTabsGUI $ilTabs)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
static _getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
static redirect($a_script)
http redirect to other script
static _isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.