Numerical question filter to accept 1.2*10^-34

Numerical question filter to accept 1.2*10^-34

by Jeff Forssell -
Number of replies: 13
I'm starting to get ready to attack the code in the numerical question type.

I was thinking of starting with a small patch that would extend the ability to enter numbers in scientific format. At present it functions quite well in accepting
1.2e-34
1.2E-34
1.2e-034
1.2e+034 etc
etc but doesn't accept 1.2*10^34

I would like to make a patch that would recognize 1.2*10^-34 and 1.2*10**-34 as equivalent to 1.2E-34 and change them to that.

Do any Math/Sci teacher's have any doubts/additions?

Any security risks to think about?

Would it be good to have (both or in stead) a JavaScript the says at attempted submission that the entry will not be recognized as a number and presents
"if you want to enter a number in Scientific notation, a number like 1.2*10^-34 can be written 1.2E-34" [Close to rewrite][Send anyhow]

Average of ratings: -
In reply to Jeff Forssell

Re: Numerical question filter to accept 1.2*10^-34

by Pierre Pichet -
Hi Jeff

1.2*10^34
The problem with your suggestion is that you use mathematical operators other than the sign + or - in your "patch".
This is equivalent to accept a mathematical equation in the answer i.e. this need to be treated by the eval() function which in PHP does not accept the exponent ^ but use the power(x,y) function.
In PHP ^ is a bitwise operator.
$a ^ $b Xor (exclusive or) Bits that are set in $a or $b but not both are set.


Pierre
P.S. However there should be a help in the quiz display for question types that need a numerical answer so that the student knows how to answer.
In reply to Pierre Pichet

Re: Numerical question filter to accept 1.2*10^-34

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I assume Jeff will not be using eval.

If it was me, I would parse the input with regular expressions.
In reply to Tim Hunt

Re: Numerical question filter to accept 1.2*10^-34

by Jeff Forssell -
I was thinking of "parse the input with regular expressions."

I know that at least in JavaScript that eval can do some fancy tricks but is security wise very risky.
In reply to Jeff Forssell

Re: Numerical question filter to accept 1.2*10^-34

by Pierre Pichet -
Hi Jeff,

I agree with your suggestions of help for the student who have to add units to an answer in a numerical question (numerical and calculated).

Things should be clear to the student i.e are the units mandatory or not.
Furthermore I think that the useable units should be known either in a description question text or a specific help.
The description text is far more easier to implement and could be written is such a way that the student could do a copy and paste which is almost a necessity for all units with exponents.

Teachers should also be teached what is really a question or a multiple question. generally they forget and want the numerical value and the units correctly written.

I do favor the multiple choice question has the best way to test the student knowledge about units to express a numerical physical quantity or about the precision of a numerical physical quantity.

As for your proposal to filter for different number formats, some of them could be done at the numerical questiontype level code on the server side.

Pierre

P.S. I will do some tests and come you back.
In reply to Jeff Forssell

Re: Numerical question filter to accept 1.2*10^-34

by Pierre Pichet -
Hi Jeff,
There various ways to inform the student on how to answer for numerical questions.
  • The description question is one way.
  • We could allsow create an instructions field analoguous to the general feedback that could be display aside or underside the response input element that will describe the teacher instructions on how to answer.
    This will have the advantage of complete flexibility for any given science, units etc.
  • As tests are sometimes done in secure condition , the pop-up window general instructions seems to be proscribe.

For conditions where the teacher wants fractions as 1/5 and no decimal fractions the short answer can be used.
You cannot put 1/5 in numerical because this is not understood as a numerical value.

The mandatory status of units could be more clearly defined at the question editing form.

Pierre

P.S. I put here those elements as I don't want to scramble your page in the docs.


In reply to Pierre Pichet

Re: Numerical question filter to accept 1.2*10^-34

by Pierre Pichet -
Hi Jeff,
I just fill a bug MDL-20296 for adding instructions to the numerical.
Look at the screenshot.


Pierre
In reply to Jeff Forssell

Re: Numerical question filter to accept 1.2*10^-34

by Pierre Pichet -
Hi Jeff,
We could also modify the numerical see MDL-4474 and some experiments to set a penalty for units

Pierre

essay
In reply to Pierre Pichet

Re: Numerical question filter to accept 1.2*10^-34

by Jeff Forssell -
I'm happy that there is some activity going on in this question.

I don't understand having the "penalty if no unit" repeated in the units. Maybe there is a case for differentiating penalty for different units, but I think it usually just a question "are the units obligatory or not?".

