Results 1 to 2 of 2

Thread: a phasetest script

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default a phasetest script

    hi allPls i am new to linux shell scripting and i need to create a phasetest script that displays a set of multiple choice questions similar to an online exam

  2. #2
    Junior Member
    Join Date
    Nov 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Lightbulb a phasetest script

    Quote Originally Posted by iykeromison View Post
    hi allPls i am new to linux shell scripting and i need to create a phasetest script that displays a set of multiple choice questions similar to an online exam
    Hi iykeromison!
    If I understand well...You can use "SELECT". This "word" allows you to generate a menu. The sintax is the following:
    SELECT [var] IN
    [list]
    do
    statements
    done
    If you want to do something after that with the correct answer you must use the variable REPLY.
    I give you an example:
    Code:
    PS3='ANSWER?'
    print 'Select your answer:'
    
    select var1 in \
       'Choice a'\
       'Choice b'\
       'Choice c'\
       'Choice d'
    do
       case $REPLY in
          1) echo "CHOICE: $var1"
            break
            ;;
          *) echo "WRONG"
            break
            ;;
       esac
    done
    The result would be like that:
    Select your answer:
    1) Choice a
    2) Choice b
    3) Choice c
    4) Choice d
    ANSWER?1
    CHOICE: Choice a

    I hope it helps you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •