예제 #1
0
        private void btnRank_Click(object sender, EventArgs e)
        {
            if (SemesterScores.Count <= 0)
            {
                MsgBox.Show("無任何成績資料可排名。");
                return; //沒有任何學期成績不進行排名。
            }
            if (!ValidateDataGrid())
            {
                return;
            }

            RefreshSelectedSubjects();
            if (SelectedSubjects.Count <= 0)
            {
                return;
            }

            RefreshSelectedTokens();
            if (Tokens.Count <= 0)
            {
                MsgBox.Show("請選擇至少一個學期來進行排名。");
                return;
            }

            RatingUtils.DisableControls(this);
            PrepareData();
        }
예제 #2
0
        private void btnRank_Click(object sender, EventArgs e)
        {
            if (SemesterScores.Count <= 0)
            {
                MsgBox.Show("無任何成績資料可排名。");
                return; //沒有任何學期成績不進行排名。
            }
            if (!Sems.ValidateControlContent())
            {
                return;                                   //學期資訊不正確不進行排名。
            }
            if (!ValidateTopRankText())
            {
                return;
            }
            if (!ValidatePercentageText())
            {
                return;
            }
            if (!ValidateDataGrid())
            {
                return;
            }

            RefreshSelectedSubjects();
            if (SelectedSubjects.Count <= 0)
            {
                return;
            }

            RatingUtils.DisableControls(this);
            PrepareData();
        }
예제 #3
0
        private void FormSemestersSubject_Load(object sender, EventArgs e)
        {
            //if (Site.DesignMode) return;

            RatingUtils.DisableControls(this);
            RefreshSubjectOptions();
            RatingUtils.EnableControls(this);
        }
예제 #4
0
        /// <summary>
        /// Pivot 列法,基本上名次一定是全部列出才能適用此種列法。
        /// </summary>
        /// <param name="scopes"></param>
        /// <param name="ratingNames">排名項目名稱清單,例:國文、英文...</param>
        /// <param name="filter"></param>
        public void Output(List <RatingScope <RatingStudent> > scopes, List <string> ratingNames)
        {
            Workbook book = new Workbook();

            book.Worksheets.Clear();
            Worksheet sheet = book.Worksheets[book.Worksheets.Add()];
            int       rowOffset = 0, columnOffset = 0;

            List <RatingStudent> students = new List <RatingStudent>();

            foreach (RatingScope <RatingStudent> each in scopes)
            {
                students.AddRange(each);
            }

            //排序學生資料。
            students.Sort(new Comparison <RatingStudent>(RatingUtils.RatingStudentComparison));

            foreach (string field in new string[] { "班級 ", "座號", "姓名", "學號" })
            {
                sheet.Cells[0, columnOffset++].PutValue(field);
            }

            foreach (string field in ratingNames)
            {
                sheet.Cells[0, columnOffset++].PutValue(field);
                sheet.Cells[0, columnOffset++].PutValue("排名");
            }

            foreach (RatingStudent student in students)
            {
                columnOffset = 0;
                rowOffset++;

                foreach (string field in new string[] { student.ClassName, student.SeatNo, student.Name, student.StudentNumber })
                {
                    sheet.Cells[rowOffset, columnOffset++].PutValue(field);
                }

                foreach (string subject in ratingNames)
                {
                    string score = "", level = "";

                    if (student.Places.Contains(subject))
                    {
                        //去除 00 大絕招。
                        score = ((double)student.Places[subject].Score).ToString();
                        level = student.Places[subject].Level.ToString();
                    }

                    sheet.Cells[rowOffset, columnOffset++].PutValue(score);
                    sheet.Cells[rowOffset, columnOffset++].PutValue(level);
                }
            }

            RatingUtils.Save(book, "分別排名結果.xls");
        }
예제 #5
0
        private void FormSemesterSubject_Load(object sender, EventArgs e)
        {
            //if (Site.DesignMode) return;

            RatingUtils.DisableControls(this);
            RatingUtils.SetSemesterDefaultItems(cboSchoolYear, cboSemester);
            Sems = new SemesterSelector(cboSchoolYear, cboSemester);
            Sems.SemesterChanged += new EventHandler(Sems_SemesterChanged);
            RefreshSubjectOptions();
            RatingUtils.EnableControls(this);
        }
