Ejemplo n.º 1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     fillquestion();
     ViewState["alfred"] = cmbChooseQue.SelectedValue.ToString();
     Classes.clsRightOrNot cls = new Classes.clsRightOrNot();
     Label2.Text = cls.allReadyCheckd(cmbChooseQue.SelectedValue.ToString(), testID);
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            fillquestion();
            ViewState["alfred"] = cmbChooseQue.SelectedValue.ToString();
            Classes.clsRightOrNot cls = new Classes.clsRightOrNot();
            Label2.Text = cls.allReadyCheckd(cmbChooseQue.SelectedValue.ToString(), testID);

        }
        private void checkedRadion()//Vilken som redan är vald och då checkar den i uppstarten 
        {
            Classes.clsRightOrNot cls = new Classes.clsRightOrNot();
            string strVal = cls.allReadyCheckd(cmbChooseQue.SelectedValue.ToString(), testID);
            Label2.Text = strVal;
            int val = 0;
            if (int.TryParse(strVal, out val))
            {
                rbQuestionList.SelectedValue = val.ToString();
            }
            else
            {

            }
        }
Ejemplo n.º 4
0
        private void checkedRadion()//Vilken som redan är vald och då checkar den i uppstarten
        {
            Classes.clsRightOrNot cls = new Classes.clsRightOrNot();
            string strVal             = cls.allReadyCheckd(cmbChooseQue.SelectedValue.ToString(), testID);

            Label2.Text = strVal;
            int val = 0;

            if (int.TryParse(strVal, out val))
            {
                rbQuestionList.SelectedValue = val.ToString();
            }
            else
            {
            }
        }
Ejemplo n.º 5
0
        private bool checkAnswers(RadioButtonList aa)//Sparar svars alternativen
        {
            try
            {
                Classes.clsRightOrNot cls = new Classes.clsRightOrNot();
                if (aa.SelectedIndex > 0)
                {
                    Label3.Text = cls.saveAnswers(cmbChooseQue.SelectedValue.ToString(), aa.SelectedValue.ToString(), testID);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                return(false);
            }

            return(true);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        //Sparar svars alternativen
        private bool checkAnswers()
        {
            Classes.clsRightOrNot cls = new Classes.clsRightOrNot();
            List<string> selDat = new List<string>();
            string sele = "";
            if (chkQuestionList.Visible == true)
            {
                if (chkQuestionList.SelectedIndex > -1)
                {
                    foreach (ListItem item in chkQuestionList.Items)
                    {
                        if (item.Selected)
                        {
                            sele = (item.Value);
                            selDat.Add(item.Value);
                        }
                    }
                }
            }
            else if (rbQuestionList.Visible == true)
            {
                if (rbQuestionList.SelectedIndex > -1)
                {
                    sele = rbQuestionList.SelectedValue.ToString();
                    selDat.Add(rbQuestionList.SelectedValue.ToString());
                }
            }
            //Label1.Text = sele;
            cls.valudateXML(testID, cmbChooseQue.SelectedValue.ToString(), selDat); //SKickar en list så att flera val kan väljas

            return true;
        }
 private bool checkAnswers(RadioButtonList aa)//Sparar svars alternativen
 {
     try
     {
         Classes.clsRightOrNot cls = new Classes.clsRightOrNot();
         if (aa.SelectedIndex > 0)
         {
             Label3.Text = cls.saveAnswers(cmbChooseQue.SelectedValue.ToString(), aa.SelectedValue.ToString(), testID);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.ToString());
         return false;
     }
     
     return true;
 }