computerized Q bank

download computerized Q bank

of 68

Transcript of computerized Q bank

  • 8/14/2019 computerized Q bank

    1/68

    COMPUTERIZED QUESTION BANK

    PROJECT REPORT

  • 8/14/2019 computerized Q bank

    2/68

    INDEX

    SL_NO CONTENTS PAGE NO

    1. ABSTRACT 5

    2. SYSTEM

    DESCRIPTION 6

    3. VISUAL BASIC6.0

    FEATURES 9

    4. MS ACCESSFEATURES 10

    5. DATA FLOW

    DIAGRAM 11

    6. SYSTEM

    DATABASE 12

    7. SCREENLAYOUTS &

    REPORTS 13

    8. SYSTEM CODE 21

    9. CONCLUSION &

    SCOPE 67

    10. BIBLIOGRAPHY 68

  • 8/14/2019 computerized Q bank

    3/68

    INTRODUCTIONABSTRACT

    This project is to implement a friendly modern computerized

    system for maintaining the question bank and the students performance intheir respective subjects in Management Studies. The existing system in this

    college maintains manually by distributing the printed question bank to the

    students. It is upto the students to completely utilize it. And moreover, there

    is maintenance of students records regarding the question bank. This leads

    to the AUTOMATING QUESTION BANK using VISUAL BASIC 6.0 as

    the front end and MS ACCESS 7.0 as the back end tool.

    The system defines the creation of teachers account and students

    account by the teachers according to their subject needs. The systemprovides the performance of students in their respective subjects.

    TEACHERS ACCOUNT

    It includes creating userid and password for the faculties and

    creation of userid and password for the students by the faculty members.

    The faculty has the control of whether to allow a student to attend the test

    on their respective subject or not.

    QUESTION BANK

    The main form allows the faculty members to create files

    containing questions of objective type on their respective subjects. This

    form has provisions for creating test for a particular amount of period

    thus providing the students an experience of real-time quizzing.

    MODIFICATIONS

    Forms are provided to change the faculty passwords and students

    as well. Questions can also be edited and saved. Questions can also be

    appended to the existing question bank.

    REPORTS

    The performance of each student can be taken as printouts and the

    questions can even be printed.

  • 8/14/2019 computerized Q bank

    4/68

    PROPOSED SYSTEM

    The system defines the creation of teachers account and students

    account by the teachers according to their subject needs. The system

    provides the performance of students in their respective subjects.

    TEACHERS ACCOUNT

    It includes creating userid and password for the faculties and

    creation of userid and password for the students by the faculty members.

    The faculty has the control of whether to allow a student to attend the test

    on their respective subject or not.

    QUESTION BANK

    The main form allows the faculty members to create files

    containing questions of objective type on their respective subjects. This

    form has provisions for creating test for a particular amount of period

    thus providing the students an experience of real-time quizzing.

    MODIFICATIONS

    Forms are provided to change the faculty passwords and studentsas well. Questions can also be edited and saved. Questions can also be

    appended to the existing question bank.

    REPORTS

    The performance of each student can be taken as printouts and the

    questions can even be printed.

  • 8/14/2019 computerized Q bank

    5/68

    SYSTEM SPECIFICATION

    HARDWARE

    PROCESSOR : PENTIUM II

    CACHE MEMORY : 512KB

    MEMORY : 32KB

    HARD DISK CAPACITY : 2GB

    SOFTWARE

    FRONT-END : VISUAL BASIC 6.0

    BACK-END : MS ACCESS 7.0

    OPERATING SYSTEM : WINDOWS 9x

  • 8/14/2019 computerized Q bank

    6/68

    VISUAL BASIC 6.0

    &

    MS-ACCESS 7.0 FEATURES

  • 8/14/2019 computerized Q bank

    7/68

    SELECTION OF SOFTWARE

    INTRODUCTION TO VISUAL BASIC 6.0

    Microsoft Visual Basic is the fastest and easiest way to create

    applications for Microsoft Windows. Visual Basic provides you with a

    complete set of tools to simplify rapid applications development. The

    Visual part to the method used to create the Graphical User Interface

    (GUI). Rather than writing numerous lines of code to describe the

    appearance and location of interface elements, we simplify drag and drop

    rebuilt objects into place on screen.

    Beginners can create useful applications by learning just a few

    of keywords, yet the power of languages allows professionals to accomplish

    anything that can be accomplished using any other Windows Programming

    Languages.

    The Visual Basic programming languages is not unique to

    Visual Basic. The Visual Basic programming system, Applications Edition

    included in Microsoft Excel, Microsoft Access, and many other windows

    applications uses the same language. The Visual Basic programming system,

    Scripting uses the same language.

    The Visual Basic programming system, Scripting Edition (VB

    Script) for Internet programming is a subset of the Visual Basic language.

    Whether your goal is to create a small utility for yourself of your work

    group, a large enterprise-wide system, or even distributed applications

    spanning the globe via the Internet, Visual Basic has the tools we need.

    Data access features allows us to create databases and front-end

    applications for most popular database formats, including MS ACCESS.

    ActiveX technologies allow you to use the functions provided by otherapplication, such as Microsoft Excel Spreadsheet, other Windows

    applications.

    Internet capabilities make it easy to provide access to documents

    and applications across the Internet from within your applications. Our

  • 8/14/2019 computerized Q bank

    8/68

  • 8/14/2019 computerized Q bank

    9/68

    When we create an application in Visual Basic, we work with objects.

    We use objects provided by Visual basic such as controls, forms and data

    access objects. We can also control other applications objects from with in

    our Visual Basic application. We even create our own objects and define

    additional properties and methods for them.

    Beyond the fundamentals of writings code, Visual Basic provides a

    variety of language elements that enhance our code; three of these language

    elements are user-defined types, enumerated constants and collections.

    MICROSOFT ACCESS

    MS-Access provides two methods to create a database. We can create

    a blank database and then add the tables, forms, reports and other objects

    later this is the most flexible method, but it requires we to define eachdatabase elements separately or you can use a database wizard to create in

    one operation the required tables, forms and reports.

    Using MS-Access we can manage all our information from a single

    database file. With in the file divide our data in to separate storage

    containers called tables, view, add, update the table using online forms; find

    and retrieve just the data we want using queries; and analyze or print data in

    a specific layout.

  • 8/14/2019 computerized Q bank

    10/68

    DATA-FLOW DIAGRAM

  • 8/14/2019 computerized Q bank

    11/68

    SYSTEM DATABASE

    Database Name: Login.mdb

    Table Name: Login

    Field Name Data Type Size

    UserID Text 9

    LastName Text 20

    FirstName Text 20

    SSN Text 4

    Password Text 5Instructor Boolean 1

    Table Name: Test

    Field Name Data Type Size

    TestName Text 50

    Table Name: TestScores

    Field Name Data Type Size

    Test Text 50

    ID Text 9

    Date Date/Time 8

    Grade Single 4

  • 8/14/2019 computerized Q bank

    12/68

    Table Name: bank

    Field Name Data Type Size

    Question Text 250Type Text 1

    Opt1 Text 50

    Opt2 Text 50

    Opt3 Text 50

    Opt4 Text 50

    Answer text 50

    FORM LAYOUTS

  • 8/14/2019 computerized Q bank

    13/68

  • 8/14/2019 computerized Q bank

    14/68

  • 8/14/2019 computerized Q bank

    15/68

  • 8/14/2019 computerized Q bank

    16/68

  • 8/14/2019 computerized Q bank

    17/68

  • 8/14/2019 computerized Q bank

    18/68

  • 8/14/2019 computerized Q bank

    19/68

  • 8/14/2019 computerized Q bank

    20/68

    SYSTEM CODE

    Login form code

    Private Sub cmdExit_Click()

    EndEnd Sub

    Private Sub cmdLogin_Click()Dim found As Boolean

    Dim instructor As Boolean

    reset found flag to falsefound = False

    check for blank login fieldsIf txtPassword.Text = Or txtUserID.Text = Then

    MsgBox One of your login fields is blank, Pleae try again., , Attention!!!Exit Sub

    End If

    search userID to see if it exists

    datLogin.Recordset.MoveFirstuserCode = datLogin.Recordset.Fields(UserID).Value

    Do Until found Or datLogin.Recordset.EOF

    userCode = datLogin.Recordset.Fields(UserID).ValueIf Ucase(Rtrim(userCode)) = Ucase(txtUserID.Text) Then

    found = True

    Exit DoElse

    datLogin.Recordset.MoveNext

    End If

    Loop

    If found Then

    check password if foundpassword = datLogin.Recordset.Fields(Password).Value

    instructor = datLogin.Recordset.Fields(Instructor).Value

    If Ucase(password) = Ucase(txtPassword.Text) Then

    load appropiate form for student or instructorloggedUser = Ucase(userCode)

    If instructor Then

    Load frmInstructor

    Else

    Load frmStudentEnd If

  • 8/14/2019 computerized Q bank

    21/68

    Else

    MsgBox Check your Password!, , Warning!!!

    End IfElse

    MsgBox Hey,Hey,HeyTrying to sneak thru!Check your UserID!, ,

    Warning!!!End If

    End Sub

    Private Sub Form_Load()

    center form on screen

    frmLogin.Left = (Screen.Width Width) / 2

    frmLogin.Top = (Screen.Height Height) / 2set color for login screen

    r = 204

    g = 195

    b = 175BackColor = RGB(r, g, b)

    Label1.BackColor = RGB(r, g, b)cmdLogin.BackColor = RGB(r, g, b)

    cmdExit.BackColor = RGB(r, g, b)

    With datLogin.DatabaseName = App.Path & \login.mdb

    .RecordSource = Login

    .RefreshEnd With

    End Sub

    Private Sub Form_Unload(Cancel As Integer)

    close login database

    datLogin.Recordset.CloseEnd Sub

    Instructor form code

    Dim testHasChanged As Boolean

    Dim createCancel As Boolean

    Dim questNum As Integer

    Private Sub chkAllowGoBack_Click()

    'since check box has changed so has the test

    testHasChanged = True

    End Sub

  • 8/14/2019 computerized Q bank

    22/68

    Private Sub chkTimed_Click()

    'since check box has changed so has the test

    testHasChanged = True

    End Sub

    Private Sub cmdAddToBank_Click()

    'bring up the form to add a new question to question bank

    Load frmAddToBank

    End Sub

    Private Sub cmdAddToTest_Click()

    'check for more than 100 questions

    If questNum > 100 ThenMsgBox "You have already reached the maximum limit of 100. " & _

    "Remove an existing question if you want to add a new one." _

    , , "Warning!!!"

    Exit SubEnd If

    'check template for blank valuesIf (optMultiple.Value = False And optTrueFalse = False) Or _

    (opt1template.Value = False And opt2Template.Value = False _

    And opt3Template = False And opt4Template.Value = False) Or _(txtQuestTemplate.Text = "") Then

    MsgBox "One of your fields is blank!", , "Warning!!!"Exit Sub

    End If

    'check to see if a current test is already in use, if not'create a new one

    If currentTest = "" ThenCall createTest

    questNum = 0

    lblCurTest.Caption = "Current Test: " & currentTestEnd If

    testHasChanged = True

  • 8/14/2019 computerized Q bank

    23/68

    'add question to list box and question test array

    lisTestQuests.AddItem txtQuestTemplate

    With questTest(lisTestQuests.ListCount)

    .quest = txtQuestTemplate

    .answerA = txtOption1.answerB = txtOption2

    .answerC = txtOption3

    .answerD = txtOption4

    If optMultiple Then

    .theType = "M"

    Else.theType = "T"

    End If

    If opt1template Then.correctAns = "A"

    ElseIf opt2Template Then

    .correctAns = "B"

    Else

    If opt3Template Then.correctAns = "C"

    Else

    .correctAns = "D"End If

    End If

    End If

    End With

    End Sub

    Private Sub SaveTest()

    Dim recordNum As Integer

    'make sure all files are closedClose

    'double check to see if there is at least 1 question

    If lisTestQuests.ListCount > 0 Then'select file for output

    Open currentTest For Output As #1

    'write array to file

    For recordNum = 1 To lisTestQuests.ListCount

  • 8/14/2019 computerized Q bank

    24/68

    Write #1, questTest(recordNum).quest

    Write #1, questTest(recordNum).answerA

    Write #1, questTest(recordNum).answerBWrite #1, questTest(recordNum).answerC

    Write #1, questTest(recordNum).answerD

    Write #1, questTest(recordNum).correctAnsWrite #1, questTest(recordNum).theType

    Next recordNum

    Close #1

    'open file for test layout

    Open Left(currentTest, Len(currentTest) - 3) & "lyt" For Output As #1

    'write the layout optionsIf chkTimed Then

    Write #1, "T"

    Else

    Write #1, "F"End If

    If chkTimed And Val(txtMinutes) < 1 ThenWrite #1, 1

    Else

    Write #1, Val(txtMinutes)

    End IfIf chkAllowGoBack Then

    Write #1, "T"

    ElseWrite #1, "F"

    End If

    If optGrey.Value = True ThenWrite #1, "G"

    Else

    If optRed.Value = True ThenWrite #1, "R"

    Else

    If optBlue.Value = True Then

    Write #1, "B"Else

    Write #1, "GN"

    End IfEnd If

    End If

    Close #1

    'reset test has changed to false

    testHasChanged = False

    End If

  • 8/14/2019 computerized Q bank

    25/68

    End Sub

    Private Sub createTest()

    Dim foundTest As Boolean

    Dim i As IntegerDim userResponse As Integer

    On Error GoTo dlgError

    'if test had changed then ask to save current test before

    'creating a new one

    If testHasChanged ThenuserResponse = MsgBox("The current test has changed since you last saved it. " & _

    "Do you want to save it before you create a new one?", _

    vbYesNoCancel, "Warning!!!")

    If userResponse = vbYes ThenCall SaveTest

    ElseIf userResponse = vbCancel Then

    Exit Sub

    End If

    End IfEnd If

    'get name for new testWith dlgFile

    .CancelError = True

    .FileName = ""

    .DialogTitle = "Choose A Name For The Test"

    .Flags = 2

    .Filter = "Test Files| *.tst"

    .ShowSave

    If Dir(.FileName) "" Then

    Kill .FileNameEnd If

    currentTest = .FileNamelblCurTest.Caption = "Current Test: " & currentTest

    mnuSave.Enabled = True

    mnuSaveAs.Enabled = TruecmdReviewQuestion.Enabled = True

    cmdRemoveTestQuest.Enabled = True

    cmdUp.Enabled = True

    cmdDown.Enabled = True

  • 8/14/2019 computerized Q bank

    26/68

    cmdSaveTest.Enabled = True

    testHasChanged = False

    End With

    'add test name to test table in login database

    foundTest = False

    datLogin.RecordSource = "Test"datLogin.Refresh

    With datLogin.Recordset

    .MoveFirst

    Do Until .EOF Or foundTestIf currentTest = RTrim(.Fields("TestName").Value) Then

    foundTest = True

    End If

    .MoveNextLoop

    If Not foundTest Then.AddNew

    .Fields("TestName").Value = currentTest

    .Update

    End IfEnd With

    'clear the list box and question test arraylisTestQuests.Clear

    For i = 1 To 100

    questTest(i).answerA = ""questTest(i).answerB = ""

    questTest(i).answerC = ""

    questTest(i).answerD = ""questTest(i).correctAns = ""

    questTest(i).quest = ""

    questTest(i).theType = ""

    Next i

    'set defaults for new test

    chkTimed.Value = FalsetxtMinutes.Text = ""

    chkAllowGoBack.Value = False

    optGrey = True

    dlgError:

    On Error GoTo 0

  • 8/14/2019 computerized Q bank

    27/68

    Exit Sub

    End Sub

    Private Sub cmdClearTemplate_Click()

    'clear all controls in template

    optMultiple.Value = False

    optTrueFalse.Value = Falseopt1template.Value = False

    opt2Template.Value = False

    opt3Template.Value = False

    opt4Template.Value = FalsetxtQuestTemplate.Text = ""

    txtOption1.Text = ""

    txtOption2.Text = ""

    txtOption3.Text = ""txtOption4.Text = ""

    End Sub

    Private Sub cmdDown_Click()

    Dim questTemp As questionSet

    Dim i As Integer

    Dim listEntries As IntegerDim curListSpot As Integer

    'make sure question is selectedIf lisTestQuests.Text = "" Then

    MsgBox "Click on a question first!", , "Attention!!!"

    Else'make sure selection is not already in the lowest position

    If lisTestQuests.ListIndex = lisTestQuests.ListCount - 1 Then

    Exit Sub

    End If

    'testhaschanged needs to be set to true

    testHasChanged = True

    'switch question in array with the one below it

    questTemp = questTest(lisTestQuests.ListIndex + 1)questTest(lisTestQuests.ListIndex + 1) = questTest(lisTestQuests.ListIndex + 2)

    questTest(lisTestQuests.ListIndex + 2) = questTemp

    'clear listbox and reload it

  • 8/14/2019 computerized Q bank

    28/68

    listEntries = lisTestQuests.ListCount

    curListSpot = lisTestQuests.ListIndex

    lisTestQuests.ClearFor i = 1 To listEntries

    lisTestQuests.AddItem questTest(i).quest

    Next i'select the question that was moved

    lisTestQuests.ListIndex = curListSpot + 1

    End If

    End Sub

    Private Sub cmdEditBank_Click()

    Dim i As Integer

    'make sure question is selectedIf lisTestBank.Text "" Then

    With datBank.Recordset.MoveFirst

    'move to current question in database

    If lisTestBank.ListIndex > 0 Then

    For i = 1 To lisTestBank.ListIndex.MoveNext

    Next i

    End If'load question to be edited into edit form

    frmEdit.txtQuestion = RTrim(.Fields("question").Value)

    If .Fields("type").Value = "M" ThenfrmEdit.optMultiple = True

    Else

    frmEdit.optTrueFalse = TrueEnd If

    frmEdit.txtOptA.Text = RTrim(.Fields("opt1"))

    frmEdit.txtOptB.Text = RTrim(.Fields("opt2"))

    frmEdit.txtOptC.Text = RTrim(.Fields("opt3"))frmEdit.txtOptD.Text = RTrim(.Fields("opt4"))

    If RTrim(.Fields("answer").Value) = "A" Then

    frmEdit.optA = TrueElse

    If RTrim(.Fields("answer")) = "B" Then

    frmEdit.optB = TrueElse

    If RTrim(.Fields("answer")) = "C" Then

    frmEdit.optC = True

    Else

  • 8/14/2019 computerized Q bank

    29/68

    frmEdit.optD = True

    End If

    End IfEnd If

    End With

    Load frmEdit

    Else

    MsgBox "Select a question to edit!", , "Warning!!!"

    End If

    End Sub

    Private Sub cmdMoveQuestion_Click()

    'check to see if a question from bank is clicked on, if so'move question, question type, options, and correct anwser

    'to template

    If lisTestBank.Text = "" ThenMsgBox "Click on a question first!", , "Attention!!!"

    Else

    With questHold(lisTestBank.ListIndex + 1)txtQuestTemplate.Text = .quest

    txtOption1.Text = .answerA

    txtOption2.Text = .answerBtxtOption3.Text = .answerC

    txtOption4.Text = .answerD

    If .correctAns = "A" Thenopt1template.Value = True

    opt2Template.Value = False

    opt3Template.Value = False

    opt4Template.Value = FalseElse

    If .correctAns = "B" Then

    opt2Template.Value = Trueopt1template.Value = False

    opt3Template.Value = False

    opt4Template.Value = FalseElse

    If .correctAns = "C" Then

    opt3Template.Value = True

    opt1template.Value = False

  • 8/14/2019 computerized Q bank

    30/68

  • 8/14/2019 computerized Q bank

    31/68

    End If

    End Sub

    Private Sub cmdRemoveTestQuest_Click()

    Dim i As Integer

    'make sure quesition is selectedIf lisTestQuests.Text = "" Then

    MsgBox "Click on a question first!", , "Attention!!!"

    Else

    'delete current question from arraytestHasChanged = True

    For i = lisTestQuests.ListIndex + 1 To lisTestQuests.ListCount - 1

    questTest(i) = questTest(i + 1)

    Next i'remove question from listbox

    lisTestQuests.RemoveItem lisTestQuests.ListIndexEnd If

    End Sub

    Private Sub cmdReviewQuestion_Click()

    'make sure a question is selectedIf lisTestQuests.Text = "" Then

    MsgBox "Click on a question first!", , "Attention!!!"

    Else'load question into template section

    With questTest(lisTestQuests.ListIndex + 1)

    txtQuestTemplate.Text = .questtxtOption1.Text = .answerA

    txtOption2.Text = .answerB

    txtOption3.Text = .answerC

    txtOption4.Text = .answerDIf .correctAns = "A" Then

    opt1template.Value = True

    opt2Template.Value = Falseopt3Template.Value = False

    opt4Template.Value = False

    ElseIf .correctAns = "B" Then

    opt2Template.Value = True

    opt1template.Value = False

    opt3Template.Value = False

  • 8/14/2019 computerized Q bank

    32/68

    opt4Template.Value = False

    Else

    If .correctAns = "C" Thenopt3Template.Value = True

    opt1template.Value = False

    opt2Template.Value = Falseopt4Template.Value = False

    Else

    opt4Template.Value = Trueopt1template.Value = False

    opt2Template.Value = False

    opt3Template.Value = False

    End IfEnd If

    End If

    If .theType = "M" Then

    optMultiple.Value = TrueElse

    optTrueFalse.Value = TruetxtOption3.Text = ""

    txtOption4.Text = ""

    opt3Template.Value = False

    opt4Template.Value = FalseEnd If

    End With

    End If

    End Sub

    Private Sub cmdSaveTest_Click()

    'make sure test has changed and there is at least 1 question

    If testHasChanged And lisTestQuests.ListCount > 0 Then

    Call SaveTest

    End If

    End Sub

    Private Sub cmdUp_Click()

    Dim questTemp As questionSetDim i As Integer

    Dim listEntries As Integer

    Dim curListSpot As Integer

  • 8/14/2019 computerized Q bank

    33/68

    'make sure a question has been selected

    If lisTestQuests.Text = "" Then

    MsgBox "Click on a question first!", , "Attention!!!"Else

    'don't perform sub if the selected question is already

    'at the top positionIf lisTestQuests.ListIndex = 0 Then

    Exit Sub

    End If

    'set testHasChanged to true since it has changed

    testHasChanged = True

    'switch question position in arrray with the 1 above it

    questTemp = questTest(lisTestQuests.ListIndex)

    questTest(lisTestQuests.ListIndex) = questTest(lisTestQuests.ListIndex + 1)

    questTest(lisTestQuests.ListIndex + 1) = questTemp

    'clear and reload list boxlistEntries = lisTestQuests.ListCount

    curListSpot = lisTestQuests.ListIndex

    lisTestQuests.Clear

    For i = 1 To listEntrieslisTestQuests.AddItem questTest(i).quest

    Next i

    'highlight the moved questionlisTestQuests.ListIndex = curListSpot - 1

    End If

    End Sub

    Private Sub Form_Load()

    'make form visible and unload login form

    Show

    Unload frmLogin

    With datLogin

    .DatabaseName = App.Path & "\login.mdb"

    .RecordSource = "Login"

    .Refresh

    End With

    'set caption of form to include user ID

    Caption = Caption & " - User ID : " & userCode

  • 8/14/2019 computerized Q bank

    34/68

    'if logged in with default system password disable menu

    'option to edit password

    If UCase(userCode) = "SYSTEM999" ThenmnuEditPassword.Enabled = False

    End If

    mnuSave.Enabled = False

    mnuSaveAs.Enabled = False

    'disable Add to bank, remove from bank, and edit from bank

    'command buttons

    cmdAddToBank.Enabled = False

    cmdRemoveFromBank.Enabled = FalsecmdEditBank.Enabled = False

    'reset newDb to false

    newDB = False

    'reset test has changed to falsetestHasChanged = False

    End Sub

    Private Sub lisTestBank_Click()

    'load question from bank list to large question displaytxtQuestDisp.Text = lisTestBank.Text

    'set the label to display correct question typeSelect Case questHold(lisTestBank.ListIndex + 1).theType

    Case "M"

    lblQuestType.Caption = "Question Type: " & "Multiple Choice"Case "T"

    lblQuestType.Caption = "Question Type: " & "True/False"

    End Select

    End Sub

    Private Sub mnuCreate_Click()

    Call createTest

    End Sub

  • 8/14/2019 computerized Q bank

    35/68

    Private Sub mnuCreateStudent_Click()

    'load form and set caption to studentLoad frmAccount

    frmAccount.Caption = "Student"

    End Sub

    Private Sub mnuCreateTeacher_Click()

    'load form and set caption to teacher

    Load frmAccount

    frmAccount.Caption = "Teacher"

    End Sub

    Private Sub mnuEditPassword_Click()

    'edit currently logged on user's passwordLoad frmTeachPass

    'search for user in database and display current(old) password

    With frmInstructor.datLogin.Recordset

    .MoveFirstDo Until .EOF

    If loggedUser = .Fields("UserID").Value Then

    frmTeachPass.picOutput.ClsfrmTeachPass.picOutput.Print "Old Password: "; .Fields("Password").Value

    Exit Do

    End If.MoveNext

    Loop

    End With

    End Sub

    Private Sub mnuEditStudent_Click()

    Load frmStudPass

    End Sub

    Private Sub mnuExit_Click()

    Dim response As Integer

    'before exiting check to see if test has changed and give

  • 8/14/2019 computerized Q bank

    36/68

    'user option to save or not or cancel exit

    If testHasChanged Then

    response = MsgBox("Test has changed, do you want to save before exitingprogram?", vbYesNoCancel _

    , "Warning!!!")

    If response = vbYes ThenCall SaveTest

    Else

    If response = vbCancel ThenExit Sub

    End If

    End If

    End If

    'stop application

    End

    End Sub

    Private Sub mnuOpen_Click()

    Dim i As IntegerDim userResponse As Integer

    Dim timed As String

    Dim minutes As IntegerDim goBack As String

    Dim theColor As String

    On Error GoTo dlgError

    'if test has changed check to see if user wants to save current'test before opening new one

    If testHasChanged Then

    userResponse = MsgBox("The current test has changed since you last saved it. " & _

    "Do you want to save it before you open another one?", _vbYesNoCancel, "Warning!!!")

    If userResponse = vbYes Then

    Call SaveTestElse

    If userResponse = vbCancel Then

    Exit SubEnd If

    End If

    End If

  • 8/14/2019 computerized Q bank

    37/68

    'select filename to open

    With dlgFile

    .CancelError = True

    .DialogTitle = "Choose Test To Open"

    .Filter = "Test Files|*.tst"

    .Flags = 2.ShowOpen

    Open .FileName For Input As #1currentTest = .FileName

    lblCurTest.Caption = "Current Test: " & currentTest

    mnuSave.Enabled = True

    mnuSaveAs.Enabled = TruecmdReviewQuestion.Enabled = True

    cmdRemoveTestQuest.Enabled = True

    cmdUp.Enabled = True

    cmdDown.Enabled = TruecmdSaveTest.Enabled = True

    lisTestQuests.Clear

    'load test question array from test file

    Do Until EOF(1)i = i + 1

    Input #1, questTest(i).quest

    Input #1, questTest(i).answerAInput #1, questTest(i).answerB

    Input #1, questTest(i).answerC

    Input #1, questTest(i).answerDInput #1, questTest(i).correctAns

    Input #1, questTest(i).theType

    lisTestQuests.AddItem questTest(i).questLoop

    Close #1

    'load test optionsOpen Left(.FileName, Len(.FileName) - 3) & "lyt" For Input As #1

    Input #1, timed

    Input #1, minutesInput #1, goBack

    Input #1, theColor

    Close

    If timed = "T" Then

    chkTimed.Value = 1

    txtMinutes = minutes

  • 8/14/2019 computerized Q bank

    38/68

    Else

    chkTimed.Value = 0

    txtMinutes = ""End If

    If goBack = "T" Then

    chkAllowGoBack.Value = 1Else

    chkAllowGoBack.Value = 0

    End IfIf theColor = "G" Then

    optGrey.Value = True

    Else

    If theColor = "R" ThenoptRed.Value = True

    Else

    If theColor = "B" Then

    optBlue.Value = TrueElse

    optGreen.Value = TrueEnd If

    End If

    End If

    End With

    'reset test has changed to falsetestHasChanged = False

    dlgError:On Error GoTo 0

    Exit Sub

    End Sub

    Private Sub mnuOpenBank_Click()

    Dim i As Integer

    Dim x As Integer

    On Error GoTo DialogError

    'open the open dialogWith dlgFile

    .CancelError = True

    .DialogTitle = "Choose The Name Of The Test Bank"

    .Flags = 2

  • 8/14/2019 computerized Q bank

    39/68

    .Filter = "Database Files|*.mdb"

    .ShowOpen

    'set database,label, and currentBank with file name

    datBank.DatabaseName = .FileName

    lblTestBank.Caption = "Test Bank: '" & .FileName & "'"currentBank = .FileName

    End With

    'enable add to bank, romove from bank, and edit bank

    'command buttons

    cmdAddToBank.Enabled = True

    cmdRemoveFromBank.Enabled = TruecmdEditBank.Enabled = True

    'clear big question display and test bank list box

    txtQuestDisp.Text = ""lisTestBank.Clear

    'open database

    datBank.RecordSource = "bank"

    datBank.Refresh

    datBank.Recordset.MoveFirst

    'clear questHold array with null

    For x = 1 To 200questHold(x).answerA = ""

    questHold(x).answerB = ""

    questHold(x).answerC = ""questHold(x).answerD = ""

    questHold(x).correctAns = ""

    questHold(x).quest = ""questHold(x).theType = ""

    Next x

    'load questHold array with test bank database dataDo Until datBank.Recordset.EOF

    i = i + 1

    With questHold(i).quest = datBank.Recordset.Fields("question").Value

    .theType = datBank.Recordset.Fields("type").Value

    .answerA = datBank.Recordset.Fields("opt1").Value

    .answerB = datBank.Recordset.Fields("opt2").Value

    .answerC = datBank.Recordset.Fields("opt3").Value

    .answerD = datBank.Recordset.Fields("opt4").Value

    .correctAns = datBank.Recordset.Fields("answer").Value

  • 8/14/2019 computerized Q bank

    40/68

    lisTestBank.AddItem (.quest)

    End With

    datBank.Recordset.MoveNextLoop

    If i = 1 And RTrim(datBank.Recordset.Fields("question").Value) = "dummy" ThennewDB = True

    End If

    'set question type label

    lblQuestType.Caption = "Question Type:"

    DialogError:On Error GoTo 0

    Exit Sub

    End Sub

    Private Sub mnuPrint_Click()

    Dim i As Integer

    Dim linecount As Integer

    'print the current test with font size 12

    Printer.FontSize = 12

    For i = 1 To 5Printer.Print

    Next i

    Printer.Print Space(80 - (Len(currentTest) / 2)); currentTestPrinter.Print

    'print questionsFor i = 1 To lisTestQuests.ListCount

    Printer.FontSize = 10

    Printer.Print i & "." & questTest(i).quest

    Printer.Printlinecount = linecount + 2

    If questTest(i).theType = "T" Then

    Printer.Print "A. " & questTest(i).answerAPrinter.Print "B. " & questTest(i).answerB

    linecount = linecount + 3

    ElsePrinter.Print "A. " & questTest(i).answerA

    Printer.Print "B. " & questTest(i).answerB

    Printer.Print "C. " & questTest(i).answerC

    Printer.Print "D. " & questTest(i).answerD

  • 8/14/2019 computerized Q bank

    41/68

    linecount = linecount + 5

    End If

    Printer.PrintIf linecount > 55 Then

    Printer.NewPage

    Printer.FontSize = 12Printer.Print: Printer.Print: Printer.Print: Printer.Print

    Printer.Print: Printer.Print: Printer.Print

    Printer.FontSize = 10linecount = 0

    End If

    Next i

    'print test key

    Printer.NewPage

    Printer.Print: Printer.Print

    Printer.Print currentTest & " - Test Key"For i = 1 To lisTestQuests.ListCount

    Printer.PrintPrinter.Print i & ": " & questTest(i).correctAns

    Next i

    Printer.EndDoc

    End Sub

    Private Sub mnuPrintScores_Click()

    Load frmTestScores

    End Sub

    Private Sub mnuSave_Click()

    'make sure test has changed and that there is at least

    '1 question in the testIf testHasChanged And lisTestQuests.ListCount > 0 Then

    Call SaveTest

    End If

    End Sub

    Private Sub mnuSaveAs_Click()

    'make sure there are questions in the test

    If lisTestQuests.ListCount > 0 Then

  • 8/14/2019 computerized Q bank

    42/68

    'select filename to save as

    With dlgFile.CancelError = True

    .FileName = ""

    .DialogTitle = "Choose A Name For The Test".Flags = 2

    .Filter = "Test Files| *.tst"

    .ShowSave

    'if file did exist, delete it

    If Dir(.FileName) "" Then

    Kill .FileNameEnd If

    'set currentTest to the filename selected

    'enable save and saves menu selectionscurrentTest = .FileName

    mnuSave.Enabled = TruemnuSaveAs.Enabled = True

    End With

    'call sub to actually save the test

    Call SaveTest

    End If

    dlgError:

    On Error GoTo 0Exit Sub

    End Sub

    Private Sub optBlue_Click()

    'if this option is changed then test has changed

    testHasChanged = True

    End Sub

    Private Sub optGreen_Click()

    'if this option is changed then test has changed

    testHasChanged = True

  • 8/14/2019 computerized Q bank

    43/68

    End Sub

    Private Sub optGrey_Click()

    'if this option is changed then test has changedtestHasChanged = True

    End Sub

    Private Sub optMultiple_Click()

    'enable options 3 and 4 if option multiple choice is choosenopt3Template.Enabled = True

    opt4Template.Enabled = True

    End Sub

    Private Sub optRed_Click()

    'if this option is changed then test has changed

    testHasChanged = True

    End Sub

    Private Sub optTrueFalse_Click()

    'disable and clear options 3 and 4 if true/false choice is choosen

    txtOption1.Text = "True"txtOption2.Text = "False"

    txtOption3.Text = ""

    txtOption4.Text = ""opt3Template.Value = False

    opt4Template.Value = False

    opt3Template.Enabled = False

    opt4Template.Enabled = False

    End Sub

    Private Sub txtMinutes_Change()

    'if this option is changed then test has changedtestHasChanged = True

    End Sub

  • 8/14/2019 computerized Q bank

    44/68

    Student form code

    Dim currentQuest As IntegerDim questNum As Integer

    Dim goBack As Boolean

    Dim timed As BooleanDim minutes As Integer

    Private Sub cmdFinished_Click()

    'check for no answer given

    If opt1.Value = False And opt2.Value = False And opt3.Value = False _And opt4.Value = False Then

    MsgBox "You must select an answer!", , "Try Again!!!"

    Exit Sub

    End If

    'assign answer selected to users answer array for checkingIf opt1.Value = True Then

    usersAnswer(currentQuest) = "A"

    ElseIf opt2.Value = True Then

    usersAnswer(currentQuest) = "B"

    Else

    If opt3.Value = True ThenusersAnswer(currentQuest) = "C"

    ElseusersAnswer(currentQuest) = "D"End If

    End If

    End If

    testIsOver

    End Sub

    Private Sub cmdNextQuestion_Click()

    'check for no answer

    If opt1.Value = False And opt2.Value = False And opt3.Value = False _

    And opt4.Value = False ThenMsgBox "You must select an answer!", , "Try Again!!!"

    Exit Sub

    End If

  • 8/14/2019 computerized Q bank

    45/68

    'enable previous command button if go back is allowed

    If goBack Then

    cmdPrevious.Enabled = TrueEnd If

    'assigns answer to users answer arrayIf opt1.Value = True Then

    usersAnswer(currentQuest) = "A"

    ElseIf opt2.Value = True Then

    usersAnswer(currentQuest) = "B"

    Else

    If opt3.Value = True ThenusersAnswer(currentQuest) = "C"

    Else

    usersAnswer(currentQuest) = "D"

    End IfEnd If

    End If

    currentQuest = currentQuest + 1

    'if current question is last question then disable next buttonIf currentQuest = questNum Then

    cmdNextQuestion.Enabled = False

    cmdFinished.Enabled = TrueEnd If

    'load value (if any) from users answer array for next questionIf usersAnswer(currentQuest) = "A" Then

    opt1.Value = True

    ElseIf usersAnswer(currentQuest) = "B" Then

    opt2.Value = True

    Else

    If usersAnswer(currentQuest) = "C" Thenopt3.Value = True

    Else

    If usersAnswer(currentQuest) = "D" Thenopt4.Value = True

    Else

    opt1.Value = Falseopt2.Value = False

    opt3.Value = False

    opt4.Value = False

    End If

  • 8/14/2019 computerized Q bank

    46/68

    End If

    End If

    End If

    'load question onto screen for user viewing

    loadQuestion

    End Sub

    Private Sub cmdPrevious_Click()

    'make sure question is not number one when moving backIf currentQuest > 1 Then

    'assign current answer to users answer array

    If opt1.Value = True ThenusersAnswer(currentQuest) = "A"

    ElseIf opt2.Value = True Then

    usersAnswer(currentQuest) = "B"

    Else

    If opt3.Value = True ThenusersAnswer(currentQuest) = "C"

    Else

    If opt4.Value = True ThenusersAnswer(currentQuest) = "D"

    End If

    End IfEnd If

    End If

    'enable next button

    cmdNextQuestion.Enabled = True

    currentQuest = currentQuest - 1

    'if current question is number 1 disable previous button

    If currentQuest = 1 Then

    cmdPrevious.Enabled = FalseEnd If

    'load current answer(if any) from users answer array for the

    'question the user is moving back toIf usersAnswer(currentQuest) = "A" Then

    opt1.Value = True

    Else

    If usersAnswer(currentQuest) = "B" Then

  • 8/14/2019 computerized Q bank

    47/68

    opt2.Value = True

    Else

    If usersAnswer(currentQuest) = "C" Thenopt3.Value = True

    Else

    If usersAnswer(currentQuest) = "D" Thenopt4.Value = True

    Else

    opt1.Value = Falseopt2.Value = False

    opt3.Value = False

    opt4.Value = False

    End IfEnd If

    End If

    End If

    loadQuestionEnd If

    End Sub

    Private Sub Form_Load()

    Show

    Unload frmLogin

    Caption = "Computerized Question Bank - Student Screen - User - " & loggedUseropt1.Value = False

    cmdPrevious.Enabled = False

    cmdNextQuestion.Enabled = FalsecmdFinished.Enabled = False

    datLogin.DatabaseName = App.Path & "\login.mdb"datLogin.RecordSource = "Login"

    datLogin.Refresh

    datScores.DatabaseName = App.Path & "\login.mdb"datScores.RecordSource = "TestScores"

    datScores.Refresh

    End Sub

    Private Sub mnuChangePassword_Click()

    'edit currently logged on user's password

    Load frmTeachPass

  • 8/14/2019 computerized Q bank

    48/68

    frmTeachPass.Caption = "Change Student Password"

    'search for user in database and display current(old) password

    With datLogin.Recordset.MoveFirst

    Do Until .EOF

    If loggedUser = .Fields("UserID").Value ThenfrmTeachPass.picOutput.Cls

    frmTeachPass.picOutput.Print "Old Password: "; .Fields("Password").Value

    Exit DoEnd If

    .MoveNext

    Loop

    End With

    End Sub

    Private Sub mnuDisplayScores_Click()

    Load frmDisplayTestStudent

    End Sub

    Private Sub mnuExit_Click()

    End

    End Sub

    Private Sub mnuOpen_Click()

    Dim i As Integer

    Dim isTimed As StringDim allowBack As String

    Dim theColor As String

    Dim ColorSet As Long

    On Error GoTo dlgError

    With dlgFile.CancelError = True

    .Flags = 2

    .Filter = "Test Files| *.tst"

    .DialogTitle = "Choose Test To Take"

    .ShowOpen

    'clear test question array

  • 8/14/2019 computerized Q bank

    49/68

    For i = 1 To 100

    usersAnswer(i) = ""

    questTest(i).answerA = ""questTest(i).answerB = ""

    questTest(i).answerC = ""

    questTest(i).answerD = ""questTest(i).correctAns = ""

    questTest(i).quest = ""

    questTest(i).theType = ""Next i

    'set current test for the program to reference

    currentTest = .FileName'set the label to indicate current test

    lblTestName.Caption = currentTest

    questNum = 0'load test question array from test file

    Open currentTest For Input As #1Do Until EOF(1)

    questNum = questNum + 1

    Input #1, questTest(questNum).quest

    Input #1, questTest(questNum).answerAInput #1, questTest(questNum).answerB

    Input #1, questTest(questNum).answerC

    Input #1, questTest(questNum).answerDInput #1, questTest(questNum).correctAns

    Input #1, questTest(questNum).theType

    LoopClose #1

    'load layout for testOpen Left(currentTest, Len(currentTest) - 3) & "lyt" For Input As #1

    Input #1, isTimed

    Input #1, minutes

    Input #1, allowBackInput #1, theColor

    Close #1

    If isTimed = "T" Then

    timed = True

    Elsetimed = False

    End If

    If timed Then

  • 8/14/2019 computerized Q bank

    50/68

    lblMinute.Caption = minutes

    Else

    lblMinute.Caption = 0End If

    lblSeconds.Caption = "00"

    Timer1.Enabled = False

    If allowBack = "T" Then

    goBack = TrueElse

    goBack = False

    End If

    cmdPrevious.Enabled = False

    If theColor = "R" Then

    ColorSet = vbRedElse

    If theColor = "GN" ThenColorSet = vbGreen

    Else

    If theColor = "B" Then

    ColorSet = vbBlueElse

    ColorSet = -2147483633

    End IfEnd If

    End If

    frmStudent.BackColor = ColorSet

    Label2.BackColor = ColorSet

    lblQuestionNumber.BackColor = ColorSetlblTestName.BackColor = ColorSet

    lblQuestionType.BackColor = ColorSet

    frmAnswers.BackColor = ColorSet

    opt1.BackColor = ColorSetopt2.BackColor = ColorSet

    opt3.BackColor = ColorSet

    opt4.BackColor = ColorSetcmdPrevious.BackColor = ColorSet

    cmdNextQuestion.BackColor = ColorSet

    cmdFinished.BackColor = ColorSet

    mnuStart.Enabled = True

    End With

  • 8/14/2019 computerized Q bank

    51/68

    dlgError:

    On Error GoTo 0

    Exit Sub

    End Sub

    Private Sub mnuPrintScores_Click()

    'set printer propertiesPrinter.ScaleMode = 4

    Printer.FontSize = 12

    Printer.CurrentY = 5

    'print all test scores for currently logged user

    With datScores.Recordset

    .MoveFirst

    Do Until .EOFIf .Fields("ID").Value = loggedUser Then

    Printer.CurrentX = 5Printer.Print .Fields("Test").Value;

    Printer.CurrentX = 25

    Printer.Print .Fields("Date").Value;

    Printer.CurrentX = 45Printer.Print .Fields("Grade").Value

    End If

    .MoveNextLoop

    End With

    Printer.EndDoc

    End Sub

    Private Sub mnuStart_Click()

    Dim response As Integer

    'check for timed test, and give user option to start or not

    If timed Thenresponse = MsgBox("You have " & minutes & " minutes to finish this test. " & _

    "Once you have started you can't stop the test. " & _

    "Are you ready to start?", vbYesNo, "Timed Test")Else

    response = MsgBox("You have an unlimited amount of time to finish this " & _

    "test. Once you have started you can't stop the " & _

    "test. Are you ready to start?", vbYesNo, _

  • 8/14/2019 computerized Q bank

    52/68

    "Non-Timed Test")

    End If

    If response = vbNo Then

    Exit Sub

    ElseIf timed Then

    Timer1.Enabled = True

    End IfcmdNextQuestion.Enabled = True

    cmdFinished.Enabled = False

    currentQuest = 1

    mnuOpen.Enabled = FalsemnuStart.Enabled = False

    mnuExit.Enabled = False

    mnuChangePassword.Enabled = False

    mnuDisplayScores.Enabled = FalsemnuPrintScores.Enabled = False

    loadQuestion

    End If

    End Sub

    Private Sub loadQuestion()

    'set the label to display current question number

    lblQuestionNumber.Caption = currentQuest

    'load answers and question on to user screen

    opt1.Caption = questTest(currentQuest).answerA

    opt2.Caption = questTest(currentQuest).answerBopt3.Caption = questTest(currentQuest).answerC

    opt4.Caption = questTest(currentQuest).answerD

    txtQuestion.Text = questTest(currentQuest).quest

    'if there is only 1 question in test disable all buttons except

    'for finished.

    If questNum = 1 ThencmdNextQuestion.Enabled = False

    cmdFinished.Enabled = True

    cmdPrevious.Enabled = FalseEnd If

    'set the label to indicate the type of question

    If questTest(currentQuest).theType = "T" Then

  • 8/14/2019 computerized Q bank

    53/68

    opt3.Enabled = False

    opt4.Enabled = False

    lblQuestionType.Caption = "True/False"Else

    opt3.Enabled = True

    opt4.Enabled = TruelblQuestionType.Caption = "Multiple Choice"

    End If

    End Sub

    Private Sub Timer1_Timer()

    'stop test if no time is left

    If Val(lblMinute.Caption) = 0 And Val(lblSeconds.Caption) = 0 Then

    testIsOver

    Exit SubEnd If

    'decrement timer by 1 second every 1 second

    If Val(lblSeconds.Caption) = 0 Then

    lblSeconds.Caption = 59

    lblMinute.Caption = Val(lblMinute.Caption) - 1Else

    lblSeconds.Caption = Val(lblSeconds.Caption) - 1

    If Val(lblSeconds.Caption) < 10 ThenlblSeconds.Caption = "0" & lblSeconds.Caption

    End If

    End If

    End Sub

    Private Sub testIsOver()

    Dim i As Integer

    Dim score As IntegerDim numOfQuestions As Integer

    Dim numberCorrect As Integer

    'shut off timer, and display test over

    Timer1.Enabled = False

    MsgBox "Time is up!!", , "Test Over"'enable menu options

    mnuOpen.Enabled = True

    mnuExit.Enabled = True

    mnuChangePassword.Enabled = True

  • 8/14/2019 computerized Q bank

    54/68

    mnuDisplayScores.Enabled = True

    mnuPrintScores.Enabled = True

    'disable command buttonscmdPrevious.Enabled = False

    cmdNextQuestion.Enabled = False

    cmdFinished.Enabled = False

    'check answers

    numberCorrect = 0numOfQuestions = questNum

    For i = 1 To numOfQuestions

    If usersAnswer(i) = RTrim(questTest(i).correctAns) Then

    numberCorrect = numberCorrect + 1End If

    Next i

    score = numberCorrect / questNum * 100

    userScore = scorenumOfQ = questNum

    numCorrect = numberCorrect

    'add test, id, date, and grade to test scores database

    With datScores.Recordset

    .AddNew

    .Fields("Test").Value = Mid(currentTest, 1, 50)

    .Fields("ID").Value = loggedUser

    .Fields("Date").Value = Date

    .Fields("Grade").Value = score

    .Update

    End With

    Load frmDisplayGrade

    End Sub

    Display Grade form code

    Private Sub cmdDisplay_Click()

    Dim i As Integer

    Dim x As Integer

    Dim numOfQuest As Integer

    'clear pic box and display score

    picScore.ClspicScore.Print "Out of " & numOfQ & " questions"

  • 8/14/2019 computerized Q bank

    55/68

    picScore.Print "you answered " & numCorrect & " correctly."

    picScore.Print "Your score is " & userScore & "."

    numOfQuest = numOfQ

    x = 0For i = 1 To numOfQuest

    x = x + 1

    'display question numbers and X's if answer is incorrectIf usersAnswer(i) = RTrim(questTest(i).correctAns) Then

    picAnswers.Print i & " - " & usersAnswer(i),

    Else

    picAnswers.Print "X" & i & " - " & usersAnswer(i) & "X",End If

    'allow 4 answers to be displayed per line

    If x = 4 Then

    picAnswers.Printx = 0

    End IfNext i

    End Sub

    Private Sub cmdPrintScore_Click()

    Dim i As Integer

    Dim x As IntegerDim numOfQuest As Integer

    'print score on printerPrinter.FontSize = 12

    Printer.Print "Out of " & numOfQ & " questions"

    Printer.Print "you answered " & numCorrect & " correctly."Printer.Print "Your score is " & userScore & "."

    Printer.Print: Printer.Print

    numOfQuest = numOfQ

    x = 0

    For i = 1 To numOfQuestx = x + 1

    'print question number and X's on wrong answer to printer

    If usersAnswer(i) = RTrim(questTest(i).correctAns) ThenPrinter.Print i & " - " & usersAnswer(i),

    Else

    Printer.Print "X" & i & " - " & usersAnswer(i) & "X",

    End If

  • 8/14/2019 computerized Q bank

    56/68

    'allow 4 answers on each line

    If x = 4 Then

    Printer.Printx = 0

    End If

    Next i

    Printer.EndDoc

    End Sub

    Private Sub Form_Load()

    Show

    Left = (Screen.Width - Width) / 2

    Top = (Screen.Height - Height) / 2

    End Sub

    Display Test Student form code

    Private Sub Form_Load()

    Dim i As Integer

    ShowTop = (Screen.Height - Height) / 2

    Left = (Screen.Width - Width) / 2

    'set column width

    MSFlexGrid1.ColWidth(0) = 5100

    For i = 1 To 2MSFlexGrid1.ColWidth(i) = 900

    Next i

    'select testscores from the currently logged user

    With datScores

    .DatabaseName = App.Path & "\login.mdb"

    .RecordSource = "SELECT Test, Date, Grade " & _"FROM TestScores " & _

    "WHERE ID = '" & loggedUser & "'"

    .RefreshEnd With

    End Sub

  • 8/14/2019 computerized Q bank

    57/68

    Test Scores form code

    Private Sub cmbStudent_Click(Area As Integer)

    'when user selects an user ID, display the user's name as

    'a tool tipWith datLogin.Recordset

    .MoveFirst

    .FindFirst ("UserID = '" & cmbStudent & "'")cmbStudent.ToolTipText = RTrim(.Fields("FirstName").Value) & " " & _

    .Fields("LastName").Value

    End With

    End Sub

    Private Sub cmdDisplayStudent_Click()

    Dim numOfTests As Integer

    Dim totalScore As IntegerDim average As Single

    'move to correct records and display infopicDisplay.Cls

    With datScores.Recordset

    .MoveFirst

    Do Until .EOFIf cmbStudent.Text = .Fields("ID").Value Then

    numOfTests = numOfTests + 1totalScore = totalScore + .Fields("Grade").ValuepicDisplay.Print "Test: " & .Fields("Test").Value; _

    Tab(25); "I.D. "; .Fields("ID").Value; _

    Tab(68); .Fields("Date").Value; _Tab(80); .Fields("Grade").Value

    End If

    .MoveNext

    Loop

    'calculate average if any tests existed

    If numOfTests > 0 Thenaverage = totalScore / numOfTests

    picDisplay.Print

    picDisplay.Print "Average of tests for student " & cmbStudent.Text & _" is " & FormatNumber(average, 1)

    Else

    MsgBox "Test Scores Not Available!", , "Attention!!!"End If

  • 8/14/2019 computerized Q bank

    58/68

    End With

    End Sub

    Private Sub cmdDisplayTest_Click()

    Dim numOfTests As Integer

    Dim totalScore As IntegerDim average As Single

    'move to current records and display

    picDisplay.ClsWith datScores.Recordset

    .MoveFirst

    Do Until .EOF

    If cmbTest.Text = .Fields("Test").Value ThennumOfTests = numOfTests + 1

    totalScore = totalScore + .Fields("Grade").ValuepicDisplay.Print "Test: " & cmbTest.Text; _

    Tab(25); "I.D. "; .Fields("ID").Value; _

    Tab(68); .Fields("Date").Value; _

    Tab(80); .Fields("Grade").ValueEnd If

    .MoveNext

    Loop

    'if tests existed then display average

    If numOfTests > 0 Thenaverage = totalScore / numOfTests

    picDisplay.Print

    picDisplay.Print "Average of test " & cmbTest.Text & _" is " & FormatNumber(average, 1)

    Else

    MsgBox "Test Scores Not Available!", , "Attention!!!"

    End IfEnd With

    End Sub

    Private Sub cmdPrintStudent_Click()

    Dim numOfTests As Integer

    Dim totalScore As Integer

    Dim average As Single

  • 8/14/2019 computerized Q bank

    59/68

    Printer.FontSize = 12

    'find records and print

    With datScores.Recordset.MoveFirst

    Do Until .EOF

    If cmbStudent.Text = .Fields("ID").Value ThennumOfTests = numOfTests + 1

    totalScore = totalScore + .Fields("Grade").Value

    Printer.Print "Test: " & .Fields("Test").Value; _Tab(35); "I.D. "; .Fields("ID").Value; _

    Tab(68); .Fields("Date").Value; _

    Tab(80); .Fields("Grade").Value

    End If.MoveNext

    Loop

    'if tests existed then print the averageIf numOfTests > 0 Then

    average = totalScore / numOfTestsPrinter.Print

    Printer.Print "Average of tests for student " & cmbStudent.Text & _

    " is " & FormatNumber(average, 1)

    Printer.EndDocElse

    MsgBox "Test Scores Not Available!", , "Attention!!!"

    End IfEnd With

    End Sub

    Private Sub cmdPrintTest_Click()

    Dim numOfTests As Integer

    Dim totalScore As Integer

    Dim average As Single

    Printer.FontSize = 12

    'find correct records and print

    With datScores.Recordset.MoveFirst

    Do Until .EOF

    If cmbTest.Text = .Fields("Test").Value ThennumOfTests = numOfTests + 1

    totalScore = totalScore + .Fields("Grade").Value

    Printer.Print "Test: " & cmbTest.Text, _

    "I.D. " & .Fields("ID").Value, _

  • 8/14/2019 computerized Q bank

    60/68

  • 8/14/2019 computerized Q bank

    61/68

  • 8/14/2019 computerized Q bank

    62/68

    Else

    If optB.Value = True Then

    .Fields("answer") = "B"questHold(frmInstructor.lisTestBank.ListIndex + 1).correctAns = "B"

    Else

    If optC.Value = True Then.Fields("answer") = "C"

    questHold(frmInstructor.lisTestBank.ListIndex + 1).correctAns = "C"

    Else.Fields("answer") = "D"

    questHold(frmInstructor.lisTestBank.ListIndex + 1).correctAns = "D"

    End If

    End IfEnd If

    .Update

    End With

    'save current number of questions in list box'clear list box

    x = frmInstructor.lisTestBank.ListCount

    frmInstructor.lisTestBank.Clear

    'load list box with newly edited question

    For i = 1 To x

    frmInstructor.lisTestBank.AddItem questHold(i).questNext i

    Unload Me

    End Sub

    Private Sub Form_Load()'make current form visible

    Show

    'center form on screenLeft = (Screen.Width - Width) / 2

    Top = (Screen.Height - Height) / 2

    End Sub

    Private Sub optMultiple_Click()

    'if multipe is selected clear first 2 answer option text'boxes in case they have been changed to true and false

    If optMultiple.Value = True Then

    txtOptA.Text = ""

    txtOptB.Text = ""

  • 8/14/2019 computerized Q bank

    63/68

    End If

    End Sub

    Private Sub optTrueFalse_Click()

    'if true/false is selected set first 2 answer option text

    'boxes to true and false, and set focus on optionAIf optTrueFalse.Value = True Then

    txtOptA.Text = "True"

    txtOptB.Text = "False"optA.SetFocus

    End If

    End Sub

    Private Sub txtOptA_Change()

    'display number of characters in text box

    Label4.Caption = Len(txtOptA.Text)

    End Sub

    Private Sub txtOptA_KeyPress(KeyAscii As Integer)'if return is pressed move to next field

    If KeyAscii = 13 Then

    txtOptB.SetFocus

    Exit SubEnd If

    'if text is larger than 50 then do not allow additional'characters

    If Len(txtOptA.Text) > 49 Then

    If Not KeyAscii = 8 ThenKeyAscii = 0

    End If

    End IfEnd Sub

    Private Sub txtOptB_Change()

    'display number of characters in text boxLabel5.Caption = Len(txtOptB.Text)

    End Sub

    Private Sub txtOptB_KeyPress(KeyAscii As Integer)

    'if return is pressed move to next field

    If KeyAscii = 13 ThentxtOptC.SetFocus

    Exit Sub

    End If

  • 8/14/2019 computerized Q bank

    64/68

    'if text is larger than 50 then do not allow additional

    'characters

    If Len(txtOptB.Text) > 49 ThenIf Not KeyAscii = 8 Then

    KeyAscii = 0

    End IfEnd If

    End Sub

    Private Sub txtOptC_Change()

    'display number of characters in text box

    Label6.Caption = Len(txtOptC.Text)

    End Sub

    Private Sub txtOptC_KeyPress(KeyAscii As Integer)

    'if return is pressed move to next field

    If KeyAscii = 13 ThentxtOptD.SetFocus

    Exit SubEnd If

    'if text is larger than 50 then do not allow additional

    'charactersIf Len(txtOptC.Text) > 49 Then

    If Not KeyAscii = 8 Then

    KeyAscii = 0End If

    End If

    End Sub

    Private Sub txtOptD_Change()'display number of characters in text box

    Label7.Caption = Len(txtOptD.Text)

    End Sub

    Private Sub txtOptD_KeyPress(KeyAscii As Integer)

    'if return is pressed move to next field

    If KeyAscii = 13 ThenoptA.SetFocus

    Exit Sub

    End If

    'if text is larger than 50 then do not allow additional

    'characters

    If Len(txtOptD.Text) > 49 Then

  • 8/14/2019 computerized Q bank

    65/68

    If Not KeyAscii = 8 Then

    KeyAscii = 0

    End IfEnd If

    End Sub

    Private Sub txtQuestion_Change()

    'display number of characters in text box

    lblLength.Caption = Len(txtQuestion.Text)End Sub

    Private Sub txtQuestion_KeyPress(KeyAscii As Integer)

    'if return is pressed move to next fieldIf KeyAscii = 13 Then

    optMultiple.SetFocus

    Exit Sub

    End If

    'if text is larger than 250 then do not allow additional'characters

    If Len(txtQuestion.Text) > 249 Then

    If Not KeyAscii = 8 Then

    KeyAscii = 0End If

    End If

    End Sub

  • 8/14/2019 computerized Q bank

    66/68

    FUTURE SCOPE

    This Computerized Question Bank project can be enhanced so that it can be

    implemented in the Network environment, so that all the students will be

    able to attend the test at the same time, as it is developed to support single

    user.

  • 8/14/2019 computerized Q bank

    67/68

    CONCLUSION

    This Computerized Question Bank project has all the features to be

    implemented in institutions for computerizing the test procedures, which are

    conducted manually so far. Also, at the beginning of each semester, our

    counselor distributes a question bank containing all the questions of the

    semester papers. That can be made easy using this project. The Faculty

    members can frame questions and ask their students to attend it and evaluate

    their performances. The Faculty members can use this project to conduct

    career development programs, like conducting tests on objective questions,

    general English, etc.

  • 8/14/2019 computerized Q bank

    68/68

    Bibliography:

    Visual Basic 6.0 Programming Black BookSteven Holzner

    The Complete Reference Visual Basic 6.0

    Noel Jerke

    Sams Teach Yourself Visual Basic 6.0

    Greg Perry

    MSDN Library

    Visual Basic 6.0

    NIIT Material

    Visual Basic 6.0

    SSI Material