Multiple choice quiz im shell not working

Hi, I have to create a quiz im form of bash-shell-script.
The problem is: I don't find a way to bring multiple choice questions to work. As long as someone selects only one of the possible answers everything is fine, but if one selects two or more options it doesn't work.
The code I used is below, can someone help me?
P.S.: Frage means question, loesung means solution.

#!/bin/bash
FRAGE7=`echo "$QUERY_STRING" | sed -n 's/^.frage7=\([^&]\).*$/\1/p' | sed "s/%20/ /g"`

if [ "$FRAGE5" == "male" ]; then
        LOESUNG="wrong!"
elif [ "$FRAGE5" == "female" ]; then
        LOESUNG="right!"
elif [ "$FRAGE5" == "other" ]; then
        LOESUNG="wrong!"
elif [ "$FRAGE5" == "fortlaufend" ]; then
        LOESUNG="wrong!"
elif [ "$FRAGE5" == "fotos" ]; then
        LOESUNG="right!"
elif [ "$FRAGE5" == "landkarten" ]; then
        LOESUNG="wrong!"
elif [ "$FRAGE5" == "musikalien" ]; then
        LOESUNG="wrong!"
fi

echo "Content-type: text/html"
echo ""
echo "<html><head><title>L�sung</title><meta charset="UTF-8"></head>"
echo "<body>"
echo "<h3>Frage 7</h3>"
echo "<p>Your answer is <b>$LOESUNG</b></p>"
echo "</body></html>"

Welcome to the forum.

Is that quiz homework / classwork? Then pls. reopen the request in the Homework & Coursework Questions - UNIX and Linux Forums forum. You may want to add some more details like sample input data, and some evaluation logics for e.g. multiple answers, and their formatting. And, consider using the case ... esac for the flow control in lieu of that many if ... elif ... fi commands.

First, you are using the varable FRAGE7 in the first line of your code and FRAGE5 in the if construct.

Second, why all the if-then-elif statements?

case "$FRAGE7" in
   female|fotos) LOESUNG="right!" ;;
   *) LOESUNG="wrong!" ;;
esac

or

case "$FRAGE7" in
   female) LOESUNG="right!" ;;
   fotos) LOESUNG="right!" ;;
   *) LOESUNG="wrong!" ;;
esac

Third, you don't need that ugly echo ... | sed construct which by the look of it will return one character which is not an ampersand (&).

FRAGE7=${FRAGE7#frage7=}

will get rid of the prefix and

FRAGE7=${FRAGE7//%20/ }

should convert the %20 to spaces.

Andrew

Hi RudiC, thank you for the suggestion. Yes, it's something like a classwork. Should I delete the post in here when I reopen it in the the other part of the forum? Sadly I don't have those information about the evaluation logics, we had to learn the code alone without any basis and without details about the evaluation mode. I'll try the case...esac , thank you very much.

I've closed it for you. When reopening as homework, pls. fill in the entire form, and add as much info as possible, like data, data formats (like "how do you present multiple choice answers"), YOUR thoughts on what should happen. That helps us help you.