mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
putting negative data from datasets between () to eliminate maths problem MDL-15358
This commit is contained in:
parent
71e02d31cc
commit
6f4accc6fb
@ -763,10 +763,11 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
|
||||
$delimiter = ': ';
|
||||
$virtualqtype = $this->get_virtual_qtype();
|
||||
foreach ($answers as $answer) {
|
||||
$formula = $answer->answer;
|
||||
foreach ($data as $name => $value) {
|
||||
// $formula = $answer->answer;
|
||||
$formula = parent::substitute_variables($answer->answer,$data);
|
||||
/* foreach ($data as $name => $value) {
|
||||
$formula = str_replace('{'.$name.'}', $value, $formula);
|
||||
}
|
||||
}*/
|
||||
$formattedanswer = qtype_calculated_calculate_answer(
|
||||
$answer->answer, $data, $answer->tolerance,
|
||||
$answer->tolerancetype, $answer->correctanswerlength,
|
||||
|
@ -82,7 +82,11 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||
|
||||
function substitute_variables($str, $dataset) {
|
||||
foreach ($dataset as $name => $value) {
|
||||
$str = str_replace('{'.$name.'}', $value, $str);
|
||||
if($value < 0 ){
|
||||
$str = str_replace('{'.$name.'}', '('.$value.')', $str);
|
||||
} else {
|
||||
$str = str_replace('{'.$name.'}', $value, $str);
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user