[LON-CAPA-users] Conditional Block Issue

Harding, Gene L glhardin at purdue.edu
Fri May 11 20:00:16 EDT 2018


Hi,

I am trying to display something (a gnuplot) only if the student has exceeded the maxtries for a problem and not gotten it correct. I used the following code in the perl script to check the problem status and set a flag ($status_a) to zero only if maxtries is exceeded:
# Check status: 'undef'=not attempted; 0=wrong but tries left; 1=correct; 2=maxtries exceeded; 3=after answer date
$status_a = &check_status('a');
if ($status_a ne 2) {$status_a=0;}  # If maxtries not reached, set to 0 so conditional block does not execute

Then I put the gnuplot code inside a conditional block:
<block condition="status_a">
<gnuplot width="700" minor_ticscale="0.75" grid="off" align="right" font="9" height="500" border="on" samples="100"
         bgcolor="xffffff" fgcolor="x000000" alttag="Spectrum Plot" transparent="off" major_ticscale="2" plottype="Cartesian">
    <xtics minorfreq="1" location="border" mirror="on" end="$xtic_stop" increment="$xtic_incr" start="0" />
    <ytics minorfreq="1" location="border" mirror="on" end="20" increment="2" start="0" />
    <axis xmin="$x_min" ymax="$y_max" color="x000000" ymin="$y_min" xmax="$x_max" />
    <xlabel>Frequency (MHz)</xlabel>
    <ylabel>Amplitude (V)</ylabel>
    <curve linestyle="vector" linetype="solid" arrowangle="30" arrowstyle="filled" color="x000000" pointtype="4"
           linewidth="1" arrowhead="head" arrowlength="$arwhd" pointsize="1">
<!-- vector plot requires 4 datasets: X, Y, deltaX, deltaY -->
        <data>@f</data>
        <data>@tails</data>
        <data>@zeros</data>
        <data>@mag</data>
    </curve>
</gnuplot>
</block>

I thought conditional blocks were skipped if the condition was zero, and executed for nonzero values, but the block is executing even when $status_a is zero. Can anyone see what I am doing wrong? Is there a better/easier way to do this?

Thanks for any help/advice you can provide.

Best regards,

Gene L. Harding, PE
Associate Professor of ECET
574-520-4190

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20180512/b5123947/attachment.html>


More information about the LON-CAPA-users mailing list