Beispiel #1
0
        public List <ExamLinkComponent> ExamsLinkComponentsFromBaseData(Exam_Board eb, string season, string year)

        {
            List <ExamLinkComponent> temp = new List <ExamLinkComponent>();

            while (year.Length > 2)
            {
                year = year.Substring(1, year.Length - 1);
            }
            string search = "L" + season + "?" + year + "_" + eb.m_LegacyExamBdId + ".X??";

            string[] filelist = System.IO.Directory.GetFiles(path, search);
            foreach (string f in filelist)
            {
                Stream myStream;
                string line;
                int    JCQ_Version = 0;
                if ((myStream = File.Open(f, FileMode.Open)) != null)
                {
                    using (StreamReader sr = new StreamReader(myStream))
                    {
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line.Substring(0, 2) == "L1")
                            {
                                JCQ_Version = System.Convert.ToInt32(line.Substring(24, 2));
                            }
                            if (line.Substring(0, 2) == "L5")
                            {
                                ExamLinkComponent eco1 = new ExamLinkComponent();
                                eco1.LoadFromBaseData(line, JCQ_Version, eb.m_ExamBoardId.ToString());
                                temp.Add(eco1);
                            }
                        }
                    }
                }
            }
            //temp.Sort();

            return(temp);
        }
Beispiel #2
0
        protected void Button_PullBaseData_Click(object sender, EventArgs e)
        {
            // so first we are going to get a list of all options used...

            int c = 0;

            c = System.Convert.ToInt32(TextBox_CycleNumber.Text);
            ISAMS_OptionsUsed_List list1 = new ISAMS_OptionsUsed_List();

            list1.LoadList(c);

            string s = "";

            foreach (ISAMS_OptionUsed o in list1.m_list)
            {
                s += o.m_OptionCode;

                //need the Cerval ExamBde Guid
                Exam_Board CExamBoard = new Exam_Board(o.m_UABCode);

                // so load option / link /components
                ISAMS_ExamOption Opt = new ISAMS_ExamOption();
                Opt.Load(c, o.m_OptionCode, o.m_UABCode);
                s += "  :  " + Opt.m_OptionTitle;
                ISAMS_ExamSyllabus Syl = new ISAMS_ExamSyllabus();
                Syl.Load(Opt.m_cycle, Opt.m_ExamBoardCode, Opt.m_Syllabus_Code);
                ISAMS_ExamLink_List Link = new ISAMS_ExamLink_List();
                Link.LoadList_Option(Opt.m_OptionCode, Opt.m_ExamBoardCode, Opt.m_cycle);

                //so try to find the Ceral Syllabus
                ExamSyllabus CSyllabus = new ExamSyllabus();
                CSyllabus.Load(Syl.m_SyllabusCode, SeasonCode.ToString(), YearCode.ToString(), CExamBoard.m_ExamBoardId);
                if (!CSyllabus.m_valid)
                {
                    CSyllabus.m_ExamBoardId    = CExamBoard.m_ExamBoardId;
                    CSyllabus.m_Syllabus_Code  = Syl.m_SyllabusCode;
                    CSyllabus.m_Syllabus_Title = Syl.m_SyllabusTitle;

                    CSyllabus.m_SyllabusId = CSyllabus.CreateNew("22");
                }

                //now try to find the option

                ExamOption COption = new ExamOption();
                COption.Load(Opt.m_OptionCode, SeasonCode.ToString(), YearCode.ToString(), Opt.m_ExamBoardCode);
                if (COption.m_valid)
                {
                    //option found...
                }
                else
                {
                    //option not found need to create...
                    COption.m_SyllabusID          = CSyllabus.m_SyllabusId;
                    COption.m_OptionCode          = Opt.m_OptionCode;
                    COption.m_OptionTitle         = Opt.m_OptionTitle;
                    COption.m_OptionQualification = Opt.m_OptionQualification;
                    COption.m_OptionLevel         = Opt.m_OptionLevel;
                    COption.m_Item              = Opt.m_Item;
                    COption.m_Process           = Opt.m_Process;
                    COption.m_QCACode           = Opt.m_QCACode;
                    COption.m_QCANumber         = Opt.m_QCANumber;
                    COption.m_fee               = Opt.m_fee;
                    COption.m_OptionMaximumMark = Opt.m_OptionMaximumMark;
                    COption.m_year_Code         = YearCode.ToString();
                    COption.m_Season_code       = SeasonCode.ToString();
                    COption.m_SeriesIdentifier  = Opt.m_SeriesIdentifier;

                    COption.m_OptionID = COption.CreateNew("22");
                }


                foreach (ISAMS_ExamLink el1 in Link.m_list)
                {
                    ISAMS_ExamComponent ec1 = new ISAMS_ExamComponent();
                    ec1.Load(el1.m_ComponentCode, Opt.m_cycle, Opt.m_ExamBoardCode);
                    s += "  &  " + ec1.m_ComponentTitle;
                    //so should be able to insert into Cerval



                    //OK so now the components...
                    ExamComponent CComp = new ExamComponent();
                    CComp.Load(ec1.m_ComponentCode, SeasonCode.ToString(), YearCode.ToString());
                    if (!CComp.m_valid)
                    {
                        //so need to create
                        CComp.m_ComponentCode  = ec1.m_ComponentCode;
                        CComp.m_ComponentTitle = ec1.m_ComponentTitle;
                        CComp.m_ExamBoardID    = CExamBoard.m_ExamBoardId;
                        CComp.m_year           = YearCode.ToString();
                        CComp.m_season         = SeasonCode.ToString();
                        CComp.m_Teachermarks   = ec1.m_Teachermarks;
                        CComp.m_MaximumMark    = ec1.m_MaximumMark;
                        CComp.m_Due_Date       = ec1.m_Due_Date;
                        CComp.m_Timetabled     = ec1.m_Timetabled;

                        CComp.m_TimetableSession = ec1.m_TimetableSession;
                        CComp.m_Time             = ec1.m_TimeAllowed;
                        DateTime t1 = new DateTime(); t1 = System.Convert.ToDateTime(ec1.m_TimetableDate);
                        CComp.m_TimetableDate = t1;

                        CComp.m_ComponentID = CComp.CreateNew();
                    }

                    ExamLinkComponent_List l2 = new ExamLinkComponent_List();
                    l2.LoadList_OptionComponent(COption.m_OptionID, CComp.m_ComponentID);
                    if (l2.m_list.Count == 0)
                    {
                        //need to make the link
                        ExamLinkComponent Clink = new ExamLinkComponent();
                        Clink.m_OptionId    = COption.m_OptionID;
                        Clink.m_ComponentId = CComp.m_ComponentID;
                        Clink.CreateNew("22");
                    }
                }
                s += Environment.NewLine;
            }
            TextBox_test.Text = s;
        }