예제 #6
0
        protected override void PrepareDataComplete(Exception error)
        {
            RatingUtils.EnableControls(this);

            if (error != null)
            {
                MsgBox.Show(error.Message);
                return;
            }

            List <MultiScoreParser>             parsers = SelectedSubjects.Keys.ToMultiScoreParsers(Tokens);
            List <RatingScope <RatingStudent> > scopes  = ToScopes();
            List <RatingStudent> sortedStudents;

            //分別排名。
            foreach (RatingScope <RatingStudent> eachScope in scopes)
            {
                foreach (MultiScoreParser eachParser in parsers)
                {
                    eachScope.Rank(eachParser, PlaceOptions.Unsequence);
                }
            }

            FilterParameter param = new FilterParameter();

            if (rbAllRank.Checked)
            {
                param.Mode = FilterMode.None;
            }
            else if (rbTopRank.Checked)
            {
                param.Mode = FilterMode.Place;
                param.Top  = int.Parse(txtTopRank.Text);
            }
            else if (rbPercentage.Checked)
            {
                param.Mode = FilterMode.Percentage;
                param.Top  = int.Parse(txtPercentage.Text);
            }
            else
            {
                throw new ArgumentException("無此種過慮排名的方式。");
            }

            if (rbAllRank.Checked)                                              //如果是列出全部名次的話。
            {
                new OutputSeparatePivot().Output(scopes, parsers.ToNameList()); //分別列出科目、名次(Pivot 列法)。
            }
            else
            {
                new OutputSeparate().Output(scopes, parsers.ToNameList(), param); //分別列出科目、名次(非 Pivot 列法)。
            }
        }
예제 #7
0
        private void FormExamSubject_Load(object sender, EventArgs e)
        {
            //if (Site.DesignMode) return;

            RatingUtils.DisableControls(this);
            RatingUtils.SetSemesterDefaultItems(cboSchoolYear, cboSemester);
            Sems = new SemesterSelector(cboSchoolYear, cboSemester);
            Sems.SemesterChanged += new EventHandler(Sems_SemesterChanged);
            FillDomainOptions();
            FillCurrentSemesterData(); //準備目前學年度學期需要的資料。
            RatingUtils.EnableControls(this);
        }
예제 #8
0
        private void FormExamSubject_Load(object sender, EventArgs e)
        {
            //if (Site.DesignMode) return;

            RatingUtils.DisableControls(this);
            RatingUtils.SetSemesterDefaultItems(cboSchoolYear, cboSemester);
            RatingUtils.SetExamDefaultItems(cboExam);
            Sems = new SemesterSelector(cboSchoolYear, cboSemester);
            Sems.SemesterChanged += new EventHandler(Sems_SemesterChanged);
            IncludeQuery          = new AEIncludeQuery();

            if (cboExam.Items.Count > 0)
            {
                cboExam.SelectedIndex = 0;
            }

            RatingUtils.EnableControls(this);
        }
예제 #9
0
        private void btnRank_Click(object sender, EventArgs e)
        {
            if (Courses.Count <= 0)
            {
                MsgBox.Show("無任何成績資料可排名。");
                return; //沒有課程資料就不排名了。
            }
            if (!Sems.ValidateControlContent())
            {
                return;                                   //學期資訊不正確不進行排名。
            }
            if (!ValidateExamControl())
            {
                return;                           //試別資訊不正確不進行排名。
            }
            if (!ValidateTopRankText())
            {
                return;
            }
            if (!ValidatePercentageText())
            {
                return;
            }
            if (!ValidateDataGrid())
            {
                return;
            }

            RefreshSelectedDomains();
            if (SelectedDomains.Count <= 0)
            {
                return;
            }

            RatingUtils.DisableControls(this);
            PrepareData();
        }
예제 #10
0
 private void FormGraduation_Load(object sender, EventArgs e)
 {
     RatingUtils.DisableControls(this);
     RatingUtils.EnableControls(this);
 }
