Merge branch 'MDL-70966-master' of git://github.com/marinaglancy/moodle
authorSara Arjona <sara@moodle.com>
Wed, 3 Mar 2021 08:30:41 +0000 (09:30 +0100)
committerSara Arjona <sara@moodle.com>
Wed, 3 Mar 2021 08:30:41 +0000 (09:30 +0100)
lib/form/datetimeselector.php
mod/quiz/classes/structure.php
question/format/gift/tests/giftformat_test.php
question/format/xml/tests/xmlformat_test.php
question/type/numerical/question.php

index 084768d..a39b081 100644 (file)
@@ -193,7 +193,7 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group {
                     }
                 }
                 $requestvalue=$value;
-                if ($value == 0) {
+                if ($value == 0 || $value === '') {
                     $value = $this->_options['defaulttime'];
                     if (!$value) {
                         $value = time();
index 1c93753..95b0fa2 100644 (file)
@@ -745,7 +745,7 @@ class structure {
         }
 
         // Check the target page number is OK.
-        if ($page == 0) {
+        if ($page == 0 || $page === '') {
             $page = 1;
         }
         if (($moveafterslotnumber > 0 && $page < $this->get_page_number_for_slot($moveafterslotnumber)) ||
index 92251cc..9af5a05 100644 (file)
@@ -729,7 +729,7 @@ class qformat_gift_test extends question_testcase {
                     'files' => array(),
                 ),
             ),
-            'tolerance' => array(2, 0),
+            'tolerance' => array(2, ''),
         );
 
         // Repeated test for better failure messages.
index 3de9b31..7c1a0b1 100644 (file)
@@ -1132,7 +1132,7 @@ END;
                     'format' => FORMAT_HTML),
             array('text' => 'Completely wrong.',
                     'format' => FORMAT_HTML));
-        $expectedq->tolerance = array(0.001, 1, 0);
+        $expectedq->tolerance = array(0.001, 1, '');
 
         $this->assert(new question_check_specified_fields_expectation($expectedq), $q);
     }
index 7137ed8..db69bdf 100644 (file)
@@ -357,7 +357,7 @@ class qtype_numerical_answer extends question_answer {
 
     public function __construct($id, $answer, $fraction, $feedback, $feedbackformat, $tolerance) {
         parent::__construct($id, $answer, $fraction, $feedback, $feedbackformat);
-        $this->tolerance = abs($tolerance);
+        $this->tolerance = abs((float)$tolerance);
     }
 
     public function get_tolerance_interval() {