To take the quizzes, you must log in.

*Username:***student***Password:***Formulas.1**You can view this site in

the language of your choice.

- Answer off by orders of magnitude
### Answer off by orders of magnitude

# Answer off by orders of magnitude

Moodle forum discussion: 2019-06-26.

A method is presented below allowing the teacher to give a feedback if the student's answer is off by some orders of magnitude, that is, by a power of 10. The method consists of obtaining the correct answer and the student's answer, then comparing the two values.

In the Calculated question and Formulas question types, the correct answer can be obtained directly by using the name of the corresponding variable enclosed in braces, for example {x}.

The student's answer can be obtained using a Java script. For example, in the simple case of a single question per page and an answer without unit:

- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ // Get the student's answer as a string and transform it into a number: var studentAnswerString= $(":text").val(); var studentAnswer = Number(studentAnswerString); // You can then use the student's answer, for example, in a feedback: document.getElementById("feedback1").innerHTML = "You answer is: " + studentAnswer + " etc."; }); </script> <p id="feedback1"></p>
### Example 1

This example illustrates a

**Formulas**question with the student receiving a feedback if his/her answer is off by some orders of magnitude.## Question settings

The question should look like this:

### Example 2

This example illustrates a

**Calculated**question with the student receiving a feedback if his/her answer is off by some orders of magnitude.## Question settings

The question should look like this: