Dictionary <string, bool> IEvaluative.Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); Dictionary <string, bool> passList = new Dictionary <string, bool>(); //// 取得學生目前班級年級 //Dictionary<string, int> studGrYearDic = new Dictionary<string, int>(); //foreach (JHSchool.Data.JHStudentRecord stud in JHSchool.Data.JHStudent.SelectByIDs(list.AsKeyList())) //{ // if (stud.Class != null) // if (stud.Class.GradeYear.HasValue) // studGrYearDic.Add(stud.ID, stud.Class.GradeYear.Value); //} //bool checkInsShi = false; //// 取得學生學期歷程 //Dictionary<string, JHSchool.Data.JHSemesterHistoryRecord> studentHistories = new Dictionary<string, JHSchool.Data.JHSemesterHistoryRecord>(); //foreach (JHSchool.Data.JHSemesterHistoryRecord rec in JHSchool.Data.JHSemesterHistory.SelectByStudentIDs(list.AsKeyList())) //{ // checkInsShi = true; // K12.Data.SemesterHistoryItem shi = new K12.Data.SemesterHistoryItem(); // shi.SchoolYear = UIConfig._UserSetSHSchoolYear; // shi.Semester = UIConfig._UserSetSHSemester; // if (studGrYearDic.ContainsKey(rec.RefStudentID)) // shi.GradeYear = studGrYearDic[rec.RefStudentID]; // foreach (K12.Data.SemesterHistoryItem shiItem in rec.SemesterHistoryItems) // if (shiItem.SchoolYear == shi.SchoolYear && shiItem.Semester == shi.Semester) // checkInsShi = false; // if (checkInsShi) // rec.SemesterHistoryItems.Add(shi); // studentHistories.Add(rec.RefStudentID, rec); //} //Dictionary<string, List<Data.JHMoralScoreRecord>> morals = new Dictionary<string, List<JHSchool.Data.JHMoralScoreRecord>>(); //foreach (Data.JHMoralScoreRecord moral in Data.JHMoralScore.SelectByStudentIDs(list.AsKeyList())) //{ // if (!morals.ContainsKey(moral.RefStudentID)) // morals.Add(moral.RefStudentID, new List<JHSchool.Data.JHMoralScoreRecord>()); // morals[moral.RefStudentID].Add(moral); //} Dictionary <string, List <AutoSummaryRecord> > morals = new Dictionary <string, List <AutoSummaryRecord> >(); foreach (AutoSummaryRecord record in AutoSummary.Select(list.AsKeyList(), null)) { if (!morals.ContainsKey(record.RefStudentID)) { morals.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } morals[record.RefStudentID].Add(record); } foreach (StudentRecord student in list) { passList.Add(student.ID, true); Dictionary <SemesterInfo, int> gyMapping = new Dictionary <SemesterInfo, int>(); Dictionary <SemesterInfo, decimal> schoolDayMapping = new Dictionary <SemesterInfo, decimal>(); foreach (K12.Data.SemesterHistoryItem item in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = item.SchoolYear; info.Semester = item.Semester; if (!gyMapping.ContainsKey(info)) { gyMapping.Add(info, item.GradeYear); if (item.SchoolDayCount.HasValue) { decimal num = (decimal)item.SchoolDayCount.Value; //設定臨界值 decimal count = 0; count += num * _dayPeriod; //foreach (string type in _SelectedType) //{ // count += num * _periodMapping[type] * _typeWeight[type]; //} count = count * _amount / 100; schoolDayMapping.Add(info, count); //num *= _dayPeriod; //num = num * _amount / 100; //schoolDayMapping.Add(info, num); } } } if (!morals.ContainsKey(student.ID)) { continue; } Dictionary <SemesterInfo, decimal> counter = new Dictionary <SemesterInfo, decimal>(); foreach (AutoSummaryRecord record in morals[student.ID]) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = record.SchoolYear; info.Semester = record.Semester; if (gyMapping.ContainsKey(info) && !((gyMapping[info] == 3 || gyMapping[info] == 9) && info.Semester == 2)) { continue; } //foreach (XmlElement itemElement in record.Summary.SelectNodes("AttendanceStatistics/Absence")) foreach (AbsenceCountRecord acRecord in record.AbsenceCounts) { //string name = itemElement.GetAttribute("Name"); //string periodType = itemElement.GetAttribute("PeriodType"); if (!_types.ContainsKey(acRecord.PeriodType + ":" + acRecord.Name)) { continue; } //decimal count; //if (!decimal.TryParse(itemElement.GetAttribute("Count"), out count)) // count = 0; //else // count *= _types[periodType + ":" + name]; if (!counter.ContainsKey(info)) { counter.Add(info, 0); } counter[info] += acRecord.Count * _types[acRecord.PeriodType + ":" + acRecord.Name]; } } List <ResultDetail> resultList = new List <ResultDetail>(); foreach (SemesterInfo info in counter.Keys) { if (!gyMapping.ContainsKey(info)) { continue; } if (!schoolDayMapping.ContainsKey(info)) { continue; } if (counter[info] > schoolDayMapping[info]) { ResultDetail rd = new ResultDetail(student.ID, "" + gyMapping[info], "" + info.Semester); rd.AddMessage("上課天數不足"); rd.AddDetail("上課天數不足(累計" + counter[info] + "節)"); resultList.Add(rd); } } if (resultList.Count > 0) { _result.Add(student.ID, resultList); passList[student.ID] = false; } } return(passList); }
/// <summary> /// 根據學生判斷是否符合條件 /// </summary> /// <param name="list"></param> /// <returns></returns> public Dictionary <string, bool> Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); //學生通過或不通過列表 Dictionary <string, bool> passList = new Dictionary <string, bool>(); list.SyncSemesterHistoryCache(); Dictionary <string, List <AutoSummaryRecord> > morals = new Dictionary <string, List <AutoSummaryRecord> >(); //取得學生的自動缺曠獎懲統計 foreach (AutoSummaryRecord record in AutoSummary.Select(list.AsKeyList(), null)) { if (!morals.ContainsKey(record.RefStudentID)) { morals.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } morals[record.RefStudentID].Add(record); } foreach (StudentRecord student in list) { //先假設每位學生通過判斷 passList.Add(student.ID, true); #region 針對每位學生產生學年度學期對學年度對照 Dictionary <SemesterInfo, int> gyMapping = new Dictionary <SemesterInfo, int>(); if (UIConfig._StudentSHistoryRecDict.ContainsKey(student.ID)) { //針對學生的每筆學期歷程 foreach (K12.Data.SemesterHistoryItem shi in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems) { //建立學年度學期物件,並將學期歷程的學年度及學期複製過去 SemesterInfo info = new SemesterInfo(); info.SchoolYear = shi.SchoolYear; info.Semester = shi.Semester; //將學年度學期對年級加入到集合中 if (!gyMapping.ContainsKey(info)) { gyMapping.Add(info, shi.GradeYear); } else { FISCA.Presentation.Controls.MsgBox.Show("學生:" + UIConfig._StudentSHistoryRecDict[student.ID].Student.Name + " 學期歷程重覆"); } } } #endregion if (!morals.ContainsKey(student.ID)) { continue; } Dictionary <SemesterInfo, decimal> counter = new Dictionary <SemesterInfo, decimal>(); #region 針對學生的每筆自動缺曠獎懲統計,統計缺曠節數 foreach (AutoSummaryRecord record in morals[student.ID]) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = record.SchoolYear; info.Semester = record.Semester; //針對每筆缺曠名稱的統計 foreach (AbsenceCountRecord acRecord in record.AbsenceCounts) { //要缺曠類別在成績計算規則中才統計 if (!_types.ContainsKey(acRecord.PeriodType + ":" + acRecord.Name)) { continue; } //將自動獎懲缺曠統計放入到變數中 if (!counter.ContainsKey(info)) { counter.Add(info, 0); } //加總缺曠節次 counter[info] += acRecord.Count * _types[acRecord.PeriodType + ":" + acRecord.Name]; } } #endregion List <ResultDetail> resultList = new List <ResultDetail>(); foreach (SemesterInfo info in counter.Keys) { //判斷統計的數字是否大於成績計算規則設定的數字 if (gyMapping.ContainsKey(info) && counter[info] >= _amount) { #region 加入回傳訊息 ResultDetail rd = new ResultDetail(student.ID, "" + gyMapping[info], "" + info.Semester); rd.AddMessage("缺課節數超次"); rd.AddDetail("缺課節數超次(累計" + counter[info] + "節)"); resultList.Add(rd); #endregion } } //若ResultDetail的列表項目大於0 if (resultList.Count > 0) { //將ResultDetail加入到回傳結果中 _result.Add(student.ID, resultList); passList[student.ID] = false; } } return(passList); }
Dictionary <string, bool> IEvaluative.Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); TempData.tmpStudentAbsenceAmountAllDict.Clear(); Dictionary <string, bool> passList = new Dictionary <string, bool>(); Dictionary <string, List <AutoSummaryRecord> > morals = new Dictionary <string, List <AutoSummaryRecord> >(); foreach (AutoSummaryRecord record in AutoSummary.Select(list.AsKeyList(), null)) { if (!morals.ContainsKey(record.RefStudentID)) { morals.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } morals[record.RefStudentID].Add(record); } foreach (StudentRecord student in list) { //核准假別的累積次數須歸零 _AvoidDic.Clear(); foreach (string key in _AvoidList) { if (!_AvoidDic.ContainsKey(key)) { _AvoidDic.Add(key, 0); } } passList.Add(student.ID, true); Dictionary <SemesterInfo, int> gyMapping = new Dictionary <SemesterInfo, int>(); Dictionary <SemesterInfo, decimal> schoolDayMapping = new Dictionary <SemesterInfo, decimal>(); Dictionary <string, K12.Data.SemesterHistoryItem> uniqloSHistoryDict = new Dictionary <string, K12.Data.SemesterHistoryItem>(); // 2018/6/22 穎驊紀錄,在此排除 重覆的學習歷程資料,若重覆,將會以新學年度 重讀學年度為主 foreach (K12.Data.SemesterHistoryItem item in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems) { if (!uniqloSHistoryDict.ContainsKey(item.GradeYear + "_" + item.Semester)) { uniqloSHistoryDict.Add(item.GradeYear + "_" + item.Semester, item); } else { if (uniqloSHistoryDict[item.GradeYear + "_" + item.Semester].SchoolYear < item.SchoolYear) { uniqloSHistoryDict.Remove(item.GradeYear + "_" + item.Semester); uniqloSHistoryDict.Add(item.GradeYear + "_" + item.Semester, item); } } } foreach (K12.Data.SemesterHistoryItem item in uniqloSHistoryDict.Values) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = item.SchoolYear; info.Semester = item.Semester; if (!gyMapping.ContainsKey(info)) { gyMapping.Add(info, item.GradeYear); if (item.SchoolDayCount.HasValue) { decimal num = (decimal)item.SchoolDayCount.Value; //設定臨界值 decimal newNum = 0; newNum += num * _dayPeriod; //foreach (string type in _periodMapping.Keys) //{ // newNum += num * _periodMapping[type]; //} schoolDayMapping.Add(info, newNum); } } } if (!morals.ContainsKey(student.ID)) { continue; } Dictionary <SemesterInfo, decimal> counter = new Dictionary <SemesterInfo, decimal>(); foreach (AutoSummaryRecord record in morals[student.ID]) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = record.SchoolYear; info.Semester = record.Semester; foreach (AbsenceCountRecord acRecord in record.AbsenceCounts) { //加總各項核定假別 ,且該節次別 是在核定節次別內 if (_AvoidDic.ContainsKey(acRecord.Name) && _PeroidList.Contains(acRecord.PeriodType)) { _AvoidDic[acRecord.Name] += acRecord.Count; } if (!_types.ContainsKey(acRecord.PeriodType + ":" + acRecord.Name)) { continue; } // 2018/05/08 穎驊註解 因應高雄小組項目 [03-03][04] 畢業預警及畢業判斷 , 學生休學期間 成績、缺曠不採計,獎懲 仍採計 // 該缺曠紀錄 在該學期必須要有學習歷程 才列入計算,否則其應該為休學的資料 if (counter.ContainsKey(info) && schoolDayMapping.ContainsKey(info)) { counter[info] += acRecord.Count * _types[acRecord.PeriodType + ":" + acRecord.Name]; } if (!counter.ContainsKey(info) && schoolDayMapping.ContainsKey(info)) { counter.Add(info, 0); counter[info] += acRecord.Count * _types[acRecord.PeriodType + ":" + acRecord.Name]; } // 累積缺曠明細 if (!TempData.tmpStudentAbsenceAmountAllDict.ContainsKey(student.ID)) { TempData.tmpStudentAbsenceAmountAllDict.Add(student.ID, new Dictionary <string, Dictionary <string, int> >()); } string scStr = info.SchoolYear + "學年度第" + info.Semester + "學期"; if (!TempData.tmpStudentAbsenceAmountAllDict[student.ID].ContainsKey(scStr)) { TempData.tmpStudentAbsenceAmountAllDict[student.ID].Add(scStr, new Dictionary <string, int>()); } string strType = acRecord.PeriodType + ":" + acRecord.Name; if (!TempData.tmpStudentAbsenceAmountAllDict[student.ID][scStr].ContainsKey(strType)) { TempData.tmpStudentAbsenceAmountAllDict[student.ID][scStr].Add(strType, 0); } TempData.tmpStudentAbsenceAmountAllDict[student.ID][scStr][strType] += acRecord.Count; } } List <ResultDetail> resultList = new List <ResultDetail>(); decimal count = 0; decimal schoolDay = 0; foreach (SemesterInfo info in counter.Keys) { count += counter[info]; } foreach (KeyValuePair <SemesterInfo, decimal> kvp in schoolDayMapping) { schoolDay += kvp.Value; } //循環要扣除的假別數 foreach (string elem in _AvoidDic.Keys) { schoolDay -= _AvoidDic[elem]; } //總節數乘上設定比例 if (schoolDay < 0) { schoolDay = 0; } schoolDay *= _amount / 100; if (count > schoolDay) { ResultDetail rd = new ResultDetail(student.ID, "0", "0"); rd.AddMessage("上課天數不足"); rd.AddDetail("上課天數不足(累計" + count + "節)"); resultList.Add(rd); } if (resultList.Count > 0) { _result.Add(student.ID, resultList); passList[student.ID] = false; } } return(passList); }
public Dictionary <string, bool> Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); Dictionary <string, bool> passList = new Dictionary <string, bool>(); Dictionary <string, List <JHSemesterScoreRecord> > studentSemesterScoreCache = new Dictionary <string, List <JHSemesterScoreRecord> >(); foreach (JHSemesterScoreRecord record in JHSemesterScore.SelectByStudentIDs(list.AsKeyList())) { if (!studentSemesterScoreCache.ContainsKey(record.RefStudentID)) { studentSemesterScoreCache.Add(record.RefStudentID, new List <JHSemesterScoreRecord>()); } studentSemesterScoreCache[record.RefStudentID].Add(record); } //學生能被承認的學年度學期對照 Dictionary <string, List <string> > studentSYSM = new Dictionary <string, List <string> >(); #region 學期歷程 foreach (K12.Data.SemesterHistoryRecord shr in K12.Data.SemesterHistory.SelectByStudentIDs(list.Select(x => x.ID))) { if (!studentSYSM.ContainsKey(shr.RefStudentID)) { studentSYSM.Add(shr.RefStudentID, new List <string>()); } Dictionary <string, K12.Data.SemesterHistoryItem> check = new Dictionary <string, K12.Data.SemesterHistoryItem>() { { "1a", null }, { "1b", null }, { "2a", null }, { "2b", null }, { "3a", null }, { "3b", null } }; foreach (K12.Data.SemesterHistoryItem item in shr.SemesterHistoryItems) { string grade = item.GradeYear + ""; if (grade == "7") { grade = "1"; } if (grade == "8") { grade = "2"; } if (grade == "9") { grade = "3"; } if (grade == "1" || grade == "2" || grade == "3") { string key = ""; if (item.Semester == 1) { key = grade + "a"; } else if (item.Semester == 2) { key = grade + "b"; } else { continue; } //相同年級取較新的學年度 if (check[key] == null) { check[key] = item; } else if (item.SchoolYear > check[key].SchoolYear) { check[key] = item; } } } foreach (string key in check.Keys) { if (check[key] == null) { continue; } K12.Data.SemesterHistoryItem item = check[key]; studentSYSM[shr.RefStudentID].Add(item.SchoolYear + "_" + item.Semester); } } #endregion // 取得108課綱認定領域 JHEvaluation.ScoreCalculation.Util.LoadDomainMap108(); foreach (StudentRecord each in list) { List <ResultDetail> resultList = new List <ResultDetail>(); // 有學期成績 if (studentSemesterScoreCache.ContainsKey(each.ID)) { // 存放符合標準畢業領域成績 List <decimal> passScoreList = new List <decimal>(); //每個學期整理後的成績 List <List <K12.Data.DomainScore> > GradeScoreList = new List <List <K12.Data.DomainScore> >(); // 取得學生學生領域成績填入計算畢業成績用 foreach (JHSemesterScoreRecord record in studentSemesterScoreCache[each.ID]) { string key = record.SchoolYear + "_" + record.Semester; //只處理承認的學年度學期 if (!studentSYSM.ContainsKey(each.ID) || !studentSYSM[each.ID].Contains(key)) { continue; } //整理後的領域成績 List <K12.Data.DomainScore> domainScoreList = new List <K12.Data.DomainScore>(); K12.Data.DomainScore 語文 = new K12.Data.DomainScore(); 語文.Domain = "語文"; decimal sum = 0; decimal credit = 0; // 2017/5/25 穎驊新增, 因應 高雄客服 高雄小組 [05-01][--] 項目調整, // 舊有邏輯無論該學期是否已經有教務作業期末結算完產生 "語文領域" 的領域成績, // 皆會再額外再幫它算一次並且加入語文領域總分、語文領域權重,此行為容易造成資料的組成比重不對,產生錯誤無法解釋的語文領域分數, // 現在加入新判斷,如果該學期已經有 語文領域成績, 則不會再另外計算、加入該學期的語文領域成績, // 反之,如果該學期 沒有語文領域成績, 會再計算一次 補上,以作為畢業預警判斷使用。 bool hasLanguageDomain = false; //跑一遍領域成績 foreach (K12.Data.DomainScore domain in record.Domains.Values) { // 不符合108課綱白名單先剔除 if (!JHEvaluation.ScoreCalculation.Util.DomainMap108List.Contains(domain.Domain)) { continue; } if (domain.SchoolYear < 108) { // 108學年度前有修科技不會被判斷 if (domain.Domain == "科技") { continue; } if (domain.Domain == "自然科學") { domain.Domain = "自然與生活科技"; } if (domain.Domain == "藝術") { domain.Domain = "藝術與人文"; } } // 經過討論高雄國語文與英語不要特別處理,應該回歸各學期有語文領域 //if (domain.Domain == "語文") //{ // hasLanguageDomain = true; //} ////這三種挑出來處理 //if (domain.Domain == "國語文" || domain.Domain == "英語") //{ // if (domain.Score.HasValue && domain.Credit.HasValue) // { // sum += domain.Score.Value * domain.Credit.Value; // credit += domain.Credit.Value; // //處理高雄語文顯示 // // 加權總分 // if (!TempData.tmpStudDomainScoreDict.ContainsKey(record.RefStudentID)) // TempData.tmpStudDomainScoreDict.Add(record.RefStudentID, new Dictionary<string, decimal>()); // if (!TempData.tmpStudDomainCreditDict.ContainsKey(record.RefStudentID)) // TempData.tmpStudDomainCreditDict.Add(record.RefStudentID, new Dictionary<string, decimal>()); // if (!TempData.tmpStudDomainScoreDict[record.RefStudentID].ContainsKey(domain.Domain)) // TempData.tmpStudDomainScoreDict[record.RefStudentID].Add(domain.Domain, 0); // // 學分數 // if (!TempData.tmpStudDomainCreditDict[record.RefStudentID].ContainsKey(domain.Domain)) // TempData.tmpStudDomainCreditDict[record.RefStudentID].Add(domain.Domain, 0); // TempData.tmpStudDomainScoreDict[record.RefStudentID][domain.Domain] += (domain.Score.Value * domain.Credit.Value); // TempData.tmpStudDomainCreditDict[record.RefStudentID][domain.Domain] += domain.Credit.Value; // } //} //else // domainScoreList.Add(domain); domainScoreList.Add(domain); } //if (!hasLanguageDomain&&credit > 0) //{ // 語文.Score = Math.Round(sum / credit, 2, MidpointRounding.AwayFromZero); // 語文.Credit = credit; // domainScoreList.Add(語文); //} //會被加入就代表承認了 GradeScoreList.Add(domainScoreList); } Dictionary <string, decimal> domainScoreSum = new Dictionary <string, decimal>(); Dictionary <string, decimal> domainScoreCount = new Dictionary <string, decimal>(); foreach (List <K12.Data.DomainScore> scoreList in GradeScoreList) { foreach (K12.Data.DomainScore ds in scoreList) { string domainName = ds.Domain; if (!domainScoreSum.ContainsKey(domainName)) { domainScoreSum.Add(domainName, 0); } if (!domainScoreCount.ContainsKey(domainName)) { domainScoreCount.Add(domainName, 0); } if (ds.Score.HasValue) { domainScoreSum[domainName] += ds.Score.Value; //同一學期不會有相同領域名稱,可直接作++ domainScoreCount[domainName]++; } } } //2017/5/9 穎驊修正 ,因應 高雄 [08-05][03] 畢業資格判斷成績及格標準調整 項目, // 領域 分數超過60分 ,以 四捨五入取到小數第二位 , 低於60分 採用 無條件進位至整數 (EX : 59.01 =60) // (只有高雄版有如此機制,新竹版照舊不管分數高低都是四捨五入) foreach (string domainName in domainScoreCount.Keys) { if (domainScoreCount[domainName] > 0) { decimal grScore = 0; if (JHEvaluation.ScoreCalculation.Program.Mode == JHEvaluation.ScoreCalculation.ModuleMode.HsinChu) { grScore = Math.Round(domainScoreSum[domainName] / domainScoreCount[domainName], 2, MidpointRounding.AwayFromZero); } if (JHEvaluation.ScoreCalculation.Program.Mode == JHEvaluation.ScoreCalculation.ModuleMode.KaoHsiung) { if (domainScoreSum[domainName] / domainScoreCount[domainName] >= 60) { grScore = Math.Round(domainScoreSum[domainName] / domainScoreCount[domainName], 2, MidpointRounding.AwayFromZero); } else { grScore = Math.Ceiling(domainScoreSum[domainName] / domainScoreCount[domainName]); } } if (grScore >= _score) { passScoreList.Add(grScore); } StudentDomainResult.AddDomain(each.ID, domainName, grScore, grScore >= _score); } } // 當及格數小於標準數,標示不符格畢業規範 if (passScoreList.Count < _domain_count) { ResultDetail rd = new ResultDetail(each.ID, "0", "0"); rd.AddMessage("領域畢業加權總平均成績不符合畢業規範"); rd.AddDetail("領域畢業加權總平均成績不符合畢業規範"); resultList.Add(rd); } } if (resultList.Count > 0) { _result.Add(each.ID, resultList); passList.Add(each.ID, false); } else { passList.Add(each.ID, true); } } return(passList); }
public Dictionary <string, bool> Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); Dictionary <string, bool> passList = new Dictionary <string, bool>(); list.SyncSemesterHistoryCache(); Dictionary <string, List <Data.JHMoralScoreRecord> > morals = new Dictionary <string, List <JHSchool.Data.JHMoralScoreRecord> >(); foreach (Data.JHMoralScoreRecord moral in Data.JHMoralScore.SelectByStudentIDs(list.AsKeyList())) { if (!morals.ContainsKey(moral.RefStudentID)) { morals.Add(moral.RefStudentID, new List <JHSchool.Data.JHMoralScoreRecord>()); } morals[moral.RefStudentID].Add(moral); } //// 取得學生目前班級年級 //Dictionary<string, int> studGrYearDic = new Dictionary<string, int>(); //foreach (JHSchool.Data.JHStudentRecord stud in JHSchool.Data.JHStudent.SelectByIDs(list.AsKeyList())) //{ // if (stud.Class != null) // if (stud.Class.GradeYear.HasValue) // studGrYearDic.Add(stud.ID, stud.Class.GradeYear.Value); //} //bool checkInsShi = false; //// 取得學生學期歷程 //Dictionary<string, JHSchool.Data.JHSemesterHistoryRecord> studHisRecDic = new Dictionary<string, JHSchool.Data.JHSemesterHistoryRecord>(); //foreach (JHSchool.Data.JHSemesterHistoryRecord rec in JHSchool.Data.JHSemesterHistory.SelectByStudentIDs(list.AsKeyList())) //{ // checkInsShi = true; // K12.Data.SemesterHistoryItem shi = new K12.Data.SemesterHistoryItem(); // shi.SchoolYear = UIConfig._UserSetSHSchoolYear; // shi.Semester = UIConfig._UserSetSHSemester; // if (studGrYearDic.ContainsKey(rec.RefStudentID)) // shi.GradeYear = studGrYearDic[rec.RefStudentID]; // foreach (K12.Data.SemesterHistoryItem shiItem in rec.SemesterHistoryItems) // if (shiItem.SchoolYear == shi.SchoolYear && shiItem.Semester == shi.Semester) // checkInsShi = false; // if (checkInsShi) // rec.SemesterHistoryItems.Add(shi); // studHisRecDic.Add(rec.RefStudentID, rec); //} foreach (StudentRecord student in list) { passList.Add(student.ID, true); Dictionary <SemesterInfo, int> gyMapping = new Dictionary <SemesterInfo, int>(); if (UIConfig._StudentSHistoryRecDict.ContainsKey(student.ID)) { foreach (K12.Data.SemesterHistoryItem shi in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = shi.SchoolYear; info.Semester = shi.Semester; if (!gyMapping.ContainsKey(info)) { gyMapping.Add(info, shi.GradeYear); } else { FISCA.Presentation.Controls.MsgBox.Show("學生:" + UIConfig._StudentSHistoryRecDict[student.ID].Student.Name + " 學期歷程重覆"); } } } //foreach (SemesterHistoryRecord record in student.GetSemesterHistories()) //{ // SemesterInfo info = new SemesterInfo(); // info.SchoolYear = record.SchoolYear; // info.Semester = record.Semester; // if (!gyMapping.ContainsKey(info)) // gyMapping.Add(info, record.GradeYear); //} if (!morals.ContainsKey(student.ID)) { continue; } Dictionary <SemesterInfo, int> counter = new Dictionary <SemesterInfo, int>(); Dictionary <SemesterInfo, bool> semsHasRecord = new Dictionary <SemesterInfo, bool>(); foreach (SemesterInfo info in gyMapping.Keys) { if (!counter.ContainsKey(info)) { counter.Add(info, 0); semsHasRecord.Add(info, false); } } foreach (Data.JHMoralScoreRecord record in morals[student.ID]) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = record.SchoolYear; info.Semester = record.Semester; foreach (XmlElement itemElement in record.TextScore.SelectNodes("DailyBehavior/Item")) { //<Item Degree="" Index="" Name="有禮貌"/> string name = itemElement.GetAttribute("Name"); int degree = _DescToDegree.GetDegree(itemElement.GetAttribute("Degree")); if (counter.ContainsKey(info)) { //若回傳值是最小整數代表有誤 if (degree == int.MinValue) { continue; } if (degree <= _degree) { counter[info]++; } semsHasRecord[info] = true; } } } List <ResultDetail> resultList = new List <ResultDetail>(); foreach (SemesterInfo info in counter.Keys) { if (!gyMapping.ContainsKey(info)) { continue; } if (counter[info] >= _amount) { ResultDetail rd = new ResultDetail(student.ID, "" + gyMapping[info], "" + info.Semester); rd.AddMessage("日常行為不符合畢業規範"); rd.AddDetail("日常行為不符合畢業規範(累計" + counter[info] + "項)"); resultList.Add(rd); } else if (semsHasRecord[info] == false) { ResultDetail rd = new ResultDetail(student.ID, "" + gyMapping[info], "" + info.Semester); rd.AddMessage("日常行為表現資料缺漏"); rd.AddDetail("日常行為表現資料缺漏"); resultList.Add(rd); } } if (resultList.Count > 0) { _result.Add(student.ID, resultList); passList[student.ID] = false; } } return(passList); }