Ejemplo n.º 1
0
            public HistoryUtil(JHSemesterHistoryRecord historyRecord)
            {
                _sems = new SemesterDataCollection();

                foreach (SemesterHistoryItem item in historyRecord.SemesterHistoryItems)
                {
                    _sems.Add(new SemesterData(item.GradeYear, item.SchoolYear, item.Semester));
                }

                _sems = _sems.GetGradeYearSemester();

                SemesterData last   = SemesterData.Empty;
                bool         delete = false;

                foreach (SemesterData sem in _sems)
                {
                    if (sem.GradeYear == 3 && sem.Semester == 2)
                    {
                        last   = sem;
                        delete = true;
                    }
                }
                if (delete)
                {
                    _sems.Remove(last);
                }
            }
Ejemplo n.º 2
0
        void wizard_ImportPackage(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e)
        {
            //根據學生編號、學年度、學期組成主鍵
            List <string>                        keyList           = new List <string>();
            Dictionary <string, int>             schoolYearMapping = new Dictionary <string, int>();
            Dictionary <string, int>             semesterMapping   = new Dictionary <string, int>();
            Dictionary <string, string>          studentIDMapping  = new Dictionary <string, string>();
            Dictionary <string, List <RowData> > rowsMapping       = new Dictionary <string, List <RowData> >();
            //一個學生只會有一筆學期歷程
            Dictionary <string, JHSemesterHistoryRecord> studentSemesterHistory = new Dictionary <string, JHSemesterHistoryRecord>();

            //掃描每行資料,定出資料的PrimaryKey,並且將PrimaryKey對應到的資料寫成Dictionary
            foreach (RowData Row in e.Items)
            {
                int    schoolYear = int.Parse(Row["學年度"]);
                int    semester   = int.Parse(Row["學期"]);
                string studentID  = Row.ID;
                string key        = schoolYear + "^_^" + semester + "^_^" + studentID;

                if (!keyList.Contains(key))
                {
                    keyList.Add(key);
                    schoolYearMapping.Add(key, schoolYear);
                    semesterMapping.Add(key, semester);
                    studentIDMapping.Add(key, studentID);
                    rowsMapping.Add(key, new List <RowData>());
                }
                rowsMapping[key].Add(Row);
            }

            //一次取得學生學期歷程
            List <JHSemesterHistoryRecord> records = JHSemesterHistory.SelectByStudentIDs(studentIDMapping.Values.Distinct());

            #region 將學生現有學期歷程做快取
            foreach (JHSemesterHistoryRecord var in records)
            {
                studentSemesterHistory.Add(var.RefStudentID, var);
            }
            #endregion

            List <JHSemesterHistoryRecord> UpdateRecords = new List <JHSemesterHistoryRecord>();

            foreach (string key in keyList)
            {
                JHSemesterHistoryRecord record = studentSemesterHistory[studentIDMapping[key]];

                List <RowData> Rows = rowsMapping[key];

                if (record != null)
                {
                    for (int i = 0; i < Rows.Count; i++)
                    {
                        string StudentID      = Rows[i].ID;
                        string SchoolYear     = Rows[i]["學年度"];
                        string Semester       = Rows[i]["學期"];
                        string GradeYear      = Rows[i]["年級"];
                        string ClassName      = Rows[i].ContainsKey("當時班級")?Rows[i]["當時班級"]:string.Empty;
                        string SeatNo         = Rows[i].ContainsKey("當時座號")?Rows[i]["當時座號"]:string.Empty;
                        string TeacherName    = Rows[i].ContainsKey("當時班導師姓名")?Rows[i]["當時班導師姓名"]:string.Empty;
                        string SchoolDayCount = Rows[i].ContainsKey("上課天數")?Rows[i]["上課天數"]:string.Empty;

                        List <K12.Data.SemesterHistoryItem> Items = record.SemesterHistoryItems.Where(x => x.RefStudentID == StudentID && x.SchoolYear.ToString() == SchoolYear && x.Semester.ToString() == Semester).ToList();

                        if (Items.Count > 0)
                        {
                            Items[0].GradeYear = K12.Data.Int.Parse(GradeYear);
                            if (Rows[i].ContainsKey("當時班級"))
                            {
                                Items[0].ClassName = ClassName;
                            }
                            if (Rows[i].ContainsKey("當時座號"))
                            {
                                Items[0].SeatNo = K12.Data.Int.ParseAllowNull(SeatNo);
                            }
                            if (Rows[i].ContainsKey("當時班導師姓名"))
                            {
                                Items[0].Teacher = TeacherName;
                            }
                            if (Rows[i].ContainsKey("上課天數"))
                            {
                                Items[0].SchoolDayCount = K12.Data.Int.ParseAllowNull(SchoolDayCount);
                            }
                        }
                        else
                        {
                            K12.Data.SemesterHistoryItem Item = new K12.Data.SemesterHistoryItem();
                            Item.SchoolYear     = K12.Data.Int.Parse(SchoolYear);
                            Item.Semester       = K12.Data.Int.Parse(Semester);
                            Item.GradeYear      = K12.Data.Int.Parse(GradeYear);
                            Item.ClassName      = ClassName;
                            Item.SeatNo         = K12.Data.Int.ParseAllowNull(SeatNo);
                            Item.Teacher        = TeacherName;
                            Item.SchoolDayCount = K12.Data.Int.ParseAllowNull(SchoolDayCount);
                            record.SemesterHistoryItems.Add(Item);
                        }
                    }

                    UpdateRecords.Add(record);
                }
                else
                {
                    JHSemesterHistoryRecord newrecord = new JHSemesterHistoryRecord();

                    newrecord.RefStudentID = Rows[0].ID;

                    List <K12.Data.SemesterHistoryItem> Items = new List <K12.Data.SemesterHistoryItem>();

                    for (int i = 0; i < Rows.Count; i++)
                    {
                        string SchoolYear     = Rows[i]["學年度"];
                        string Semester       = Rows[i]["學期"];
                        string GradeYear      = Rows[i].ContainsKey("年級") ? Rows[i]["年級"] : string.Empty;
                        string ClassName      = Rows[i].ContainsKey("當時班級") ? Rows[i]["當時班級"] : string.Empty;
                        string SeatNo         = Rows[i].ContainsKey("當時座號") ? Rows[i]["當時座號"] : string.Empty;
                        string TeacherName    = Rows[i].ContainsKey("當時班導師姓名") ? Rows[i]["當時班導師姓名"] : string.Empty;
                        string SchoolDayCount = Rows[i].ContainsKey("上課天數") ? Rows[i]["上課天數"] : string.Empty;

                        K12.Data.SemesterHistoryItem Item = new K12.Data.SemesterHistoryItem();
                        Item.SchoolYear     = K12.Data.Int.Parse(SchoolYear);
                        Item.Semester       = K12.Data.Int.Parse(Semester);
                        Item.GradeYear      = K12.Data.Int.Parse(GradeYear);
                        Item.ClassName      = ClassName;
                        Item.SeatNo         = K12.Data.Int.ParseAllowNull(SeatNo);
                        Item.Teacher        = TeacherName;
                        Item.SchoolDayCount = K12.Data.Int.ParseAllowNull(SchoolDayCount);
                        Items.Add(Item);
                    }

                    newrecord.SemesterHistoryItems = Items;

                    UpdateRecords.Add(newrecord);
                }
            }

            if (UpdateRecords.Count > 0)
            {
                JHSemesterHistory.Update(UpdateRecords);
            }
        }
