From: tjhunt Date: Tue, 20 Nov 2007 16:57:22 +0000 (+0000) Subject: MDL-12282 - Numerical question type - the units are displayed on the editing form... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b4d7d27cea95bea0b90fbd6f899002862c496f5f;p=moodle.git MDL-12282 - Numerical question type - the units are displayed on the editing form with a stupidly large number of decimal places. Merged from MOODLE_18_STABLE. --- diff --git a/question/type/numerical/edit_numerical_form.php b/question/type/numerical/edit_numerical_form.php index 9c73168544..e47433c5a9 100644 --- a/question/type/numerical/edit_numerical_form.php +++ b/question/type/numerical/edit_numerical_form.php @@ -62,7 +62,7 @@ class question_edit_numerical_form extends question_edit_form { $mform->setType('unit', PARAM_NOTAGS); $repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz')); - $mform->setType('multiplier', PARAM_NOTAGS); + $mform->setType('multiplier', PARAM_NUMBER); if (isset($this->question->options)){ $countunits = count($this->question->options->units); diff --git a/question/type/numerical/questiontype.php b/question/type/numerical/questiontype.php index 63052f2dea..2a3564a178 100644 --- a/question/type/numerical/questiontype.php +++ b/question/type/numerical/questiontype.php @@ -60,12 +60,16 @@ class question_numerical_qtype extends question_shortanswer_qtype { } function get_numerical_units(&$question) { - if ($question->options->units = get_records('question_numerical_units', + if ($units = get_records('question_numerical_units', 'question', $question->id, 'id ASC')) { - $question->options->units = array_values($question->options->units); + $units = array_values($question->options->units); } else { - $question->options->units = array(); + $units = array(); } + foreach ($units as $key => $unit) { + $units[$key]->multiplier = clean_param($unit->multiplier, PARAM_NUMBER); + } + $question->options->units = $units; return true; }