Beispiel #1
0
        public ExamOption Find_Option(string code, Exam_Board eb, string season, string year)
        {
            //find the entry in db... or search basedata files
            code = code + "     ";
            if (code.Length > 6)
            {
                code = code.Substring(0, 6);
            }
            ExamOption exo1 = new ExamOption();

            exo1.Load(code, season, year, eb.m_ExamBoardId);
            if (exo1.m_valid)
            {
                return(exo1);
            }

            string search = "O" + season + "?" + year + "_" + eb.m_LegacyExamBdId + ".X??";

            string[] filelist = System.IO.Directory.GetFiles(path, search);

            foreach (string s1 in filelist)
            {
                int n = s1.ToUpper().IndexOf("O");
                n = s1.ToUpper().LastIndexOf("O");
                string s      = s1.Substring(n);
                string series = s.Substring(1, 2);
                exo1 = Find_OptionEntry1(s, code, eb, season, series, year);
                if (exo1 != null)
                {
                    return(exo1);
                }
            }
            return(null);
        }
Beispiel #2
0
        protected void Button_Upload_Click(object sender, EventArgs e)
        {
            string     id   = DropDownList_ExamBoards.SelectedValue;
            Exam_Board eb1  = new Exam_Board(new Guid(id));
            string     s1   = DropDownList_data.SelectedValue;
            ExamOption exo1 = new ExamOption();
            ExamFiles  ef1  = new ExamFiles();

            exo1.Load(s1, SeasonCode.ToString(), YearCode.ToString(), eb1.m_LegacyExamBdId);
            if (!exo1.m_valid)
            {
                ExamOption exo2 = ef1.Find_Option(s1, eb1, SeasonCode.ToString(), YearCode.ToString());
                if (exo2 != null)
                {
                    //Label_Result.Text = "Successfully uploaded " + exo.m_OptionCode + " : " + exo.m_OptionTitle + " to Cerval";
                    //DropDownList1.SelectedIndex = -1;
                    //ListItem l = DropDownList1.SelectedItem;
                    //DropDownList1.Items.Remove(l);
                }
                else
                {
                    //Label_Result.Text = "Failed to upload " + exo.m_OptionCode + " : " + exo.m_OptionTitle + " to Cerval";
                }
            }
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString.Count >= 2)
                {
                    string s   = "test";
                    string id0 = Request.QueryString["StudentId"];
                    ViewState.Add("StudentId", id0);
                    string id1 = Request.QueryString["OptionId"];
                    ExamComponentResultList ecrl1 = new ExamComponentResultList();
                    ecrl1.Load_OptionStudent(new Guid(id1), new Guid(id0));
                    SimplePupil   pupil1 = new SimplePupil(); pupil1.Load(id0);
                    ExamOption    exo1   = new ExamOption(); exo1.Load(new Guid(id1));
                    ExamComponent ec1    = new ExamComponent();
                    ResultsList   rl1    = new ResultsList();
                    rl1.LoadListSimple(" WHERE (ExamsOptionId = '" + id1 + "') AND (StudentID = '" + id0 + "')");
                    Result r1 = new Result();
                    r1 = (Result)rl1._results[0];
                    s  = " <p><h3> Component Scores for ";
                    s += pupil1.m_GivenName + " " + pupil1.m_Surname + " for " + exo1.m_OptionTitle + "(" + r1.Text + ")</h3></p>";
                    s += "This table gives your component marks for this subject. Please note these are <b>not</b> UMS marks. ";
                    s += "<br/> The sum of the component marks gives your TQM (Total Qualification Mark), which leads to your final grade.";
                    s += "The table below tells you how the TQM is related to the final grade, i.e. the grade boundaries, if we know them! If not, please speak to a member of staff in school.";

                    s += "<br/><br /> Note that for Drama and Music the non-integer Scaling factors may mean that the component marks do not exactly add up to the TQM. In this case the TQM is CORRECT!<br/>";

                    s += "<br/><br /><TABLE BORDER   class=\"ResultsTbl\" style = \"font-size:small\"   align=\"center\">";
                    s += "<TR><th>Syllabus Code</th><th>Option Code</th><th>Component Code</th><th>Component Name</th>";
                    s += "<th>Mark</th> <th>Max Mark</th></tr>";
                    foreach (ExamComponentResult r in ecrl1.m_list)
                    {
                        ec1.Load(r.ComponentId);
                        s += "<tr align=\"center\">";
                        s += "<td>" + exo1.m_Syllabus_Code + "</td>";
                        s += "<td>" + exo1.m_OptionCode + "</td>";
                        s += "<td>" + ec1.m_ComponentCode + "</td>";
                        s += "<TD>" + ec1.m_ComponentTitle + "</td>";
                        s += "<td>" + r.ComponentScaledMark.ToString() + "</td>";
                        s += "<td>" + ec1.m_MaximumMark.ToString() + "</td>";
                        s += " </tr>";
                    }
                    s += "</table>";
                    ExamTQMBoundaryList bl1 = new ExamTQMBoundaryList();//will be ordered largest first
                    bl1.LoadList(new Guid(id1), exo1.m_year_Code, exo1.m_Season_code);

                    s += "<br/><br/>"; s += " <p><h3 align=\"center\" > TQM Grade Boundaries</h3></p>";
                    s += "<TABLE BORDER   class=\"TimetableTable\" style = \"font-size:small\" align=\"center\"  >";
                    s += "<tr><th>Grade</th><th>  TQM   </th></tr>";
                    foreach (ExamTQMBoundary eb in bl1.m_list)
                    {
                        s += "<tr><td>" + eb.Grade + "</td><td>" + eb.Mark + "</td></tr>";
                    }

                    s += "</table>";

                    content.InnerHtml = s;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsRetakeActive())
            {
                servercontent.InnerHtml = "<H3><center>No re-take entries are possible at this time.</center></H3>";
                Label1.Visible          = false; TextBox_cost.Visible = false;
                Button_submit.Visible   = false;
                Label_title.Visible     = false;
                return;
            }

            Utility u1 = new Utility();

            PersonID = u1.GetPersonIdfromRequest(Request);
#if DEBUG
            //u1.Is_student = true; PersonID = u1.GetPersonIDX(@"CHALLONERS\michael.warren");//development
            //u1.Is_student = true;PersonID = u1.GetPersonIDX(@"CHALLONERS\Henry.Anning");//development
#endif
            //u1.Is_student = true; PersonID = u1.GetPersonIDX(@"CHALLONERS\Benjamin.Smith1");//development
            if ((PersonID == Guid.Empty))
            {
                Response.Write("<center> No Data to display</center>"); return;
            }

            if (!IsPostBack)
            {
                ViewState.Add("PersonID", PersonID);
                ResultsList rl = new ResultsList();
                rl.LoadList("StudentPersonId", PersonID.ToString());
                resultlist1._results.Clear();
                ExamOption exo1 = new ExamOption();

                TextBox_cost.Text = "0";
                //first time we load ... get the results data...
                foreach (Result res1 in rl._results)
                {
                    if (res1.OptionItem == "U")
                    {
                        Result r1 = new Result();
                        r1 = res1; r1.Valid = false;
                        exo1.Load(res1.OptionId);
                        exo1.Load(exo1.m_OptionCode, RetakeSeason(), RetakeYear(), exo1.m_ExamBoardID);
                        r1.Valid = exo1.m_valid;
                        //if (exo1.NeedsTeacherMarks()) r1.Valid = false;//try to disable csewrk modules..??
                        resultlist1._results.Add(r1);
                        r1.OptionId = exo1.m_OptionID;//update optionID!!!!
                    }
                }
                ViewState.Add("ResultList", resultlist1);
            }
            resultlist1 = (ResultsList)ViewState["ResultList"];
            int cost = AddControls(resultlist1, !IsPostBack);
            if (!IsPostBack)
            {
                double x = (double)cost;
                x = x / 100;
                TextBox_cost.Text = x.ToString();
                ViewState.Add("cost", cost);
            }
        }
Beispiel #5
0
        public ExamInfo GenerateProcessItems(ExamOption selection)
        {
            ExamInfo exameInfo = new ExamInfo();

            if (string.IsNullOrWhiteSpace(selection.columnName))
            {
                throw new Exception("Error: course name is not decided.");
            }

            string sqlQuery = "Select * from dbo." + selection.tableName + " Where CourseName = N'" + selection.columnName + "'";

            if (selection.genType == ExamItemGenerateType.RandomSelection)
            {
                sqlQuery = "SELECT TOP " + selection.count.ToString() + " * FROM dbo." + selection.tableName + " Where CourseName = N'" + selection.columnName + "' ORDER BY NEWID()";
            }

            exameInfo.courseName          = selection.courseName;
            exameInfo.columnName          = selection.columnName;
            exameInfo.description         = selection.description;
            exameInfo.dispType            = selection.dispType;
            exameInfo.quitType            = selection.quitType;
            exameInfo.askBackLimitTimes   = selection.askbackTimeLimitation;
            exameInfo.items               = GenerateProcessItems(sqlQuery);
            exameInfo.summerizerClassName = selection.summerizerClassName;
            exameInfo.quitMessage         = selection.quitMessage;
            exameInfo.restartMessage      = selection.restartMessage;

            return(exameInfo);
        }
