[LON-CAPA-users] Conditional Block Issue

Stuart Raeburn raeburn at msu.edu
Fri May 11 20:10:39 EDT 2018

Hello Gene,

Without looking in detail at your code, one thing jumped out at me  
when glancing at your code.

In the text included in your e-mail to the users list you have:

<block condition="status_a">

I don't know whether that's just a typo in your e-mail, but in your  
LON-CAPA code you'd want:

<block condition="$status_a">

Stuart Raeburn
LON-CAPA Academic Consortium

Quoting "Harding, Gene L" <glhardin at purdue.edu>:

> 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
> the following code in the perl script to check the problem status
> 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
> 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"
> <!-- 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
> $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

More information about the LON-CAPA-users mailing list