[LON-CAPA-users] submission masaging
Peter Riegler
lon-capa-users@mail.lon-capa.org
Fri, 18 Jul 2008 20:39:22 +0200
Bob Gonzales wrote:
> Peter,
>
> The &implicit_multiplication() doesn't seem to work. For
> a string like "1.1 e-1" it returns "1.1*e-1".
Arrgh, yes. And "1.1*e-1" is a string, of course. So, same Perl problem
as before!
I might have been mistaken with the implicit_multiplication-diagnosis.
Your first analysis stated that loncapa has taken out the space out of
"1.1 e-7". Presumably that's what you have to do as well:
$submission = &EXT....
$submission =~ s/(\d)\s*[Ee]/$1e/g;
Now do whatever you like with $submission;
This should replace the space between the digit and exponent (E or e)
even for vector input.
$submission =~ s/(\d)\s*[Ee][\d+-]/$1e$2/g;
might be even more suitable.
Peter
If I use
> that in a calculation it becomes the number 1.1 just like
> the "1.1 e-1" does.
>
> Also, I'm not using formularesponse or mathresponse, I'm
> using numericalresponse but I can't see that it would matter
> since Perl is doing the math as you said.
>
> Thank you for the information!
>
> Bob Gonzales
> Binghamton University
>
> -----Original Message-----
> From: lon-capa-users-admin@mail.lon-capa.org
> [mailto:lon-capa-users-admin@mail.lon-capa.org] On Behalf Of Peter Riegler
> Sent: Thursday, July 17, 2008 3:40 PM
> To: lon-capa-users@mail.lon-capa.org
> Subject: Re: [LON-CAPA-users] submission masaging
>
> Hi Bob,
>
> below is a guess what is going on. To give a more reliable answer I would
> need to see the source code of the problem.
>
> Bob Gonzales wrote:
>
>
>>What kind of massaging does LONCAPA do to the string of text that is
>>entered for an answer?
>>
>>I ran into a situation where a student entered the number 1.1e-7 as
>>1.1 e-7. LONCAPA took out the spaces before it checked the answer
>>and then marked the problem correct.
>
>
> Presumably, you are using formularesponse or mathresponse. There, prior to
> grading the submission is passed through a function named
> &implicit_multiplication. Among other things it interprets suitable spaces
> as multiplication operators (which is perfectly fine for 1.1<space>e-7).
>
>
>
>
>>I then grabbed the
>>submission (via &EXT) and assigned it to a variable and then used the
>>variable in a calculation, without removing spaces (who would have
>>thought...) and got an answer I didn't expect. Interestingly,
>>LONCAPA used the mantissa (the 1.1 part) in the calculation and
>>ignored the rest of the submission.
>
>
> Well, this was Perl. Your 1.1 e-7 entered as a string in your calculation,
> but within the context of a calculation was converted into a number.
>
>>So, I guess I need to massage the submission the same way LONCAPA does
>>in order to avoid this situation in the future.
>
> Me too. Wrapping an &implicit_multiplication() around the submission should
> do it.
>
> Hope this will help
>
> Peter
>
>>Thanks,
>>Bob Gonzales
>>Chemistry Dept
>>Binghamton University
>>
>>_______________________________________________
>>LON-CAPA-users mailing list
>>LON-CAPA-users@mail.lon-capa.org
>>http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>
>
> --
> Peter Riegler
> Fachhochschule Braunschweig/Wolfenbüttel Salzdahlumer Str. 46/48, 38302
> Wolfenbüttel Tel. +49 5331 939 6314, Fax. +49 5331 939 6002
> email: p.riegler@fh-wolfenbuettel.de
> http://public.rz.fh-wolfenbuettel.de/~riegler
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>
>
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
--
Peter Riegler
Fachhochschule Braunschweig/Wolfenbüttel
Salzdahlumer Str. 46/48, 38302 Wolfenbüttel
Tel. +49 5331 939 6314, Fax. +49 5331 939 6002
email: p.riegler@fh-wolfenbuettel.de
http://public.rz.fh-wolfenbuettel.de/~riegler