Start by creating some extra criteria for your new enhanced quiz engine.
Example:
Quiz Engine Requirements
User is greeted by splash page.
Quizzes are multiple choice. One question per screen.
User can see the results on the screen in a detailed grid.
Results are stored in a SQL Server Database.
The user can exit the program before the quiz is finished.
List the pages, controls, files and databases necessary to complete the project.
Example:
Welcome Page
Question Page
SQL Server Database
-Welcome Page
--button to navigate to question page
-Question page
--question description label
--results description label
--total score label
--3 radio buttons with 3 descriptions
--GridView
--submit button
--exit button
-Quiz Database
--Quiz Table
---question id
---question description
---question answer1 ID
---question answer1 Description
---question answer2 ID
---question answer2 Description
---question answer3 ID
---question answer3 Description
---question correct answer ID
--UserScore Table
---RowID
---UserID
---UserName
---QuestionDescription
---UserAnswerID
---UserAnswerDescription
---QuizCorrectQuestionID
---QuizCorrectQuestionDescription
---UserQuestionScore
Use the code from "Create a Basic Quiz Engine (part1)" to create a new project. Add a "UserScore" table to the Quiz database.
Create a new class for the new "UserScore" list.
Example:
class UserScore { public int intRowID { get; set; } public int intUserID { get; set; } public string strUserName { get; set; } public string strQuestionDescription { get; set; } public int intUserAnswerID { get; set; } public string strUserAnswerDescription { get; set; } public int intQuizCorrectQuestionID { get; set; } public string strQuizCorrectDescription { get; set; } public int intUserQuestionScore { get; set; } }
Hard code the user name and ID for this version.
Example:
int intUserID = 1; string strUserName = "harry";
Load the questions and uncheck the radio buttons.
Populate the radio buttons and description label with the first question.
Example:
public QuestionPage() { InitializeComponent(); ClearUserScoreTable(); ReadQuestionTable(); foreach (Question objQuestion in QuestionRowList) { if (objQuestion.intQuestionID == intTestQuestionNumber) { lblQuestion.Text = objQuestion.strQuestionDescription; strQuestionDescription = objQuestion.strQuestionDescription; radioButton1.Text = objQuestion.strAnswer1Description; radioButton2.Text = objQuestion.strAnswer2Description; radioButton3.Text = objQuestion.strAnswer3Description; intCorrectQuestionID = objQuestion.intCorrectAnswerID; strCorrectQuestionDescription = objQuestion.strCorrectAnswerDescription; } }// end foreach radioButton1.Checked = false; radioButton2.Checked = false; radioButton3.Checked = false; }// end QuestionPage()
Click here for the project code. Just create a SQL Server database with test data, edit the connection string and run it.
No comments:
Post a Comment