[LON-CAPA-users] Forcing a sigma solution

Seema Ali sali at vsb.bc.ca
Thu Mar 29 20:13:13 EDT 2012


I published the question and the text boxes show up when I'm an author but do not show up as a student, when I publish the problem to a course.  What am I doing wrong?

Thanks.


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

<startouttext />
<instructions>
</instructions>

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

<customresponse answerdisplay="$sample" id="11">
<startouttext /><table><tr><td><endouttext />
    <textline readonly="no" size="3" />
<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>





-----Original Message-----
From: lon-capa-users-bounces at mail.lon-capa.org on behalf of Gerd Kortemeyer
Sent: Fri 3/23/2012 3:31 AM
To: Discussion list for LON-CAPA users
Subject: Re: [LON-CAPA-users] Forcing a sigma solution
 
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>



_______________________________________________
LON-CAPA-users mailing list
LON-CAPA-users at mail.lon-capa.org
http://mail.lon-capa.org/mailman/listinfo/lon-capa-users

td
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20120329/99744c0b/attachment-0001.html>


More information about the LON-CAPA-users mailing list