示例#1
0
        public MainForm(List <string> classes)
        {
            InitializeComponent();

            this.MinimumSize = this.Size;
            this.MaximumSize = this.Size;

            cbExam.DisplayMember = "Name";
            cbScore.Items.Add("定期");
            cbScore.Items.Add("平時");
            cbScore.Items.Add("定期加平時平均");
            cbScore.SelectedIndex = 0;

            cbExam.Items.Add("");
            foreach (JHExamRecord exam in JHExam.SelectAll())
            {
                cbExam.Items.Add(exam);
            }
            cbExam.SelectedIndex = 0;

            cbExam.SelectedIndexChanged += new EventHandler(cbExam_SelectedIndexChanged);

            LoadingSubject.Visible = false;
            LoadingDomain.Visible  = false;

            //準備相關學生、班級資料。
            ReportStudent.SetClassMapping(JHClass.SelectAll());
            SelectedClasses = JHClass.SelectByIDs(classes); //要列印成績單的班級清單。
            AllStudents     = JHStudent.SelectAll().ToReportStudent();
        }
示例#2
0
        public void CalculateScore(ReportStudent student)
        {
            ItemWeightCollection subjectWeight = new ItemWeightCollection();

            foreach (string each in Subjects)
            {
                if (student.Scores[SubjectToken].Contains(each))
                {
                    subjectWeight.Add(each, student.Scores[SubjectToken].Weights[each]);
                }
            }

            ItemWeightCollection domainWeight = new ItemWeightCollection();

            foreach (string each in Domains)
            {
                if (student.Scores[DomainToken].Contains(each))
                {
                    domainWeight.Add(each, student.Scores[DomainToken].Weights[each]);
                }
            }

            if (subjectWeight.Count <= 0 && domainWeight.Count < 0)
            {
                return;
            }

            student.Scores[TargetToken].Clear();
            student.Scores[TargetToken].Add("加權平均", 加權平均(student, subjectWeight, domainWeight), 0);
            student.Scores[TargetToken].Add("加權總分", 加權總分(student, subjectWeight, domainWeight), 0);
            student.Scores[TargetToken].Add("合計總分", 合計總分(student, subjectWeight, domainWeight), 0);
            student.Scores[TargetToken].Add("算術平均", 算術平均(student, subjectWeight, domainWeight), 0);
        }
示例#3
0
        private decimal 加權總分(ReportStudent student, ItemWeightCollection subjectWeight, ItemWeightCollection domainWeight)
        {
            decimal sum = 0;

            foreach (string scoreItem in subjectWeight.Keys)
            {
                sum += (student.Scores[SubjectToken][scoreItem] * subjectWeight[scoreItem]);
            }

            foreach (string scoreItem in domainWeight.Keys)
            {
                sum += (student.Scores[DomainToken][scoreItem] * domainWeight[scoreItem]);
            }

            return(sum);
        }
示例#4
0
        private decimal 算術平均(ReportStudent student, ItemWeightCollection subjectWeight, ItemWeightCollection domainWeight)
        {
            decimal sum = 0, weight = subjectWeight.Count + domainWeight.Count;

            foreach (string scoreItem in subjectWeight.Keys)
            {
                sum += student.Scores[SubjectToken][scoreItem];
            }

            foreach (string scoreItem in domainWeight.Keys)
            {
                sum += student.Scores[DomainToken][scoreItem];
            }

            if (weight == 0)
            {
                return(0);
            }
            else
            {
                return(Round(sum / weight));
            }
        }
示例#5
0
        private void MasterWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //1.Goup By 可選擇的科目清單。
            //2.寫入成績資料到 ReportStudent 上。

            // TODO: 改這裡
            //List<JHSemesterScoreRecord> semsScores = JHSemesterScore.SelectBySchoolYearAndSemester(AllStudents.ToKeys(), Semester.SelectedSchoolYear, Semester.SelectedSemester);
            List <InternalExamScoreRecord> examScores = InternalExamScore.Select(AllStudents.ToKeys(), Options);

            //GroupBySubjects(semsScores);
            GroupBySubjects(examScores);

            //先把學生身上的成績、排名相關資料清掉。
            foreach (ReportStudent each in AllStudents)
            {
                each.Clear();
                each.Scores.Add(Utilities.SubjectToken, new ScoreCollection()); //科目成績。
                each.Scores.Add(Utilities.DomainToken, new ScoreCollection());  //領域成績。
                each.Scores.Add(Utilities.SummaryToken, new ScoreCollection()); //運算後的成績。
            }

            //將成績填到學生身上。
            Dictionary <string, ReportStudent> dicAllStudent = AllStudents.ToDictionary();

            // TODO: 這裡
            //foreach (JHSemesterScoreRecord eachScore in semsScores)
            foreach (InternalExamScoreRecord eachScore in examScores)
            {
                //如果找不到該學生,跳到下一筆。
                if (!dicAllStudent.ContainsKey(eachScore.RefStudentID))
                {
                    continue;
                }

                ReportStudent student = dicAllStudent[eachScore.RefStudentID];

                //科目成績。
                foreach (SubjectScore each in eachScore.Subjects.Values)
                {
                    if (!each.Score.HasValue)
                    {
                        continue;                       //沒有分數不處理。
                    }
                    if (!each.Credit.HasValue || each.Credit.Value <= 0)
                    {
                        continue;                                                   //沒有節數不處理。
                    }
                    if (!student.Scores[Utilities.SubjectToken].Contains(each.Subject))
                    {
                        student.Scores[Utilities.SubjectToken].Add(each.Subject, each.Score.Value, each.Credit.Value);
                    }
                }

                //領域成績。
                foreach (DomainScore each in eachScore.Domains.Values)
                {
                    if (!each.Score.HasValue)
                    {
                        continue;
                    }
                    if (!each.Credit.HasValue || each.Credit.Value <= 0)
                    {
                        continue;
                    }

                    student.Scores[Utilities.DomainToken].Add(each.Domain, each.Score.Value, each.Credit.Value);
                }

                //運算後成績是在使用者按下列印時才計算。
                //因為需要依據使用者選擇的科目進行計算。
            }
        }