It question

profileGaurav8200
ICTPRG418Sandip1.docx

Queensland International Business Academy

CRICOS Code –01515 RTO Code-5304

ASSESSMENT

Cluster:

Intermediate Programming

Units:

ICTPRG418 Apply intermediate programming skills in another language

Course Name:

ICT50715 - Diploma of Software Development

Training Package:

ICT

Assessment Tool:

Multiple Choice and Written Questions/ Problem Scenario: A1

Candidate must fill this section:

Candidate Name:

Sandip Shrestha

Candidate ID:

201405830

Privacy Release Clause:

“I give my permission for my assessment material to be used in the auditing, assessment validation & moderation Process”

Student signature:

Sandip Date: 15th August,2019

Feedback to student:

Assessment Completion Status

Attempt

Satisfactory

Non-Satisfactory

Date

Assessor’s Signature

Initial attempt

2nd attempt/Re-assessment

Information for Candidate:

· All work is to be entirely of the candidate.

General Information for this assessment:

· Read the instructions for each question very carefully.

· Be sure to PRINT your FULL name & LAST name in every place that is provided.

· Short questions must be answered in the spaces provided.

· For those activities requesting extra evidence such as: research reports, ESSAY reports, etc. The student must attach its own work formatted in double space, Arial 12 pts.

· All activities must be addressed correctly in order to obtain a competence for the unit of competency.

· If the candidate doesn’t understand the assessment, they can request help from the assessor to interpret the assessment.

Re-assessment of Result & Academic Appeal procedures:

If a student at Queensland International Business Academy is not happy with his/ her results, the student may appeal against their result via a written letter, clearly stating the grounds of appeal to the MSS / DSS. This should be submitted after completion of the subject and within 14 days of commencement of the new term.

 

Re-assessment Process:

· An appeal in writing is made to the ACC / MSS providing reasons for re-assessment /appeal.

· ACC / MSS will delegate another faculty member of QIBA to review the assessment.

· The student will be advised of the review result done by another assessor.

· If the student is still not satisfied and further challenges the decision, then a review panel is formed comprising the lecturer/trainer in charge, the ACC, the MSS and the DSS OR if need be an external assessor.

· The Institute will advise the student of the appeal decision within 14 days from the submission date of the appeal. The decision of the panel will be deemed to be final.

· If the student is still not satisfied with the result, the he / she has the right to seek independent advice or follow external mediation option with QIBA’s nominated mediation agency.

· Any student who fails a compulsory subject or appeals unsuccessfully will be required to re-enroll in that subject.

 

The cost of reassessment will be borne by the Institute. The external assessor will base his/her judgement based on principles of assessment. These principles require assessment to be reliable, fair, practical and valid.

 

Academic Appeals:

· If the student is dissatisfied with the outcome of the assessment marking process, he/she has a right to appeal the assessment results.

· The notice of appeal should be in writing addressed to the MSS / ACC and submitted within seven days of notification of the assessment results.

· If the appeal is not lodged in the specified time, the result will stand as marked.

· In emergency circumstances, such as in cases of serious illness or injury, the student must forward a medical certificate in support of a deferred appeal. The notice of appeal must be made within three working days of the concluding date shown on the medical certificate.

· The decision of MSS / ACC will be discussed with the DSS and will be final.

For further information please refer to Student Handbook.

“I understand all the above rules and guidelines for the assessment”

Sandip Shrestha

Sandip

15th August,2019

Full Name

Signature

Date (dd/mm/yyyy)

Submission Details:

The assessment task is due on the date provided by the assessor. Any variations to this arrangement must be approved in writing by your assessor. Submit this document with any required evidence attached. See specifications below for details

Performance objective

The candidate must demonstrate skills, knowledge and understanding of promote the use and implementation of innovative work practices to effect change, as states the unit of competency ICTPRG418. Throughout this program you are to demonstrate knowledge in:

· describe in detail:

· dynamic variables

· medium-size application development

· standard array and file handling algorithms

· user-defined data structures

· describe a limited range of development methodologies and their application

· outline the principles of language development.

And foundation skills in:

Skill

Performance Criteria

Description

Reading

3.1, 3.2, 4.1, 6.1

· Interprets and critically analyses and applies appropriate strategies to construct meaning from texts relating to organisational guidelines and coding standards

Writing

1.2-1.3, 2.1-2.5, 4.1, 4.2, 4.3, 6.1, 6.6

· Communicates complex relationships between ideas and information, matching style of writing to purpose and audience when documenting activities

