CourseScoreServices.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMISOnline.DataLogic.Repositories;
  6. using EMISOnline.DataLogic.Student;
  7. using EMISOnline.ViewModel.Student;
  8. using EMISOnline.Entities;
  9. using System.Linq.Expressions;
  10. using Bowin.Common.Linq.Entity;
  11. using Bowin.Common.Linq;
  12. namespace EMISOnline.CommonLogic.StudentServices
  13. {
  14. public class CourseScoreServices : ICourseScoreServices
  15. {
  16. //public TeacherScoreRepository teacherScoreRepository { get; set; }
  17. //public LoginCountRepository loginCountRepository { get; set; }
  18. public CoursematerialDAL CoursematerialDAL { get; set; }
  19. public SchoolyearDAL SchoolyearDAL { get; set; }
  20. public CourseScoreDAL courseScoreDAL { get; set; }
  21. public CorseStudyScoreView getCorseStudyScoreInfo(Guid? CoursematerialID, Guid UserID)
  22. {
  23. CorseStudyScoreView model = new CorseStudyScoreView();
  24. var scoreRule = CoursematerialDAL.GetScoreRule();
  25. var teacherscore = CoursematerialDAL.teacherScoreRepository.GetSingle(w => w.CoursematerialID == CoursematerialID && w.UserID == UserID);
  26. var curschoolYear=SchoolyearDAL.GetCurSchoolyear();
  27. model.CoursematerialID = CoursematerialID.Value;
  28. var corseModel = CoursematerialDAL.loginCountRepository.UnitOfWork.EM_Coursematerial.FirstOrDefault(w => w.CoursematerialID == CoursematerialID);
  29. model.CourseName = corseModel.CourseName;
  30. if(scoreRule==null)
  31. {
  32. return model;
  33. }
  34. //老师评分
  35. model.TeacherScore = teacherscore!=null && teacherscore.Score.HasValue ? teacherscore.Score.Value : 0;
  36. var maxTeacherScore=(scoreRule.TeacherScore.HasValue?scoreRule.TeacherScore.Value:0);
  37. model.TeacherScore = maxTeacherScore <= model.TeacherScore ? maxTeacherScore : model.TeacherScore;
  38. //登陆成绩
  39. var logincount = CoursematerialDAL.loginCountRepository.GetSingle(w => w.SchoolyearID == curschoolYear.SchoolyearID && w.UserID == UserID);
  40. if (logincount == null)
  41. {
  42. model.loginScore = 0;
  43. }
  44. else
  45. {
  46. decimal loginScore = (scoreRule.LoginEachTime.HasValue?scoreRule.LoginEachTime.Value:0) * (logincount.LoginCount.HasValue?logincount.LoginCount.Value:0);
  47. model.loginScore = loginScore >= scoreRule.LoginMax.Value ? scoreRule.LoginMax.Value : loginScore;
  48. }
  49. //课程评分
  50. var courseStudy = CoursematerialDAL.loginCountRepository.UnitOfWork.EM_CourseStudyStatus.FirstOrDefault(w => w.CoursematerialID == CoursematerialID && w.UserID == UserID);
  51. if (courseStudy == null)
  52. {
  53. model.StudyRate = 0;
  54. model.studyScore = 0;
  55. }
  56. else
  57. {
  58. int LastCourseVideoLength = courseStudy.LastCourseVideoLength.HasValue ? courseStudy.LastCourseVideoLength.Value : 0;
  59. var LastCourseVideoMin = LastCourseVideoLength / 60;
  60. var curCoursewareScore = (scoreRule.CoursewareEachTime.HasValue?scoreRule.CoursewareEachTime.Value:0) * LastCourseVideoMin;
  61. var CoursewareMax=scoreRule.CoursewareMax.HasValue ? scoreRule.CoursewareMax.Value : 0;
  62. model.studyScore = CoursewareMax <= curCoursewareScore ? curCoursewareScore : CoursewareMax;
  63. model.StudyRate = Math.Round(model.studyScore / CoursewareMax, 3);
  64. }
  65. //作业成绩
  66. model.homeWorkScore = 0;//等作业设置
  67. model.TitleScore = model.TeacherScore + model.studyScore + model.loginScore + model.homeWorkScore;
  68. return model;
  69. }
  70. public IGridResultSet<studentEducationMissionClassAddView> CorseStudyScoreList(int pageIndex, int pageSize, string CoursematerialName, string Years,Guid UserID)
  71. {
  72. var sql = courseScoreDAL.getStudentEducationAdd(UserID, CoursematerialName, Years);
  73. var datas=sql.OrderByDescending(o=>o.yearCode).ThenByDescending(o=>o.EducationMissionClassID).ToGridResultSet(pageIndex, pageSize);
  74. //添加成绩计算成绩
  75. datas.rows.ForEach(it => it.CorseStudyScoreModel = getCorseStudyScoreInfo(it.CoursematerialID,it.UserID));
  76. return datas;
  77. }
  78. }
  79. }