Example #1
0
 public Result(Employee e1, Exam_Details e2,Questions[] q1, Answers[] a1)
 {
     InitializeComponent();
     emp = e1;
     ed = e2;
     a = a1;
     q = q1;
 }
Example #2
0
 public CheckSolution(Questions[] q1, Answers[] a1, Employee e1, Exam_Details ed1)
 {
     InitializeComponent();
     q = q1;
     a = a1;
     emp = e1;
     ed = ed1;
 }
Example #3
0
 //
 //Accepts and assigns Question, Answers, Bookmark array, index, time left, Employee and Exam Details
 //
 public MatchTheColumnTest(Questions[] que, Answers[] ans, Bookmark[] b1, int ind, int timeleft1, Employee e, Exam_Details exd)
 {
     InitializeComponent();
     q = que;
     a = ans;
     index = ind;
     b = b1;
     timeLeft = timeleft1;
     emp = e;
     ed = exd;
 }
Example #4
0
 //
 //Accepts and assigns Question, Answers, Bookmark array, index, time left, Employee and Exam Details
 //
 public PictureQuestionSingleAns(Questions[] que, Answers[] ans, Bookmark[] b1, int ind, int timeleft1, Employee e, Exam_Details exd)
 {
     InitializeComponent();
     q = que;
     a = ans;
     b = b1;
     index = ind;
     timeLeft = timeleft1;
     emp = e;
     ed = exd;
 }
        //
        //On click Of Start Button
        //
        protected void startTest_Click(object sender, EventArgs e)
        {
            //DialogResult r = MessageBox.Show("Are you sure you want to start the test?", "Start the Test", MessageBoxButtons.OKCancel);
            string confirmValue = Request.Form["confirm_value"];
            if (confirmValue == "Yes")
            {
                //Gets the Set Paper Details for the Exam
                Paper s = new Paper();
                s.exam_ID = ed.exam_ID;
                PaperBS p = new PaperBS();
                int scount = p.getRowCountForExam(s);
                Paper[] arr = new Paper[scount];
                arr = p.viewPaperDetails(s, scount);

                //Timer duration
                int timeLeft = ed.duration * 60;

                //Gets the questions according to the set paper details after random selection and shuffling
                int qcount = p.getAddedQuestionCount(s);
                q = new Questions[qcount];
                QuestionsBS b = new QuestionsBS();
                q = b.getQuestionPaper(arr, q, ed);

                //Initializes the Answers array and Bookmark array
                AnswerBS ab = new AnswerBS();
                a = new Answers[qcount];
                a = ab.initializeAnswersArray(a, q, ed, emp);
                b1 = new Bookmark[qcount];
                b1 = ab.initializeBookmarksArray(b1);

                //Swap Options
                Questions[] qnew = b.swapOptions(q);
                Int32 n = 0;
                Session["noOfQues"] = q.Count();
                Session["questions"] = qnew;
                Session["answers"] = a;
                Session["bookmark"] = b1;
                Session["ind"] = n;
                Session["time"] = timeLeft;
                Session["employee"] = emp;
                Session["exam"] = ed;
                Session["timeout"] = DateTime.Now.AddMinutes(ed.duration).ToString();

                //Chooses the first from according to the format of first question
                string first = qnew[0].format;
                switch (first)
                {
                    case "Match The Column":
                        Response.Redirect("~/MatchTheColumnTest.aspx");
                        break;

                    case "MCQ (Single Answer)":
                        Response.Redirect("~/SingleAnswerTest.aspx");
                        break;

                    case "MCQ (Multiple Answers)":
                        Response.Redirect("~/MultipleAnswerTest.aspx");
                        break;

                    case "Picture Question: Single Answer":
                        Response.Redirect("~/PictureQuestionSingleAns.aspx");
                        break;

                    case "Picture Question: Multiple Answer":
                        Response.Redirect("~/PictureQuestionMultipleAnswer.aspx");
                        break;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            q = (Questions[])Session["questions"];
            a = (Answers[])Session["answers"];
            b = (Bookmark[])Session["bookmark"];
            index = (int)Session["ind"];
            timeLeft = (int)Session["time"];
            emp = (Employee)Session["employee"];
            ed = (Exam_Details)Session["exam"];

            //Session["answers"] = null;
            //Session.Remove("answers");
            //if (!SM1.IsInAsyncPostBack)
              //  Session["timeout"] = DateTime.Now.AddMinutes(ed.duration).ToString();

            //Displays timer, employee name, exam ID, question, question no, options

            //Timer.Start();
            employeeNameLabel.Text = emp.first_Name + " " + emp.last_Name;
            examIDLabel.Text = "Exam ID:" + ed.exam_ID;
            questionLabel.Text = q[index].question;
            questionNoLabel.Text = (index + 1) + ".";
            option1RadioButton.Text = q[index].option1;
            option2RadioButton.Text = q[index].option2;
            option3RadioButton.Text = q[index].option3;
            option4RadioButon.Text = q[index].option4;

            //Displays previous answer, if any
            if (Page.IsPostBack)
            {
                if (a[index].answer != "")
                {
                    string ans = a[index].answer;
                    if (ans.Equals("1"))
                        option1RadioButton.Checked = true;
                    else if (ans.Equals("2"))
                        option2RadioButton.Checked = true;
                    else if (ans.Equals("3"))
                        option3RadioButton.Checked = true;
                    else if (ans.Equals("4"))
                        option4RadioButon.Checked = true;
                    else
                    {
                        option1RadioButton.Checked = false;
                        option2RadioButton.Checked = false;
                        option3RadioButton.Checked = false;
                        option4RadioButon.Checked = false;
                    }
                    //answ.Text = a[index].answer;
                }
            }
            else
            {
                option1RadioButton.Checked = false;
                option2RadioButton.Checked = false;
                option3RadioButton.Checked = false;
                option4RadioButon.Checked = false;
                //answ.Text = a[index].answer;
            }

            //Displays correctly enabled/disabled Next, Previous, Bookmark and Remove Bookmark buttons
            if (index == q.Length - 1)
                next.Enabled = false;
            else
                next.Enabled = true;

            if (index == 0)
                previous.Enabled = false;
            else
                previous.Enabled = true;

            if (b[index].status == true)
            {
                bookmark.Enabled = false;
                removeBookmark.Enabled = true;
            }
            else
            {
                bookmark.Enabled = true;
                removeBookmark.Enabled = false;
            }

            //Displays bookmark Grid and current question cell
            DataTable dt = new DataTable();
            dt.Columns.Add("Question", Type.GetType("System.Int32"));

            if (q.Length > 0)
            {
                for (int i = 0; i < q.Length; i++)
                {
                    dt.Rows.Add();
                    dt.Rows[dt.Rows.Count - 1]["Question"] = (i + 1);
                }
                bookmarkGridView.DataSource = dt;
                //bookmarkGridView.Enabled = false;
                bookmarkGridView.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            q = (Questions[])Session["questions"];
            a = (Answers[])Session["answers"];
            b = (Bookmark[])Session["bookmark"];
            index = (int)Session["ind"];
            timeLeft = (int)Session["time"];
            emp = (Employee)Session["employee"];
            ed = (Exam_Details)Session["exam"];

            if (!SM1.IsInAsyncPostBack)
                Session["timeout"] = DateTime.Now.AddMinutes(ed.duration).ToString();

            //Displays timer, employee name, exam ID, question, question no, options
            //Timer.Start();
            employeeNameLabel.Text = emp.first_Name + " " + emp.last_Name;
            examIDLabel.Text = "Exam ID:" + ed.exam_ID;
            questionLabel.Text = q[index].question;
            questionNoLabel.Text = (index + 1) + ".";
            option1CheckBox.Text = q[index].option1;
            option2CheckBox.Text = q[index].option2;
            option3CheckBox.Text = q[index].option3;
            option4CheckBox.Text = q[index].option4;

            //Displays previous answer, if any
            string ans = a[index].answer;
            if (ans.Contains("1"))
                option1CheckBox.Checked = true;
            if (ans.Contains("2"))
                option2CheckBox.Checked = true;
            if (ans.Contains("3"))
                option3CheckBox.Checked = true;
            if (ans.Contains("4"))
                option4CheckBox.Checked = true;

            //Displays correctly enabled/disabled Next, Previous, Bookmark and Remove Bookmark buttons
            if (index == q.Length - 1)
                next.Enabled = false;
            else
                next.Enabled = true;
            if (index == 0)
                previous.Enabled = false;
            else
                previous.Enabled = true;
            if (b[index].status == true)
            {
                bookmark.Enabled = false;
                removeBookmark.Enabled = true;
            }
            else
            {
                bookmark.Enabled = true;
                removeBookmark.Enabled = false;
            }

            //Displays bookmark Grid and current question cell
            DataTable dt = new DataTable();
            dt.Columns.Add("Question", Type.GetType("System.Int32"));

            if (q.Length > 0)
            {
                for (int i = 0; i < q.Length; i++)
                {
                    dt.Rows.Add();
                    dt.Rows[dt.Rows.Count - 1]["Question"] = (i + 1);
                }
                bookmarkGridView.DataSource = dt;
                //bookmarkGridView.Enabled = false;
                bookmarkGridView.DataBind();
            }

            //Displays the picture
            byte[] image = qb.getImage(q[index]);

            string base64String = Convert.ToBase64String(image, 0, image.Length);
            pictureBox.ImageUrl = "data:image/png;base64," + base64String;
            pictureBox.Visible = true;

            //pictureBox.Image = Image.FromFile(s);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            q = (Questions[])Session["questions"];
            a = (Answers[])Session["answers"];
            b = (Bookmark[])Session["bookmark"];
            index = (int)Session["ind"];
            timeLeft = (int)Session["time"];
            emp = (Employee)Session["employee"];
            ed = (Exam_Details)Session["exam"];

            //Session["answers"] = null;
            //Session.Remove("answers");
            //if (!SM1.IsInAsyncPostBack)
              //  Session["timeout"] = DateTime.Now.AddMinutes(ed.duration).ToString();

            //Displays timer, employee name, exam ID, question, question no, options
            employeeNameLabel.Text = emp.first_Name + " " + emp.last_Name;
            examIDLabel.Text = "Exam ID:" + ed.exam_ID;
            questionNoLabel.Text = (index + 1) + ".";

            string temp = "";
            int pos;
            temp = q[index].question;

            temp = temp.Substring(1);
            pos = temp.IndexOf(".");
            aOption1Label.Text = temp.Substring(0, pos);

            temp = temp.Substring(pos + 1);
            pos = temp.IndexOf(".");
            aOption2Label.Text = temp.Substring(0, pos);

            temp = temp.Substring(pos + 1);
            pos = temp.IndexOf(".");
            aOption3Label.Text = temp.Substring(0, pos);

            temp = temp.Substring(pos + 1);
            pos = temp.IndexOf(".");
            aOption4Label.Text = temp.Substring(0, pos);

            bOption1Label.Text = q[index].option1;
            bOption2Label.Text = q[index].option2;
            bOption3Label.Text = q[index].option3;
            bOption4Label.Text = q[index].option4;

            //Displays previous answer, if any
            if (Page.IsPostBack)
            {
                //string ans = a[index].answer;
                orderTextBox.Text = a[index].answer;
            }
            else
            {
                string hi = "Enter Answer..";
                orderTextBox.Text = hi;
            }

            //Displays correctly enabled/disabled Next, Previous, Bookmark and Remove Bookmark buttons
            if (index == q.Length - 1)
                next.Enabled = false;
            else
                next.Enabled = true;

            if (index == 0)
                previous.Enabled = false;
            else
                previous.Enabled = true;

            if (b[index].status == true)
            {
                bookmark.Enabled = false;
                removeBookmark.Enabled = true;
            }
            else
            {
                bookmark.Enabled = true;
                removeBookmark.Enabled = false;
            }

            //Displays bookmark Grid and current question cell
            DataTable dt = new DataTable();
            dt.Columns.Add("Question", Type.GetType("System.Int32"));

            if (q.Length > 0)
            {
                for (int i = 0; i < q.Length; i++)
                {
                    dt.Rows.Add();
                    dt.Rows[dt.Rows.Count - 1]["Question"] = (i + 1);
                }
                bookmarkGridView.DataSource = dt;
                //bookmarkGridView.Enabled = false;
                bookmarkGridView.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            q = (Questions[])Session["questions"];
            a = (Answers[])Session["answers"];
            emp = (Employee)Session["employee"];
            ed = (Exam_Details)Session["exam"];

            DataTable dt = new DataTable();
            dt.Columns.Add("No.", Type.GetType("System.Int32"));
            dt.Columns.Add("Question", Type.GetType("System.String"));
            dt.Columns.Add("Right Answer", Type.GetType("System.String"));
            dt.Columns.Add("Answer Marked", Type.GetType("System.String"));

            for (int i = 0; i < q.Length; i++)
            {
                dt.Rows.Add();
                dt.Rows[dt.Rows.Count - 1]["No."] = (i + 1);
                dt.Rows[dt.Rows.Count - 1]["Question"] = q[i].question;
                string ans = "", a2 = "";

                //dt.Rows[dt.Rows.Count - 1]["Right Answer"] = arr[i].score;
                //dt.Rows[dt.Rows.Count - 1]["Answer Marked"] = arr[i].percentage;

                switch (q[i].format)
                {
                    case "Match The Column":
                        dt.Rows[dt.Rows.Count - 1]["Right Answer"] = q[i].solution;
                        dt.Rows[dt.Rows.Count - 1]["Answer Marked"] = a[i].answer;
                        break;

                    case "MCQ (Single Answer)":
                        switch (q[i].solution)
                        {
                            case "1":
                                dt.Rows[dt.Rows.Count - 1]["Right Answer"] = q[i].option1;
                                break;
                            case "2":
                                dt.Rows[dt.Rows.Count - 1]["Right Answer"] = q[i].option2;
                                break;
                            case "3":
                                dt.Rows[dt.Rows.Count - 1]["Right Answer"] = q[i].option3;
                                break;
                            case "4":
                                dt.Rows[dt.Rows.Count - 1]["Right Answer"] = q[i].option4;
                                break;
                        }
                        switch (a[i].answer)
                        {
                            case "1":
                                dt.Rows[dt.Rows.Count - 1]["Answer Marked"] = q[i].option1;
                                break;
                            case "2":
                                dt.Rows[dt.Rows.Count - 1]["Answer Marked"] = q[i].option2;
                                break;
                            case "3":
                                dt.Rows[dt.Rows.Count - 1]["Answer Marked"] = q[i].option3;
                                break;
                            case "4":
                                dt.Rows[dt.Rows.Count - 1]["Answer Marked"] = q[i].option4;
                                break;
                        }
                        break;

                    case "MCQ (Multiple Answers)":
                        ans =  q[i].solution;
                        a2="";
                        if (ans.Contains("1"))
                            a2 += q[i].option1 + "  ";
                        if (ans.Contains("2"))
                            a2 += q[i].option2 + "  ";
                        if (ans.Contains("3"))
                            a2 += q[i].option3 + "  ";
                        if (ans.Contains("4"))
                            a2 += q[i].option4 + "  ";
                        dt.Rows[dt.Rows.Count - 1]["Right Answer"] = a2;

                        ans =  a[i].answer;
                        a2="";
                        if (ans.Contains("1"))
                            a2 += q[i].option1 + "  ";
                        if (ans.Contains("2"))
                            a2 += q[i].option2 + "  ";
                        if (ans.Contains("3"))
                            a2 += q[i].option3 + "  ";
                        if (ans.Contains("4"))
                            a2 += q[i].option4 + "  ";
                        dt.Rows[dt.Rows.Count - 1]["Answer Marked"] = a2;
                        break;

                    case "Picture Question: Single Answer":
                        switch (q[i].solution)
                        {
                            case "1":
                                dt.Rows[dt.Rows.Count - 1]["Right Answer"] = q[i].option1;
                                break;
                            case "2":
                                dt.Rows[dt.Rows.Count - 1]["Right Answer"] = q[i].option2;
                                break;
                            case "3":
                                dt.Rows[dt.Rows.Count - 1]["Right Answer"] = q[i].option3;
                                break;
                            case "4":
                                dt.Rows[dt.Rows.Count - 1]["Right Answer"] = q[i].option4;
                                break;
                        }
                        switch (a[i].answer)
                        {
                            case "1":
                                dt.Rows[dt.Rows.Count - 1]["Answer Marked"] = q[i].option1;
                                break;
                            case "2":
                                dt.Rows[dt.Rows.Count - 1]["Answer Marked"] = q[i].option2;
                                break;
                            case "3":
                                dt.Rows[dt.Rows.Count - 1]["Answer Marked"] = q[i].option3;
                                break;
                            case "4":
                                dt.Rows[dt.Rows.Count - 1]["Answer Marked"] = q[i].option4;
                                break;
                        }
                        break;

                    case "Picture Question: Multiple Answer":
                        ans =  q[i].solution;
                        a2="";
                        if (ans.Contains("1"))
                            a2 += q[i].option1+"  ";
                        if (ans.Contains("2"))
                            a2 += q[i].option2 + "  ";
                        if (ans.Contains("3"))
                            a2 += q[i].option3 + "  ";
                        if (ans.Contains("4"))
                            a2 += q[i].option4 + "  ";
                        dt.Rows[dt.Rows.Count - 1]["Right Answer"] = a2;

                        ans =  a[i].answer;
                        a2="";
                        if (ans.Contains("1"))
                            a2 += q[i].option1 + "  ";
                        if (ans.Contains("2"))
                            a2 += q[i].option2 + "  ";
                        if (ans.Contains("3"))
                            a2 += q[i].option3 + "  ";
                        if (ans.Contains("4"))
                            a2 += q[i].option4 + "  ";
                        dt.Rows[dt.Rows.Count - 1]["Answer Marked"] = a2;
                        break;

                }
            }
            GridView1.DataSource = dt;
            GridView1.Enabled = false;
            GridView1.DataBind();
        }