Ejemplo n.º 3
0
        public Dictionary <string, bool> Evaluate(IEnumerable <StudentRecord> list)
        {
            _result.Clear();

            Dictionary <string, bool> passList = new Dictionary <string, bool>();

            //Dictionary<string, SemesterHistoryUtility> shList = new Dictionary<string, SemesterHistoryUtility>();
            //foreach (Data.JHSemesterHistoryRecord shRecord in Data.JHSemesterHistory.SelectByStudentIDs(list.AsKeyList().ToArray()))
            //{
            //    if (!shList.ContainsKey(shRecord.RefStudentID))
            //        shList.Add(shRecord.RefStudentID, new SemesterHistoryUtility(shRecord));
            //}

            //list.SyncSemesterScoreCache();
            Dictionary <string, List <Data.JHSemesterScoreRecord> > studentSemesterScoreCache = new Dictionary <string, List <JHSchool.Data.JHSemesterScoreRecord> >();

            foreach (Data.JHSemesterScoreRecord record in Data.JHSemesterScore.SelectByStudentIDs(list.AsKeyList()))
            {
                if (!studentSemesterScoreCache.ContainsKey(record.RefStudentID))
                {
                    studentSemesterScoreCache.Add(record.RefStudentID, new List <JHSchool.Data.JHSemesterScoreRecord>());
                }
                studentSemesterScoreCache[record.RefStudentID].Add(record);
            }

            foreach (StudentRecord each in list)
            {
                List <ResultDetail>     resultList = new List <ResultDetail>();
                JHSemesterHistoryRecord shRec      = new JHSemesterHistoryRecord();
                if (UIConfig._StudentSHistoryRecDict.ContainsKey(each.ID))
                {
                    shRec = UIConfig._StudentSHistoryRecDict[each.ID];
                }
                // 有成績學年度學期
                List <string> hasSemsScoreSchoolYearSemester = new List <string>();
                if (studentSemesterScoreCache.ContainsKey(each.ID))
                {
                    foreach (Data.JHSemesterScoreRecord record in studentSemesterScoreCache[each.ID])
                    {
                        hasSemsScoreSchoolYearSemester.Add(record.SchoolYear.ToString() + record.Semester.ToString());
                        // 只檢查三下,以學期歷程為主
                        int gradeYear = 0;
                        foreach (K12.Data.SemesterHistoryItem shi in shRec.SemesterHistoryItems)
                        {
                            if (shi.SchoolYear == record.SchoolYear && shi.Semester == record.Semester)
                            {
                                gradeYear = shi.GradeYear;
                            }
                        }

                        if (!((gradeYear == 3 || gradeYear == 9) && record.Semester == 2))
                        {
                            continue;
                        }

                        // 領域有及格的數量
                        int count = 0;

                        //2017/5/9 穎驊修正 ,因應 高雄 [08-05][03] 畢業資格判斷成績及格標準調整 項目,
                        // 領域 分數超過60分 ,以 四捨五入取到小數第二位 , 低於60分 採用 無條件進位至整數 (EX : 59.01 =60)
                        // (只有高雄版有如此機制,新竹版照舊不管分數高低都是四捨五入)
                        if (JHEvaluation.ScoreCalculation.Program.Mode == JHEvaluation.ScoreCalculation.ModuleMode.HsinChu)
                        {
                            foreach (K12.Data.DomainScore domain in record.Domains.Values)
                            {
                                if (domain.Score.HasValue)
                                {
                                    if (domain.Score.Value >= _score)
                                    {
                                        count++;
                                    }
                                }
                            }
                        }
                        if (JHEvaluation.ScoreCalculation.Program.Mode == JHEvaluation.ScoreCalculation.ModuleMode.KaoHsiung)
                        {
                            foreach (K12.Data.DomainScore domain in record.Domains.Values)
                            {
                                if (domain.Score.HasValue)
                                {
                                    if (domain.Score.Value >= 60 && domain.Score.Value >= _score)
                                    {
                                        count++;
                                    }
                                    if (domain.Score.Value < 60 && Math.Ceiling(domain.Score.Value) >= _score)
                                    {
                                        count++;
                                    }
                                }
                            }
                        }



                        if (count < _domain_count)
                        {
                            ResultDetail rd = new ResultDetail(each.ID, "" + gradeYear, "" + record.Semester);
                            rd.AddMessage("學期領域成績不符合畢業規範");
                            rd.AddDetail("學期領域成績不符合畢業規範");
                            resultList.Add(rd);
                        }
                    }
                }

                // 檢查有學期歷程沒有成績
                foreach (K12.Data.SemesterHistoryItem shi in shRec.SemesterHistoryItems)
                {
                    if (shi.GradeYear == 3 || shi.GradeYear == 9)
                    {
                        if (!hasSemsScoreSchoolYearSemester.Contains(shi.SchoolYear.ToString() + shi.Semester.ToString()))
                        {
                            ResultDetail rd = new ResultDetail(each.ID, shi.GradeYear.ToString(), shi.Semester.ToString());
                            rd.AddMessage("學期領域成績資料缺漏");
                            rd.AddDetail("學期領域成績資料缺漏");
                            resultList.Add(rd);
                        }
                    }
                }

                if (resultList.Count > 0)
                {
                    _result.Add(each.ID, resultList);
                    passList.Add(each.ID, false);
                }
                else
                {
                    passList.Add(each.ID, true);
                }
            }

            return(passList);
        }
