protected void Page_Load(object sender, EventArgs e)
    {
        DataBase.Exams DbExams = new DataBase.Exams();

        DbExams.RetrieveExams(Convert.ToInt32(Session["IncomingPaper"]));

        string path = String.Format("C://Cosmo//Teachers/QuestionPaper/Exams/Config/{0}", DbExams.ExamData);

        ConfigFile.Sections ConfigSections = new ConfigFile.Sections(path);

        Secs.Add(ConfigSections.SectionCount, ConfigSections.SectionWeight, QuestionPanel);

        DataBase.Questions Quests = new DataBase.Questions(DbExams.ExamCode);

        Quests.RetrieveData();

        foreach (DataRow Row in Quests.DataSet.Tables[0].Rows)
        {
            List <string> ls = new List <string>();

            if (Row["Objective Data"] != DBNull.Value)
            {
                ls = ((string[])Row["Objective Data"]).ToList();
            }

            else
            {
                ls = null;
            }


            AddQuestion(Convert.ToInt32(Row["Section"]), Convert.ToInt32(Row["Question Type"]), Convert.ToInt32(Row["Question Number"]), Row["Question"].ToString(), null, ls);
        }
    }
    public static DataBase.QuestionStructure RetrieveData(int QuestionNumber, int Section)
    {
        DataBase.Questions Questions = new DataBase.Questions("TST008/005");

        DataBase.Questions.ObjectivesContent ObjCont = new DataBase.Questions.ObjectivesContent();
        DataBase.QuestionStructure           Qs      = new DataBase.QuestionStructure();

        Questions.RetrieveData(QuestionNumber, Section);
        Qs.QuestionNumber = Questions.QuestionSructure.QuestionNumber;

        Qs.Question     = Questions.QuestionSructure.Question;
        Qs.QuestionType = Questions.QuestionSructure.QuestionType;
        Qs.Objectives   = Questions.QuestionSructure.Objectives;

        return(Qs);
    }