Beispiel #6
0
        protected void DropDownList_data_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DropDownList_data.SelectedIndex > -1)
            {
                string     id = DropDownList_ExamBoards.SelectedValue; string s = "";
                Exam_Board eb = new Exam_Board(new Guid(id));
                ExamFiles  ef = new ExamFiles();
                foreach (ExamBaseOption ebo in ef.ExamsOptionsFromBaseData(eb, SeasonCode.ToString(), YearCode.ToString()))
                {
                    if (ebo.m_OptionEntryCode == DropDownList_data.SelectedValue)
                    {
                        s  = "Option Code:           " + ebo.m_OptionEntryCode + Environment.NewLine;
                        s += "Option Title:          " + ebo.m_Title + Environment.NewLine;
                        s += "Qualification/Level:   " + ebo.m_Qualification + ebo.m_Level + Environment.NewLine;
                        s += "Cost:                  " + ebo.m_Fee + Environment.NewLine;
                        s += "SyllabusCode:          " + ebo.m_SyllabusCode + Environment.NewLine;
                        s += "Item (C=Cert.):        " + ebo.m_Item + Environment.NewLine;
                        s += "QCA Number:             " + ebo.m_QCANumber + Environment.NewLine;
                        ExamOption eo1 = new ExamOption();
                        if (eo1.Load(DropDownList_data.SelectedValue, SeasonCode.ToString(), YearCode.ToString(), eb.m_ExamBoardId))
                        {
                            s += Environment.NewLine + Environment.NewLine + "Option is known to Cerval";
                        }
                        else
                        {
                            s += Environment.NewLine + Environment.NewLine + "Option is NOT known to Cerval";
                        }


                        TextBox1.Text = s;
                    }
                }
            }
        }
        private void SetUpForReatkes()
        {
            List <ExamOption> list1 = new List <ExamOption>();
            int             no_new = 0; int no_found = 0; string Errors = "The following Options seem not to be offered this summer:  ";
            ExamOption_List exoL1 = new ExamOption_List();
            ExamFiles       ef1   = new ExamFiles();
            ExamOption      exo1  = new ExamOption();

            //load results for last JUNE sitting now.

            exoL1.Load((YearCode - 1).ToString(), SeasonCode.ToString());

            foreach (ExamOption exo in exoL1.m_list)
            {
                Exam_Board eb1 = new Exam_Board(exo.m_ExamBoardID);
                exo1.Load(exo.m_OptionCode, SeasonCode.ToString(), YearCode.ToString(), eb1.m_LegacyExamBdId);
                if (exo1.m_valid)
                {
                    no_found++;
                }
                else
                {
                    if (!exo.NeedsTeacherMarks())
                    {
                        ExamOption exo2 = ef1.Find_Option(exo.m_OptionCode, eb1, SeasonCode.ToString(), YearCode.ToString());
                        if (exo2 != null)
                        {
                            no_new++;
                        }
                        else
                        {
                            Errors += exo.m_OptionCode + ",  ";
                        }
                    }
                    else
                    {
                        list1.Add(exo);  //list has those needing teacher marks
                    }
                }
            }
            Label_Result.Text = "We made  " + no_new.ToString() + " new options and found already " + no_found.ToString();
            Label_Error.Text  = Errors;
            //now need to offer those with coursework...
            if (list1.Count > 0)
            {
                DropDownList1.Visible = true; Button_Upload.Visible = true;
                foreach (ExamOption e in list1)
                {
                    ListItem l = new ListItem(e.m_OptionCode + e.m_OptionTitle, e.m_OptionID.ToString());
                    DropDownList1.Items.Add(l);
                }
                LabelDropDown.Text = "The list below are options that require Teacher marks... select and add any you want students to see.";
            }
        }
        protected void Button_Upload_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow r in GridView1.Rows)
            {
                if (r.BackColor == System.Drawing.Color.Red)
                {
                    string ErrorMsg = ""; Label_Error.Text = "";

                    Exam_ResitEntry exr1 = new Exam_ResitEntry();
                    Guid            g1   = new Guid(r.Cells[1].Text);
                    exr1.Load(g1);

                    ExamOption exo1 = new ExamOption();
                    exo1.Load(exr1.m_OptionId);
                    Exam_Board   exbde1 = new Exam_Board(exo1.m_ExamBoardID);
                    Guid         g2     = new Guid(); g2 = Guid.Empty;
                    ExamsUtility u      = new ExamsUtility();
                    try
                    {
                        if (u.AddEntry(new Guid(StudentID), exbde1, Year, YearCode, SeasonCode, r.Cells[2].Text, 1, true, ref ErrorMsg, ref g2))
                        {
                            //it worked so delete the resit entry
                            exr1.Delete();
                            Encode en = new Encode();
                            SqlDataSource1.SelectCommand    = GetQueryString();
                            SqlDataSource1.ConnectionString = en.GetDbConnection();
                            SqlDataSource1.DataBind();
                        }
                        else
                        {
                            //it didn't
                            Label_Error.Text = ErrorMsg; break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Label_Error.Text = ex.ToString(); break;
                    }
                }
            }
            int cost = 0;

            foreach (GridViewRow r in GridView1.Rows)
            {
                if (r.BackColor == System.Drawing.Color.Red)
                {
                    cost += System.Convert.ToInt32(r.Cells[5].Text);
                }
            }
            double costd = (double)cost / 100;

            Label_cost.Text = " Total cost of selected = £" + costd.ToString();
        }
Beispiel #9
0
        public void Install_Components(string OptionCode, string l_file, string c_file, Exam_Board ExamBoard, string season, string year)
        {
            string     s, line;
            Stream     myStream;
            string     LinkOption    = "";
            string     LinkComponent = "";
            ExamOption opt1          = new ExamOption();
            Guid       opt1ID        = new Guid();
            Guid       com1ID        = new Guid();

            opt1.Load(OptionCode, season, year, ExamBoard.m_ExamBoardId);
            opt1ID = opt1.m_OptionID;

            //TODO    ADD EXCEPTION HANDLING... IF LINE <12

            if ((myStream = File.Open(l_file, FileMode.Open)) != null)
            {
                using (StreamReader sr = new StreamReader(myStream))
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        s          = line.Substring(0, 2);
                        LinkOption = line.Substring(2, 6);
                        if ((s == "L5") && (LinkOption == OptionCode))
                        {
                            LinkComponent = line.Substring(8, 12);
                            com1ID        = Find_Component(c_file, LinkComponent, ExamBoard.m_ExamBoardId.ToString(), season, year, true);//forceupdate = true means it will search basedata to check OK
                            //now check the link file
                            ExamLinkComponent_List elcl1 = new ExamLinkComponent_List(); elcl1.LoadList_Option(opt1.m_OptionID);
                            bool found = false;
                            foreach (ExamLinkComponent ec1 in elcl1.m_list)
                            {
                                if (ec1.m_ComponentId == com1ID)
                                {
                                    found = true;
                                }
                            }
                            if (!found)
                            {
                                s  = " INSERT INTO dbo.tbl_Exams_Link  ( OptionID, ComponentID ) ";
                                s += " VALUES ('" + opt1ID.ToString() + "' , '" + com1ID.ToString() + "' )";
                                if ((opt1.m_valid) && (com1ID != Guid.Empty))
                                {
                                    ExecuteSQL(s);
                                }
                            }
                        }
                    }
                }
            }
            return;
        }
Beispiel #10
0
        private ExamOption Find_OptionEntry1(string f, string code, Exam_Board eb, string season, string series, string year)
        {
            ExamOption exo1 = new ExamOption();

            if (exo1.Load(code, season, year, eb.m_ExamBoardId))
            {
                return(exo1);
            }
            Stream myStream;
            string s      = "";
            string s1     = "";
            string s2     = "";
            string s_file = "S" + f.Substring(1, f.Length - 1);
            string line;
            string Qualification;
            int    JCQ_Version = 0;

            if ((myStream = File.Open(path + f, FileMode.Open)) != null)
            {
                using (StreamReader sr = new StreamReader(myStream))
                {
                    //ExamFiles exfiles1 = new ExamFiles();
                    while ((line = sr.ReadLine()) != null)
                    {
                        s             = line.Substring(0, 2);
                        Qualification = line.Substring(14, 4);
                        s1            = line.Substring(2, 6);
                        if (code.Length > 6)
                        {
                            code = code.Substring(0, 6);
                        }
                        s2 = line.Substring(8, 6);//syllabus code..
                        if (s == "O1")
                        {
                            JCQ_Version = Convert.ToInt32(line.Substring(24, 2));
                        }
                        if ((s1.Trim().ToUpper() == code.Trim().ToUpper()) && (s == "O5"))
                        {
                            Load_Option(line, eb, season, series, year, s_file, path, JCQ_Version);
                            if (exo1.Load(s1, season, year, eb.m_ExamBoardId))
                            {
                                return(exo1);
                            }
                        }
                    }
                }
            }
            return(null);//not found
        }
        protected void Button_Enter_Click(object sender, EventArgs e)
        {
            //do the entry....
            List <Guid> students = new List <Guid>();

            students = (List <Guid>)ViewState["studentlist"];
            List <Guid> Options = new List <Guid>();

            foreach (ListItem item in ListBox_Options.Items)
            {
                if (item.Selected)
                {
                    Options.Add(new Guid(item.Value));
                }
            }
            ExamsUtility u = new ExamsUtility();
            string       Errors = ""; Guid g2 = new Guid();
            int          n = 0;

            foreach (Guid g in Options)
            {
                ExamOption eo1 = new ExamOption(); eo1.Load(g);
                Exam_Board eb1 = new Exam_Board(eo1.m_ExamBoardID);
                foreach (Guid g1 in students)
                {
                    //try {
                    u.AddEntry(g1, eb1, Year, YearCode, SeasonCode, eo1.m_OptionCode, 2, false, ref Errors, ref g2);
                    n++;
                    //}
                    //catch
                    //{
                    //    n = n;
                    // }
                }
            }
            TextBox2.Text        = ""; TextBox2.Visible = false;
            TextBox1.Text        = " Made " + n.ToString() + "  Entries";
            ButtonTest.Visible   = false;
            Button_Enter.Visible = false;
            DropDownList_Course.SelectedIndex = -1;
            foreach (ListItem item in ListBox_Options.Items)
            {
                if (item.Selected)
                {
                    item.Selected = false;
                }
            }
        }