· Displays knowledge of structure and layout, employing broad vocabulary, grammatical structure and conventions appropriate to text when documenting activities

Navigate the world of work

4.1

· Takes personal responsibility for following explicit and implicit policies, procedures and industry standards

Get the work done

All

· Uses systematic, analytical processes, setting goals, gathering relevant information, and identifying and evaluating options against agreed criteria

· Uses analytical processes to decide on a course of action, establishing criteria for deciding between options

· Uses a systematic process to identify possible solutions to a difficult problem

· Understands key principles and concepts underpinning the design and operation of digital systems and tools

Table: ICT Information and Communications Technology Training Package

Assessment description:

You will develop an application based on given program specification, document the code and test to ensure that it meets requirements.

Procedure:

1 You will need to follow instructions below and address all activities required.

2 This is an individual activity where each candidate will be assessed individually;

3 Complete all activities and submit assessment evidence (Both hard and soft copy including these papers) to your assessor by the date provided (see submission details).

Specifications/Conditions:

Your assessor will be looking for evidence of:

· Design and build application programs to a problem scenario and program specification

· Generate code documentation and test it to confirm that created application meets original specification and solves original problem

OBSERVATION CHECKLIST

Cluster:

Intermediate Programming 2

Unit name:

ICTPRG418 Apply intermediate programming skills in another language

Training Package/Qualification:

ICT50715 - Diploma of Software Development

Assessor Name: HABIBHABIRAHMAN

HABIB RAHMAN

Student ID: 201405830

Student Name: SANDIP SHRESTHA

Date of Assessment:

During the demonstration did the trainee/student:

YES

NO

N/A

Design, define and use data structures that are an aggregate of other data types

Code using an array of user-defined data types

Use the facilities in the language to create, manipulate and destroy dynamic variables, such as arrays

When coding, use a modular programming approach, including pass-by-reference parameter passing

Write code to create and manipulate a 2-D array

Create and maintain a sorted array and use language-provided facilities for sorting an array of ordered elements

Code a simple binary search technique for use with an array of sorted data

Code binary file-handling solutions using random access algorithms

Use stand-alone debugging tools or tools provided by integrated development environment to debug code

Use a debugger to trace code execution and examine variable contents to detect and correct errors

Follow organisational guidelines for developing maintainable code and adhere to the provided coding standard when documenting activities

Apply internal documentation suitable for use by peers to all code created

Use documentation tools available in the target language when documenting activities

Design and document tests

Undertake limited testing of produced code to ensure compliance with program specification

Capture and record test results

Build an application in response to a user requirement

Access multiple source code files

Employ integrated development environment project maintenance facilities or make files to automate program building

Develop a program specification solution when provided with a basic design document

Design the algorithm, and document, construct and test applications in response to a problem description using the language

Document the completed application

Trainee/Student’s performance was:

Satisfactory

Not Satisfactory

Assessor feedback to student:

Student signature and Date: SIRISH

Assessor signature and Date: HABIB RAHMAN

Section 1: Multiple Choice Questions

For each multiple-choice question, circle the correct answer.

1) Which one of the following is true about parameters and arguments?

a) They are completely different in a program.

b) Both terms are identical.

c) Parameters appear in procedure and function definitions; Arguments appear in call statement.

d) Parameters appear in call statement; Arguments appear in procedure and function definitions.

2) Which of the following statements will close the file after the below statement has been executed:

Dim fileRead As IO.FileStream = IO.File.OpenRead(“abc.txt”)

a) fileRead.Close()

b) “abc.txt”.Close()

c) Close fileRead

d) Close “abc.txt”

3) In the statement

Dim marks(15) As Integer

the number 15 represents which one of the following.

a) The total number of elements in the array.

b) The value 15 initially assigned to each element in the array.

c) The maximum value that can be assigned to any element in the array.

d) None of the above.

4) Consider the array given below

Dim data() As Integer = {10,14,15,0,19,100,52,58}

Which one of the following sorts an array in ascending order?

a) Array.Sort(data)

b) data.Sort()

c) Sort(data)

d) Sort().data

5) Which data structure allocates all elements contiguously in memory and keep a count of the current number of elements?

a) Linked List

b) Static array

c) Dynamic array

d) Binary tree

6) Which statement is true regarding the members of a structure (data structure)?

a) A structure may not be placed in a structure

b) The data types of variables in a structure can be different

c) Only three data types (boolean, integer, string,) may be included in a structure.

d) The data types of variables in a structure must be same

7) Which of the following is not the required condition for binary search algorithm?