I just read through the thread http://moodle.org/mod/forum/discuss.php?d=95193, whew!

It's good for people, like Pierre, that feel that the numerical and units questions can be separate. For you people, that is doable in Moodle as it is.

For Swedish national exams, the teachers that have indoctrinated me, "some of our natural scientific lecturers are very unsatisfied with this" (in the 09-09-09 post in the tracker thread) it feels about like for a language teacher to have "articles" in separate questions.

Or here: http://www.journaleic.com%2Farticle%2FviewPDFInterstitial%2F3418%2F2481&ei=cAWxSvO7IIrM-Qbf9bnSBg&usg=AFQjCNFBQs9MNxL5KJHwGOyXsN-xkSjKaA&sig2=8r3g1ZuUj1NPMeVe7z3OFQ

"The proper choice of unit and indication of sense to a solution of an
engineering problem is an indispensable part of engineering training. An answer to engineering problems usually consists up to three entries: numerical value, unit
and sense. "

I realize that it will be a challenge to program this kind of feature, but there are many people that feel that this is the way to go.

"As in other systems (like WebCT) the teacher should be able to set separately the grading of the numerical value and the grading of the unit part." I tried to google that but didn't find anything (but some that didn't think WEBct handled it well.) How do they implement it? ONE right number and ONE right unit for the right answer?
Average of ratings:Useful (1)
In reply to Jeff Forssell

Handling units and numerical proposal

by Pierre Pichet -
Hi Jeff
ONE right number and ONE right unit for the right answer?

The grading was more like the good answer and a penalty if the unit is not right i.e. a fraction of the grade as there was only one answer if I remember well. Our WebCT site was closed 2 years ago.

Solving for all possible cases is a very ambitious task.

First we can offer for new questions the possibility to set the unit as mandatory with a given penalty for a bad unit as a fraction of the numerical value grade.
This is not a completely valid solution for test theory but more related to usual manual grading.

If the teacher want to grade the student capacity to choose a valid unit , he should create other questions (short, multichoice).

Engeneering effectively ask for a good numerical response in a specific unit and this set-up could accomodate the need, I think.

The instructions about how to answer a numerical question in Moodle should be known by the student.
They could vary according to localized standard (like metric) and be specific to a given installation.
The instructions for numerical conversions should be set at the installation level and display near the response input element.

The instructions for the units should be
  • written by the teacher and display with the numerical conversions instructions.
  • or display as a multiple choice element that is filled by the teacher when editing the question so that there are no mispelled or formating problems.

Pierre
In reply to Pierre Pichet

Re: Handling units and numerical proposal

by Jeff Forssell -
I've been playing with some regular expressions for doing this and made a PHP page that maybe others working with regular expressions could find useful. I'm sure there are other resources that maybe do it better, but at least I had it mark up the various substrings that I found, which made it easier to make the replace string. The page can test a whole array of teststrings each time you adjust your search/replace strings.

Anyhow I have 2 version of the search string. Both change *10^and *10** to E.

One of them also changes a , decimal point to . but it than changes 3*10^5 to 3.E5 which probably works Ok but doesn't seem as clean as I'd like. The other one one handles that OK but doesn't change , to .

(there's also some filter ideas about ½ and " 1/2" to .5 but that is not the major idea)

Any how if anyone would like to suggest some possible (but not HIGHLY improbable) student input string that might cause problems with this conversion, please suggest!

In reply to Jeff Forssell

Re: Handling units and numerical proposal

by Pierre Pichet -

Thanks Jeff,

The ideal solution will be to change the response handling code so that various number formats could be interpreted correctly by question code so that the input is more user friendlywink.

 I just noticed that there are already old  bugs on this matter MDL-3282

Pierre

In reply to Pierre Pichet

Re: Handling units and numerical proposal

by Jeff Forssell -
I have the impression that Moodle numerical questions handle . and , (like we have in Sweden) as decimal OK on the student side but I think it is less tolerant when the teacher is putting in the correct patterns. So it doesn't feel like it's a major issue. (Even if we want to make things easy for teacher's too. But there I think good help files and Docs might suffice.)

I'm still trying to find what happens, in which php, when someone answers a numerical question. I've read about where the various bits are stored in the DB, (It was interesting to me that the answer patterns were in a different table from the questions.) but I haven't read anything describing, something like:

When the student hits the submit button quiz.php sees that the answer string is to go to numeric/questiontype and sends the string after trimming trailing and leading whitespace as $trimmedanswer to it ....

Is there any doc like that, or can you tell me a good way of "picking up the trail"?