Beispiel #12
0
        protected void Button_Update_Click(object sender, EventArgs e)
        {
            //so first check we have a valid option and value
            int v = 0;

            try
            {
                v = System.Convert.ToInt32(TextBox_Value.Text);
            }
            catch
            {
                //flag error
                return;
            }
            ExamOption ex1 = new ExamOption();

            ex1.Load(new Guid(DropDownList_Options.SelectedValue));
            if (!ex1.m_valid)
            {
                //flag error
                return;
            }

            ExamTQMBoundaryList exTQMlist1 = new ExamTQMBoundaryList();

            exTQMlist1.LoadList(ex1.m_OptionID, YearCode.ToString(), SeasonCode.ToString());
            bool found = false;

            foreach (ExamTQMBoundary eb in exTQMlist1.m_list)
            {
                if (eb.Grade == DropDownList_Grades.SelectedItem.Value)
                {
                    found   = true;
                    eb.Mark = v;
                    eb.Save();
                    break;
                }
            }
            if (!found)
            {
                ExamTQMBoundary eb1 = new ExamTQMBoundary();
                eb1.OptionId = ex1.m_OptionID; eb1.Season = SeasonCode.ToString(); eb1.Year = YearCode.ToString();
                eb1.Grade    = DropDownList_Grades.SelectedItem.Value; eb1.Mark = v; eb1.Version = 1;
                eb1.Save();
            }
            exTQMlist1.LoadList(ex1.m_OptionID, YearCode.ToString(), SeasonCode.ToString());
            Current_Data.InnerHtml = UpdateCurrentData(exTQMlist1);
        }
        protected void GridView1_DataBound(object sender, EventArgs e)
        {
            //going to check if any need teacher marks.
            string s = "";

            foreach (GridViewRow r in GridView1.Rows)
            {
                Exam_ResitEntry exr1 = new Exam_ResitEntry();
                Guid            g1   = new Guid(r.Cells[1].Text);
                exr1.Load(g1);
                ExamOption exo1 = new ExamOption(); exo1.Load(exr1.m_OptionId);
                if (exo1.NeedsTeacherMarks())
                {
                    s += "WARNING: Option " + r.Cells[2].Text + " requires Teacher Marks!   ";
                }
            }
            Label_Error.Text = s;
        }
        protected void Button_Opt_Find_Click(object sender, EventArgs e)
        {
            //find code...
            string s     = TextBox_FindOption.Text.ToUpper().Trim();
            bool   found = false;

            foreach (ListItem item in ListBox_Options.Items)
            {
                if (item.Text.Substring(0, 6).ToUpper().Trim() == s)
                {
                    item.Selected = true; found = true; TextBox_FindOption.Text = "";
                }
            }
            if (found)
            {
                return;
            }
            found = false; ExamOption eo1 = new ExamOption();
            ExamBoardList             ebl1 = new ExamBoardList(); ExamFiles ef1 = new ExamFiles();

            foreach (Exam_Board eb in ebl1._ExamBoardList)
            {
                eo1 = ef1.Find_Option(s, eb, SeasonCode.ToString(), YearCode.ToString());
                if (eo1 != null)
                {
                    found = true; break;
                }
            }
            if (!found)
            {
                TextBox1.Text = "NOT FOUND!!!!"; TextBox1.Visible = true; return;
            }

            ListItem i1 = new ListItem(eo1.m_OptionCode + ":" + eo1.m_OptionTitle, eo1.m_OptionID.ToString());

            ListBox_Options.Items.Add(i1);
            foreach (ListItem item in ListBox_Options.Items)
            {
                if (item.Text.Substring(0, 6).ToUpper().Trim() == s)
                {
                    item.Selected = true; found = true; TextBox_FindOption.Text = "";
                }
            }
        }
Beispiel #15
0
        protected void Button_Delete_Click(object sender, EventArgs e)
        {
            ExamOption ex1 = new ExamOption();

            ex1.Load(new Guid(DropDownList_Options.SelectedValue));
            if (!ex1.m_valid)
            {
                //flag error
                return;
            }
            ExamTQMBoundaryList exTQMlist1 = new ExamTQMBoundaryList();

            exTQMlist1.LoadList(ex1.m_OptionID, YearCode.ToString(), SeasonCode.ToString());
            foreach (ExamTQMBoundary eb in exTQMlist1.m_list)
            {
                eb.Delete();
            }
            exTQMlist1.LoadList(ex1.m_OptionID, YearCode.ToString(), SeasonCode.ToString());
            Current_Data.InnerHtml = UpdateCurrentData(exTQMlist1);
        }
Beispiel #16
0
        protected void Button_PullEntries_Click(object sender, EventArgs e)
        {
            ISAMS_SimpleExamEntry_List IEntries = new ISAMS_SimpleExamEntry_List();

            int c = 0;

            c = System.Convert.ToInt32(TextBox_CycleNumber.Text);
            IEntries.LoadList(c);

            foreach (ISAMS_SimpleExamEntry Ien in IEntries.m_list)
            {
                //need to find Guids for Pupil, OPtion etc...
                Utility u   = new Utility();
                Guid    SId = new Guid();
                SId = u.GetStudentIDfromiSAMS(Ien.m_PupilId);
                Exam_Board eb1 = new Exam_Board(Ien.m_UABCode);
                ExamOption eo1 = new ExamOption();
                eo1.Load(Ien.m_OptionCode, SeasonCode.ToString(), YearCode.ToString(), Ien.m_UABCode.ToString());

                Exam_Entry Ex1 = new Exam_Entry();
                Ex1.Load(Ien.m_OptionCode, SeasonCode.ToString(), YearCode.ToString(), eb1.m_ExamBoardId, SId);
                if (!Ex1.m_valid)
                {
                    Ex1.m_Date_Created = DateTime.Now;
                    Ex1.m_OptionID     = eo1.m_OptionID;
                    Ex1.m_season       = SeasonCode.ToString();
                    Ex1.m_StudentID    = SId;
                    Ex1.m_withdrawn    = false;
                    Ex1.m_year         = Year.ToString();
                    Ex1.m_EntryStatus  = 7;
                    Ex1.Save();
                }
                else
                {
                    bool f = Ex1.m_valid;
                }
            }
        }
        protected void cb_CheckedChanged(object sender, EventArgs e)
        {
            string   s         = sender.ToString();
            CheckBox cb1       = (CheckBox)sender;
            string   Option_id = cb1.ID;
            Guid     g1        = new Guid(Option_id);
            //if it has been checked.... increase cost.....
            ExamOption exo1       = new ExamOption(); exo1.Load(g1);
            int        cover_cost = RetakeCoverCost();
            int        cost       = (int)ViewState["cost"];

            if (cb1.Checked)
            {
                cost += exo1.m_feeInt + cover_cost;
            }
            else
            {
                cost -= (exo1.m_feeInt + cover_cost);
            }
            ViewState.Add("cost", cost);
            double x = (double)cost; x = x / 100;

            TextBox_cost.Text = x.ToString();
        }
