public SCETakeCollection LoadData() { int current = 0; SCETakeCollection includes = new SCETakeCollection(); foreach (List <string> each in _packings) { current++; if (_progress.Cancellation) { break; } _progress.ReportProgress(string.Format("下載成績相關資料({0}%)", Math.Round(((float)current / (float)_packings.Count) * 100, 0)), 0); XmlElement xmlRecords = QueryCourse.GetSECTake(each.ToArray()).GetContent().BaseElement; foreach (XmlElement attend in xmlRecords.SelectNodes("Score")) { SCETake include = new SCETake(attend); includes.Add(include); } } return(includes); }
public void CalculateScore() { if (Course.ExamTemplate == null) { return; } if (!Course.ExamRequired) { return; } //AllowUpload 為 True 時,略過成績計算,因為成績是由老師提供。 if (Course.ExamTemplate.AllowUpload) { return; } decimal total = 0; foreach (TEInclude exam in Course.RefExams) { decimal score = 0; if (SCETakes.ContainsKey(exam.ExamId)) { SCETake take = SCETakes[exam.ExamId]; if (!decimal.TryParse(take.Score, out score)) //如果缺考會 0 分處理。 { _contains_lack = true; } } else { _contains_lack = true; } total += (score * ((decimal)exam.Weight / 100m)); } //SetScore(Math.Round(total, 2).ToString()); SetScore(total.ToString()); }
public void LoadCalculationData(IProgressUI progressUI) { _progress_ui = progressUI; _courses = new CourseCollection(); List <string> courseIds = new List <string>(); foreach (CourseRecord each in JHSchool.Course.Instance.SelectedList) { courseIds.Add(each.ID); } CurrentStep = 1; ReportProgress("下載課程相關資料...", 0); CourseCollection courses = Course.GetCourses(courseIds.ToArray()); if (_progress_ui.Cancellation) { return; } CurrentStep++; ReportProgress("下載評量相關資料...", 0); ExamTemplateCollection templates = ExamTemplate.GetExamTemplates(); if (_progress_ui.Cancellation) { return; } TEIncludeCollection teincludes = TEInclude.GetTEIncludes(); if (_progress_ui.Cancellation) { return; } CurrentStep++; SCAttendCollection scattends = SCAttend.GetSCAttends(_progress_ui, courseIds.ToArray()); if (_progress_ui.Cancellation) { return; } CurrentStep++; SCETakeCollection scetakes = SCETake.GetSCETakes(_progress_ui, courseIds.ToArray()); if (_progress_ui.Cancellation) { return; } //建立 ExamTemplate 的 TEInclude。 CreateTemplateExamReference(templates, teincludes); //建立 Course 的 ExamTemplate。 CreateCourseTemplateReference(courses, templates); //建立 Course 的 SCAttend。 CreateCourseStudentTwoWayReference(courses, scattends); //建立 SCAttend 的 SCETake。 CreateSCAttendSCETakeReference(scattends, scetakes); _courses = courses; }