123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMISOnline.DataLogic.Repositories;
- using EMISOnline.DataLogic.Student;
- using EMISOnline.ViewModel.Student;
- using EMISOnline.Entities;
- using System.Linq.Expressions;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Linq;
- namespace EMISOnline.CommonLogic.StudentServices
- {
- public class CourseScoreServices : ICourseScoreServices
- {
- //public TeacherScoreRepository teacherScoreRepository { get; set; }
- //public LoginCountRepository loginCountRepository { get; set; }
- public CoursematerialDAL CoursematerialDAL { get; set; }
- public SchoolyearDAL SchoolyearDAL { get; set; }
- public CourseScoreDAL courseScoreDAL { get; set; }
- public CorseStudyScoreView getCorseStudyScoreInfo(Guid? CoursematerialID, Guid UserID)
- {
- CorseStudyScoreView model = new CorseStudyScoreView();
- var scoreRule = CoursematerialDAL.GetScoreRule();
- var teacherscore = CoursematerialDAL.teacherScoreRepository.GetSingle(w => w.CoursematerialID == CoursematerialID && w.UserID == UserID);
- var curschoolYear=SchoolyearDAL.GetCurSchoolyear();
- model.CoursematerialID = CoursematerialID.Value;
- var corseModel = CoursematerialDAL.loginCountRepository.UnitOfWork.EM_Coursematerial.FirstOrDefault(w => w.CoursematerialID == CoursematerialID);
- model.CourseName = corseModel.CourseName;
- if(scoreRule==null)
- {
- return model;
- }
- //老师评分
- model.TeacherScore = teacherscore!=null && teacherscore.Score.HasValue ? teacherscore.Score.Value : 0;
- var maxTeacherScore=(scoreRule.TeacherScore.HasValue?scoreRule.TeacherScore.Value:0);
- model.TeacherScore = maxTeacherScore <= model.TeacherScore ? maxTeacherScore : model.TeacherScore;
- //登陆成绩
- var logincount = CoursematerialDAL.loginCountRepository.GetSingle(w => w.SchoolyearID == curschoolYear.SchoolyearID && w.UserID == UserID);
- if (logincount == null)
- {
- model.loginScore = 0;
- }
- else
- {
- decimal loginScore = (scoreRule.LoginEachTime.HasValue?scoreRule.LoginEachTime.Value:0) * (logincount.LoginCount.HasValue?logincount.LoginCount.Value:0);
- model.loginScore = loginScore >= scoreRule.LoginMax.Value ? scoreRule.LoginMax.Value : loginScore;
- }
- //课程评分
- var courseStudy = CoursematerialDAL.loginCountRepository.UnitOfWork.EM_CourseStudyStatus.FirstOrDefault(w => w.CoursematerialID == CoursematerialID && w.UserID == UserID);
- if (courseStudy == null)
- {
- model.StudyRate = 0;
- model.studyScore = 0;
- }
- else
- {
- int LastCourseVideoLength = courseStudy.LastCourseVideoLength.HasValue ? courseStudy.LastCourseVideoLength.Value : 0;
- var LastCourseVideoMin = LastCourseVideoLength / 60;
- var curCoursewareScore = (scoreRule.CoursewareEachTime.HasValue?scoreRule.CoursewareEachTime.Value:0) * LastCourseVideoMin;
- var CoursewareMax=scoreRule.CoursewareMax.HasValue ? scoreRule.CoursewareMax.Value : 0;
- model.studyScore = CoursewareMax <= curCoursewareScore ? curCoursewareScore : CoursewareMax;
- model.StudyRate = Math.Round(model.studyScore / CoursewareMax, 3);
- }
- //作业成绩
- model.homeWorkScore = 0;//等作业设置
- model.TitleScore = model.TeacherScore + model.studyScore + model.loginScore + model.homeWorkScore;
-
- return model;
- }
- public IGridResultSet<studentEducationMissionClassAddView> CorseStudyScoreList(int pageIndex, int pageSize, string CoursematerialName, string Years,Guid UserID)
- {
- var sql = courseScoreDAL.getStudentEducationAdd(UserID, CoursematerialName, Years);
- var datas=sql.OrderByDescending(o=>o.yearCode).ThenByDescending(o=>o.EducationMissionClassID).ToGridResultSet(pageIndex, pageSize);
- //添加成绩计算成绩
- datas.rows.ForEach(it => it.CorseStudyScoreModel = getCorseStudyScoreInfo(it.CoursematerialID,it.UserID));
- return datas;
- }
-
- }
- }
|