Beispiel #18
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 #19
0
        void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
        {
            //calls here for any command - including a sort
            if (e.CommandName == "Edit_Grade")
            {
                Cerval_Configuration c = new Cerval_Configuration("StaffIntranet_Forecast_Grade_Edit");
                string s1 = c.Value;
                if (!c.valid)//try revert to config file
                {
                    System.Configuration.AppSettingsReader ar = new AppSettingsReader();
                    s1 = ar.GetValue("Exam Entries Forecast Grade Edit", s1.GetType()).ToString();
                }
                if (s1 == "none")
                {
                    visibility(4);
                    {
                        ListBox_PredictedGrades.Visible = false;
                        Button_Save_Prediction.Visible  = false;
                        Label_Title_for_Edit.Text       = "Predicted grades can't be edited at present";
                        return;
                    }
                }


                int             row      = Convert.ToInt32(e.CommandArgument);
                GridViewRow     row1     = GridView1.Rows[row];
                string          s        = Server.HtmlDecode(row1.Cells[0].Text);//is id
                Exam_Entry      ex1      = new Exam_Entry(); ex1.Load(s);
                SimplePupil     p1       = new SimplePupil(); p1.Load(ex1.m_StudentID.ToString());
                ExamOption      exo1     = new ExamOption(); exo1.Load(ex1.m_OptionID);
                Utility         u        = new Utility();
                bool            valid    = false;
                PupilPeriodList PPLlist1 = new PupilPeriodList();
                PPLlist1.LoadList("StudentID", ex1.m_StudentID.ToString(), true, DateTime.Now);
                //now I'd like to find the cse... but we dont know these
                CourseList   cselist1 = new CourseList(ex1.m_OptionID);
                GroupList_SL grplist1 = new GroupList_SL(Label_staffCode.Text.Trim());

                foreach (Course c1 in cselist1._courses)
                {
                    foreach (ScheduledPeriod scp in PPLlist1.m_pupilTTlist)
                    {
                        if (scp.m_groupcode.Substring(2, 2).ToUpper().Trim() == c1.CourseCode.ToUpper().Trim())
                        {
                            if (scp.m_staffcode.Trim().ToUpper() == Label_staffCode.Text.Trim().ToUpper())
                            {
                                if (s1 == "staff")
                                {
                                    valid = true;
                                }
                            }
                            foreach (Group g1 in grplist1._groups)
                            {
                                if (g1._GroupCode == scp.m_groupcode)
                                {
                                    valid = true;                                  //is SL
                                }
                            }
                        }
                    }
                }
                if (s1 == "all")
                {
                    valid = true;
                }
                visibility(4);
                if (!valid)
                {
                    ListBox_PredictedGrades.Visible = false;
                    Button_Save_Prediction.Visible  = false;
                    Label_Title_for_Edit.Text       = "Can't edit this grade as you don't teach the student";
                    return;
                }

                Label_Title_for_Edit.Text   = "Predicted Grade for " + p1.m_GivenName + " " + p1.m_Surname + " for " + exo1.m_OptionCode + ": " + exo1.m_OptionTitle;
                Label_EntryID_for_edit.Text = s;
                ListBox_PredictedGrades.Items.Clear();
                if (exo1.m_OptionQualification == "GCE")
                {
                    ListBox_PredictedGrades.Items.Add("A*");
                    ListBox_PredictedGrades.Items.Add("A");
                    ListBox_PredictedGrades.Items.Add("B");
                    ListBox_PredictedGrades.Items.Add("C");
                    ListBox_PredictedGrades.Items.Add("D");
                    ListBox_PredictedGrades.Items.Add("E");
                    ListBox_PredictedGrades.Items.Add("U");
                }
                if (exo1.m_OptionQualification == "GCSE")
                {
                    ListBox_PredictedGrades.Items.Add("A*");
                    ListBox_PredictedGrades.Items.Add("A");
                    ListBox_PredictedGrades.Items.Add("B");
                    ListBox_PredictedGrades.Items.Add("C");
                    ListBox_PredictedGrades.Items.Add("D");
                    ListBox_PredictedGrades.Items.Add("E");
                    ListBox_PredictedGrades.Items.Add("");
                }
                if (ListBox_PredictedGrades.Items.FindByText(Server.HtmlDecode(row1.Cells[7].Text)) != null)
                {
                    ListBox_PredictedGrades.Items.FindByText(Server.HtmlDecode(row1.Cells[7].Text)).Selected = true;
                    Button_Save_Prediction.Visible = true;
                }
                else
                {
                    //ListBox_PredictedGrades.Visible = false;
                    //Button_Save_Prediction.Visible = false;
                    //Label_Title_for_Edit.Text = "Can't edit this grade";
                }
                Button_Save_Prediction.Visible = true;
            }

            if (e.CommandName == "Edit_Button")
            {
                int         row  = Convert.ToInt32(e.CommandArgument);
                GridViewRow row1 = GridView1.Rows[row];
                string      s    = Server.HtmlDecode(row1.Cells[0].Text);//is id
                Exam_Entry  ex1  = new Exam_Entry(); ex1.Load(s);
                ExamsEntries_sql.UpdateCommand = "UPDATE  dbo.tbl_Exams_Entries  SET PredictedGrade = '?' WHERE ExamEntryID ='" + s + "' ";
            }
            if (e.CommandName == "Delete_Button")
            {
                int         row  = Convert.ToInt32(e.CommandArgument);
                GridViewRow row1 = GridView1.Rows[row];
                string      s    = Server.HtmlDecode(row1.Cells[0].Text);
                //do delete...
            }
        }
        /*
         *  private void RenderModuleResultLine(HttpResponse Response, Result r1,bool retake)
         *  {
         *      string s = "";
         *      ExamOption exo1 = new ExamOption();
         *      Response.Write("<TR>");
         *      s = r1.Date.ToShortDateString(); Response.Write("<TD>" + s + "</TD>");
         *      s = r1.Coursename; Response.Write("<TD>" + s + "</TD>");
         *      s = r1.OptionTitle; Response.Write("<TD>" + s + "</TD>");
         *      s = r1.OptionCode; Response.Write("<TD>" + s + "</TD>");
         *      s = r1.Value; Response.Write("<TD>" + s + "</TD>");
         *      s = r1.OptionMaximumMark; Response.Write("<TD>" + s + "</TD>");
         *
         *      s = "";
         *      if (r1.Resulttype == 27)//UMS mark for GCSE
         *      {
         *          try
         *          {
         *              double v1 = System.Convert.ToDouble(r1.Value);
         *              double v2 = System.Convert.ToDouble(r1.OptionMaximumMark);
         *              v1 = v1 / v2;
         *              if (v1 >= 0.9) s = "a*";
         *              if ((v1 < 0.9) && (v1 >= 0.8)) s = "a";
         *              if ((v1 < 0.8) && (v1 >= 0.7)) s = "b";
         *              if ((v1 < 0.7) && (v1 >= 0.6)) s = "c";
         *              if ((v1 < 0.6) && (v1 >= 0.5)) s = "d";
         *              if ((v1 < 0.5) && (v1 >= 0.4)) s = "e";
         *              if ((v1 < 0.4)) s = "u";
         *          }
         *          catch (Exception exc1)
         *          {
         *              s = exc1.Message;
         *          }
         *      }
         *      if (r1.Resulttype == 11)//GCE module mark
         *      {
         *          try
         *          {
         *              double v1 = System.Convert.ToDouble(r1.Value);
         *              double v2 = System.Convert.ToDouble(r1.OptionMaximumMark);
         *              v1 = v1 / v2;
         *              if (v1 >= 0.8) s = "a";
         *              if ((v1 < 0.8) && (v1 >= 0.7)) s = "b";
         *              if ((v1 < 0.7) && (v1 >= 0.6)) s = "c";
         *              if ((v1 < 0.6) && (v1 >= 0.5)) s = "d";
         *              if ((v1 < 0.5) && (v1 >= 0.4)) s = "e";
         *              if ((v1 < 0.4)) s = "u";
         *          }
         *          catch (Exception exc1)
         *          {
         *              s = exc1.Message;
         *          }
         *      }
         *
         *      Response.Write("<TD>" + s + "</TD>");
         *      exo1.Load(r1.OptionId);
         *      Exam_Board exb1 = new Exam_Board(exo1.m_ExamBoardID);
         *      Response.Write("<TD>" + exb1.m_OrganisationFriendlyName + "</TD>");
         *      if (retake)
         *      {
         *          CheckBox cb1 = new CheckBox();
         *          cb1.ID = "CheckBox-" + r1.OptionId.ToString() ;
         *          Response.Write("<TD><asp:CheckBox ID=\"" + cb1.ID.ToString() + "\"  runat=\"server\" /></TD>");
         *      }
         *      Response.Write("</TR>");
         *  }
         *
         *  private void RenderModuleResultTableHeader(HttpResponse Response, Guid PersonId,bool retake)
         *  {
         *      Utility u1 = new Utility();
         *      Response.Write("<H1><center> Module Results for " + u1.GetPersonName(PersonID) + "</H1></center><BR>");
         *      Response.Write("<BR><p  align=\"center\"><TABLE BORDER><TR>");
         *      Response.Write("<TD>Date</TD>");
         *      Response.Write("<TD>Subject</TD>");
         *      Response.Write("<TD>Option Title</TD>");
         *      Response.Write("<TD>Option Code</TD>");
         *      Response.Write("<TD>Result</TD>");
         *      Response.Write("<TD>Max Mark</TD>");
         *      Response.Write("<TD>Grade</TD>");
         *      Response.Write("<TD>Exam Board</TD>");
         *      if (retake) Response.Write("<TD>Retake ?</TD>");
         *      Response.Write("</TR>");
         *  }
         */
        protected void Button_submit_Click(object sender, EventArgs e)
        {
            Guid PersonID = (Guid)ViewState["PersonID"];

            Table1.Visible        = false;
            Label1.Visible        = false;
            TextBox_cost.Visible  = false;
            Button_submit.Visible = false;
            Label_title.Visible   = false;
            ExamOption           exo1 = new ExamOption();
            ExamCompononent_List ecl1 = new ExamCompononent_List();
            string  dates             = "";
            double  cost  = 0;
            double  total = 0;
            Utility u1    = new Utility();

            Guid[]       list1 = new Guid[100]; int no_list1 = 0; bool in_list1 = false;
            PupilDetails pupil1 = new PupilDetails(u1.GetStudentId(PersonID).ToString());

            int    cover_cost = RetakeCoverCost();
            string season     = RetakeSeason();
            string year       = RetakeYear();
            string s1         = RetakeMessage();
            string s2         = "";

            s2  = "<H2><center>Entry Requests for " + u1.GetPersonName(PersonID) + "  " + u1.Get_Form(pupil1.m_StudentId.ToString()) + "(" + pupil1.m_examNo.ToString() + ")</H2></center><BR>";
            s2 += "<H3><center>You should print this page and take it with your cheque ";
            s2 += "made out to DCGS to the Exams Office.</H3></center><BR><H3><center>" + s1 + "</H3></center><BR>";


            s2 += "<BR><p  align=\"center\"><TABLE BORDER><TR><TD>Option Code</TD><TD>Option Title</TD>";
            s2 += "<TD>Exam Board</TD><TD>Date</TD><TD>Cost</TD><TD>Comment</TD></TR>";

            resultlist1 = (ResultsList)ViewState["ResultList"];
            string   s   = "";
            CheckBox cb1 = new CheckBox();

            foreach (Result r1 in resultlist1._results)
            {
                s   = r1.OptionId.ToString(); cb1 = null;
                cb1 = (CheckBox)content.FindControl(s);
                if (cb1 != null)
                {
                    if (cb1.Checked)
                    {
                        exo1.Load(r1.OptionId);
                        ecl1.m_list.Clear();
                        ecl1.Load(r1.OptionId);
                        Exam_ResitEntry exres1 = new Exam_ResitEntry();
                        exres1.Load(r1.StudentID, r1.OptionId);
                        in_list1 = false;
                        for (int i = 0; i < no_list1; i++)
                        {
                            if (list1[i] == r1.OptionId)
                            {
                                in_list1 = true;
                            }
                        }

                        if (in_list1)
                        {
                            //already entered......
                        }
                        else
                        {
                            s2 += "<TR><TD>" + r1.OptionCode + "</TD><TD>" + r1.OptionTitle + "</TD>";
                            Exam_Board exb1 = new Exam_Board(exo1.m_ExamBoardID);
                            s2   += "<TD>" + exb1.m_OrganisationFriendlyName + "</TD>";
                            dates = "";
                            foreach (ExamComponent c1 in ecl1.m_list)
                            {
                                if (c1.m_Timetabled == "T")
                                {
                                    dates += c1.m_TimetableDate.ToShortDateString();
                                }
                            }
                            s2  += "<TD>" + dates + "</TD>";
                            cost = (double)exo1.m_feeInt + cover_cost;
                            exres1.Load(r1.StudentID, r1.OptionId);
                            if (!exres1.m_valid)
                            {
                                exres1.m_cost        = (int)cost;
                                exres1.m_DateCreated = DateTime.Now;
                                exres1.m_OptionId    = r1.OptionId;//has been updated when we loaded it to be the new one..
                                exres1.m_season      = season;
                                exres1.m_year        = year;
                                exres1.m_StudentId   = u1.GetStudentId(PersonID);
                                exres1.m_version     = 1;
                                exres1.Save();
                            }
                            cost   = cost / 100;
                            total += cost;
                            s2    += "<TD>" + cost.ToString() + "</TD>";
                            if (exo1.NeedsTeacherMarks())
                            {
                                s2 += "<TD>Warning - Needs CW</TD></TR>";
                            }
                            else
                            {
                                s2 += "<TD></TD></TR>";
                            }
                            list1[no_list1] = r1.OptionId; no_list1++;
                        }
                    }
                    else
                    {
                        Exam_ResitEntry exres1 = new Exam_ResitEntry();
                        exres1.Load(r1.StudentID, r1.OptionId);
                        if (exres1.m_valid)
                        {
                            exres1.Delete();                 //need to delete it!!!;
                        }
                    }
                }
            }
            s2 += "</TABLE> <H3><center>Total Cost : £" + total.ToString() + "</H3></center><H3><center>Dates are provisional!</H3></center>";
            servercontent.InnerHtml = s2;
        }
