随机化MCQ问题 [英] Randomize MCQ questions
问题描述
亲爱的,
请帮助我在VB.net中从新手那里帮助我
我试图轻松MCQ(员工和部门)。我有3个问题:
(在你开始阅读我的问题之前,请以新的visual basic形式复制并粘贴我的所有代码并添加4个单选按钮,1个标签和2个按钮,所以问题将很容易理解点)
1-我想随机化问题 - (不是答案) - :总是我的问题在相同的序列。例如:问题#1是富人,Q2#Tal,Q3#sau。
我想要的是将它们随机化一些sau成为Q#1等等......
2-如果一个人回答了正确的问题我不想再在列表中看到问题(除非该人再次加载表格)。例如:富人是IT部门,如果该人选择IT,那么测验继续其余的问题Tal,sau没有问题被正确回答富有
3 - 我想直接转到下一个问题:在我的例子中:如果我选择单选按钮1或2或3或4,那么我必须单击按钮1才能转到下一个问题。
我想要的是跳过按钮1(我想删除它),只需要带有启动按钮和1个标签和4个单选按钮的测验。
:
i不知道如何将它连接到数据库,尽管我已经有6列数据库文件。在我将数据库文件加载到visual basic后我不知道如何将它与代码混合。
因此请帮助我使用没有数据库的正常代码。
非常感谢
我尝试过:
公共舱Form1
私人结构问题Nanswers
公共Q作为字符串
Public a As String
公共QT为整数
公共QC为整数
结束结构
私有wstart为整数
私人adad As Integer = 10
私人QA(15)as questionsNanswers
私人字(999)字符串
私人名称(999)字符串
私人aray(999)作为整数
Private Sub RandomizeArray(一个整数,ByRef数组()作为整数)
Dim i As Integer
Dim j As Integer
Dim tmp As Integer
随机化()
对于i = 0来a - 1
j = Int((6 - i + 1)* Rnd()+ i)
tmp = array(i)
数组(i)=数组(j)
数组(j)= tmp
下一页
End Sub
私有子随机化()
Dim r As New Random
End Sub
Private Sub Button1_Click(sender As System.Object,e As System.EventArgs)处理Button1.Click
'next
CheckEntry()
wstart = wstart + 1
如果wstart> = adad那么
wstart = 0
结束如果
WriteText()
randomize()
End Sub
Private Sub Button2_Click(sender As System.Object,e As System.EventArgs)处理Button2.Click
'上一页
CheckEntry()
wstart = wstart - 1
如果wstart< 0然后
wstart = adad - 1
结束如果
WriteText()
结束子
私人子CheckEntry()
RadioButton1.Visible =真
RadioButton2.Visible = True
RadioButton3.Visible = True
RadioButton4.Visible = True
RadioButton1.ForeColor = Color.Black
RadioButton2.ForeColor = Color.Black
RadioButton3.ForeColor = Color.Black
RadioButton4.ForeColor = Color.Black
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
结束次级
Private Sub WriteText()
Dim out As Boolean = False
对于kk = 0到6
aray(kk)= kk
下一页
RandomizeArray(7,aray)
Do to out
for j = 0 to 3
If out = False然后
如果aray(j)= QA(wstart).QT那么
out = True
退出做
结束如果
结束如果
下一页
对于kkk = 0到6 >
aray(kkk)= kkk
下一页
RandomizeArray(7,aray)
循环
RadioButton1.Text = word(aray(0))
RadioButton2.Text = word(aray(1))
RadioButton3.Text = word(aray(2))
RadioButton4.Text = word(aray(3))
Label1.Text = QA(wstart).Q
'=========================== ===
'Dim go As Boolean = False
'如果去那么
'Dim msg As String
'For ll = 0 to 6
'msg = msg + CStr(aray(ll))+|
'Next
'MsgBox(msg)
'结束如果
结束子
Public Sub New()
'此电话是必需的由设计师。
InitializeComponent()
'在InitializeComponent()调用后添加任何初始化。
'a
字(0)=TA
字(1)=GR
字(2)=HR
字(3)=FIN
字(4)=commerci al
word(5)=Proc
word(6)=IT
姓名(0)=富
姓名(1)=Tal
姓名(2)=sau
姓名( 3)=轻拍
名称(4)=del
'q和wstart意味着介于()
QA(0).Q =姓名(0)
QA(0).a =字(6)
QA(0).QT = 6
QA(0).QC = -1
QA (1).Q =姓名(1)
QA(1).a =字(1)
QA(1).QT = 1
QA(1).QC = -1
QA(2).Q =姓名(2)
QA(2 ).a =字(2)
QA(2).QT = 2
QA(2).QC = -1
< br $>
QA(3).Q =姓名(3)
QA(3).a =字(3)
QA(3)。 QT = 3
QA(3).QC = -1
QA(4).Q =姓名(4)
QA(4).a =字(5)
QA(4).QT = 5
QA(4) .QC = -1
WriteText()
End Sub
Private Sub RadioButton1_CheckedChanged(sender As System.Object,e As System.EventArgs)处理RadioButton1 .CheckedChanged
如果RadioButton1.Checked那么
如果是StrComp(QA(wstart).a,RadioButton1 .Text)= 0然后
RadioButton1.ForeColor = Color.Red
RadioButton2.Visible = False
RadioButton3.Visible = False >
RadioButton4.Visible = False
结束如果
结束如果
'如果RadioButton1.ForeColor = Color.Red那么
'结束如果
'如果wstart> = adad那么
' WSTA rt = 0
'结束如果
'wstart = wstart + 1
'如果wstart> = adad然后
'wstart = 0
'结束如果
结束Sub
Private Sub RadioButton2_CheckedChanged(sender As System.Object,e As System.EventArgs)处理RadioButton2.CheckedChanged
如果RadioButton2.Checked那么
如果是StrComp(QA(wstart)。 a,RadioButton2.Text)= 0然后
RadioButton2.ForeColor = Color.Red
RadioButton1.Visible = False
RadioButton3.Visible = False
RadioButton4.Visible = False
结束如果
结束如果
结束子
Private Sub RadioButton3_CheckedChanged(sender As System.Object,e As System.EventArgs)处理RadioButton3.CheckedChanged
如果RadioButton3.Chec ked然后
如果StrComp(QA(wstart).a,RadioButton3.Text)= 0那么
RadioButton3.ForeColor = Color.Red
RadioButton1.Visible = False
RadioButton2.Visible = False
RadioButton4.Visible = False
结束如果
结束如果
End Sub
Private Sub RadioButton4_CheckedChanged(sender As System.Object,e As System.EventArgs)处理RadioButton4.CheckedChanged
如果RadioButton4.Checked那么
如果StrComp(QA(wstart).a,RadioButton4.Text)= 0那么
RadioButton4.ForeColor = Color.Red
RadioButton1.Visible = False
RadioButton2.Visible = False
RadioButton3.Visible = False
结束如果
结束如果
结束子
Private Sub Label1_Click(发件人作为对象,e作为EventArgs)处理Label1.Click
End Sub
Private Sub RadioButton1_Click(发送者为对象,e为EventArgs)处理RadioButton1.Click
End Sub
Private Sub RadioButton1_MouseClick(发送者为对象,e为MouseEventArgs)处理RadioButton1.MouseClick
'如果RadioButton1.Checked那么
'如果是StrComp(QA(wstart).a,RadioButton1.Text )= 0然后
'RadioButton1.ForeColor = Color.Red
'RadioButton2.Visible = False
'RadioButton3.Visible = False
'RadioButton4.Visible = False
'结束如果
'结束如果
'moveto()
End Sub
Private Sub moveto()
wstart = wstart + 1
如果wstart> = adad那么
wstart = 0
结束如果
'随机()
WriteText()
'如果RadioButton1.ForeColor = Color.Red那么MessageBox.Show(correct)Else MessageBox.Show(false)
'如果RadioButton2.ForeColor = Color.Red那么Label1.Text = QA(wstart).Q
'如果RadioButton3.ForeColor = Color.Red那么Label1.Text = QA(wstart) .Q
'如果RadioButton3.ForeColor = Color.Red那么Label1.Text = QA(wstart).Q
结束子
结束类
dears,
please assist me in VB.net as from newbie
im trying to make easy MCQ (employees and departments). i have 3 problems :
(before you start reading my issues , please copy and paste all my codes in new form of visual basic and add 4 radio buttons , 1 label and 2 buttons, so the questions will be easily understanding points)
1- i want to randomize the questions - (not the answers)-: always my questions are in the same sequence. for example : question #1 is "rich" , Q2# "Tal" , Q3#"sau".
what i want is to randomize them some times "sau" become Q#1 and so on...
2- if the person answered the right question i dont want to see the question again in the list (unless the person load the form again). for example: "rich" is IT department, if the person choose IT then the quiz continue with the rest of questions " Tal","sau" without the question been answered correctly "rich"
3-i want to move on to the next question directly: in my example: if i choose radio button 1 or 2 or 3 or 4 then i have to click on button 1 to move to the next question.
what i want is to skip the button 1( i want to remove it) and just have the quiz with starting button and 1 label and 4 radio buttons.
for database file:
i dont know how to connect it to data base although i have data base file already from 6 columns. after i load the data base file into the visual basic im not sure how to mingle it with the codes.
therefore please assist me with the normal codes without the database.
thank you very much
What I have tried:
Public Class Form1
Private Structure questionsNanswers
Public Q As String
Public a As String
Public QT As Integer
Public QC As Integer
End Structure
Private wstart As Integer
Private adad As Integer = 10
Private QA(15) As questionsNanswers
Private word(999) As String
Private names(999) As String
Private aray(999) As Integer
Private Sub RandomizeArray(a As Integer, ByRef array() As Integer)
Dim i As Integer
Dim j As Integer
Dim tmp As Integer
Randomize()
For i = 0 To a - 1
j = Int((6 - i + 1) * Rnd() + i)
tmp = array(i)
array(i) = array(j)
array(j) = tmp
Next
End Sub
Private Sub randomize()
Dim r As New Random
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
' next
CheckEntry()
wstart = wstart + 1
If wstart >= adad Then
wstart = 0
End If
WriteText()
randomize()
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
' previous
CheckEntry()
wstart = wstart - 1
If wstart < 0 Then
wstart = adad - 1
End If
WriteText()
End Sub
Private Sub CheckEntry()
RadioButton1.Visible = True
RadioButton2.Visible = True
RadioButton3.Visible = True
RadioButton4.Visible = True
RadioButton1.ForeColor = Color.Black
RadioButton2.ForeColor = Color.Black
RadioButton3.ForeColor = Color.Black
RadioButton4.ForeColor = Color.Black
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
End Sub
Private Sub WriteText()
Dim out As Boolean = False
For kk = 0 To 6
aray(kk) = kk
Next
RandomizeArray(7, aray)
Do Until out
For j = 0 To 3
If out = False Then
If aray(j) = QA(wstart).QT Then
out = True
Exit Do
End If
End If
Next
For kkk = 0 To 6
aray(kkk) = kkk
Next
RandomizeArray(7, aray)
Loop
RadioButton1.Text = word(aray(0))
RadioButton2.Text = word(aray(1))
RadioButton3.Text = word(aray(2))
RadioButton4.Text = word(aray(3))
Label1.Text = QA(wstart).Q
' ==============================
' Dim go As Boolean = False
'If go Then
'Dim msg As String
'For ll = 0 To 6
'msg = msg + CStr(aray(ll)) + "|"
'Next
'MsgBox(msg)
'End If
End Sub
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
'a
word(0) = "TA"
word(1) = "GR"
word(2) = "HR"
word(3) = "FIN"
word(4) = "commercial"
word(5) = "Proc"
word(6) = "IT"
names(0) = "rich"
names(1) = "Tal"
names(2) = "sau"
names(3) = "pat"
names(4) = "del"
'q and wstart means between ( )
QA(0).Q = names(0)
QA(0).a = word(6)
QA(0).QT = 6
QA(0).QC = -1
QA(1).Q = names(1)
QA(1).a = word(1)
QA(1).QT = 1
QA(1).QC = -1
QA(2).Q = names(2)
QA(2).a = word(2)
QA(2).QT = 2
QA(2).QC = -1
QA(3).Q = names(3)
QA(3).a = word(3)
QA(3).QT = 3
QA(3).QC = -1
QA(4).Q = names(4)
QA(4).a = word(5)
QA(4).QT = 5
QA(4).QC = -1
WriteText()
End Sub
Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged
If RadioButton1.Checked Then
If StrComp(QA(wstart).a, RadioButton1.Text) = 0 Then
RadioButton1.ForeColor = Color.Red
RadioButton2.Visible = False
RadioButton3.Visible = False
RadioButton4.Visible = False
End If
End If
' If RadioButton1.ForeColor = Color.Red Then
' End If
' If wstart >= adad Then
'wstart = 0
' End If
'wstart = wstart + 1
' If wstart >= adad Then
'wstart = 0
' End If
End Sub
Private Sub RadioButton2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton2.CheckedChanged
If RadioButton2.Checked Then
If StrComp(QA(wstart).a, RadioButton2.Text) = 0 Then
RadioButton2.ForeColor = Color.Red
RadioButton1.Visible = False
RadioButton3.Visible = False
RadioButton4.Visible = False
End If
End If
End Sub
Private Sub RadioButton3_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton3.CheckedChanged
If RadioButton3.Checked Then
If StrComp(QA(wstart).a, RadioButton3.Text) = 0 Then
RadioButton3.ForeColor = Color.Red
RadioButton1.Visible = False
RadioButton2.Visible = False
RadioButton4.Visible = False
End If
End If
End Sub
Private Sub RadioButton4_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton4.CheckedChanged
If RadioButton4.Checked Then
If StrComp(QA(wstart).a, RadioButton4.Text) = 0 Then
RadioButton4.ForeColor = Color.Red
RadioButton1.Visible = False
RadioButton2.Visible = False
RadioButton3.Visible = False
End If
End If
End Sub
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
End Sub
Private Sub RadioButton1_Click(sender As Object, e As EventArgs) Handles RadioButton1.Click
End Sub
Private Sub RadioButton1_MouseClick(sender As Object, e As MouseEventArgs) Handles RadioButton1.MouseClick
' If RadioButton1.Checked Then
'If StrComp(QA(wstart).a, RadioButton1.Text) = 0 Then
'RadioButton1.ForeColor = Color.Red
'RadioButton2.Visible = False
'RadioButton3.Visible = False
'RadioButton4.Visible = False
'End If
' End If
' moveto()
End Sub
Private Sub moveto()
wstart = wstart + 1
If wstart >= adad Then
wstart = 0
End If
'random()
WriteText()
' If RadioButton1.ForeColor = Color.Red Then MessageBox.Show("correct") Else MessageBox.Show("false")
' If RadioButton2.ForeColor = Color.Red Then Label1.Text = QA(wstart).Q
' If RadioButton3.ForeColor = Color.Red Then Label1.Text = QA(wstart).Q
' If RadioButton3.ForeColor = Color.Red Then Label1.Text = QA(wstart).Q
End Sub
End Class
推荐答案
Sub Main()
Dim questions As New List(Of KeyValuePair(Of String, String))
questions.Add(New KeyValuePair(Of String, String)("What is the capital of England?", "London"))
questions.Add(New KeyValuePair(Of String, String)("What is the capital of France?", "Paris"))
questions.Add(New KeyValuePair(Of String, String)("What is the capital of Germany?", "Berlin"))
Dim qNumber As New Random()
For i As Integer = 0 To 5
Dim qi As Integer = qNumber.Next() Mod questions.Count
Dim qa As KeyValuePair(Of String, String) = questions.ElementAt(qi)
Console.WriteLine(qa.Key)
Console.WriteLine(qa.Value)
Next
Console.ReadLine()
End Sub
更新为VB.NET
Updated for VB.NET
这篇关于随机化MCQ问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!