Professional Documents
Culture Documents
'Bring Up The Form To Add A New Question To Question Bank: Frminstructor
'Bring Up The Form To Add A New Question To Question Bank: Frminstructor
'check to see if a current test is already in use, if not create a new one
testHasChanged = True
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"
Else
If 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 closed
Close
'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
Write #1, questTest(recordNum).quest
Write #1, questTest(recordNum).answerA
Write #1, questTest(recordNum).answerB
Write #1, questTest(recordNum).answerC
Write #1, questTest(recordNum).answerD
Write #1, questTest(recordNum).correctAns
Write #1, questTest(recordNum).theType
Next recordNum
Close #1
Close #1
'reset test has changed to false
testHasChanged = False
End If
End Sub
Private Sub createTest()
'if test had changed then ask to save current test before creating a 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 create a new one?", _
vbYesNoCancel, "Warning!")
If userResponse = vbYes Then
Call SaveTest
Else
If userResponse = vbCancel Then
Exit Sub
End If
End If
End If
currentTest = .FileName
lblCurTest.Caption = "Current Test: " & currentTest
mnuSave.Enabled = True
mnuSaveAs.Enabled = True
cmdReviewQuestion.Enabled = True
cmdRemoveTestQuest.Enabled = True
cmdUp.Enabled = True
cmdDown.Enabled = True
cmdSaveTest.Enabled = True
testHasChanged = False
End With
dlgError:
On Error GoTo 0
Exit Sub
End Sub
Private Sub cmdClearTemplate_Click()
'clear all controls in template
optMultiple.Value = False
optTrueFalse.Value = False
opt1template.Value = False
opt2Template.Value = False
opt3Template.Value = False
opt4Template.Value = False
txtQuestTemplate.Text = ""
txtOption1.Text = ""
txtOption2.Text = ""
txtOption3.Text = ""
txtOption4.Text = ""
End Sub
End Sub
Private Sub cmdEditBank_Click()
Dim i As Integer
'make sure question is selected
If 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" Then
frmEdit.optMultiple = True
Else
frmEdit.optTrueFalse = True
End 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 = True
Else
If RTrim(.Fields("answer")) = "B" Then
frmEdit.optB = True
Else
If RTrim(.Fields("answer")) = "C" Then
frmEdit.optC = True
Else
frmEdit.optD = True
End If
End If
End If
End With
Load frmEdit
Else
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 answer to template
End Sub
'check to see if the question to be removed from the bank has been clicked on
If lisTestBank.Text = "" Then
MsgBox "You have not selected a question to remove.", , "Warning!"
Else
End If
End Sub
Dim i As Integer
End Sub
Private Sub cmdReviewQuestion_Click()
End If
End Sub
End Sub
End Sub
Private Sub Form_Load()
With datLogin
.DatabaseName = App.Path & "\login.mdb"
.RecordSource = "Login"
.Refresh
End With
'if logged in with default system password disable menu option to edit password
If UCase(userCode) = "SYSTEM999" Then
mnuEditPassword.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 = False
cmdEditBank.Enabled = False
End Sub
End Sub
Private Sub mnuCreate_Click()
Call createTest
End Sub
datBank.Database.Close
'set Add to bank, remove from bank, and edit from bank command buttons
cmdAddToBank.Enabled = True
cmdRemoveFromBank.Enabled = True
cmdEditBank.Enabled = True
Set T1 = NewBank.CreateTableDef("bank")
Set T1Flds(1) = T1.CreateField("question", dbText, 250)
Set T1Flds(2) = T1.CreateField("type", dbText, 1)
Set T1Flds(3) = T1.CreateField("opt1", dbText, 50)
Set T1Flds(4) = T1.CreateField("opt2", dbText, 50)
Set T1Flds(5) = T1.CreateField("opt3", dbText, 50)
Set T1Flds(6) = T1.CreateField("opt4", dbText, 50)
Set T1Flds(7) = T1.CreateField("answer", dbText, 50)
T1.Fields.Append T1Flds(1)
T1.Fields.Append T1Flds(2)
T1.Fields.Append T1Flds(3)
T1.Fields.Append T1Flds(4)
T1.Fields.Append T1Flds(5)
T1.Fields.Append T1Flds(6)
T1.Fields.Append T1Flds(7)
End With
DialogError:
On Error GoTo 0
Exit Sub
End Sub
End Sub
End Sub
End Sub
Load frmStudPass
End Sub
'before exiting check to see if test has changed and give user option to save or not or cancel exit
If testHasChanged Then
response = MsgBox("Test has changed, do you want to save before exiting program?",
vbYesNoCancel _
, "Warning!")
If response = vbYes Then
Call SaveTest
Else
If response = vbCancel Then
Exit Sub
End If
End If
End If
'stop application
End
End Sub
Dim i As Integer
Dim userResponse As Integer
Dim timed As String
Dim minutes As Integer
Dim goBack As String
Dim theColor As String
'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 SaveTest
Else
If userResponse = vbCancel Then
Exit Sub
End If
End If
End If
lisTestQuests.Clear
Close
End With
dlgError:
On Error GoTo 0
Exit Sub
End Sub
Dim i As Integer
Dim x As Integer
'enable add to bank, romove from bank, and edit bank command buttons
cmdAddToBank.Enabled = True
cmdRemoveFromBank.Enabled = True
cmdEditBank.Enabled = True
DialogError:
On Error GoTo 0
Exit Sub
End Sub
Dim i As Integer
Dim linecount As Integer
'print the current test with font size 12
Printer.FontSize = 12
For i = 1 To 5
Printer.Print
Next i
Printer.Print Space(80 - (Len(currentTest) / 2)); currentTest
Printer.Print
'print questions
For i = 1 To lisTestQuests.ListCount
Printer.FontSize = 10
Printer.Print i & "." & questTest(i).quest
Printer.Print
linecount = linecount + 2
If questTest(i).theType = "T" Then
Printer.Print "A. " & questTest(i).answerA
Printer.Print "B. " & questTest(i).answerB
linecount = linecount + 3
Else
Printer.Print "A. " & questTest(i).answerA
Printer.Print "B. " & questTest(i).answerB
Printer.Print "C. " & questTest(i).answerC
Printer.Print "D. " & questTest(i).answerD
linecount = linecount + 5
End If
Printer.Print
If linecount > 55 Then
Printer.NewPage
Printer.FontSize = 12
Printer.Print: Printer.Print: Printer.Print: Printer.Print
Printer.Print: Printer.Print: Printer.Print
Printer.FontSize = 10
linecount = 0
End If
Next i
Printer.EndDoc
End Sub
End Sub
'make sure test has changed and that there is at least 1 question in the test
If testHasChanged And lisTestQuests.ListCount > 0 Then
Call SaveTest
End If
End Sub
'set currentTest to the filename selected enable save and saves menu selections
currentTest = .FileName
mnuSave.Enabled = True
mnuSaveAs.Enabled = True
End With
dlgError:
On Error GoTo 0
Exit Sub
End Sub
End Sub
End Sub