internal SemesterScoreRecordEditor(SemesterScoreRecord info) { SemesterSubjectScoreRecord = info; RefStudentID = info.RefStudentID; ID = info.ID; SchoolYear = info.SchoolYear; Semester = info.Semester; GradeYear = info.GradeYear; LearnDomainScore = info.LearnDomainScore; CourseLearnScore = info.CourseLearnScore; Dictionary <string, SubjectScore> subjectList = new Dictionary <string, SubjectScore>(); foreach (var subject in info.Subjects.Values) { subjectList.Add(subject.Subject, subject.Clone() as SubjectScore); } Subjects = subjectList; Dictionary <string, DomainScore> domainList = new Dictionary <string, DomainScore>(); foreach (var domain in info.Domains.Values) { domainList.Add(domain.Domain, domain.Clone() as DomainScore); } Domains = domainList; }
public static List <SemesterScoreRecord> GetSemesterScores(IEnumerable <string> primaryKeys) { DSXmlHelper helper = new DSXmlHelper("GetSemesterSubjectScore"); helper.AddElement("Field"); helper.AddElement("Field", "ID"); helper.AddElement("Field", "RefStudentId"); helper.AddElement("Field", "SchoolYear"); helper.AddElement("Field", "Semester"); helper.AddElement("Field", "GradeYear"); helper.AddElement("Field", "ScoreInfo"); helper.AddElement("Condition"); helper.AddElement("Condition", "StudentIDList"); foreach (var each in primaryKeys) { helper.AddElement("Condition/StudentIDList", "ID", each); } DSResponse rsp = FISCA.Authentication.DSAServices.CallService("SmartSchool.Score.GetSemesterSubjectScore", new DSRequest(helper)); List <SemesterScoreRecord> result = new List <SemesterScoreRecord>(); foreach (XmlElement element in rsp.GetContent().GetElements("SemesterSubjectScore")) { SemesterScoreRecord record = new SemesterScoreRecord(element); result.Add(record); } return(result); }
/// <summary> /// 讀取學期成績AvgScore /// </summary> /// <param name="ssr"></param> public void LoadData(SemesterScoreRecord ssr) { if (ssr.Semester == 1) { MidtermAvg = ssr.AvgScore; } else if (ssr.Semester == 2) { FinalAvg = ssr.AvgScore; } }
private void btnEdit_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count == 1) { SemesterScoreRecord record = listView.SelectedItems[0].Tag as SemesterScoreRecord; SemesterScoreEditor edit = new SemesterScoreEditor(record, RunningID); if (edit.ShowDialog() == DialogResult.OK) { _bgWorker.RunWorkerAsync(); } } }
public SemesterScoreEditor(SemesterScoreRecord ssr, string id) { InitializeComponent(); _ssr = ssr; _sid = id; //record舊資料for log foreach (SubjectScore ss in _ssr.Subjects.Values) { _old.Add(ss.Subject + "_節數", ss.Period + ""); _old.Add(ss.Subject + "_權數", ss.Credit + ""); _old.Add(ss.Subject + "_成績", ss.Score + ""); _old.Add(ss.Subject + "_類別", ss.Type + ""); _old.Add(ss.Subject + "_群組", ss.Domain + ""); _old.Add(ss.Subject + "_Level", ss.Level + ""); } //科目對照 foreach (SubjectRecord r in _A.Select <SubjectRecord>()) { if (!_SubjectDic.ContainsKey(r.Name)) { _SubjectDic.Add(r.Name, r); } } //新增科目下拉清單 //colSubjectName.Items.Add(""); //空白預設項 foreach (string name in _SubjectDic.Keys) { colSubjectName.Items.Add(name); } //Type colSubjectType.Items.Add("Regular"); colSubjectType.Items.Add("Honor"); //Domain Dictionary <int, List <Tool.Domain> > domains = Tool.DomainDic; foreach (int grade in domains.Keys) { foreach (Tool.Domain domain in domains[grade]) { if (!colDomain.Items.Contains(domain.Name)) { colDomain.Items.Add(domain.Name); } } } }
private string GetSemesterScoreInfo(SemesterScoreRecord record) { StringBuilder sb = new StringBuilder(); sb.AppendLine("平均成績:" + record.AvgScore); sb.AppendLine("平均GPA:" + record.AvgGPA); foreach (SubjectScore ss in record.Subjects.Values) { sb.AppendLine("科目:" + ss.Subject + " 節數:" + ss.Period + " 權數:" + ss.Credit + " 成績:" + ss.Score); } return(sb.ToString()); }
/// <summary> /// 設定學期成績 /// </summary> /// <param name="ssr"></param> public void SetSubjects(SemesterScoreRecord ssr) { //各科目學期成績(obj version) foreach (string subj in ssr.Subjects.Keys) { string subjKey = ssr.SchoolYear + "_" + subj; if (!SubjectObjDic.ContainsKey(subjKey)) { SubjectObjDic.Add(subjKey, new SubjectObj()); } SubjectObjDic[subjKey].LoadData(ssr.Subjects[subj]); //將科目清單分類 if (SchoolYearToGrade.ContainsKey(ssr.SchoolYear)) { int grade = SchoolYearToGrade[ssr.SchoolYear]; if (grade <= 6) { if (!SubjectList6.Contains(subj)) { SubjectList6.Add(subj); } } else { if (!SubjectList12.Contains(subj)) { SubjectList12.Add(subj); } } } } //排序科目清單 SortSubjects(); //各學期平均成績 string key = ssr.SchoolYear + ""; if (!AvgObjDic.ContainsKey(key)) { AvgObjDic.Add(key, new AvgObj()); } AvgObjDic[key].LoadData(ssr); }
private void btnOk_Click(object sender, EventArgs e) { int schoolYear = int.Parse(cboSchoolYear.Text); int semester = int.Parse(cboSemester.Text); string key = schoolYear + "_" + semester; if (_list.Contains(key)) { MessageBox.Show("該學年度學期已存在,無法新增"); } else { SemesterScoreRecord record = new SemesterScoreRecord(_id, schoolYear, semester); K12.Data.SemesterScore.Insert(record); this.DialogResult = DialogResult.OK; this.Close(); } }
private void btnDelete_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count == 1) { SemesterScoreRecord record = listView.SelectedItems[0].Tag as SemesterScoreRecord; if (MessageBox.Show("確認刪除「" + record.SchoolYear + "學年度 第" + record.Semester + "學期」的學期成績?", "ischool", MessageBoxButtons.OKCancel) == DialogResult.OK) { StudentRecord student = record.Student; string str = "學年度:" + record.SchoolYear + " 學期:" + record.Semester; str += Tool.GetStudentInfo(record.Student); str += GetSemesterScoreInfo(record); FISCA.LogAgent.ApplicationLog.Log("成績系統.學期成績", "刪除學期成績", str); K12.Data.SemesterScore.Delete(record); _bgWorker.RunWorkerAsync(); } } }
public StudentObj(StudentRecord sr) { StudentRecord = sr; SemesterScoreRecord = new SemesterScoreRecord(); }
public static SemesterScoreRecordEditor GetEditor(this SemesterScoreRecord semesterSubjectScoreRecord) { return(new SemesterScoreRecordEditor(semesterSubjectScoreRecord)); }
/// <summary> /// 計算指定學生在該學年度學期的累計GPA /// </summary> /// <param name="ids"></param> /// <param name="schoolYear"></param> /// <param name="semester"></param> public static void SetCumulateGPA(List <string> ids, int schoolYear, int semester) { //學期歷程 Dictionary <string, string> sems_history = new Dictionary <string, string>(); foreach (SemesterHistoryRecord shr in K12.Data.SemesterHistory.SelectByStudentIDs(ids)) { foreach (SemesterHistoryItem item in shr.SemesterHistoryItems) { //學生年級對照 string key = item.RefStudentID + "_" + item.SchoolYear + "_" + item.Semester; if (!sems_history.ContainsKey(key)) { if (item.Semester == 1) { sems_history.Add(key, item.GradeYear + "上"); } else { sems_history.Add(key, item.GradeYear + "下"); } } } } //取得學期成績紀錄 Dictionary <string, K12.Data.SemesterScoreRecord> update = new Dictionary <string, SemesterScoreRecord>(); foreach (var record in K12.Data.SemesterScore.SelectBySchoolYearAndSemester(ids, schoolYear, semester)) { if (!update.ContainsKey(record.RefStudentID)) { update.Add(record.RefStudentID, record); } } //結算累計GPA Dictionary <string, Dictionary <string, SemesterScoreRecord> > student_gpa_dic = new Dictionary <string, Dictionary <string, SemesterScoreRecord> >(); foreach (SemesterScoreRecord r in K12.Data.SemesterScore.SelectByStudentIDs(ids)) { //學年度學期判斷排除 if (r.SchoolYear > schoolYear) { continue; } else if (r.SchoolYear == schoolYear) { if (r.Semester > semester) { continue; } } string key = r.RefStudentID + "_" + r.SchoolYear + "_" + r.Semester; if (!student_gpa_dic.ContainsKey(r.RefStudentID)) { student_gpa_dic.Add(r.RefStudentID, new Dictionary <string, SemesterScoreRecord>()); } if (sems_history.ContainsKey(key)) { string grade = sems_history[key]; if (grade == "9上" || grade == "9下" || grade == "10上" || grade == "10下" || grade == "11上" || grade == "11下" || grade == "12上" || grade == "12下") { if (!student_gpa_dic[r.RefStudentID].ContainsKey(grade)) { student_gpa_dic[r.RefStudentID].Add(grade, r); } SemesterScoreRecord ssr = student_gpa_dic[r.RefStudentID][grade]; //如果有相同grade的record,以較新的為主 if (r.SchoolYear > ssr.SchoolYear) { student_gpa_dic[r.RefStudentID][grade] = r; } else if (r.SchoolYear == ssr.SchoolYear) { if (r.Semester > ssr.Semester) { student_gpa_dic[r.RefStudentID][grade] = r; } } } } } foreach (string id in update.Keys) { if (!student_gpa_dic.ContainsKey(id)) { continue; } SemesterScoreRecord ssr = update[id]; decimal total = 0; int count = 0; foreach (SemesterScoreRecord r in student_gpa_dic[id].Values) { if (r.AvgGPA.HasValue) { total += r.AvgGPA.Value; count++; } } if (count > 0) { ssr.CumulateGPA = Math.Round(total / count, 2, MidpointRounding.AwayFromZero); } } K12.Data.SemesterScore.Update(update.Values); }