[LON-CAPA-users] tables, matching problems

Gerd Kortemeyer lon-capa-users@mail.lon-capa.org
Fri, 11 Feb 2005 16:59:01 -0500


Hi Sally,

Here's a solution with static images. I am sort of reconstruction what the
listitems usually do for you. Replace the <img>'s with the GNUplots, and you
are in business.

What this does:
The script has two arrays
@files - filenames, in your case, the parameters/functions for dynamic plots
@vals - the correct answer to go with each
The next loop just permutes both @files and @vals, but keeps them in order
correspondence.
Then between the <startouttext />...<endouttext />, you plot your table,
labeling the columns A, B, etc. While I pass the filenames to static <img>, you
would pass the functions to the GNUplots.
The I use a normal optionresponse, with "Circuit A", ... and "none" as options.
Then I make foils with the correct answers "Circuit A", ... "none", and vals[n]
as printed text. I have put in two capacitances that I do not have plots for,
and then have five foils picked.


<problem>
<script type="loncapa/perl"># Names of the files
@files=('p2s2','s4','p4','p2p2');
# Capacitances of the depicted circuits
@vals=('5C/2','C/4','4C','C');
# Mix up the order
for ($i=1;$i<=3;$i++) {
     $i1=&random(0,3,1);
     $i2=&random(0,3,1);
     $f=$files[$i1];
     $v=$vals[$i1];
     $files[$i1]=$files[$i2];
     $vals[$i1]=$vals[$i2];
     $files[$i2]=$f;
     $vals[$i2]=$v;
}</script>

<startouttext />Consider the following four circuits:
<table>
<tr>
<tr><th>Circuit A</th><th>Circuit B</th><th>Circuit C</th><th>Circuit
D</th></tr>
<td><img src="four/$files[0].gif" TeXwidth="18" /></td>
<td><img src="four/$files[1].gif" TeXwidth="18" /></td>
<td><img src="four/$files[2].gif" TeXwidth="18" /></td>
<td><img src="four/$files[3].gif" TeXwidth="18" /></td>
</tr>
</table>
Match the circuits and their capacitances.<endouttext />
<optionresponse max="5" randomize="yes" TeXlayout="horizontal">
    <foilgroup options="('Circuit A','Circuit B','Circuit C','Circuit
D','none')">

<foil location="random" value="Circuit A" name="foilA">
<startouttext />
$vals[0]<endouttext />
</foil>
<foil location="random" value="Circuit B" name="foilB">
<startouttext />
$vals[1]<endouttext />
</foil>
<foil location="random" value="Circuit C" name="foilC">
<startouttext />
$vals[2]<endouttext />
</foil>
<foil location="random" value="Circuit D" name="foilD">
<startouttext />
$vals[3]<endouttext />
</foil>
<foil location="random" value="none" name="foilE">
<startouttext />
2C<endouttext />
</foil>
<foil location="random" value="none" name="foilF">
<startouttext />
C/2<endouttext />
</foil>

    </foilgroup>

</optionresponse>
<allow src="/res/msu/kortemey/physicslib/capacitors/four/*" />
</problem>

Quoting Sally Hunnicutt <sshunnic@vcu.edu>:

> The graphs are dynamically generated within CAPA.
>
> Sally
>
> At 03:49 PM 2/11/05 -0500, Gerd Kortemeyer wrote:
> >Hi Sally,
> >
> >Quoting Sally Hunnicutt <sshunnic@vcu.edu>:
> >
> > > OK, here is what I am trying to do.  I have four graphs (gnuplots), one
> for
> > > A, one for B, etc.
> >
> >Are these static graphs (boiled down to gifs, jpgs), or dynamically
> generated
> >within LON-CAPA?
> >
> >- Gerd.
> >
> >
> >----------------------------------------------------------------
> >This message was sent using IMP, the Internet Messaging Program.
>
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>


-- 
Gerd Kortemeyer, Ph.D.
E-192 Holmes Hall
Michigan State University
East Lansing, MI 48825
http://www.lite.msu.edu/kortemeyer/

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.