/// <summary> /// 處理扶助弱勢 /// </summary> /// <param name="studentObj"></param> /// <param name="tagIdList"></param> private decimal Cal_VulnerableGroups(ValueObj.StudentVO studentObj, Dictionary <string, List <string> > tagIdList) { int ItemIndex = Global.index_VulnerableGroups; // 取得大項目的條件 ValueObj.ItemConditionVO itemCondition = new ValueObj.ItemConditionVO(ItemIndex); // 取得子項目的條件 ValueObj.DetailItemConditionVO detailCondition = new ValueObj.DetailItemConditionVO(ItemIndex); // 大項目名稱 string itemName = itemCondition.ItemName; // 項目的積分 decimal ItemTotalPoints = 0; // loop 每個子項目 for (int intI = 0; intI < Global.DetailItemNameList[ItemIndex].Length; intI++) { // 子項目名稱 string detailItemName = Global.DetailItemNameList[ItemIndex][intI]; // 子項目積分 decimal points = detailCondition.DetailItemListDic[detailItemName]; // 看學生的類別有沒有在TagIdList bool isFound = Utility.IsContansTagId(studentObj.StudentTagId, tagIdList[detailItemName]); if (isFound == false) { points = 0; } // 取得detail item in student ValueObj.DetailItemVO detailItem = studentObj.DetailItemList[itemName][detailItemName]; // 回存此項目顯示的內容 detailItem.Value = "TagID: " + string.Join(",", tagIdList[detailItemName].ToArray()); // 回存此項目的積分 detailItem.Points = points; // 加總 ItemTotalPoints += points; } // 假如超過上限, 就以上限為主 ItemTotalPoints = (ItemTotalPoints > itemCondition.MaxItemPoints) ? itemCondition.MaxItemPoints : ItemTotalPoints; // 此學生在這個項目的積分 studentObj.ItemList[itemName] = ItemTotalPoints; return(ItemTotalPoints); }
/// <summary> /// 取得學生資料 /// </summary> /// <param name="StudentIdList"></param> /// <returns></returns> public static Dictionary <string, ValueObj.StudentVO> GetStudentInfo(List <string> StudentIdList) { Dictionary <string, ValueObj.StudentVO> result = new Dictionary <string, ValueObj.StudentVO>(); StringBuilder sb = new StringBuilder(); sb.Append("select student.id as student_id,"); sb.Append("student.name as student_name,"); sb.Append("student.birthdate as student_birthday,"); sb.Append("student.id_number as student_idnumber,"); sb.Append("class.grade_year as class_grade_year,"); sb.Append("class.display_order as class_display_order,"); sb.Append("class.class_name,"); sb.Append("student.seat_no as student_seat_no,"); sb.Append("student.student_number as student_number,"); sb.Append("tag_student.ref_tag_id"); sb.Append(" from student"); sb.Append(" inner join class"); sb.Append(" on student.ref_class_id = class.id"); sb.Append(" left join tag_student"); sb.Append(" on tag_student.ref_student_id = student.id"); sb.Append(" where student.id in ('" + string.Join("','", StudentIdList.ToArray()) + "')"); if (Global.IsDebug) { Console.WriteLine("[GetStudentInfo] sql: [" + sb.ToString() + "]"); } QueryHelper qh = new QueryHelper(); DataTable dt = qh.Select(sb.ToString()); foreach (DataRow row in dt.Rows) { string studentId = ("" + row["student_id"]).Trim(); if (!result.ContainsKey(studentId)) { ValueObj.StudentVO studentVO = new ValueObj.StudentVO(row); result.Add(studentId, studentVO); } else { result[studentId].AddTagId(row); } } return(result); }
/// <summary> /// 排序:年級/班級序號/班級名稱/座號/學號/姓名 /// </summary> /// <param name="obj1"></param> /// <param name="obj2"></param> private int SortStudent(ValueObj.StudentVO obj1, ValueObj.StudentVO obj2) { string seatno1 = obj1.ClassGradeYear.PadLeft(1, '0'); // 年級 seatno1 += obj1.ClassDisplayOrder.PadLeft(3, '0'); // 班級序號 seatno1 += obj1.ClassName.PadLeft(20, '0'); // 班級名稱 seatno1 += obj1.StudentSeatNo.PadLeft(3, '0'); // 座號 seatno1 += obj1.StudentNumber.PadLeft(20, '0'); // 學號 seatno1 += obj1.StudentName.PadLeft(10, '0'); // 姓名 string seatno2 = obj2.ClassGradeYear.PadLeft(1, '0'); // 年級 seatno2 += obj2.ClassDisplayOrder.PadLeft(3, '0'); // 班級序號 seatno2 += obj2.ClassName.PadLeft(20, '0'); // 班級名稱 seatno2 += obj2.StudentSeatNo.PadLeft(3, '0'); // 座號 seatno2 += obj2.StudentNumber.PadLeft(20, '0'); // 學號 seatno2 += obj2.StudentName.PadLeft(10, '0'); // 姓名 return(seatno1.CompareTo(seatno2)); }
/// <summary> /// 取得學生資料 /// </summary> /// <param name="StudentIdList"></param> /// <returns></returns> public static Dictionary<string, ValueObj.StudentVO> GetStudentInfo(List<string> StudentIdList) { Dictionary<string, ValueObj.StudentVO> result = new Dictionary<string,ValueObj.StudentVO>(); StringBuilder sb = new StringBuilder(); sb.Append("select student.id as student_id,"); sb.Append("student.name as student_name,"); sb.Append("student.birthdate as student_birthday,"); sb.Append("student.id_number as student_idnumber,"); sb.Append("class.grade_year as class_grade_year,"); sb.Append("class.display_order as class_display_order,"); sb.Append("class.class_name,"); sb.Append("student.seat_no as student_seat_no,"); sb.Append("student.student_number as student_number,"); sb.Append("tag_student.ref_tag_id"); sb.Append(" from student"); sb.Append(" inner join class"); sb.Append(" on student.ref_class_id = class.id"); sb.Append(" left join tag_student"); sb.Append(" on tag_student.ref_student_id = student.id"); sb.Append(" where student.id in ('" + string.Join("','", StudentIdList.ToArray()) + "')"); if (Global.IsDebug) Console.WriteLine("[GetStudentInfo] sql: [" + sb.ToString() + "]"); QueryHelper qh = new QueryHelper(); DataTable dt = qh.Select(sb.ToString()); foreach (DataRow row in dt.Rows) { string studentId = ("" + row["student_id"]).Trim(); if(!result.ContainsKey(studentId)) { ValueObj.StudentVO studentVO = new ValueObj.StudentVO(row); result.Add(studentId, studentVO); } else { result[studentId].AddTagId(row); } } return result; }
/// <summary> /// 處理獎勵紀錄 /// </summary> /// <param name="studentObj"></param> /// <param name="gradeMap"></param> /// <param name="meritsObj"></param> private decimal Cal_Merit(ValueObj.StudentVO studentObj, Dictionary <int, ValueObj.SchoolYearSemester> gradeMap, ValueObj.MeritsVO meritsObj) { int ItemIndex = Global.index_Merit; // 取得大項目的條件 ValueObj.ItemConditionVO itemCondition = new ValueObj.ItemConditionVO(ItemIndex); // 取得子項目的條件 ValueObj.DetailItemConditionVO detailCondition = new ValueObj.DetailItemConditionVO(ItemIndex); // 取得需要看的學年度學期 List <ValueObj.SchoolYearSemester> needSchoolYearList = Utility.GetNeedSchoolSemester(itemCondition.NeedSemester, gradeMap); // 大項目名稱 string itemName = itemCondition.ItemName; // 項目的積分 decimal ItemTotalPoints = 0; decimal[] meritCount = new decimal[Global.DetailItemNameList[ItemIndex].Length]; if (meritsObj != null) { // loop 每個學期分數的大功, 小功, 獎勵 foreach (ValueObj.SchoolYearSemester schoolYear in needSchoolYearList) { if (schoolYear == null) { continue; } List <Data.MeritRecord> meritList = meritsObj.GetMeritsBySchoolYear(schoolYear); foreach (Data.MeritRecord rec in meritList) { if (rec.MeritA.HasValue) { meritCount[0] += rec.MeritA.Value; } if (rec.MeritB.HasValue) { meritCount[1] += rec.MeritB.Value; } if (rec.MeritC.HasValue) { meritCount[2] += rec.MeritC.Value; } } } } // loop 每個子項目 for (int intI = 0; intI < Global.DetailItemNameList[ItemIndex].Length; intI++) { // 子項目名稱 string meritName = Global.DetailItemNameList[ItemIndex][intI]; // 子項目積分 decimal points = detailCondition.DetailItemListDic[meritName]; // 取得detail item in student ValueObj.DetailItemVO detailItem = studentObj.DetailItemList[itemName][meritName]; // 計算積分 decimal mixPoints = meritCount[intI] * points; // 回存此項目顯示的內容 detailItem.Value = "Points:" + points + " Counts:" + meritCount[intI].ToString(); // 回存此項目的積分 detailItem.Points = mixPoints; // 加總 ItemTotalPoints += mixPoints; } // 假如超過上限, 就以上限為主 ItemTotalPoints = (ItemTotalPoints > itemCondition.MaxItemPoints) ? itemCondition.MaxItemPoints : ItemTotalPoints; // 此學生在這個項目的積分 studentObj.ItemList[itemName] = ItemTotalPoints; return(ItemTotalPoints); }
/// <summary> /// 處理無記過紀錄 /// </summary> /// <param name="studentObj"></param> /// <param name="gradeMap"></param> /// <param name="demeritObj"></param> private decimal Cal_Demerit(ValueObj.StudentVO studentObj, Dictionary <int, ValueObj.SchoolYearSemester> gradeMap, ValueObj.DemeritsVO demeritObj) { int ItemIndex = Global.index_Demerit; // 取得大項目的條件 ValueObj.ItemConditionVO itemCondition = new ValueObj.ItemConditionVO(ItemIndex); // 取得子項目的條件 ValueObj.DetailItemConditionVO detailCondition = new ValueObj.DetailItemConditionVO(ItemIndex); // 取得需要看的學年度學期 List <ValueObj.SchoolYearSemester> needSchoolYearList = Utility.GetNeedSchoolSemester(itemCondition.NeedSemester, gradeMap); // 大項目名稱 string itemName = itemCondition.ItemName; decimal ItemTotalPoints = 0; #region 處理無記過紀錄 // 無記過紀錄名稱 string detailItemName = Global.DetailItemNameList[ItemIndex][0]; // 無記過紀錄積分 decimal noDemeritPoints = detailCondition.DetailItemListDic[detailItemName]; if (demeritObj != null) { foreach (ValueObj.SchoolYearSemester schoolYear in needSchoolYearList) { if (schoolYear == null) { continue; } int demeritCnt = demeritObj.GetDemeritsBySchoolYear(schoolYear).Count; // 其中有一個學期被記過或警告, 就為0分 if (demeritCnt > 0) { noDemeritPoints = 0; break; } } } // 取得detail item in student ValueObj.DetailItemVO detailItem = studentObj.DetailItemList[itemName][detailItemName]; // 回存此項目顯示的內容 detailItem.Value = "--"; // 回存此項目的積分 detailItem.Points = noDemeritPoints; #endregion if (noDemeritPoints > 0) { // 回存此項目顯示的內容 detailItem.Value = "無記過紀錄!"; studentObj.ItemList[itemName] = noDemeritPoints; // 不處理無小過以上記錄 return(noDemeritPoints); } #region 處理無小過以上記錄 int MaxDemeritCount = 3; // 無小過以上記錄名稱 detailItemName = Global.DetailItemNameList[ItemIndex][1]; // 無小過以上記錄積分 decimal demeritPoints = detailCondition.DetailItemListDic[detailItemName]; // loop 每個學期, 取得所有的大過, 小過, 警告 decimal[] Demerit = new decimal[3]; foreach (ValueObj.SchoolYearSemester schoolYear in needSchoolYearList) { if (schoolYear == null) { continue; } List <Data.DemeritRecord> demeritList = demeritObj.GetDemeritsBySchoolYear(schoolYear); foreach (Data.DemeritRecord rec in demeritList) { if (rec.DemeritA.HasValue) { Demerit[0] = rec.DemeritA.Value; } if (rec.DemeritB.HasValue) { Demerit[1] = rec.DemeritB.Value; } if (rec.DemeritC.HasValue) { Demerit[2] += rec.DemeritC.Value; } } } if (Demerit[0] > 0 || Demerit[1] > 0) { // 此學生在這個項目的積分 ItemTotalPoints = 0; } else { // 看警告有沒有超過三次 if (Demerit[2] >= MaxDemeritCount) { ItemTotalPoints = 0; } else { ItemTotalPoints = demeritPoints; } } // 取得detail item in student detailItem = studentObj.DetailItemList[itemName][detailItemName]; // 回存此項目顯示的內容 detailItem.Value = "大過:" + Demerit[0] + ", 小過:" + Demerit[1] + ", 警告:" + Demerit[2]; // 回存此項目的積分 detailItem.Points = ItemTotalPoints; #endregion // 此學生在這個項目的積分 studentObj.ItemList[itemName] = ItemTotalPoints; return(ItemTotalPoints); }
/// <summary> /// 處理德行表現 /// </summary> /// <param name="studentObj"></param> /// <param name="gradeMap"></param> /// <param name="clubsObj"></param> /// <param name="servicesObj"></param> private decimal Cal_VirtuousConduct(ValueObj.StudentVO studentObj, Dictionary <int, ValueObj.SchoolYearSemester> gradeMap, ValueObj.ClubsVO clubsObj, ValueObj.ServicesVO servicesObj) { int ItemIndex = Global.index_VirtuousConduct; // 取得大項目的條件 ValueObj.ItemConditionVO itemCondition = new ValueObj.ItemConditionVO(ItemIndex); // 取得子項目的條件 ValueObj.DetailItemConditionVO detailCondition = new ValueObj.DetailItemConditionVO(ItemIndex); // 取得需要看的學年度學期 List <ValueObj.SchoolYearSemester> needSchoolYearList = Utility.GetNeedSchoolSemester(itemCondition.NeedSemester, gradeMap); // 大項目名稱 string itemName = itemCondition.ItemName; decimal ItemTotalPoints = 0; #region 處理社團 // 社團名稱 string detailItemName = Global.DetailItemNameList[ItemIndex][0]; // 社團積分 decimal clubPoints = detailCondition.DetailItemListDic[detailItemName]; decimal clubTotalPoints = 0; if (clubsObj != null) { // loop 每個學期 foreach (ValueObj.SchoolYearSemester schoolYear in needSchoolYearList) { if (schoolYear == null) { continue; } List <ValueObj.ClubVO> clubList = clubsObj.GetClubsBySchoolYear(schoolYear); // 假如有參加過社團, +1分 if (clubList.Count > 0) { clubTotalPoints += 1; } } } // 取得detail item in student ValueObj.DetailItemVO detailItem = studentObj.DetailItemList[itemName][detailItemName]; // 回存此項目顯示的內容 detailItem.Value = "Count:" + clubTotalPoints.ToString(); // 假如超過上限, 就以上限為主 clubPoints = (clubTotalPoints > clubPoints) ? clubPoints : clubTotalPoints; // 回存此項目的積分 detailItem.Points = clubPoints; #endregion #region 處理服務學習 decimal ServiceHours = 6; // 服務學習名稱 detailItemName = Global.DetailItemNameList[ItemIndex][1]; // 服務學習積分 decimal servicePoints = detailCondition.DetailItemListDic[detailItemName]; decimal serviceTotalPoints = 0; // 特殊條件 // 取得三下的學年度學期 ValueObj.SchoolYearSemester specilSchoolYear = gradeMap[6]; // 截止時間 103/5/9 DateTime deadTime = new DateTime(2014, 5, 9); if (servicesObj != null) { // loop 每個學期 foreach (ValueObj.SchoolYearSemester schoolYear in needSchoolYearList) { if (schoolYear == null) { continue; } decimal hours = 0; List <ValueObj.ServiceVO> serviceList = servicesObj.GetServicesBySchoolYear(schoolYear); // 加總此學期的時數 foreach (var serviceObj in serviceList) { if (schoolYear == specilSchoolYear) { if (serviceObj.OccurTime.HasValue && (serviceObj.OccurTime.Value <= deadTime)) { hours += serviceObj.Hours; } } else { hours += serviceObj.Hours; } } // 假如超過6小時, +1分 if (hours >= ServiceHours) { serviceTotalPoints += 1; } } } // 取得detail item in student detailItem = studentObj.DetailItemList[itemName][detailItemName]; // 回存此項目顯示的內容 detailItem.Value = "Count:" + serviceTotalPoints.ToString(); // 假如超過上限, 就以上限為主 servicePoints = (serviceTotalPoints > servicePoints) ? servicePoints : serviceTotalPoints; // 回存此項目的積分 detailItem.Points = servicePoints; #endregion ItemTotalPoints = clubPoints + servicePoints; // 此學生在這個項目的積分 studentObj.ItemList[itemName] = ItemTotalPoints; return(ItemTotalPoints); }
/// <summary> /// 處理均衡學習 /// </summary> /// <param name="studentObj"></param> /// <param name="gradeMap"></param> /// <param name="domains"></param> private decimal Cal_BalanceLearning(ValueObj.StudentVO studentObj, Dictionary <int, ValueObj.SchoolYearSemester> gradeMap, ValueObj.DomainsVO domains) { int ItemIndex = Global.index_BalanceLearning; // 取得大項目的條件 ValueObj.ItemConditionVO itemCondition = new ValueObj.ItemConditionVO(ItemIndex); // 取得子項目的條件 ValueObj.DetailItemConditionVO detailCondition = new ValueObj.DetailItemConditionVO(ItemIndex); // 取得需要看的學年度學期 Dictionary <int, ValueObj.SchoolYearSemester> needSchoolYearList = Utility.GetNeedSchoolSemesterIndex(itemCondition.NeedSemester, gradeMap); // 大項目名稱 string itemName = itemCondition.ItemName; // 及格分數 decimal PassScore = 60; // 項目的積分 decimal ItemTotalPoints = 0; if (domains != null) { // loop 每個需要的領域 for (int intI = 0; intI < Global.DetailItemNameList[ItemIndex].Length; intI++) { // 子項目名稱 string detailItemName = Global.DetailItemNameList[ItemIndex][intI]; // 子項目積分 decimal points = detailCondition.DetailItemListDic[detailItemName]; decimal totalScore = 0; decimal avgScore = 0; decimal scoreCount = 0; // loop 領域的每個學期分數 foreach (KeyValuePair <int, ValueObj.SchoolYearSemester> pair in needSchoolYearList) { ValueObj.SchoolYearSemester schoolYear = pair.Value; if (schoolYear == null) { // 少了需要的學期 if (!_WarningStudentDic.ContainsKey(studentObj)) { _WarningStudentDic.Add(studentObj, new ValueObj.LackMsg()); } _WarningStudentDic[studentObj].AddHistoryLack(pair.Key); continue; } List <ValueObj.DomainVO> domainList = domains.GetDomainsBySechoolYear(schoolYear, detailItemName); if (domainList.Count == 0) { // 少了需要的領域 if (!_WarningStudentDic.ContainsKey(studentObj)) { _WarningStudentDic.Add(studentObj, new ValueObj.LackMsg()); } _WarningStudentDic[studentObj].AddDomainLack(pair.Key); continue; } foreach (ValueObj.DomainVO domain in domainList) { totalScore += domain.DomainScore; scoreCount++; } } // 取得detail item in student ValueObj.DetailItemVO detailItem = studentObj.DetailItemList[itemName][detailItemName]; // 領域的平均 // 原本是固定除以需要的學期, 這樣有少一個學期分數的話, 會很難看, 所以改成有幾個分數就除以幾 // avgScore = Math.Round((totalScore / needSchoolYearList.Count), 2, MidpointRounding.AwayFromZero); if (scoreCount > 0) { avgScore = Math.Round((totalScore / scoreCount), 2, MidpointRounding.AwayFromZero); } // 回存此項目顯示的內容 detailItem.Value = "總分: " + totalScore + ", 學期數: " + scoreCount + ", 平均: " + avgScore.ToString(); // 看學生有沒有得到此積分 if (avgScore >= PassScore) { ItemTotalPoints += points; // 回存此項目的積分 detailItem.Points = points; } } } else { // 完全沒有領域成績 if (!_WarningStudentDic.ContainsKey(studentObj)) { _WarningStudentDic.Add(studentObj, new ValueObj.LackMsg()); } foreach (int rec in needSchoolYearList.Keys) { _WarningStudentDic[studentObj].AddDomainLack(rec); } } // 假如超過上限, 就以上限為主 ItemTotalPoints = (ItemTotalPoints > itemCondition.MaxItemPoints) ? itemCondition.MaxItemPoints : ItemTotalPoints; // 此學生在這個項目的積分 studentObj.ItemList[itemName] = ItemTotalPoints; return(ItemTotalPoints); }