I have a numerical question where the math is usually done in the units of watts, the answer is normally converted and expressed in kilowatts while some of our specifications are listed in megawatts. Since it would be reasonable for the student to return an answer in any of those units I set up the units as follows:
After saving, the multiplier for MW gets converted to 1.0E-6 which is fine.
Just the number, W, Watts and kW all work fine but I can not get a proper MW value to return as correct. Any ideas as to why this unit is not working for me?
I think it is but unfortunately it looks like both Moodle and php have given up and washed their hands of it. It looks like a very hard to pin point the source kinda bug. I'm running php 5.2.9 and if I run the test script from the php bug report
$f=array(1E-4, 1E-5, 1E-6, 1E-7, 1E-8); foreach ($f as $fval) echo $fval, "\n"; I get the correct results. However playing around with the numerical question: Answer: 59700 Acceptable error: (blank) with 'Unit' set to "MW" trying various multipliers I get: submit: 0.0000597MW multiplier: 1.0E-9 Result: works fine submit: 0.000597MW multiplier: 1.0E-8 Result: works fine submit: 0.00597MW multiplier: 1.0E-7 Result: works fine submit: 0.0597MW multiplier: 1.0E-6 Result: FAILS! submit: 0.597MW multiplier: 1.0E-5 Result: FAILS! submit: 5.97MW multiplier: 1.0E-4 Result: FAILS! submit: 59.7MW multiplier: 1.0E-3 Result: works fine From the Moodle Bug report it looks like there is a work around if it's a tolerance you just increase your tolerance by 10% but I can't do that for a unit conversion unless somebody has any suggestions.
Well I found my own work around. I gave the answer an Acceptable error of 1 and now MW works with a multiplier of 1.0E-6. Submitting an answer of 0.0597MW gets counted as correct. Still interesting on how the various multipliers failed from 1.0E-6 to 1.0E-4 but worked above and below that.