a) There should be the direct access to the middle element in any collection. b) The collection must be sorted. c) There must be mechanism to delete and/or insert elements in list. d) None of above.

8) Two dimensional arrays are also called

a) tables arrays b) matrix arrays c) none of above d) both of above

9) Binary search algorithm can’t be applied to

a) sorted linear array b) sorted binary trees c) sorted linked list d) sorted dynamic array

Section 2:

Specification and Task

(Covering elements - ICTPRG418 - 1.1, 1.2, 1.3, 2.1, 2.2, 2.3, 2.4, 2.5, 3.1, 3.2, 4.1, 4.2, 4.3, 5.1, 5.2, 5.3, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6)

Driving Knowledge Test Program contain 3 parts:

1) Login

2) Question

3) Test Knowledge and Result

User will login to the system to access the “Driving Knowledge Test” program. According to level, user will get access for 2nd and 3rd part of that. Admin user can Add/Update/Delete question and test their knowledge. Ordinary user only can test their knowledge and check the result.

Using Visual studio and VB.net create a windows application for the “Driving Knowledge Test “. Consider the following naming, layout and commenting conventions when coding:

i) Naming convention

· Begin each separate word in a name with a capital letter, as in FindLastRecord and RedrawMyForm.

· Begin function and method names with a verb, as in InitNameArray or CloseDialog.

· Begin class, structure, module, and property names with a noun, as in EmployeeName or CarAccessory.

· Begin interface names with the prefix "I", followed by a noun or a noun phrase, like IComponent, or with an adjective describing the interface's behavior, like IPersistable. Do not use the underscore, and use abbreviations sparingly, because abbreviations can cause confusion.

· Begin event handler names with a noun describing the type of event followed by the "EventHandler" suffix, as in "MouseEventHandler".

· In names of event argument classes, include the "EventArgs" suffix.

· If an event has a concept of "before" or "after," use a suffix in present or past tense, as in "ControlAdd" or "ControlAdded".

· For long or frequently used terms, use abbreviations to keep name lengths reasonable, for example, "HTML", instead of "Hypertext Markup Language". In general, variable names greater than 32 characters are difficult to read on a monitor set to a low resolution. Also, make sure your abbreviations are consistent throughout the entire application. Randomly switching in a project between "HTML" and "Hypertext Markup Language" can lead to confusion.

· Avoid using names in an inner scope that are the same as names in an outer scope. Errors can result if the wrong variable is accessed. If a conflict occurs between a variable and the keyword of the same name, you must identify the keyword by preceding it with the appropriate type library. For example, if you have a variable called Date, you can use the intrinsic Date function only by calling DateTime.Date.

ii) Layout Conventions

Good layout uses formatting to emphasize the structure of the code and makes code easier to read.

· Use the pretty listing feature to format code with the default settings (smart indenting, 4 character indents, save tabs as spaces).

· Use only one statement per line. Do not use the Visual Basic line continuation character (:).

· Use only one declaration per line.

· If pretty listing does not format continuation lines, indent continuation lines one tab stop.

· Add at least one blank line between method and property definitions.

ii) Commenting Conventions

· Do not use comments at the end of a line of code. Put comments on a separate line.

· Begin the comment text with an uppercase letter.

· End the comment with a period.

· Insert one space between the comment delimiter (') and the comment text.

Task1: Create Windows Application and Design Forms (Graphical Interface for the user)

1) Login: To design a login form, consider the following control.

Control

Name

Property

Value

LoginForm/ Windows Form

Login Form

Text

Driving Knowledge Test Program

Name

Login

StartupPosition

CenterScreen

Label

Label1

name

LBLUserName

Text

User Name

Label

Label2

name

LBLPassword

Text

Password

TextBox

TextBox1

name

TXTUserName

TextBox

TextBox2

name

TXTPassword

Button

Button1

name

BTNLogin

Text

&Login

Button

Button2

name

BTNCancel

Text

&Cancel

Figure 1: Specification of different control

2) Main: Design a “Form” to provide options to the user about Question and Test Knowledge

Control

Name

Property

Value

WindowsForm

Main Form

Text

Driving Knowledge Test Program

Name

Main

StartupPosition

CenterScreen

Button

Button1

name

BTNTest

Text

&Test Your Knowledge

Fore Color

Maroon

Font Size

15

Button

Button2

name

BTNQuestion

Text

&Question

Fore Color

Maroon

Font Size

15

Button

Button3

name

BTNCancel

Text

&Cancel

Fore Color

Maroon

Font Size

15

