Beispiel #1
0
        private void defaultExamOnLoad()
        {
            string StudentName = (string)Session["student"];

            ExamID = (string)Session["exam_id"];


            if (Request.QueryString["id"] != null)
            {
                currentQuestionId = Request.QueryString["id"];
                Session[currentQuestionId + "VQ"] = "Ahoy";
            }

            //Time to set the timer accordingly
            String examDuration = AptitudeTestBLL.Instance.GetExamDurationByID(ExamID);

            int timeLeft = 0;

            if (Session["currentExamDuration"] != null)
            {
                timeLeft = (int.Parse(examDuration) * 60) - int.Parse(SessionsCommon.getTimeDifference(Session));
            }
            else
            {
                timeLeft = int.Parse(examDuration) * 60;
                Session["currentExamDuration"] = DateTime.Now;
            }

            this.currentExamTime.Value = (timeLeft).ToString();
            questionID = Request.QueryString["id"];

            DataTable questionTable = AptitudeTestBLL.Instance.GetQuestionsForExamByID(ExamID);



            ArrayList al = (ArrayList)Session["questionList"];

            //if (Session["questionList"] == null)
            //{
            al = GenerateArrayList(questionTable);
            ShuffleList(al);
            Session["questionList"] = al;
            //}

            //////////List<string> lstquestion = new List<string>();
            //////////if (Session["questionList"] == null)
            //////////{
            //////////    lstquestion = GenerateArrayList(questionTable);
            //////////    //ShuffleList(al);
            //////////    Session["questionList"] = lstquestion;
            //////////}
            //////////else
            //////////    lstquestion = (List<string>) Session["questionList"];


            GenerateHtml(al);
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string ExamID = (string)Session["exam_id"];

            String examDuration = AptitudeTestBLL.Instance.GetExamDurationByID(ExamID);

            int timeLeft = 0;

            if (Session["currentExamDuration"] != null)
            {
                timeLeft = (int.Parse(examDuration) * 60) - int.Parse(SessionsCommon.getTimeDifference(Session));
            }
            else
            {
                timeLeft = int.Parse(examDuration) * 60;
                Session["currentExamDuration"] = DateTime.Now;
            }
            this.currentExamTime.Value = (timeLeft).ToString();

            string StudentName = (string)Session["student"];

            DataTable questionTable = AptitudeTestBLL.Instance.GetQuestionsForExamByID(ExamID);

            String s = "<table bgcolor=white class='tblExamSummary' border =1>";

            //for (int j = 0; j < questionTable.Rows.Count; j++)
            foreach (DataRow questionRow in questionTable.Rows)
            {
                s += "<tr><td>";

                string i        = questionRow["QuestionID"].ToString();
                object o        = Session[i];
                string question = questionRow["Question"].ToString();
                s += "<a href=StartExam.aspx?id=" + questionRow["QuestionID"] + ">Edit Your Answer</a>" + question + "</a>";

                String lblType = "", answerString = "";

                answerString = "You did not yet mark answer for this question!";
                if ("SingleSelect" == "SingleSelect")
                {
                    ListItemCollection coll = (ListItemCollection)o;
                    if (o != null)
                    {
                        foreach (ListItem item in coll)
                        {
                            if (item.Selected)
                            {
                                answerString = "The option you selected is <b>" + item.Text;
                                break;
                            }
                        }
                    }
                    lblType = "Single choice question";
                }
                else
                {
                    if (o != null)
                    {
                        answerString = "The answer you wrote is <b>" + (string)o;
                    }
                    lblType = "Fill in the blank question";
                }

                s += "<br><font color=black>" + answerString + "</b></font></td>";

                //s += "<td><b>Question Type:</b> " + lblType + "</td>";
                s += "</tr>";

                //s += "<tr><td><font color=black>" + answerString + "</font></td></tr>";
            }
            s += "</table>";
            lblObjectiveSummary.Text = s;
        }
