protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Debug.WriteLine("Startat");
                Classes.clsSetGetStarttime clSetStart = new Classes.clsSetGetStarttime();
                HttpCookie myCookie = clSetStart.getStart();
               if (myCookie == null)
               {
                   Response.Cookies.Add(myCookie);
               }
                

              //  Classes.clsFillMenu aa = new Classes.clsFillMenu();
                Classes.clsTestMenuFill clMenFill = new Classes.clsTestMenuFill();
                cmbChooseQue.DataValueField = "id";
                cmbChooseQue.DataTextField = "name";
                cmbChooseQue.DataSource = clMenFill.read(Server.MapPath("~/questions.xml"));
                //Debug.WriteLine(aa.read(Server.MapPath("~/questions.xml")).Rows.Count.ToString());
                cmbChooseQue.DataBind();
                if (cmbChooseQue.Items.Count > 0)
                {
                    ViewState["alfred"] = cmbChooseQue.SelectedItem.ToString();
                    fillquestion();
                    checkedRadion();
                }
                else
                {
                    Label1.Text = "Något gick fel försök igen";
                    Button1.Enabled = false;
                    btnNext.Enabled = false;
                    btnPrevious.Enabled = false;
                    rbQuestionList.Enabled = false;
                    cmbChooseQue.Enabled = false;
                }                
            }
            else
            {

            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Debug.WriteLine("Startat");
                Classes.clsSetGetStarttime clSetStart = new Classes.clsSetGetStarttime();
                HttpCookie myCookie = clSetStart.getStart();
                if (myCookie == null)
                {
                    Response.Cookies.Add(myCookie);
                }


                //  Classes.clsFillMenu aa = new Classes.clsFillMenu();
                Classes.clsTestMenuFill clMenFill = new Classes.clsTestMenuFill();
                cmbChooseQue.DataValueField = "id";
                cmbChooseQue.DataTextField  = "name";
                cmbChooseQue.DataSource     = clMenFill.read(Server.MapPath("~/questions.xml"));
                //Debug.WriteLine(aa.read(Server.MapPath("~/questions.xml")).Rows.Count.ToString());
                cmbChooseQue.DataBind();
                if (cmbChooseQue.Items.Count > 0)
                {
                    ViewState["alfred"] = cmbChooseQue.SelectedItem.ToString();
                    fillquestion();
                    checkedRadion();
                }
                else
                {
                    Label1.Text            = "Något gick fel försök igen";
                    Button1.Enabled        = false;
                    btnNext.Enabled        = false;
                    btnPrevious.Enabled    = false;
                    rbQuestionList.Enabled = false;
                    cmbChooseQue.Enabled   = false;
                }
            }
            else
            {
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (HttpContext.Current.Session["userid"] != null)
                {

                    Classes.clsLogin clsLog = new Classes.clsLogin();
                    if (clsLog.getLevel(HttpContext.Current.Session["userid"].ToString()) == "deltagare") //Inloggad
                    {
                        Label2.Text = HttpContext.Current.Session["userid"].ToString();
                    }
                    else //Är inloggad med fel credinatl
                    {
                        Response.Redirect("default.aspx");
                    }
                }
                else //Har inte loggat in
                {
                    Response.Redirect("login.aspx");
                }
                if (ViewState["testID"] != null || Convert.ToString(ViewState["testID"]) != "")
                {
                    testID = ViewState["testID"].ToString();
                }
                else
                {
                    int tstID;
                    clsStartingTest clsTestID = new clsStartingTest();
                    testID = clsTestID.getTestid(HttpContext.Current.Session["userid"].ToString());
                    if (int.TryParse(testID, out tstID))
                    {
                        ViewState["testID"] = testID;
                    }
                }
                // ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:timeToEnd(); ", true); //Skapar en timer för nedräkning javascript
                Label2.Text = Label2.Text + "  testID_ " + testID;
                Classes.clsTestMenuFill clMenFill = new Classes.clsTestMenuFill();
                cmbChooseQue.DataValueField = "id";
                cmbChooseQue.DataTextField = "name";
                cmbChooseQue.DataSource = clMenFill.read(testID);
                cmbChooseQue.DataBind();
                cmbChooseQue.Enabled = false;
                if (cmbChooseQue.Items.Count > 0) //Om den inte hämtat någon data så blir det felmedelande
                {
                    ViewState["alfred"] = cmbChooseQue.SelectedItem.ToString();
                    fillquestion();
                }
                else
                {
                    Label1.Text = "Något gick fel försök igen";
                    btnNext.Enabled = false;
                    btnPrevious.Enabled = false;
                    rbQuestionList.Enabled = false;
                    cmbChooseQue.Enabled = false;
                }
            }
            else
            {
                testID = ViewState["testID"].ToString();
            }
            if (btnNext.Text == "Lämna in")
            {
                checkAnswers();
                clsMethods clMeth = new clsMethods();
                clsFillQuestion clQue = new clsFillQuestion();
                clsRightOrNot clRi = new clsRightOrNot();

                string handle = clRi.canHandIn(ViewState["testID"].ToString());
                if (handle == "TIDEN DROG ÖVER")
                {
                    clRi.setFail(ViewState["testID"].ToString()); //Om tiden har gått över 30min så har man failat
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "UpdateMsg", "alert('Du lämnade in testet för sent du blir underkänd');", true);
                    Response.Redirect("default.aspx");
                    return;
                }
                else if(handle != "OK")
                {
                    return;
                }
                string xml = clQue.getXml(ViewState["testID"].ToString());
                Tuple<bool, List<int>, List<int>, int, int> aa = clMeth.PartAndTotalResult(clMeth.XmlToClasses(xml));//list1,
                bool resultP = aa.Item1;
                //Debug.WriteLine("TESTID " + testID + "  " + resultP.ToString() + " res och " + aa.Item4.ToString() + " till sist " + aa.Item5);
                clRi.updateResult(ViewState["testID"].ToString(), resultP);
                Response.Redirect("webbtestresult.aspx");
            }
            string start;
            if (ViewState["startime"] == null)
            {
                clsSetGetStarttime clSta = new clsSetGetStarttime();
                start = clSta.getStarttime(ViewState["testID"].ToString()).ToString();
                ViewState.Add("startime", start.ToString());
            }
            else
            {
                start = ViewState["startime"].ToString();
            }
            ClientScript.RegisterStartupScript(GetType(), "Javascript", "CallHandler('" + start + "'); ", true);
        }