[LON-CAPA-users] Does formula response support inequalities?
Gerd Kortemeyer
korte at lite.msu.edu
Sat Mar 29 11:59:48 EDT 2014
Hi,
On Mar 29, 2014, at 11:37 AM, Itay Furman <itayf at nospammail.net> wrote:
>
> Consider a certain physical in which stable equilibrium exists if
> 2*k*l^2 - mgL > 0,
> where k,l,m,g, and L, are parameters.
>
> I would like to challenge my students with a problem for which the
> answer would be the above symbolic inequality.
>
> However, as I understand I _cannot_ use formula response for that purpose; is this correct? or did I miss something?
>
> [
> I believe I could use formula response to challenge the students by
> reformulating the question like this
> "A stable equilibrium would exist if the potential energy, mgL, be
> smaller than:"
> and match the students' response against the expression "2*k*l^2".
> But I think that asking them to provide the full inequality is preferred.
> ]
No, formularesponse will not do this. But you can use customresponse or mathresponse.
With mathresponse, you can do whatever you like with the student expression inside of MAXIMA CAS.
With customresponse, you can do whatever you like with the student expression inside of a Perl environment. From there, you can call MAXIMA if needed using &cas(‘maxima’,…).
You probably want to accept “2*k*l^2>m*g*L” as correct, so I would in customresponse:
<problem>
<startouttext />
In which case do you have stable equilibrium?
<endouttext />
<customresponse answerdisplay="2*k*l^2 - m*g*L > 0">
<answer type="loncapa/perl"># Get left and right side of (in)equality
($left,$sign,$right)=($submission=~/^(.*)([\>\<\=])(.*)$/);
# If it's not an (in)equality, forget it
unless ($sign) { return 'BAD_FORMULA'; }
# If it's an equality, it's wrong
if ($sign eq '=') { return 'INCORRECT'; }
# If it's "smaller than", invert
if ($sign eq '<') { $inter=$left; $left=$right; $right=$inter; }
# Okay, so now we have $left>$right
# And compare to the expression we want
my $diff=&cas('maxima',"$left-($right)-(2*k*l^2-m*g*L)");
if ($diff=~/^Error/) { return 'BAD_FORMULA'; }
if ($diff==0) { return 'EXACT_ANS'; }
return 'INCORRECT';</answer>
<textline readonly="no" spellcheck="none" />
</customresponse>
</problem>
- Gerd.
More information about the LON-CAPA-users
mailing list