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

hkng hkng at fsu.edu
Thu Oct 17 07:54:31 EDT 2013


Hi,

As Gerd pointed out not an easy problem. However, Perl will automatically
take the numeric part of a variable if you do a arithmetic operation. For
example, if you do the following.

$vx = $vi_submitted+1;
$vx--;

then $vx will be just the numeric value. Works with exp too but not
something like 1.23x10^3 m/s.

-hk


On Thu, Oct 17, 2013 at 7:37 AM, Gerd Kortemeyer <korte at lite.msu.edu> wrote:

> Hi,
>
> 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.
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users at mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20131017/0a1a45b2/attachment.html>


More information about the LON-CAPA-users mailing list