Visual Basic Help. If code and screenshots of both forms can be included that wo
ID: 3863146 • Letter: V
Question
Visual Basic Help. If code and screenshots of both forms can be included that would be helpful. Thank you.
Create a VB windows desktop application to make online tests. This application will be catering to an instructor interested in making online tests. That means it is used to create a test but not to deploy tests.
Types of questions: Multiple choice (MC), and True and False (TF). Fill in (a) blank (FIB), Short answer/ Essay (SA)
General Specifications:
1. Ask user for username
2. Ask user for a test name
3. Create a new text file named userName_testName.txt
Make sure that you use some unique combination of user and test name.
4. For every question there must be a question box and a feedback box . The latter can be used for providing optional feedback for the test taker. Both must allow multiple lines of text.
5. You must have a SAVE button for saving the question and answers. Saving will make changes to the text file and save the questions and options/answers to the text file.
6. Reset button allows the user to reset the question and answers.
7. Allow instructor (user) to choose between MC, TF, FIB, SA. You can use a MENUSTRIP for this. Display a BLANK FORM with just a menustrip option before the choice between MC or TF is made (make all go invisible). After the question type is chosen, display only part of form related to the choice along with MENUSTRIP. So if MC is chosen, do not display the TF, FIB or SA parts.
MC:
Allow teacher to enter up to as many ANSWER choices as desired. Each answer can be only one word long. The possible answers can be entered in a text-box.
Each possible answer for MC must have a checkbox following it to indicate answer choice.
Answers must be exactly one word long . Display a message to indicate that the answers are longer than a word and needed to be fixed.
Application needs to ensure that same answer is not being entered in more than one text box.
Force the application to check at least one answer has been marked as the correct choice in MC
Force the application to provide at least 2 choices in MC
TF
If the user choses TF question, it must be allowed to choose only one correct answer, either true or false.
On pressing SAVE button you must check that it has been indicated if question statement is a TRUE or a FALSE.
FIB
Only one blank is required. Allowing user to provide more than one blank is optional.
Ensure that the user provides the correct answer to the blank.
The answer must be exactly one word long.
SA
Allow user to provide key words for correct answer/s
Explanation / Answer
VB desktop application to make online tests
For using the user name ypu should use the following code for last name and first name
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("please fill the blanks")
Exit Sub
End If
End Sub
'this for exit buttons
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
For using reset the form and submit form
If Me.TextBox1.Text = "First name entered!"
Me.TextBox2.Text = "Last name entered!"
Then
Dim frm = New Form1
frm.Show()
Me.Close()
End If
-----------------------------------
Option Strict On
Public Class Form2
Dim TestAboutMe As New Quiz3x
Friend WithEvents QuizStart, AnswerSubmit As New System.Windows.Forms.Button
Friend WithEvents RadioButton1, RadioButton2, RadioButton3, RadioButton4 As New System.Windows.Forms.RadioButton
Friend WithEvents Label1 As New System.Windows.Forms.Label
Private Sub Form2_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.Dispose()
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Width = 297 : Me.Height = 389 : Label1.Top = 0
Label1.Text = "Click 'Start Quiz' to begin the quiz."
Label1.Width = Me.Width
RadioButton1.Top = Label1.Top + Label1.Height
RadioButton2.Top = RadioButton1.Top + RadioButton1.Height
RadioButton3.Top = RadioButton2.Top + RadioButton2.Height
RadioButton4.Top = RadioButton3.Top + RadioButton3.Height
RadioButton1.Width = Me.Width : RadioButton2.Width = Me.Width
RadioButton3.Width = Me.Width : RadioButton4.Width = Me.Width
RadioButton1.Checked = False : RadioButton2.Checked = False
RadioButton3.Checked = False : RadioButton4.Checked = False
RadioButton1.Visible = False : RadioButton2.Visible = False
RadioButton3.Visible = False : RadioButton4.Visible = False
AnswerSubmit.Visible = False
AnswerSubmit.Top = Me.ClientRectangle.Height - AnswerSubmit.ClientRectangle.Height
QuizStart.Top = Me.ClientRectangle.Height - QuizStart.ClientRectangle.Height
QuizStart.Text = "Start Quiz" : AnswerSubmit.Text = "Submit Answer"
Me.Controls.Add(AnswerSubmit) : Me.Controls.Add(QuizStart)
Me.Controls.Add(RadioButton1) : Me.Controls.Add(RadioButton2)
Me.Controls.Add(RadioButton3) : Me.Controls.Add(RadioButton4)
Me.Controls.Add(Label1) : AnswerSubmit.Visible = False
AddHandler QuizStart.Click, AddressOf QuizStart_Click
AddHandler AnswerSubmit.Click, AddressOf AnswerSubmit_Click
End Sub
Private Sub QuizStart_Click(sender As System.Object, e As System.EventArgs)
ResetQuiz() : UpdateQuestion() : QuizStart.Visible = False : AnswerSubmit.Visible = True
End Sub
Private Sub AnswerSubmit_Click(sender As System.Object, e As System.EventArgs)
Dim Answer As Integer = 0
If RadioButton1.Checked = True Then Answer = 1
If RadioButton2.Checked = True Then Answer = 2
If RadioButton3.Checked = True Then Answer = 3
If RadioButton4.Checked = True Then Answer = 4
Select Case Answer
Case 1 : TestAboutMe.GradeQuestion(RadioButton1.Text)
UpdateQuestion()
Case 2 : TestAboutMe.GradeQuestion(RadioButton2.Text)
UpdateQuestion()
Case 3 : TestAboutMe.GradeQuestion(RadioButton3.Text)
UpdateQuestion()
Case 4 : TestAboutMe.GradeQuestion(RadioButton4.Text)
UpdateQuestion()
Case Else : MsgBox("You must check an answer!")
End Select
Select Case TestAboutMe.TestComplete
Case True
RadioButton1.Text = "" : RadioButton2.Text = ""
RadioButton3.Text = "" : RadioButton4.Text = ""
Label1.Text = Math.Round((TestAboutMe.CorrectAnswers / TestAboutMe.TotalQuestions) * 100, 2) & "% You got " & TestAboutMe.CorrectAnswers & " question(s) out of " & TestAboutMe.TotalQuestions & " right."
RadioButton1.Checked = False : RadioButton2.Checked = False
RadioButton3.Checked = False : RadioButton4.Checked = False
RadioButton1.Visible = False : RadioButton2.Visible = False
RadioButton3.Visible = False : RadioButton4.Visible = False
AnswerSubmit.Visible = False : QuizStart.Visible = True
Case Else
RadioButton1.Checked = False : RadioButton2.Checked = False
RadioButton3.Checked = False : RadioButton4.Checked = False
End Select
End Sub
Sub ResetQuiz()
TestAboutMe.Clear()
TestAboutMe.AddQuestion( Quiz.Question("What is 2 x 1 ?", {"2", "3", "5", "7"}.ToList, "2"))
TestAboutMe.AddQuestion( Quiz.Question("What is 2 x 2 ?", {"3", "5", "4", "7"}.ToList, "4"))
TestAboutMe.AddQuestion( Quiz.Question("What is 2 x 3 ?", {"6", "99", "7", "1"}.ToList, "6"))
TestAboutMe.AddQuestion( Quiz.Question("What is 2 x 4 ?", {"8", "0", "9", "2"}.ToList, "8"))
TestAboutMe.AddQuestion( Quiz.Question("What is 2 x 5 ?", {"12", "10", "5", "7"}.ToList, "10"))
TestAboutMe.AddQuestion( Quiz.Question("What is 2 x 6 ?", {"6", "66", "666", "12"}.ToList, "12"))
TestAboutMe.AddQuestion( Quiz.Question("What is 2 x 7 ?", {"13", "15", "14", "55"}.ToList, "14"))
TestAboutMe.AddQuestion( Quiz.Question("What is 2 x 8 ?", {"15", "14", "17", "16"}.ToList, "16"))
TestAboutMe.AddQuestion( Quiz.Question("What is 2 x 9 ?", {"17", "18", "12", "33"}.ToList, "18"))
TestAboutMe.AddQuestion( Quiz.Question("What is 2 x 10 ?", {"20", "18", "19", "22"}.ToList, "20"))
TestAboutMe.AddQuestion( Quiz.Question("What is 2 x 11 ?", {"23", "24", "22", "32"}.ToList, "22"))
TestAboutMe.AddQuestion( Quiz.Question("What is 2 x 12 ?", {"23", "24", "25", "12"}.ToList, "24"))
RadioButton1.Checked = False : RadioButton2.Checked = False
RadioButton3.Checked = False : RadioButton4.Checked = False
RadioButton1.Visible = True : RadioButton2.Visible = True
RadioButton3.Visible = True : RadioButton4.Visible = True
End Sub
Sub UpdateQuestion()
TestAboutMe.NextQuestion()
Label1.Text = TestAboutMe.CurrentQuestion.Question
RadioButton1.Text = TestAboutMe.CurrentQuestion.Choices(0)
RadioButton2.Text = TestAboutMe.CurrentQuestion.Choices(1)
RadioButton3.Text = TestAboutMe.CurrentQuestion.Choices(2)
RadioButton4.Text = TestAboutMe.CurrentQuestion.Choices(3)
End Sub
End Class
Public Class Quiz3x
Private Property _Questions As New List(Of Question)
Private Index As Integer = 0
Private _CurrentQuestion As Question
Private Property _CorrectAnswers As Integer = 0
Private Property _TestComplete As Boolean = False
Public ReadOnly Property TestComplete As Boolean
Get
Return _TestComplete
End Get
End Property
Public ReadOnly Property CurrentQuestion As Question
Get
Return _CurrentQuestion
End Get
End Property
Public ReadOnly Property TotalQuestions As Integer
Get
Return _Questions.Count
End Get
End Property
Public ReadOnly Property CorrectAnswers As Integer
Get
Return _CorrectAnswers
End Get
End Property
Public ReadOnly Property Questions As List(Of Question)
Get
Return _Questions
End Get
End Property
Public Sub NextQuestion()
Dim TmpIndex As Integer = Index
Index = Index + 1
If TmpIndex > Questions.Count - 1 Then
_TestComplete = True
Exit Sub
End If
_CurrentQuestion = Questions(TmpIndex)
End Sub
Public Sub AddQuestion(ByVal Question As Question)
_Questions.Add(Question)
End Sub
Public Sub GradeQuestion(ChosenAnswer As String)
If ChosenAnswer = CurrentQuestion.CorrectAnswer Then
_CorrectAnswers = _CorrectAnswers + 1
End If
End Sub
Public Sub Clear()
_Questions.Clear()
Index = 0
_CorrectAnswers = 0
_TestComplete = False
End Sub
Class Question
Private _Question As String
Private _Choices As New List(Of String)
Private _CorrectAnswer As String
Public ReadOnly Property Question As String
Get
Return _Question
End Get
End Property
Public ReadOnly Property Choices As List(Of String)
Get
Return _Choices
End Get
End Property
Public ReadOnly Property CorrectAnswer As String
Get
Return _CorrectAnswer
End Get
End Property
Sub New(Question As String, Choices As List(Of String), CorrectAnswer As String)
_Question = Question
_Choices = Choices
_CorrectAnswer = CorrectAnswer
End Sub
End Class
End Class
------------------------------------------------------
SAVE IT AS APP
Public Class APP
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
End Sub
End Class
----------------------------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.