Figure 2: Specification of different control

3) Add Question: Design a form to add multiple choice questions with result and question number.

Control

Name

Property

Value

WindowsForm

Question Form

Text

Driving Knowledge Test Program

Name

Question

StartupPosition

CenterScreen

Label

Label1

name

LBLQuestionNo

Text

Question Number

TextBox

TextBox1

name

TXTQuestionNo

Label

Label2

name

LBLQuestion

Text

Question

TextBox

TextBox2

Name

TXTQuestion

multiline

true

Label

Label3

name

LBLAnswer1

Text

Answer1

TextBox

TextBox3

Name

TXTAnswer1

Label

Label4

name

LBLAnswer2

Text

Answer2

TextBox

TextBox4

Name

TXTAnswer2

Label

Label5

name

LBLAnswer3

Text

Answer3

TextBox

TextBox5

Name

TXTAnswer3

Label

Label6

name

LBLAnswer4

Text

Answer4

TextBox

TextBox6

Name

TXTAnswer4

Label

Label7

name

LBLCorrectAnswer

Text

Correct Answer

TextBox

TextBox7

name

TXTAnswer5

Button

Button1

name

BTNAdd

Text

&Add

Button

Button2

Name

BTNClose

text

&Close

Button

Button3

name

BTNFind

Text

&Find

Button

Button4

name

BTNUpdate

Text

&Update

Button

Button5

name

BTNDelete

Text

&Delete

Button

Button6

name

BTNSave

Text

&Save

Figure 3: Specification of different control

4) Test Information: Design a form to show information about test and provide option to start or cancel the test.

Control

Name

Property

Value

Windows Form

Information Form

Text

Driving Knowledge Test Program

Name

Test Information

StartupPosition

CenterScreen

Label

Label1

name

LBLInformation

Text

Welcome to the Driver Knowledge Test. The test includes 5 questions. Each question contains 2 points. Total hour is one hour and pass mark 95%

Fore Color

Maroon

Font Size

15

AutoSize

False

Button

Button1

name

BTNStart

Text

&Start

Button

Button2

name

BTNCancel

Text

&Cancel

Figure 4: Specification of different control

5) Test knowledge: Design a form for multiple choice questions.

Control

Name

Property

Value

Windows Form

Test Form

Text

Driving Knowledge Test Program

Name

Test Knowledge

StartupPosition

CenterScreen

Label

Label1

name

LBLQuestion

Text

Question

Label

Label2

name

LBLAnswer1

Text

Answer1

Label

Label3

name

LBLAnswer2

Text

Answer2

Label

Label4

name

LBLAnswer3

Text

Answer3

Label

Label5

name

LBLAnswer4

Text

Answer4

RadioButton

RadioButton 1

name

RBTNAnswerA

Text

Answer A

RadioButton

RadioButton 2

name

RBTNAnswerB

Text

Answer B

RadioButton

RadioButton 3

name

RBTNAnswerC

Text

Answer C

RadioButton

RadioButton 4

Name

RBTNAnswerD

Text

Answer D

Button

Button1

name

BTNnext

Text

&Next

Button

Button2

Name

BTNBack

text

&Back

Button

Button3

Name

BTNClose

text

&Close

Label

Label6

Name

LBLMessage

Text

Message

Button

Button4

Name

BTNSubmit

text

&Submit

Figure 5: Specification of different control

0

6) Result: Design a form to show the total point and the result (pass/fail).

Control

Name

Property

Value

WindowsForm

Result Form

Text

Driving Knowledge Test Program

Name

Result

StartupPosition

CenterScreen

Label

Label1

name

lblUsername

Fore Color

Maroon

Font Size

15

Figure 6: Specification of different control

Task 2: Manipulate data using Control and conditional structure, and data structures – 2D array and dynamic variables. Implement binary search technique and binary file handling algorithms.

1) Login Form:

Store below listed sample user information into a 2-D global array “UserInfo”.

User Name

Password

Status

John

John123

user

Kumary

Krishnan

Admin

Sunate

Sunate001

user

Cathy

CathyRubby

user

Margarate

Margarita

Admin

David

DavidHaug

user

Sunil

Sunil120

Administrator

Login button: Write code to check the username and password from “UserInfo”. If valid, store the user name and status into global variable “gloStrUserstatus”, “gloStrUsername” respectivley and redirect to the Main Form. Otherwise, display a message “Please write a valid user name and password “.

Form Load: Read all the question information from a binary file “Question.dat” and store into arraylist gloTestQuestions. (Implement this functionality after finishing Question form coding)

