[LON-CAPA-users] Forcing a sigma solution

Gerd Kortemeyer korte at lite.msu.edu
Fri Mar 23 06:31:09 EDT 2012


Hi,

On Mar 22, 2012, at 11:35 PM, Seema Ali wrote:
> 
> I'm not sure how to extract information from an ordered triple.  I'm also concerned that students might have a hard time entering the 3 pieces of information correctly.  So I tried to implement Justin's idea

Yes, I would definitely go with Justin's idea.


> in a different way by having 3 textboxes, however each text box requires an answer and I would like to use the Math Response to see of a small set of conditions have been satisfied to determine if the response is correct.

You can have several boxes within the same customresponse.


>  I also don't really know how to extract the 3 pieces of information and am hoping that RESPONSE[1], RESPONSE[2] AND RESPONSE[3] can be used for the 3 text boxes.
> 
> Below is a copy of the problem with the 3 textboxes.  I'm stuck on the coding part. If anyone has a similar question that uses information from a few different textboxes to see if the answer is correct or another way to implement this type of question and is willing to share, I'd greatly appreciate it.

You can have more than one textbox within the same response, no problem. I did not have much time this morning, but I started coding something for you. It's sort of your setup, but inside-out. It brings up a customresponse with four textboxes and shows how to access the values from within the answer-script.

Inside customresponse, I would then use &cas()-calls to evaluate the sum, using MAXIMA. I haven't done that part correctly (something's wrong), but it's just straight MAXIMA.

I'll be happy to work some more on this later today, just let me know what you need.

- Gerd.

<problem>
<script type="loncapa/perl">
$answer=&random(3,18,1);
</script>

<startouttext />
Given a sum with the expected result.
<endouttext />

<customresponse answerdisplay="$sample">
<startouttext /><table><tr><td><endouttext />
    <textline size="3" readonly="no" />
<startouttext /></td><td></td><td></td></tr><tr><td><font size="+6">Σ</font></td><td><endouttext />
    <textline readonly="no" />
<startouttext /></td><td>=$answer</td></tr><tr><td><endouttext />
    <textline readonly="no" size="1" />
<startouttext />=<endouttext />
    <textline readonly="no" size="3" />
<startouttext /></td><td></td><td></td></tr></table><endouttext />
<answer type="loncapa/perl">
$upper=$$submission[0];
$term=$$submission[1];
$vari=$$submission[2];
$lower=$$submission[3];

$sum=&cas('maxima',"sum($term,$vari,$lower,$upper)");
if ($sum=~/^Error/) { return 'BAD_FORMULA'; }
if ($sum==$answer) { return 'EXACT_ANS'; }
return 'INCORRECT';</answer>

    
</customresponse>

</problem>





More information about the LON-CAPA-users mailing list