Example #1
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;
                    }
                }
            }
        }
Example #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";
                }
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            // going to run through db and add any missing uci where we have an exam no...

            SimpleStudentList sl1    = new SimpleStudentList(SimpleStudentList.LIST_TYPE.NOFORM_ONROLE);
            PupilDetails      pupil1 = new PupilDetails();
            string            s      = "";

            ExamFiles ef = new ExamFiles();
            Encode    en = new Encode();
            int       n = 0; int n1 = 0;

            foreach (SimplePupil p in sl1._studentlist)
            {
                pupil1.m_UCI = "";
                pupil1.Load(p.m_StudentId.ToString());
                string year = DateTime.Now.Year.ToString();
                if ((pupil1.m_UCI == "") && (pupil1.m_examNo > 0))
                {
                    pupil1.m_UCI = ef.Calculate_UCI_Checksum("52205", "0", year, pupil1.m_examNo.ToString());
                    s            = "UPDATE dbo.tbl_Core_Students SET StudentUCI='" + pupil1.m_UCI + "' ";
                    s           += "WHERE StudentId = '" + p.m_StudentId.ToString() + "' ";
                    en.ExecuteSQL(s);
                    n++;
                }
                if (pupil1.m_examNo == 0)
                {
                    n1++;
                }
            }
            Label1.Text = "Created " + n.ToString() + " new UCIs.  There were " + n1.ToString() + " students found with no Exam Number!";
        }
Example #4
0
        /// <summary>
        /// 对上传的试题题库进行分析
        /// </summary>
        /// <param name="examFiles"></param>
        /// <returns></returns>
        public static object AnalysisExamQuestion(ExamFiles examFiles)
        {
            //var absolutePath = HttpContext.Current.Server.MapPath(examFiles.FilePath);
            // @FrancisTan 20170208
            var absolutePath = PathExtension.MapPath(examFiles.FilePath);

            try
            {
                using (var fileStream = new FileStream(absolutePath, FileMode.Open, FileAccess.Read))
                {
                    var workBook = new HSSFWorkbook(fileStream);
                    var qaList   = AnalysisQuestions(workBook);

                    if (qaList.Count == 0)
                    {
                        return(ErrorModel.OperateFailed);
                    }

                    return(InsertQuestionsToDb(examFiles, qaList));
                }
            }
            catch (Exception ex)
            {
                ExceptionLogBll.ExceptionPersistence("ExamController.cs", "ExamController", ex);

                return(ErrorModel.OperateFailed);
            }
        }
Example #5
0
        /// <summary>
        /// 将试题文件及问题集合插入数据库中
        /// </summary>
        private static object InsertQuestionsToDb(ExamFiles examFiles, List <KeyValuePair <ExamQuestion, List <ExamAnswers> > > list)
        {
            var examFilesBll = new ExamFilesBll();

            examFilesBll.Insert(examFiles);

            if (examFiles.Id > 0)
            {
                DataUpdateLog.SingleUpdate(typeof(ExamFiles).Name, examFiles.Id, DataUpdateType.Insert);

                var questionBll = new ExamQuestionBll();
                var answerBll   = new ExamAnswersBll();

                // 在插入之前获取两表的最大id,以便在插入完成之后做数据库更新记录
                var maxQuestionId = (int)questionBll.GetMaxId();
                var maxAnswerId   = (int)answerBll.GetMaxId();

                try
                {
                    foreach (var keyPair in list)
                    {
                        var question = keyPair.Key;
                        var answers  = keyPair.Value;
                        question.ExamFileId = examFiles.Id;

                        // 将问题与答案放到事务中一起插入,保证数据的准确性
                        questionBll.ExecuteTransation(() => {
                            questionBll.Insert(question);
                            if (question.Id > 0)
                            {
                                answers.ForEach(answer => answer.QuestionId = question.Id);
                                answerBll.BulkInsert(answers);

                                return(true);
                            }

                            return(false);
                        });
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                // 数据库更新记录上传
                DataUpdateLog.BulkUpdate(typeof(ExamQuestion).Name, maxQuestionId, DataUpdateType.Insert);
                DataUpdateLog.BulkUpdate(typeof(ExamAnswers).Name, maxAnswerId, DataUpdateType.Insert);

                return(ErrorModel.OperateSuccess);
            }

            return(ErrorModel.OperateFailed);
        }
        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.";
            }
        }
Example #7
0
 protected void DropDownList_ExamBoards_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (DropDownList_ExamBoards.SelectedIndex > -1)
     {
         string     id = DropDownList_ExamBoards.SelectedValue;
         Exam_Board eb = new Exam_Board(new Guid(id));
         ExamFiles  ef = new ExamFiles();
         DropDownList_data.Items.Clear();
         foreach (ExamBaseOption ebo in ef.ExamsOptionsFromBaseData(eb, SeasonCode.ToString(), YearCode.ToString()))
         {
             ListItem l = new ListItem(ebo.ToString(), ebo.m_OptionEntryCode);
             DropDownList_data.Items.Add(l);
         }
     }
 }
        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 = "";
                }
            }
        }