Exemple #3
0
    public DataBase.QuestionStructure GetQuestionData(string TestCode, int QuestionNumber, int Section)
    {
        Questions = new DataBase.Questions(TestCode);

        Qs = new DataBase.QuestionStructure();

        if (Questions.CheckForQuestionExistance(TestCode, QuestionNumber, Section))
        {
            Questions.RetrieveData(QuestionNumber, Section);
            Qs.QuestionNumber = Questions.QuestionSructure.QuestionNumber;
            Qs.Question       = Questions.QuestionSructure.Question;
            Qs.QuestionType   = Questions.QuestionSructure.QuestionType;
            Qs.Objectives     = Questions.QuestionSructure.Objectives;
        }

        else
        {
        }

        return(Qs);
    }
    public void LoadData(int QuestionNumber, int SectionNumber)
    {
        ClearTemplate();

        char[] Sections = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();


        for (int i = 0; i <= SectionNumber; i++)
        {
            ListItem Li = new ListItem();
            Li.Value = "Section" + " " + Sections[i];

            SectionSelection.Items.Add(Li);



            if (QuestionNumber == 1)
            {
                ButtonPrev.Disabled = true;
            }

            else
            {
                ButtonPrev.Disabled = false;
            }

            qt.InnerText = "Qtn: " + QuestionNumber;

            if (Questions.CheckForQuestionExistance(TestCodeData, QuestionNumber, SectionNumber))
            {
                int count = 1;
                DisableControls(true);
                ButtonNext.InnerText = "NEXT";

                Questions.RetrieveData(QuestionNumber, SectionNumber);

                QuestionTextArea.InnerText = Questions.QuestionSructure.Question;

                List <string> data = new List <string>();

                HtmlTableRow Htr = new HtmlTableRow();

                switch (Questions.QuestionSructure.QuestionType)
                {
                case 1:
                    QuestionTypeDropDown.Items.Add(QuestionTypes[0].ToString());
                    break;

                case 2:
                    QuestionTypeDropDown.Items.Add(QuestionTypes[1].ToString());
                    break;

                case 3:
                    QuestionTypeDropDown.Items.Add(QuestionTypes[2].ToString());
                    break;
                }

                if (Questions.QuestionSructure.Objectives != null)
                {
                    foreach (DataBase.Questions.ObjectivesContent obc in Questions.QuestionSructure.Objectives)
                    {
                        HtmlInputText HtText = (HtmlInputText)obtable.Rows[count].Cells[2].Controls[0].FindControl("TextBox" + count.ToString());

                        HtText.Value = obc.Detail;

                        RadioButton Hradio = (RadioButton)obtable.Rows[count].Cells[3].Controls[0].FindControl("AnswerRadio" + count.ToString());

                        HiddenField Hfield = (HiddenField)obtable.Rows[count].Cells[4].Controls[0].FindControl("HiddenField" + count.ToString());

                        Hfield.Value = obc.ObjID.ToString();


                        if (obc.validity == 1)
                        {
                            Hradio.Checked = true;
                        }
                        else
                        {
                            Hradio.Checked = false;
                        }

                        PopulateObjectives(count);

                        count++;
                    }


                    ViewState["ObjectivesReturnedCount"] = count;
                }
                else
                {
                    PopulateObjectives(0);
                }

                ButtonNext.Visible = true;
                ButtonAdd.Visible  = false;
            }
            else
            {
                ButtonAdd.Visible  = true;
                ButtonNext.Visible = false;
                DisableControls(false);
                LoadOptions();

                LoadQuestionTypes();
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ExData = (Exams)Session["ExamData"];

        try
        {
            TestCode = ExData.ExamCode;

            // TestCode = "TST0041/005";

            MyBank.TestCodeData = this.TestCode;

            DbExams = new DataBase.Exams();

            DbExams.RetrieveExams(TestCode);

            PaperHeader.InnerText = DbExams.ExamName;

            string path = String.Format("C://Cosmo//Teachers/QuestionPaper/Exams/Config/{0}", DbExams.ExamData);

            System.Diagnostics.Debug.WriteLine("There is sec " + ExData.Sections);

            DropDownList SectionSelector = (DropDownList)MyBank.FindControl("SectionSelection");

            ConfigFile MyConfigurations = new ConfigFile(path, ExData.Sections);

            ConfigFile.Sections ConfigSections = new ConfigFile.Sections(path);

            Secs.Add(ConfigSections.SectionCount, ConfigSections.SectionWeight, QuestionPanel);

            DataBase.Questions Qs = new DataBase.Questions(TestCode);


            if (ConfigSections.SectionCount > 1)
            {
                SectionSelector.Visible = true;
            }
            else
            {
                SectionSelector.Visible = false;
            }

            /*Retrieve Question Paper Data from DataSet and Pass it into Table*/

            foreach (int Weight in ConfigSections.SectionWeight)
            {
                System.Diagnostics.Debug.WriteLine("The Ratio is: " + Weight.ToString());
            }

            Qs.RetrieveData();

            DataSet Ds = new DataSet();

            Ds = Qs.DataSet;

            /*Instance of Table Holding Question Data for The Exam Selected*/

            DataTable dt = new DataTable();

            dt = Ds.Tables[0];

            if (dt.Rows.Count > 0)
            {
                QuestionPanel.Style.Add(HtmlTextWriterStyle.BackgroundImage, "url(QuestionPaper/Images/CosmoPaperBackground.png)");
            }

            foreach (DataRow Dr in dt.Rows)
            {
                List <string> ls = new List <string>();

                if (Dr[3] != DBNull.Value)
                {
                    ls = ((string[])Dr[3]).ToList();
                }

                else
                {
                    ls = null;
                }


                AddQuestion(Convert.ToInt32(Dr[4]), Convert.ToInt32(Dr[2]), Convert.ToInt32(Dr[0]), Dr[1].ToString(), ls, null);
            }
        }
        catch
        {
            Response.Redirect("Tests.aspx");
        }
    }