Exemplo n.º 1
0
        //TODO:这里用教师姓名,可能有重名的隐患
        public List<Topdorm> CalculateTeacherHorizontal(List<DormExam> list)
        {
            var dormNumList = new List<String>();
            foreach (var item in list)
            {
                if (!dormNumList.Contains(item.DormInfo.Num))
                {
                    dormNumList.Add(item.DormInfo.Num);
                }
            }

            var teacherList = new List<String>();
            foreach (var i in dormNumList.Select(item => Db.DormInfoSimples.Where(u => u.Dorm.Num == item).ToList()).SelectMany(dormList => dormList.Where(i => !teacherList.Contains(i.TeacherName) && !String.IsNullOrEmpty(i.TeacherName))))
            {
                teacherList.Add(i.TeacherName);
            }

            var results = new List<Topdorm>();
            foreach (var item in teacherList)
            {
                var dormExamList = new List<DormExam>();
                foreach (var i in list)
                {
                    var dormInfoList = Db.DormInfoSimples.Where(u => u.Dorm.Num == i.DormInfo.Num);
                    foreach (var j in dormInfoList)
                    {
                        if (j.TeacherName == item)
                        {
                            dormExamList.Add(i);
                            break;
                        }
                    }
                }
                var countRates = CountRates(dormExamList);
                var irregularity = (from i in dormExamList where i.Irregularity.Name != "无" select i.Irregularity).ToList();
                var topdorm = new Topdorm()
                {
                    DormExamList = dormExamList,
                    GreatRate = countRates.GreatRate,
                    GoodRate = countRates.GoodRate,
                    FailRate = countRates.FailRate,
                    Average = countRates.Average,
                    ExamCount = dormExamList.Count,
                    IrregularityCount = irregularity.Count,
                    Teacher = item,
                    IrregularityList = irregularity
                };
                results.Add(topdorm);
            }
            results.Sort();
            return results;
        }
Exemplo n.º 2
0
        public List<Topdorm> CalculateTopdorm(List<DormExam> list)
        {
            var dormNumList = new List<String>();
            foreach (var item in list)
            {
                if (!dormNumList.Contains(item.DormInfo.Num))
                {
                    dormNumList.Add(item.DormInfo.Num);
                }
            }
            var results = new List<Topdorm>();
            foreach (var i in dormNumList)
            {
                var dormExamList = list.Where(u => u.DormInfo.Num == i).ToList();
                var countRates = CountRates(dormExamList);
                var dormInfoSimple = Db.DormInfoSimples.Where(u => u.Dorm.Num == i).ToList();
                var classInfo = new List<ClassInfo>();
                var teacher = new List<String>();
                foreach (var item in dormInfoSimple)
                {
                    if (item.ClassInfo != null)
                    {
                        if (!classInfo.Contains(item.ClassInfo))
                        {
                            classInfo.Add(item.ClassInfo);
                        }
                    }
                    if (!String.IsNullOrEmpty(item.TeacherName))
                    {
                        if (!teacher.Contains(item.TeacherName))
                        {
                            teacher.Add(item.TeacherName);
                        }
                    }
                }

                var irregularity = (from item in dormExamList where item.Irregularity.Name != "无" select item.Irregularity).ToList();
                var classInfoAbbStr = classInfo.Aggregate("", (current, item) => current + (item.Abbreviation + " "));
                var teacherStr = teacher.Aggregate("", (current, item) => current + (item + " "));
                var topdorm = new Topdorm()
                {
                    DormExamList = dormExamList,
                    GreatRate = countRates.GreatRate,
                    GoodRate = countRates.GoodRate,
                    FailRate = countRates.FailRate,
                    Average = countRates.Average,
                    ExamCount = dormExamList.Count,
                    IrregularityCount = irregularity.Count,
                    ClassAbb = classInfoAbbStr,
                    Teacher = teacherStr,
                    DormNum = i,
                    IrregularityList = irregularity

                };
                results.Add(topdorm);
            }
            results.Sort();
            return results;
        }