[LON-CAPA-users] numeric portion of a submission

Gerd Kortemeyer korte at lite.msu.edu
Thu Oct 17 07:37:19 EDT 2013


On Oct 17, 2013, at 7:08 AM, Jon Hall <jdh65 at bellsouth.net> wrote:

> Is there an easy way to access just the numeric portion of a student's submitted answer?
> In other words, if a student submits 54.6 m/s as an answer, is there a way to strip the non-numeric characters to use just the 54.6 as a point on a gnuplot, for example?
> So my script would include:
> $vi_submitted=&EXT('user.resource.resource.15.16.submission');
> but then what?

Not easy at all, since the number could include scientific notation, etc. The regular expression used within LON-CAPA itself to make the separation is rather complicated, and we needed to fix it more than once :-(.

But I would recommend against this anyway, since the number alone does not make *any* sense. How would the plot consider the equivalence between 54.6 m/s and 0.0546 km/s?

If your problem expects certain units, I would recommend to give them to the student. Either make the question text specify "in m/s" or write that behind the answer box, e.g.

[    ] m/s

- Gerd.

More information about the LON-CAPA-users mailing list