/// <summary>
        /// 取得學生領域成績
        /// </summary>
        /// <param name="StudentIdList"></param>
        /// <returns></returns>
        public static Dictionary <string, ValueObj.DomainsVO> GetDomainScore(List <string> StudentIdList)
        {
            // 學生每個學年度學期的領域分數
            Dictionary <string, ValueObj.DomainsVO>    result            = new Dictionary <string, ValueObj.DomainsVO>();
            List <JHSchool.Data.JHSemesterScoreRecord> SemesterScoreList = JHSchool.Data.JHSemesterScore.SelectByStudentIDs(StudentIdList);

            foreach (JHSchool.Data.JHSemesterScoreRecord rec in SemesterScoreList)
            {
                string studentId = rec.RefStudentID;
                if (!result.ContainsKey(studentId))
                {
                    result.Add(studentId, new ValueObj.DomainsVO());
                }

                foreach (Data.DomainScore domainScore in rec.Domains.Values)
                {
                    ValueObj.SchoolYearSemester SchoolYearSemester = new ValueObj.SchoolYearSemester(domainScore.SchoolYear, domainScore.Semester);
                    ValueObj.DomainsVO          domainsVo          = result[studentId];
                    domainsVo.AddDomain(SchoolYearSemester, studentId, domainScore.Domain, domainScore.Score);
                }
            }

            return(result);
        }   // end of GetDomainScore
Ejemplo n.º 2
0
        /// <summary>
        /// 處理均衡學習
        /// </summary>
        /// <param name="studentObj"></param>
        /// <param name="gradeMap"></param>
        /// <param name="domains"></param>
        private decimal Cal_BalanceLearning(ValueObj.StudentVO studentObj, Dictionary <int, ValueObj.SchoolYearSemester> gradeMap, ValueObj.DomainsVO domains)
        {
            int ItemIndex = Global.index_BalanceLearning;

            // 取得大項目的條件
            ValueObj.ItemConditionVO itemCondition = new ValueObj.ItemConditionVO(ItemIndex);
            // 取得子項目的條件
            ValueObj.DetailItemConditionVO detailCondition = new ValueObj.DetailItemConditionVO(ItemIndex);
            // 取得需要看的學年度學期
            Dictionary <int, ValueObj.SchoolYearSemester> needSchoolYearList = Utility.GetNeedSchoolSemesterIndex(itemCondition.NeedSemester, gradeMap);
            // 大項目名稱
            string itemName = itemCondition.ItemName;
            // 及格分數
            decimal PassScore = 60;
            // 項目的積分
            decimal ItemTotalPoints = 0;

            if (domains != null)
            {
                // loop 每個需要的領域
                for (int intI = 0; intI < Global.DetailItemNameList[ItemIndex].Length; intI++)
                {
                    // 子項目名稱
                    string detailItemName = Global.DetailItemNameList[ItemIndex][intI];
                    // 子項目積分
                    decimal points = detailCondition.DetailItemListDic[detailItemName];

                    decimal totalScore = 0;
                    decimal avgScore   = 0;
                    decimal scoreCount = 0;
                    // loop 領域的每個學期分數
                    foreach (KeyValuePair <int, ValueObj.SchoolYearSemester> pair in needSchoolYearList)
                    {
                        ValueObj.SchoolYearSemester schoolYear = pair.Value;
                        if (schoolYear == null)
                        {
                            // 少了需要的學期
                            if (!_WarningStudentDic.ContainsKey(studentObj))
                            {
                                _WarningStudentDic.Add(studentObj, new ValueObj.LackMsg());
                            }
                            _WarningStudentDic[studentObj].AddHistoryLack(pair.Key);
                            continue;
                        }
                        List <ValueObj.DomainVO> domainList = domains.GetDomainsBySechoolYear(schoolYear, detailItemName);

                        if (domainList.Count == 0)
                        {
                            // 少了需要的領域
                            if (!_WarningStudentDic.ContainsKey(studentObj))
                            {
                                _WarningStudentDic.Add(studentObj, new ValueObj.LackMsg());
                            }
                            _WarningStudentDic[studentObj].AddDomainLack(pair.Key);
                            continue;
                        }

                        foreach (ValueObj.DomainVO domain in domainList)
                        {
                            totalScore += domain.DomainScore;
                            scoreCount++;
                        }
                    }

                    // 取得detail item in student
                    ValueObj.DetailItemVO detailItem = studentObj.DetailItemList[itemName][detailItemName];

                    // 領域的平均
                    // 原本是固定除以需要的學期, 這樣有少一個學期分數的話, 會很難看, 所以改成有幾個分數就除以幾
                    // avgScore = Math.Round((totalScore / needSchoolYearList.Count), 2, MidpointRounding.AwayFromZero);
                    if (scoreCount > 0)
                    {
                        avgScore = Math.Round((totalScore / scoreCount), 2, MidpointRounding.AwayFromZero);
                    }

                    // 回存此項目顯示的內容
                    detailItem.Value = "總分: " + totalScore + ", 學期數: " + scoreCount + ", 平均: " + avgScore.ToString();

                    // 看學生有沒有得到此積分
                    if (avgScore >= PassScore)
                    {
                        ItemTotalPoints += points;
                        // 回存此項目的積分
                        detailItem.Points = points;
                    }
                }
            }
            else
            {
                // 完全沒有領域成績
                if (!_WarningStudentDic.ContainsKey(studentObj))
                {
                    _WarningStudentDic.Add(studentObj, new ValueObj.LackMsg());
                }

                foreach (int rec in needSchoolYearList.Keys)
                {
                    _WarningStudentDic[studentObj].AddDomainLack(rec);
                }
            }

            // 假如超過上限, 就以上限為主
            ItemTotalPoints = (ItemTotalPoints > itemCondition.MaxItemPoints) ? itemCondition.MaxItemPoints : ItemTotalPoints;

            // 此學生在這個項目的積分
            studentObj.ItemList[itemName] = ItemTotalPoints;

            return(ItemTotalPoints);
        }