예제 #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="scopes"></param>
        /// <param name="ratingNames">排名項目名稱,例:國文。</param>
        /// <param name="param"></param>
        internal void Output(List <RatingScope <RatingStudent> > scopes, List <string> ratingNames, FilterParameter filter)
        {
            Workbook book = new Workbook();

            book.Worksheets.Clear();
            Worksheet sheet = book.Worksheets[book.Worksheets.Add()];
            int       rowOffset = 0, columnOffset = 0;

            foreach (string field in new string[] { "班級 ", "座號", "姓名", "學號", "名稱", "分數", "排名" })
            {
                sheet.Cells[0, columnOffset++].PutValue(field);
            }

            foreach (string eachRating in ratingNames)                    //每一種排名。
            {
                foreach (RatingScope <RatingStudent> eachScope in scopes) //每一種範圍。
                {
                    RatingScope <RatingStudent> eachFiltered;
                    if (filter.Mode == FilterMode.None)
                    {
                        eachFiltered = eachScope;
                    }
                    else if (filter.Mode == FilterMode.Place)
                    {
                        eachFiltered = eachScope.GetTopPlaces(eachRating, filter.Top);
                    }
                    else if (filter.Mode == FilterMode.Percentage)
                    {
                        eachFiltered = eachScope.GetTopPercentage(eachRating, filter.Top);
                    }
                    else
                    {
                        throw new ArgumentException("無此種取名次方式。");
                    }

                    eachFiltered.Sort(new PlaceComparer(eachRating));

                    foreach (RatingStudent student in eachFiltered)
                    {
                        columnOffset = 0;
                        rowOffset++;

                        foreach (string field in new string[] { student.ClassName, student.SeatNo, student.Name, student.StudentNumber })
                        {
                            sheet.Cells[rowOffset, columnOffset++].PutValue(field);
                        }

                        string score = "", level = "";

                        //去除 00 大絕招。
                        score = ((double)student.Places[eachRating].Score).ToString();
                        level = student.Places[eachRating].Level.ToString();

                        sheet.Cells[rowOffset, columnOffset++].PutValue(eachRating);
                        sheet.Cells[rowOffset, columnOffset++].PutValue(score);
                        sheet.Cells[rowOffset, columnOffset++].PutValue(level);
                    }
                }
            }

            RatingUtils.Save(book, "分別排名結果.xls");
        }
