本文介绍了我在参加测验后在ASP.NET中创建在线测验系统如何显示结果表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当问题显示在测验形式的单选按钮中时,下一个按钮点击下一个问题将会出现。我如何检查单选按钮选项点击并在数据库中存储正确的问题,并在进行测验后如何显示结果。
我有什么试过:
when question are show in radio buttons in quiz form next button click next question will be appear . how can i check radio button option click and question correct ans that store in data base, and after taking quiz how can i show result.
What I have tried:
private static int question_id=0;
protected void Page_Load(object sender, EventArgs e)
{
GetData();
}
<pre> private DataTable GetData()
{
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection("Data Source=.;Initial Catalog=Quiz_system;Integrated Security=True");
try
{
connection.Open();
SqlCommand sqlCmd = new SqlCommand("Select question,op1,op2,op3,op4 From tbl_question_bank where course_name='" + Session["coursename"] + "'" , connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dt);
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Fetch Error:";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
connection.Close();
}
return dt;
}
<pre> protected void btninsert_Click(object sender, EventArgs e)
{
DataTable dt = GetData();
Session["dt"] = dt;
if(Session["dt"]!=null && question_id < dt.Rows.Count)
{
lblquestion.Text = dt.Rows[question_id]["question"].ToString();// questions.Add(red[0]);
rdb1.Text = dt.Rows[question_id]["op1"].ToString();// opt1.Add(red[1]);
rdb2.Text = dt.Rows[question_id]["op2"].ToString();// opt2.Add(red[2]);
rdb3.Text = dt.Rows[question_id]["op3"].ToString(); //opt3.Add(red[3]);
rdb4.Text = dt.Rows[question_id]["op4"].ToString(); //opt4.Add(red[4]);
}
question_id++;
//else
//{
// Response.Write("quizz end");
//}
}
<
推荐答案
这篇关于我在参加测验后在ASP.NET中创建在线测验系统如何显示结果表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!