#!/bin/bash # "makequiz": shell script to generate a multiple choice quiz in # Javascript for use on the Web. # We need as input a quiz description file, the name of # which is supplied to "makequiz" as a parameter. See the # sample file "myquiz.txt". We also need Bash 2.0 or higher # (use of arrays). if ! echo $BASH_VERSION | grep 2 >/dev/null ; then echo "Sorry, this script requires bash version 2.0 or higher." echo "You are using $BASH_VERSION." exit 1 fi if [ "$#" = "0" ] ; then echo "Please supply the name of a quiz description file." exit 1 fi if [ ! -r "$1" ] ; then echo "Sorry, could not read \"$1\"." exit 1 else . $1 fi echo "" echo "$TITLE" echo "" echo "" echo "" echo -n "
" else echo "action='mailto:$RECIPIENT' enctype=\"text/plain\">" fi if [ ! "$LOGO_URL" = "" ] ; then echo "\"quiz" fi echo "

$TITLE

" echo "First Name: " echo "Last Name:

" echo "Select the correct answer by clicking on its button.
" echo "You can change your answer by clicking another answer.
" echo "There are $N questions in all.



" i=1 until [ $i -gt $N ] ; do echo "(${i}) " if [ ! "${FIG[$i]}" = "" ] ; then echo "

" fi echo "${Q[$i]}

" echo "  ${A[$i]}
" echo "  ${B[$i]}
" echo "  ${C[$i]}
" echo "  ${D[$i]}
" if [ ! "${E[$i]}" = "" ] ; then echo "  ${E[$i]}
" fi echo "
" i=$(($i+1)) done echo "" echo "" echo "
" echo "" echo ""