Nested Conditional Comparisons
Example
- Displaying a letter grade based on a quiz score.
MGI Tags
Steps
- Open the quiz grading page in a text editor.
- Insert an mgiConditional tag for each letter grade.
- Save the quiz grading page.
- FTP the quiz grading page to the web server running MGI.
- Take the quiz.
Step 1: Open the quiz grading page in a text editor.
- Open the quiz grading page in a text editing program that allows you
to view and modify the HTML of your page.
Step 2: Insert an mgiConditional tag for each letter grade.
- For each letter grade, enter an mgiConditional tag, id parameter, lhs
parameter, relationship parameter, rhs parameter, mgiElse tag and id parameter,
and ending mgiConditional tag. Enter each subsequent letter grade conditional
in the false body of the previous mgiConditional tag (between the mgiElse
tag and the ending mgiConditional tag).
-
- In the id parameter of the beginning mgiConditional tag and its associated
mgiElse tag, enter a unique ID number to associate the correct mgiElse
tag with the correct mgiConditional tag. In the lhs parameter of each conditional,
embed the mgiQuizGrade variable for the grade comparison. In the relationship
parameter, enter "greaterThanOrEqualTo". In the rhs parameter,
enter the lowest numeric grade that qualifies for each letter grade. In
the first body of the mgiConditional tag (between the beginning mgiConditional
tag and the mgiElse tag), enter the letter grade to display if the conditional
comparison is true. In the second body of the mgiConditional tag (between
the mgiElse tag and the ending mgiConditional tag), enter the next conditinoal
comparison or the final letter grade if all other comparisons have been
entered.
<mgiConditional id="1"lhs={mgiGet name="mgiQuizGrade"}
relationship="greaterThanOrEqualTo" rhs="90">
A
<mgiElse id="1">
<mgiConditional id="2"lhs={mgiGet name="mgiQuizGrade"}
relationship="greaterThanOrEqualTo" rhs="80">
B
<mgiElse id="2">
<mgiConditional id="3"lhs={mgiGet name="mgiQuizGrade"}
relationship="greaterThanOrEqualTo" rhs="70">
C
<mgiElse id="3">
<mgiConditional id="4"lhs={mgiGet name="mgiQuizGrade"}
relationship="greaterThanOrEqualTo" rhs="60">
D
<mgiElse id="4">
F
</mgiConditional>
</mgiConditional>
</mgiConditional>
</mgiConditional>
Step 3: Save the quiz grading page.
- Save the changes you have made to the quiz grading page.
Step 4: FTP the quiz grading page to the web server running MGI.
- Upload the quiz grading page from your local computer to the web server
using an FTP program.
Step 5: Take the quiz.
- Take and submit a quiz. If your grade was 90 or greater, then the letter
grade "A" displays. If your grade was 80 or greater, then the
letter grade "B" displays. If your grade was 70 or greater, then
the letter grade "C" displays. If your grade was 60 or greater,
then the letter grade "D" displays. Otherwise, the lettergrade
"F" displays.
|