Public Class LoginForm

' Define 2-D Array.

Dim UserInfo(,) As String = {{"John", "John123", "user"}, {"Kumary", "Krishnan", "Admin"}, {"Sunate", "Sunate001", "user"}, {"Cathy", "CathyRubby", "user"},

{"Margarate", "Margarita", "Admin"}, {"David", "DavidHaug", "user"}, {"Sunil", "Sunil120", "Administrator"}}

' Code for Login Button.

Private Sub BTNLogin_Click(sender As System.Object, e As System.EventArgs) Handles BTNLogin.Click

For i = 0 To UserInfo.GetUpperBound(0)

If (TXTUsername.Text = UserInfo(i, 0) And TXTPassword.Text = UserInfo(i, 1)) Then

gloStrUsername = UserInfo(i, 0)

gloStrUserstatus = UserInfo(i, 2)

MainForm.Show()

Me.Hide()

Exit Sub

End If

Next

MessageBox.Show("Please write a valid user name and password ")

End Sub

Private Sub BTNCancel_Click(sender As System.Object, e As System.EventArgs) Handles BTNCancel.Click

Close()

End Sub

Private Sub LoginForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

' Reads questions stored in binary file and store into arraylist gloTestQuestions.

Try

Dim file As New FileStream(Directory.GetCurrentDirectory() & "\Question.dat", FileMode.Open, FileAccess.Read)

Dim fileRead As New BinaryReader(file)

While fileRead.BaseStream.Position < fileRead.BaseStream.Length

Dim question As Trivia_Data

question.intQuestionNo = fileRead.ReadUInt16()

question.strQuestion = fileRead.ReadString()

question.strAnswer1 = fileRead.ReadString()

question.strAnswer2 = fileRead.ReadString()

question.strAnswer3 = fileRead.ReadString()

question.strAnswer4 = fileRead.ReadString()

question.intCorrectAnswer = fileRead.ReadUInt16()

gloTestQuestions.Add(question)

End While

' Handles file IO exceptions

Catch ex As Exception

MessageBox.Show("There is no quiz exist. Add questions in system for an exam of Driver Knowledge Test Program....")

End Try

End Sub

End Class

2) Main Form:

Question Button: Redirect to the “Question Form” if logged on user is in administrator role otherwise inform user is not allowed to do that.

Knowledge Test Button: Redirect to the “Information form”

Public Class MainForm

' Navigates to test information.

Private Sub BTNTest_Click(sender As System.Object, e As System.EventArgs) Handles BTNTest.Click

'TestInformationForm.Show()

MessageBox.Show("Form not ready yet.")

'Me.Close()

End Sub

' Navigates to Question for based on role (status) of user.

Private Sub BTNQuestion_Click(sender As System.Object, e As System.EventArgs) Handles BTNQuestion.Click

If gloStrUserstatus = "user" Then

MessageBox.Show("User is not allowed to add new question.")

Exit Sub

Else

QuestionForm.Show()

End If

End Sub

' Closes current form

Private Sub BTNClose_Click(sender As System.Object, e As System.EventArgs) Handles BTNClose.Click

Close()

End Sub

3) Information Form:

Start Button: Redirect to the “Test Form”.

Cancel Button: Redirect to the Main form.

Public Class TestInformationForm

Private Sub BTNCancel_Click(sender As System.Object, e As System.EventArgs) Handles BTNCancel.Click

Close()

End Sub

Private Sub BTNStart_Click(sender As System.Object, e As System.EventArgs) Handles BTNStart.Click

Close()

TestForm.Show()

End Sub

End Class

4) Question Form:

Create a sub procedure ClearText() to clear all text boxes. Display the possible question number for new question into the text box for question number.

Add Button: Write code to add question information into a global/public arraylist “gloTestQuestions”.Clear all text box content.

Hint: Create a global structure Trivia_Data to hold pieces of question information i.e. question number, question, 4 answers choices and correct answer.

Find Button: Implement binary search technique to find question information from the gloTestQuestions according to the question no provided and display into the related text boxes.

Update Button: Save updated information for question identified by question number into the arraylist.

Delete Button: Delete question according to the question number from the arraylist.

Save Button: Write all the question information from the arraylist gloTestQuestions to a binary file “Question.dat”.

Exit Button: Close Question form and redirect to “Main Form”.

Public Class QuestionForm

' Holds question number of question currently being updating or deleting.

Dim currentlyEditingDeleteingQueNo As Integer

Private Sub QuestionForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

TXTQuestionNo.Enabled = False

