Example #1
0
        //
        //Updates & displays time. On time up, submits the paper
        //
        private void Timer_Tick(object sender, EventArgs e)
        {
            if (timeLeft > 0)
            {
                // Updates & Display the new time left
                timeLeft = timeLeft - 1;
                min = timeLeft / 60;
                sec = timeLeft - 60 * min;
                timerLabel.Text = min + " minutes: " + sec + " seconds";
            }
            else
            {
                //If the user runs out of time, stops the timer, shows a MessageBox
                Timer.Stop();
                timerLabel.Text = "Time's up!";
                MessageBox.Show("You have run out of time! You didn't finish in time. Sorry.", "Time up !", MessageBoxButtons.OK);

                //Stores the answer
                ans = (string)orderTextBox.Text;
                ab.storeAnswer(a, index, ans);

                //Calculates score, stores answers and result in database
                bool feed = ab.submit(a, q, emp, ed);
                if (feed == true)
                {

                    //Add Detailed Result
                    Results re = new Results();
                    DetailedReports dr = new DetailedReports();
                    re.employee_ID = emp.employee_Id;
                    re.exam_ID = ed.exam_ID;
                    //re.score = score;
                    ResultsBS rb = new ResultsBS();
                    bool flag = rb.calculateResult(a, q, re, emp);

                    //Navigates to Results Form
                    Result rs = new Result(emp, ed, q, a);
                    rs.MdiParent = this.MdiParent;
                    rs.Dock = DockStyle.Fill;
                    this.Close();
                    rs.Show();
                }
                else
                    MessageBox.Show("Some error occured. Sorry for the inconvenience.", "Error");
            }
        }
        protected void timer1_tick(object sender, EventArgs e)
        {
            if (0 > DateTime.Compare(DateTime.Now, DateTime.Parse(Session["timeout"].ToString())))
            {
                timerLabel.Text = string.Format("Time Left: 00:{0}:{1}", ((Int32)DateTime.Parse(Session["timeout"].ToString()).Subtract(DateTime.Now).TotalMinutes).ToString(), ((Int32)DateTime.Parse(Session["timeout"].ToString()).Subtract(DateTime.Now).Seconds).ToString());
            }
            else
            {
                //If the user runs out of time, stops the timer, shows a MessageBox
                //Timer.Stop();
                timerLabel.Text = "Time's up!";
                //MessageBox.Show("You have run out of time! You didn't finish in time. Sorry.", "Time up !", MessageBoxButtons.OK);
                System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('You have run out of time! You didn't finish in time. Sorry.')</SCRIPT>");

                //Stores the selected ans
                string ans = "";
                if (option1RadioButton.Checked)
                    ans = "1";
                else if (option2RadioButton.Checked)
                    ans = "2";
                else if (option3RadioButton.Checked)
                    ans = "3";
                else if (option4RadioButon.Checked)
                    ans = "4";
                a[index].answer = ans;
                //a = ab.storeAnswer(a, index, ans);

                //Calculates score, stores answers and result in database
                bool feed = ab.submit(a, q, emp, ed);
                if (feed == true)
                {

                    //Add Detailed Result
                    Results re = new Results();
                    DetailedReports dr = new DetailedReports();
                    re.employee_ID = emp.employee_Id;
                    re.exam_ID = ed.exam_ID;
                    //re.score = score;
                    ResultsBS rb = new ResultsBS();
                    bool flag = rb.calculateResult(a, q, re, emp);

                    /*Navigates to Results Form
                    Result rs = new Result(emp, ed, q, a);
                    rs.MdiParent = this.MdiParent;
                    rs.Dock = DockStyle.Fill;
                    this.Close();
                    rs.Show();*/
                }
            }
        }
Example #3
0
        //
        //On click on Submit button: Stores the selected answer, Confirms choice to submit, submits and navigates to Result Form
        //
        private void submit_Click(object sender, EventArgs e)
        {
            //Stores the selected answer
            ans = (string)orderTextBox.Text;
            ab.storeAnswer(a, index, ans);

            //Confirms choice to submit
            DialogResult r = MessageBox.Show("Are you sure you want to submit?", "Submit Test", MessageBoxButtons.YesNo);
            if (r == DialogResult.Yes)
            {
                //Calculates score, stores answers, and result
                bool feed = ab.submit(a, q, emp, ed);
                if (feed == true)
                {
                    //Add Detailed Result
                    Results re = new Results();
                    DetailedReports dr = new DetailedReports();
                    re.employee_ID = emp.employee_Id;
                    re.exam_ID = ed.exam_ID;
                    //re.score = score;
                    ResultsBS rb = new ResultsBS();
                    bool flag = rb.calculateResult(a, q, re, emp);

                    //Navigates to Results Form
                    Result rs = new Result(emp, ed, q, a);
                    rs.MdiParent = this.MdiParent;
                    rs.Dock = DockStyle.Fill;
                    this.Close();
                    rs.Show();
                }
                else
                    MessageBox.Show("Some error occured. Sorry for the inconvenience.", "Error");
            }
        }
        protected void submit_Click(object sender, EventArgs e)
        {
            //Stores the selected ans
            string ans = "";
            //Response.Write(option1RadioButton.Checked.ToString());
            if (option1RadioButton.Checked)
                //Response.Write("Hello 1");
                //(Session["answeres"] as Answers[])[index].answer = "1";
                a[index].answer = "1";
            else if (option2RadioButton.Checked)
                a[index].answer = "2";
            else if (option3RadioButton.Checked)
                a[index].answer = "3";
            else if (option4RadioButon.Checked)
                a[index].answer = "4";
            //a = ab.storeAnswer(a, index, ans);
            //answ.Text = a[index].answer;
            //Response.Write("Hello" + answ.Text + "  " + a[index].answer);

            Session.Remove("answers");
            Session["answers"] = a;

            string confirmValue = Request.Form["confirm_value"];
            if (confirmValue == "Yes")
            {

                Session["questions"] = q;
                Session["answers"] = a;
                Session["employee"] = emp;
                Session["exam"] = ed;

                bool feed = ab.submit(a, q, emp, ed);
                if (feed == true)
                {
                    //Add Detailed Result
                    Results re = new Results();
                    DetailedReports dr = new DetailedReports();
                    re.employee_ID = emp.employee_Id;
                    re.exam_ID = ed.exam_ID;
                    //re.score = score;
                    ResultsBS rb = new ResultsBS();
                    bool flag = rb.calculateResult(a, q, re, emp);

                    /*Navigates to Results Form
                    Result rs = new Result(emp, ed, q, a);
                    rs.MdiParent = this.MdiParent;
                    rs.Dock = DockStyle.Fill;
                    this.Close();
                    rs.Show();*/

                    Response.Redirect("~/Result.aspx");
                }
                else
                    System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Some error occured. Sorry for the inconvenience.')</SCRIPT>");
                //MessageBox.Show("Some error occured. Sorry for the inconvenience.", "Error");
            }
        }