From: pichetp Date: Tue, 11 Dec 2007 09:13:17 +0000 (+0000) Subject: MDL-12421 rounding X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4efa376ffb56c43b1bd59691a00af4a82ccc683f;p=moodle.git MDL-12421 rounding --- diff --git a/question/type/datasetdependent/abstractqtype.php b/question/type/datasetdependent/abstractqtype.php index 54edd15fc0..c20daf72ac 100644 --- a/question/type/datasetdependent/abstractqtype.php +++ b/question/type/datasetdependent/abstractqtype.php @@ -623,9 +623,10 @@ class question_dataset_dependent_questiontype extends default_questiontype { // Select a dataset in the following format: // An array indexed by the variable names (d.name) pointing to the value // to be substituted + //the value is rounded following the decimals setting global $CFG; if (!$dataset = get_records_sql( - "SELECT d.name, i.value + "SELECT d.name, i.value, d.options FROM {$CFG->prefix}question_dataset_definitions d, {$CFG->prefix}question_dataset_items i, {$CFG->prefix}question_datasets q @@ -637,6 +638,14 @@ class question_dataset_dependent_questiontype extends default_questiontype { "question! (question: {$question->id}, " . "datasetitem: {$datasetitem})"); } + foreach($dataset as $dset ){ + list($distribution, $min, $max,$dec) = explode(':', $dset->options, 4); + if ($dec == "") { + $dec = 0 ; + } + unset($dset->options); + } + $dset->value = sprintf("%.".$dec."f",$dset->value); array_walk($dataset, create_function('&$val', '$val = $val->value;')); return $dataset; }