4 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
5 include_once
"./Modules/TestQuestionPool/classes/class.assFormulaQuestionResult.php";
6 include_once
"./Modules/TestQuestionPool/classes/class.assFormulaQuestionVariable.php";
7 include_once
"./Modules/TestQuestionPool/classes/class.ilUnitConfigurationRepository.php";
8 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
9 include_once
"./Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php";
10 require_once
'./Modules/TestQuestionPool/classes/class.ilUserQuestionResult.php';
49 $this->variables = array();
50 $this->results = array();
51 $this->resultunits = array();
57 $this->variables = array();
67 if (array_key_exists($variable, $this->variables)) {
68 return $this->variables[$variable];
75 $this->variables[$variable->getVariable()] = $variable;
80 $this->results = array();
90 if (array_key_exists(
$result, $this->results)) {
103 $this->resultunits[
$result->getResult()] = array();
104 if ((!is_object(
$result)) || (!is_array($unit_ids))) {
107 foreach ($unit_ids as
$id) {
108 if (is_numeric($id) && ($id > 0)) {
116 if (is_object(
$result) && is_object($unit)) {
117 if (!is_array($this->resultunits[
$result->getResult()])) {
118 $this->resultunits[
$result->getResult()] = array();
120 $this->resultunits[
$result->getResult()][$unit->getId()] = $unit;
127 return $this->resultunits[
$result->getResult()];
136 if (array_key_exists($unit_id, $this->resultunits[
$result->getResult()])) {
148 if (preg_match_all(
"/(\\\$v\\d+)/ims", $this->
getQuestion(), $matches)) {
149 foreach ($matches[1] as $variable) {
155 if (preg_match_all(
"/(\\\$r\\d+)/ims", $this->
getQuestion(), $rmatches)) {
156 foreach ($rmatches[1] as
$result) {
165 if (preg_match_all(
"/(\\\$v\\d+)/ims", $this->
getQuestion(), $matches)) {
166 if ((count(array_unique($matches[1]))) != count($matches[1])) {
175 if (preg_match_all(
"/(\\\$r\\d+)/ims", $this->
getQuestion(), $rmatches)) {
176 if ((count(array_unique($rmatches[1]))) != count($rmatches[1])) {
189 $resObjects = array();
192 if (preg_match_all(
"/(\\\$r\\d+)/ims", $questionText, $matches)) {
193 foreach ($matches[1] as $resultKey) {
194 $resObjects[] = $this->
getResult($resultKey);
207 $varObjects = array();
210 if (preg_match_all(
"/(\\\$v\\d+)/ims", $questionText, $matches)) {
211 foreach ($matches[1] as $variableKey) {
226 if (!isset($userSolution[$varObj->getVariable()])) {
230 if (!strlen($userSolution[$varObj->getVariable()])) {
247 $variableSolutionValues = array();
250 $variableSolutionValues[$varObj->getVariable()] = $varObj->getValue();
253 return $variableSolutionValues;
264 public function substituteVariables(array $userdata, $graphicalOutput =
false, $forsolution =
false, $result_output =
false)
266 if ((count($this->results) == 0) && (count($this->variables) == 0)) {
273 if (isset($userdata[$varObj->getVariable()]) && strlen($userdata[$varObj->getVariable()])) {
274 $varObj->setValue($userdata[$varObj->getVariable()]);
277 $unit = (is_object($varObj->getUnit())) ? $varObj->getUnit()->getUnit() :
"";
278 $val = (strlen($varObj->getValue()) > 8) ? strtoupper(sprintf(
"%e", $varObj->getValue())) : $varObj->getValue();
280 $text = preg_replace(
"/\\$" . substr($varObj->getVariable(), 1) .
"(?![0-9]+)/", $val .
" " . $unit .
"\\1",
$text);
283 if (preg_match_all(
"/(\\\$r\\d+)/ims", $this->
getQuestion(), $rmatches)) {
284 foreach ($rmatches[1] as
$result) {
288 $user_data[
$result][
'result_type'] = $resObj->getResultType();
296 if (is_array($userdata)) {
297 if (is_array($userdata[$result])) {
298 if (
false && $forsolution && $result_output) {
300 $value = sprintf(
"%." . $resObj->getPrecision() .
"f", $value_org);
303 if (is_array($value)) {
304 $frac_helper = $value[1];
310 $value = $userdata[
$result][
"value"];
312 $value =
' value="' . $userdata[
$result][
"value"] .
'"';
319 $value = sprintf(
"%." . $resObj->getPrecision() .
"f", $value);
323 if (is_array($value)) {
324 $frac_helper = $value[1];
327 $value =
' value="' . $value .
'"';
332 $use_precision = !($userdata == null && $graphicalOutput ==
false && $forsolution ==
false && $result_output ==
false);
334 $val = $resObj->calculateFormula($this->
getVariables(), $this->
getResults(), parent::getId(), $use_precision);
338 $val = $resObj->convertDecimalToCoprimeFraction($val);
339 if (is_array($val)) {
340 $frac_helper = $val[1];
344 $val = sprintf(
"%." . $resObj->getPrecision() .
"f", $val);
345 $val = (strlen($val) > 8) ? strtoupper(sprintf(
"%e", $val)) : $val;
347 $value =
' value="' . $val .
'"';
354 $input =
'<input class="ilc_qinput_TextInput" type="text" spellcheck="false" autocomplete="off" autocorrect="off" autocapitalize="off" name="result_' . $result .
'"' . $value .
' />';
360 if (is_array($userdata)) {
362 if ($userdata[$result][
"unit"] == $unit->getId()) {
363 $units = $unit->getUnit();
367 if ($resObj->getUnit()) {
368 $units = $resObj->getUnit()->getUnit();
372 $units =
'<select name="result_' . $result .
'_unit">';
373 $units .=
'<option value="-1">' . $this->lng->txt(
"select_unit") .
'</option>';
375 $units .=
'<option value="' . $unit->getId() .
'"';
376 if ((is_array($userdata[$result])) && (strlen($userdata[$result][
"unit"]))) {
377 if ($userdata[$result][
"unit"] == $unit->getId()) {
378 $units .=
' selected="selected"';
381 $units .=
'>' . $unit->getUnit() .
'</option>';
383 $units .=
'</select>';
388 switch ($resObj->getResultType()) {
390 $units .=
' ' . $this->lng->txt(
'expected_result_type') .
': ' . $this->lng->txt(
'result_dec');
393 if (strlen($frac_helper)) {
394 $units .=
' ≈ ' . $frac_helper .
', ';
395 } elseif (is_array($userdata) && isset($userdata[$result]) && strlen($userdata[$result][
"frac_helper"])) {
396 if (!preg_match(
'-/-', $value)) {
397 $units .=
' ≈ ' . $userdata[
$result][
"frac_helper"] .
', ';
400 $units .=
' ' . $this->lng->txt(
'expected_result_type') .
': ' . $this->lng->txt(
'result_frac');
403 if (strlen($frac_helper)) {
404 $units .=
' ≈ ' . $frac_helper .
', ';
405 } elseif (is_array($userdata) && isset($userdata[$result]) && strlen($userdata[$result][
"frac_helper"])) {
406 if (!preg_match(
'-/-', $value)) {
407 $units .=
' ≈ ' . $userdata[
$result][
"frac_helper"] .
', ';
410 $units .=
' ' . $this->lng->txt(
'expected_result_type') .
': ' . $this->lng->txt(
'result_co_frac');
416 if ($graphicalOutput) {
419 if (is_array($userdata) && is_array($userdata[$result])) {
420 if ($userdata[$result][
"unit"] > 0) {
424 if (isset($userdata[$result][
"value"])) {
425 $user_value = $userdata[
$result][
"value"];
429 $template =
new ilTemplate(
"tpl.il_as_qpl_formulaquestion_output_solution_image.html",
true,
true,
'Modules/TestQuestionPool');
431 if ($resObj->isCorrect($this->getVariables(), $this->
getResults(), $user_value, $resunit)) {
434 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
437 $template->setCurrentBlock(
"icon_not_ok");
439 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
445 if ($result_output) {
446 $template =
new ilTemplate(
"tpl.il_as_qpl_formulaquestion_output_solution_result.html",
true,
true,
'Modules/TestQuestionPool');
448 if (is_array($userdata)) {
449 $found = $resObj->getResultInfo($this->
getVariables(), $this->
getResults(), $userdata[$resObj->getResult()][
"value"], $userdata[$resObj->getResult()][
"unit"], $this->
getUnitrepository()->getUnits());
451 $found = $resObj->getResultInfo($this->
getVariables(), $this->
getResults(), $resObj->calculateFormula($this->getVariables(), $this->
getResults(), parent::getId()), is_object($resObj->getUnit()) ? $resObj->getUnit()->getId() : null, $this->
getUnitrepository()->getUnits());
454 if ($resObj->getRatingSimple()) {
456 $resulttext .=
"n/a";
458 $resulttext .= $found[
'points'] .
" " . (($found[
'points'] == 1) ? $this->lng->txt(
'point') : $this->lng->txt(
'points'));
461 $resulttext .= $this->lng->txt(
"rated_sign") .
" " . (($found[
'sign']) ? $found[
'sign'] : 0) .
" " . (($found[
'sign'] == 1) ? $this->lng->txt(
'point') : $this->lng->txt(
'points')) .
", ";
462 $resulttext .= $this->lng->txt(
"rated_value") .
" " . (($found[
'value']) ? $found[
'value'] : 0) .
" " . (($found[
'value'] == 1) ? $this->lng->txt(
'point') : $this->lng->txt(
'points')) .
", ";
463 $resulttext .= $this->lng->txt(
"rated_unit") .
" " . (($found[
'unit']) ? $found[
'unit'] : 0) .
" " . (($found[
'unit'] == 1) ? $this->lng->txt(
'point') : $this->lng->txt(
'points'));
467 $template->setVariable(
"RESULT_OUTPUT", $resulttext);
471 $text = preg_replace(
"/\\\$" . substr($result, 1) .
"(?![0-9]+)/",
$input .
" " . $units .
" " . $checkSign .
" " . $resultOutput .
" " .
"\\1",
$text);
486 $resultunit =
$result->getUnit();
488 foreach ($result_units as $unit) {
489 if (is_object($resultunit)) {
490 if ($resultunit->getId() != $unit->getId()) {
491 if ($resultunit->getBaseUnit() && $unit->getBaseUnit()) {
492 if ($resultunit->getBaseUnit() == $unit->getBaseUnit()) {
496 if ($resultunit->getBaseUnit()) {
497 if ($resultunit->getBaseUnit() == $unit->getId()) {
501 if ($unit->getBaseUnit()) {
502 if ($unit->getBaseUnit() == $resultunit->getId()) {
532 $ilDB = $DIC[
'ilDB'];
536 $affectedRows =
$ilDB->manipulateF(
538 DELETE FROM il_qpl_qst_fq_var 539 WHERE question_fi = %s",
541 array($this->
getId())
544 foreach ($this->variables as $variable) {
545 $next_id =
$ilDB->nextId(
'il_qpl_qst_fq_var');
549 'variable_id' => array(
'integer', $next_id),
550 'question_fi' => array(
'integer', $this->
getId()),
551 'variable' => array(
'text', $variable->getVariable()),
552 'range_min' => array(
'float', ((strlen($variable->getRangeMin())) ? $variable->getRangeMin() : 0.0)),
553 'range_max' => array(
'float', ((strlen($variable->getRangeMax())) ? $variable->getRangeMax() : 0.0)),
554 'unit_fi' => array(
'integer', (is_object($variable->getUnit()) ? (
int) $variable->getUnit()->getId() : 0)),
555 'varprecision' => array(
'integer', (
int) $variable->getPrecision()),
556 'intprecision' => array(
'integer', (
int) $variable->getIntprecision()),
557 'range_min_txt' => array(
'text', $variable->getRangeMinTxt()),
558 'range_max_txt' => array(
'text', $variable->getRangeMaxTxt())
563 $affectedRows =
$ilDB->manipulateF(
564 "DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s",
566 array($this->
getId())
569 foreach ($this->results as
$result) {
570 $next_id =
$ilDB->nextId(
'il_qpl_qst_fq_res');
571 if (is_object($result->getUnit())) {
572 $tmp_result_unit = $result->getUnit()->getId();
574 $tmp_result_unit = null;
577 $formula = str_replace(
",",
".", $result->getFormula());
579 $ilDB->insert(
"il_qpl_qst_fq_res", array(
580 "result_id" => array(
"integer", $next_id),
581 "question_fi" => array(
"integer", $this->
getId()),
582 "result" => array(
"text", $result->getResult()),
583 "range_min" => array(
"float", ((strlen($result->getRangeMin())) ? $result->getRangeMin() : 0)),
584 "range_max" => array(
"float", ((strlen($result->getRangeMax())) ? $result->getRangeMax() : 0)),
585 "tolerance" => array(
"float", ((strlen($result->getTolerance())) ? $result->getTolerance() : 0)),
586 "unit_fi" => array(
"integer", (
int) $tmp_result_unit),
587 "formula" => array(
"clob", $formula),
588 "resprecision" => array(
"integer", $result->getPrecision()),
589 "rating_simple" => array(
"integer", ($result->getRatingSimple()) ? 1 : 0),
590 "rating_sign" => array(
"float", ($result->getRatingSimple()) ? 0 : $result->getRatingSign()),
591 "rating_value" => array(
"float", ($result->getRatingSimple()) ? 0 : $result->getRatingValue()),
592 "rating_unit" => array(
"float", ($result->getRatingSimple()) ? 0 : $result->getRatingUnit()),
593 "points" => array(
"float", $result->getPoints()),
594 "result_type" => array(
'integer', (
int) $result->getResultType()),
595 "range_min_txt" => array(
"text", $result->getRangeMinTxt()),
596 "range_max_txt" => array(
"text", $result->getRangeMaxTxt())
601 $affectedRows =
$ilDB->manipulateF(
602 "DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
604 array($this->
getId())
606 foreach ($this->results as $result) {
608 $next_id =
$ilDB->nextId(
'il_qpl_qst_fq_res_unit');
609 $affectedRows =
$ilDB->manipulateF(
610 "INSERT INTO il_qpl_qst_fq_res_unit (result_unit_id, question_fi, result, unit_fi) VALUES (%s, %s, %s, %s)",
611 array(
'integer',
'integer',
'text',
'integer'),
615 $result->getResult(),
632 $ilDB = $DIC[
'ilDB'];
635 "SELECT qpl_questions.* FROM qpl_questions WHERE question_id = %s",
641 $this->
setId($question_id);
658 include_once(
"./Services/RTE/classes/class.ilRTE.php");
664 "SELECT * FROM il_qpl_qst_fq_var WHERE question_fi = %s",
671 $varObj->setRangeMinTxt(
$data[
'range_min_txt']);
672 $varObj->setRangeMaxTxt(
$data[
'range_max_txt']);
678 "SELECT * FROM il_qpl_qst_fq_res WHERE question_fi = %s",
684 $resObj =
new assFormulaQuestionResult(
$data[
"result"],
$data[
"range_min"],
$data[
"range_max"],
$data[
"tolerance"], $this->
getUnitrepository()->getUnit(
$data[
"unit_fi"]),
$data[
"formula"],
$data[
"points"],
$data[
"resprecision"],
$data[
"rating_simple"],
$data[
"rating_sign"],
$data[
"rating_value"],
$data[
"rating_unit"]);
685 $resObj->setResultType(
$data[
'result_type']);
686 $resObj->setRangeMinTxt(
$data[
'range_min_txt']);
687 $resObj->setRangeMaxTxt(
$data[
'range_max_txt']);
694 "SELECT * FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
706 parent::loadFromDb($question_id);
715 if ($this->
id <= 0) {
720 $this_id = $this->
getId();
724 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
728 if ((
int) $testObjId > 0) {
729 $clone->setObjId($testObjId);
749 $clone->unitrepository->cloneUnits($this_id, $clone->getId());
752 $clone->copyPageOfQuestion($this_id);
754 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
755 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
766 if ($this->
id <= 0) {
772 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
775 $source_questionpool_id = $this->
getObjId();
776 $clone->setObjId($target_questionpool_id);
782 $clone->unitrepository->cloneUnits(
$original_id, $clone->getId());
789 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
796 if ($this->
id <= 0) {
801 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
804 $sourceParentId = $this->
getObjId();
810 $clone->setObjId($targetParentId);
812 if ($targetQuestionTitle) {
813 $clone->setTitle($targetQuestionTitle);
818 $clone->copyPageOfQuestion($sourceQuestionId);
820 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
822 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
834 foreach ($this->results as
$result) {
835 $points += $result->getPoints();
850 if (is_null(
$pass)) {
854 $user_solution = array();
855 foreach ($solutions as $idx => $solution_value) {
856 if (preg_match(
"/^(\\\$v\\d+)$/", $solution_value[
"value1"], $matches)) {
857 $user_solution[$matches[1]] = $solution_value[
"value2"];
858 $varObj = $this->
getVariable($solution_value[
"value1"]);
859 $varObj->setValue($solution_value[
"value2"]);
860 } elseif (preg_match(
"/^(\\\$r\\d+)$/", $solution_value[
"value1"], $matches)) {
861 if (!array_key_exists($matches[1], $user_solution)) {
862 $user_solution[$matches[1]] = array();
864 $user_solution[$matches[1]][
"value"] = $solution_value[
"value2"];
865 } elseif (preg_match(
"/^(\\\$r\\d+)_unit$/", $solution_value[
"value1"], $matches)) {
866 if (!array_key_exists($matches[1], $user_solution)) {
867 $user_solution[$matches[1]] = array();
869 $user_solution[$matches[1]][
"unit"] = $solution_value[
"value2"];
876 $points += $result->getReachedPoints($this->
getVariables(), $this->
getResults(), $user_solution[$result->getResult()][
"value"], $user_solution[$result->getResult()][
"unit"], $this->unitrepository->getUnits());
888 $v = isset($user_solution[$result->getResult()]) ? $user_solution[$result->getResult()] : null;
889 $u = isset($user_solution[$result->getResult() .
'_unit']) ? $user_solution[$result->getResult() .
'_unit'] : null;
891 $points += $result->getReachedPoints(
896 $this->unitrepository->getUnits()
907 $submittedValue = str_replace(
',',
'.', $submittedValue);
909 if (is_numeric($submittedValue)) {
913 if (preg_match(
'/^[-+]{0,1}\d+\/\d+$/', $submittedValue)) {
930 $ilDB = $DIC[
'ilDB'];
932 if (is_null(
$pass)) {
933 include_once
"./Modules/Test/classes/class.ilObjTest.php";
937 $entered_values =
false;
939 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values,
$ilDB, $active_id,
$pass, $authorized) {
941 foreach ($solutionSubmit as
$key => $value) {
943 if (preg_match(
"/^result_(\\\$r\\d+)$/",
$key, $matches)) {
944 if (strlen($value)) {
945 $entered_values =
true;
948 $queryResult =
"SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND authorized = %s AND " .
$ilDB->like(
'value1',
'clob', $matches[1]);
950 if ($this->
getStep() !== null) {
951 $queryResult .=
" AND step = " .
$ilDB->quote((
int) $this->
getStep(),
'integer') .
" ";
956 array(
'integer',
'integer',
'integer',
'integer'),
957 array($active_id,
$pass, $this->
getId(), (
int) $authorized)
962 "DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
963 array(
'integer',
'integer'),
964 array(
$row[
'solution_id'], (
int) $authorized)
970 } elseif (preg_match(
"/^result_(\\\$r\\d+)_unit$/",
$key, $matches)) {
971 $queryResultUnit =
"SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND authorized = %s AND " .
$ilDB->like(
'value1',
'clob', $matches[1] .
"_unit");
973 if ($this->
getStep() !== null) {
974 $queryResultUnit .=
" AND step = " .
$ilDB->quote((
int) $this->
getStep(),
'integer') .
" ";
979 array(
'integer',
'integer',
'integer',
'integer'),
980 array($active_id,
$pass, $this->
getId(), (
int) $authorized)
985 "DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
986 array(
'integer',
'integer'),
987 array(
$row[
'solution_id'], (
int) $authorized)
997 if ($entered_values) {
998 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1003 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1022 $ilDB = $DIC[
'ilDB'];
1025 'authorized' =>
false,
1026 'intermediate' =>
false 1030 SELECT authorized, COUNT(*) cnt 1032 WHERE active_fi = " .
$ilDB->quote($activeId,
'integer') .
" 1033 AND question_fi = " .
$ilDB->quote($this->
getId(),
'integer') .
" 1034 AND pass = " .
$ilDB->quote(
$pass,
'integer') .
" 1035 AND value1 like '\$r%' 1036 AND value2 is not null 1040 if ($this->
getStep() !== null) {
1051 if (
$row[
'authorized']) {
1052 $return[
'authorized'] =
$row[
'cnt'] > 0;
1054 $return[
'intermediate'] =
$row[
'cnt'] > 0;
1071 $ilDB = $DIC[
'ilDB'];
1074 DELETE FROM tst_solutions 1075 WHERE active_fi = " .
$ilDB->quote($activeId,
'integer') .
" 1076 AND question_fi = " .
$ilDB->quote($this->
getId(),
'integer') .
" 1077 AND pass = " .
$ilDB->quote(
$pass,
'integer') .
" 1078 AND value1 like '\$r%' 1081 if ($this->
getStep() !== null) {
1096 if (preg_match(
"/^result_(\\\$r\\d+)$/",
$key, $matches)) {
1097 $userSolution[$matches[1]] = $val;
1098 } elseif (preg_match(
"/^result_(\\\$r\\d+)_unit$/",
$key, $matches)) {
1099 $userSolution[$matches[1] .
"_unit"] = $val;
1112 return "assFormulaQuestion";
1141 $ilDB = $DIC[
'ilDB'];
1143 $affectedRows =
$ilDB->manipulateF(
1144 "DELETE FROM il_qpl_qst_fq_var WHERE question_fi = %s",
1149 $affectedRows =
$ilDB->manipulateF(
1150 "DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s",
1155 $affectedRows =
$ilDB->manipulateF(
1156 "DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
1161 $affectedRows =
$ilDB->manipulateF(
1162 "DELETE FROM il_qpl_qst_fq_ucat WHERE question_fi = %s",
1167 $affectedRows =
$ilDB->manipulateF(
1168 "DELETE FROM il_qpl_qst_fq_unit WHERE question_fi = %s",
1180 $text = parent::getRTETextWithMediaObjects();
1189 parent::setExportDetailsXLS($worksheet, $startrow, $active_id,
$pass);
1194 foreach ($solution as $solutionvalue) {
1195 $worksheet->setCell($startrow +
$i, 0, $solutionvalue[
"value1"]);
1196 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow +
$i));
1197 if (strpos($solutionvalue[
"value1"],
"_unit")) {
1199 if (is_object($unit)) {
1200 $worksheet->setCell($startrow +
$i, 1, $unit->getUnit());
1203 $worksheet->setCell($startrow +
$i, 1, $solutionvalue[
"value2"]);
1205 if (preg_match(
"/(\\\$v\\d+)/", $solutionvalue[
"value1"], $matches)) {
1206 $var = $this->
getVariable($solutionvalue[
"value1"]);
1207 if (is_object($var) && (is_object($var->getUnit()))) {
1208 $worksheet->setCell($startrow +
$i, 2, $var->getUnit()->getUnit());
1214 return $startrow +
$i + 1;
1224 $user_solution = array();
1226 foreach ($solutions as $idx => $solution_value) {
1227 if (preg_match(
"/^(\\\$v\\d+)$/", $solution_value[
"value1"], $matches)) {
1228 $user_solution[$matches[1]] = $solution_value[
"value2"];
1230 $varObj->setValue($solution_value[
"value2"]);
1231 } elseif (preg_match(
"/^(\\\$r\\d+)$/", $solution_value[
"value1"], $matches)) {
1232 if (!array_key_exists($matches[1], $user_solution)) {
1233 $user_solution[$matches[1]] = array();
1235 $user_solution[$matches[1]][
"value"] = $solution_value[
"value2"];
1236 } elseif (preg_match(
"/^(\\\$r\\d+)_unit$/", $solution_value[
"value1"], $matches)) {
1237 if (!array_key_exists($matches[1], $user_solution)) {
1238 $user_solution[$matches[1]] = array();
1240 $user_solution[$matches[1]][
"unit"] = $solution_value[
"value2"];
1246 if (is_object($result->getUnit())) {
1247 $user_solution[$result->getResult()][
"unit"] = $result->getUnit()->getId();
1248 $user_solution[$result->getResult()][
"value"] = $resVal;
1249 } elseif ($result->getUnit() == null) {
1253 $available_units = $result->getAvailableResultUnits(parent::getId());
1254 $result_name = $result->getResult();
1256 if ($available_units[$result_name] != null) {
1257 $check_unit = in_array($user_solution[$result_name][
'unit'], $available_units[$result_name]);
1260 if ($check_unit ==
true) {
1266 $user_solution[$result->getResult()][
"value"] =
ilMath::_div($resVal, $unit_factor, 55);
1268 $user_solution[$result->getResult()][
"value"] = 0;
1274 if (is_array($value)) {
1275 $user_solution[$result->getResult()][
"value"] = $value[0];
1276 $user_solution[$result->getResult()][
"frac_helper"] = $value[1];
1278 $user_solution[$result->getResult()][
"value"] = $value;
1279 $user_solution[$result->getResult()][
"frac_helper"] = null;
1282 $user_solution[$result->getResult()][
"value"] = round($user_solution[$result->getResult()][
"value"], $result->getPrecision());
1292 return $user_solution;
1298 $this->unitrepository->setConsumerId($this->
getId());
1311 return parent::__get($value);
1337 $solutionSubmit = array();
1338 foreach (
$_POST as $k => $v) {
1339 if (preg_match(
"/^result_(\\\$r\\d+)$/", $k)) {
1340 $solutionSubmit[$k] = $v;
1341 } elseif (preg_match(
"/^result_(\\\$r\\d+)_unit$/", $k)) {
1342 $solutionSubmit[$k] = $v;
1345 return $solutionSubmit;
1351 if (preg_match(
"/^result_(\\\$r\\d+)$/",
$key)) {
1356 } elseif (preg_match(
"/^result_(\\\$r\\d+)_unit$/",
$key)) {
1374 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1403 $ilDB = $DIC[
'ilDB'];
1406 $maxStep = $this->lookupMaxStep($active_id,
$pass);
1408 if ($maxStep !== null) {
1410 "SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
1411 array(
"integer",
"integer",
"integer",
'integer'),
1412 array($active_id,
$pass, $this->
getId(), $maxStep)
1416 "SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
1417 array(
"integer",
"integer",
"integer"),
1423 if (strstr(
$row[
"value1"],
'$r') &&
$row[
"value2"] != null) {
1424 $result->addKeyValue(str_replace(
'$r',
"",
$row[
"value1"]),
$row[
"value2"]);
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getId()
Gets the id of the assQuestion object.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static _getOriginalId($question_id)
Returns the original id of a question.
const PercentageResultExpression
setSuggestedSolution($solution_id="", $subquestion_index=0, $is_import=false)
Sets a suggested solution for the question.
Class iQuestionCondition.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
Abstract basic class which is to be extended by the concrete assessment question type classes...
ensureNonNegativePoints($points)
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
Class ilUnitConfigurationRepository.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
static _div($left_operand, $right_operand, $scale=50)
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second. ...
getParticipantsSolution()
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
getObjId()
Get the object id of the container object.
setParticipantsSolution($participantSolution)
static _getLogLanguage()
retrieve the log language for assessment logging
setAuthor($author="")
Sets the authors name of the assQuestion object.
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
Class ilUserQuestionResult.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
const NumericResultExpression
special template class to simplify handling of ITX/PEAR
getQuestion()
Gets the question string of the question object.
static getOperatorsByExpression($expression)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
setPoints($a_points)
Sets the maximum available points for the question.
saveQuestionDataToDb($original_id="")
setQuestion($question="")
Sets the question string of the question object.
setOriginalId($original_id)
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setComment($comment="")
Sets the comment string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
const EmptyAnswerExpression