TXTQuestionNo.Text = gloTestQuestions.Count + 1

Fill_Grid()

End Sub

' Insert a new question in array list.

Private Sub BTNAdd_Click(sender As System.Object, e As System.EventArgs) Handles BTNAdd.Click

Dim question As Trivia_Data

question.intQuestionNo = TXTQuestionNo.Text

question.strQuestion = TXTQuestion.Text

question.strAnswer1 = TXTAnswer1.Text

question.strAnswer2 = TXTAnswer2.Text

question.strAnswer3 = TXTAnswer3.Text

question.strAnswer4 = TXTAnswer4.Text

question.intCorrectAnswer = Integer.Parse(TXTAnswer5.Text)

gloTestQuestions.Add(question)

Fill_Grid()

MessageBox.Show("Question inserted successfully....")

ClearText()

End Sub

' Clears all text boxes for next question and displays possible question for it.

Private Sub ClearText()

TXTAnswer1.Clear()

TXTAnswer2.Clear()

TXTAnswer3.Clear()

TXTAnswer4.Clear()

TXTAnswer5.Clear()

TXTQuestion.Clear()

TXTQuestionNo.Clear()

TXTQuestionNo.Text = gloTestQuestions.Count + 1

End Sub

' Fills data grid view controls with available questions in a system.

Private Sub Fill_Grid()

Dim dt As DataTable

dt = New DataTable()

dt.Columns.Add("Question Number")

dt.Columns.Add("Question")

dt.Columns.Add("Answer1")

dt.Columns.Add("Answer2")

dt.Columns.Add("Answer3")

dt.Columns.Add("Answer4")

dt.Columns.Add("CorrectAnswer")

Dim question As Trivia_Data

For j = 0 To gloTestQuestions.Count - 1

dt.Rows.Add()

question = CType(gloTestQuestions(j), Trivia_Data)

dt.Rows(j)("Question Number") = question.intQuestionNo.ToString()

dt.Rows(j)("Question") = question.strQuestion

dt.Rows(j)("Answer1") = question.strAnswer1

dt.Rows(j)("Answer2") = question.strAnswer2

dt.Rows(j)("Answer3") = question.strAnswer3

dt.Rows(j)("Answer4") = question.strAnswer4

dt.Rows(j)("CorrectAnswer") = question.intCorrectAnswer

Next

DataGridView1.DataSource = dt

End Sub

' Searchs a question by user supplied question number using binary search technique.

Private Sub BTNFind_Click(sender As System.Object, e As System.EventArgs) Handles BTNFind.Click

Dim totalAddedQuestion As Integer = gloTestQuestions.Count

Dim questionNo = InputBox("Enter the question number that you want to search:")

If questionNo > gloTestQuestions.Count Or questionNo = 0 Then

MessageBox.Show("Question doesn't exist..........")

ClearText()

Exit Sub

Else

Dim compare As New ArrayListIntegerComparere

gloTestQuestions.Sort(compare)

Fill_Grid()

Dim max As Integer

Dim min As Integer

Dim mid As Integer

min = 0

max = totalAddedQuestion - 1

While (max >= min)

mid = (min + max) / 2

Dim question As Trivia_Data = CType(gloTestQuestions(mid), Trivia_Data)

If question.intQuestionNo < questionNo Then

min = mid + 1

ElseIf question.intQuestionNo > questionNo Then

max = mid - 1

Else

TXTAnswer1.Text = question.strAnswer1

TXTAnswer2.Text = question.strAnswer2

TXTAnswer3.Text = question.strAnswer3

TXTAnswer4.Text = question.strAnswer4

TXTAnswer5.Text = question.intCorrectAnswer

TXTQuestion.Text = question.strQuestion

TXTQuestionNo.Text = question.intQuestionNo

currentlyEditingDeleteingQueNo = mid

MessageBox.Show("Question found............")

BTNUpdate.Enabled = True

BTNDelete.Enabled = True

Exit Sub

End If

End While

End If

MessageBox.Show("Question doesn't exist.................")

ClearText()

End Sub

' Saves questions in binary file and closes the file after writing operations.

Private Sub BTNSave_Click(sender As System.Object, e As System.EventArgs) Handles BTNSave.Click

Dim file As New FileStream(Directory.GetCurrentDirectory() & "\Question.dat", FileMode.Create, FileAccess.Write)

Dim fileWrite As BinaryWriter = New BinaryWriter(file)

Dim question As Trivia_Data

For i = 0 To gloTestQuestions.Count - 1

