Very small numbers in answers in calculated question type

Very small numbers in answers in calculated question type

ó $a->name - $a->date
Number of replies: 8

I am using Moodle 3.5. I have found that once the magnitude of the numbers comprising the range of a parameter or worse, the answer to the question goes below around 1e-8 (probably corresponding to the maximum number of digits (9)), it becomes impossible to use the calculated question type - you just get it calculated to zero, which puts it outside the range (under Answers Tolerance Parameters). For instance, if I want to set a question based on the size of the electron charge (this is just an illustrative example) where the answer is a small multiple of q (the multiple being physically meaningful), you cannot define the question with say 150 datasets - it will just treat the answer as zero as it goes beyond 9 digits. Why can't answers accept scientific notation at the definition time? The students can enter it in that form, but I as the instructor can't do this when I set up a question.

I accept that it is possible to use multiplicative units, such as attocoulombs etc. to express such answers, but those are artificial-looking and can needlessly confuse students. In this case, it simply is traditional (at least since 1915 or whereabouts) to say that q=1.602e-19 coulombs. No one I know writes 0.1602 aC as the fundamental electron charge. C is the SI unit, not aC. If we are supposed to encourage students to use SI units, it would look singulalrly weird to abandon that overarching effort at exam time just becaue of a technical limitation. Asking students to explicitly calculate the ratio (charge/q) can give away an important hint to the solution of the question (which I may not want to do), so that is not an option either.

And even if you could do that, what would you do about cases like h=6.626e-34, which can be the LCM of angular momenta in quantum mechanics, or m=9.109e-31 which is the rest mass of an electron in SI units? It gets ugly. I have intentionally picked these examples to make this point. In engineering, you would be stuck with permittivity which is of the order of 1e-13 for most materials in cgs units, and 1e-10 in SI units.

Can this Moodle limitation be fixed? Sometimes, the parameters and answers need to be such ranges for the question to not look contrived/weird.

Meán na gcomhlán: -
In reply to H Singh

Re: Very small numbers in answers in calculated question type

ó $a->name - $a->date
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hello H Singh,

With the Formulas question type ↗, values are limited only to the minimum and maximum float values in PHP, i.e. 2E-308 to 1.8E308 (where the exact values depend on the platform).

Here is an example:


In reply to Dominique Bauer

Re: Very small numbers in answers in calculated question type

ó $a->name - $a->date
Formulas question type isn't as powerful as the calculated question type - can't do multi-part questions with shared datasets for one. Can't define multiple answers with different grade percentages. Can't use multiple units with conversion (useful in the case of currents, where a student may respond in uA or mA equally well). Among other issues. The calculated question type is close to perfect. But it chokes on problems where the answer has to be a small number.
In reply to H Singh

Re: Very small numbers in answers in calculated question type

ó $a->name - $a->date
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hello H Singh,

can't do multi-part questions with shared datasets for one
Yes, it can.

Can't define multiple answers with different grade percentages.
Yes, it can.

Can't use multiple units with conversion
Yes, it can.

Please do not post false information on this forum.


In reply to Dominique Bauer

Re: Very small numbers in answers in calculated question type

ó $a->name - $a->date
Thanks. You are right on the multiple parts with shared datasets. That is good to find out.

However, it cannot do multiple answers with different grade percentages. I just tried to create a question. In Part 1, I do not see any space for an alternate answer for that part that gives students 90% or (any number other than 100%) of the grade. This is often used to account for expected student errors. In the Calculated question, it allows you to add additional answers (with their own expressions).

I also checked the units available - only options are SI or none. Can you point out where I might set up multiple units (say uA. mA, A, with defined scaling factors for the current), or those in non-SI units (especially in electromagnetism)?
In reply to H Singh

Re: Very small numbers in answers in calculated question type

ó $a->name - $a->date
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hello H Singh,

However, it cannot do multiple answers with different grade percentages. I just tried to create a question. In Part 1, I do not see any space an alternate answer for that part that gives students 90% or (any number other than 100%) of the grade. This is often used to account for expected student errors.

Use the Manual grading criteria ↗. It may take you a few minutes to figure out how it works, but once you get the hang of it you'll find it's pretty effective.

I also checked the units available - only options are SI or none. Can you point out where I might set up multiple units (say uA. mA, A, with defined scaling factors for the current).

See Units ↗. You can even define your own set of units and conversion factors ("User defined rules" at the bottom of the page).

In reply to Dominique Bauer

Re: Very small numbers in answers in calculated question type

ó $a->name - $a->date
Thanks. However, it does not look very practical. Let me explain why.

In my usual courses, I often have complicated answer expressions in Calculated question type which can be very lengthy expressions with fairly large number of in-built Moodle math functions (pow, exp, sinh, etc.), and problematically, parenthesis. Character lengths for these expressions can sometimes exceed the displayed space there. Now, it takes me usually some debugging (in the case of complicated expressions), where I sometimes miss out a closing brace, etc. That is just one answer. If I use what I am seeing in the docs of Manual grading criteria, it looks like that the answer expression has to be constructed as a composite of all the answers I am constructing (with one or more giving the student 100% of the grade) and others giving the student smaller percentages (I assume this is where different c values come in). I like the coolness of the idea - construct a mathematical expression giving the student the grade itself. However, I think that as a practical matter, this is going to be very hard to do without significant debugging overhead (when you have lengthy expressions for each answer with a non-zero grade). Worryingly, I think that one could easily make an error in distributing the correct grade percentages to each of the answers. I wish this had been implemented as separated text boxes for expressions for each possible answer. Maybe it sounds like I am too used to the Calculated question type, but that is simpler for an instructor to enter.

Thanks for the answer on Units.

So, while I will revise my initial opinion on Formulas, but I am going to grade this as too difficult to use for complicated lengthy expressions for multiple answers. Most of the answers for my topics tend to be lengthy, so it may be something that affects me and not that many other people.

All that said, I have looked at the docs for the formula question type, and it certainly seems to have a lot of power, provided you are willing to sacrifice some practicality and accept the possibility of greater errors. That you have seamlessly included parts in the question type in a way that is extremely natural is something I must congratulate you on. I wish that is something that Calculated could learn from. Right now, if we want parts, I have to create sections in the question paper, and forego global shuffling options. Your way of handling that is superior. However, nearly 90%+ of my questions tend to have long complicated answer expressions, and fewer than 20% have parts (probably because of how difficult and contrived Calculated makes it), so I think I am going to have to stick to Calculated for now.

That means that my original query remains unaddressed.
In reply to H Singh

Re: Very small numbers in answers in calculated question type

ó $a->name - $a->date
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Most of the answers for my topics tend to be lengthy...
... nearly 90%+ of my questions tend to have long complicated answer expressions


Certainly, either you are not using the "Calculated" question or you are misdescribing your question. Please provide a full example so that we can understand what you want to do.

provided you are willing to sacrifice some practicality and accept the possibility of greater errors

The Formulas question type is most practical. Its well-thought-out structure and clear syntax will save you from making errors.

probably because of how difficult and contrived Calculated makes it
Well, good luck.
In reply to H Singh

Re: Very small numbers in answers in calculated question type

ó $a->name - $a->date
I found the solution to this "problem". It seems that under the tolerance settings on the last page in the calculated question type, there is a tolerance type setting. Changing it from decimals (default) to significant figures appears to have addressed this problem. So, my problem above is solved.

Now, if only calculated question type could directly include parts the way formulas question type does, it would be perfect. I guess I need to brush up my rudimentary php skills, and find some time to do it.