private void ProcessDomain(Dictionary <string, DomainScoreCalculator> domainscores, JHSCETakeRecord take, JHCourseRecord course, RatingStudent student, ScoreItem subject, ScoreItem domain) { if (!course.Credit.HasValue) { return; //如果課程沒有權重就不處理。 } decimal weight = course.Credit.Value; if (!SelectedItems.Contains(domain)) { return; //不在處理的領域清單中。 } if (!domainscores.ContainsKey(student.Id)) { domainscores.Add(student.Id, new DomainScoreCalculator()); } if (domainscores[student.Id].Contains(subject.Name)) { throw new ArgumentException(string.Format("學生「{0}」在同一學期修習「{1}」科目一次以上。", student.Name, subject.Name)); } domainscores[student.Id].Add(domain.Name, subject.Name, take.Score.Value, weight); }
protected override void PrepareDataBackground() { JHClass.RemoveAll(); RatingStudent.SetClassMapping(JHClass.SelectAll()); //快取班級對照資訊。 Dictionary <string, RatingStudent> dicstuds = Students.ToDictionary(); //將學生的成績清除,並新增一個 Token 用來放成績。 foreach (RatingStudent each in Students) { each.Clear(); each.Scores.Add(ScoreType.Subject.Regulation(Token), new ScoreCollection()); each.Scores.Add(ScoreType.Domain.Regulation(Token), new ScoreCollection()); each.Scores.Add(ScoreType.SummaryDomain.Regulation(Token), new ScoreCollection()); } foreach (JHSemesterScoreRecord semsRecord in SemesterScores.Values) { RatingStudent student; if (!dicstuds.TryGetValue(semsRecord.RefStudentID, out student)) { continue; //找不到該學生。 } #region 科目 ScoreCollection subjscores = student.Scores[ScoreType.Subject.Regulation(Token)]; foreach (K12.Data.SubjectScore subjRecord in semsRecord.Subjects.Values) { if (!subjRecord.Score.HasValue) { continue; //沒有成績就不處理。 } ScoreItem subject = new ScoreItem(subjRecord.Subject, ScoreType.Subject); if (!SelectedItems.Contains(subject)) { continue; //不在處理的科目清單中。 } if (subjscores.Contains(subject.Name)) { throw new ArgumentException(string.Format("學生「{0}」在同一學期修習「{1}」科目一次以上。", student.Name, subject.Name)); } subjscores.Add(subject.Name, subjRecord.Score.Value); } #endregion #region 領域 ScoreCollection domainscores = student.Scores[ScoreType.Domain.Regulation(Token)]; foreach (K12.Data.DomainScore domainRecord in semsRecord.Domains.Values) { if (!domainRecord.Score.HasValue) { continue; //沒有成績就不處理。 } ScoreItem domain = new ScoreItem(domainRecord.Domain.Trim(), ScoreType.Domain); if (!SelectedItems.Contains(domain)) { continue; //不在處理的科目清單中。 } if (!NameMapping.ContainsKey(domain.Name)) { throw new ArgumentException(string.Format("領域名稱「{0}」在此畫面沒有定議。", domain)); } if (domainscores.Contains(domain.Name)) { throw new ArgumentException(string.Format("學生「{0}」在同一學期有「{1}」領域一次以上。", student.Name, domain)); } domainscores.Add(domain.Name, domainRecord.Score.Value); } if (semsRecord.LearnDomainScore.HasValue) { domainscores.Add("學習領域", semsRecord.LearnDomainScore.Value); } if (semsRecord.CourseLearnScore.HasValue) { domainscores.Add("課程學習", semsRecord.CourseLearnScore.Value); } #endregion } }