Random Test Generator

zul336

Registered User.
Local time
Yesterday, 20:15
Joined
Dec 24, 2011
Messages
9
Hi All,

Can someone please help me with sample of database which can choose from a sample of questions, multiple choice answer, to produce a test of 10 questions (no duplicates) AND be able to 'mark" the test somehow?

I am after a very simple database, I will make rest of changes my self.

Your help will be highly appreciated.
 
There are often references to Duane Hookum's software for this sort of thing. I have not used it personally,but I have directed others to it. You should review and see if it applies to your situation.

See AtYourSurvey
 
Hi,

1st off all thanks for your prompt reply.

Is it possible to create such database in Access as at my work place we are not authorised to install third party softwares.

Thanks
 
I'm sure it's possible. But like many things, it may be more cost advantageous to use an existing, tested software.
Look at whatever documentation you can find. It will give you some ideas of what is involved. Do some research, then make your decision(s).
 
Hi,

1st off all thanks for your prompt reply.

Is it possible to create such database in Access as at my work place we are not authorised to install third party softwares.

Thanks

Yes it is possible.

The link you were provided is to an Access database that is is a complete Application (not just tables). It is not software Application that needs to be installed. You simply open it with Access. It can be used as a template to start your own application in Access.
 
Hi,

I manage to create my Database but I am facing few issues and I might require some help.

Below is the list of problems I am facing

1. My database is not looking at questions after question number 38 (I got no idea why).
2. It is not giving me correct Feedback of wrong questions (Again no idea why as i gone through code several time)

3. I would like it to let me select Multiple choice answers (Right now I can only select 1 answer)

Your help will be highly appreciated.

Once completed I will publish it for others to use free of charge as on several forums i seen people are requesting similar Database.
 
Did you download the suggested survey? At the very least look at the table structure.


attachment.php
 

Attachments

  • Survey.png
    Survey.png
    47.7 KB · Views: 933
hi,

I have looked at it and based my Design mainly on same fundamentals.

My design and table structure is very simple

I worked fine under small sample but when I added more dats it started giving me issues.

If you want I can share Database with you.

Regards
 

Attachments

  • Relationships.png
    Relationships.png
    10.8 KB · Views: 151
Last edited:
I am using form name "Registration for the test" to gather data, it is asking for Name, ID and Category from User. and Loading up Form TEST with right category and 25 questions.

Once completed it is loading up report name REPORT with Name, ID, Percentage of Marks, Category and Wrong questions. Also saving feedback in Users Table.

Below is the Code I'm Using



Option Compare Database

Sub SleepVB(Seconds)
Dim Start
Start = Timer
Do While Timer < Start + Seconds
DoEvents
Loop
End Sub


Private Sub Command6_Click()
Dim dbs As Database

Dim rst As Recordset

Dim mystrSQL As String

Dim name As String
Dim staff_ID As String
Dim Category As String

Application.SetOption "Confirm Record Changes", False
Application.SetOption "Confirm Document Deletions", False
Application.SetOption "Confirm Action Queries", False

' ----------------------------------------------------------------------

If IsNull(Me.Text0.Value) Then
MsgBox ("Error! Enter the name, please")
Else
name = Me.Text0.Value

If IsNull(Me.Text4.Value) Then
MsgBox ("Error! Enter the staff ID, please")
Else
staff_ID = Me.Text4.Value

If IsNull(Me.Combo9.Value) Then
MsgBox ("Error! Enter the category, please")
Else
Category = Me.Combo9.Column(1)

' DoCmd.Close acForm, "Registration for the test"

Dim i&, a&, z&, x&, y&, j&, answers&, mark&, s$

Dim responding As Boolean
Dim responding2 As Boolean

' z - he number of questions selected category. Must be 50, but check it:
' x - the number of questions asked, must be 25
' y - the current number of unasked question
' answers - number of correct answers
' mark - received points

x = 25
' x = 3

z = 185
answers = 0

Dim arrayAnswers(25 - 1) As Integer
Dim arrayAnswersIncorrect(25 - 1) As Integer

mystrSQL = "SELECT Nz(Count(Questions.ID_question),0) AS CountOfID_question "
mystrSQL = mystrSQL & "FROM Categories LEFT JOIN Questions ON Categories.ID_category = Questions.Category "
mystrSQL = mystrSQL & "GROUP BY Categories.ID_category "
mystrSQL = mystrSQL & "HAVING (((Categories.ID_category)=" & Category & "))"

