Exponential notation in the feedback (Formulas question)

Exponential notation in the feedback (Formulas question)

by Dominique Bauer -
Number of replies: 2
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Help in how to show questions answer in Moodle

Dear Dominique,

I hope everything is fine with you.

Please forgive me for bothering you, but I really couldn't find the information I need about Moodle.

I'm a new Moodle user and I'm still learning all of its features. For the moment, try to understand how to make the answer to an exercise with a number be shown in scientific notation and with only 3 significant figures. With respect to the significant figures, I have used "sigfig () 'but, as in my exercises, answers whose values are very large (of the order of 10 ^ 20 or more) or very small (of the order of 10 ^ -15 or less are common) ), many zeros appear in the responses.

So, please, could you give me some reference on how to get the answers to be presented in scientific notation?

Thank you very much for your attention and, again, forgive me for the inconvenience.

Best wishes,

Average of ratings: -
In reply to Dominique Bauer

Re: Exponential notation in the feedback (Formulas question)

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

First of all, thank you for your question.

You wrote to me privately, but I will answer you on this forum because your question may be of interest to other moodlers.

The easiest way is probably to use the JavaScript toPrecision() method. Simply insert the following in the HTML codes of the Combined feedback, for example "For any correct response":

      
Correct. The answer is <span id="answer"></span>.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
    $("#answer").text({m}.toPrecision(3));
});
</script>

where m is the answer and 3 is the number of significant digits.

The XML file of an example is attached.

Feel free to register to this forum and ask for details if necessary.



In reply to Dominique Bauer

Re: Exponential notation in the feedback (Formulas question)

by Luis H Avanzi -

Dear Dominique, 
Thank you very much for your response and for your enormous help.
Best regards,