MDL-53140 question: Support localised floats when previewing a question
authorShamim Rezaie <shamim@moodle.com>
Mon, 4 Feb 2019 16:39:37 +0000 (03:39 +1100)
committerShamim Rezaie <shamim@moodle.com>
Wed, 1 May 2019 02:10:32 +0000 (12:10 +1000)
lib/questionlib.php
question/previewlib.php

index a465c7d..e0b3014 100644 (file)
@@ -796,7 +796,7 @@ function question_preview_url($questionid, $preferredbehaviour = null,
     }
 
     if (!is_null($maxmark)) {
-        $params['maxmark'] = $maxmark;
+        $params['maxmark'] = format_float($maxmark, strlen($maxmark), true, true);
     }
 
     if (!is_null($displayoptions)) {
index 588e435..6c11625 100644 (file)
@@ -52,9 +52,8 @@ class preview_options_form extends moodleform {
                 get_string('howquestionsbehave', 'question'), $behaviours);
         $mform->addHelpButton('behaviour', 'howquestionsbehave', 'question');
 
-        $mform->addElement('text', 'maxmark', get_string('markedoutof', 'question'),
+        $mform->addElement('float', 'maxmark', get_string('markedoutof', 'question'),
                 array('size' => '5'));
-        $mform->setType('maxmark', PARAM_FLOAT);
 
         if ($this->_customdata['maxvariant'] > 1) {
             $variants = range(1, $this->_customdata['maxvariant']);
@@ -152,7 +151,7 @@ class question_preview_options extends question_display_options {
     protected function get_field_types() {
         return array(
             'behaviour' => PARAM_ALPHA,
-            'maxmark' => PARAM_FLOAT,
+            'maxmark' => PARAM_LOCALISEDFLOAT,
             'variant' => PARAM_INT,
             'correctness' => PARAM_BOOL,
             'marks' => PARAM_INT,