Thursday, 30 January 2014

Online examination system project In Asp Net with c#

Online examination system project In Asp Net with c#
Live-Online Examination System is an online examinationing program ran by qualified live examination online perfect for your children to enhance their education online. Online examinationing is an easy way to teach kids and to let them have fun while learning. Live-Online Examination System has advanced online examinationing techniques using an advanaced online classroom to examination children online. By using an online examinationing white board, both kids and examinations can write down their thoughts and communicate effectively over the internet. Your child's most valuable tool is his/her education and online examinationing is a great tool enhancer. By using Live-Online Examination System's online examinationing services you can create a fun online examinationing environment for your child.
Code : asp.net and c#  Datebase : SQL

Selecting topic for exam :

 protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserName"].ToString() == "")
        {
            Response.Redirect("index.aspx");
           
        }
        txt_stdId.Text = Session["UserName"].ToString();

    }
    protected void DdlSubject_SelectedIndexChanged(object sender, EventArgs e)
    {
        Ddtopic.Items.Clear();
      
        string pr = DdlSubject.SelectedValue.ToString();
      // get topic names data set from class file
        ds = info.GetTopic(pr);

        Ddtopic.DataSource = ds;

        Ddtopic.DataBind();
        Ddtopic.Items.Insert(0, new ListItem("--Select--", "0"));
    }
    protected void Ddtopic_SelectedIndexChanged(object sender, EventArgs e)
    {
      
    }
    protected void DdlProgrm_SelectedIndexChanged(object sender, EventArgs e)
    {
        DdlSubject.Items.Clear();
        Ddtopic.Items.Clear();
     
        string pr = DdlProgrm.SelectedValue.ToString();
         // get subjects names data set from class file
        ds = info.GetSubjects(pr);

        DdlSubject.DataSource = ds;

        DdlSubject.DataBind();
        DdlSubject.Items.Insert(0, new ListItem("--Select--", "0"));

    }
    protected void ImgBtnStartExm_Click(object sender, ImageClickEventArgs e)
    {
    
        string prg = DdlProgrm.SelectedValue.ToString();
        string sub = DdlSubject.SelectedValue.ToString();
        string stp = Ddtopic.SelectedValue.ToString();
        string lvl = Ddllevel.SelectedValue.ToString();
        string rng = ddlrange.SelectedValue.ToString();

 // get questions and answers from table using  data set from class file

        DataSet ds = info.GetQuestions(sub, stp, lvl);
       
       
        int nquestions = ds.Tables[0].Rows.Count;
        int SIZE=Convert.ToInt32(rng);
        Random r = new Random();
        int[] positions = new int[SIZE];
        int num;
        for (int pos = 0; pos < SIZE; )
        {
            num = Math.Abs(r.Next(nquestions));
            // check whether the number is already in the array
            bool found = false;
            for (int i = 0; i < pos; i++)
                if (num == positions[i]) { found = true; break; }

            if (!found)
            {
                positions[pos] = num;
                pos++;
            }
        } // end of for                
         DataTable dt1 = new DataTable();
         dt1.Columns.Add("topic", typeof(string));
         dt1.Columns.Add("question", typeof(string));
         dt1.Columns.Add("option1", typeof(string));
         dt1.Columns.Add("option2", typeof(string));
         dt1.Columns.Add("option3", typeof(string));
         dt1.Columns.Add("option4", typeof(string));
         dt1.Columns.Add("cans", typeof(string));
         dt1.Columns.Add("level", typeof(string));
         dt1.Columns.Add("EXPLANATION", typeof(string));
         dt1.Columns.Add("(ANALYSIS/CORRECT)", typeof(string));
         dt1.Columns.Add("(ANALYSIS /WRONG)", typeof(string));

         foreach (int pos in positions)
         {
           
             dt1.ImportRow(ds.Tables[0].Rows[pos]);
         
         }
         DataSet ds3 = new DataSet();
         ds3.Tables.Add(dt1);
         Session["questionpaper"] = ds3;
         Session["starttime"] = DateTime.Now.ToString();

        Response.Redirect("~/login_startexam.aspx?program=" + prg + "&subject=" + sub + " &subtopic=" + stp + " &level=" + lvl + " &range=" + rng);
    }