mystrSQL = "SELECT Nz(Count(Questions.ID_question),0) AS CountOfID_question "
mystrSQL = mystrSQL & "FROM Categories LEFT JOIN Questions ON Categories.ID_category = Questions.Category "
mystrSQL = mystrSQL & "GROUP BY Categories.my_category HAVING (((Categories.my_category)=""" & Category & """));"

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(mystrSQL)
z = rst![CountOfID_question].Value

Randomize

For i = 1 To x
arrayAnswers(i - 1) = 0
arrayAnswersIncorrect(i - 1) = 0
Next

For i = 1 To x

Do
responding = True

y = CInt(Int((z * Rnd()) + 1))

mystrSQL = "SELECT Questions.ID_question FROM Categories INNER JOIN Questions ON Categories.ID_category = Questions.Category "
mystrSQL = mystrSQL & "WHERE (((Questions.[Number question])=" & y & ") AND ((Categories.my_category)=""" & Category & """))"

Set rst = dbs.OpenRecordset(mystrSQL)

If (rst.RecordCount > 0) Then
responding2 = True
' get the data on viewing this question # y
For a = 1 To x
If arrayAnswers(a - 1) = y Then
responding2 = False
End If
Next

If (Not responding2) Then
responding = False
End If

Else
responding = False
End If

rst.Close

' Exit Do
Loop While (Not responding)

arrayAnswers(i - 1) = y


' selection question
mystrSQL = "SELECT Questions.[Number question], Questions.Question, Categories.my_category, Answers.Answer, Answers.[Correct answer] "
mystrSQL = mystrSQL & "FROM (Categories INNER JOIN Questions ON Categories.ID_category = Questions.Category) INNER JOIN Answers ON Questions.ID_question = Answers.Question "
mystrSQL = mystrSQL & "GROUP BY Questions.[Number question], Questions.Question, Categories.my_category, Answers.Answer, Answers.[Correct answer], Questions.ID_question "
' mystrSQL = mystrSQL & "HAVING (((Questions.ID_question)=" & y & "))"
mystrSQL = mystrSQL & "HAVING (((Questions.[Number question])=" & y & "))"


CurrentDb.QueryDefs("Query1").SQL = mystrSQL
CurrentDb.QueryDefs("Query1").OpenRecordset

DoCmd.OpenForm "Testing", acNormal
'
Do While Forms![Testing].Controls![Text16].Value = 0
SleepVB (1)
Loop

If Forms![Testing].Controls![Text16].Value = 1 Then
answers = answers + 1
Else
If Forms![Testing].Controls![Text16].Value = -1 Then
arrayAnswersIncorrect(i - 1) = y
End If
End If

DoCmd.Close acForm, "Testing"

Next

Dim myTime As Date

' --------------------------------------------------------------------------------------------------------------
i = (100 * answers) / x

myTime = CDate(Now())

mystrSQL = "INSERT INTO Users ( Name, [Date], [Staff ID], Points, my_category ) "
mystrSQL = mystrSQL & "values(""" & name & """, #" & myTime & "#, """ & staff_ID & """, " & i & ", """ & Category & """)"

DoCmd.RunSQL mystrSQL

' --------------------------
Dim str As String
str = ""

For a = 1 To x
If arrayAnswersIncorrect(a - 1) > 0 Then
str = str & " (((Questions.[Number question])=" & a & ")) OR"
End If
Next

If str = "" Then
mystrSQL = "SELECT Users.Name, Users.Date, Users.[Staff ID], Users.Points, Users.my_category, " & """"" AS Question FROM Users "
mystrSQL = mystrSQL & "WHERE (((Users.Name)=""" & name & """) AND ((Users.Date)=#" & myTime & "#) AND ((Users.[Staff ID])=""" & staff_ID & """) AND ((Users.my_category)=""" & Category & """) AND ((Users.Points)=" & i & "))"

Else

mystrSQL = "SELECT Users.Name, Users.Date, Users.[Staff ID], Users.Points, Users.my_category, Questions.Question "
mystrSQL = mystrSQL & "FROM Users, Questions WHERE "

' delete last word - OR
j = InStrRev(str, " ")
If j > 0 Then
mystrSQL = mystrSQL & Left$(str, j)
End If

mystrSQL = mystrSQL & " GROUP BY Questions.Question, Users.Name, Users.Date, Users.[Staff ID], Users.my_category, Users.Points "
mystrSQL = mystrSQL & "HAVING (((Users.Name)=""" & name & """) AND ((Users.Date)=#" & myTime & "#) AND ((Users.[Staff ID])=""" & staff_ID & """) AND ((Users.my_category)=""" & Category & """) AND ((Users.Points)=" & i & "))"

End If

If i < 80 Then
MsgBox ("Sorry, you have not passed testing...")
End If

Debug.Print mystrSQL

CurrentDb.QueryDefs("Query2").SQL = mystrSQL

' --------------------------

DoCmd.OpenReport "Report", acViewPreview, , stLinkCriteria

End If
End If
End If

' ----------------------------------------------------------------------
Application.SetOption "Confirm Record Changes", True
Application.SetOption "Confirm Document Deletions", True
Application.SetOption "Confirm Action Queries", True

End Sub
 
y = CInt(Int((z * Rnd()) + 1))

If I use 185 instead of z (Total Number of questions) than this allows me to complete 25 questions.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom