Template Keywords

Conditional - if

The /if/ keyword allows parts of a template script to be skipped or be done depending on what is in a field. For example, on a report there may be a box with a heading drawn with space for a teacher comment. But if the comment is optional you not want the box and heading to appear if there is no comment.

/if/,<field name>,<course index>,<condition>,<compare with>
...
/else/
...
/endif/

If the condition is satisfied the script before the /else/ is followed. The script after the /else/ line is then skipped and the next line of script done is after the /endif/ line.

If the condition is not satisfied the script before the /else/ is skipped and the script after the /else/ line is done and continues after the /endif/.

The field name must be a SM-Reports field name predefined for use on a report template. The field names are listed here and are not the names of the fields in the Set Report Definition command.

The course index value determines which course is used.

The condition and compare with text is optional and can be either:

Condition TypeAction
If there is no condition, the condition is satisfied is there is text in the field, or the field has a numeric value that is not equal to zero.
equalsThe condition is satisfied if the text in the field is equal to the compare with text. The text in the field does not need to be the same case as the compare with text.
startsThe condition is satisfied if the text in the field starts with to the compare with text. The text in the field does not need to be the same case as the compare with text.

 

Examples

This shows the comment and the box around it only if there is a comment for the student.

/if/,comment,1
/grid/,0,0,1800,300,1,1
/field/,comment,10,10,1750,300
/else/
/endif/

This shows a result for a student if they have one, but otherwise shows text about the student not being assessed.

/if/,level21,1
/text/,0,0,500,70,Exam result:
/field/,level21,500,0,600,70
/else/
/text/,0,0,1000,70,This student has not been assessed.
/endif/

This draws a grid with 5 boxes and shades one of the boxes depending on the grade. The grid line comes after the shading so the shaded box does not cover the edges of the grid.

/if/,grade,1,equals,A
/dingbat/,shade,0,0,150,70
/else/
/endif/
/if/,grade,1,equals,B
/dingbat/,shade,150,0,300,70
/else/
/endif/
/if/,grade,1,equals,C
/dingbat/,shade,300,0,450,70
/else/
/endif/
/if/,grade,1,equals,D
/dingbat/,shade,450,0,600,70
/else/
/endif/
/if/,grade,1,equals,E
/dingbat/,shade,600,0,750,70
/else/
/endif/
/grid/,0,0,750,70,5,1

 

Contents
Search