question = CType(gloTestQuestions(i), Trivia_Data)

fileWrite.Write(Convert.ToInt16(question.intQuestionNo))

fileWrite.Write(question.strQuestion)

fileWrite.Write(question.strAnswer1)

fileWrite.Write(question.strAnswer2)

fileWrite.Write(question.strAnswer3)

fileWrite.Write(question.strAnswer4)

fileWrite.Write(Convert.ToInt16(question.intCorrectAnswer))

Next

fileWrite.Close()

file.Close()

MessageBox.Show("Questions saved in file successfully..........")

End Sub

' Updates exisitng question as per newly provided values.

Private Sub BTNUpdate_Click(sender As System.Object, e As System.EventArgs) Handles BTNUpdate.Click

Dim question As Trivia_Data = CType(gloTestQuestions(currentlyEditingDeleteingQueNo), Trivia_Data)

question.strAnswer1 = TXTAnswer1.Text

question.strAnswer2 = TXTAnswer2.Text

question.strAnswer3 = TXTAnswer3.Text

question.strAnswer4 = TXTAnswer4.Text

question.intCorrectAnswer = Integer.Parse(TXTAnswer5.Text)

question.strQuestion = TXTQuestion.Text

gloTestQuestions(currentlyEditingDeleteingQueNo) = question

MessageBox.Show("Question updated successfully...................")

BTNUpdate.Enabled = False

BTNDelete.Enabled = False

ClearText()

Fill_Grid()

End Sub

' Deletes a current question from the arraylist.

Private Sub BTNDelete_Click(sender As System.Object, e As System.EventArgs) Handles BTNDelete.Click

gloTestQuestions.RemoveAt(currentlyEditingDeleteingQueNo)

Fill_Grid()

ClearText()

MessageBox.Show("Question removed successfully.....")

BTNDelete.Enabled = False

BTNUpdate.Enabled = False

End Sub

' Closes the Question form

Private Sub BTNClose_Click(sender As System.Object, e As System.EventArgs) Handles BTNClose.Click

Me.Close()

End Sub

End Class

5) Test Form:

Retrieve first question information from the arraylist and display into appropriate textboxes and radio buttons.

Back Button: Write code to display the previous question of the exam.

Next Button: Write code to store each question answer (right answer = 1, and wrong answer=0) into a global one dimensional array gloSubmittedAnswers() and display the next question. Display messages “You have finished all questions. Go back for review or submit the test and get the result” into the “message label” on last question.

Submit Button: Redirect to the “Result Form”

Cancel Button: Redirect to the “Main Form”

Public Class TestForm

' Keeps track of currently displayed question.

Dim intCurrentQuestion As Integer

' Displays 1st question when form loads

Private Sub TestForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

intCurrentQuestion = 0

DisplayQuestion(intCurrentQuestion)

End Sub

' Dispalys question whose question number specified by variable que.

Private Sub DisplayQuestion(ByVal que As Integer)

Dim question As Trivia_Data = CType(gloTestQuestions(que), Trivia_Data)

LBLQuestion.Text = question.intQuestionNo.ToString() + " " + question.strQuestion

RBTNAnswerA.Text = question.strAnswer1

RBTNAnswerB.Text = question.strAnswer2

RBTNAnswerC.Text = question.strAnswer3

RBTNAnswerD.Text = question.strAnswer4

End Sub

' Redirects to next question.

Private Sub BTNNext_Click(sender As System.Object, e As System.EventArgs) Handles BTNNext.Click

SubmitAnswer()

If intCurrentQuestion = gloTestQuestions.Count - 1 Then

MessageBox.Show("Last question..........")

LBLMessage.Text = "You have finished all questions. Go back for review or submit the test and get the result"

Exit Sub

End If

intCurrentQuestion = intCurrentQuestion + 1

DisplayQuestion(intCurrentQuestion)

End Sub

' Redirects to previous question.

Private Sub BTNBack_Click(sender As System.Object, e As System.EventArgs) Handles BTNBack.Click

SubmitAnswer()

If intCurrentQuestion = 0 Then

MessageBox.Show("First question...........")

Exit Sub

End If

intCurrentQuestion = intCurrentQuestion - 1

DisplayQuestion(intCurrentQuestion)

End Sub

' Stores the answer of current question submitted by user in gloSubmittedAnswers arraylist.

Private Sub SubmitAnswer()

Dim answer As Integer

If RBTNAnswerA.Checked = True Then

answer = 1

End If

If RBTNAnswerB.Checked = True Then

answer = 2

End If

