internal void Add(HC.JHSCETakeRecord sce) { if (!_courseDict.ContainsKey(sce.RefCourseID)) { return; } JHCourseRecord course = _courseDict[sce.RefCourseID]; if (!Domains.ContainsKey(course.Domain)) { Domains.Add(course.Domain, new DomainRow(course.Domain)); } DomainRow row = Domains[course.Domain]; if (!row.Subjects.ContainsKey(course.Subject)) { row.AddSubject(course.Subject); } SubjectRow subjectRow = row.Subjects[course.Subject]; subjectRow.RefAssessmentSetupID = course.RefAssessmentSetupID; subjectRow.SetPeriodCredit(course.Period, course.Credit); subjectRow.Score = sce.Score; subjectRow.AssignmentScore = sce.AssignmentScore; subjectRow.Text = sce.Text; subjectRow.Display = true; }
internal void SetSubjects(List <string> list) { List <JHCourseRecord> courseList = new List <JHCourseRecord>(); foreach (string courseID in list) { if (!_courseDict.ContainsKey(courseID)) { continue; } courseList.Add(_courseDict[courseID]); } courseList.Sort(delegate(JHCourseRecord x, JHCourseRecord y) { return(JHSchool.Evaluation.Subject.CompareSubjectOrdinal(x.Subject, y.Subject)); }); //courseList = from course in courseList orderby course.Subject select course; foreach (JHCourseRecord course in courseList) { string domain = course.Domain; string subject = course.Subject; if (!Domains.ContainsKey(domain)) { Domains.Add(domain, new DomainRow(domain)); } DomainRow domainRow = Domains[domain]; if (_config.DomainSubjectSetup == "Subject") { domainRow.Display = false; } if (!domainRow.Subjects.ContainsKey(subject)) { domainRow.AddSubject(subject); } domainRow.Subjects[subject].SetPeriodCredit(course.Period, course.Credit); domainRow.Subjects[subject].Display = true; } }
internal void SetConfig(Config config) { _config = config; foreach (var domain in config.PrintSubjects.Keys) { if (!Domains.ContainsKey(domain)) { Domains.Add(domain, new DomainRow(domain)); } DomainRow domainRow = Domains[domain]; domainRow.Display = config.PrintDomains[domain]; foreach (var subject in config.PrintSubjects[domain]) { domainRow.AddSubject(subject); domainRow.Subjects[subject].Display = true; } } }
/// <summary> /// 判斷是否要顯示領域 /// </summary> /// <param name="dr"></param> /// <returns></returns> private bool CheckDisplayDomain(DomainRow dr) { bool retVal = false; foreach (var sr in dr.Subjects) { if (_SubjCourseDict.ContainsKey(sr.Value.SubjectName)) { foreach (var subjectName in dr.Subjects.Keys) { if (_SubjCourseDict.ContainsKey(subjectName)) { if (_config.HasExam(_SubjCourseDict[subjectName])) { retVal = true; break; } } } } } return(retVal); }
/// <summary> /// 處理領域顯示 /// </summary> /// <param name="indexCell"></param> /// <param name="domain"></param> private void WriteDomainRowOnly(Cell indexCell, DomainRow domain) { try { // 判斷領域名稱是否需要顯示 bool DisplayDomain1 = CheckDisplayDomain(domain); if (DisplayDomain1) { // 當領域為空白時需要另外處理 if (string.IsNullOrEmpty(domain.DomainName)) { Cell subjectCell = WordHelper.GetMoveRightCell(indexCell, 1); int count = 0; foreach (var subjectName in domain.Subjects.Keys) { // 判斷是否需要顯示科目 bool DisplaySubject = true; if (_SubjCourseDict.ContainsKey(subjectName)) { if (_config.HasExam(_SubjCourseDict[subjectName]) == false) { DisplaySubject = false; } } if (DisplaySubject == false) { continue; } SubjectRow row = domain.Subjects[subjectName]; if (row.Display) { Cell temp1 = subjectCell; Write(temp1, row.SubjectName); temp1 = temp1.NextSibling as Cell; Write(temp1, GetPCDisplay(row.PeriodCredit)); // 依照成績計算規則 // 定期評量 if (PrintScore) { temp1 = temp1.NextSibling as Cell; if (row.Score.HasValue) { Write(temp1, "" + _calculator.ParseSubjectScore(row.Score.Value)); } else { Write(temp1, ""); } } // 平時評量 if (PrintAssScore) { temp1 = temp1.NextSibling as Cell; if (row.AssignmentScore.HasValue) { Write(temp1, "" + _calculator.ParseSubjectScore(row.AssignmentScore.Value)); } else { Write(temp1, ""); } } // 定期學習評量總成績 if (PrintTotalScore) { temp1 = temp1.NextSibling as Cell; if (row.FinalScore.HasValue) { Write(temp1, "" + _calculator.ParseSubjectScore(row.FinalScore.Value)); } else { Write(temp1, ""); } } // 文字評語 if (PrintText) { temp1 = temp1.NextSibling as Cell; Write(temp1, "" + row.Text); } subjectCell = WordHelper.GetMoveDownCell(subjectCell, 1); count++; // 算領域加權平均 if (row.Score.HasValue) { DomainSumScore += row.Score.Value * row.Credit; DomainSumCredit += row.Credit; } // 算領域平時評量加權平均 if (row.AssignmentScore.HasValue) { DomainSumAssignmentScore += row.AssignmentScore.Value * row.Credit; DomainSumCreditAss += row.Credit; } // 算領域學習總分加權平均 if (row.FinalScore.HasValue) { DomainSumFinalScore += row.FinalScore.Value * row.Credit; DomainSumFinalCredit += row.Credit; } if (subjectCell == null) { break; } } } WordHelper.MergeVerticalCell(indexCell, count); Write(indexCell, "彈性課程"); } else { WordHelper.MergeHorizontalCell(indexCell, 2); Write(indexCell, domain.DomainName); Cell temp = indexCell.NextSibling as Cell; temp = temp.NextSibling as Cell; Write(temp, GetPCDisplay(domain.PeriodCredit)); // 定期評量 if (PrintScore) { temp = temp.NextSibling as Cell; Write(temp, (domain.Score.HasValue ? "" + _calculator.ParseDomainScore(domain.Score.Value) : "")); } // 平時評量 if (PrintAssScore) { temp = temp.NextSibling as Cell; Write(temp, (domain.AssignmentScore.HasValue ? "" + _calculator.ParseDomainScore(domain.AssignmentScore.Value) : "")); } // 定期學習評量總成績 if (PrintTotalScore) { temp = temp.NextSibling as Cell; Write(temp, (domain.FinalScore.HasValue ? "" + _calculator.ParseDomainScore(domain.FinalScore.Value) : "")); } // 文字評語 if (PrintText) { temp = temp.NextSibling as Cell; Write(temp, domain.Text); } // 算領域加權平均 if (domain.Score.HasValue) { decimal crd; if (decimal.TryParse(GetPCDisplay(domain.PeriodCredit), out crd)) { DomainSumScore += (domain.Score.Value * crd); DomainSumCredit += crd; } } // 算領域平時評量加權平均 if (domain.AssignmentScore.HasValue) { decimal crd; if (decimal.TryParse(GetPCDisplay(domain.PeriodCredit), out crd)) { DomainSumAssignmentScore += (domain.AssignmentScore.Value * crd); DomainSumCreditAss += crd; } } // 算領域學習總成績加權平均 if (domain.FinalScore.HasValue) { decimal crd; if (decimal.TryParse(GetPCDisplay(domain.PeriodCredit), out crd)) { DomainSumFinalScore += (domain.FinalScore.Value * crd); DomainSumFinalCredit += crd; } } } } } catch (Exception) { throw; } }
private int WriteDomainRow(Cell indexCell, DomainRow domain) { try { // 判斷領域名稱是否需要顯示 bool DisplayDomain = CheckDisplayDomain(domain); if (DisplayDomain) { Write(indexCell, string.IsNullOrEmpty(domain.DomainName) ? "彈性課程" : domain.DomainName); } Cell subjectCell = WordHelper.GetMoveRightCell(indexCell, 1); int count = 0; foreach (var subjectName in domain.Subjects.Keys) { // 判斷是否需要顯示科目 bool DisplaySubject = true; if (_SubjCourseDict.ContainsKey(subjectName)) { if (_config.HasExam(_SubjCourseDict[subjectName]) == false) { DisplaySubject = false; } } if (DisplaySubject == false) { continue; } SubjectRow row = domain.Subjects[subjectName]; if (row.Display) { Cell temp = subjectCell; Write(temp, row.SubjectName); temp = temp.NextSibling as Cell; Write(temp, GetPCDisplay(row.PeriodCredit)); // 依照成績計算規則設定 // 定期評量 if (PrintScore) { temp = temp.NextSibling as Cell; if (row.Score.HasValue) { Write(temp, "" + _calculator.ParseSubjectScore(row.Score.Value)); } else { Write(temp, ""); } } // 平時評量 if (PrintAssScore) { temp = temp.NextSibling as Cell; if (row.AssignmentScore.HasValue) { Write(temp, "" + _calculator.ParseSubjectScore(row.AssignmentScore.Value)); } else { Write(temp, ""); } } // 定期學習評量總成績 if (PrintTotalScore) { temp = temp.NextSibling as Cell; if (row.FinalScore.HasValue) { Write(temp, "" + _calculator.ParseSubjectScore(row.FinalScore.Value)); } else { Write(temp, ""); } } // 文字評語 if (PrintText) { temp = temp.NextSibling as Cell; Write(temp, "" + row.Text); } subjectCell = WordHelper.GetMoveDownCell(subjectCell, 1); count++; // 定期評量加權平均 if (row.Score.HasValue) { SubjSumScore += (row.Score.Value * row.Credit); SubjSumCredit += row.Credit; } // 平時評量加權平均 if (row.AssignmentScore.HasValue) { SubjSumAssignmentScore += (row.AssignmentScore.Value * row.Credit); SubjSumCreditAss += row.Credit; } // 學習總成績加權平均 if (row.FinalScore.HasValue) { SubjSumFinalScore += (row.FinalScore.Value * row.Credit); SubjSumFinalCredit += row.Credit; } if (subjectCell == null) { break; } } } return(count); } catch (Exception) { throw; } }
private void FillScore() { RemoveNoScoreRows(); // 建立對照 foreach (JHCourseRecord cr in _courseDict.Values) { if (!_SubjCourseDict.ContainsKey(cr.Subject)) { _SubjCourseDict.Add(cr.Subject, cr); } } //_SubjCourseDict = _courseDict.Values.Distinct().ToDictionary(x => x.Subject); _builder.MoveToMergeField("成績"); Cell indexCell = _builder.CurrentParagraph.ParentNode as Cell; try { //排序 List <string> domains = new List <string>(_manager.Domains.Keys); domains.Sort(JHSchool.Evaluation.Subject.CompareDomainOrdinal); foreach (var domainName in _manager.Domains.Keys) { DomainRow domain = _manager.Domains[domainName]; bool display = false; if (_config.PrintDomains.ContainsKey(domain.DomainName)) { display = CheckDisplayDomain(domain); // display = _config.PrintDomains[domain.DomainName]; } else { display = domain.Display; } if (_config.DomainSubjectSetup == "Domain") { if (display) { Cell temp = indexCell; indexCell = WordHelper.GetMoveDownCell(indexCell, 1); WriteDomainRowOnly(temp, domain); // WordHelper.MergeHorizontalCell(temp, 2); if (indexCell == null) { break; } } } else { if (domain.Subjects.Count > 0) { int count = WriteDomainRow(indexCell, domain); Cell temp = indexCell; indexCell = WordHelper.GetMoveDownCell(indexCell, count); WordHelper.MergeVerticalCell(temp, count); if (indexCell == null) { break; } } } } // 算科目加權平均 if (SubjSumCredit > 0) { // 定期 //SubjAvgScore = Math.Round(SubjSumScore / SubjSumCredit, 2, MidpointRounding.AwayFromZero); SubjAvgScore = _calculator.ParseSubjectScore(SubjSumScore / SubjSumCredit); } if (SubjSumCreditAss > 0) { // 平時 SubjAvgAssignmentScore = _calculator.ParseSubjectScore(SubjSumAssignmentScore / SubjSumCreditAss); } // 總分 if (SubjSumFinalCredit > 0) { SubjAvgFinalScore = _calculator.ParseSubjectScore(SubjSumFinalScore / SubjSumFinalCredit); } // 算領域加權平均 if (DomainSumCredit > 0) { //DomainAvgScore = Math.Round(DomainSumScore / DomainSumCredit, 2, MidpointRounding.AwayFromZero); DomainAvgScore = _calculator.ParseDomainScore(DomainSumScore / DomainSumCredit); } if (DomainSumCreditAss > 0) { DomainAvgAssignmentScore = _calculator.ParseDomainScore(DomainSumAssignmentScore / DomainSumCreditAss); } if (DomainSumFinalCredit > 0) { DomainAvgFinalScore = _calculator.ParseDomainScore((DomainSumFinalScore) / DomainSumFinalCredit); } } catch (Exception ex) { throw ex; } }