Beispiel #21
0
 public ExamOption SavExamOption(ExamOption eo)
 {
     _db.ExamOptions.Add(eo);
     _db.SaveChanges();
     return(eo);
 }
Beispiel #22
0
        private Result <CandidateExamsRegistrations> CreateCandidateExamRegistrations(
            List <ExamOptionPriceListEntry> allowedExamOptions,
            CandidateExamsRegistrationsCollection allRegistrations,
            ExamRegistrationRow row,
            SessionInfo session,
            PreparationCentreInfo preparationCentreInfo,
            SessionChronology sessionChronology
            )
        {
            var candidateResult = CreateCandidate(row.Candidate, row.CandidateGuardian);


            var identifierResult = PersonIdentifier.Create(row.Candidate.IdType, row.Candidate.IdNumber, row.Candidate.IdExpiryDate);

            var registrationsResults = new List <Result <Registration> >();

            foreach (var eo in row.ExamOptions)
            {
                var registrationTypeValue = RegistrationTypeValueExtensions.Cast(eo.RegisteringTypeCellValue);

                var combinedExamOptionResult = Result.Ok();
                var domainExamOptionResult   = GetExamOptionIfAllowed(allowedExamOptions, eo);

                ExamOption examOption = null;
                if (domainExamOptionResult.IsSuccess)
                {
                    var examOptionResult = ExamOption.Create(domainExamOptionResult.Value.Code, domainExamOptionResult.Value.SyllabusOption, domainExamOptionResult.Value.SyllabusId);
                    if (examOptionResult.IsSuccess)
                    {
                        examOption = examOptionResult.Value;
                    }
                    combinedExamOptionResult = Result.Combine(domainExamOptionResult, examOptionResult);
                }

                var previousSession = sessionChronology.GetByName(row.PreviousSession);
                int?prevSessionId   = previousSession.HasValue ? previousSession.Value.Id : default(int?);
                var regTypeOrError  = RegistrationType.Create(
                    registrationTypeValue, row.GroupAward, row.PreviousCandidateNumber, row.PreviousCentreNumber, prevSessionId);

                var registrationsError = Result.Combine(combinedExamOptionResult, regTypeOrError)
                                         .OnSuccess(() => new Registration(regTypeOrError.Value, examOption, row.SpecialArrangements))
                                         .Map(x => x);

                registrationsResults.Add(registrationsError);
            }

            var cg = row.CandidateGuardian;
            var candidateGuardianResult = CandidateGuardian.CreateOptional(cg.OtherNames, cg.FamilyName, cg.Telephone, cg.Relationship);

            var childCollectionResult = Result.Ok(ChildCollection.Empty);

            if (candidateGuardianResult.IsSuccess)
            {
                childCollectionResult = ChildCollection.Create(row.Candidate.ChildCollectionOption, candidateGuardianResult.Value);
            }

            var candidateRegistrationResult = Result.Ok();
            Maybe <CandidateExamsRegistrations> candidateRegistration = null;

            if (candidateResult.IsSuccess) // .On
            {
                if (identifierResult.IsSuccess)
                {
                    candidateRegistration = allRegistrations.Find(candidateResult.Value, identifierResult.Value);

                    if (candidateRegistration.HasValue)
                    {
                        var result = CandidateExamsRegistrations.CreateNew(session, candidateResult.Value);
                        if (result.IsSuccess)
                        {
                            candidateRegistration = result.Value;
                            allRegistrations.Add(candidateRegistration.Value);
                        }

                        candidateRegistrationResult = Result.Combine(candidateRegistrationResult, result);
                    }
                }
            }

            var combinedRegistrationsResults = Result.Combine(registrationsResults.ToArray());

            return(Result.Combine(candidateResult, identifierResult, combinedRegistrationsResults,
                                  candidateGuardianResult, childCollectionResult, candidateRegistrationResult)
                   .OnSuccess(() =>
                              candidateRegistration.Value.AddNewRegistrationGroup(
                                  registrationsResults.Select(x => x.Value),
                                  preparationCentreInfo,
                                  identifierResult.Value,
                                  childCollectionResult.Value
                                  )));
        }
Beispiel #23
0
        protected void Button_Process_Click(object sender, EventArgs e)
        {
            string       s      = TextBox1.Text;
            TextFileType ftype1 = TextFileType.Unknown;

            try
            {
                ftype1 = (TextFileType)ViewState["TextFileType"];
            }
            catch
            {
                Label_Text.Text = "File Type not recognised"; return;
            }
            if (ftype1 == TextFileType.Unknown)
            {
                Label_Text.Text = "Board Not Set!!!"; return;
            }
            char[]   ct1    = new char[1]; ct1[0] = (char)0x09;
            string[] fields = new string[20];

            ExamsUtility    u      = new ExamsUtility();
            PupilGroupList  pgl    = new PupilGroupList();
            ExamConversions Ec     = new ExamConversions();
            SimplePupil     pupil1 = new SimplePupil();
            Guid            g1     = new Guid(); g1 = Guid.Empty;
            Exam_Board      eb1    = new Exam_Board();
            SimplePupil     p1     = new SimplePupil();
            ExamComponent   ec1    = new ExamComponent();

            ExamOption exo1 = new ExamOption();
            ExamComponentResultList ecrl1 = new ExamComponentResultList();
            string component_code         = "";
            int    adno1           = 0;
            string Option_Code     = "";
            string ScaledMark      = "";
            string ComponentUMS    = "";
            string ComponentStatus = "";
            string TQM_value       = "";

            int n_Year          = (int)ViewState["n_Year"];
            int n_Season        = (int)ViewState["n_Season"];
            int n_OptionCode    = (int)ViewState["n_OptionCode"];
            int n_TQM           = (int)ViewState["n_TQM"];
            int n_ComponentCode = (int)ViewState["n_ComponentCode"];
            int n_ComponentUMS  = (int)ViewState["n_ComponentUMS"];
            int n_ScaledMark    = (int)ViewState["n_ScaledMark"];
            int n_Status        = (int)ViewState["n_Status"];
            int n_CandNo        = (int)ViewState["n_CandNo"];


            int number_entered = 0;

            //get exam board....
            switch (ftype1)
            {
            case TextFileType.Unknown:
                return;

            case TextFileType.AQA_GCE:
                eb1 = new Exam_Board("70");
                break;

            case TextFileType.OCR_GCE:
                eb1 = new Exam_Board("01");
                break;

            case TextFileType.EDEXCEL_GCE:
                eb1 = new Exam_Board("11");
                break;

            case TextFileType.AQA_GCSE:
                eb1 = new Exam_Board("70");
                break;

            case TextFileType.OCR_GCSE:
                break;

            case TextFileType.EDEXCEL_GCSE:
                eb1 = new Exam_Board("10");
                break;

            case TextFileType.CIE:
                eb1 = new Exam_Board("02");
                break;

            case TextFileType.WJEC_GCSE:
                eb1 = new Exam_Board("40");
                break;

            case TextFileType.WJEC_GCE:
                eb1 = new Exam_Board("41");
                break;

            default:
                break;
            }


            using (StringReader sr = new StringReader(s))
            {
                string firstline = sr.ReadLine();
                string line;

                while ((line = sr.ReadLine()) != null)
                {
                    fields = line.Split(ct1);
                    adno1  = 0; component_code = ""; Option_Code = ""; ScaledMark = ""; ComponentUMS = ""; ComponentStatus = "";

                    adno1 = Convert.ToInt32(fields[n_CandNo]);
                    if (Year.ToString() != fields[n_Year])
                    {
                        Label_Text.Text = "Year code mismatch in file, line" + number_entered.ToString(); return;
                    }
                    if (SeasonCode.ToString() != fields[n_Season].Substring(0, 1))
                    {
                        Label_Text.Text = "Series code mismatch in file, line" + number_entered.ToString(); return;
                    }
                    component_code  = fields[n_ComponentCode];
                    Option_Code     = fields[n_OptionCode];
                    ScaledMark      = fields[n_ScaledMark];
                    ComponentUMS    = fields[n_ComponentUMS];
                    ComponentStatus = fields[n_Status];
                    TQM_value       = fields[n_TQM];

                    ExamComponentResult r = new ExamComponentResult();

                    try
                    {
                        p1.Load_StudentIdOnly(adno1);
                        ec1.Load(component_code, SeasonCode.ToString(), YearCode.ToString());

                        exo1.Load(Option_Code, SeasonCode.ToString(), YearCode.ToString(), eb1.m_ExamBoardId);
                        r.OptionId    = exo1.m_OptionID;
                        r.ComponentId = ec1.m_ComponentID;
                        r.StudentId   = p1.m_StudentId;
                        try
                        {
                            r.ComponentScaledMark = System.Convert.ToInt32(ScaledMark);
                        }
                        catch
                        {
                            //assume it is non integer....
                            double d = Convert.ToDouble(ScaledMark);
                            r.ComponentScaledMark = Convert.ToInt32(d);
                        }
                        try { r.ComponentUMS = System.Convert.ToInt32(ComponentUMS); } catch { }
                        r.ComponentStatus = ComponentStatus;

                        switch (ecrl1.Load_OptionStudent(r.OptionId, r.StudentId, r.ComponentId))
                        {
                        case 0:
                            //so can write in
                            r.Save();
                            break;

                        case 1:
                            //so update
                            r.ComponentResultId = ecrl1.m_list[0].ComponentResultId;
                            r.Save();
                            break;

                        case 2:
                            //so problem
                            break;

                        default:
                            break;
                        }

                        //now find the result....
                        ResultsList rl1 = new ResultsList();
                        rl1.m_parameters = 0;
                        rl1.m_where      = "WHERE (dbo.tbl_Core_Students.StudentId='" + r.StudentId.ToString() + "')AND(dbo.tbl_Core_Results.ExamsOptionId='" + r.OptionId.ToString() + "') ";
                        rl1.LoadList("", "");
                        Result r1 = new Result();
                        r1      = (Result)rl1._results[0];
                        r1.Text = "TQM=" + TQM_value;
                        r1.UpdateResultTextOnly();
                        number_entered++;
                    }
                    catch (Exception ex)
                    {
                        Label_Text.Text = ex.ToString();
                    }
                }
            }
            Label_Text.Text = "Correctly processed... " + number_entered.ToString() + " entries";
        }