If RBTNAnswerC.Checked = True Then

answer = 3

End If

If RBTNAnswerD.Checked = True Then

answer = 4

End If

If CType(gloTestQuestions(intCurrentQuestion), Trivia_Data).intCorrectAnswer = answer Then

gloSubmittedAnswers.Add(1)

Else

gloSubmittedAnswers.Add(0)

End If

End Sub

Private Sub BTNQuit_Click(sender As System.Object, e As System.EventArgs) Handles BTNQuit.Click

Close()

End Sub

' Displays Result form.

Private Sub BTNSubmit_Click(sender As System.Object, e As System.EventArgs) Handles BTNSubmit.Click

Me.Close()

ResultForm.Show()

End Sub

End Class

6) Result Form: Calculate the total marks and display the result (Pass/Fail and total marks) into the User Name Label.

Hint: Total Marks = Total number of right question * 2, Pass mark > = 95%

Use mechanism to destroy dynamic arrays.

Public Class ResultForm

' Calculates the result as per given specification and dispalys result

Private Sub Welcome_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim totalCorrectAns As Integer = 0

For i = 0 To gloTestQuestions.Count - 1

If gloSubmittedAnswers(i) = 1 Then

totalCorrectAns = totalCorrectAns + 1

End If

Next

Dim totalMarks As Integer = ((totalCorrectAns * 2) * 100) / (gloTestQuestions.Count * 2)

If totalMarks >= 95 Then

lblUsername.Text = "Congratulation " & gloStrUsername & ". You have got " & totalMarks & "% marks and passed in this test."

Else

lblUsername.Text = "Sorry " & gloStrUsername & ". You have got " & totalMarks & "% marks and failedd in this test"

End If

End Sub

' Destroys arraylist elements and stops application debugging.

Private Sub ResultForm_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing

gloTestQuestions.Clear()

Application.Exit()

End Sub

End Class

Task 3: Debug application

Use Visual Studio debugging tools to detect syntax and logical errors, trace code and examine variable contents.

Module GlobalModule

' Global variable to store user infromation.

Public gloStrUserstatus As String

Public gloStrUsername As String

' Global structure to represent question.

Public Structure Trivia_Data

Dim intQuestionNo As Integer

Dim strQuestion As String

Dim strAnswer1 As String

Dim strAnswer2 As String

Dim strAnswer3 As String

Dim strAnswer4 As String

Dim intCorrectAnswer As Integer

End Structure

' Global variable to store questions of test

Public gloTestQuestions As New ArrayList

' Global variable to store answers submitted by user

Public gloSubmittedAnswers As New ArrayList

End Module

'comparer class for sort on inetegr data fucntionality of arraylist

Public Class ArrayListIntegerComparere

: Implements IComparer

Public Function Compare(x As Object, y As Object) As Integer Implements System.Collections.IComparer.Compare

Dim a As New CaseInsensitiveComparer()

If IsNumeric(x) And IsNumeric(y) Then

Return CInt(y).CompareTo(x)

Else

Return (Compare(CType(y, Trivia_Data).intQuestionNo, CType(x, Trivia_Data).intQuestionNo))

End If

End Function

End Class

'comparer class for sort on string data fucntionality of arraylist

Public Class StringComparer

: Implements IComparer

Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare

Return x(1).CompareTo(y(1))

End Function

End Class

Task 4: Testing

Design test cases to confirm code meets the program specification. You are allowed to use any type of tools to design test cases such as debugger, MS office tools, etc. Your designed test cases should reflect the design specification and also MUST include the following:

· TestID

· Test description with required steps

· Expected outcomes

· Actual outcomes

· Pass/Fail results

Example of test case:

Test ID: FT_1 *(Note: F1 = functionality testing, 1 = test case number)

Test Description: Verify login functionality

Steps

Actions

Expected Result

Actual Result

Pass/Fail

1

Form Load

“Login window” will be displayed

“login window” displayed as excepted.

PASS

2

Enter login name and password in appropriate text boxes and click on “Login” button

If supplied user name and password are valid, user will successfully have logged in the system and can access further part of the system otherwise he will be asked to try again for login functionality.

User logged in successfully with valid username and password combination to access the DKT system.

PASS

You are required to conduct the testing based on your described test cases and write the test results in Actual outcomes and Pass/Fail results for each test case.

Task 5: Documentation

Follow Visual Basic commenting conventions and write internal comments for all created code using documentation tools available in the Visual Studio. Document the completed application.

QIBA-ICTPRG418-A-V2018.1 | Page of