Jump to content
Sign in to follow this  
Tinnu

simple Quiz

Recommended Posts

Tinnu

Hello

i am beginner of AutoIt, i need help to write a script.

i am going to explain my idea and plan.

i need a simple program with very simple GUI. it's a Quiz program where 100 questions are asked and at the end result with percentage and rank by marks.

Questions 'll be like this (with 4 options)

1. Who is the Chairman of Microsoft?

A. Bill Gates

B. Jonathan Bennett

C. Paul Allen

D. Steve Ballmer

if the Program user gives the correct answer which is A then he 'll get a blinking message on the same GUI for 3 seconds and then he is proceeded to next Question. and it's all same until 100 questions are finished.

at the end user 'll get % of his correct answer with a title which is given to him by his total marks.

for example these are 4 titles.

1. Good (on 1-25%)

2. Better (on 26-50%)

3. Best (on 51-75%)

4. Excellent, Marvelous - You Won! (on 76-100%)

So, what i have to do for this?


Share this post


Link to post
Share on other sites
bogQ

To start learning and testing from help file (every command have exemple on end of the page), to read some FAQ or search the forum to se if someone had similar problem, and post small part of working code when you need help with some funcs or logic that you cant solve with FAQ or forum search. :idea:

Welcome to AutoIt 1-2-3 Class... is now in Session


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites
Tinnu

i don't have time to Learn the whole language, i just need guideline to make this script.

i 'll learn the full scripting but currently i just want my work to be done.

i am not saying to do it for me, just let me know how my project can be done.

maybe some little code which is used for this to understand?


Share this post


Link to post
Share on other sites
Malkey

Here is one method of doing this to get you started.

This is a text file that contains the questions and answers. Call it :-

QQues.txt

1. Who is the Chairman of Microsoft?
A. Bill Gates
B. Jonathan Bennett
C. Paul Allen
D. Steve Ballmer

A. Bill Gates

2. Who is the Chairman of Microsoft?
A. Bill Gates
B. Jonathan Bennett
C. Paul Allen
D. Steve Ballmer

A. Bill Gates

3. Who is the Chairman of Microsoft?
A. Bill Gates
B. Jonathan Bennett
C. Paul Allen
D. Steve Ballmer

A. Bill Gates

4. Who is the Chairman of Microsoft?
A. Paul Allen
B. Jonathan Bennett
C. Bill Gates
D. Steve Ballmer

C. Bill Gates

and here is the script to be placed in the same directory as the QQues.txt data file.

#include <GUIConstantsEx.au3>
#include <Array.au3>

Opt('MustDeclareVars', 1)

Quiz()

Func Quiz()
    Local $GUI, $msg, $Lab, $LabAns, $Input, $But, $iQResult = 0, $QPercnt, $sTitles
    Local $aArrQues = StringSplit(StringStripWS(FileRead("QQues.txt"), 3), @CRLF & @CRLF, 1)
    ;_ArrayDisplay($aArrQues)
    $GUI = GUICreate("Quiz Window", 450, 450) ; will create a dialog box that when displayed is centered
    GUISetFont(12, 800)
    GUISetBkColor(0xFFFFE0)
    $Lab = GUICtrlCreateLabel("", 10, 30, 430, 350)
    $LabAns = GUICtrlCreateLabel("", 10, 375, 430, 40)
    $Input = GUICtrlCreateInput("", 10, 420, 20, 20)
    $But = GUICtrlCreateButton("Send Answer", 50, 420, 120, 20)
    GUISetState()

    For $i = 1 To $aArrQues[0] Step 2
        GUICtrlSetData($Lab, $aArrQues[$i])
        GUICtrlSetData($LabAns, "")
        GUICtrlSetState($Input, $GUI_FOCUS)
        Do
            $msg = GUIGetMsg()
            If $msg = $But Then
                GUICtrlSetData($LabAns, "Correct answer is:- " & @CRLF & $aArrQues[$i + 1])
                If StringLeft($aArrQues[$i + 1], 1) = GUICtrlRead($Input) Then
                    MsgBox(0, "Result", "Correct", 3, $GUI)
                    $iQResult += 1
                Else
                    MsgBox(0, "Result", "Incorrect", 3, $GUI)
                EndIf
                GUICtrlSetData($Input, "")
                ExitLoop
            EndIf
            If $msg = -3 Then Exit
        Until 0
    Next

    #cs
        1. Good (on 1-25%)
        2. Better (on 26-50%)
        3. Best (on 51-75%)
        4. Excellent, Marvelous - You Won! (on 76-100%)
    #ce

    $QPercnt = 100 * $iQResult / ($aArrQues[0] / 2)
    Switch $QPercnt
        Case 0 To 25
            $sTitles = "Good"
        Case 26 To 50
            $sTitles = "Better"
        Case 51 To 75
            $sTitles = "Best"
        Case 76 To 100
            $sTitles = "Excellent, Marvelous - You Won! "
    EndSwitch
    MsgBox(0, "Final Result of Quiz", $QPercnt & "% correct, " & $sTitles, 0, $GUI)

    Return
EndFunc ;==>Quiz

Share this post


Link to post
Share on other sites
Bert

Seeing how you need something fast, go here:

http://www.gejos.com/

Look for TranDumper. It is an app that runs in Internet explorer. It will do exactly as you ask, and building test is simply creating a txt file with the questions. I've used it for years for studying and designing my own test.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.