public Report() { Template = new Workbook(); //Template.Open(new MemoryStream(Prc.班級評量成績單B4)); DefaultCalc = new JHSchool.Evaluation.Calculation.ScoreCalculator(null); Calcs = new Dictionary <string, JHSchool.Evaluation.Calculation.ScoreCalculator>(); foreach (var record in JHScoreCalcRule.SelectAll()) { if (!Calcs.ContainsKey(record.ID)) { Calcs.Add(record.ID, new JHSchool.Evaluation.Calculation.ScoreCalculator(record)); } } }
//public Report(List<ClassExamScoreData> data, Dictionary<string, JHCourseRecord> courseDict, JHExamRecord exam, List<ComputeMethod> methods) //{ public Report(List <ClassExamScoreData> data, Dictionary <string, JHCourseRecord> courseDict, JHExamRecord exam, List <string> domains) { _data = data; _courseDict = courseDict; _exam = exam; _domains = domains; _calc = new JHSchool.Evaluation.Calculation.ScoreCalculator(null); //_methods = methods; InitializeWorker(); SchoolName = School.ChineseName; // Semester = string.Format("{0}學年度 第{1}學期", School.DefaultSchoolYear, School.DefaultSemester); Semester = string.Format("{0}學年度 第{1}學期", Global.UserSelectSchoolYear, Global.UserSelectSemester); }
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)); }