Exemple #1
0
        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 (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, 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) && counter[info] >= _amount)
                    {
                        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);
        }
Exemple #2
0
        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);
        }
        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

            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)
                        {
                            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);
                            }
                        }

                        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);
        }
Exemple #4
0
        Dictionary <string, bool> IEvaluative.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, 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);
            }

            //// 取得學生目前班級年級
            //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);
            //}

            // 獎懲明細統計
            TempData.tmpStudentDemeritAmountAllDict.Clear();

            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, DisTestABC> counter = new Dictionary <SemesterInfo, DisTestABC>();
                foreach (AutoSummaryRecord record in morals[student.ID])
                {
                    SemesterInfo info = new SemesterInfo();
                    info.SchoolYear = record.SchoolYear;
                    info.Semester   = record.Semester;
                    if (!counter.ContainsKey(info))
                    {
                        counter.Add(info, new DisTestABC());
                    }

                    string scStr = info.SchoolYear + "學年度第" + info.Semester + "學期";
                    if (!TempData.tmpStudentDemeritAmountAllDict.ContainsKey(student.ID))
                    {
                        TempData.tmpStudentDemeritAmountAllDict.Add(student.ID, new Dictionary <string, Dictionary <string, int> >());
                    }

                    if (!TempData.tmpStudentDemeritAmountAllDict[student.ID].ContainsKey(scStr))
                    {
                        Dictionary <string, int> value = new Dictionary <string, int>();
                        value.Add("大功", 0);
                        value.Add("小功", 0);
                        value.Add("嘉獎", 0);
                        value.Add("大過", 0);
                        value.Add("小過", 0);
                        value.Add("警告", 0);

                        TempData.tmpStudentDemeritAmountAllDict[student.ID].Add(scStr, value);
                    }

                    TempData.tmpStudentDemeritAmountAllDict[student.ID][scStr]["大功"] += record.MeritA;
                    TempData.tmpStudentDemeritAmountAllDict[student.ID][scStr]["小功"] += record.MeritB;
                    TempData.tmpStudentDemeritAmountAllDict[student.ID][scStr]["嘉獎"] += record.MeritC;
                    TempData.tmpStudentDemeritAmountAllDict[student.ID][scStr]["大過"] += record.DemeritA;
                    TempData.tmpStudentDemeritAmountAllDict[student.ID][scStr]["小過"] += record.DemeritB;
                    TempData.tmpStudentDemeritAmountAllDict[student.ID][scStr]["警告"] += record.DemeritC;

                    decimal total_merit   = _meritConverter.BtoC(_meritConverter.AtoB(record.MeritA) + record.MeritB) + record.MeritC;
                    decimal total_demerit = _demeritConverter.BtoC(_demeritConverter.AtoB(record.DemeritA) + record.DemeritB) + record.DemeritC;

                    //獎懲加總
                    counter[info].Merit   = total_merit;
                    counter[info].Demerit = total_demerit;
                }

                List <ResultDetail> resultList = new List <ResultDetail>();

                decimal merit      = 0;
                decimal demerit    = 0;
                decimal demeritINT = 0;

                //存放懲戒詳細數量
                Dictionary <string, int> ABC = new Dictionary <string, int>();
                ABC.Add("大過", 0);
                ABC.Add("小過", 0);
                ABC.Add("警告", 0);

                //加總總懲戒及各項懲戒
                foreach (SemesterInfo info in counter.Keys)
                {
                    merit   += counter[info].Merit;
                    demerit += counter[info].Demerit;
                }

                if (_balance)
                {//功過相抵
                    demerit -= merit;
                    if (demerit > 0)
                    {
                        Dictionary <string, int> dic = _demeritConverter.Change(demerit);
                        ABC["大過"] += dic["大過"];
                        ABC["小過"] += dic["小過"];
                        ABC["警告"] += dic["警告"];
                    }
                    demeritINT = _demeritConverter.BtoA(_demeritConverter.CtoB(demerit));
                }
                else
                {
                    if (demerit > 0)
                    {
                        Dictionary <string, int> dic = _demeritConverter.Change(demerit);
                        ABC["大過"] += dic["大過"];
                        ABC["小過"] += dic["小過"];
                        ABC["警告"] += dic["警告"];
                    }
                    demeritINT = _demeritConverter.BtoA(_demeritConverter.CtoB(demerit));
                }

                if (demeritINT >= _amount)
                {
                    ResultDetail rd = new ResultDetail(student.ID, "0", "0");
                    rd.AddMessage("懲戒表現不符合畢業規範");
                    string str = "";
                    //取得懲戒詳細數量
                    foreach (KeyValuePair <string, int> kvp in ABC)
                    {
                        str += kvp.Key + kvp.Value;
                    }
                    //2017/12/19,羿均根據高雄小組會議[09-11][02] 所做之修改
                    rd.AddDetail("懲戒表現不符合畢業規範(說明:所有學期之獎懲累計,經功過相抵換算後相當於" + str + ",已滿三大過)");
                    resultList.Add(rd);
                }

                if (resultList.Count > 0)
                {
                    _result.Add(student.ID, resultList);
                    passList[student.ID] = false;
                }
            }

            return(passList);
        }
