Esempio n. 1
0
        private void ProcessDomain(Dictionary <string, DomainScoreCalculator> domainscores,
                                   JHSCETakeRecord take,
                                   JHCourseRecord course,
                                   RatingStudent student,
                                   ScoreItem subject,
                                   ScoreItem domain)
        {
            if (!course.Credit.HasValue)
            {
                return;                          //如果課程沒有權重就不處理。
            }
            decimal weight = course.Credit.Value;

            if (!SelectedItems.Contains(domain))
            {
                return; //不在處理的領域清單中。
            }
            if (!domainscores.ContainsKey(student.Id))
            {
                domainscores.Add(student.Id, new DomainScoreCalculator());
            }

            if (domainscores[student.Id].Contains(subject.Name))
            {
                throw new ArgumentException(string.Format("學生「{0}」在同一學期修習「{1}」科目一次以上。", student.Name, subject.Name));
            }

            domainscores[student.Id].Add(domain.Name, subject.Name, take.Score.Value, weight);
        }
Esempio n. 2
0
        public static int RatingStudentComparison(RatingStudent x, RatingStudent y)
        {
            string xx = x.GradeYear.PadLeft(3, '0') + ":" + x.ClassOrderString + ":" + x.SeatNo.PadLeft(3, '0');
            string yy = y.GradeYear.PadLeft(3, '0') + ":" + y.ClassOrderString + ":" + y.SeatNo.PadLeft(3, '0');

            return(xx.CompareTo(yy));
        }
Esempio n. 3
0
        private void ProcessSubject(ScoreItem subject, RatingStudent student, JHSCETakeRecord take)
        {
            ScoreCollection subjScores = student.Scores[subject.Regulation(Token)];

            if (!SelectedItems.Contains(subject))
            {
                return; //不在處理的科目清單中。
            }
            if (subjScores.Contains(subject.Name))
            {
                throw new ArgumentException(string.Format("學生「{0}」在同一學期修習「{1}」科目一次以上。", student.Name, subject.Name));
            }

            //take.Score  一定有值,因為在很前面就處理掉了。
            subjScores.Add(subject.Name, take.Score.Value);
        }
        protected override void PrepareDataBackground()
        {
            JHClass.RemoveAll();
            RatingStudent.SetClassMapping(JHClass.SelectAll()); //快取班級對照資訊。
            Dictionary <string, RatingStudent> dicstuds = Students.ToDictionary();

            //將學生的成績清除,並新增一個 Token 用來放成績。
            foreach (RatingStudent each in Students)
            {
                each.Clear();
                each.Scores.Add(ScoreType.Subject.Regulation(Token), new ScoreCollection());
                each.Scores.Add(ScoreType.Domain.Regulation(Token), new ScoreCollection());
                each.Scores.Add(ScoreType.SummaryDomain.Regulation(Token), new ScoreCollection());
            }

            foreach (JHSemesterScoreRecord semsRecord in SemesterScores.Values)
            {
                RatingStudent student;

                if (!dicstuds.TryGetValue(semsRecord.RefStudentID, out student))
                {
                    continue; //找不到該學生。
                }
                #region 科目
                ScoreCollection subjscores = student.Scores[ScoreType.Subject.Regulation(Token)];

                foreach (K12.Data.SubjectScore subjRecord in semsRecord.Subjects.Values)
                {
                    if (!subjRecord.Score.HasValue)
                    {
                        continue;                             //沒有成績就不處理。
                    }
                    ScoreItem subject = new ScoreItem(subjRecord.Subject, ScoreType.Subject);

                    if (!SelectedItems.Contains(subject))
                    {
                        continue; //不在處理的科目清單中。
                    }
                    if (subjscores.Contains(subject.Name))
                    {
                        throw new ArgumentException(string.Format("學生「{0}」在同一學期修習「{1}」科目一次以上。", student.Name, subject.Name));
                    }

                    subjscores.Add(subject.Name, subjRecord.Score.Value);
                }
                #endregion

                #region 領域
                ScoreCollection domainscores = student.Scores[ScoreType.Domain.Regulation(Token)];

                foreach (K12.Data.DomainScore domainRecord in semsRecord.Domains.Values)
                {
                    if (!domainRecord.Score.HasValue)
                    {
                        continue;                               //沒有成績就不處理。
                    }
                    ScoreItem domain = new ScoreItem(domainRecord.Domain.Trim(), ScoreType.Domain);

                    if (!SelectedItems.Contains(domain))
                    {
                        continue; //不在處理的科目清單中。
                    }
                    if (!NameMapping.ContainsKey(domain.Name))
                    {
                        throw new ArgumentException(string.Format("領域名稱「{0}」在此畫面沒有定議。", domain));
                    }

                    if (domainscores.Contains(domain.Name))
                    {
                        throw new ArgumentException(string.Format("學生「{0}」在同一學期有「{1}」領域一次以上。", student.Name, domain));
                    }

                    domainscores.Add(domain.Name, domainRecord.Score.Value);
                }

                if (semsRecord.LearnDomainScore.HasValue)
                {
                    domainscores.Add("學習領域", semsRecord.LearnDomainScore.Value);
                }

                if (semsRecord.CourseLearnScore.HasValue)
                {
                    domainscores.Add("課程學習", semsRecord.CourseLearnScore.Value);
                }

                #endregion
            }
        }
