-
Bug
-
Resolution: Fixed
-
Major
-
2.2, 3.4
-
MOODLE_22_STABLE, MOODLE_34_STABLE
-
MOODLE_35_STABLE
-
MDL-32113-master-xmldbnumeric -
<TABLE NAME="question_numerical_units" COMMENT="Optional unit options for numerical questions. This table is also used by the calculated question type." PREVIOUS="question_numerical_options">
|
<FIELDS>
|
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="question"/>
|
<FIELD NAME="question" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Foreign key references question.id" PREVIOUS="id" NEXT="multiplier"/>
|
<FIELD NAME="multiplier" TYPE="number" LENGTH="40" NOTNULL="true" DEFAULT="1.00000000000000000000" SEQUENCE="false" DECIMALS="20" COMMENT="The multiplier for this unit. For example, if the first unit is (1.0, 'cm'), another unit might be (0.1, 'mm') or (100.0, 'm')." PREVIOUS="question" NEXT="unit"/>
|
<FIELD NAME="unit" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="The unit. For example 'm' or 'kg'." PREVIOUS="multiplier"/>
|
</FIELDS>
|
is against the XMLDB docs and XMLDB editor validation. This was discovered in MDL-32112, I have added an ugly workaround there.
Looking at the code it seems that we could use VARCHAR(50) there without any problems because the column is not used in any SQL condition. Please note that all these high precision numbers must be passed to database as strings and they are also fetched from db as strings (PHP float limitation), so if you do not do any arithmetic operation on it directly in database the db field type should not matter.
In any case number with 40 digit is NOT going to fit the float PHP type no matter how hard you try. (Grep for 'multiplier' in question/type/numerical/*, you will see PARAM_NUMBER input cleaning and "$xx * $multiplier".)