Ejemplo n.º 4
0
        public StudentHistoryProcessor(DocumentBuilder builder, SemesterMap map, JHSemesterHistoryRecord record)
        {
            _data = new Dictionary <string, string>();
            _data.Add("一上班級", "");
            _data.Add("一下班級", "");
            _data.Add("二上班級", "");
            _data.Add("二下班級", "");
            _data.Add("三上班級", "");
            _data.Add("三下班級", "");
            _data.Add("一上導師", "");
            _data.Add("一下導師", "");
            _data.Add("二上導師", "");
            _data.Add("二下導師", "");
            _data.Add("三上導師", "");
            _data.Add("三下導師", "");

            _gradeMap = new Dictionary <int, string>();
            _gradeMap.Add(1, "一上");
            _gradeMap.Add(2, "一下");
            _gradeMap.Add(3, "二上");
            _gradeMap.Add(4, "二下");
            _gradeMap.Add(5, "三上");
            _gradeMap.Add(6, "三下");

            List <string> fieldName  = new List <string>();
            List <string> fieldValue = new List <string>();

            int index = 0;

            //foreach (string name in new string[] { "一上", "一下", "二上", "二下", "三上", "三下" })
            foreach (string name in new string[] { "一年級學年度", "二年級學年度", "三年級學年度" })
            {
                fieldName.Add(name);
                if (map.SchoolYearMapping.ContainsKey(index))
                {
                    fieldValue.Add(map.SchoolYearMapping[index] + "學年度");
                }
                else
                {
                    fieldValue.Add("");
                }
                index += 2;
            }

            foreach (var item in record.SemesterHistoryItems)
            {
                int gradeYear = item.GradeYear;
                if (gradeYear > 6)
                {
                    gradeYear -= 6;
                }

                index = (gradeYear - 1) * 2 + item.Semester;
                if (_gradeMap.ContainsKey(index))
                {
                    string key = _gradeMap[index];

                    string classSeatNo = string.Empty;
                    if (!string.IsNullOrEmpty(item.ClassName))
                    {
                        classSeatNo += item.ClassName + "班";
                    }
                    if (!string.IsNullOrEmpty("" + item.SeatNo))
                    {
                        classSeatNo += item.SeatNo + "號";
                    }

                    _data[key + "導師"] = item.Teacher;
                    _data[key + "班級"] = classSeatNo;
                }
            }

            fieldName.AddRange(_data.Keys);
            fieldValue.AddRange(_data.Values);

            builder.Document.MailMerge.Execute(fieldName.ToArray(), fieldValue.ToArray());
        }
        public StudentHistoryProcessor(DocumentBuilder builder, SemesterMap map, JHSemesterHistoryRecord record)
        {
            _data = new Dictionary<string, string>();
            _data.Add("一上班級", "");
            _data.Add("一下班級", "");
            _data.Add("二上班級", "");
            _data.Add("二下班級", "");
            _data.Add("三上班級", "");
            _data.Add("三下班級", "");
            _data.Add("一上導師", "");
            _data.Add("一下導師", "");
            _data.Add("二上導師", "");
            _data.Add("二下導師", "");
            _data.Add("三上導師", "");
            _data.Add("三下導師", "");

            _gradeMap = new Dictionary<int, string>();
            _gradeMap.Add(1, "一上");
            _gradeMap.Add(2, "一下");
            _gradeMap.Add(3, "二上");
            _gradeMap.Add(4, "二下");
            _gradeMap.Add(5, "三上");
            _gradeMap.Add(6, "三下");

            List<string> fieldName = new List<string>();
            List<string> fieldValue = new List<string>();

            int index = 0;
            //foreach (string name in new string[] { "一上", "一下", "二上", "二下", "三上", "三下" })
            foreach (string name in new string[] { "一年級學年度", "二年級學年度", "三年級學年度" })
            {
                fieldName.Add(name);
                if (map.SchoolYearMapping.ContainsKey(index))
                    fieldValue.Add(map.SchoolYearMapping[index] + "學年度");
                else
                    fieldValue.Add("");
                index += 2;
            }

            foreach (var item in record.SemesterHistoryItems)
            {
                int gradeYear = item.GradeYear;
                if (gradeYear > 6) gradeYear -= 6;

                index = (gradeYear - 1) * 2 + item.Semester;
                if (_gradeMap.ContainsKey(index))
                {
                    string key = _gradeMap[index];

                    string classSeatNo = string.Empty;
                    if (!string.IsNullOrEmpty(item.ClassName))
                        classSeatNo += item.ClassName + "班";
                    if (!string.IsNullOrEmpty("" + item.SeatNo))
                        classSeatNo += item.SeatNo + "號";

                    _data[key + "導師"] = item.Teacher;
                    _data[key + "班級"] = classSeatNo;
                }
            }

            fieldName.AddRange(_data.Keys);
            fieldValue.AddRange(_data.Values);

            builder.Document.MailMerge.Execute(fieldName.ToArray(), fieldValue.ToArray());
        }