4
Answers

Need help with scoring and calculating a quiz

Mike Sanders

Mike Sanders

15y
4.1k
1

I created a trivia page and need help with calculating the number of correct answers vs wrong answers. when customers click the summary button. How ever i also created a submit buttton for each question but i dont like that idea. I would like the users to answers the questions and then hit a submit button or summary and then it totals their score

Below is my code. Please advice

 

protected void Q1btnSubmit_Click(object sender, EventArgs e)

{

if(RadioButtonList1.SelectedIndex >-1)

{

if (RadioButtonList1.SelectedIndex == 0)

lblQ1Message.Text = "You Selected: " + RadioButtonList1.SelectedItem ;

else

lblQ1Message.Text = "Sorry that incorrect";

}

else

lblQ1Message.Text = "Please make a selection";

}

protected void Q2btnButton_Click(object sender, EventArgs e)

{

if(RadioButtonList2.SelectedIndex >-1)

{

if (RadioButtonList2.SelectedIndex == 2)

 

lblQ2Message.Text = "You Selected: " + RadioButtonList2.SelectedItem ;

else

lblQ2Message.Text = "Sorry that incorrect";

}

else

lblQ2Message.Text = "Please make a selection";

}

protected void Q3btnSubmit_Click(object sender, EventArgs e)

{

if (RadioButtonList3.SelectedIndex > -1)

{

if (RadioButtonList3.SelectedIndex == 4)

 

lblQ3Message.Text = "You Selected: " + RadioButtonList3.SelectedItem;

else

lblQ3Message.Text = "Sorry that incorrect";

}

else

lblQ3Message.Text = "Please make a selection";

}

protected void Q4btnSubmit_Click(object sender, EventArgs e)

{

if (RadioButtonList4.SelectedIndex > -1)

{

if (RadioButtonList4.SelectedIndex == 3)

 

lblQ4Message.Text = "You Selected: " + RadioButtonList4.SelectedItem;

else

lblQ4Message.Text = "Sorry that incorrect";

}

else

lblQ4Message.Text = "Please make a selection";

}

protected void Q5btnSubmit_Click(object sender, EventArgs e)

{

if (RadioButtonList5.SelectedIndex > -1)

{

if (RadioButtonList5.SelectedIndex == 0)

 

lblQ5Message.Text = "You Selected: " + RadioButtonList5.SelectedItem;

else

lblQ5Message.Text = "Sorry that incorrect";

}

else

lblQ5Message.Text = "Please make a selection";

}

protected void Q6btnSubmit_Click(object sender, EventArgs e)

{

if (RadioButtonList6.SelectedIndex > -1)

{

if (RadioButtonList6.SelectedIndex == 3)

 

lblQ6Message.Text = "You Selected: " + RadioButtonList6.SelectedItem;

else

lblQ6Message.Text = "Sorry that incorrect";

}

else

lblQ6Message.Text = "Please make a selection";

}

protected void Button1_Click(object sender, EventArgs e)

{

}

protected void btnSummary_Click(object sender, EventArgs e)

{

}

Answers (4)