Exemplo n.º 1
0
 /// <summary>
 /// Button event for user to click if use exceeds the time limit of the test.
 /// Calls method failuser and redirects to start1.aspx.
 /// </summary>
 protected void Button_Go_To_Start_Click(object sender, EventArgs e)
 {
     DatabaseConnection dc = new DatabaseConnection();
     var labelUserName1 = this.ContentPlaceHolder1.FindControl("lblUserName1") as Label;
     var labelTestType = this.ContentPlaceHolder1.FindControl("lblTestType") as Label;
     string userName = labelUserName1.Text;
     string typeOfTest = labelTestType.Text;
     dc.FailUser(userName, typeOfTest);
     Response.Redirect("~/start1.aspx");
 }
Exemplo n.º 2
0
        //session[typeofTest]
        protected void btnSend_Click(object sender, EventArgs e)
        {
            if(CheckTestTime() == true)
            {
                //Response.Write("Mer än 30 minuter"); //Test purpose
                DatabaseConnection dc = new DatabaseConnection();
                string typeOfTest = Session["typeOfTest"].ToString();
                string userName = lblUserName1.Text;
                dc.FailUser(userName, typeOfTest);
                btnSend.Enabled = false;
                Response.Redirect("~/FailPage.aspx"); //Sends user to a page to inform user that he/she failed.
            }
            else
            {
                //Response.Write("MIndre än 30 minuter"); //Test purpose.
                if (Session["IsFirstTime"] != null) //after buttonclick page reload will trigger onClick-event
                {
                    CorrectTest();
                }
                else
                {
                    string fileName = GetUserXmlFileName();
                    XDocument xDoc = XDocument.Load(Server.MapPath(fileName));

                    List<Repeater> reps = new List<Repeater>();
                    foreach (Repeater rep in repeaters.Controls.OfType<Repeater>())
                    {
                        reps.Add(rep);
                    }

                    foreach (Repeater rep in reps)
                    {
                        foreach (RepeaterItem item in rep.Items)
                        {
                            Label lbl = (Label)item.FindControl("question");
                            CheckBox chBox1 = (CheckBox)item.FindControl("cBox1");
                            CheckBox chBox2 = (CheckBox)item.FindControl("cBox2");
                            CheckBox chBox3 = (CheckBox)item.FindControl("cBox3");
                            CheckBox[] cBoxes = { chBox1, chBox2, chBox3 };
                            AddXmlAttribute(lbl.Text, cBoxes, xDoc);
                        }
                    }
                    SendUserXmlToDb();
                    CorrectTest();
                }
            }
        }
Exemplo n.º 3
0
 //session[typeoftest]
 /// <summary>
 /// Tick event for timer. At the moment its on 3 minutes.
 /// Calls methods in databaseconnection to failuser.
 /// </summary>
 protected void Timer1_Tick(object sender, EventArgs e)
 {
     DatabaseConnection dc = new DatabaseConnection();
     string userName = lblUserName1.Text;
     string typeOfTest = Session["typeOfTest"].ToString();
     dc.FailUser(userName, typeOfTest);
     Response.Redirect("~/start1.aspx");
 }