Beispiel #3
0
        private void GenerateHtml(ArrayList al)
        {
            string s = "";
            int    c = 1;

            int    xCount = 0, xMaxCount = 10, questionsMarked = 0;
            string dispQuestionId = "0";

            s += "<table><tr>";
            for (int k = 0; k < al.Count; k++)
            {
                if (xCount == xMaxCount)
                {
                    s += "<tr>";
                }
                if (al[k].ToString().Equals(currentQuestionId))
                {
                    dispQuestionId = (c).ToString();
                    if (al.Count == k + 1)
                    {
                        Session["nextQuestionId"] = al[0].ToString();
                    }
                    else
                    {
                        Session["nextQuestionId"] = al[k + 1].ToString();
                    }
                    if (k == 0)
                    {
                        Session["prevQuestionId"] = al[al.Count - 1].ToString();
                    }
                    else
                    {
                        Session["prevQuestionId"] = al[k - 1].ToString();
                    }
                }

                /*
                 * if (dispQuestionId.ToString().Equals(c.ToString()))
                 * {
                 *  s += "<td><font size=large><a href=StartExam.aspx?id=" + al[k] + " style='color: #ffffff;'>Q" + c++ + "</a></font></td>";
                 *  if (Session[al[k] + "MA"] != null)
                 *      questionsMarked++;
                 *  c++;
                 * }
                 * else
                 * {*/
                if (Session[al[k] + "VQ"] != null)
                {
                    if (Session[al[k] + "MA"] != null)
                    {
                        s += "<td><a href=StartExam.aspx?id=" + al[k] + " style='color: #33cc33;'>Q" + c++ + "</a></td>";
                        questionsMarked++;
                    }
                    else
                    {
                        s += "<td><a href=StartExam.aspx?id=" + al[k] + " style='color: #3366ff;'>Q" + c++ + "</a></td>";
                    }
                }

                else
                {
                    s += "<td><a href=StartExam.aspx?id=" + al[k] + " style='color: #ff3300'>Q" + c++ + "</a></td>";
                }
                //}

                xCount++;
                if (xCount == xMaxCount || k == al.Count - 1)
                {
                    s     += "</tr>";
                    xCount = 0;
                }
            }
            s          += "</table>";
            Label2.Text = s;

            if (questionsMarked == al.Count)
            {
                if (SessionsCommon.RedirectStudentToSummaryPage(Session))
                {
                    Response.Redirect("./ObjectiveExamSummary.aspx");
                }
            }


            if (questionID != null)
            {
                // Exam summary now makes a lot of human sense to me. Eeeeee haaaaaa

                DataTable DtQuestion = AptitudeTestBLL.Instance.GetQuestionsByID(Int32.Parse(questionID));
                JG_Prospect.Common.modal.Aptitude.QuestionRow selectedQuestion = new Common.modal.Aptitude.QuestionRow();

                foreach (DataRow Ques in DtQuestion.Rows) // It will be only 1 rows.
                {
                    //selectedQuestion = new Common.modal.Aptitude.QuestionRow();

                    selectedQuestion.QuestionID     = Convert.ToInt32(Ques["QuestionID"]);
                    selectedQuestion.Question       = Ques["Question"].ToString();
                    selectedQuestion.QuestionType   = Convert.ToInt32(Ques["QuestionType"]);
                    selectedQuestion.PositiveMarks  = Convert.ToInt32(Ques["PositiveMarks"]);
                    selectedQuestion.NegetiveMarks  = Convert.ToInt32(Ques["NegetiveMarks"]);
                    selectedQuestion.PictureURL     = "";
                    selectedQuestion.ExamID         = Convert.ToInt32(Ques["ExamID"]);;
                    selectedQuestion.AnswerTemplate = "";
                }

                //JG_Prospect.Common.modal.Aptitude.QuestionRow selectedQuestion = AptitudeTestBLL.Instance.GetQuestionsByID(Int32.Parse(questionID));

                //QuestionType questionType = (QuestionType)selectedQuestion.QuestionType;

                lblQuestion.Text      = "<font color=black>Q" + dispQuestionId + "." + selectedQuestion.Question + "</font>";
                positiveMarks         = selectedQuestion.PositiveMarks;
                negetiveMarks         = selectedQuestion.NegetiveMarks;
                lblPositiveMarks.Text = positiveMarks.ToString();
                lblNegetiveMarks.Text = negetiveMarks.ToString();

                //string pictureURL = selectedQuestion.PictureURL;
                //showPicture(pictureURL);

                if ("SingleSelect" == "SingleSelect")
                {
                    //Single Select
                    #region Single Select

                    pnlMultiSelect.Visible  = false;
                    pnlSingleSelect.Visible = true;
                    pnlPhrase.Visible       = false;

                    ListItemCollection coll = (ListItemCollection)Session[questionID];
                    if (coll != null)
                    {
                        RadioButtonList1.Items.Clear();
                        foreach (ListItem li in coll)
                        {
                            RadioButtonList1.Items.Add(li);
                        }
                        return;
                    }


                    DataTable optionData = AptitudeTestBLL.Instance.GetQuestionsoptionByQustionID(Int32.Parse(questionID));
                    foreach (DataRow OptionRow in optionData.Rows)
                    {
                        string item = OptionRow["OptionText"].ToString();
                        RadioButtonList1.Items.Add(new ListItem(item, item));
                    }

                    #endregion
                }
                //else if (questionType == QuestionType.MultiSelect)
                //{
                //    #region  Multi Select
                //    //Multiple Select
                //    pnlMultiSelect.Visible = true;
                //    pnlSingleSelect.Visible = false;
                //    pnlPhrase.Visible = false;

                //    ListItemCollection coll = (ListItemCollection)Session[questionID];
                //    if (coll != null)
                //    {
                //        CheckBoxList1.Items.Clear();
                //        foreach (ListItem li in coll)
                //            CheckBoxList1.Items.Add(li);
                //        return;
                //    }

                //    OptionTableAdapter optionAdapter = new OptionTableAdapter();
                //    ExamOMaticSchema.OptionDataTable optionData = optionAdapter.GetDataByQuestionID(Int32.Parse(questionID));

                //    for (int k = 0; k < optionData.Rows.Count; k++)
                //    {
                //        string item = optionData[k].OptionText;
                //        CheckBoxList1.Items.Add(new ListItem(item, item));
                //    }
                //    #endregion
                //}
                else
                {
                    //Phrase Mode
                    pnlMultiSelect.Visible  = false;
                    pnlSingleSelect.Visible = false;
                    pnlPhrase.Visible       = true;

                    string str = (string)Session[questionID];
                    if (str != null)
                    {
                        txtAnswer.Text = str;
                    }
                }
            }
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["exam_id"] != null)
            {
                string ExamID = (string)Session["exam_id"];
                //ExamTableAdapter examAdapter = new ExamTableAdapter();
                //String examDuration = examAdapter.GetData().FindByExamID(Int32.Parse(ExamID)).ExamDuration.ToString();
                String examDuration = AptitudeTestBLL.Instance.GetExamDurationByID(ExamID);

                int timeLeft = 0;
                if (Session["currentExamDuration"] != null)
                {
                    timeLeft = (int.Parse(examDuration) * 60) - int.Parse(SessionsCommon.getTimeDifference(Session));
                }
                else
                {
                    timeLeft = int.Parse(examDuration) * 60;
                    Session["currentExamDuration"] = DateTime.Now;
                }
                this.currentExamTime.Value = (timeLeft).ToString();

                DataTable questionTable = AptitudeTestBLL.Instance.GetQuestionsForExamByID(ExamID);

                String s = "<table bgcolor=white border=1>";


                foreach (DataRow QuestionRow in questionTable.Rows)
                {
                    s += "<tr><td>";

                    string i        = QuestionRow["QuestionID"].ToString();
                    object o        = Session[i];
                    string question = QuestionRow["Question"].ToString();
                    s += "<a href=StartExam.aspx?id=" + QuestionRow["QuestionID"] + ">Edit Your Answer</a>" + question + "</a>";

                    String lblType = "", answerString = "";

                    answerString = "You did not yet mark answer for this question!";
                    if ("SingleSelect" == "SingleSelect") //== TODO
                    {
                        ListItemCollection coll = (ListItemCollection)o;
                        if (o != null)
                        {
                            foreach (ListItem item in coll)
                            {
                                if (item.Selected)
                                {
                                    answerString = "The option you selected is <b>" + item.Text;
                                    break;
                                }
                            }
                        }
                        lblType = "Single choice question";
                    }
                    else
                    {
                        if (o != null)
                        {
                            answerString = "The answer you wrote is <b>" + (string)o;
                        }
                        lblType = "Fill in the blank question";
                    }

                    s += "<br><font color=black>" + answerString + "</b></font></td>";

                    s += "<td><b>Question Type:</b> " + lblType + "</td>";
                    s += "</tr>";

                    //s += "<tr><td><font color=black>" + answerString + "</font></td></tr>";
                }
                s += "</table>";
                lblObjectiveSummary.Text = s;
            }
            else
            {
                Response.Redirect("../MCQTest/McqTestPage.aspx");
            }
        }