Beispiel #24
0
        public bool AddEntry(Guid StudentId, Exam_Board exbde1, int Year, int YearCode, int Season, string option, int EntryStatusCode, bool checkDisallowed, ref string ErrorMessage, ref Guid EntryId)
        {
            //Year is 2 digit code.....
            bool       disallowed = false; ErrorMessage = "";
            ExamOption ex01       = new ExamOption();
            ExamOption ex02       = new ExamOption();
            ExamFiles  ef1        = new ExamFiles();

            ex01.Load(option, Season.ToString(), YearCode.ToString(), exbde1.m_ExamBoardId);
            if (!ex01.m_valid)
            {
                //need to search basedata...
                ex01 = ef1.Find_Option(option, exbde1, Season.ToString(), YearCode.ToString());
            }
            if (ex01 != null)
            {
                ExamEntries_List exen1 = new ExamEntries_List();
                exen1.Load(StudentId, Year.ToString(), Season.ToString());
                if (checkDisallowed)
                {
                    foreach (Exam_Entry ex1 in exen1.m_list)
                    {
                        if (!ex1.m_withdrawn)
                        {
                            ex02.Load(ex1.m_OptionID);
                            disallowed = ef1.CombinationDisallowed(exbde1, ex01.m_OptionCode, ex02.m_OptionCode, ex01.m_SeriesIdentifier, ex01.m_year_Code);
                            if (disallowed)
                            {
                                ErrorMessage = "Combination of " + ex01.m_OptionCode + " and " + ex02.m_OptionCode + " not allowed!";
                                return(false);
                            }
                        }
                    }
                }
                if (!disallowed)
                {
                    Exam_Entry entry1 = new Exam_Entry();
                    entry1.m_OptionID     = ex01.m_OptionID;
                    entry1.m_StudentID    = StudentId;
                    entry1.m_Date_Created = DateTime.Now;
                    entry1.m_season       = Season.ToString();
                    entry1.m_year         = Year.ToString();
                    entry1.m_ExamEntryID  = Guid.Empty;
                    entry1.m_EntryStatus  = EntryStatusCode;

                    foreach (Exam_Entry ex1 in exen1.m_list)
                    {
                        if (ex1.m_OptionID == ex01.m_OptionID)
                        {
                            //found this student, this series, this option
                            entry1.m_ExamEntryID = ex1.m_ExamEntryID;
                        }
                    }
                    entry1.Save();
                    EntryId = entry1.m_ExamEntryID;
                    return(true);
                }
            }
            else
            {
                ErrorMessage = "Option code  " + option + " not found"; return(false);
            }

            return(false);
        }
