public AEIncludeData(JHAEIncludeRecord record) { Weight = record.Weight; UseScore = record.UseScore; UseText = record.UseText; UseEffort = false; UseAssignmentScore = false; RefAssessmentSetupID = record.RefAssessmentSetupID; XmlElement xmlrecord = record.ToXML(); #region 嘗試取得 UseAssignmentScore XmlNode assignment = xmlrecord.SelectSingleNode("Extension/Extension/UseAssignmentScore"); if (assignment != null) { UseAssignmentScore = ParseBool(assignment.InnerText); } #endregion #region 嘗試取得 UseEffort XmlNode effort = xmlrecord.SelectSingleNode("Extension/Extension/UseEffort"); if (effort != null) { UseEffort = ParseBool(effort.InnerText); } #endregion }
private void JHAssessmentSetup_AfterInsert(object sender, K12.Data.DataChangedEventArgs e) { if (e.PrimaryKeys.Count > 0) { if (cboExistTemplates.Enabled == true && cboExistTemplates.SelectedItem is JHAssessmentSetupRecord) { JHAssessmentSetupRecord source = cboExistTemplates.SelectedItem as JHAssessmentSetupRecord; bool executeRequired = false; List <JHAEIncludeRecord> aeincludes = new List <JHAEIncludeRecord>(); foreach (JHAEIncludeRecord each in JHAEInclude.SelectByAssessmentSetupID(source.ID)) { JHAEIncludeRecord aeNew = new JHAEIncludeRecord(); aeNew.RefAssessmentSetupID = e.PrimaryKeys[0]; aeNew.RefExamID = each.RefExamID; aeNew.UseScore = each.UseScore; aeNew.UseText = each.UseText; aeNew.UseEffort = each.UseEffort; aeNew.Weight = each.Weight; aeNew.StartTime = each.StartTime; aeNew.EndTime = each.EndTime; aeincludes.Add(aeNew); executeRequired = true; } if (executeRequired) { JHAEInclude.Insert(aeincludes); } } } JHAssessmentSetup.AfterInsert -= new EventHandler <K12.Data.DataChangedEventArgs>(JHAssessmentSetup_AfterInsert); }
private bool SaveTemplate() { if (HasErrors()) { MsgBox.Show("請修正資料後再儲存。", Application.ProductName); return(false); } try { Listener.SuspendListen(); JHAssessmentSetupRecord record = CurrentItem.Tag as JHAssessmentSetupRecord; //刪除原先的 AEInclude if (OriginAEs.Count > 0) { JHAEInclude.Delete(OriginAEs); OriginAEs.Clear(); } //List<JHAEIncludeRecord> deleteList = JHAEInclude.SelectByAssessmentSetupID(record.ID); //if (deleteList.Count > 0) // JHAEInclude.Delete(deleteList); //將畫面上新的 AEInclude 寫入 List <JHAEIncludeRecord> insertList = new List <JHAEIncludeRecord>(); foreach (DataGridViewRow each in dataview.Rows) { if (each.IsNewRow) { continue; } JHAEIncludeRecord aeNew = new JHAEIncludeRecord(); aeNew.RefAssessmentSetupID = record.ID; aeNew.RefExamID = "" + each.Cells[ExamID.Index].Value; aeNew.UseScore = GetYesNoString(each.Cells[UseScore.Index].FormattedValue, false); aeNew.UseText = GetYesNoString(each.Cells[UseText.Index].FormattedValue, false); aeNew.UseEffort = GetYesNoString(each.Cells[UseEffort.Index].FormattedValue, false); int i; aeNew.Weight = int.TryParse("" + each.Cells[Weight.Index].Value, out i) ? i : 0; aeNew.StartTime = DateToSaveFormat("" + each.Cells[StartTime.Index].Value); aeNew.EndTime = DateToSaveFormat("" + each.Cells[EndTime.Index].Value); insertList.Add(aeNew); } if (insertList.Count > 0) { JHAEInclude.Insert(insertList); } //繳交時間寫入 record.OrdinarilyStartTime = GetDateTimeNullable(txtOStartTime.Text, PaddingMethod.First); record.OrdinarilyEndTime = GetDateTimeNullable(txtOEndTime.Text, PaddingMethod.Last); record.TextStartTime = GetDateTimeNullable(txtTStartTime.Text, PaddingMethod.First); record.TextEndTime = GetDateTimeNullable(txtTEndTime.Text, PaddingMethod.Last); JHAssessmentSetup.Update(record); lblIsDirty.Visible = false; Listener.Reset(); Listener.ResumeListen(); return(true); } catch (Exception ex) { MsgBox.Show(ex.Message); return(false); } }
public static List <InternalExamScoreRecord> Select(IEnumerable <string> StudentIDs, UserOptions Options) { //key:CourseID Dictionary <string, JHCourseRecord> dictCourses = Utilities.GetCourseDict(Options.SchoolYear, Options.Semester); //key:AssessmentSetupID Dictionary <string, JHAEIncludeRecord> dictAEIncludes = Utilities.GetAEIncludeDict(dictCourses.Values.ToAssessmentSetupIDs(), Options.Exam); //類似學期成績的結構… Dictionary <string, InternalExamScoreRecord> dictStudentScores = new Dictionary <string, InternalExamScoreRecord>(); // 取得評量比例 Utilities.ScorePercentageHSDict = Utilities.GetScorePercentageHS(); #region 取得及轉換評量科目成績 int size = 200; int thread = 5; FunctionSpliter <string, JHSCETakeRecord> spliter = new FunctionSpliter <string, JHSCETakeRecord>(size, thread); spliter.Function = delegate(List <string> studentKeysPart) { return(JHSCETake.Select(null, studentKeysPart, new string[] { Options.Exam.ID }, null, null)); }; foreach (JHSCETakeRecord sce in spliter.Execute(StudentIDs.ToList())) { if (!dictCourses.ContainsKey(sce.RefCourseID)) { continue; //評量成績所屬課程非本學期,跳過 } if (Options.Exam.ID != sce.RefExamID) { continue; //評量成績的試別不符,跳過 } JHCourseRecord course = dictCourses[sce.RefCourseID]; if (!dictAEIncludes.ContainsKey(course.RefAssessmentSetupID)) { continue; //如果課程沒有評量設定,跳過 } JHAEIncludeRecord ae = dictAEIncludes[course.RefAssessmentSetupID]; //每個學生一個 InternalExamScoreRecord if (!dictStudentScores.ContainsKey(sce.RefStudentID)) { dictStudentScores.Add(sce.RefStudentID, new InternalExamScoreRecord(sce.RefStudentID)); } if (!dictStudentScores[sce.RefStudentID].Subjects.ContainsKey(course.Subject)) { SubjectScore subjectScore = new SubjectScore(); subjectScore.Domain = course.Domain; subjectScore.Subject = course.Subject; subjectScore.Period = course.Period; subjectScore.Credit = course.Credit; subjectScore.Score = Utilities.GetScore(new HC.JHSCETakeRecord(sce), new HC.JHAEIncludeRecord(ae), Options.ScoreSource); if (subjectScore.Score.HasValue) { dictStudentScores[sce.RefStudentID].Subjects.Add(course.Subject, subjectScore); } } } #endregion #region 計算評量領域成績 JHSchool.Evaluation.Calculation.ScoreCalculator defaultCalculator = new JHSchool.Evaluation.Calculation.ScoreCalculator(null); StudentScore.SetClassMapping(); List <StudentScore> Students = ToStudentScore(StudentIDs); Students.ReadCalculationRule(null); foreach (StudentScore student in Students) { student.SemestersScore.Add(SemesterData.Empty, new global::JHEvaluation.ScoreCalculation.ScoreStruct.SemesterScore(Options.SchoolYear, Options.Semester)); if (!dictStudentScores.ContainsKey(student.Id)) { continue; } global::JHEvaluation.ScoreCalculation.ScoreStruct.SemesterScore semesterScore = student.SemestersScore[SemesterData.Empty]; foreach (SubjectScore score in dictStudentScores[student.Id].Subjects.Values) { //科目成績偷偷進位 if (score.Score.HasValue) { if (student.CalculationRule != null) { score.Score = student.CalculationRule.ParseSubjectScore(score.Score.Value); } else { score.Score = defaultCalculator.ParseSubjectScore(score.Score.Value); } } if (!semesterScore.Subject.Contains(score.Subject)) { semesterScore.Subject.Add(score.Subject, new SemesterSubjectScore(score)); } } } Students.CalcuateDomainSemesterScore(new string[] { }); #endregion foreach (StudentScore student in Students) { if (!dictStudentScores.ContainsKey(student.Id)) { dictStudentScores.Add(student.Id, new InternalExamScoreRecord(student.Id)); } InternalExamScoreRecord examScore = dictStudentScores[student.Id]; examScore.Subjects = ToSubjects(student.SemestersScore[SemesterData.Empty].Subject); examScore.Domains = ToDomains(student.SemestersScore[SemesterData.Empty].Domain); } return(new List <InternalExamScoreRecord>(dictStudentScores.Values)); }
public void GetRefTotalScore(Boolean isReferrnceScore, JHAEIncludeRecord IRecord, Dictionary <string, decimal> ScorePercentageHSDict) { AEIncludeData aedata; if (IRecord == null) { aedata = new AEIncludeData(); } else { aedata = new AEIncludeData(IRecord); } ScorePercentage = AssessScorePercentage = 0; if (ScorePercentageHSDict.ContainsKey(IRecord.RefAssessmentSetupID)) { ScorePercentage = ScorePercentageHSDict[IRecord.RefAssessmentSetupID] * 0.01M; AssessScorePercentage = (100 - ScorePercentageHSDict[IRecord.RefAssessmentSetupID]) * 0.01M; } if (!aedata.UseScore && aedata.UseAssignmentScore) { ScorePercentage = 0; AssessScorePercentage = 1; } if (!aedata.UseScore && !aedata.UseAssignmentScore) { ScorePercentage = 0; AssessScorePercentage = 0; } if (ScoreF.HasValue && Program.ScoreValueMap.ContainsKey(ScoreF.Value)) { if (!Program.ScoreValueMap[ScoreF.Value].AllowCalculation) { ScorePercentage = 0; AssessScorePercentage = 1; } } if (ScoreA.HasValue && Program.ScoreValueMap.ContainsKey(ScoreA.Value)) { if (!Program.ScoreValueMap[ScoreA.Value].AllowCalculation) { ScorePercentage = 1; AssessScorePercentage = 0; } } if (isReferrnceScore) // 如果有含參考試別 就要計算 參考試的總成績 { if (RefScoreF.HasValue && Program.ScoreValueMap.ContainsKey(RefScoreF.Value)) { if (!Program.ScoreValueMap[RefScoreF.Value].AllowCalculation) { ScorePercentage = 0; AssessScorePercentage = 1; } } if (RefScoreA.HasValue && Program.ScoreValueMap.ContainsKey(RefScoreA.Value)) { if (!Program.ScoreValueMap[RefScoreA.Value].AllowCalculation) { ScorePercentage = 1; AssessScorePercentage = 0; } } if (ScorePercentage > 0 && RefScoreF.HasValue) { if (Program.ScoreValueMap.ContainsKey(RefScoreF.Value)) { if (Program.ScoreValueMap[RefScoreF.Value].AllowCalculation) { RefScoreT = (RefScoreT == null ? 0 : RefScoreT) + Program.ScoreValueMap[RefScoreF.Value].Score.Value * ScorePercentage; } } else { RefScoreT = (RefScoreT == null ? 0 : RefScoreT) + RefScoreF.Value * ScorePercentage; } } if (AssessScorePercentage > 0 && RefScoreA.HasValue) { if (Program.ScoreValueMap.ContainsKey(RefScoreA.Value)) { if (Program.ScoreValueMap[RefScoreA.Value].AllowCalculation) { RefScoreT = (RefScoreT == null ? 0 : RefScoreT) + Program.ScoreValueMap[RefScoreA.Value].Score.Value * AssessScorePercentage; } } else { RefScoreT = (RefScoreT == null ? 0 : RefScoreT) + RefScoreA.Value * AssessScorePercentage; } } } }