예제 #12
0
        protected override void PrepareDataComplete(Exception error)
        {
            RatingUtils.EnableControls(this);

            if (error != null)
            {
                MsgBox.Show(error.Message);
                return;
            }

            CalculationScoreParser calcparser          = rbCombine.Checked ? GetCalculationScoreParser() : null;
            List <ScoreParser>     parsers             = SelectedDomains.Keys.ToScoreParsers(ThisToken);
            List <RatingScope <RatingStudent> > scopes = ToScopes();

            //分別排名。
            foreach (RatingScope <RatingStudent> eachScope in scopes)
            {
                foreach (ScoreParser eachParser in parsers)
                {
                    eachScope.Rank(eachParser, PlaceOptions.Unsequence);
                }
            }

            if (calcparser != null)
            {
                //運算排名。
                foreach (RatingScope <RatingStudent> eachScope in scopes)
                {
                    eachScope.Rank(calcparser, PlaceOptions.Unsequence);
                }
            }

            FilterParameter param = new FilterParameter();

            if (rbAllRank.Checked)
            {
                param.Mode = FilterMode.None;
            }
            else if (rbTopRank.Checked)
            {
                param.Mode = FilterMode.Place;
                param.Top  = int.Parse(txtTopRank.Text);
            }
            else if (rbPercentage.Checked)
            {
                param.Mode = FilterMode.Percentage;
                param.Top  = int.Parse(txtPercentage.Text);
            }
            else
            {
                throw new ArgumentException("無此種過慮排名的方式。");
            }

            if (rbSeparate.Checked)                                                 //分別排名。
            {
                if (rbAllRank.Checked)                                              //如果是列出全部名次的話。
                {
                    new OutputSeparatePivot().Output(scopes, parsers.ToNameList()); //分別列出科目、名次(Pivot 列法)。
                }
                else
                {
                    new OutputSeparate().Output(scopes, parsers.ToNameList(), param); //分別列出科目、名次(非 Pivot 列法)。
                }
            }
            else
            {
                new OutputCalculationPivot().Output(scopes, parsers, calcparser.Name, param); //列出運算名次、運算前成績。
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="scopes"></param>
        /// <param name="originParsers"></param>
        /// <param name="rankName">排名項目名稱,例如:加權平均…</param>
        /// <param name="filter"></param>
        internal void Output(List <RatingScope <RatingStudent> > scopes, List <ScoreParser> originParsers, string rankName, FilterParameter filter)
        {
            Workbook book = new Workbook();

            book.Worksheets.Clear();
            Worksheet sheet = book.Worksheets[book.Worksheets.Add()];
            int       rowOffset = 0, columnOffset = 0;

            Dictionary <string, RatingStudent> dicstudents = new Dictionary <string, RatingStudent>();

            foreach (RatingScope <RatingStudent> eachOrigin in scopes)
            {
                RatingScope <RatingStudent> eachFiltered;
                if (filter.Mode == FilterMode.None)
                {
                    eachFiltered = eachOrigin;
                }
                else if (filter.Mode == FilterMode.Place)
                {
                    eachFiltered = eachOrigin.GetTopPlaces(rankName, filter.Top);
                }
                else if (filter.Mode == FilterMode.Percentage)
                {
                    eachFiltered = eachOrigin.GetTopPercentage(rankName, filter.Top);
                }
                else
                {
                    throw new ArgumentException("無此種取名次方式。");
                }

                foreach (RatingStudent eachStud in eachFiltered)
                {
                    if (!dicstudents.ContainsKey(eachStud.Id))
                    {
                        dicstudents.Add(eachStud.Id, eachStud);
                    }
                }
            }
            List <RatingStudent> students = new List <RatingStudent>(dicstudents.Values);

            //排序學生資料。
            students.Sort(new Comparison <RatingStudent>(RatingUtils.RatingStudentComparison));

            foreach (string field in new string[] { "班級 ", "座號", "姓名", "學號" })
            {
                sheet.Cells[0, columnOffset++].PutValue(field);
            }

            //列出原始成績的科目欄位。
            foreach (ScoreParser field in originParsers)
            {
                sheet.Cells[0, columnOffset++].PutValue(field.Name);
            }

            sheet.Cells[0, columnOffset++].PutValue(rankName); //運算排名的名稱。
            sheet.Cells[0, columnOffset++].PutValue("名次");     //運算排名的名次。

            foreach (RatingStudent student in students)
            {
                columnOffset = 0;
                rowOffset++;

                foreach (string field in new string[] { student.ClassName, student.SeatNo, student.Name, student.StudentNumber })
                {
                    sheet.Cells[rowOffset, columnOffset++].PutValue(field);
                }

                //列出原始成績。
                foreach (ScoreParser eachParser in originParsers)
                {
                    decimal?originScore = eachParser.GetScore(student);

                    if (originScore.HasValue)
                    {
                        sheet.Cells[rowOffset, columnOffset++].PutValue(((double)originScore).ToString());
                    }
                    else
                    {
                        columnOffset++;
                    }
                }

                string score = "", level = "";
                if (student.Places.Contains(rankName))
                {
                    //去除 00 大絕招。
                    score = ((double)student.Places[rankName].Score).ToString();
                    level = student.Places[rankName].Level.ToString();
                }

                sheet.Cells[rowOffset, columnOffset++].PutValue(score);
                sheet.Cells[rowOffset, columnOffset++].PutValue(level);
            }

            RatingUtils.Save(book, "運算排名結果.xls");
        }
예제 #14
0
 /// <summary>
 /// 將需要排名的學生指定到表單中。
 /// </summary>
 public void SetRatingStudents(IEnumerable <string> studentIds)
 {
     Students = RatingUtils.ToRatingStudent(studentIds);
     DisplaySelectedStudentCount();
 }