using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMISOnline.CommonLogic.StudentServices; using EMISOnline.Entities; using Bowin.Web.Controls.Mvc; using EMISOnline.ViewModel.Student; using EMISOnline.ViewModel; namespace EMISOnline.Web.Controllers { [Authorization] public class StudentController : Controller { public ISchoolyearServices SchoolyearServices { get; set; } public ICoursematerialServices CoursematerialServices { get; set; } public ICourseScoreServices scoreServices { get; set; } public ICourseExamServices courseExamServices { get; set; } public ActionResult Index() { var user = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal; var Schoolyear = SchoolyearServices.GetStudentSchollyear(user.UserID); if(Schoolyear!=null) { ViewBag.Schoolyear = Schoolyear; var list=CoursematerialServices.GetStudentCoursematerialList(user.UserID, Schoolyear.SchoolyearID); ViewBag.CoursList = list.Select(s=>new StudentEducationinfoView(){ StudentEducation=s, CorseStudyScore = scoreServices.getCorseStudyScoreInfo(s.CoursematerialID,s.UserID) }).ToList(); } //20151301104 return View(); } public ActionResult OuterPlayer(Guid? coursematerialID, string playUrl, int? courseContinueTime) { return View(); } public ActionResult CoursematerialInfo(Guid EducationMissionClassID) { var user = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal; V_StudentEducationMissionClass plan = CoursematerialServices.GetEducationMissionClass(EducationMissionClassID); EM_CourseStudyStatus csStatus = CoursematerialServices.GetCourseStudyStatusByUser(plan.CoursematerialID, user.UserID); var scoreRule = CoursematerialServices.getScoreRule(); //视频播放的总长度 ViewBag.ContinuousTime = csStatus.ContinuousTime; ViewBag.scoreRule = scoreRule; //最后一次播放的视频信息 ViewBag.LastCourseVideoLength = csStatus.LastCourseVideoLength; var CoureseStudyMin=csStatus.ContinuousTime.Value / 60; ViewBag.CoureseStudyMin = CoureseStudyMin; ViewBag.CoursewareScore = CoureseStudyMin * scoreRule.CoursewareEachTime > scoreRule.CoursewareMax ? scoreRule.CoursewareMax : CoureseStudyMin * scoreRule.CoursewareEachTime; ViewBag.LastVideoTypeID = csStatus.LastVideoTypeID; ViewBag.LocalVideoTypeID = (int)EM_OnlineVideoType.Local; ViewBag.LastOuterVideoUrl = csStatus.LastOuterVideoUrl; EM_CourseVideo cv = null; EM_CourseChapter cc=null; if (csStatus.LastCourseVideoID.HasValue) { cv = CoursematerialServices.GetCourseVideo(csStatus.LastCourseVideoID.Value); } else { cv = CoursematerialServices.GetFirstCourseVideo(plan.CoursematerialID); } if (cv != null) { ViewBag.LastCourseVideoID = cv.CourseVideoID; ViewBag.LastCourseVideoUrl = cv.PlayUrl; ViewBag.LastOuterVideoUrl = csStatus.LastOuterVideoUrl; //因为CV获取的是本地视频,所以无论什么结果视频类型都是本地 ViewBag.LastVideoTypeID = (int)EM_OnlineVideoType.Local; } else { //如果没有本地视频在找有没有外部视频 cc = CoursematerialServices.GetOutPlayUrl(plan.CoursematerialID); if (cc != null) { ViewBag.LastCourseVideoID = null; ViewBag.LastCourseVideoUrl = ""; ViewBag.LastOuterVideoUrl = cc.OuterVideoUrl; //因为CC获取的是本地视频,所以无论什么结果视频类型都是外部 ViewBag.LastVideoTypeID = (int)EM_OnlineVideoType.Outer; } else { ViewBag.LastCourseVideoID = ""; ViewBag.LastCourseVideoUrl = ""; } } return View(plan); } /// /// 课程章节列表 /// /// /// public ActionResult CourseChapterTree(Guid CoursematerialID) { List list = CoursematerialServices.GetCourseChapterTree(CoursematerialID); return base.Json(list, JsonRequestBehavior.AllowGet); } public ActionResult SaveCourseStudyStatus(Guid CoursematerialID, int ContinuousTime, int? LastVideoTypeID, int? LastCourseVideoLength, Guid? LastCourseVideoID, string LastOuterVideoUrl) { EM_CourseStudyStatus csStatus = new EM_CourseStudyStatus(); csStatus.CoursematerialID = CoursematerialID; csStatus.ContinuousTime = ContinuousTime; csStatus.LastVideoTypeID = LastVideoTypeID; csStatus.LastCourseVideoLength = LastCourseVideoLength; csStatus.LastCourseVideoID = LastCourseVideoID; csStatus.LastOuterVideoUrl = LastOuterVideoUrl; var user = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal; csStatus.UserID = user.UserID; CoursematerialServices.SaveCourseStudyStatusByUser(csStatus); return base.Json(new { rtn = true }, JsonRequestBehavior.AllowGet); } public ActionResult studentscorelist() { return View(); } public JsonResult SudentScoreDatas(int page, int rows, string CoursematerialName, string Years) { var user = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal; var list = scoreServices.CorseStudyScoreList(page, rows, CoursematerialName, Years, user.UserID); return Json(list, JsonRequestBehavior.AllowGet); } public ActionResult ExamIndex() { return View(); } public JsonResult ExamStatusItems() { List list=new List(); courseExamServices.getExamResult_state().ForEach(it =>list.Add(new DropdownListItem() { Text=it.Name,Value=it.Value })); return base.Json(list); } public JsonResult ExamListbyUser(int page, int rows, string CourseName,int? ExamStatus) { var user = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal; var datas = courseExamServices.getCourseExamList(CourseName, ExamStatus, user.UserID, page, rows); return Json(datas, JsonRequestBehavior.AllowGet); } public ActionResult HomeWorkIndex(Guid educationMissionClassID) { return View(); } public JsonResult HomeWorkList(Guid educationMissionClassID) { var user = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal; return Json(null, JsonRequestBehavior.AllowGet); } } }