Exemplo n.º 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Utilities.SetSemesterDefaultItems(cboSchoolYear, cboSemester); //顯示學年度學期選項。

            Semester = new SemesterSelector(cboSchoolYear, cboSemester);
            Semester.SemesterChanged += new EventHandler(Semester_SemesterChanged);

            Options = new UserOptions();

            MasterWorker.DoWork             += new DoWorkEventHandler(MasterWorker_DoWork);
            MasterWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(MasterWorker_RunWorkerCompleted);

            //報表設定。
            Perference = new ReportPreference();

            FillCurrentSemesterData();
        }
Exemplo n.º 2
0
        public static List <InternalExamScoreRecord> Select(IEnumerable <string> StudentIDs, UserOptions Options)
        {
            //key:CourseID
            Dictionary <string, JHCourseRecord> dictCourses = Utilities.GetCourseDict(Options.SchoolYear, Options.Semester);
            //key:AssessmentSetupID
            Dictionary <string, JHAEIncludeRecord> dictAEIncludes = Utilities.GetAEIncludeDict(dictCourses.Values.ToAssessmentSetupIDs(), Options.Exam);

            //類似學期成績的結構…
            Dictionary <string, InternalExamScoreRecord> dictStudentScores = new Dictionary <string, InternalExamScoreRecord>();

            // 取得評量比例
            Utilities.ScorePercentageHSDict = Utilities.GetScorePercentageHS();

            #region 取得及轉換評量科目成績
            int size   = 200;
            int thread = 5;
            FunctionSpliter <string, JHSCETakeRecord> spliter = new FunctionSpliter <string, JHSCETakeRecord>(size, thread);
            spliter.Function = delegate(List <string> studentKeysPart)
            {
                return(JHSCETake.Select(null, studentKeysPart, new string[] { Options.Exam.ID }, null, null));
            };

            foreach (JHSCETakeRecord sce in spliter.Execute(StudentIDs.ToList()))
            {
                if (!dictCourses.ContainsKey(sce.RefCourseID))
                {
                    continue;                                            //評量成績所屬課程非本學期,跳過
                }
                if (Options.Exam.ID != sce.RefExamID)
                {
                    continue;                                   //評量成績的試別不符,跳過
                }
                JHCourseRecord course = dictCourses[sce.RefCourseID];
                if (!dictAEIncludes.ContainsKey(course.RefAssessmentSetupID))
                {
                    continue;                                                           //如果課程沒有評量設定,跳過
                }
                JHAEIncludeRecord ae = dictAEIncludes[course.RefAssessmentSetupID];

                //每個學生一個 InternalExamScoreRecord
                if (!dictStudentScores.ContainsKey(sce.RefStudentID))
                {
                    dictStudentScores.Add(sce.RefStudentID, new InternalExamScoreRecord(sce.RefStudentID));
                }

                if (!dictStudentScores[sce.RefStudentID].Subjects.ContainsKey(course.Subject))
                {
                    SubjectScore subjectScore = new SubjectScore();
                    subjectScore.Domain  = course.Domain;
                    subjectScore.Subject = course.Subject;
                    subjectScore.Period  = course.Period;
                    subjectScore.Credit  = course.Credit;
                    subjectScore.Score   = Utilities.GetScore(new HC.JHSCETakeRecord(sce), new HC.JHAEIncludeRecord(ae), Options.ScoreSource);

                    if (subjectScore.Score.HasValue)
                    {
                        dictStudentScores[sce.RefStudentID].Subjects.Add(course.Subject, subjectScore);
                    }
                }
            }
            #endregion

            #region 計算評量領域成績
            JHSchool.Evaluation.Calculation.ScoreCalculator defaultCalculator = new JHSchool.Evaluation.Calculation.ScoreCalculator(null);

            StudentScore.SetClassMapping();
            List <StudentScore> Students = ToStudentScore(StudentIDs);
            Students.ReadCalculationRule(null);
            foreach (StudentScore student in Students)
            {
                student.SemestersScore.Add(SemesterData.Empty, new global::JHEvaluation.ScoreCalculation.ScoreStruct.SemesterScore(Options.SchoolYear, Options.Semester));

                if (!dictStudentScores.ContainsKey(student.Id))
                {
                    continue;
                }

                global::JHEvaluation.ScoreCalculation.ScoreStruct.SemesterScore semesterScore = student.SemestersScore[SemesterData.Empty];
                foreach (SubjectScore score in dictStudentScores[student.Id].Subjects.Values)
                {
                    //科目成績偷偷進位
                    if (score.Score.HasValue)
                    {
                        if (student.CalculationRule != null)
                        {
                            score.Score = student.CalculationRule.ParseSubjectScore(score.Score.Value);
                        }
                        else
                        {
                            score.Score = defaultCalculator.ParseSubjectScore(score.Score.Value);
                        }
                    }

                    if (!semesterScore.Subject.Contains(score.Subject))
                    {
                        semesterScore.Subject.Add(score.Subject, new SemesterSubjectScore(score));
                    }
                }
            }

            Students.CalcuateDomainSemesterScore(new string[] { });
            #endregion

            foreach (StudentScore student in Students)
            {
                if (!dictStudentScores.ContainsKey(student.Id))
                {
                    dictStudentScores.Add(student.Id, new InternalExamScoreRecord(student.Id));
                }
                InternalExamScoreRecord examScore = dictStudentScores[student.Id];

                examScore.Subjects = ToSubjects(student.SemestersScore[SemesterData.Empty].Subject);
                examScore.Domains  = ToDomains(student.SemestersScore[SemesterData.Empty].Domain);
            }

            return(new List <InternalExamScoreRecord>(dictStudentScores.Values));
        }