我在参加测验后在ASP.NET中创建在线测验系统如何显示结果表格? [英] I am creating online quiz system in ASP.NET after taking quiz how can I show result form?

查看:77
本文介绍了我在参加测验后在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");
            //}
        }

<

推荐答案

您可以全部显示在一个页面中的问题和单选按钮。首先通过在viewbag中获取所有问题列表,在视图上逐个显示问题。在每个问题显示单选按钮下方,并给予自动增加的ech单选按钮的ID。您可以通过以下方式执行此操作在控制器方法之后使用formcollection来获取所选答案列表。并比较两个列表并显示结果
You can display all questions and radio buttons in one page.First by getting all questions list in viewbag,display one by one questions on view.and below each question show radio button and give id to ech radio button which should increase automatically.You can do this by for loop.After this in controller method use formcollection to get selected answers list.And compare two list and show result


您应该在数据库中映射Question_ID和corrent Answer_ID作为主数据。



一旦你的应用程序启动,用户将检查一个单选按钮。

点击下一步按钮后你必须存储User_ID,Question_ID和Answer_ID以及表格在应用程序结束后,您可以计算正确答案和错误答案
You should have mapped Question_ID and corrent Answer_ID in your database as a master data.

Once your application started user will check one radio button.
After click on next button you have to store User_ID, Question_ID and Answer_ID and table after end of the application you can calculate correct answers and incorrect answers


这篇关于我在参加测验后在ASP.NET中创建在线测验系统如何显示结果表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