Beispiel #25
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //file has  Board short name/optioncode/grade/mark


            if (!FileUpload1.HasFile)
            {
                return;
            }
            Cerval_Library.TextReader TxtRd1 = new Cerval_Library.TextReader();
            TextRecord t = new TextRecord(); int l = 0; int n = 0;
            string     s1 = ""; char ct = (char)0x09;

            int  n_Board = 0; int n_OptionCode = 0; int n_Grade = 0; int n_Mark = 0;
            bool f_Board = false; bool f_OptionCode = false; bool f_Grade = false; bool f_Mark = false;


            while (TxtRd1.ReadTextLine(FileUpload1.FileContent, ref t) == Cerval_Library.TextReader.READ_LINE_STATUS.VALID)
            {
                l = s1.Length;
                for (int i = 0; i <= t.number_fields; i++)
                {
                    s1 += t.field[i] + ct;
                }
                if (s1.Length > l)
                {
                    s1 += Environment.NewLine;
                }
                if (n == 0)
                {
                    //going to look for our columns:
                    for (int i = 0; i <= t.number_fields; i++)
                    {
                        switch (t.field[i])
                        {
                        case "Board": n_Board = i; f_Board = true; break;

                        case "Option": n_OptionCode = i; f_OptionCode = true; break;

                        case "Mark": n_Mark = i; f_Mark = true; break;

                        case "Grade": n_Grade = i; f_Grade = true; break;

                        default: break;
                        }
                    }

                    // so do we have all the required columns??
                    if (!(f_Board && f_OptionCode && f_Grade && f_Mark))
                    {
                        Label_Text.Text = "Can't recognise the format of this file. ";
                        if (!f_Board)
                        {
                            Label_Text.Text += "No Board Column";
                        }
                        if (!f_OptionCode)
                        {
                            Label_Text.Text += "No Option Column";
                        }
                        if (!f_Mark)
                        {
                            Label_Text.Text += "No  Mark Column";
                        }
                        if (!f_Grade)
                        {
                            Label_Text.Text += "No Grade Column";
                        }
                        return;
                    }
                    else
                    {
                        Label_Text.Text = "File Format Fine:   ";
                    }
                }
            }

            //so process the file...
            string s2 = "";

            char[]   ct1 = new char[1]; ct1[0] = (char)0x09;
            string[] fields = new string[20];

            using (StringReader sr = new StringReader(s1))
            {
                string firstline = sr.ReadLine();
                string line;

                while ((line = sr.ReadLine()) != null)
                {
                    fields = line.Split(ct1);
                    bool       found = false;
                    Exam_Board eb1   = new Exam_Board();
                    eb1.Load(fields[n_Board]);
                    ExamOption eo1 = new ExamOption();
                    if (eo1.Load(fields[n_OptionCode], SeasonCode.ToString(), YearCode.ToString(), eb1.m_ExamBoardId))
                    {
                        //valid option cod
                        ExamTQMBoundaryList l1 = new ExamTQMBoundaryList();
                        l1.LoadList(eo1.m_OptionID, YearCode.ToString(), SeasonCode.ToString());
                        foreach (ExamTQMBoundary b in l1.m_list)
                        {
                            if (b.Grade == fields[n_Grade])
                            {
                                b.Mark = Convert.ToInt32(fields[n_Mark]);
                                b.Save();
                                found = true;
                                s2   += eb1.m_OrganisationFriendlyName + ct + eo1.m_OptionCode + ct + eo1.m_OptionTitle + ct + b.Grade + ct + b.Mark + ct + "Updated" + System.Environment.NewLine;
                            }
                        }
                        if (!found)
                        {
                            ExamTQMBoundary etqm1 = new ExamTQMBoundary();
                            etqm1.OptionId    = eo1.m_OptionID;
                            etqm1.Mark        = Convert.ToInt32(fields[n_Mark]);
                            etqm1.Grade       = fields[n_Grade];
                            etqm1.OptionCode  = eo1.m_OptionCode;
                            etqm1.OptionTitle = eo1.m_OptionTitle;
                            etqm1.Season      = SeasonCode.ToString();
                            etqm1.Year        = YearCode.ToString();
                            etqm1.Version     = 22;
                            etqm1.Save();
                            s2 += eb1.m_OrganisationFriendlyName + ct + eo1.m_OptionCode + ct + eo1.m_OptionTitle + ct + etqm1.Grade + ct + etqm1.Mark + ct + "New Entry" + System.Environment.NewLine;
                        }
                    }
                }
                Label_Text.Text = " Completed... saved as below:";
                TextBox1.Text   = s2;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Utility  u1 = new Utility();
                DateTime t1 = new DateTime();
                DateTime t0 = new DateTime();
                DateTime t2;
                t0 = u1.ThisExamSeasonStart(); t1 = u1.ThisExamSeasonEnd(t0);
                string season = u1.ThisSeason(t0);
                season = "3";
                ArrayList m_list = new ArrayList();
                PersonID = u1.GetPersonIdfromRequest(Request);

#if DEBUG
                u1.Is_student = true;
                u1.Is_student = true; PersonID = u1.GetPersonIDX(@"CHALLONERS\william.arnold");//development
#endif
                string s = ""; string s1 = "";
                if ((PersonID != Guid.Empty) && (u1.Is_student))
                {
                    s1 += "<br><center><h2>Exam Entries</h2></center>";
                    s1 += "<p  align=\"center\"><TABLE BORDER><Tr>";
                    s   = "Option"; s1 += "<Th>" + s + "</Th>";
                    s   = "Code"; s1 += "<Th>" + s + "</Th>";
                    s   = "Qualification"; s1 += "<Th>" + s + "</Th>";
                    s   = "Level"; s1 += "<Th>" + s + "</Th>";
                    s   = "Status"; s1 += "<Th>" + s + "</Th>";
                    s1 += "</Tr>";
                    ExamEntries_List exl1 = new ExamEntries_List();
                    exl1.Load(u1.GetStudentId(PersonID));
                    foreach (Exam_Entry ex1 in exl1.m_list)
                    {
                        ExamOption exo1 = new ExamOption(); exo1.Load(ex1.m_OptionID);
                        //if ((ex1.m_season == season) && (ex1.m_year == t0.Year.ToString())&&(!ex1.m_withdrawn))
                        if ((ex1.m_year == t0.Year.ToString()) && (!ex1.m_withdrawn))
                        {
                            //ExamOption exo1 = new ExamOption(); exo1.Load(ex1.m_OptionID);
                            //if (exo1.m_Item == "C")
                            {
                                s1 += "<TR>";
                                s   = exo1.m_OptionTitle; s1 += "<TD>" + s + "</TD>";
                                s   = exo1.m_OptionCode; s1 += "<TD>" + s + "</TD>";
                                s   = exo1.m_OptionQualification; s1 += "<TD>" + s + "</TD>";
                                if (exo1.m_OptionLevel != "B")
                                {
                                    s = exo1.m_OptionLevel; s1 += "<TD>" + s + "</TD>";
                                }
                                else
                                {
                                    s1 += "<TD></TD>";
                                }
                                if (ex1.m_EntryFileID == Guid.Empty)

                                {
                                    //if DCGS board then Mock/Internal exam
                                    if (exo1.m_ExamBoardID.ToString() == "436ff234-0457-430a-b1e2-b08758ff30ef")
                                    {
                                        //so internal.. if Jan is mocks..
                                        if (exo1.m_Season_code == "1")
                                        {
                                            s1 += "<td>Mock</td>";
                                        }
                                        else
                                        {
                                            s1 += "<td>Internal</td>";
                                        }
                                    }
                                    else
                                    {
                                        s1 += "<TD>Provisional</TD>";
                                    }
                                }
                                else
                                {
                                    s1 += "<TD>Entered</TD>";
                                }
                                s1 += "</TR>";
                            }

                            ExamCompononent_List excl1 = new ExamCompononent_List();
                            excl1.Load(ex1.m_OptionID);
                            foreach (ExamComponent ec in excl1.m_list)
                            {
                                if (ec.m_Timetabled == "T")
                                {
                                    ExamComponent ec2 = new ExamComponent(); ec2 = ec;
                                    m_list.Add(ec2); ec2.m_OptionTitle = exo1.m_Syllabus_Title;
                                }
                            }
                        }
                    }
                    s1 += "</TABLE>";
                    s1 += "<center>FC = Full Course, SC = Short(Half) Course<br>";

                    foreach (ExamComponent ec in m_list)
                    {
                        t2 = System.Convert.ToDateTime(ec.m_TimetableDate);
                        if (t2 < t1)
                        {
                            t1 = System.Convert.ToDateTime(ec.m_TimetableDate);
                        }
                        if (t2 > t0)
                        {
                            t0 = System.Convert.ToDateTime(ec.m_TimetableDate);
                        }
                    }
                    int month = t1.Month; ExamComponent ecx;
                    int day = t1.Day;
                    s1 += "<br><br><br><center><h2>Outline Exam Timetable</h2>";
                    s1 += "Full Exam Timetable can be found <a href=\"ExamTimetables.aspx?\">here</a></center>";
                    s1 += "<center>Note that for GCSE Languages the tier (Foundation or Higher) is not significant. ";
                    s1 += "<BR><p  align=\"center\"><TABLE BORDER><TR>";
                    s   = "Date"; s1 += "<Th>" + s + "</Th>";
                    s   = "AM Session"; s1 += "<Th>" + s + "</Th>";
                    s   = "PM Session"; s1 += "<Th>" + s + "</Th>";
                    s1 += "</TR>";
                    //from t1 to t0...
                    t2 = t1; t0 = t0.AddDays(1);
                    while (t2 < t0)
                    {
                        if ((t2.DayOfWeek.ToString() != "Saturday") && (t2.DayOfWeek.ToString() != "Sunday"))
                        {
                            s1 += "<TR>";
                            s   = t2.DayOfWeek.ToString(); s += "<br>" + t2.ToShortDateString(); s1 += "<TD>" + s + "</TD>"; s = ""; ecx = null;
                            foreach (ExamComponent ec in m_list)
                            {
                                if ((t2 == System.Convert.ToDateTime(ec.m_TimetableDate)) && (ec.m_TimetableSession == "A"))
                                {
                                    s += ec.m_OptionTitle + ec.m_ComponentTitle.ToLower() + "<br>"; ecx = ec;
                                }
                            }
                            if (ecx != null)
                            {
                                m_list.Remove(ecx);
                            }
                            s1 += "<TD>" + s + "</TD>"; s = ""; ecx = null;
                            foreach (ExamComponent ec in m_list)
                            {
                                if ((t2 == System.Convert.ToDateTime(ec.m_TimetableDate)) && (ec.m_TimetableSession == "P"))
                                {
                                    s += ec.m_OptionTitle + ec.m_ComponentTitle.ToLower() + "<br>"; ecx = ec;
                                }
                            }
                            m_list.Remove(ecx);
                            s1 += "<TD>" + s + "</TD>";
                            s1 += "</TR>";
                        }
                        t2 = t2.AddDays(1);
                    }
                    s1 += "</TABLE>";
                    servercontent.InnerHtml = s1;
                }
            }
        }
