Ejemplo n.º 1
0
        internal void Add(KH.JHSCETakeRecord sce)
        {
            if (!_courseDict.ContainsKey(sce.RefCourseID))
            {
                return;
            }
            JHCourseRecord course = _courseDict[sce.RefCourseID];

            if (!Domains.ContainsKey(course.Domain))
            {
                Domains.Add(course.Domain, new DomainRow(course.Domain));
            }

            DomainRow row = Domains[course.Domain];

            if (!row.Subjects.ContainsKey(course.Subject))
            {
                row.AddSubject(course.Subject);
            }

            SubjectRow subjectRow = row.Subjects[course.Subject];

            subjectRow.SetPeriodCredit(course.Period, course.Credit);
            subjectRow.Score   = sce.Score;
            subjectRow.Effort  = sce.Effort;
            subjectRow.Text    = sce.Text;
            subjectRow.Display = true;
        }
Ejemplo n.º 2
0
        internal void SetSubjects(List <string> list)
        {
            List <JHCourseRecord> courseList = new List <JHCourseRecord>();

            foreach (string courseID in list)
            {
                if (!_courseDict.ContainsKey(courseID))
                {
                    continue;
                }
                courseList.Add(_courseDict[courseID]);
            }

            courseList.Sort(delegate(JHCourseRecord x, JHCourseRecord y)
            {
                return(JHSchool.Evaluation.Subject.CompareSubjectOrdinal(x.Subject, y.Subject));
            });


            //courseList = from course in courseList orderby course.Subject select course;

            foreach (JHCourseRecord course in courseList)
            {
                //if (!_courseDict.ContainsKey(courseID)) continue;
                //JHCourseRecord course = _courseDict[courseID];

                string domain  = course.Domain;
                string subject = course.Subject;

                if (!Domains.ContainsKey(domain))
                {
                    Domains.Add(domain, new DomainRow(domain));
                }

                DomainRow domainRow = Domains[domain];
                if (_config.DomainSubjectSetup == "Subject")
                {
                    domainRow.Display = false;
                }

                if (!domainRow.Subjects.ContainsKey(subject))
                {
                    domainRow.AddSubject(subject);
                }
                domainRow.Subjects[subject].SetPeriodCredit(course.Period, course.Credit);
                domainRow.Subjects[subject].Display = true;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 判斷是否要顯示領域
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        private bool CheckDisplayDomain(DomainRow dr)
        {
            bool retVal = false;

            foreach (var sr in dr.Subjects)
            {
                if (_SubjCourseDict.ContainsKey(sr.Value.SubjectName))
                {
                    foreach (var subjectName in dr.Subjects.Keys)
                    {
                        if (_SubjCourseDict.ContainsKey(subjectName))
                        {
                            if (_config.HasExam(_SubjCourseDict[subjectName]))
                            {
                                retVal = true;
                            }
                        }
                    }
                }
            }
            return(retVal);
        }
Ejemplo n.º 4
0
        internal void AddAssignment(JHSCAttendRecord assignment)
        {
            if (!_courseDict.ContainsKey(assignment.RefCourseID))
            {
                return;
            }
            JHCourseRecord course = _courseDict[assignment.RefCourseID];

            if (!Domains.ContainsKey(course.Domain))
            {
                return;
            }

            DomainRow row = Domains[course.Domain];

            if (!row.Subjects.ContainsKey(course.Subject))
            {
                return;
            }

            SubjectRow subjectRow = row.Subjects[course.Subject];

            subjectRow.AssignmentScore = assignment.OrdinarilyScore;
        }
Ejemplo n.º 5
0
        // 這段在處理只有列印領域
        private void WriteDomainRowOnly(Cell indexCell, DomainRow domain)
        {
            // 判斷領域名稱是否需要顯示
            bool DisplayDomain1 = CheckDisplayDomain(domain);

            if (DisplayDomain1)
            {
                // 當領域是空白另外處理
                if (string.IsNullOrEmpty(domain.DomainName))
                {
                    int  co          = 0;
                    Cell subjectCell = WordHelper.GetMoveRightCell(indexCell, 1);
                    foreach (var subjectName in domain.Subjects.Keys)
                    {
                        // 判斷是否需要顯示科目
                        bool DisplaySubject = true;

                        if (_SubjCourseDict.ContainsKey(subjectName))
                        {
                            if (_config.HasExam(_SubjCourseDict[subjectName]) == false)
                            {
                                DisplaySubject = false;
                            }
                        }

                        if (DisplaySubject == false)
                        {
                            continue;
                        }


                        SubjectRow row = domain.Subjects[subjectName];


                        if (row.Display)
                        {
                            Cell temp1 = subjectCell;
                            Write(temp1, row.SubjectName);
                            temp1 = temp1.NextSibling as Cell;
                            Write(temp1, GetPCDisplay(row.PeriodCredit));
                            if (PrintScore)
                            {
                                temp1 = temp1.NextSibling as Cell;
                                // 依照成績計算規則設定
                                if (row.Score.HasValue)
                                {
                                    Write(temp1, "" + _calculator.ParseSubjectScore(row.Score.Value));
                                }
                                else
                                {
                                    Write(temp1, "");
                                }
                            }

                            if (PrintEffort)
                            {
                                temp1 = temp1.NextSibling as Cell;
                                string effortText1 = string.Empty;
                                if (row.Effort.HasValue)
                                {
                                    effortText1 = _effortMapper.GetTextByCode(row.Effort.Value);
                                }
                                Write(temp1, effortText1);
                            }
                            if (PrintAssignment)
                            {
                                temp1 = temp1.NextSibling as Cell;
                                // 依照成績計算規則設定
                                if (row.AssignmentScore.HasValue)
                                {
                                    Write(temp1, "" + _calculator.ParseSubjectScore(row.AssignmentScore.Value));
                                }
                                else
                                {
                                    Write(temp1, "");
                                }
                            }

                            if (PrintText)
                            {
                                temp1 = temp1.NextSibling as Cell;
                                Write(temp1, "" + row.Text);
                            }
                            co++;

                            // 算領域加權平均
                            if (row.Score.HasValue)
                            {
                                DomainSumScore  += row.Score.Value * row.Credit;
                                DomainSumCredit += row.Credit;
                            }


                            subjectCell = WordHelper.GetMoveDownCell(subjectCell, 1);
                            if (subjectCell == null)
                            {
                                break;
                            }
                        }
                    }
                    WordHelper.MergeVerticalCell(indexCell, co);
                    Write(indexCell, "彈性課程");
                }
                else
                {
                    WordHelper.MergeHorizontalCell(indexCell, 2);
                    Write(indexCell, domain.DomainName);

                    Cell temp = indexCell.NextSibling as Cell;
                    temp = temp.NextSibling as Cell;
                    Write(temp, GetPCDisplay(domain.PeriodCredit));

                    if (PrintScore)
                    {
                        temp = temp.NextSibling as Cell;
                        Write(temp, (domain.Score.HasValue ? "" + _calculator.ParseDomainScore(domain.Score.Value) : ""));
                    }

                    if (PrintEffort)
                    {
                        temp = temp.NextSibling as Cell;
                        string effortText = string.Empty;
                        if (domain.Score.HasValue)
                        {
                            effortText = _effortMapper.GetTextByScore(domain.Score.Value);
                        }
                        Write(temp, effortText);
                    }

                    if (PrintAssignment)
                    {
                        temp = temp.NextSibling as Cell;
                        Write(temp, (domain.AssignmentScore.HasValue ? "" + _calculator.ParseDomainScore(domain.AssignmentScore.Value) : ""));
                    }
                    if (PrintText)
                    {
                        temp = temp.NextSibling as Cell;
                        Write(temp, "" + domain.Text);
                    }

                    // 算領域加權平均
                    if (domain.Score.HasValue)
                    {
                        decimal crd;
                        if (decimal.TryParse(GetPCDisplay(domain.PeriodCredit), out crd))
                        {
                            DomainSumScore  += (domain.Score.Value * crd);
                            DomainSumCredit += crd;
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private int WriteDomainRow(Cell indexCell, DomainRow domain)
        {
            // 判斷領域名稱是否需要顯示
            bool DisplayDomain = CheckDisplayDomain(domain);

            if (DisplayDomain)
            {
                Write(indexCell, string.IsNullOrEmpty(domain.DomainName) ? "彈性課程" : domain.DomainName);
            }

            Cell subjectCell = WordHelper.GetMoveRightCell(indexCell, 1);
            int  count       = 0;

            foreach (var subjectName in domain.Subjects.Keys)
            {
                // 判斷是否需要顯示科目
                bool DisplaySubject = true;

                if (_SubjCourseDict.ContainsKey(subjectName))
                {
                    if (_config.HasExam(_SubjCourseDict[subjectName]) == false)
                    {
                        DisplaySubject = false;
                    }
                }

                if (DisplaySubject == false)
                {
                    continue;
                }

                SubjectRow row = domain.Subjects[subjectName];

                if (row.Display)
                {
                    Cell temp = subjectCell;
                    Write(temp, row.SubjectName);
                    temp = temp.NextSibling as Cell;
                    Write(temp, GetPCDisplay(row.PeriodCredit));

                    if (PrintScore)
                    {
                        temp = temp.NextSibling as Cell;
                        // 依照成績計算規則
                        if (row.Score.HasValue)
                        {
                            Write(temp, "" + _calculator.ParseSubjectScore(row.Score.Value));
                        }
                        else
                        {
                            Write(temp, "");
                        }
                    }
                    if (PrintEffort)
                    {
                        temp = temp.NextSibling as Cell;
                        string effortText = string.Empty;
                        if (row.Effort.HasValue)
                        {
                            effortText = _effortMapper.GetTextByCode(row.Effort.Value);
                        }
                        Write(temp, effortText);
                    }

                    if (PrintAssignment)
                    {
                        temp = temp.NextSibling as Cell;
                        if (row.AssignmentScore.HasValue)
                        {
                            Write(temp, "" + _calculator.ParseSubjectScore(row.AssignmentScore.Value));
                        }
                        else
                        {
                            Write(temp, "");
                        }
                    }

                    if (PrintText)
                    {
                        temp = temp.NextSibling as Cell;
                        Write(temp, "" + row.Text);
                    }

                    subjectCell = WordHelper.GetMoveDownCell(subjectCell, 1);
                    count++;

                    if (row.Score.HasValue)
                    {
                        SubjSumScore  += (row.Score.Value * row.Credit);
                        SubjSumCredit += row.Credit;
                    }

                    if (subjectCell == null)
                    {
                        break;
                    }
                }
            }
            return(count);
        }
Ejemplo n.º 7
0
        public void FillScore()
        {
            //RemoveNoScoreRows();

            _builder.MoveToMergeField("成績");
            _font = _builder.Font;
            Cell indexCell = _builder.CurrentParagraph.ParentNode as Cell;

            _SubjCourseDict.Clear();
            // 建立對照
            foreach (JHCourseRecord cr in _courseDict.Values)
            {
                if (!_SubjCourseDict.ContainsKey(cr.Subject))
                {
                    _SubjCourseDict.Add(cr.Subject, cr);
                }
            }
            //_SubjCourseDict = _courseDict.Values.Distinct().ToDictionary(x=>x.Subject);

            List <string> HasExamDomain = new List <string>();


            try
            {
                //排序
                List <string> domains = new List <string>(_manager.Domains.Keys);
                domains.Sort(JHSchool.Evaluation.Subject.CompareDomainOrdinal);

                foreach (var domainName in domains)
                {
                    DomainRow domain = _manager.Domains[domainName];

                    bool display = false;


                    if (_config.PrintDomains.ContainsKey(domain.DomainName))
                    {
                        //// 判斷是否有考試
                        //display = _config.PrintDomains[domain.DomainName];
                        display = CheckDisplayDomain(domain);
                    }
                    else
                    {
                        display = domain.Display;
                    }

                    if (_config.DomainSubjectSetup == "Domain")
                    {
                        if (display)
                        {
                            Cell temp = indexCell;
                            indexCell = WordHelper.GetMoveDownCell(indexCell, 1);
                            WriteDomainRowOnly(temp, domain);
                            //WordHelper.MergeHorizontalCell(temp, 2);
                            if (indexCell == null)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (domain.Subjects.Count > 0)
                        {
                            int  count = WriteDomainRow(indexCell, domain);
                            Cell temp  = indexCell;
                            indexCell = WordHelper.GetMoveDownCell(indexCell, count);
                            WordHelper.MergeVerticalCell(temp, count);
                            if (indexCell == null)
                            {
                                break;
                            }
                        }
                    }
                }
                // 算科目加權平均
                if (SubjSumCredit > 0)
                {
                    SubjAvgScore = Math.Round(SubjSumScore / SubjSumCredit, 2, MidpointRounding.AwayFromZero);
                }

                // 算領域加權平均
                if (DomainSumCredit > 0)
                {
                    DomainAvgScore = Math.Round(DomainSumScore / DomainSumCredit, 2, MidpointRounding.AwayFromZero);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }