Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 把使用者已選擇的科目資訊(權重)更新到 SelectedSubjects 變數。
        /// </summary>
        /// <returns>true 為資料正確沒有發生任何錯誤。</returns>
        private bool RefreshSelectedDomains()
        {
            bool result = true;

            SelectedItems = new ItemWeightCollection();
            foreach (DataGridViewRow each in dgv.Rows)
            {
                if (each.IsNewRow)
                {
                    continue;
                }
                string value = "" + each.Cells[chCheck.Index].Value;
                bool   b;
                if (bool.TryParse(value, out b) && b == true)
                {
                    string  domain    = "" + each.Cells[chScoreItem.Index].Value;
                    string  strPeriod = "" + each.Cells[chPeriod.Index].Value;
                    decimal period;

                    if (decimal.TryParse(strPeriod, out period) && period > 0)
                    {
                        each.Cells[chPeriod.Index].ErrorText = string.Empty;
                        ScoreItem si = (ScoreItem)each.Tag;

                        SelectedItems.Add(si, period);
                    }
                    else
                    {
                        each.Cells[chPeriod.Index].ErrorText = "計算比例必須是大於 0 的數字。";
                        result = false;
                    }
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 把使用者已選擇的科目資訊(權重)更新到 SelectedSubjects 變數。
        /// </summary>
        /// <returns>true 為資料正確沒有發生任何錯誤。</returns>
        private bool RefreshSelectedItems()
        {
            bool result = true;

            SelectedItems = new ItemWeightCollection();
            foreach (DataGridViewRow each in dgv.Rows)
            {
                if (each.IsNewRow)
                {
                    continue;
                }
                string value = "" + each.Cells[chCheck.Index].Value;
                bool   b;
                if (bool.TryParse(value, out b) && b == true)
                {
                    string    scoreName = "" + each.Cells[chScoreItem.Index].Value;
                    ScoreItem si        = (ScoreItem)each.Tag;
                    SelectedItems.Add(si, 1);
                    result = true;
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        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
            }
        }
Exemplo 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
            }
        }
Exemplo 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());
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 將 Token 依 ScoreType 標準化。
 /// </summary>
 public static string Regulation(this ScoreItem item, string token)
 {
     return(string.Format("{0}:{1}", item.Type.ToString(), token));
 }
Exemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name">科目或領域名稱</param>
 /// <param name="tokens">學期識別資訊。</param>
 public MultiScoreParser(ScoreItem item, List <string> tokens)
 {
     Item   = item;
     Name   = item.Name;
     Tokens = tokens;
 }
Exemplo n.º 9
0
 /// <summary>
 /// 科目或領域名稱。
 /// </summary>
 /// <param name="item"></param>
 public ScoreParser(ScoreItem item, string token)
 {
     Item  = item;
     Name  = Item.Name;
     Token = token;
 }