kindly make correction in my codings..
Dear All,
I designed the below form to display the quiz questions...
All labels for displaying questions and Radio button for displaying four different option for each questions.
Asp.net using c# coding back end is ms sql server
QUIZQUESTIONS FORM
LABEL
RADIOBUTTON1
RADIOBUTTON2 (Total number of question is 5)
RADIOBUTTON3
RADIOBUTTON4
label(maximum marks) label(your marks)
label (for displaying the maximum mark 5) textbox(to display marks scored by the student who attended quiz)
Button(submit)
Button(list of programs)
I completed my codings upto displaying all the five questions.
After that,(I need codings for the below process).........
when the student answered for all the five quiz questions then they should click the submit button.After clicking the submit button their marks should be calculated and displayed in the textbox below your marks.
I put codings for the above procedure, But i have error in my coding kindly correct my errors. I just tried i am not sure whether the coding is right or not. Kindly help me to improve my coding knowledge.
NOTE: i stored my four option in database like ans1,ans2,ans3,ans4.
Apart from four answer one answer will be right answer that is stored in correctans.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace WebApplication15
{
public partial class WebForm2 : System.Web.UI.Page
{
public static String[] ans = new String[5];
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
string practicallab = Request.QueryString["practicallab"];
string sub_topic = Request.QueryString["subtopic"];
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=c:\\Users\\studio\\Documents\\Visual Studio 2008\\Projects\\WebApplication15\\WebApplication15\\App_Data\\Database1.mdf;Integrated Security=True;User Instance=True";
con.Open();
SqlCommand cmd = new SqlCommand("select top 5 * from " + practicallab + " where subtopic ='" + sub_topic + "' order by newid()", con);
SqlDataReader adp;
adp = cmd.ExecuteReader();
if (adp.Read())
{
Label14.Text = adp["ques"].ToString();
RadioButton1.Text = adp["ans1"].ToString();
RadioButton2.Text = adp["ans2"].ToString();
RadioButton3.Text = adp["ans3"].ToString();
RadioButton4.Text = adp["ans4"].ToString();
}
if (adp.Read())
{
Label15.Text = adp["ques"].ToString();
RadioButton5.Text = adp["ans1"].ToString();
RadioButton6.Text = adp["ans2"].ToString();
RadioButton7.Text = adp["ans3"].ToString();
RadioButton8.Text = adp["ans4"].ToString();
}
if (adp.Read())
{
Label16.Text = adp["ques"].ToString();
RadioButton9.Text = adp["ans1"].ToString();
RadioButton10.Text = adp["ans2"].ToString();
RadioButton11.Text = adp["ans3"].ToString();
RadioButton12.Text = adp["ans4"].ToString();
}
if (adp.Read())
{
Label17.Text = adp["ques"].ToString();
RadioButton13.Text = adp["ans1"].ToString();
RadioButton14.Text = adp["ans2"].ToString();
RadioButton15.Text = adp["ans3"].ToString();
RadioButton16.Text = adp["ans4"].ToString();
}
if (adp.Read())
{
Label18.Text = adp["ques"].ToString();
RadioButton17.Text = adp["ans1"].ToString();
RadioButton18.Text = adp["ans2"].ToString();
RadioButton19.Text = adp["ans3"].ToString();
RadioButton20.Text = adp["ans4"].ToString();
}
}(Upto this my coding is working)
protected void Button1_Click(object sender, EventArgs e)
{
int mark = 0;
string correctans; //
if (RadioButton1.Checked == false && RadioButton2.Checked == false && RadioButton3.Checked == false && RadioButton4.Checked == false)
if (RadioButton5.Checked == false && RadioButton6.Checked == false && RadioButton7.Checked == false && RadioButton8.Checked == false)
if (RadioButton9.Checked == false && RadioButton10.Checked == false && RadioButton11.Checked == false && RadioButton12.Checked == false)
if (RadioButton13.Checked == false && RadioButton14.Checked == false && RadioButton15.Checked == false && RadioButton16.Checked == false)
if (RadioButton17.Checked == false && RadioButton18.Checked == false && RadioButton19.Checked == false && RadioButton20.Checked == false)
if (RadioButton1.Checked == true)
if (correctans == RadioButton1.Text)
{
mark = mark + 1;
}
if (RadioButton2.Checked == true)
if (correctans == RadioButton2.Text)
{
mark == mark + 1;
}
if (RadioButton3.Checked == true)
if (correctans == RadioButton3.Text)
{
mark == mark + 1;
}
if (RadioButton4.Checked == true)
if (correctans == RadioButton4.Text)
{
mark = mark + 1;
}
if (RadioButton5.Checked == true)
if (correctans == RadioButton5.Text)
{
mark == mark + 1;
}
if (RadioButton6.Checked == true)
if (correctans == RadioButton6.Text)
{
mark = mark + 1;
}
if (RadioButton7.Checked == true)
if (correctans == RadioButton7.Text)
{
mark == mark + 1;
}
if (RadioButton8.Checked == true)
if (correctans == RadioButton8.Text)
{
mark = mark + 1;
}
if (RadioButton9.Checked == true)
if (correctans == RadioButton9.Text)
{
mark == mark + 1;
}
if (RadioButton10.Checked == true)
if (correctans == RadioButton10.Text)
{
mark = mark + 1;
}
if (RadioButton11.Checked == true)
if (correctans == RadioButton11.Text)
{
mark == mark + 1;
}
if (RadioButton12.Checked == true)
if (correctans == RadioButton12.Text)
{
mark = mark + 1;
}
if (RadioButton13.Checked == true)
if (correctans == RadioButton13.Text)
{
mark == mark + 1;
}
if (RadioButton14.Checked == true)
if (correctans == RadioButton14.Text)
{
mark = mark + 1;
}
if (RadioButton15.Checked == true)
if (correctans == RadioButton15.Text)
{
mark == mark + 1;
}
if (RadioButton16.Checked == true)
if (correctans == RadioButton16.Text)
{
mark = mark + 1;
}
if (RadioButton17.Checked == true)
if (correctans == RadioButton17.Text)
{
mark == mark + 1;
}
if (RadioButton18.Checked == true)
if (correctans == RadioButton18.Text)
{
mark = mark + 1;
}
if (RadioButton19.Checked == true)
if (correctans == RadioButton19.Text)
{
mark == mark + 1;
}
if (RadioButton20.Checked == true)
{
if (correctans == RadioButton20.Text)
{
mark == mark + 1;
}
} }}