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 <ko...@lite.msu.edu> wrote: > Hi, > > On Oct 17, 2013, at 7:08 AM, Jon Hall <jd...@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@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