Exemple #5
0
        public Dictionary <string, bool> Evaluate(IEnumerable <StudentRecord> list)
        {
            _result.Clear();

            Dictionary <string, bool> passList = new Dictionary <string, bool>();

            //Dictionary<string, SemesterHistoryUtility> shList = new Dictionary<string, SemesterHistoryUtility>();
            //foreach (Data.JHSemesterHistoryRecord shRecord in Data.JHSemesterHistory.SelectByStudentIDs(list.AsKeyList().ToArray()))
            //{
            //    if (!shList.ContainsKey(shRecord.RefStudentID))
            //        shList.Add(shRecord.RefStudentID, new SemesterHistoryUtility(shRecord));
            //}

            //list.SyncSemesterScoreCache();
            Dictionary <string, List <Data.JHSemesterScoreRecord> > studentSemesterScoreCache = new Dictionary <string, List <JHSchool.Data.JHSemesterScoreRecord> >();

            foreach (Data.JHSemesterScoreRecord record in Data.JHSemesterScore.SelectByStudentIDs(list.AsKeyList()))
            {
                if (!studentSemesterScoreCache.ContainsKey(record.RefStudentID))
                {
                    studentSemesterScoreCache.Add(record.RefStudentID, new List <JHSchool.Data.JHSemesterScoreRecord>());
                }
                studentSemesterScoreCache[record.RefStudentID].Add(record);
            }

            foreach (StudentRecord each in list)
            {
                List <ResultDetail>     resultList = new List <ResultDetail>();
                JHSemesterHistoryRecord shRec      = new JHSemesterHistoryRecord();
                if (UIConfig._StudentSHistoryRecDict.ContainsKey(each.ID))
                {
                    shRec = UIConfig._StudentSHistoryRecDict[each.ID];
                }
                // 有成績學年度學期
                List <string> hasSemsScoreSchoolYearSemester = new List <string>();
                if (studentSemesterScoreCache.ContainsKey(each.ID))
                {
                    foreach (Data.JHSemesterScoreRecord record in studentSemesterScoreCache[each.ID])
                    {
                        hasSemsScoreSchoolYearSemester.Add(record.SchoolYear.ToString() + record.Semester.ToString());
                        // 只檢查三下,以學期歷程為主
                        int gradeYear = 0;
                        foreach (K12.Data.SemesterHistoryItem shi in shRec.SemesterHistoryItems)
                        {
                            if (shi.SchoolYear == record.SchoolYear && shi.Semester == record.Semester)
                            {
                                gradeYear = shi.GradeYear;
                            }
                        }

                        if (!((gradeYear == 3 || gradeYear == 9) && record.Semester == 2))
                        {
                            continue;
                        }

                        // 領域有及格的數量
                        int count = 0;

                        //2017/5/9 穎驊修正 ,因應 高雄 [08-05][03] 畢業資格判斷成績及格標準調整 項目,
                        // 領域 分數超過60分 ,以 四捨五入取到小數第二位 , 低於60分 採用 無條件進位至整數 (EX : 59.01 =60)
                        // (只有高雄版有如此機制,新竹版照舊不管分數高低都是四捨五入)
                        if (JHEvaluation.ScoreCalculation.Program.Mode == JHEvaluation.ScoreCalculation.ModuleMode.HsinChu)
                        {
                            foreach (K12.Data.DomainScore domain in record.Domains.Values)
                            {
                                if (domain.Score.HasValue)
                                {
                                    if (domain.Score.Value >= _score)
                                    {
                                        count++;
                                    }
                                }
                            }
                        }
                        if (JHEvaluation.ScoreCalculation.Program.Mode == JHEvaluation.ScoreCalculation.ModuleMode.KaoHsiung)
                        {
                            foreach (K12.Data.DomainScore domain in record.Domains.Values)
                            {
                                if (domain.Score.HasValue)
                                {
                                    if (domain.Score.Value >= 60 && domain.Score.Value >= _score)
                                    {
                                        count++;
                                    }
                                    if (domain.Score.Value < 60 && Math.Ceiling(domain.Score.Value) >= _score)
                                    {
                                        count++;
                                    }
                                }
                            }
                        }



                        if (count < _domain_count)
                        {
                            ResultDetail rd = new ResultDetail(each.ID, "" + gradeYear, "" + record.Semester);
                            rd.AddMessage("學期領域成績不符合畢業規範");
                            rd.AddDetail("學期領域成績不符合畢業規範");
                            resultList.Add(rd);
                        }
                    }
                }

                // 檢查有學期歷程沒有成績
                foreach (K12.Data.SemesterHistoryItem shi in shRec.SemesterHistoryItems)
                {
                    if (shi.GradeYear == 3 || shi.GradeYear == 9)
                    {
                        if (!hasSemsScoreSchoolYearSemester.Contains(shi.SchoolYear.ToString() + shi.Semester.ToString()))
                        {
                            ResultDetail rd = new ResultDetail(each.ID, shi.GradeYear.ToString(), shi.Semester.ToString());
                            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 <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>();
                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 + " 學期歷程重覆");
                        }
                    }
                }

                if (!morals.ContainsKey(student.ID))
                {
                    continue;
                }
                string keyStr = "所有學期";
                Dictionary <string, DisTestABC> counter = new Dictionary <string, DisTestABC>();
                foreach (AutoSummaryRecord record in morals[student.ID])
                {
                    if (!counter.ContainsKey(keyStr))
                    {
                        counter.Add(keyStr, new DisTestABC());
                    }

                    if (_balance)
                    {
                        decimal total_merit   = _meritConverter.BtoC(_meritConverter.AtoB(record.MeritA) + record.MeritB) + record.MeritC;
                        decimal total_demerit = _demeritConverter.BtoC(_demeritConverter.AtoB(record.DemeritA) + record.DemeritB) + record.DemeritC;
                        total_demerit -= total_merit;
                        if (total_demerit > 0)
                        {
                            counter[keyStr].ABC = _demeritConverter.Change(total_demerit);
                        }
                        total_demerit = _demeritConverter.BtoA(_demeritConverter.CtoB(total_demerit));
                        counter[keyStr].demeritINT = total_demerit;
                    }
                    else
                    {
                        decimal total_demerit     = record.DemeritA + _demeritConverter.BtoA(record.DemeritB) + _demeritConverter.BtoA(_demeritConverter.CtoB(record.DemeritC));
                        decimal total_demerit_ABC = _demeritConverter.BtoC(_demeritConverter.AtoB(record.DemeritA) + record.DemeritB) + record.DemeritC;
                        if (total_demerit_ABC > 0)
                        {
                            counter[keyStr].ABC = _demeritConverter.Change(total_demerit_ABC);
                        }
                        counter[keyStr].demeritINT = total_demerit;
                    }
                }

                List <ResultDetail> resultList = new List <ResultDetail>();
                if (counter[keyStr].demeritINT >= _amount)
                {
                    ResultDetail rd = new ResultDetail(student.ID, "0", "0");
                    rd.AddMessage("懲戒表現不符合畢業規範");
                    rd.AddDetail("懲戒表現不符合畢業規範(" + counter[keyStr].ABC + ")");
                    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>();

                decimal count = 0;
                foreach (SemesterInfo info in counter.Keys)
                {
                    count += counter[info];
                }

                if (count >= _amount)
                {
                    ResultDetail rd = new ResultDetail(student.ID, "0", "0");
                    rd.AddMessage("缺課節數超次");
                    rd.AddDetail("缺課節數超次(累計" + count + "節)");
                    resultList.Add(rd);
                }

                //若ResultDetail的列表項目大於0
                if (resultList.Count > 0)
                {
                    //將ResultDetail加入到回傳結果中
                    _result.Add(student.ID, resultList);
                    passList[student.ID] = false;
                }
            }

            return(passList);
        }