Esempio n. 5
0
        protected override void PrepareDataBackground()
        {
            JHClass.RemoveAll();
            RatingStudent.SetClassMapping(JHClass.SelectAll()); //快取班級對照資訊。
            Dictionary <string, RatingStudent> dicstuds = Students.ToDictionary();

            //學期歷程查詢類別。
            SemesterHistory = new HistoryQuery(JHSemesterHistory.SelectByStudentIDs(Students.ToKeys()));

            //將學生的成績清除。
            foreach (RatingStudent each in Students)
            {
                each.Clear();
            }

            foreach (JHSemesterScoreRecord semsRecord in SemesterScores)
            {
                RatingStudent student;

                if (!dicstuds.TryGetValue(semsRecord.RefStudentID, out student))
                {
                    continue; //找不到該學生。
                }
                ScoreCollection subjScores = null, domainScores = null;

                if (SemesterHistory.Contains(semsRecord.RefStudentID, semsRecord.SchoolYear, semsRecord.Semester))
                {
                    //tokne 意思是特定學期的識別字串,例如「一上」。
                    string token = SemesterHistory.GetToken(semsRecord.RefStudentID, semsRecord.SchoolYear, semsRecord.Semester);

                    //不在使用者選擇的學期中,就不處理。
                    if (!Tokens.Contains(token))
                    {
                        continue;
                    }

                    if (!student.Scores.Contains(ScoreType.Subject.Regulation(token))) //如果學生不包含該學期的成績,就加上該學期。
                    {
                        student.Scores.Add(ScoreType.Subject.Regulation(token), new ScoreCollection());
                    }

                    if (!student.Scores.Contains(ScoreType.Domain.Regulation(token))) //如果學生不包含該學期的成績,就加上該學期。
                    {
                        student.Scores.Add(ScoreType.Domain.Regulation(token), new ScoreCollection());
                    }

                    subjScores   = student.Scores[ScoreType.Subject.Regulation(token)];
                    domainScores = student.Scores[ScoreType.Domain.Regulation(token)];
                }
                else
                {
                    continue; //沒有該學期的學期歷程就不處理。
                }
                #region 科目
                foreach (K12.Data.SubjectScore subjRecord in semsRecord.Subjects.Values)
                {
                    if (!subjRecord.Score.HasValue)
                    {
                        continue;                             //沒有成績就不處理。
                    }
                    ScoreItem subject = new ScoreItem(subjRecord.Subject, ScoreType.Subject);

                    if (!SelectedItems.Contains(subject))
                    {
                        continue; //不在處理的科目清單中。
                    }
                    if (subjScores.Contains(subject.Name))
                    {
                        throw new ArgumentException(string.Format("學生「{0}」在同一學期修習「{1}」科目一次以上。", student.Name, subject.Name));
                    }

                    subjScores.Add(subject.Name, subjRecord.Score.Value);
                }
                #endregion

                #region 領域
                foreach (K12.Data.DomainScore domainRecord in semsRecord.Domains.Values)
                {
                    if (!domainRecord.Score.HasValue)
                    {
                        continue;                               //沒有成績就不處理。
                    }
                    ScoreItem domain = new ScoreItem(domainRecord.Domain, ScoreType.Domain);

                    if (!SelectedItems.Contains(domain))
                    {
                        continue; //不在處理的領域清單中。
                    }
                    if (domainScores.Contains(domain.Name))
                    {
                        throw new ArgumentException(string.Format("學生「{0}」在{1}學年第{2}學期「{3}」領域成績出現一次以上。", student.Name, domainRecord.SchoolYear, domainRecord.Semester, domain.Name));
                    }

                    domainScores.Add(domain.Name, domainRecord.Score.Value);
                }

                if (semsRecord.LearnDomainScore.HasValue)
                {
                    domainScores.Add("學習領域", semsRecord.LearnDomainScore.Value);
                }

                if (semsRecord.CourseLearnScore.HasValue)
                {
                    domainScores.Add("課程學習", semsRecord.CourseLearnScore.Value);
                }

                #endregion
            }
        }