Examination paper : 

 protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserName"].ToString() == "")
        {
            Response.Redirect("index.aspx");

        }
        DateTime dt = Convert.ToDateTime(Session["starttime"]);
        lblstarttime.Text = dt.ToString();
        lblcurrnttime.Text = DateTime.Now.ToString();
        if (!Page.IsPostBack)
        {
            GridView1.DataSource = (DataSet)Session["questionpaper"];
            GridView1.DataBind();
            lblSid.Text = Session["UserName"].ToString();
            lblsub.Text = Request.QueryString["subject"];
            lblprogrm.Text = Request.QueryString["program"];
            lbltopic.Text = Request.QueryString["subtopic"];
            lbllvl.Text = Request.QueryString["level"];
            lblrange.Text = Request.QueryString["range"];
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int d = GridView1.Rows.Count;
        string[] choice = new string[d];
        int increment = 0;
        foreach (GridViewRow r in GridView1.Rows)
        {
            string opt;
            RadioButton radio1;
            RadioButton radio2;
            RadioButton radio3;
            RadioButton radio4;
            radio1 = (RadioButton)r.FindControl("ra1");
            radio2 = (RadioButton)r.FindControl("ra2");
            radio3 = (RadioButton)r.FindControl("ra3");
            radio4 = (RadioButton)r.FindControl("ra4");
            DataSet ds2 = new DataSet();
            ds2 = (DataSet)Session["questionpaper"];
            if ((radio1.Checked == true || radio2.Checked == true || radio3.Checked == true || radio4.Checked == true))
            {
                if (radio1 != null && radio1.Checked)
                {

                    opt = "a";
                    string str1 = (ds2.Tables[0].Rows[increment]["cans"]).ToString();
                    if (opt == str1)
                    {
                        choice[index++] = str1;
                    }
                    else
                    {
                        choice[index++] = "a";
                    }
                }
                else if (radio2 != null && radio2.Checked)
                {
                    opt = "b";
                    string str1 = (ds2.Tables[0].Rows[increment]["cans"]).ToString();
                    if (opt == str1)
                    {
                        choice[index++] = str1;
                    }
                    else
                    {
                        choice[index++] = "b";
                    }

                }
                else if (radio3 != null && radio3.Checked)
                {
                    opt = "c";
                    string str1 = (ds2.Tables[0].Rows[increment]["cans"]).ToString();
                    if (opt == str1)
                    {
                        choice[index++] = str1;
                    }
                    else
                    {
                        choice[index++] = "c";
                    }
                }
                else if (radio4 != null && radio4.Checked)
                {
                    opt = "d";
                    string str1 = (ds2.Tables[0].Rows[increment]["cans"]).ToString();
                    if (opt == str1)
                    {
                        choice[index++] = str1;

                    }
                    else
                    {
                        choice[index++] = "d";
                    }
                }


            }
            else
            {
                choice[index++] = "empty";

            }
            increment++;

        
            }

        if (GridView1.Rows.Count == increment)
        {
          
            string prg = lblprogrm.Text;
            string sub = lblsub.Text;
            string stp = lbltopic.Text;
            string lvl = lbllvl.Text;
            string rng = lblrange.Text;

            List<string> quest = new List<string>();
            List<string> opt1 = new List<string>();
            List<string> opt2 = new List<string>();
            List<string> opt3 = new List<string>();
            List<string> opt4 = new List<string>();
            List<string> CAns = new List<string>();
            List<string> myans = new List<string>();

            DataSet ds2 = (DataSet)Session["questionpaper"];
            foreach (DataRow row in ds2.Tables[0].Rows)
            {
                quest.Add(row["question"].ToString());
                opt1.Add(row["option1"].ToString());
                opt2.Add(row["option2"].ToString());
                opt3.Add(row["option3"].ToString());
                opt4.Add(row["option4"].ToString());
                CAns.Add(row["cans"].ToString());

            }




            string[] Questions = quest.ToArray();
            string[] Option1 = opt1.ToArray();
            string[] Option2 = opt2.ToArray();
            string[] Option3 = opt3.ToArray();
            string[] Option4 = opt4.ToArray();
            string[] correctAns = CAns.ToArray();


            int ind;
            for (ind = 0; ind <= d - 1; ind++)
            {
                myans.Add(choice[ind]);

            }
            string[] mychoice = new string[d];
            mychoice = myans.ToArray();

            int count = 0;
            for (int i = 0; i < correctAns.Length; i++)
            {
                for (int j = i; j < mychoice.Length; j++)
                {
                    if (correctAns[i] == mychoice[j])
                    {
                        count++;
                    }
                    i++;
                }         
            }
            int scr= 0 ;
           
            Session["scr"] = count++;
            TimeSpan duration = Convert.ToDateTime(Session["starttime"]) - DateTime.Now;
            string totltime = duration.ToString();
          //info.insertexamdetails(lblSid.Text, lblprogrm.Text, lblsub.Text, lbltopic.Text, lbllvl.Text, lblrange.Text, string.Join(",", Questions), string.Join(",", Option1), string.Join(",", Option2), string.Join(",", Option3), string.Join(",", Option4), string.Join(",", correctAns), string.Join(",", mychoice), scr);
       info.insertexamdetails(lblSid.Text, lblprogrm.Text, lblsub.Text, lbltopic.Text, lbllvl.Text, lblrange.Text, string.Join("@", Questions), string.Join("@", Option1), string.Join("@", Option2), string.Join("@", Option3), string.Join("@", Option4), string.Join("@", Array.ConvertAll(correctAns, x => x.ToString())), string.Join("@", Array.ConvertAll(mychoice, x => x.ToString())), Convert.ToInt32(Session["scr"]));
       Response.Redirect("Result.aspx?program=" + prg + "&subject=" + sub + " &subtopic=" + stp + " &level=" + lvl + " &range=" + rng + " &tottym=" + totltime);

        }
    }

