public async Task <ServiceResultOfT <ScoreModel> > Add(StudentScoreViewModel model) { var student = model.studentScore; var result = await _studentService.AddStudentAsync(student); return(result); }
public async Task <IActionResult> Details(int id) { var result = await _studentService.GetStudentAsync(id); var studentViewModel = new StudentScoreViewModel { studentScore = result.Entities }; return(View(studentViewModel)); }
public async Task <IActionResult> StudentScore(int id) { var model = new StudentScoreViewModel(); model.Student = await stu.GetByIdAsync(id); model.SSM = mx.GetScoreById(id); if (model == null) { ViewBag.message = "null"; return(View()); } return(View(model)); }
public async Task <IActionResult> Index() { var result = await _studentService.GetAllAsync(); if (result.Code == ServiceResultCode.Unauthorized) { RedirectToAction(); } var studentViewModel = new StudentScoreViewModel { studentScores = result.Entities }; return(View(studentViewModel)); }
public ActionResult LoadScore(int id) { Student student = db.Students.SingleOrDefault(s => s.Id == id); StudentScoreViewModel model = new StudentScoreViewModel(); if (student != null) { model.StudentName = student.Name; model.Scores = student.Scores.Select(sc => new ScoreInfoViewModel { ScoreName = sc.Course.CourseName, ScoreValue = sc.Value ?? 0 }).ToList(); model.Total = model.Scores.Sum(sc => sc.ScoreValue); } return(PartialView("PartialStudentScore", model)); }
/// <summary> /// 班级学生成绩提交页面Html /// </summary> /// <returns></returns> public ActionResult OriginalScore() { var studentScoreViewModel = new StudentScoreViewModel(); var originalScoreResponseViewModel = new OriginalScoreResponseViewModel(); var yearTerm = Request["SchYearTerm"]; var examId = Request["SchExam"]; var gradeCode = Request["SchGrade"]; var classCode = Request["SchClass"]; var subjectName = Request["SchSubject"]; var kldm = Request["SchKLDM"]; SqlParameter[] para = new SqlParameter[5]; para[0] = new SqlParameter("@ExamId", new Guid(examId)); para[1] = new SqlParameter("@SchId", schoolId); para[2] = new SqlParameter("@ExamNJ", gradeCode); para[3] = new SqlParameter("@ExamKL", kldm); para[4] = new SqlParameter("@ClassCode", classCode); var studentScoreByPrimary = _examService.GetStudentScoreByPrimary(para).Where(w => w.SubjectName == subjectName).ToList(); if (studentScoreByPrimary.Any()) { #region 数据处理 originalScoreResponseViewModel.OriginalScoreList = studentScoreByPrimary; var studentList = studentScoreByPrimary.Select(s => new StudentScoreViewModel { StudentId = s.XSID, SchoolName = s.XXMC, GradeCode = s.NJDM, GradeName = s.NJMC, ClassName = s.BJMC, StudentName = s.XSXM, StuClassCode = s.KLDM, StudentCardNumber = s.SFZHM, StuSchoolNumber = s.KSH }).GroupBy(g => g.StudentCardNumber).Select(s => s.First()).ToList(); originalScoreResponseViewModel.StudentList = studentList; var subjectList = _examService.GetSubjectByExamIdList(new Guid(examId)).Where(w => w.SubjectName == subjectName) .Select( s => new View_Exam_ExamSubject { SubjectCode = s.SubjectCode, SubjectName = s.SubjectName }) .GroupBy(g => g.SubjectCode).Select(s => s.First()).OrderBy(o => o.SubjectCode).ToList(); originalScoreResponseViewModel.SubjectList = subjectList; #endregion #region 生成图表数据 try { List <Series> serList = new List <Series>(); string[] studentNames = new string[studentList.Count]; #region 学科生成图表 Series s = new Series(); s.id = 1; s.type = "column"; s.name = subjectName; decimal[] d = new decimal[studentList.Count]; List <StudentRankViewModel> rankList = new List <StudentRankViewModel>(); for (int j = 0; j < studentList.Count; j++) { var stuScore = studentScoreByPrimary.Where( w => w.SFZHM == studentList[j].StudentCardNumber && w.SubjectName == subjectName).ToList(); var rank = new StudentRankViewModel(); var studentName = studentList[j].StudentName; var ai = 1; while (studentNames.Contains(studentList[j].StudentName)) { studentName = studentList[j].StudentName + "_" + ai++; } rank.StudentName = studentName; studentNames[j] = studentName; var examScore = stuScore.FirstOrDefault(w => w.RankType == "班名次"); if (examScore != null) { rank.ClassRank = examScore.ScoreRank; d[j] = examScore.Score; } else { rank.ClassRank = 0; d[j] = 0; } var schoolRank = stuScore.FirstOrDefault(w => w.RankType == "校名次"); if (schoolRank != null) { rank.SchoolRank = schoolRank.ScoreRank; } else { rank.SchoolRank = 0; } var areaRank = stuScore.FirstOrDefault(w => w.RankType == "区名次"); if (areaRank != null) { rank.AreaRank = areaRank.ScoreRank; } else { rank.AreaRank = 0; } rankList.Add(rank); } s.Score = d; serList.Add(s); studentScoreViewModel.StudentNames = studentNames; studentScoreViewModel.SeriesList = serList; studentScoreViewModel.StuRankList = rankList; #endregion } catch (Exception ex) { } #endregion } //页面图形数据 ViewBag.StudentScoreViewModel = NewtonsoftJson(studentScoreViewModel); return(View("OriginalScore", originalScoreResponseViewModel)); }
/// <summary> /// 获取学生年度成绩详情Html /// </summary> /// <returns></returns> public ActionResult StudentYearAllScoreDetails() { var examId = Request["ExamId"]; var studentId = Request["StudentId"]; var gradeCode = Request["GradeCode"]; var classTypeCode = Request["ClassTypeCode"]; var yearTerm = Request["YearTerm"]; var originalScoreResponseViewModel = new OriginalScoreResponseViewModel(); var studentScoreViewModel = new StudentScoreViewModel(); List <StudentRankViewModel> rankList = new List <StudentRankViewModel>(); var year = yearTerm.Substring(0, 4) + "-" + (Convert.ToInt32(yearTerm.Substring(0, 4)) + 1); var term = yearTerm.Substring(4, 1); switch (classTypeCode) { case "不分科": classTypeCode = "0"; break; case "文科": classTypeCode = "1"; break; case "理科": classTypeCode = "2"; break; } SqlParameter[] para = new SqlParameter[6]; para[0] = new SqlParameter("@SchId", schoolId); para[1] = new SqlParameter("@StudentId", studentId); para[2] = new SqlParameter("@GradeCode", gradeCode); para[3] = new SqlParameter("@ClassTypeCode", classTypeCode); para[4] = new SqlParameter("@Year", year); para[5] = new SqlParameter("@Term", term); var studentScoreByPrimary = _examService.GetStudentYearScoreByPrimary(para).ToList(); if (studentScoreByPrimary.Any()) { #region 数据处理 originalScoreResponseViewModel.OriginalScoreList = studentScoreByPrimary; var examList = studentScoreByPrimary.Select(s => new ExamViewModel { ExamId = s.ExamId, ExamName = s.ExamName }) .GroupBy(g => g.ExamId) .Select(s => s.First()) .ToList(); originalScoreResponseViewModel.ExamList = examList; var examIdList = examList.Select(s => s.ExamId).ToList(); var subjectList = _examService.GetSubjectByExamIdsList(examIdList) .Select( s => new View_Exam_ExamSubject { SubjectCode = s.SubjectCode, SubjectName = s.SubjectName }) .GroupBy(g => g.SubjectCode).Select(s => s.First()).OrderBy(o => o.SubjectCode).ToList(); subjectList.Add(new View_Exam_ExamSubject { SubjectName = "总分" }); #endregion #region 生成图表数据 List <Series> serList = new List <Series>(); string[] examNames = new string[examList.Count]; for (int i = 0; i < examList.Count; i++) { var name = examList[i].ExamName; var ai = 1; while (examNames.Contains(examList[i].ExamName)) { name = examList[i].ExamName + "_" + ai++; } examNames[i] = name; } for (int i = 0; i < subjectList.Count; i++) { Series s1 = new Series(); s1.id = 1; s1.type = "column"; s1.name = subjectList[i].SubjectName; decimal[] d = new decimal[examList.Count]; var names = new string[examList.Count]; for (int j = 0; j < examList.Count; j++) { var stuScore = studentScoreByPrimary.Where( w => w.ExamName == examList[j].ExamName && w.SubjectName == subjectList[i].SubjectName).ToList(); if (stuScore.Any()) { var rank = new StudentRankViewModel(); var examName = examList[j].ExamName; var ai = 1; while (names.Contains(examList[j].ExamName)) { examName = examList[j].ExamName + "_" + ai++; } rank.SubjectName = subjectList[i].SubjectName; rank.StudentName = examName; names[j] = examName; var examScore = stuScore.FirstOrDefault(w => w.RankType == "班名次"); if (examScore != null) { rank.ClassRank = examScore.ScoreRank; d[j] = examScore.Score; } else { rank.ClassRank = 0; d[j] = 0; } var schoolRank = stuScore.FirstOrDefault(w => w.RankType == "校名次"); if (schoolRank != null) { rank.SchoolRank = schoolRank.ScoreRank; } else { rank.SchoolRank = 0; } var areaRank = stuScore.FirstOrDefault(w => w.RankType == "区名次"); if (areaRank != null) { rank.AreaRank = areaRank.ScoreRank; } else { rank.AreaRank = 0; } rankList.Add(rank); } } s1.Score = d; serList.Add(s1); } studentScoreViewModel.StudentNames = examNames; studentScoreViewModel.SeriesList = serList; studentScoreViewModel.StuRankList = rankList; #endregion subjectList.Add(new View_Exam_ExamSubject { SubjectName = "参考总分" }); originalScoreResponseViewModel.SubjectList = subjectList; } ViewBag.StudentScoreViewModel = NewtonsoftJson(studentScoreViewModel); return(View(originalScoreResponseViewModel)); }