StudentController.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMISOnline.CommonLogic.StudentServices;
  7. using EMISOnline.Entities;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMISOnline.ViewModel.Student;
  10. using EMISOnline.ViewModel;
  11. namespace EMISOnline.Web.Controllers
  12. {
  13. [Authorization]
  14. public class StudentController : Controller
  15. {
  16. public ISchoolyearServices SchoolyearServices { get; set; }
  17. public ICoursematerialServices CoursematerialServices { get; set; }
  18. public ICourseScoreServices scoreServices { get; set; }
  19. public ICourseExamServices courseExamServices { get; set; }
  20. public ActionResult Index()
  21. {
  22. var user = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal;
  23. var Schoolyear = SchoolyearServices.GetStudentSchollyear(user.UserID);
  24. if(Schoolyear!=null)
  25. {
  26. ViewBag.Schoolyear = Schoolyear;
  27. var list=CoursematerialServices.GetStudentCoursematerialList(user.UserID, Schoolyear.SchoolyearID);
  28. ViewBag.CoursList = list.Select(s=>new StudentEducationinfoView(){
  29. StudentEducation=s,
  30. CorseStudyScore = scoreServices.getCorseStudyScoreInfo(s.CoursematerialID,s.UserID)
  31. }).ToList();
  32. }
  33. //20151301104
  34. return View();
  35. }
  36. public ActionResult OuterPlayer(Guid? coursematerialID, string playUrl, int? courseContinueTime)
  37. {
  38. return View();
  39. }
  40. public ActionResult CoursematerialInfo(Guid EducationMissionClassID)
  41. {
  42. var user = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal;
  43. V_StudentEducationMissionClass plan = CoursematerialServices.GetEducationMissionClass(EducationMissionClassID);
  44. EM_CourseStudyStatus csStatus = CoursematerialServices.GetCourseStudyStatusByUser(plan.CoursematerialID, user.UserID);
  45. var scoreRule = CoursematerialServices.getScoreRule();
  46. //视频播放的总长度
  47. ViewBag.ContinuousTime = csStatus.ContinuousTime;
  48. ViewBag.scoreRule = scoreRule;
  49. //最后一次播放的视频信息
  50. ViewBag.LastCourseVideoLength = csStatus.LastCourseVideoLength;
  51. var CoureseStudyMin=csStatus.ContinuousTime.Value / 60;
  52. ViewBag.CoureseStudyMin = CoureseStudyMin;
  53. ViewBag.CoursewareScore = CoureseStudyMin * scoreRule.CoursewareEachTime > scoreRule.CoursewareMax ? scoreRule.CoursewareMax : CoureseStudyMin * scoreRule.CoursewareEachTime;
  54. ViewBag.LastVideoTypeID = csStatus.LastVideoTypeID;
  55. ViewBag.LocalVideoTypeID = (int)EM_OnlineVideoType.Local;
  56. ViewBag.LastOuterVideoUrl = csStatus.LastOuterVideoUrl;
  57. EM_CourseVideo cv = null;
  58. EM_CourseChapter cc=null;
  59. if (csStatus.LastCourseVideoID.HasValue)
  60. {
  61. cv = CoursematerialServices.GetCourseVideo(csStatus.LastCourseVideoID.Value);
  62. }
  63. else
  64. {
  65. cv = CoursematerialServices.GetFirstCourseVideo(plan.CoursematerialID);
  66. }
  67. if (cv != null)
  68. {
  69. ViewBag.LastCourseVideoID = cv.CourseVideoID;
  70. ViewBag.LastCourseVideoUrl = cv.PlayUrl;
  71. ViewBag.LastOuterVideoUrl = csStatus.LastOuterVideoUrl;
  72. //因为CV获取的是本地视频,所以无论什么结果视频类型都是本地
  73. ViewBag.LastVideoTypeID = (int)EM_OnlineVideoType.Local;
  74. }
  75. else
  76. {
  77. //如果没有本地视频在找有没有外部视频
  78. cc = CoursematerialServices.GetOutPlayUrl(plan.CoursematerialID);
  79. if (cc != null)
  80. {
  81. ViewBag.LastCourseVideoID = null;
  82. ViewBag.LastCourseVideoUrl = "";
  83. ViewBag.LastOuterVideoUrl = cc.OuterVideoUrl;
  84. //因为CC获取的是本地视频,所以无论什么结果视频类型都是外部
  85. ViewBag.LastVideoTypeID = (int)EM_OnlineVideoType.Outer;
  86. }
  87. else
  88. {
  89. ViewBag.LastCourseVideoID = "";
  90. ViewBag.LastCourseVideoUrl = "";
  91. }
  92. }
  93. return View(plan);
  94. }
  95. /// <summary>
  96. /// 课程章节列表
  97. /// </summary>
  98. /// <param name="CoursematerialID"></param>
  99. /// <returns></returns>
  100. public ActionResult CourseChapterTree(Guid CoursematerialID)
  101. {
  102. List<TreeItem> list = CoursematerialServices.GetCourseChapterTree(CoursematerialID);
  103. return base.Json(list, JsonRequestBehavior.AllowGet);
  104. }
  105. public ActionResult SaveCourseStudyStatus(Guid CoursematerialID, int ContinuousTime, int? LastVideoTypeID, int? LastCourseVideoLength, Guid? LastCourseVideoID, string LastOuterVideoUrl)
  106. {
  107. EM_CourseStudyStatus csStatus = new EM_CourseStudyStatus();
  108. csStatus.CoursematerialID = CoursematerialID;
  109. csStatus.ContinuousTime = ContinuousTime;
  110. csStatus.LastVideoTypeID = LastVideoTypeID;
  111. csStatus.LastCourseVideoLength = LastCourseVideoLength;
  112. csStatus.LastCourseVideoID = LastCourseVideoID;
  113. csStatus.LastOuterVideoUrl = LastOuterVideoUrl;
  114. var user = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal;
  115. csStatus.UserID = user.UserID;
  116. CoursematerialServices.SaveCourseStudyStatusByUser(csStatus);
  117. return base.Json(new { rtn = true }, JsonRequestBehavior.AllowGet);
  118. }
  119. public ActionResult studentscorelist()
  120. {
  121. return View();
  122. }
  123. public JsonResult SudentScoreDatas(int page, int rows, string CoursematerialName, string Years)
  124. {
  125. var user = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal;
  126. var list = scoreServices.CorseStudyScoreList(page, rows, CoursematerialName, Years, user.UserID);
  127. return Json(list, JsonRequestBehavior.AllowGet);
  128. }
  129. public ActionResult ExamIndex()
  130. {
  131. return View();
  132. }
  133. public JsonResult ExamStatusItems()
  134. {
  135. List<DropdownListItem> list=new List<DropdownListItem>();
  136. courseExamServices.getExamResult_state().ForEach(it =>list.Add(new DropdownListItem() { Text=it.Name,Value=it.Value }));
  137. return base.Json(list);
  138. }
  139. public JsonResult ExamListbyUser(int page, int rows, string CourseName,int? ExamStatus)
  140. {
  141. var user = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal;
  142. var datas = courseExamServices.getCourseExamList(CourseName, ExamStatus, user.UserID, page, rows);
  143. return Json(datas, JsonRequestBehavior.AllowGet);
  144. }
  145. public ActionResult HomeWorkIndex(Guid educationMissionClassID)
  146. {
  147. return View();
  148. }
  149. public JsonResult HomeWorkList(Guid educationMissionClassID)
  150. {
  151. var user = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal;
  152. return Json(null, JsonRequestBehavior.AllowGet);
  153. }
  154. }
  155. }