예제 #1
0
        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 sce in xmlRecords.SelectNodes("Score"))
                {
                    SCETake include = new SCETake(sce);
                    includes.Add(include);
                }
            }

            return(includes);
        }
예제 #2
0
        public void CalculateScore()
        {
            if (Course.ExamTemplate == null)
            {
                return;
            }

            if (!Course.ExamRequired)
            {
                return;
            }

            //AllowUpload 為 True 時,略過成績計算,因為成績是由老師提供。
            //if (Course.ExamTemplate.AllowUpload)
            //    return;

            decimal total        = 0;
            int     effort_total = 0;
            int     effort_count = 0;
            bool    hasScore     = false;
            bool    hasEffort    = false;

            if (new List <TEInclude>(Course.RefExams).Count == 0)
            {
                _no_exam = true;
                return;
            }

            foreach (TEInclude exam in Course.RefExams)
            {
                decimal score  = 0;
                int     effort = 0;
                if (SCETakes.ContainsKey(exam.ExamId))
                {
                    SCETake take = SCETakes[exam.ExamId];

                    if (exam.UseScore)
                    {
                        if (!decimal.TryParse(take.Score, out score))
                        {
                            _contains_lack = true;
                            SetScoreLack(exam.ExamName);
                        }
                        else
                        {
                            total   += (score * ((decimal)exam.Weight / 100m));
                            hasScore = true;
                        }
                    }

                    if (exam.UseEffort)
                    {
                        if (!int.TryParse(take.Effort, out effort))
                        {
                            _contains_lack = true;
                            SetEffortLack(exam.ExamName);
                        }
                        else
                        {
                            effort_count++;
                            effort_total += effort;
                            hasEffort     = true;
                        }
                    }
                }
                else
                {
                    if (exam.UseScore)
                    {
                        _contains_lack = true;
                        SetScoreLack(exam.ExamName);
                    }
                    if (exam.UseEffort)
                    {
                        _contains_lack = true;
                        SetEffortLack(exam.ExamName);
                    }
                }
            }

            //SetScore(Math.Round(total, 2).ToString());
            if (hasScore)
            {
                SetScore(total.ToString());
            }
            if (hasEffort)
            {
                SetEffort("");
                if (effort_count > 0)
                {
                    SetEffort("" + (effort_total / effort_count));
                }
            }
        }
예제 #3
0
        public void LoadCalculationData(IProgressUI progressUI, IEnumerable <StudentRecord> students, int schoolYear, int semester)
        {
            _progress_ui = progressUI;
            _courses     = new CourseCollection();

            List <string> courseIds = new List <string>();

            //foreach (CourseRecord each in JHSchool.Course.Instance.SelectedList)
            //    courseIds.Add(each.ID);
            foreach (StudentRecord each in students)
            {
                foreach (CourseRecord attend_course in GetAttendCourses(each))
                {
                    if (attend_course.SchoolYear != schoolYear)
                    {
                        continue;
                    }
                    if (attend_course.Semester != semester)
                    {
                        continue;
                    }

                    if (!courseIds.Contains(attend_course.ID))
                    {
                        courseIds.Add(attend_course.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;
        }