Significant figures not working as described in documentation site

Significant figures not working as described in documentation site

by Mike Taylor -
Number of replies: 3

Hi,

I have set up a Sig Fig question as described on the Moodle Formulas documentation site, but whenever the question asks for 3 sig fig (nsf = 3), it marks it as incorrect even if the "Fill in correct response" button is used:

3sf problem

It works for nsf =  1 or 2.

Setting below are used.

Random variables: nsf={1:4:1};
                  x={10.001:99.999:0.001};

Global variables: a=nsf-1-floor(log10(abs(x)));
                  xr=x==0?x:round(x*pow(10,a),0)*pow(10,-a);
                  ans=xr;

Can anyone spot what I have done wrong?

Average of ratings: -
In reply to Mike Taylor

Re: Significant figures not working as described in documentation site

by Dominique Bauer -
Wužiwarjo-wobraz wo Documentation writers Wužiwarjo-wobraz wo Particularly helpful Moodlers Wužiwarjo-wobraz wo Plugin developers

Mike,

Starting with version 4.81 for Moodle 3.3 to 3.5 (2018080300), the Formulas question type has a built-in sigfig() function which displays values with the desired number of significant figures.

If you have not already done so, install version 4.81 of the Formulas question type and use the sigfig() function.

The Moodle Formulas documentation site has been updated.

Average of ratings:Useful (1)
In reply to Dominique Bauer

Re: Significant figures not working as described in documentation site

by Mike Taylor -

Thanks Dominique,

sigfig() worked so our IS team must have installed 4.81.

Also, the problem was my error - I found an "a" variable in the Local Variable field (erroneously left in from a previous version). Deleting this fixed the problem. But sigfig() is far more convenient!

In reply to Mike Taylor

Re: Significant figures not working as described in documentation site

by Dominique Bauer -
Wužiwarjo-wobraz wo Documentation writers Wužiwarjo-wobraz wo Particularly helpful Moodlers Wužiwarjo-wobraz wo Plugin developers

Mike,

If you are using an earlier version of the Formulas question type, you must use the workaround a=nsf-1-floor...

I tried 76.072 rounded to 3 significant digits and it works fine. I do not see what's wrong with the information you provided. Please include the XML file.

Average of ratings:Useful (1)