Exemple #8
0
        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>();
                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 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))
                        {
                            _AvoidDic[acRecord.Name] += acRecord.Count;
                        }

                        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];

                        // 累積缺曠明細
                        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);
        }
Exemple #9
0
        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 (gyMapping.ContainsKey(info) &&
                        !((gyMapping[info] == 3 || gyMapping[info] == 9) && info.Semester == 2))
                    {
                        continue;
                    }

                    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;

                    if (gyMapping.ContainsKey(info) &&
                        !((gyMapping[info] == 3 || gyMapping[info] == 9) && info.Semester == 2))
                    {
                        continue;
                    }

                    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);
        }
        public Dictionary <string, bool> Evaluate(IEnumerable <StudentRecord> list)
        {
            _result.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)
            {
                passList.Add(student.ID, true);
                decimal schoolDay = 0;
                // 取得學生上課日期
                foreach (K12.Data.SemesterHistoryItem item in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems)
                {
                    if (item.SchoolDayCount.HasValue)
                    {
                        decimal num = (decimal)item.SchoolDayCount.Value;
                        num       *= _dayPeriod;
                        num        = num * _amount / 100;
                        schoolDay += num;
                    }
                }

                if (!morals.ContainsKey(student.ID))
                {
                    continue;
                }
                decimal counter = 0;
                foreach (AutoSummaryRecord record in morals[student.ID])
                {
                    foreach (AbsenceCountRecord acRecord in record.AbsenceCounts)
                    {
                        if (!_types.ContainsKey(acRecord.PeriodType + ":" + acRecord.Name))
                        {
                            continue;
                        }

                        counter += acRecord.Count * _types[acRecord.PeriodType + ":" + acRecord.Name];
                    }
                }

                List <ResultDetail> resultList = new List <ResultDetail>();

                if (counter >= schoolDay)
                {
                    ResultDetail rd = new ResultDetail(student.ID, "0", "0");
                    rd.AddMessage("上課天數不足");
                    rd.AddDetail("上課天數不足(累計" + counter + "節)");
                    resultList.Add(rd);
                }
                if (resultList.Count > 0)
                {
                    _result.Add(student.ID, resultList);
                    passList[student.ID] = false;
                }
            }

            return(passList);
        }
        Dictionary <string, bool> IEvaluative.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, 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);
            }

            //// 取得學生目前班級年級
            //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, DisTestABC> counter = new Dictionary <SemesterInfo, DisTestABC>();
                foreach (AutoSummaryRecord record in morals[student.ID])
                {
                    SemesterInfo info = new SemesterInfo();
                    info.SchoolYear = record.SchoolYear;
                    info.Semester   = record.Semester;
                    if (!counter.ContainsKey(info))
                    {
                        counter.Add(info, new DisTestABC());
                    }

                    //decimal meritA = 0, meritB = 0, meritC = 0;
                    //decimal demeritA = 0, demeritB = 0, demeritC = 0;

                    //foreach (XmlElement itemElement in record.Summary.SelectNodes("DisciplineStatistics/Merit"))
                    //{
                    //    decimal merit;
                    //    if (decimal.TryParse(itemElement.GetAttribute("A"), out merit))
                    //        meritA = merit;
                    //    if (decimal.TryParse(itemElement.GetAttribute("B"), out merit))
                    //        meritB = merit;
                    //    if (decimal.TryParse(itemElement.GetAttribute("C"), out merit))
                    //        meritC = merit;
                    //}

                    //foreach (XmlElement itemElement in record.Summary.SelectNodes("DisciplineStatistics/Demerit"))
                    //{
                    //    decimal demerit;
                    //    if (decimal.TryParse(itemElement.GetAttribute("A"), out demerit))
                    //        demeritA = demerit;
                    //    if (decimal.TryParse(itemElement.GetAttribute("B"), out demerit))
                    //        demeritB = demerit;
                    //    if (decimal.TryParse(itemElement.GetAttribute("C"), out demerit))
                    //        demeritC = demerit;
                    //}

                    if (_balance)
                    {
                        decimal total_merit   = _meritConverter.BtoC(_meritConverter.AtoB(record.MeritA) + record.MeritB) + record.MeritC;
                        decimal total_demerit = _demeritConverter.BtoC(_demeritConverter.AtoB(record.DemeritA) + record.DemeritB) + record.DemeritC;
                        total_demerit -= total_merit;
                        if (total_demerit > 0)
                        {
                            counter[info].ABC = _demeritConverter.Change(total_demerit);
                        }
                        total_demerit            = _demeritConverter.BtoA(_demeritConverter.CtoB(total_demerit));
                        counter[info].demeritINT = total_demerit;
                    }
                    else
                    {
                        decimal total_demerit     = record.DemeritA + _demeritConverter.BtoA(record.DemeritB) + _demeritConverter.BtoA(_demeritConverter.CtoB(record.DemeritC));
                        decimal total_demerit_ABC = _demeritConverter.BtoC(_demeritConverter.AtoB(record.DemeritA) + record.DemeritB) + record.DemeritC;
                        if (total_demerit_ABC > 0)
                        {
                            counter[info].ABC = _demeritConverter.Change(total_demerit_ABC);
                        }
                        counter[info].demeritINT = total_demerit;
                    }
                }

                List <ResultDetail> resultList = new List <ResultDetail>();
                foreach (SemesterInfo info in counter.Keys)
                {
                    if (gyMapping.ContainsKey(info) && counter[info].demeritINT >= _amount)
                    {
                        ResultDetail rd = new ResultDetail(student.ID, "" + gyMapping[info], "" + info.Semester);
                        rd.AddMessage("懲戒表現不符合畢業規範");
                        rd.AddDetail("懲戒表現不符合畢業規範(" + counter[info].ABC + ")");
                        resultList.Add(rd);
                    }
                }

                if (resultList.Count > 0)
                {
                    _result.Add(student.ID, resultList);
                    passList[student.ID] = false;
                }
            }

            return(passList);
        }