Beispiel #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //create table...

            List <ExamSyllabus>      syllabuses = new List <ExamSyllabus>();
            List <ExamComponent>     components = new List <ExamComponent>();
            List <ExamBaseOption>    options    = new List <ExamBaseOption>();
            List <ExamLinkComponent> Links      = new List <ExamLinkComponent>();
            string s = TextBox1.Text; Label1.Text = "";

            Label1.BackColor = System.Drawing.Color.White;
            string[]  s1 = new string[20];
            char[]    c1 = new char[2]; char c2 = (char)0x09; c1[0] = c2; c1[1] = ',';
            string[]  s2 = new string[1]; s2[0] = Environment.NewLine;
            string [] s3 = new string[10];
            s1 = s.Split(s2, StringSplitOptions.RemoveEmptyEntries);
            int    n = -1; bool correct = true;
            string errorstring = "";

            foreach (string s5 in s1)
            {
                n++;
                if (n == 0)
                {
                    //so this needs to be Subject	Option	Component   CODE    Date	Length	AM/PM
                    s3      = s5.Split(c1);
                    correct = (s3[0].ToUpper() == "SUBJECT") && (s3[1].ToUpper() == "OPTION") && (s3[2].ToUpper() == "COMPONENT");
                    correct = correct && (s3[3].ToUpper() == "CODE");
                    correct = correct && (s3[4].ToUpper() == "DATE") && (s3[5].ToUpper() == "LENGTH") && (s3[6].ToUpper() == "AM/PM");
                }
                if (!correct)
                {
                    errorstring = "Header Row incorrect; should be  Subject	Option	Component	Date	Length	AM/PM"; break;
                }

                if (n > 0)
                {
                    s3 = s5.Split(c1); int k = 1;
                    //so s3[0] has subject
                    ExamSyllabus es1 = new ExamSyllabus();
                    es1.m_Syllabus_Title = s3[0];


                    es1.m_Syllabus_Code = s3[0].Substring(0, 2) + k.ToString();
                    while (es1.m_Syllabus_Code.Length < 6)
                    {
                        es1.m_Syllabus_Code += " ";
                    }
                    while (es1.m_Syllabus_Title.Length < 36)
                    {
                        es1.m_Syllabus_Title += " ";
                    }

                    //check code unique
                    foreach (ExamSyllabus es in syllabuses)
                    {
                        if ((es.m_Syllabus_Code == es1.m_Syllabus_Code) && (es.m_Syllabus_Title != es1.m_Syllabus_Title))
                        {
                            k++; es1.m_Syllabus_Code = s3[0].Substring(0, 2) + k.ToString();
                            while (es1.m_Syllabus_Code.Length < 6)
                            {
                                es1.m_Syllabus_Code += " ";
                            }
                        }
                    }

                    syllabuses.Add(es1);
                    ExamBaseOption ebo1 = new ExamBaseOption();
                    ebo1.m_Title = s3[1]; k = 1;
                    if (s3[1].Contains("["))
                    {
                        //use defined code after [
                        int i1 = s3[1].IndexOf("[");
                        int i2 = s3[1].IndexOf("]");
                        ebo1.m_OptionEntryCode = s3[1].Substring(i1 + 1, i2 - i1 - 1);
                        ebo1.m_Title           = s3[1].Substring(0, i1);
                    }
                    else
                    {
                        ebo1.m_OptionEntryCode = s3[1].Substring(0, 2) + k.ToString();
                        //check code unique
                        foreach (ExamBaseOption ebo in options)
                        {
                            if ((ebo.m_OptionEntryCode == ebo1.m_OptionEntryCode) && (ebo.m_Title != ebo1.m_Title))
                            {
                                k++; ebo1.m_OptionEntryCode = s3[1].Substring(0, 2) + k.ToString();
                                while (ebo1.m_OptionEntryCode.Length < 6)
                                {
                                    ebo1.m_OptionEntryCode += " ";
                                }
                            }
                        }
                    }


                    ebo1.m_SyllabusCode = es1.m_Syllabus_Code;
                    while (ebo1.m_OptionEntryCode.Length < 6)
                    {
                        ebo1.m_OptionEntryCode += " ";
                    }
                    while (ebo1.m_Title.Length < 36)
                    {
                        ebo1.m_Title += " ";
                    }

                    options.Add(ebo1);

                    ExamComponent ec1 = new ExamComponent();
                    k = 1; int    t1 = 0;
                    ec1.m_ComponentCode  = s3[3];
                    ec1.m_ComponentTitle = s3[2];
                    ec1.m_Time           = s3[5];
                    ec1.m_TimetableDate  = new DateTime();
                    try { ec1.m_TimetableDate = System.Convert.ToDateTime(s3[4]); }catch { errorstring = "Time must be in format dd/mm/yyyy"; correct = false; break; }
                    ec1.m_TimetableSession = s3[6];
                    try { t1 = Convert.ToInt16(s3[5]); } catch { errorstring = "Length must be an integer."; correct = false; break; }
                    while (ec1.m_Time.Length < 3)
                    {
                        ec1.m_Time = "0" + ec1.m_Time;
                    }
                    while (ec1.m_ComponentCode.Length < 12)
                    {
                        ec1.m_ComponentCode += " ";
                    }
                    while (ec1.m_ComponentTitle.Length < 36)
                    {
                        ec1.m_ComponentTitle += " ";
                    }

                    //check code unique
                    foreach (ExamComponent ec in components)
                    {
                        if ((ec.m_ComponentCode == ec1.m_ComponentCode) && (ec.m_ComponentTitle != ec1.m_ComponentTitle))
                        {
                            k++; ec1.m_ComponentCode = s3[2].Substring(0, 2) + k.ToString(); while (ec1.m_ComponentCode.Length < 12)
                            {
                                ec1.m_ComponentCode += " ";
                            }
                        }
                    }
                    components.Add(ec1);


                    ExamLinkComponent el0 = new ExamLinkComponent();
                    el0.m_ComponentCode = ec1.m_ComponentCode;
                    el0.m_OptionCode    = ebo1.m_OptionEntryCode;
                    Links.Add(el0);


                    TableRow r = new TableRow();
                    Table1.Rows.Add(r);
                    TableCell cell1 = new TableCell(); cell1.Text = es1.m_Syllabus_Title; r.Cells.Add(cell1);
                    TableCell cell2 = new TableCell(); cell2.Text = es1.m_Syllabus_Code; r.Cells.Add(cell2);
                    TableCell cell3 = new TableCell(); cell3.Text = ebo1.m_Title; r.Cells.Add(cell3);
                    TableCell cell4 = new TableCell(); cell4.Text = ebo1.m_OptionEntryCode; r.Cells.Add(cell4);
                    TableCell cell5 = new TableCell(); cell5.Text = ec1.m_ComponentTitle; r.Cells.Add(cell5);
                    TableCell cell6 = new TableCell(); cell6.Text = ec1.m_ComponentCode; r.Cells.Add(cell6);
                    TableCell cell7 = new TableCell(); cell7.Text = ec1.m_TimetableDate.ToShortDateString(); r.Cells.Add(cell7);
                    TableCell cell8 = new TableCell(); cell8.Text = ec1.m_Time.ToString(); r.Cells.Add(cell8);
                    TableCell cell9 = new TableCell(); cell9.Text = ec1.m_TimetableSession; r.Cells.Add(cell9);
                }
            }
            if (correct)
            {
                Table1.Visible          = true;
                Label1.Text             = "Data Correctly Parsed.....";
                Button_Upload.Visible   = true;
                ViewState["syllabuses"] = syllabuses;
                ViewState["components"] = components;
                ViewState["options"]    = options;
                ViewState["Links"]      = Links;
            }
            else
            {
                Label1.Text = errorstring; Label1.BackColor = System.Drawing.Color.Red;
            }
        }