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';
50 $this->variables =
array();
51 $this->results =
array();
52 $this->resultunits =
array();
59 $this->variables =
array();
69 if(array_key_exists($variable, $this->variables))
71 return $this->variables[$variable];
78 $this->variables[$variable->getVariable()] = $variable;
83 $this->results =
array();
93 if(array_key_exists(
$result, $this->results))
108 if((!is_object(
$result)) || (!is_array($unit_ids)))
return;
109 foreach($unit_ids as
$id)
117 if(is_object(
$result) && is_object($unit))
119 if(!is_array($this->resultunits[
$result->getResult()]))
123 $this->resultunits[
$result->getResult()][$unit->getId()] = $unit;
132 return $this->resultunits[
$result->getResult()];
144 if(array_key_exists($unit_id, $this->resultunits[
$result->getResult()]))
157 if(preg_match_all(
"/(\\\$v\\d+)/ims", $this->
getQuestion(), $matches))
159 foreach($matches[1] as $variable)
166 if(preg_match_all(
"/(\\\$r\\d+)/ims", $this->
getQuestion(), $rmatches))
168 foreach($rmatches[1] as
$result)
178 if(preg_match_all(
"/(\\\$v\\d+)/ims", $this->
getQuestion(), $matches))
180 if((count(array_unique($matches[1]))) != count($matches[1]))
return false;
187 if(preg_match_all(
"/(\\\$r\\d+)/ims", $this->
getQuestion(), $rmatches))
189 if((count(array_unique($rmatches[1]))) != count($rmatches[1]))
return false;
200 $resObjects =
array();
203 if(preg_match_all(
"/(\\\$r\\d+)/ims", $questionText, $matches))
205 foreach($matches[1] as $resultKey)
207 $resObjects[] = $this->
getResult($resultKey);
220 $varObjects =
array();
223 if(preg_match_all(
"/(\\\$v\\d+)/ims", $questionText, $matches))
225 foreach($matches[1] as $variableKey)
242 if( !isset($userSolution[$varObj->getVariable()]) )
247 if( !strlen($userSolution[$varObj->getVariable()]) )
266 $variableSolutionValues =
array();
270 $variableSolutionValues[$varObj->getVariable()] = $varObj->getValue();
273 return $variableSolutionValues;
286 if((count($this->results) == 0) && (count($this->variables) == 0))
293 if( isset($userdata[$varObj->getVariable()]) && strlen($userdata[$varObj->getVariable()]) )
295 $varObj->setValue( $userdata[$varObj->getVariable()] );
298 $unit = (is_object($varObj->getUnit())) ? $varObj->getUnit()->getUnit() :
"";
299 $val = (strlen($varObj->getValue()) > 8) ? strtoupper(sprintf(
"%e", $varObj->getValue())) : $varObj->getValue();
301 $text = preg_replace(
"/\\$" . substr($varObj->getVariable(), 1) .
"(?![0-9]+)/", $val .
" " . $unit .
"\\1",
$text);
304 if(preg_match_all(
"/(\\\$r\\d+)/ims", $this->
getQuestion(), $rmatches))
306 foreach($rmatches[1] as
$result)
311 $user_data[
$result][
'result_type'] = $resObj->getResultType();
320 if(is_array($userdata))
322 if(is_array($userdata[$result]))
324 if($forsolution && $result_output)
327 $value = sprintf(
"%." . $resObj->getPrecision() .
"f", $value_org);
333 $frac_helper = $value[1];
342 $value = $userdata[
$result][
"value"];
346 $value =
' value="' . $userdata[
$result][
"value"] .
'"';
356 $value = sprintf(
"%." . $resObj->getPrecision() .
"f", $value);
363 $frac_helper = $value[1];
366 $value =
' value="' . $value .
'"';
373 $use_precision = !($userdata == null && $graphicalOutput == FALSE && $forsolution == FALSE && $result_output == FALSE);
375 $val = $resObj->calculateFormula($this->
getVariables(), $this->
getResults(), parent::getId(), $use_precision);
380 $val = $resObj->convertDecimalToCoprimeFraction($val);
383 $frac_helper = $val[1];
389 $val = sprintf(
"%." . $resObj->getPrecision() .
"f", $val);
390 $val = (strlen($val) > 8) ? strtoupper(sprintf(
"%e", $val)) : $val;
392 $value =
' value="' . $val .
'"';
402 $input =
'<input class="ilc_qinput_TextInput" type="text" spellcheck="false" autocomplete="off" autocorrect="off" autocapitalize="off" name="result_' . $result .
'"' . $value .
' />';
410 if(is_array($userdata))
414 if($userdata[$result][
"unit"] == $unit->getId())
416 $units = $unit->getUnit();
422 if($resObj->getUnit())
424 $units = $resObj->getUnit()->getUnit();
430 $units =
'<select name="result_' . $result .
'_unit">';
431 $units .=
'<option value="-1">' . $this->lng->txt(
"select_unit") .
'</option>';
434 $units .=
'<option value="' . $unit->getId() .
'"';
435 if((is_array($userdata[$result])) && (strlen($userdata[$result][
"unit"])))
437 if($userdata[$result][
"unit"] == $unit->getId())
439 $units .=
' selected="selected"';
442 $units .=
'>' . $unit->getUnit() .
'</option>';
444 $units .=
'</select>';
451 switch($resObj->getResultType())
454 $units .=
' ' . $this->lng->txt(
'expected_result_type') .
': ' . $this->lng->txt(
'result_dec');
457 if(strlen($frac_helper))
459 $units .=
' ≈ ' . $frac_helper .
', ';
461 elseif (is_array($userdata) && isset($userdata[$result]) && strlen($userdata[$result][
"frac_helper"]))
463 if(!preg_match(
'-/-', $value))
465 $units .=
' ≈ ' . $userdata[
$result][
"frac_helper"] .
', ';
468 $units .=
' ' . $this->lng->txt(
'expected_result_type') .
': ' . $this->lng->txt(
'result_frac');
471 if(strlen($frac_helper))
473 $units .=
' ≈ ' . $frac_helper .
', ';
475 elseif (is_array($userdata) && isset($userdata[$result]) && strlen($userdata[$result][
"frac_helper"]))
477 if(!preg_match(
'-/-', $value))
479 $units .=
' ≈ ' . $userdata[
$result][
"frac_helper"] .
', ';
482 $units .=
' ' . $this->lng->txt(
'expected_result_type') .
': ' . $this->lng->txt(
'result_co_frac');
492 if(is_array($userdata) && is_array($userdata[$result]))
494 if($userdata[$result][
"unit"] > 0)
499 if(isset($userdata[$result][
"value"]))
501 $user_value = $userdata[
$result][
"value"];
505 $template =
new ilTemplate(
"tpl.il_as_qpl_formulaquestion_output_solution_image.html",
true,
true,
'Modules/TestQuestionPool');
507 if($resObj->isCorrect($this->getVariables(), $this->
getResults(), $user_value, $resunit))
509 $template->setCurrentBlock(
"icon_ok");
511 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
512 $template->parseCurrentBlock();
516 $template->setCurrentBlock(
"icon_not_ok");
518 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
519 $template->parseCurrentBlock();
521 $checkSign = $template->get();
526 $template =
new ilTemplate(
"tpl.il_as_qpl_formulaquestion_output_solution_result.html",
true,
true,
'Modules/TestQuestionPool');
528 if(is_array($userdata))
530 $found = $resObj->getResultInfo($this->
getVariables(), $this->
getResults(), $userdata[$resObj->getResult()][
"value"], $userdata[$resObj->getResult()][
"unit"], $this->
getUnitrepository()->getUnits());
534 $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());
537 if($resObj->getRatingSimple())
545 $resulttext .= $found[
'points'] .
" " . (($found[
'points'] == 1) ? $this->lng->txt(
'point') : $this->lng->txt(
'points'));
550 $resulttext .= $this->lng->txt(
"rated_sign") .
" " . (($found[
'sign']) ? $found[
'sign'] : 0) .
" " . (($found[
'sign'] == 1) ? $this->lng->txt(
'point') : $this->lng->txt(
'points')) .
", ";
551 $resulttext .= $this->lng->txt(
"rated_value") .
" " . (($found[
'value']) ? $found[
'value'] : 0) .
" " . (($found[
'value'] == 1) ? $this->lng->txt(
'point') : $this->lng->txt(
'points')) .
", ";
552 $resulttext .= $this->lng->txt(
"rated_unit") .
" " . (($found[
'unit']) ? $found[
'unit'] : 0) .
" " . (($found[
'unit'] == 1) ? $this->lng->txt(
'point') : $this->lng->txt(
'points'));
556 $template->setVariable(
"RESULT_OUTPUT", $resulttext);
558 $resultOutput = $template->get();
560 $text = preg_replace(
"/\\\$" . substr($result, 1) .
"(?![0-9]+)/", $input .
" " . $units .
" " . $checkSign .
" " . $resultOutput .
" " .
"\\1",
$text);
575 $resultunit =
$result->getUnit();
577 foreach($result_units as $unit)
579 if(is_object($resultunit))
581 if($resultunit->getId() != $unit->getId())
583 if($resultunit->getBaseUnit() && $unit->getBaseUnit())
585 if($resultunit->getBaseUnit() == $unit->getBaseUnit())
return false;
587 if($resultunit->getBaseUnit())
589 if($resultunit->getBaseUnit() == $unit->getId())
return false;
591 if($unit->getBaseUnit())
593 if($unit->getBaseUnit() == $resultunit->getId())
return false;
627 $affectedRows = $ilDB->manipulateF(
" 628 DELETE FROM il_qpl_qst_fq_var 629 WHERE question_fi = %s",
634 foreach($this->variables as $variable)
636 $next_id = $ilDB->nextId(
'il_qpl_qst_fq_var');
637 $ilDB->insert(
'il_qpl_qst_fq_var',
639 'variable_id' =>
array(
'integer', $next_id),
640 'question_fi' =>
array(
'integer', $this->
getId()),
641 'variable' =>
array(
'text', $variable->getVariable()),
642 'range_min' =>
array(
'float', ((strlen($variable->getRangeMin())) ? $variable->getRangeMin() : 0.0)),
643 'range_max' =>
array(
'float', ((strlen($variable->getRangeMax())) ? $variable->getRangeMax() : 0.0)),
644 'unit_fi' =>
array(
'integer', (is_object($variable->getUnit()) ? (
int)$variable->getUnit()->getId() : 0)),
645 'varprecision' =>
array(
'integer', (
int)$variable->getPrecision()),
646 'intprecision' =>
array(
'integer', (
int)$variable->getIntprecision()),
647 'range_min_txt' =>
array(
'text', $variable->getRangeMinTxt()),
648 'range_max_txt' =>
array(
'text', $variable->getRangeMaxTxt())
653 $affectedRows = $ilDB->manipulateF(
"DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s",
658 foreach($this->results as
$result)
660 $next_id = $ilDB->nextId(
'il_qpl_qst_fq_res');
661 if( is_object($result->getUnit()))
663 $tmp_result_unit = $result->getUnit()->getId();
667 $tmp_result_unit = NULL;
670 $formula = str_replace(
",",
".", $result->getFormula());
672 $ilDB->insert(
"il_qpl_qst_fq_res",
array(
673 "result_id" =>
array(
"integer", $next_id),
674 "question_fi" =>
array(
"integer", $this->
getId()),
675 "result" =>
array(
"text", $result->getResult()),
676 "range_min" =>
array(
"float", ((strlen($result->getRangeMin())) ? $result->getRangeMin() : 0)),
677 "range_max" =>
array(
"float", ((strlen($result->getRangeMax())) ? $result->getRangeMax() : 0)),
678 "tolerance" =>
array(
"float", ((strlen($result->getTolerance())) ? $result->getTolerance() : 0)),
679 "unit_fi" =>
array(
"integer", (
int)$tmp_result_unit),
680 "formula" =>
array(
"clob", $formula),
681 "resprecision" =>
array(
"integer", $result->getPrecision()),
682 "rating_simple" =>
array(
"integer", ($result->getRatingSimple()) ? 1 : 0),
683 "rating_sign" =>
array(
"float", ($result->getRatingSimple()) ? 0 : $result->getRatingSign()),
684 "rating_value" =>
array(
"float", ($result->getRatingSimple()) ? 0 : $result->getRatingValue()),
685 "rating_unit" =>
array(
"float", ($result->getRatingSimple()) ? 0 : $result->getRatingUnit()),
686 "points" =>
array(
"float", $result->getPoints()),
687 "result_type" =>
array(
'integer', (
int)$result->getResultType()),
688 "range_min_txt" =>
array(
"text", $result->getRangeMinTxt()),
689 "range_max_txt" =>
array(
"text", $result->getRangeMaxTxt())
694 $affectedRows = $ilDB->manipulateF(
"DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
698 foreach($this->results as $result)
702 $next_id = $ilDB->nextId(
'il_qpl_qst_fq_res_unit');
703 $affectedRows = $ilDB->manipulateF(
"INSERT INTO il_qpl_qst_fq_res_unit (result_unit_id, question_fi, result, unit_fi) VALUES (%s, %s, %s, %s)",
704 array(
'integer',
'integer',
'text',
'integer'),
708 $result->getResult(),
726 $result = $ilDB->queryF(
"SELECT qpl_questions.* FROM qpl_questions WHERE question_id = %s",
733 $this->
setId($question_id);
753 include_once(
"./Services/RTE/classes/class.ilRTE.php");
758 $result = $ilDB->queryF(
"SELECT * FROM il_qpl_qst_fq_var WHERE question_fi = %s",
767 $varObj->setRangeMinTxt(
$data[
'range_min_txt']);
768 $varObj->setRangeMaxTxt(
$data[
'range_max_txt']);
773 $result = $ilDB->queryF(
"SELECT * FROM il_qpl_qst_fq_res WHERE question_fi = %s",
781 $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"]);
782 $resObj->setResultType(
$data[
'result_type']);
783 $resObj->setRangeMinTxt(
$data[
'range_min_txt']);
784 $resObj->setRangeMaxTxt(
$data[
'range_max_txt']);
790 $result = $ilDB->queryF(
"SELECT * FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
804 parent::loadFromDb($question_id);
819 $this_id = $this->
getId();
823 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
827 if( (
int)$testObjId > 0 )
829 $clone->setObjId($testObjId);
855 $clone->unitrepository->cloneUnits($this_id, $clone->getId());
858 $clone->copyPageOfQuestion($this_id);
860 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
861 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
879 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
882 $source_questionpool_id = $this->
getObjId();
883 $clone->setObjId($target_questionpool_id);
890 $clone->unitrepository->cloneUnits(
$original_id, $clone->getId());
897 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
910 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
913 $sourceParentId = $this->
getObjId();
919 $clone->setObjId($targetParentId);
921 if ($targetQuestionTitle)
923 $clone->setTitle($targetQuestionTitle);
928 $clone->copyPageOfQuestion($sourceQuestionId);
930 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
932 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
944 foreach($this->results as
$result)
946 $points += $result->getPoints();
966 $user_solution =
array();
967 foreach($solutions as $idx => $solution_value)
969 if(preg_match(
"/^(\\\$v\\d+)$/", $solution_value[
"value1"], $matches))
971 $user_solution[$matches[1]] = $solution_value[
"value2"];
972 $varObj = $this->
getVariable($solution_value[
"value1"]);
973 $varObj->setValue($solution_value[
"value2"]);
975 else if(preg_match(
"/^(\\\$r\\d+)$/", $solution_value[
"value1"], $matches))
977 if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] =
array();
978 $user_solution[$matches[1]][
"value"] = $solution_value[
"value2"];
980 else if(preg_match(
"/^(\\\$r\\d+)_unit$/", $solution_value[
"value1"], $matches))
982 if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] =
array();
983 $user_solution[$matches[1]][
"unit"] = $solution_value[
"value2"];
991 $points += $result->getReachedPoints($this->
getVariables(), $this->
getResults(), $user_solution[$result->getResult()][
"value"], $user_solution[$result->getResult()][
"unit"], $this->unitrepository->getUnits());
1004 $v = isset($user_solution[$result->getResult()]) ? $user_solution[$result->getResult()] : null;
1005 $u = isset($user_solution[$result->getResult().
'_unit']) ? $user_solution[$result->getResult().
'_unit'] : null;
1007 $points += $result->getReachedPoints(
1012 $this->unitrepository->getUnits());
1022 $submittedValue = str_replace(
',',
'.', $submittedValue);
1024 if( is_numeric($submittedValue) )
1029 if( preg_match(
'/^[-+]{0,1}\d+\/\d+$/', $submittedValue) )
1050 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1054 $entered_values =
false;
1056 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function() use (&$entered_values, $ilDB, $active_id,
$pass, $authorized) {
1059 foreach($solutionSubmit as $key => $value)
1062 if(preg_match(
"/^result_(\\\$r\\d+)$/", $key, $matches))
1066 $entered_values = TRUE;
1069 $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]);
1071 if( $this->
getStep() !== NULL )
1073 $queryResult .=
" AND step = " . $ilDB->quote((
int)$this->
getStep(),
'integer') .
" ";
1078 array(
'integer',
'integer',
'integer',
'integer'),
1085 $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
1086 array(
'integer',
'integer'),
1087 array(
$row[
'solution_id'], (
int)$authorized)
1094 else if(preg_match(
"/^result_(\\\$r\\d+)_unit$/", $key, $matches))
1096 $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");
1098 if( $this->
getStep() !== NULL )
1100 $queryResultUnit .=
" AND step = " . $ilDB->quote((
int)$this->
getStep(),
'integer') .
" ";
1105 array(
'integer',
'integer',
'integer',
'integer'),
1112 $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
1113 array(
'integer',
'integer'),
1114 array(
$row[
'solution_id'], (
int)$authorized)
1127 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1135 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1157 'authorized' =>
false,
1158 'intermediate' =>
false 1162 SELECT authorized, COUNT(*) cnt 1164 WHERE active_fi = " . $ilDB->quote($activeId,
'integer') .
" 1165 AND question_fi = ". $ilDB->quote($this->
getId(),
'integer') .
" 1166 AND pass = " .$ilDB->quote(
$pass,
'integer') .
" 1167 AND value1 like '\$r%' 1168 AND value2 is not null 1172 if( $this->
getStep() !== NULL )
1174 $query .=
" AND step = " . $ilDB->quote((
int)$this->
getStep(),
'integer') .
" ";
1185 if (
$row[
'authorized']) {
1186 $return[
'authorized'] =
$row[
'cnt'] > 0;
1190 $return[
'intermediate'] =
$row[
'cnt'] > 0;
1209 DELETE FROM tst_solutions 1210 WHERE active_fi = " . $ilDB->quote($activeId,
'integer') .
" 1211 AND question_fi = ". $ilDB->quote($this->
getId(),
'integer') .
" 1212 AND pass = " .$ilDB->quote(
$pass,
'integer') .
" 1213 AND value1 like '\$r%' 1216 if( $this->
getStep() !== NULL )
1218 $query .=
" AND step = " . $ilDB->quote((
int)$this->
getStep(),
'integer') .
" ";
1221 return $ilDB->manipulate(
$query);
1233 if(preg_match(
"/^result_(\\\$r\\d+)$/", $key, $matches))
1235 $userSolution[$matches[1]] = $val;
1237 else if(preg_match(
"/^result_(\\\$r\\d+)_unit$/", $key, $matches))
1239 $userSolution[$matches[1] .
"_unit"] = $val;
1260 return "assFormulaQuestion";
1290 $affectedRows = $ilDB->manipulateF(
"DELETE FROM il_qpl_qst_fq_var WHERE question_fi = %s",
1295 $affectedRows = $ilDB->manipulateF(
"DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s",
1300 $affectedRows = $ilDB->manipulateF(
"DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
1305 $affectedRows = $ilDB->manipulateF(
"DELETE FROM il_qpl_qst_fq_ucat WHERE question_fi = %s",
1310 $affectedRows = $ilDB->manipulateF(
"DELETE FROM il_qpl_qst_fq_unit WHERE question_fi = %s",
1322 $text = parent::getRTETextWithMediaObjects();
1331 parent::setExportDetailsXLS(
$worksheet, $startrow, $active_id,
$pass);
1336 foreach($solution as $solutionvalue)
1338 $worksheet->setCell($startrow + $i, 0,$solutionvalue[
"value1"]);
1340 if(strpos($solutionvalue[
"value1"],
"_unit"))
1343 if(is_object($unit))
1345 $worksheet->setCell($startrow + $i, 1, $unit->getUnit());
1350 $worksheet->setCell($startrow + $i, 1, $solutionvalue[
"value2"]);
1352 if(preg_match(
"/(\\\$v\\d+)/", $solutionvalue[
"value1"], $matches))
1354 $var = $this->
getVariable($solutionvalue[
"value1"]);
1355 if(is_object($var) && (is_object($var->getUnit())))
1357 $worksheet->setCell($startrow + $i, 2, $var->getUnit()->getUnit());
1363 return $startrow + $i + 1;
1373 $user_solution =
array();
1375 foreach($solutions as $idx => $solution_value)
1377 if(preg_match(
"/^(\\\$v\\d+)$/", $solution_value[
"value1"], $matches))
1379 $user_solution[$matches[1]] = $solution_value[
"value2"];
1381 $varObj->setValue($solution_value[
"value2"]);
1383 else if(preg_match(
"/^(\\\$r\\d+)$/", $solution_value[
"value1"], $matches))
1385 if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] =
array();
1386 $user_solution[$matches[1]][
"value"] = $solution_value[
"value2"];
1388 else if(preg_match(
"/^(\\\$r\\d+)_unit$/", $solution_value[
"value1"], $matches))
1390 if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] =
array();
1391 $user_solution[$matches[1]][
"unit"] = $solution_value[
"value2"];
1398 if(is_object($result->getUnit()))
1400 $user_solution[$result->getResult()][
"unit"] = $result->getUnit()->getId();
1401 $user_solution[$result->getResult()][
"value"] = $resVal;
1403 else if($result->getUnit() == NULL)
1408 $available_units = $result->getAvailableResultUnits(parent::getId());
1409 $result_name = $result->getResult();
1411 if($available_units[$result_name] != NULL)
1413 $check_unit = in_array($user_solution[$result_name][
'unit'], $available_units[$result_name]);
1416 if($check_unit ==
true)
1422 $user_solution[$result->getResult()][
"value"] = round(
ilMath::_div($resVal, $unit_factor), 55);
1428 if(is_array($value))
1430 $user_solution[$result->getResult()][
"value"] = $value[0];
1431 $user_solution[$result->getResult()][
"frac_helper"] = $value[1];
1435 $user_solution[$result->getResult()][
"value"] = $value;
1436 $user_solution[$result->getResult()][
"frac_helper"] = null;
1439 elseif($result->getPrecision() > 0)
1441 $user_solution[$result->getResult()][
"value"] = round(
1442 $user_solution[$result->getResult()][
"value"], $result->getPrecision()
1447 $user_solution[$result->getResult()][
"value"] = round(
1448 $user_solution[$result->getResult()][
"value"]
1452 return $user_solution;
1458 $this->unitrepository->setConsumerId($this->
getId());
1472 return parent::__get($value);
1498 $solutionSubmit =
array();
1499 foreach(
$_POST as $k => $v)
1501 if(preg_match(
"/^result_(\\\$r\\d+)$/", $k))
1503 $solutionSubmit[$k] = $v;
1505 elseif(preg_match(
"/^result_(\\\$r\\d+)_unit$/", $k))
1507 $solutionSubmit[$k] = $v;
1510 return $solutionSubmit;
1517 if(preg_match(
"/^result_(\\\$r\\d+)$/", $key))
1525 elseif(preg_match(
"/^result_(\\\$r\\d+)_unit$/", $key))
1544 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1575 $maxStep = $this->lookupMaxStep($active_id,
$pass);
1577 if( $maxStep !== null )
1579 $data = $ilDB->queryF(
1580 "SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
1581 array(
"integer",
"integer",
"integer",
'integer'),
1587 $data = $ilDB->queryF(
1588 "SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
1589 array(
"integer",
"integer",
"integer"),
1596 if(strstr(
$row[
"value1"],
'$r') &&
$row[
"value2"] != null)
1598 $result->addKeyValue(str_replace(
'$r',
"",
$row[
"value1"]),
$row[
"value2"]);
1622 return $this->
getResult(
'$r'.($index+1));
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)
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)
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
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