Beispiel #27
0
        public string HandleMessage(string userId, string userInput, ref EEContext eContext)
        {
            if (eContext.GetType() != typeof(ExamContext))
            {
                eContext = new ExamContext(userId);
            }

            ExamContext context = (ExamContext)eContext;

            ExamProcessor processor = new ExamProcessor();

            string            respStr = null;
            ExamSelectionInfo sInfo   = sStore.GetSelectionInfo();
            Dictionary <string, ExamOption> selectionOptionMap = sStore.GetSelectionMap();
            ExamInfo info = null;

            switch (context.stage)
            {
            case StageType.Init:
                respStr = sInfo.optionMessage + "\r\n";
                foreach (string key in selectionOptionMap.Keys)
                {
                    respStr += "(" + key + ")" + selectionOptionMap[key].courseName + " ";
                }

                context.stage = StageType.Start;
                break;

            case StageType.Start:

                bool isMatched = Utils.Utils.IsRegexMatched(sInfo.optionRegex, userInput);

                if (isMatched)
                {
                    if (selectionOptionMap.ContainsKey(userInput))
                    {
                        ExamOption       option       = selectionOptionMap[userInput];
                        ExamPreProcessor preProcessor = new ExamPreProcessor();
                        info = preProcessor.GenerateProcessItems(option);
                        eStore.SetExamInfo(userId, info);

                        respStr       = info.courseName + "\r\n" + (string.IsNullOrWhiteSpace(info.description)?"":(info.description + "\r\n")) + info.items[context.processContext.index].question;
                        context.stage = StageType.InProcess;
                    }
                    else
                    {
                        throw new Exception("Option " + userInput + " is not available.");
                    }
                }
                else
                {
                    respStr = sInfo.askbackMessage + "\r\n" + sInfo.optionMessage;
                    context.selectContext.askbackTime++;
                }
                break;

            case StageType.InProcess:
                info    = eStore.GetExamInfo(userId);
                respStr = processor.ProcessItem(userId, userInput, ref context, ref info);
                break;

            case StageType.Paused:
                info          = eStore.GetExamInfo(userId);
                respStr       = info.restartMessage;
                context.stage = StageType.Restarted;
                break;

            case StageType.Restarted:
                info = eStore.GetExamInfo(userId);
                if (userInput.Trim().ToLower() != "y")
                {
                    context.processContext = new ExamProcessContext();
                }
                respStr       = processor.ProcessItem(userId, userInput, ref context, ref info);
                context.stage = StageType.InProcess;
                break;
            }

            if (context.stage == StageType.Completed)
            {
                cStore.RemoveContext(userId);
                eStore.RemoveExamInfo(userId);
            }
            else
            {
                if (context.stage == StageType.Paused)
                {
                    context.processContext.askbackTime = 0;
                }

                cStore.SetContext(userId, context);
            }

            return(respStr);
        }
        public ActionResult AddQuestion(SingleQuestionUpload squ, HttpPostedFileBase upload)
        {
            int ex = squ.ExamId;

            if (ModelState.IsValid)
            {
                var kdk = new ExamQuestion
                {
                    Examination     = _examinationRepository.GetExaminationData(squ.ExamId),
                    QuestionContent = squ.Question
                };

                var quest = _examinationRepository.SaveQuestion(kdk, upload);
                //add options
                var eo1 = new ExamOption
                {
                    OptionContent = squ.Option1,
                    ExamQuestion  = quest
                };
                var op1 = _examinationRepository.SavExamOption(eo1);

                var eo2 = new ExamOption
                {
                    OptionContent = squ.Option2,
                    ExamQuestion  = quest
                };
                var op2 = _examinationRepository.SavExamOption(eo2);

                var eo3 = new ExamOption
                {
                    OptionContent = squ.Option3,
                    ExamQuestion  = quest
                };
                var op3 = _examinationRepository.SavExamOption(eo3);

                var eo4 = new ExamOption
                {
                    OptionContent = squ.Option4,
                    ExamQuestion  = quest
                };
                var op4 = _examinationRepository.SavExamOption(eo4);

                var eo5 = new ExamOption
                {
                    OptionContent = squ.Option5,
                    ExamQuestion  = quest
                };
                var op5 = _examinationRepository.SavExamOption(eo5);


                int value = squ.AnswerIdentifier;
                //save answer
                switch (value)
                {
                case 1:
                    var ans1 = new ExamAnswer
                    {
                        ExamQuestion = quest,
                        ExamOption   = op1
                    };
                    _examinationRepository.SaveAnswer(ans1);
                    break;


                case 2:
                    var ans2 = new ExamAnswer
                    {
                        ExamQuestion = quest,
                        ExamOption   = op2
                    };
                    _examinationRepository.SaveAnswer(ans2);
                    break;

                case 3:
                    var ans3 = new ExamAnswer
                    {
                        ExamQuestion = quest,
                        ExamOption   = op3
                    };
                    _examinationRepository.SaveAnswer(ans3);
                    break;

                case 4:
                    var ans4 = new ExamAnswer
                    {
                        ExamQuestion = quest,
                        ExamOption   = op4
                    };
                    _examinationRepository.SaveAnswer(ans4);
                    break;

                case 5:
                    var ans5 = new ExamAnswer
                    {
                        ExamQuestion = quest,
                        ExamOption   = op5
                    };
                    _examinationRepository.SaveAnswer(ans5);
                    break;
                }
            }
            TempData["notification"] = "The Question has been successfully uploaded";
            return(RedirectToAction("Qustion", new { examId = ex }));
        }
        public ActionResult BulkQuestionDataUpload(FormCollection fc, HttpPostedFileBase questionFile)
        {
            int examId         = int.Parse(fc["examId"]);
            var postedFileBase = Request.Files["questionFile"];

            if (postedFileBase != null && postedFileBase.ContentLength > 0)
            {
                string fileExtension =
                    Path.GetExtension(postedFileBase.FileName);

                if (fileExtension == ".xls" || fileExtension == ".xlsx")
                {
                    var fileLocation = $"{Server.MapPath("~/App_Data/ExportData")}/{postedFileBase.FileName}";

                    if (System.IO.File.Exists(fileLocation))
                    {
                        System.IO.File.Delete(fileLocation);
                    }

                    // ReSharper disable once PossibleNullReferenceException
                    Request.Files["questionFile"].SaveAs(fileLocation);

                    string excelConnectionString;

                    excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation +
                                            ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
                    if (fileExtension == ".xls")
                    {
                        excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation +
                                                ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
                    }
                    //connection String for xlsx file format.
                    else if (fileExtension == ".xlsx")
                    {
                        excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation +
                                                ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
                    } //Create Connection to Excel work book and add oledb namespace

                    OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
                    excelConnection.Open();
                    DataTable dt;

                    dt = excelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                    if (dt == null)
                    {
                        return(null);
                    }

                    String[] excelSheets = new String[dt.Rows.Count];
                    int      t           = 0;
                    //excel data saves in temp file here.
                    foreach (DataRow row in dt.Rows)
                    {
                        excelSheets[t] = row["TABLE_NAME"].ToString();
                        t++;
                    }
                    OleDbConnection excelConnection1 = new OleDbConnection(excelConnectionString);
                    DataSet         ds = new DataSet();

                    string query = $"Select * from [{excelSheets[0]}]";
                    using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, excelConnection1))
                    {
                        dataAdapter.Fill(ds);
                    }
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        var kdk = new ExamQuestion
                        {
                            Examination     = _examinationRepository.GetExaminationData(examId),
                            QuestionContent = ds.Tables[0].Rows[i]["Question"].ToString()
                        };

                        var quest = _examinationRepository.SaveQuestion(kdk, null);
                        //add options
                        var eo1 = new ExamOption
                        {
                            OptionContent = ds.Tables[0].Rows[i]["Option1"].ToString(),
                            ExamQuestion  = quest
                        };
                        var op1 = _examinationRepository.SavExamOption(eo1);

                        var eo2 = new ExamOption
                        {
                            OptionContent = ds.Tables[0].Rows[i]["Option2"].ToString(),
                            ExamQuestion  = quest
                        };
                        var op2 = _examinationRepository.SavExamOption(eo2);

                        var eo3 = new ExamOption
                        {
                            OptionContent = ds.Tables[0].Rows[i]["Option3"].ToString(),
                            ExamQuestion  = quest
                        };
                        var op3 = _examinationRepository.SavExamOption(eo3);

                        var eo4 = new ExamOption
                        {
                            OptionContent = ds.Tables[0].Rows[i]["Option4"].ToString(),
                            ExamQuestion  = quest
                        };
                        var op4 = _examinationRepository.SavExamOption(eo4);

                        var eo5 = new ExamOption
                        {
                            OptionContent = ds.Tables[0].Rows[i]["Option5"].ToString(),
                            ExamQuestion  = quest
                        };
                        var op5 = _examinationRepository.SavExamOption(eo5);


                        int value = int.Parse(ds.Tables[0].Rows[i]["Answer"].ToString());
                        //save answer
                        switch (value)
                        {
                        case 1:
                            var ans1 = new ExamAnswer
                            {
                                ExamQuestion = quest,
                                ExamOption   = op1
                            };
                            _examinationRepository.SaveAnswer(ans1);
                            break;


                        case 2:
                            var ans2 = new ExamAnswer
                            {
                                ExamQuestion = quest,
                                ExamOption   = op2
                            };
                            _examinationRepository.SaveAnswer(ans2);
                            break;

                        case 3:
                            var ans3 = new ExamAnswer
                            {
                                ExamQuestion = quest,
                                ExamOption   = op3
                            };
                            _examinationRepository.SaveAnswer(ans3);
                            break;

                        case 4:
                            var ans4 = new ExamAnswer
                            {
                                ExamQuestion = quest,
                                ExamOption   = op4
                            };
                            _examinationRepository.SaveAnswer(ans4);
                            break;

                        case 5:
                            var ans5 = new ExamAnswer
                            {
                                ExamQuestion = quest,
                                ExamOption   = op5
                            };
                            _examinationRepository.SaveAnswer(ans5);
                            break;
                        }
                    }
                    excelConnection.Close();

                    if (System.IO.File.Exists(fileLocation))
                    {
                        System.IO.File.Delete(fileLocation);
                    }

                    TempData["notification"] = "The Questions,Options ans Answers have been uploaded";
                    return(RedirectToAction("Qustion", new { examId }));
                }

                else
                {
                    ModelState.AddModelError("", "Please,select a valid excel file!");
                    ViewBag.examId = examId;

                    return(View(new { id = examId }));
                }
            }

            ModelState.AddModelError("", "Please,select an excel file!");
            ViewBag.examId = examId;

            return(View(new { id = examId }));
        }
        protected int AddControls(ResultsList rl, bool setup)
        {
            int cost = 0;

            Guid[]          listID     = new Guid[100];
            Exam_ResitEntry ExamResit1 = new Exam_ResitEntry();
            Exam_Entry      entry1     = new Exam_Entry();

            Table1.Visible = true;
            Table tb1 = (Table)content.FindControl("table1");

            tb1.Width           = 700;
            tb1.EnableViewState = true;
            TableRow r0 = new TableRow();

            tb1.Controls.Add(r0);
            TableCell c01 = new TableCell(); r0.Controls.Add(c01); SetCellStyle(c01, tb1);
            TableCell c02 = new TableCell(); r0.Controls.Add(c02); SetCellStyle(c02, tb1);
            TableCell c03 = new TableCell(); r0.Controls.Add(c03); SetCellStyle(c03, tb1);
            TableCell c04 = new TableCell(); r0.Controls.Add(c04); SetCellStyle(c04, tb1);
            TableCell c05 = new TableCell(); r0.Controls.Add(c05); SetCellStyle(c05, tb1);

            c01.Text = "Code"; c02.Text = "Title"; c03.Text = "Result"; c04.Text = "Date Taken"; c05.Text = "Retake ?";

            foreach (Result res1 in rl._results)
            {
                if (res1.OptionItem == "U")
                {//we have a module result
                    TableRow r1 = new TableRow();
                    tb1.Controls.Add(r1);
                    r1.BorderStyle = BorderStyle.Solid;
                    r1.BorderColor = tb1.BorderColor;
                    r1.BorderWidth = tb1.BorderWidth;
                    TableCell c1 = new TableCell(); r1.Controls.Add(c1); SetCellStyle(c1, tb1);
                    TableCell c2 = new TableCell(); r1.Controls.Add(c2); SetCellStyle(c2, tb1);
                    TableCell c3 = new TableCell(); r1.Controls.Add(c3); SetCellStyle(c3, tb1);
                    TableCell c4 = new TableCell(); r1.Controls.Add(c4); SetCellStyle(c4, tb1);
                    TableCell c5 = new TableCell(); r1.Controls.Add(c5); SetCellStyle(c5, tb1);


                    if ((res1.Valid) && ((CheckBox)content.FindControl(res1.OptionId.ToString()) == null))
                    {
                        entry1.Load(res1.OptionId, res1.StudentID);
                        //now if already entered we don't want to offer.....
                        if (entry1.m_valid)
                        {
                            c5.Text = "Entered";
                        }
                        else
                        {
                            CheckBox cb1 = new CheckBox();
                            cb1.ID = res1.OptionId.ToString();
                            c5.Controls.Add(cb1);
                            //decide if we already have an entry....
                            if (setup)
                            {
                                ExamResit1.Load(res1.StudentID, res1.OptionId);
                                if (ExamResit1.m_valid)
                                {
                                    cb1.Checked = true;
                                    ExamOption exo1 = new ExamOption();
                                    exo1.Load(res1.OptionId);
                                    cost += exo1.m_feeInt + RetakeCoverCost();
                                }
                            }
                            cb1.CheckedChanged += new EventHandler(cb_CheckedChanged);
                            cb1.AutoPostBack    = true;
                        }
                    }
                    else
                    {
                        c5.Text = "Not available";
                    }
                    c1.Text = res1.OptionCode;
                    c2.Text = res1.OptionTitle;
                    c3.Text = res1.Value;
                    c4.Text = res1.Date.ToShortDateString();
                }
            }
            return(cost);
        }