view my result :

  protected void Page_Load(object sender, EventArgs e)
    {
        lblprogrme.Text = Request.QueryString["program"];
        lblsub.Text = Request.QueryString["subject"];
        lbltopic.Text = Request.QueryString["subtopic"];
        lbllevel.Text = Request.QueryString["level"];
        lblNquestions.Text = Request.QueryString["range"];   
        lblStime.Text = Session["starttime"].ToString();
        lblMin.Text = Request.QueryString["tottym"];
        int cnt = Convert.ToInt32(Session["scr"]);
        lblscore.Text = cnt.ToString();
        if (cnt > 19)
            lblGrade.Text = "Excellent";
        else
            if (cnt > 9)
                lblGrade.Text = "Average";
            else
                lblGrade.Text = "Poor";
     
    }

View my answer sheet :
 protected void Page_Load(object sender, EventArgs e)
    {
       
            bindgrid();
       
     
    }
    private void bindgrid()
    {
        DataSet ds = info.Getmyexampaper(Session["UserName"].ToString());

        string quest = (ds.Tables[0].Rows[0]["examquestions"]).ToString();
        string op1 = (ds.Tables[0].Rows[0]["examanswers1"]).ToString();
        string op2 = (ds.Tables[0].Rows[0]["examanswers2"]).ToString();
        string op3 = (ds.Tables[0].Rows[0]["examanswers3"]).ToString();
        string op4 = (ds.Tables[0].Rows[0]["examanswers4"]).ToString();
        string corans = (ds.Tables[0].Rows[0]["correctanswer"]).ToString();
        string myan = (ds.Tables[0].Rows[0]["myanswer"]).ToString();
        DataTable dt = new DataTable();
        dt.Columns.Add("QUE");
        dt.Columns.Add("OPT1");
        dt.Columns.Add("OPT2");
        dt.Columns.Add("OPT3");
        dt.Columns.Add("OPT4");
        dt.Columns.Add("ANS");
        dt.Columns.Add("MYANS");

        int cnt = Convert.ToInt32(ds.Tables[0].Rows[0]["rang"]);
        for (int i = 0; i < cnt; i++)
        {
            string[] Aquest = quest.Split('@');
            string[] Aop1 = op1.Split('@');
            string[] Aop2 = op2.Split('@');
            string[] Aop3 = op3.Split('@');
            string[] Aop4 = op4.Split('@');
            string[] Acorans = corans.Split('@');
            string[] Amyan = myan.Split('@');
            DataRow dr = dt.NewRow();
            dr["QUE"] = Aquest[i];
            dr["OPT1"] = Aop1[i];
            dr["OPT2"] = Aop2[i];
            dr["OPT3"] = Aop3[i];
            dr["OPT4"] = Aop4[i];
            dr["ANS"] = Acorans[i];
            dr["MYANS"] = Amyan[i];
            dt.Rows.Add(dr);
        }
        gvdetails.DataSource = dt;
        gvdetails.DataBind();
    
    }

    public override void VerifyRenderingInServerForm(Control control)
    {
        /* Verifies that the control is rendered */
    }
   
    protected void btnExcel_Click(object sender, ImageClickEventArgs e)
    {
        Response.ClearContent();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.xls"));
        Response.ContentType = "application/ms-excel";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        gvdetails.AllowPaging = false;
        gvdetails.DataBind();
        //Change the Header Row back to white color
        gvdetails.HeaderRow.Style.Add("background-color", "#FFFFFF");
        //Applying stlye to gridview header cells
        for (int i = 0; i < gvdetails.HeaderRow.Cells.Count; i++)
        {
            gvdetails.HeaderRow.Cells[i].Style.Add("background-color", "#507CD1");
        }
        int j = 1;
        //This loop is used to apply stlye to cells based on particular row
        foreach (GridViewRow gvrow in gvdetails.Rows)
        {
            gvrow.BackColor = System.Drawing.Color.White;
            if (j <= gvdetails.Rows.Count)
            {
                if (j % 2 != 0)
                {
                    for (int k = 0; k < gvrow.Cells.Count; k++)
                    {
                        gvrow.Cells[k].Style.Add("background-color", "#EFF3FB");
                    }
                }
            }
            j++;
        }
        gvdetails.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.End();
    }
    protected void btnWord_Click(object sender, ImageClickEventArgs e)
    {

        gvdetails.AllowPaging = false;
        gvdetails.DataBind();
        Response.ClearContent();
        Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.doc"));
        Response.Charset = "";
        Response.ContentType = "application/ms-word";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        gvdetails.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.End();
    }
    protected void gvdetails_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvdetails.PageIndex = e.NewPageIndex;
        bindgrid();
    }