Esempio n. 6
0
        protected override void PrepareDataBackground()
        {
            FunctionSpliter <string, JHSCETakeRecord> selectData = new FunctionSpliter <string, JHSCETakeRecord>(500, 5);

            selectData.Function = delegate(List <string> ps)
            {
                return(JHSCETake.SelectByCourseAndExam(ps, ExamId));
            };
            List <JHSCETakeRecord> scetakes = selectData.Execute(Courses.Values.ToKeys());

            JHClass.RemoveAll();
            RatingStudent.SetClassMapping(JHClass.SelectAll()); //快取班級對照資訊。
            Dictionary <string, RatingStudent> dicstuds = Students.ToDictionary();

            //將學生的成績清除,並新增一個 Token 用來放成績。
            foreach (RatingStudent each in Students)
            {
                each.Clear();
                each.Scores.Add(ScoreType.Domain.Regulation(Token), new ScoreCollection());
                each.Scores.Add(ScoreType.Subject.Regulation(Token), new ScoreCollection());
                each.Scores.Add(ScoreType.SummaryDomain.Regulation(Token), new ScoreCollection());
            }

            //記錄每一位學生的領域成績。
            Dictionary <string, DomainScoreCalculator> domainscores = new Dictionary <string, DomainScoreCalculator>();

            //計算領域成績。
            foreach (JHSCETakeRecord take in scetakes) //特別注意 take.Score 是 Extensions 裡面的 Score 不是實體欄位的 Score。
            {
                if (!take.Score.HasValue)
                {
                    continue;                       //沒有成績就不處理。
                }
                JHSCAttendRecord attend;
                JHCourseRecord   course;
                RatingStudent    student;

                if (!SCAttends.TryGetValue(take.RefSCAttendID, out attend))
                {
                    continue;  //找不到該修課記錄。
                }
                if (!dicstuds.TryGetValue(attend.RefStudentID, out student))
                {
                    continue; //找不到該學生。
                }
                if (!Courses.TryGetValue(take.RefCourseID, out course))
                {
                    continue;  //找不到該課程。
                }
                ScoreItem subject = new ScoreItem(course.Subject.Trim(), ScoreType.Subject);
                ScoreItem domain  = new ScoreItem(course.Domain.Trim(), ScoreType.Domain);

                //--- Subject
                ProcessSubject(subject, student, take);

                //--- Domain
                ProcessDomain(domainscores, take, course, student, subject, domain);
            }

            foreach (KeyValuePair <string, DomainScoreCalculator> eachStudent in domainscores)
            {
                string studentId = eachStudent.Key;                   //學生編號。
                DomainScoreCalculator calculator = eachStudent.Value; //領域成績。

                foreach (DomainScore eachDomain in calculator.Domains)
                {
                    dicstuds[studentId].Scores[ScoreType.Domain.Regulation(Token)].Add(eachDomain.Name, eachDomain.GetScore());
                }
            }
        }