コード例 #1
0
    protected void btnnext1_Click(object sender, EventArgs e)
    {
        try
        {
            //Write your code here to save the question
            ClsTakeTest obj = new ClsTakeTest();
            obj.QuestionId = lblquestionid.Text;
            obj.Testid     = Session["TestId"].ToString();
            obj.StudentId  = Session["StudentId"].ToString();
            if (rdoquestionoption.Visible == true)
            {
                obj.Studentanswer = clsCommon.GetListSelectValues(rdoquestionoption);
            }
            else
            {
                obj.Studentanswer = clsCommon.GetListSelectValues(chkquestionoption);
            }
            obj.StudentAnswer();

            //Displays the Next Question

            LoadQuestion();
            Question.Text = ((Convert.ToInt32(Question.Text)) + 1).ToString();
            Label5.Text   = "Q:" + " " + Question.Text;
        }

        catch (Exception ex)
        {
            Response.Write("<script>alert(''" + ex.Message + "'')</script>");
        }
    }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["StudentId"] == null)
     {
         //Response.Write("<script>alert('Your Session Timer has Expired! We are Sorry!')</script>");
         Response.Redirect("Login.aspx");
     }
     if (!IsPostBack)
     {
         //ClsTakeTest obj = new ClsTakeTest();
         // obj.Testid = "BA8C31B9-F1E5-483A-AF3F-A8D867372E80";
         //obj.TestSet = "A";
         ClsTakeTest obj = new ClsTakeTest();
         // gettestduration();
         obj.Testid            = Session["TestId"].ToString();
         ds                    = obj.DisplayQuestionSet();
         totalQs               = ds.Tables[0].Rows.Count;
         lbltotalquestion.Text = totalQs.ToString();
         Question.Text         = "1";
         Label5.Text           = "Q:" + " " + Question.Text;
         LoadQuestion();
         DataSet questions = new DataSet("Questions");
         questions.Tables.Add();
         //Response.Cache.SetNoStore();
         //Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
         //Response.Cache.SetCacheability(HttpCacheability.NoCache);
         //Response.Cache.SetNoStore();
         //lbltestname.Text = Request.QueryString["TestName"];
     }
 }
コード例 #3
0
    protected void LoadQuestion()
    {
        if (ds.Tables[0].Rows.Count > 0)
        {
            //Load Question;
            DataRow DR = ds.Tables[0].Rows[0];

            lblquestionid.Text = DR[0].ToString();
            lblquestion.Text   = DR[1].ToString();
            ClsTakeTest obj1 = new ClsTakeTest();
            obj1.Testid     = Session["TestId"].ToString();
            obj1.TestSet    = "A";
            obj1.QuestionId = lblquestionid.Text.ToString();
            DataSet dsoption = obj1.TestAnswer();
            if (DR[2].ToString() == "1")
            {
                btnnext.Visible                  = true;
                btnnext1.Visible                 = false;
                rdoquestionoption.Visible        = true;
                chkquestionoption.Visible        = false;
                rdoquestionoption.DataTextField  = "ANSWEROPTION";
                rdoquestionoption.DataValueField = "INTOPTIONID";
                rdoquestionoption.DataSource     = dsoption;
                rdoquestionoption.DataBind();
            }
            else
            {
                btnnext.Visible                  = false;
                btnnext1.Visible                 = true;
                rdoquestionoption.Visible        = false;
                chkquestionoption.Visible        = true;
                chkquestionoption.DataTextField  = "ANSWEROPTION";
                chkquestionoption.DataValueField = "INTOPTIONID";
                chkquestionoption.DataSource     = dsoption;
                chkquestionoption.DataBind();
            }



            ds.Tables[0].Rows.Remove(DR);

            if (Question.Text.Equals(totalQs.ToString()))
            {
                IsLastQs = true;
            }
        }
        else
        {
            //End Of File;
            //Response.Write("<script>alert('Thanks For Your Presence! You Can Leave Now.')</script>");
            //Session.Abandon();
            // RedirectToResults();
            Response.Redirect("EndTest.aspx");
        }
    }
コード例 #4
0
    protected int gettestduration()
    {
        ClsTakeTest   obj = new ClsTakeTest();
        SqlDataReader dr  = null;

        obj.Testid = Session["TestId"].ToString();
        dr         = obj.Gettestduration();
        int duration = 0;

        if (dr.HasRows)
        {
            dr.Read();
            duration = Convert.ToInt32(dr["DURATION"]);
            //    return duration;
        }
        dr.Close();
        return(duration);
    }