public async Task <MessageModel <PageModel <ExamDetail> > > Get(int page = 1, string key = "") { if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) { key = ""; } else { page = 1; } int intPageSize = 50; var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false); var courseList = await _iCourseRepository.Query(d => d.IsDeleted == false); var examList = await _iExamRepository.Query(d => d.IsDeleted == false); var examDetailList = await _iExamDetailRepository.Query(d => d.IsDeleted == false && (d.gradeid == GID || (GID == -9999 && true))); foreach (var item in examList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.course = courseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var item in examDetailList) { item.exam = examList.Where(d => d.Id == item.examid).FirstOrDefault(); } if (!string.IsNullOrEmpty(key)) { examDetailList = examDetailList.Where(d => d.Name.Contains(key)).ToList(); } var totalCount = examDetailList.Count; int pageCount = (Math.Ceiling(totalCount.ObjToDecimal() / intPageSize.ObjToDecimal())).ObjToInt(); var exdetails = examDetailList.Skip((page - 1) * intPageSize).Take(intPageSize).ToList(); var data = new PageModel <ExamDetail>() { data = exdetails, dataCount = totalCount, page = page, pageCount = pageCount, PageSize = intPageSize }; return(new MessageModel <PageModel <ExamDetail> >() { msg = "获取成功", success = data.dataCount >= 0, response = data }); }
public async Task <MessageModel <ObjectiveStudent> > Get(int GradeId, string AcademicYearSchoolTerm, string ExamName, int CourseId, int ClazzId, int page = 1) { int intPageSize = 100; if (!(GradeId > 0 && CourseId > 0 && ClazzId > 0 && !string.IsNullOrEmpty(AcademicYearSchoolTerm) && !string.IsNullOrEmpty(ExamName))) { return(new MessageModel <ObjectiveStudent>()); } var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false && d.Id == GradeId); var clazzList = await _iClazzRepository.Query(d => d.IsDeleted == false && d.GradeId == GradeId); var courseList = await _iCourseRepository.Query(d => d.IsDeleted == false); var examList = await _iExamRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var studentsList = await _iStudentsRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var cctList = await _iCCTRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var teachersList = await _iTeacherRepository.Query(d => d.IsDeleted == false && d.gradeId == GradeId); //题目 var examDetailList = await _iExamDetailRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId && d.EDType == "客观题"); var examDetailScoreList = await _iExamDetailScoreRepository.Query(d => d.IsDeleted == false); foreach (var item in examList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.course = courseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var item in examDetailList) { item.exam = examList.Where(d => d.Id == item.examid).FirstOrDefault(); } //题目 examDetailList = examDetailList.Where(d => AcademicYearSchoolTerm == (d.exam.AcademicYear + d.exam.SchoolTerm) && d.exam.ExamName == ExamName && d.exam.gradeid == GradeId && d.exam.courseid == CourseId && d.courseid == CourseId).ToList(); // 如果选中班级,则是部分学生 studentsList = studentsList.Where(d => d.gradeid == GradeId && d.clazzid == ClazzId).ToList(); StringBuilder jsonBuilder = new StringBuilder(); StringBuilder jsonBuilderHeader = new StringBuilder(); jsonBuilder.Append("["); jsonBuilderHeader.Append("["); jsonBuilderHeader.Append("{\"prop\": \"学号\", \"label\": \"学号\"},"); jsonBuilderHeader.Append("{\"prop\": \"姓名\", \"label\": \"姓名\"},"); jsonBuilderHeader.Append("{\"prop\": \"班级\", \"label\": \"班级\"},"); foreach (var item in studentsList) { var clazzModel = clazzList.Where(d => d.Id == item.clazzid).FirstOrDefault(); jsonBuilder.Append("{"); jsonBuilder.Append("\""); jsonBuilder.Append("学号"); jsonBuilder.Append("\":\""); jsonBuilder.Append(item.StudentNo.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("姓名"); jsonBuilder.Append("\":\""); jsonBuilder.Append(item.Name.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("班级"); jsonBuilder.Append("\":\""); jsonBuilder.Append(clazzModel.ClassNo.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); for (int j = 0; j < examDetailList.Count; j++) { var examDetailScore = examDetailScoreList.Where(d => d.ExamDetailId == examDetailList[j].Id && d.studentid == item.Id).FirstOrDefault(); jsonBuilder.Append("\""); jsonBuilder.Append(examDetailList[j].Name); jsonBuilder.Append("\":\""); jsonBuilder.Append(examDetailScore.StudentAnswer.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilder.Append("},"); } for (int j = 0; j < examDetailList.Count; j++) { jsonBuilderHeader.Append("{\"prop\": \"" + examDetailList[j].Name + "\", \"label\": \"" + examDetailList[j].Name + "\"},"); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilderHeader.Remove(jsonBuilderHeader.Length - 1, 1); jsonBuilder.Append("]"); jsonBuilderHeader.Append("]"); ObjectiveStudent objectiveStudent = new ObjectiveStudent() { Header = jsonBuilderHeader.ObjToString(), Content = jsonBuilder.ObjToString() }; return(new MessageModel <ObjectiveStudent>() { msg = "获取成功", success = true, response = objectiveStudent }); }
public async Task <MessageModel <PageModel <Objective> > > Get(int GradeId, string AcademicYearSchoolTerm, string ExamName, int CourseId, int ClazzId, int page = 1) { int intPageSize = 100; if (!(GradeId > 0 && CourseId > 0 && !string.IsNullOrEmpty(AcademicYearSchoolTerm) && !string.IsNullOrEmpty(ExamName))) { return(new MessageModel <PageModel <Objective> >()); } var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false && d.Id == GradeId); var clazzList = await _iClazzRepository.Query(d => d.IsDeleted == false && d.GradeId == GradeId); var courseList = await _iCourseRepository.Query(d => d.IsDeleted == false); var examList = await _iExamRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var studentsList = await _iStudentsRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var cctList = await _iCCTRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var teachersList = await _iTeacherRepository.Query(d => d.IsDeleted == false && d.gradeId == GradeId); var examDetailList = await _iExamDetailRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId && d.EDType == "客观题"); var examDetailScoreList = await _iExamDetailScoreRepository.Query(d => d.IsDeleted == false); foreach (var item in examList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.course = courseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var item in examDetailList) { item.exam = examList.Where(d => d.Id == item.examid).FirstOrDefault(); } //题目 examDetailList = examDetailList.Where(d => AcademicYearSchoolTerm == (d.exam.AcademicYear + d.exam.SchoolTerm) && d.exam.ExamName == ExamName && d.exam.gradeid == GradeId && d.exam.courseid == CourseId && d.courseid == CourseId).ToList(); // 如果选中班级,则是部分学生 if (ClazzId > 0) { studentsList = studentsList.Where(d => d.gradeid == GradeId && d.clazzid == ClazzId).ToList(); } var lookStudentIds = studentsList.Select(d => d.Id).ToList(); var studentCount = examDetailScoreList.Where(d => lookStudentIds.Contains(d.studentid)).Select(d => d.studentid).GroupBy(x => new { x }).Select(x => x.First()).Count(); List <Objective> objectives = new List <Objective>(); foreach (var item in examDetailList) { var examDetailScoreCurrent = examDetailScoreList.Where(d => d.ExamDetailId == item.Id & lookStudentIds.Contains(d.studentid)); Objective objective = new Objective() { Name = item.Name, Answer = item.Answer, A = examDetailScoreCurrent.Where(d => d.StudentAnswer == "A").Count(), B = examDetailScoreCurrent.Where(d => d.StudentAnswer == "B").Count(), C = examDetailScoreCurrent.Where(d => d.StudentAnswer == "C").Count(), D = examDetailScoreCurrent.Where(d => d.StudentAnswer == "D").Count(), AB = examDetailScoreCurrent.Where(d => d.StudentAnswer == "AB").Count(), ABC = examDetailScoreCurrent.Where(d => d.StudentAnswer == "ABC").Count(), ABCD = examDetailScoreCurrent.Where(d => d.StudentAnswer == "ABCD").Count(), AC = examDetailScoreCurrent.Where(d => d.StudentAnswer == "AC").Count(), ACD = examDetailScoreCurrent.Where(d => d.StudentAnswer == "ACD").Count(), AD = examDetailScoreCurrent.Where(d => d.StudentAnswer == "AD").Count(), BC = examDetailScoreCurrent.Where(d => d.StudentAnswer == "BC").Count(), BCD = examDetailScoreCurrent.Where(d => d.StudentAnswer == "BCD").Count(), BD = examDetailScoreCurrent.Where(d => d.StudentAnswer == "BD").Count(), CD = examDetailScoreCurrent.Where(d => d.StudentAnswer == "CD").Count(), NoWrite = 0, ReadCardCount = studentCount, TotalScore = item.Score * studentCount, StudentTotalScore = examDetailScoreCurrent.Select(d => d.StudentScore).Sum(), }; objective.NoWrite = studentCount - (objective.A + objective.B + objective.C + objective.D + objective.AB + objective.ABC + objective.ABCD + objective.AC + objective.ACD + objective.AD + objective.BC + objective.BCD + objective.BD + objective.CD); objective.TotalScoreRate = (((objective.StudentTotalScore / objective.TotalScore).ToString("#0.00")).ObjToDecimal()) * 100; objectives.Add(objective); } var totalCount = objectives.Count; int pageCount = (Math.Ceiling(totalCount.ObjToDecimal() / intPageSize.ObjToDecimal())).ObjToInt(); var exScores = objectives.Skip((page - 1) * intPageSize).Take(intPageSize).ToList(); PageModel <Objective> data = new PageModel <Objective>() { data = exScores, dataCount = totalCount, page = page, pageCount = pageCount, PageSize = intPageSize }; return(new MessageModel <PageModel <Objective> >() { msg = "获取成功", success = data.dataCount >= 0, response = data }); }
public async Task <MessageModel <ObjectiveStudent> > Get(int GradeId, string AcademicYearSchoolTerm, string ExamName, int CourseId, int ClazzId, int page = 1) { int intPageSize = 100; if (!(GradeId > 0 && CourseId > 0 && ClazzId > 0 && !string.IsNullOrEmpty(AcademicYearSchoolTerm) && !string.IsNullOrEmpty(ExamName))) { return(new MessageModel <ObjectiveStudent>()); } var exScoreList = await _iExScoreRepository.Query(d => d.IsDeleted == false); var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false && d.Id == GradeId); var clazzList = await _iClazzRepository.Query(d => d.IsDeleted == false && d.GradeId == GradeId); var courseList = await _iCourseRepository.Query(d => d.IsDeleted == false); var examList = await _iExamRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var studentsList = await _iStudentsRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var cctList = await _iCCTRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var teachersList = await _iTeacherRepository.Query(d => d.IsDeleted == false && d.gradeId == GradeId); //题目 var examDetailList = await _iExamDetailRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var examDetailScoreList = await _iExamDetailScoreRepository.Query(d => d.IsDeleted == false); foreach (var item in examList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.course = courseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var exscore in exScoreList) { exscore.exam = examList.Where(d => d.Id == exscore.examid).FirstOrDefault(); var teacherid = cctList.Where(d => d.clazzid == exscore.clazzid && d.gradeid == exscore.exam.gradeid && d.courseid == exscore.exam.courseid).FirstOrDefault()?.teacherid; exscore.Teacher = teachersList.Where(d => d.Id == teacherid.ObjToInt()).FirstOrDefault()?.Name; exscore.clazz = clazzList.Where(d => d.Id == exscore.clazzid).FirstOrDefault(); exscore.student = studentsList.Where(d => d.Id == exscore.studentid).FirstOrDefault(); } // 统计 全年级的 某次考试 全部科目的 全部成绩 var examSortAllCourse = exScoreList.Where(d => d.clazzid == ClazzId && AcademicYearSchoolTerm == (d.exam.AcademicYear + d.exam.SchoolTerm) && d.exam.ExamName == ExamName && d.exam.gradeid == GradeId).ToList(); // 统计 全年级的 某次考试 某门科目中 的全部成绩 var exscoreGrade = examSortAllCourse.Where(d => d.courseid == CourseId).ToList(); List <SingleCourseStudent> totalGradeSingleCourseStudents = new List <SingleCourseStudent>(); foreach (var item in exscoreGrade) { SingleCourseStudent SingleCourseStudent = new SingleCourseStudent() { StudentNo = item.student.StudentNo, StudentName = item.student.Name, TotalScore = item.score.ObjToDecimal(), SubjectiveScore = item.SubjectiveScore.ObjToDecimal(), ObjectiveScore = item.ObjectiveScore.ObjToDecimal(), Clazz = item.clazz.ClassNo, Clazzid = item.clazz.Id, }; totalGradeSingleCourseStudents.Add(SingleCourseStudent); } // 如果选中班级,则是部分学生 studentsList = studentsList.Where(d => d.gradeid == GradeId && d.clazzid == ClazzId).ToList(); StringBuilder jsonBuilder = new StringBuilder(); StringBuilder jsonBuilderHeader = new StringBuilder(); jsonBuilder.Append("["); jsonBuilderHeader.Append("["); jsonBuilderHeader.Append("{\"prop\": \"学号\", \"label\": \"学号\"},"); jsonBuilderHeader.Append("{\"prop\": \"姓名\", \"label\": \"姓名\"},"); jsonBuilderHeader.Append("{\"prop\": \"班级\", \"label\": \"班级\"},"); jsonBuilderHeader.Append("{\"prop\": \"主观分数\", \"label\": \"主观分数\"},"); jsonBuilderHeader.Append("{\"prop\": \"客观分数\", \"label\": \"客观分数\"},"); jsonBuilderHeader.Append("{\"prop\": \"总分数\", \"label\": \"总分数\"},"); foreach (var item in studentsList) { var clazzModel = clazzList.Where(d => d.Id == item.clazzid).FirstOrDefault(); var examdetailscoreModel = totalGradeSingleCourseStudents.Where(d => d.StudentNo == item.StudentNo).FirstOrDefault(); jsonBuilder.Append("{"); jsonBuilder.Append("\""); jsonBuilder.Append("学号"); jsonBuilder.Append("\":\""); jsonBuilder.Append(item.StudentNo.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("姓名"); jsonBuilder.Append("\":\""); jsonBuilder.Append(item.Name.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("班级"); jsonBuilder.Append("\":\""); jsonBuilder.Append(clazzModel.ClassNo.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("主观分数"); jsonBuilder.Append("\":\""); jsonBuilder.Append(examdetailscoreModel.SubjectiveScore.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("客观分数"); jsonBuilder.Append("\":\""); jsonBuilder.Append(examdetailscoreModel.ObjectiveScore.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("总分数"); jsonBuilder.Append("\":\""); jsonBuilder.Append(examdetailscoreModel.TotalScore.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); for (int j = 0; j < examDetailList.Count; j++) { var examDetailScore = examDetailScoreList.Where(d => d.ExamDetailId == examDetailList[j].Id && d.studentid == item.Id).FirstOrDefault(); jsonBuilder.Append("\""); jsonBuilder.Append(examDetailList[j].Name); jsonBuilder.Append("\":\""); jsonBuilder.Append(examDetailScore.StudentScore.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilder.Append("},"); } for (int j = 0; j < examDetailList.Count; j++) { jsonBuilderHeader.Append("{\"prop\": \"" + examDetailList[j].Name + "\", \"label\": \"" + examDetailList[j].Name + "\"},"); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilderHeader.Remove(jsonBuilderHeader.Length - 1, 1); jsonBuilder.Append("]"); jsonBuilderHeader.Append("]"); ObjectiveStudent objectiveStudent = new ObjectiveStudent() { Header = jsonBuilderHeader.ObjToString(), Content = jsonBuilder.ObjToString() }; return(new MessageModel <ObjectiveStudent>() { msg = "获取成功", success = true, response = objectiveStudent }); }