【发布时间】:2018-05-28 07:06:15
【问题描述】:
Private Sub QuestionNavigation()
rdbA.Checked = False
rdbB.Checked = False
rdbC.Checked = False
rdbD.Checked = False
Dim qDT As DataTable = DTTable("SELECT *", "tblQuestions", "")
numItems = qDT.Rows.Count
If (numItems > 0) Then
If (n < numItems) Then
lblQuestionNumber.Text = "Question {" & (n + 1) & "} of {" & qDT.Rows.Count & "}"
Qid = qDT.Rows(n).Item(0).ToString()
txtQuestion.Text = qDT.Rows(n).Item(1).ToString()
Dim qcDT As DataTable = DTTable("SELECT *", "tblChoices", " WHERE QuestionID='" & Qid & "'")
txtChoiceA.Text = qcDT.Rows(0).Item(2).ToString()
txtChoiceB.Text = qcDT.Rows(1).Item(2).ToString()
txtChoiceC.Text = qcDT.Rows(2).Item(2).ToString()
txtChoiceD.Text = qcDT.Rows(3).Item(2).ToString()
Else
MessageBox.Show("Congratulation! You have completed the exam. Thank you for your cooperation.", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Close()
DisplayForm(frmLogin, frmMain.pnlMain)
End If
End If
End Sub
这是从数据库生成问题到带有圆形按钮的数据网格视图的代码。我已经有了包含正确答案的表格,但我不知道如何将其连接到表格考生的答案中,并且分数将被计算在内。
Dim Score As String
Dim dict As New Dictionary(Of Integer, Integer)
Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
If (answerChoice() <> "") Then
Try
RecordRow("INSERT INTO tblExamineeAnswers(ExamineeID, QuestionID, ExamineeAnswer) VALUES ('" & examineeID & "', '" & Qid & "', '" & (Qid & answerChoice()) & "')")
n += 1
QuestionNavigation()
Dim dt As DataTable = DTTable("SELECT *", "tblExamineeAnswers", "")
For examineeID = 170001 To 170004
For Each row As DataRow In dt.Rows
If examineeID = CInt(row(0)) And row(2).ToString.EndsWith("A") Then
Score += 1
End If
Next
dict.Add(examineeID, Score)
Score = 0
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
MessageBox.Show("Please Select Your Answer", "Answer", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
End If
End Sub
这是按下提交按钮并进入下一个问题的代码。以及如何将所有计算的分数相加并放入另一个表中。
tbl个人信息
ID LastName FirstName Gender Address ContactNo EmailAd Score Name
170001 Padilla John David Male Palina East 639304536 dsd 0
170002 hgdfd fdgffd Female aa 11 1 0
170003 Laguit Mark Angelo Male Pozzorubio 12314 jkwej 0
score 属性是我打算放置要求和的分数的地方。
tblexamineeanswers
ExamineeID QuestionID ExamineeAnswer
170001 Q170001 Q170001A
170001 Q170002 Q170002A
170001 Q170003 Q170003B
170001 Q170004 Q170004B
170002 Q170001 Q170001C
170002 Q170002 Q170002B
170002 Q170003 Q170003B
170002 Q170004 Q170004C
170003 Q170001 Q170001A
170003 Q170002 Q170002B
170003 Q170003 Q170003B
170003 Q170004 Q170004B
这是考生回答的表格。 ExamineeAnswer 上的字母表示他单击了哪个圆形按钮。
tbl选择
QuestionID ChoiceID Choice
Q170001 Q170001A Paragraph
Q170001 Q170001B Sentence
Q170001 Q170001C Word
Q170001 Q170001D Topic
Q170002 Q170002A Masking
Q170002 Q170002B Remembering
Q170002 Q170002C Hearing
Q170002 Q170002D Listening
Q170003 Q170003A Airport
Q170003 Q170003B Canteen
Q170003 Q170003C Garden
Q170003 Q170003D School
Q170004 Q170004A Common
Q170004 Q170004B Communicare
Q170004 Q170004C Communar
此表显示问题的选项。
tbl问题
QuestionID Question
Q170001 A _________ is a group of sentence about one topic...
Q170002 It is a natural process of recieving aural and vis...
Q170003 A specific place to show where the departure and a...
Q170004 The term communication was derived from the term _...
此表格显示带有 ID 的问题
tblanswer
QuestionID ChoiceID
Q170001 Q170001A
Q170002 Q170002A
Q170003 Q170003A
Q170004 Q170004A
此表显示了对特定问题的正确选择/答案。
【问题讨论】:
-
欢迎来到 stackoverflow,停止使用“请在明天之前我需要这个”,在询问之前阅读this
-
@kentLoves 从 Soumesh 提供的链接中读取
-
我的错,我不是故意的。我还是新来的,对不起
-
您设计了数据库吗?我需要对架构有一个清晰的了解。
-
@Mary 我刚刚用数据库编辑了关于它的帖子,你可以看看。
标签: mysql vb.net phpmyadmin xampp