Random questionnaires probably the useful tools for creating an exam because every student given questions randomly based on what computer generated. With that, it’s maximized cheating each other. There are different ways how to integrate random questions, actually human can create manual random questions but it is very difficult to handle that tasks. However, computer is the answer in that problem because we know computer is one of our best friend incomes in technology that help our work faster.
In this sample program, it shows how to pick random questions based on what you declared using Visual Basic.Net (VB.Net). Yet, the example here is simple but you can increase your idea how to work in your own. To implement random questions and make it flexible and secure your data, you can use database where you can add and store a data, at the same time you can query a certain data. Well, this is my sample code.
Option Strict On
Option Explicit On
Public Class Form1
Private Sub btngenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngenerate.Click
Dim questionexists As New Collection
Dim validquestion As Boolean = False
txtquestionnaires.Text = RandomQuestion(CStr(randonNumber(0, 8)))
questionexists.Add(txtquestionnaires.Text, txtquestionnaires.Text)
While validquestion = False
Dim strquestion2 As String = RandomQuestion(CStr(randonNumber(0, 8)))
If questionexists.Contains(strquestion2) Then
validquestion = False
Else
validquestion = True
txtquestionnaires.Text = strquestion2
End If
End While
End Sub
Private Function GenerateRandomkey(ByVal LowerBand As Integer, ByVal UpperBound As Integer) As Integer
Randomize()
Dim r As New Random
Return r.Next(LowerBand, UpperBound)
End Function
Public Function randonNumber(ByVal ilower As Integer, ByVal iUpper As Integer) As Integer
Return GenerateRandomkey(ilower, iUpper)
End Function
Private Function RandomQuestion(ByVal iRandom As String) As String
Select Case iRandom
Case CStr(0)
Return "What is VB stands for?"
Case CStr(1)
Return "What is Java"
Case CStr(2)
Return "What is PHP?"
Case CStr(3)
Return "What is ASP?"
Case CStr(4)
Return "What is programmer?"
Case CStr(5)
Return "What is syntax?"
Case CStr(6)
Return "What is your favorite programming language?"
Case CStr(7)
Return "What is Python?"
Case CStr(8)
Return "What is computer?"
End Select
Return "Who is your name?"
End Function
End Class
Noted: There are different ways how to work with random questions.
0 comments:
Post a Comment