protected void Page_Load(object sender, EventArgs e)
        {
            r = (Results)Session["exam_ID"];
            examIDTextBox.Text = r.exam_ID;
            int count = re.getResultCountForDetailedReport(r);

            DataTable dt = new DataTable();
            dt.Columns.Add("Employee_ID", Type.GetType("System.String"));
            dt.Columns.Add("Exam_ID", Type.GetType("System.String"));
            dt.Columns.Add("Section", Type.GetType("System.String"));
            dt.Columns.Add("Percentage", Type.GetType("System.Double"));

            if (count > 0)
            {
                DetailedReports[] arr = new DetailedReports[count];
                arr = re.getDetailedReports(r, count);
                for (int i = 0; i < count; i++)
                {
                    dt.Rows.Add();
                    dt.Rows[dt.Rows.Count - 1]["Employee_ID"] = arr[i].employee_ID;
                    dt.Rows[dt.Rows.Count - 1]["Exam_ID"] = arr[i].exam_ID;
                    dt.Rows[dt.Rows.Count - 1]["Section"] = arr[i].section;
                    dt.Rows[dt.Rows.Count - 1]["Percentage"] = arr[i].percentage;
                }
                GridView1.DataSource = dt;
                GridView1.Enabled = false;
                GridView1.DataBind();
            }
            else
                System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('No Results present in the database.')</SCRIPT>");
            //MessageBox.Show("No Results present in the database.", "Error");
        }
Exemple #2
0
 //
 //On form Load: Loads the detailed reports for the selected exam
 //
 private void DetailedReport_Load(object sender, EventArgs e)
 {
     examIDTextBox.Text = r.exam_ID;
     int count = re.getResultCountForDetailedReport(r);
     if (count > 0)
     {
         DetailedReports[] arr = new DetailedReports[count];
         arr = re.getDetailedReports(r, count);
         resultDataGrid.DataSource = arr;
         resultDataGrid.Enabled = false;
     }
     else
         MessageBox.Show("No Results present in the database.", "Error");
 }
        //Add Detailed Result into the Database
        public bool addDetailedResult(DetailedReports dr)
        {
            try
            {
                cmd = new SqlCommand();
                cmd.Connection = conn;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "Insert into Detailed_Reports(Employee_ID,Exam_ID,Section,Percentage) values('" + dr.employee_ID + "','" + dr.exam_ID + "','" + dr.section + "'," + dr.percentage + ")";
                conn.Open();

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                return false;
            }
            conn.Close();
            return true;
        }
        //Calculate Detailed Result
        public bool calculateResult(Answers[] a, Questions[] q, Results r, Employee emp)
        {
            bool flag = true;
            int count = q.Length;
            int total = 0;
            string[] abc;
            ResultsDAL d = new ResultsDAL();

            int i = d.getSectionCount(r);
            DetailedReports[] re = new DetailedReports[i];
            abc = new string[i];
            int[] section = new int[i];
            abc = d.loadSection(r, i);

            int[] totalQuestions = d.totalSectionQuestions(abc, r);

            for (int j = 0; j < count; j++)
            {

                //total = total + q[j].marks;
                if (a[j].answer.Equals(q[j].solution))
                {
                    string click = q[j].section;
                    for (int k = 0; k < i; k++)
                    {
                        if (click == abc[k])
                            section[k]++;
                    }
                }
            }

            for (int k = 0; k < i; k++)
            {
                re[k] = new DetailedReports();
                re[k].employee_ID = emp.employee_Id;
                re[k].exam_ID = r.exam_ID;
                re[k].section = abc[k];
                re[k].percentage = (section[k] * 100) / totalQuestions[k];
                flag = d.addDetailedResult(re[k]);
            }
            return flag;
        }
 //
 //Returns detailed results for a particular Exam
 //
 public DetailedReports[] getDetailedReports(Results s, int count)
 {
     DetailedReports[] arr = new DetailedReports[count];
     conn.Open();
     cmd = new SqlCommand("select Employee_ID, Exam_ID, Section,Percentage from Detailed_Reports where Exam_ID ='" + s.exam_ID + "'", conn);
     dread = cmd.ExecuteReader();
     for (int i = 0; i < count; i++)
     {
         if (dread.Read())
         {
             arr[i] = new DetailedReports();
             arr[i].employee_ID = dread[0].ToString();
             arr[i].exam_ID = dread[1].ToString();
             arr[i].section = dread[2].ToString();
             arr[i].percentage = Convert.ToSingle(dread[3].ToString());
         }
     }
     dread.Close();
     conn.Close();
     return arr;
 }
Exemple #6
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");
            }
        }
Exemple #7
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 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();*/
                }
            }
        }
        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");
            }
        }
 //
 //DAL call to get Detailed Reports for an Exam
 //
 public DetailedReports[] getDetailedReports(Results s, int count)
 {
     DetailedReports[] arr = new DetailedReports[count];
     arr = dd.getDetailedReports(s, count);
     return arr;
 }