27 comments:

  1. hi I want source code as zip folder please

    ReplyDelete
  2. hi can I download compete source code as a zip folder .........Thank u very very much

    ReplyDelete
  3. Hi. I want source code. Plz help me..

    ReplyDelete
  4. can you give link to download source code???

    ReplyDelete
  5. plz send the source code in my mail id: anandcrks@gmail.com

    ReplyDelete
  6. Please Send me Source Code on sabaaqeel.aqeelahmad@gmail.com

    ReplyDelete
  7. plz send the source code in my mail id:patelsavan1113@gmail.com

    ReplyDelete
  8. Please immediately Send me Source Code on manojranjan0@gmail.com or ranjanmanoj@ymail.com..

    thankfully..

    ReplyDelete
  9. please send me source code in zip file!! at fakhar.csv@gmail.com

    ReplyDelete
  10. hey,
    please send me source code in zip file at prafulla.nepal@gmail.com

    ReplyDelete
  11. hey
    please send me source code in zip file!! at prafulla.nepal@gmail.com

    ReplyDelete
  12. Please very much, send me source code and data base in rar/zip file!
    E-mail: flavius.manuel96@gmail.com

    ReplyDelete
  13. hi I want source code as zip folder

    ReplyDelete
  14. hi plz send me source code at dh91maurya@gmail.com

    ReplyDelete
  15. Could you please send link for download code through anssary@gmail.com

    ReplyDelete
  16. hi plz send me source code at kriptacool90@gmail.com

    ReplyDelete
  17. hi plz send me source code at aartidevi200@gmail.com
    plz its urgent.

    ReplyDelete
  18. hi plz send me source code at aartidevi200@gmail.com
    plz its urgent.

    ReplyDelete
  19. hi plz send me source code at aartidevi200@gmail.com
    plz its urgent.

    ReplyDelete
  20. hi plz send me source code at aartidevi200@gmail.com
    plz its urgent.

    ReplyDelete
  21. hi plz send me source code at aartidevi200@gmail.com
    plz its urgent.

    ReplyDelete
  22. khushich64@yahoo.com is my id please send me the code

    ReplyDelete
  23. PLease send the whole source code to vidushibaru@gmail.com

    ReplyDelete
  24. Please send me the source code at arvindid@gmail.com

    ReplyDelete
  25. It's very nice.... can u Please send me the source code and its description at "signup.bucks@gmail.com" .... i want implement it in real time environment and its urgent....

    ReplyDelete