[LON-CAPA-users] More elegant conditional text?

Ray Batchelor lon-capa-users@mail.lon-capa.org
Thu, 7 Feb 2008 16:46:15 -0800


No doubt those are more robust solutions that what I have sometimes used...
variants of things like

<script type="loncapa/perl">$a='$ \mathrm{KE}_1=(1/2)M_1v_1^2 $';
$b='$ \mathrm{E}_2=M_2c^2 $';
$c='$ \mathrm{P}_3=M_3v_3^2 $';

$choice=&random(0,2,1);

@array=($a,$b,$c);</script>
<startouttext /><p><m eval="on"> $array[$choice] </m></p><endouttext />


Possibly someone can tell me that this is not robust?

Cheers,
Ray

On 2/7/08, Todd Ruskell <truskell@mines.edu> wrote:
> Hello master problem coders,
>
> I'm wondering if there's a more elegant way to do something like the
> following:
>
> <startouttext />
> A bunch of text
> <block condition="$smallChoice == 1">
>  <m>$\mathrm{KE}_1=(1/2)Mv^2$</m>
> </block>
> <block condition="$smallChoice == 2">
> <m>$p=mv$</m>
> </block>
> More text.
> <endouttext />
>
> What I'd like to do is more like this:
>
> <startouttext />
> A bunch of text $array[$smallChoice] More text
> <endouttext />
>
> The difficulty for me is the math tags.  I haven't found the magic
> incantation to embed the math tags in perl variables such that it
> actually gets passed through the parser before being displayed.
>
> I also explored randomlist, but it appears as though that is pretty much
> limited to choosing between different <part> or <response> tags, rather
> than simple text.
>
> Can someone enlighten me?
>
> Thanks,
>
> Todd
> --
> Dr. Todd Ruskell
> Senior Lecturer, Department of Physics       Office:  Meyer Hall 326
> Colorado School of Mines                     Phone: 303-384-2080
> 1523 Illinois Street                         Fax: 303-273-3919
> Golden, CO 80401
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>


-- 
Raymond J. Batchelor
Dept of Chemistry
Simon Fraser University

http://www.sfu.ca/loncapa-info/