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)) {
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()])) {
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;
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()) {
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()) {
518 if (($this->title) and ($this->author) and ($this->question) and ($this->
getMaximumPoints() > 0)) {
535 $affectedRows = $ilDB->manipulateF(
537 DELETE FROM il_qpl_qst_fq_var 538 WHERE question_fi = %s",
543 foreach ($this->variables as $variable) {
544 $next_id = $ilDB->nextId(
'il_qpl_qst_fq_var');
548 'variable_id' =>
array(
'integer', $next_id),
549 'question_fi' =>
array(
'integer', $this->
getId()),
550 'variable' =>
array(
'text', $variable->getVariable()),
551 'range_min' =>
array(
'float', ((strlen($variable->getRangeMin())) ? $variable->getRangeMin() : 0.0)),
552 'range_max' =>
array(
'float', ((strlen($variable->getRangeMax())) ? $variable->getRangeMax() : 0.0)),
553 'unit_fi' =>
array(
'integer', (is_object($variable->getUnit()) ? (
int) $variable->getUnit()->getId() : 0)),
554 'varprecision' =>
array(
'integer', (
int) $variable->getPrecision()),
555 'intprecision' =>
array(
'integer', (
int) $variable->getIntprecision()),
556 'range_min_txt' =>
array(
'text', $variable->getRangeMinTxt()),
557 'range_max_txt' =>
array(
'text', $variable->getRangeMaxTxt())
562 $affectedRows = $ilDB->manipulateF(
563 "DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s",
568 foreach ($this->results as
$result) {
569 $next_id = $ilDB->nextId(
'il_qpl_qst_fq_res');
570 if (is_object($result->getUnit())) {
571 $tmp_result_unit = $result->getUnit()->getId();
573 $tmp_result_unit = null;
576 $formula = str_replace(
",",
".", $result->getFormula());
578 $ilDB->insert(
"il_qpl_qst_fq_res",
array(
579 "result_id" =>
array(
"integer", $next_id),
580 "question_fi" =>
array(
"integer", $this->
getId()),
581 "result" =>
array(
"text", $result->getResult()),
582 "range_min" =>
array(
"float", ((strlen($result->getRangeMin())) ? $result->getRangeMin() : 0)),
583 "range_max" =>
array(
"float", ((strlen($result->getRangeMax())) ? $result->getRangeMax() : 0)),
584 "tolerance" =>
array(
"float", ((strlen($result->getTolerance())) ? $result->getTolerance() : 0)),
585 "unit_fi" =>
array(
"integer", (
int) $tmp_result_unit),
586 "formula" =>
array(
"clob", $formula),
587 "resprecision" =>
array(
"integer", $result->getPrecision()),
588 "rating_simple" =>
array(
"integer", ($result->getRatingSimple()) ? 1 : 0),
589 "rating_sign" =>
array(
"float", ($result->getRatingSimple()) ? 0 : $result->getRatingSign()),
590 "rating_value" =>
array(
"float", ($result->getRatingSimple()) ? 0 : $result->getRatingValue()),
591 "rating_unit" =>
array(
"float", ($result->getRatingSimple()) ? 0 : $result->getRatingUnit()),
592 "points" =>
array(
"float", $result->getPoints()),
593 "result_type" =>
array(
'integer', (
int) $result->getResultType()),
594 "range_min_txt" =>
array(
"text", $result->getRangeMinTxt()),
595 "range_max_txt" =>
array(
"text", $result->getRangeMaxTxt())
600 $affectedRows = $ilDB->manipulateF(
601 "DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
605 foreach ($this->results as $result) {
607 $next_id = $ilDB->nextId(
'il_qpl_qst_fq_res_unit');
608 $affectedRows = $ilDB->manipulateF(
609 "INSERT INTO il_qpl_qst_fq_res_unit (result_unit_id, question_fi, result, unit_fi) VALUES (%s, %s, %s, %s)",
610 array(
'integer',
'integer',
'text',
'integer'),
614 $result->getResult(),
633 "SELECT qpl_questions.* FROM qpl_questions WHERE question_id = %s",
639 $this->
setId($question_id);
656 include_once(
"./Services/RTE/classes/class.ilRTE.php");
662 "SELECT * FROM il_qpl_qst_fq_var WHERE question_fi = %s",
669 $varObj->setRangeMinTxt(
$data[
'range_min_txt']);
670 $varObj->setRangeMaxTxt(
$data[
'range_max_txt']);
676 "SELECT * FROM il_qpl_qst_fq_res WHERE question_fi = %s",
682 $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"]);
683 $resObj->setResultType(
$data[
'result_type']);
684 $resObj->setRangeMinTxt(
$data[
'range_min_txt']);
685 $resObj->setRangeMaxTxt(
$data[
'range_max_txt']);
692 "SELECT * FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
704 parent::loadFromDb($question_id);
713 if ($this->
id <= 0) {
718 $this_id = $this->
getId();
722 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
726 if ((
int) $testObjId > 0) {
727 $clone->setObjId($testObjId);
747 $clone->unitrepository->cloneUnits($this_id, $clone->getId());
750 $clone->copyPageOfQuestion($this_id);
752 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
753 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
764 if ($this->
id <= 0) {
770 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
773 $source_questionpool_id = $this->
getObjId();
774 $clone->setObjId($target_questionpool_id);
780 $clone->unitrepository->cloneUnits(
$original_id, $clone->getId());
787 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
794 if ($this->
id <= 0) {
799 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
802 $sourceParentId = $this->
getObjId();
808 $clone->setObjId($targetParentId);
810 if ($targetQuestionTitle) {
811 $clone->setTitle($targetQuestionTitle);
816 $clone->copyPageOfQuestion($sourceQuestionId);
818 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
820 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
832 foreach ($this->results as
$result) {
833 $points += $result->getPoints();
848 if (is_null(
$pass)) {
852 $user_solution =
array();
853 foreach ($solutions as $idx => $solution_value) {
854 if (preg_match(
"/^(\\\$v\\d+)$/", $solution_value[
"value1"], $matches)) {
855 $user_solution[$matches[1]] = $solution_value[
"value2"];
856 $varObj = $this->
getVariable($solution_value[
"value1"]);
857 $varObj->setValue($solution_value[
"value2"]);
858 } elseif (preg_match(
"/^(\\\$r\\d+)$/", $solution_value[
"value1"], $matches)) {
859 if (!array_key_exists($matches[1], $user_solution)) {
860 $user_solution[$matches[1]] =
array();
862 $user_solution[$matches[1]][
"value"] = $solution_value[
"value2"];
863 } elseif (preg_match(
"/^(\\\$r\\d+)_unit$/", $solution_value[
"value1"], $matches)) {
864 if (!array_key_exists($matches[1], $user_solution)) {
865 $user_solution[$matches[1]] =
array();
867 $user_solution[$matches[1]][
"unit"] = $solution_value[
"value2"];
874 $points += $result->getReachedPoints($this->
getVariables(), $this->
getResults(), $user_solution[$result->getResult()][
"value"], $user_solution[$result->getResult()][
"unit"], $this->unitrepository->getUnits());
886 $v = isset($user_solution[$result->getResult()]) ? $user_solution[$result->getResult()] : null;
887 $u = isset($user_solution[$result->getResult() .
'_unit']) ? $user_solution[$result->getResult() .
'_unit'] : null;
889 $points += $result->getReachedPoints(
894 $this->unitrepository->getUnits()
905 $submittedValue = str_replace(
',',
'.', $submittedValue);
907 if (is_numeric($submittedValue)) {
911 if (preg_match(
'/^[-+]{0,1}\d+\/\d+$/', $submittedValue)) {
929 if (is_null(
$pass)) {
930 include_once
"./Modules/Test/classes/class.ilObjTest.php";
934 $entered_values =
false;
936 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $ilDB, $active_id,
$pass, $authorized) {
938 foreach ($solutionSubmit as
$key => $value) {
940 if (preg_match(
"/^result_(\\\$r\\d+)$/",
$key, $matches)) {
941 if (strlen($value)) {
942 $entered_values =
true;
945 $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]);
947 if ($this->
getStep() !== null) {
948 $queryResult .=
" AND step = " . $ilDB->quote((
int) $this->
getStep(),
'integer') .
" ";
953 array(
'integer',
'integer',
'integer',
'integer'),
959 "DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
960 array(
'integer',
'integer'),
961 array(
$row[
'solution_id'], (
int) $authorized)
967 } elseif (preg_match(
"/^result_(\\\$r\\d+)_unit$/",
$key, $matches)) {
968 $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");
970 if ($this->
getStep() !== null) {
971 $queryResultUnit .=
" AND step = " . $ilDB->quote((
int) $this->
getStep(),
'integer') .
" ";
976 array(
'integer',
'integer',
'integer',
'integer'),
982 "DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
983 array(
'integer',
'integer'),
984 array(
$row[
'solution_id'], (
int) $authorized)
994 if ($entered_values) {
995 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1000 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1021 'authorized' =>
false,
1022 'intermediate' =>
false 1026 SELECT authorized, COUNT(*) cnt 1028 WHERE active_fi = " . $ilDB->quote($activeId,
'integer') .
" 1029 AND question_fi = " . $ilDB->quote($this->
getId(),
'integer') .
" 1030 AND pass = " . $ilDB->quote(
$pass,
'integer') .
" 1031 AND value1 like '\$r%' 1032 AND value2 is not null 1036 if ($this->
getStep() !== null) {
1037 $query .=
" AND step = " . $ilDB->quote((
int) $this->
getStep(),
'integer') .
" ";
1047 if (
$row[
'authorized']) {
1048 $return[
'authorized'] =
$row[
'cnt'] > 0;
1050 $return[
'intermediate'] =
$row[
'cnt'] > 0;
1069 DELETE FROM tst_solutions 1070 WHERE active_fi = " . $ilDB->quote($activeId,
'integer') .
" 1071 AND question_fi = " . $ilDB->quote($this->
getId(),
'integer') .
" 1072 AND pass = " . $ilDB->quote(
$pass,
'integer') .
" 1073 AND value1 like '\$r%' 1076 if ($this->
getStep() !== null) {
1077 $query .=
" AND step = " . $ilDB->quote((
int) $this->
getStep(),
'integer') .
" ";
1080 return $ilDB->manipulate(
$query);
1091 if (preg_match(
"/^result_(\\\$r\\d+)$/",
$key, $matches)) {
1092 $userSolution[$matches[1]] = $val;
1093 } elseif (preg_match(
"/^result_(\\\$r\\d+)_unit$/",
$key, $matches)) {
1094 $userSolution[$matches[1] .
"_unit"] = $val;
1115 return "assFormulaQuestion";
1145 $affectedRows = $ilDB->manipulateF(
1146 "DELETE FROM il_qpl_qst_fq_var WHERE question_fi = %s",
1151 $affectedRows = $ilDB->manipulateF(
1152 "DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s",
1157 $affectedRows = $ilDB->manipulateF(
1158 "DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
1163 $affectedRows = $ilDB->manipulateF(
1164 "DELETE FROM il_qpl_qst_fq_ucat WHERE question_fi = %s",
1169 $affectedRows = $ilDB->manipulateF(
1170 "DELETE FROM il_qpl_qst_fq_unit WHERE question_fi = %s",
1182 $text = parent::getRTETextWithMediaObjects();
1191 parent::setExportDetailsXLS(
$worksheet, $startrow, $active_id,
$pass);
1196 foreach ($solution as $solutionvalue) {
1197 $worksheet->setCell($startrow +
$i, 0, $solutionvalue[
"value1"]);
1199 if (strpos($solutionvalue[
"value1"],
"_unit")) {
1201 if (is_object($unit)) {
1202 $worksheet->setCell($startrow +
$i, 1, $unit->getUnit());
1205 $worksheet->setCell($startrow +
$i, 1, $solutionvalue[
"value2"]);
1207 if (preg_match(
"/(\\\$v\\d+)/", $solutionvalue[
"value1"], $matches)) {
1208 $var = $this->
getVariable($solutionvalue[
"value1"]);
1209 if (is_object($var) && (is_object($var->getUnit()))) {
1210 $worksheet->setCell($startrow +
$i, 2, $var->getUnit()->getUnit());
1216 return $startrow +
$i + 1;
1226 $user_solution =
array();
1228 foreach ($solutions as $idx => $solution_value) {
1229 if (preg_match(
"/^(\\\$v\\d+)$/", $solution_value[
"value1"], $matches)) {
1230 $user_solution[$matches[1]] = $solution_value[
"value2"];
1232 $varObj->setValue($solution_value[
"value2"]);
1233 } elseif (preg_match(
"/^(\\\$r\\d+)$/", $solution_value[
"value1"], $matches)) {
1234 if (!array_key_exists($matches[1], $user_solution)) {
1235 $user_solution[$matches[1]] =
array();
1237 $user_solution[$matches[1]][
"value"] = $solution_value[
"value2"];
1238 } elseif (preg_match(
"/^(\\\$r\\d+)_unit$/", $solution_value[
"value1"], $matches)) {
1239 if (!array_key_exists($matches[1], $user_solution)) {
1240 $user_solution[$matches[1]] =
array();
1242 $user_solution[$matches[1]][
"unit"] = $solution_value[
"value2"];
1248 if (is_object($result->getUnit())) {
1249 $user_solution[$result->getResult()][
"unit"] = $result->getUnit()->getId();
1250 $user_solution[$result->getResult()][
"value"] = $resVal;
1251 } elseif ($result->getUnit() == null) {
1255 $available_units = $result->getAvailableResultUnits(parent::getId());
1256 $result_name = $result->getResult();
1258 if ($available_units[$result_name] != null) {
1259 $check_unit = in_array($user_solution[$result_name][
'unit'], $available_units[$result_name]);
1262 if ($check_unit ==
true) {
1267 $user_solution[$result->getResult()][
"value"] = round(
ilMath::_div($resVal, $unit_factor), 55);
1272 if (is_array($value)) {
1273 $user_solution[$result->getResult()][
"value"] = $value[0];
1274 $user_solution[$result->getResult()][
"frac_helper"] = $value[1];
1276 $user_solution[$result->getResult()][
"value"] = $value;
1277 $user_solution[$result->getResult()][
"frac_helper"] = null;
1279 } elseif ($result->getPrecision() > 0) {
1280 $user_solution[$result->getResult()][
"value"] = round(
1281 $user_solution[$result->getResult()][
"value"],
1282 $result->getPrecision()
1285 $user_solution[$result->getResult()][
"value"] = round(
1286 $user_solution[$result->getResult()][
"value"]
1290 return $user_solution;
1296 $this->unitrepository->setConsumerId($this->
getId());
1309 return parent::__get($value);
1335 $solutionSubmit =
array();
1336 foreach (
$_POST as $k => $v) {
1337 if (preg_match(
"/^result_(\\\$r\\d+)$/", $k)) {
1338 $solutionSubmit[$k] = $v;
1339 } elseif (preg_match(
"/^result_(\\\$r\\d+)_unit$/", $k)) {
1340 $solutionSubmit[$k] = $v;
1343 return $solutionSubmit;
1349 if (preg_match(
"/^result_(\\\$r\\d+)$/",
$key)) {
1354 } elseif (preg_match(
"/^result_(\\\$r\\d+)_unit$/",
$key)) {
1372 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1403 $maxStep = $this->lookupMaxStep($active_id,
$pass);
1405 if ($maxStep !== null) {
1406 $data = $ilDB->queryF(
1407 "SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
1408 array(
"integer",
"integer",
"integer",
'integer'),
1412 $data = $ilDB->queryF(
1413 "SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
1414 array(
"integer",
"integer",
"integer"),
1419 while (
$row = $ilDB->fetchAssoc(
$data)) {
1420 if (strstr(
$row[
"value1"],
'$r') &&
$row[
"value2"] != null) {
1421 $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.
Create styles array
The data for the language used.
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