Note: You are currently viewing documentation for Moodle 3.3. Up-to-date documentation for the latest stable version of Moodle is probably available here: Formulas: More examples.

Formulas: More examples

From MoodleDocs


Significant figures

"The significant figures of a number are digits that carry meaning contributing to its measurement resolution." (Reference: https://en.wikipedia.org/wiki/Significant_figures).

The Formulas question has no built-in function to display numbers with a given number of significant figures. However, it is easy to work out this function as the following variable assignment which works with any real number:

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

where x is the number to be rounded, nsf the number of significant digits to keep and xr the resulting rounded value.

Example

This example deals with the display of the correct answers with different numbers of significant figures.

The Formulas question should look like this:

Formulas201712310126.png

Play it   Login info  (Open in new tab: Ctrl+Shift+Click)

Example

This example is a significant figures drill.

General
  Question name*       Significant figures drill
Variables
  Random variables     a=a={-1,1};
                       b={-4:4.01:0.01};
                       ncs={2,3,4};
Main question
  Question text*       With part's text placeholders
                       Two subquestions on addition:
                       {#1a}
                       {#1b}
                       One subquestion on subtraction:
                       {#2}
Part 1
  Part's mark*         1
  Answer type          Number
  Answer*              7
  Grading criteria*    Absolute error == 0
  Placeholder name     #1a
  Part's text          What is 3 + 4?
Part 2
  Part's mark*         1
  Answer type          Number
  Answer*              9
  Grading criteria*    Absolute error == 0
  Placeholder name     #1b
  Part's text          What is 4 + 5?
Part 3
  Part's mark*         1
  Answer type          Number
  Answer*              3
  Grading criteria*    Absolute error == 0
  Placeholder name     #2
  Part's text          What is 9 − 6?

The Formulas question should look like this:

Formulas201712301427.png

Play it   Login info  (Open in new tab: Ctrl+Shift+Click)

Back to top of page

← FORMULAS QUESTION TYPE