You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

299 lines
9.8 KiB

  1. using System;
  2. using Learun.Util;
  3. using System.Data;
  4. using System.Web.Mvc;
  5. using System.Collections.Generic;
  6. using Learun.Application.TwoDevelopment.EducationalAdministration;
  7. using Learun.Application.TwoDevelopment.EvaluationTeach;
  8. using System.Linq;
  9. namespace Learun.Application.Web.Areas.EvaluationTeach.Controllers
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2019-04-23 15:50
  16. /// 描 述:问卷管理
  17. /// </summary>
  18. public class Eval_MainController : MvcControllerBase
  19. {
  20. private Eval_MainIBLL ask_MainIBLL = new Eval_MainBLL();
  21. private EmpInfoIBLL empInfoIbll = new EmpInfoBLL();
  22. private StuInfoBasicIBLL stuInfoBasicIbll = new StuInfoBasicBLL();
  23. private LessonInfoIBLL lessonInfoIbll = new LessonInfoBLL();
  24. #region 视图功能
  25. /// <summary>
  26. /// 主页面
  27. /// <summary>
  28. /// <returns></returns>
  29. [HttpGet]
  30. public ActionResult Index()
  31. {
  32. return View();
  33. }
  34. [HttpGet]
  35. public ActionResult AnswerIndex()
  36. {
  37. return View();
  38. }
  39. [HttpGet]
  40. public ActionResult TeacherIndex()
  41. {
  42. return View();
  43. }
  44. [HttpGet]
  45. public ActionResult TeacherIndex2()
  46. {
  47. return View();
  48. }
  49. [HttpGet]
  50. public ActionResult StudentIndex()
  51. {
  52. var logininfo = LoginUserInfo.Get();
  53. ViewBag.StuNo = logininfo.account;
  54. ViewBag.StuName = logininfo.realName;
  55. var yearsemester = Common.GetSemesterAndYear();
  56. ViewBag.AcademicYearNo = yearsemester.AcademicYearShort;
  57. ViewBag.Semester = yearsemester.Semester;
  58. return View();
  59. }
  60. [HttpGet]
  61. public ActionResult AnswerQuery()
  62. {
  63. return View();
  64. }
  65. [HttpGet]
  66. public ActionResult Paper(string VID)
  67. {
  68. ViewBag.StuNo = LoginUserInfo.Get().account;
  69. ViewBag.StuName = LoginUserInfo.Get().realName;
  70. if (!string.IsNullOrEmpty(VID))
  71. {
  72. var Eval_Main = ask_MainIBLL.GetEval_MainEntityAndQuestions(VID);
  73. return View(Eval_Main);
  74. }
  75. else
  76. {
  77. return View();
  78. }
  79. }
  80. [HttpGet]
  81. public ActionResult PaperAdminView(string VID)
  82. {
  83. ViewBag.StuNo = LoginUserInfo.Get().account;
  84. ViewBag.StuName = LoginUserInfo.Get().realName;
  85. if (!string.IsNullOrEmpty(VID))
  86. {
  87. var Eval_Main = ask_MainIBLL.GetEval_MainEntityAndQuestions(VID);
  88. return View(Eval_Main);
  89. }
  90. else
  91. {
  92. return View();
  93. }
  94. }
  95. [HttpGet]
  96. public ActionResult PaperView(string VID, string StuNo, string EmpNo, string LessonNo)
  97. {
  98. if (!string.IsNullOrEmpty(VID))
  99. {
  100. var Eval_Main = ask_MainIBLL.GetEval_MainEntityAndQuestionsResult(VID, StuNo, EmpNo, LessonNo);
  101. Eval_Main.StuName = stuInfoBasicIbll.GetStuInfoBasicEntityByStuNo(StuNo).StuName;
  102. Eval_Main.EmpName = empInfoIbll.GetEmpInfoEntityByEmpNo(EmpNo).EmpName;
  103. Eval_Main.LessonName = lessonInfoIbll.GetLessonInfoEntityByLessonNo(LessonNo).LessonName;
  104. return View(Eval_Main);
  105. }
  106. else
  107. {
  108. return View();
  109. }
  110. }
  111. /// <summary>
  112. /// 表单页
  113. /// <summary>
  114. /// <returns></returns>
  115. [HttpGet]
  116. public ActionResult Form()
  117. {
  118. ViewBag.VSerial = "EvaluationTeach_" + CommonHelper.CreateNo();
  119. return View();
  120. }
  121. #endregion
  122. #region 获取数据
  123. [HttpGet]
  124. public ActionResult GenerateNearByAcademic()
  125. {
  126. return Success(Learun.Util.WebHelper.GenerateNearByAcademic());
  127. }
  128. /// <summary>
  129. /// 获取页面显示列表数据
  130. /// <summary>
  131. /// <param name="queryJson">查询参数</param>
  132. /// <returns></returns>
  133. [HttpGet]
  134. [AjaxOnly]
  135. public ActionResult GetPageList(string pagination, string queryJson)
  136. {
  137. Pagination paginationobj = pagination.ToObject<Pagination>();
  138. var data = ask_MainIBLL.GetPageList(paginationobj, queryJson);
  139. var jsonData = new
  140. {
  141. rows = data,
  142. total = paginationobj.total,
  143. page = paginationobj.page,
  144. records = paginationobj.records
  145. };
  146. return Success(jsonData);
  147. }
  148. [HttpGet]
  149. [AjaxOnly]
  150. public ActionResult GetStudentPageList(string pagination, string queryJson)
  151. {
  152. var data = ask_MainIBLL.GetStudentPageList(null, queryJson);
  153. return Success(data);
  154. }
  155. [HttpGet]
  156. [AjaxOnly]
  157. public ActionResult GetAnswerPageList(string pagination, string queryJson)
  158. {
  159. Pagination paginationobj = pagination.ToObject<Pagination>();
  160. var data = ask_MainIBLL.GetAnswerPageList(paginationobj, queryJson);
  161. var jsonData = new
  162. {
  163. rows = data,
  164. total = paginationobj.total,
  165. page = paginationobj.page,
  166. records = paginationobj.records
  167. };
  168. return Success(jsonData);
  169. }
  170. [HttpGet]
  171. [AjaxOnly]
  172. public ActionResult GetTeacherIndexPageList(string pagination, string queryJson)
  173. {
  174. var data = ask_MainIBLL.GetTeacherIndexPageList2(null, queryJson);
  175. return Success(data);
  176. }
  177. [HttpGet]
  178. [AjaxOnly]
  179. public ActionResult GetTeacherIndexPageList2(string pagination, string queryJson)
  180. {
  181. var data = ask_MainIBLL.GetTeacherIndexPageList2(null, queryJson);
  182. var data2 = data.GroupBy(x => x.EmpNo).Select(x => new Eval_QuestionResultEntity()
  183. {
  184. EmpNo = x.Key,
  185. EmpName = x.Select(y => y.EmpName).FirstOrDefault(),
  186. LessonNo = String.Join(",", x.Select(y => y.LessonNo).ToArray()),
  187. StudentCount = x.Select(y => y.StudentCount).Sum(),
  188. EvalCount = x.Select(y => y.EvalCount).Sum(),
  189. EvalTotalScore = x.Select(y => y.EvalTotalScore).Sum(),
  190. AverageScore = x.Select(y => y.EvalCount).Sum() > 0 ? Math.Round((x.Select(y => y.EvalTotalScore).Sum() / x.Select(y => y.EvalCount).Sum()).ToDecimal(), 2, MidpointRounding.AwayFromZero) : 0
  191. });
  192. return Success(data2);
  193. }
  194. /// <summary>
  195. /// 获取表单数据
  196. /// <summary>
  197. /// <returns></returns>
  198. [HttpGet]
  199. [AjaxOnly]
  200. public ActionResult GetFormData(string keyValue)
  201. {
  202. var Eval_MainData = ask_MainIBLL.GetEval_MainEntity(keyValue);
  203. var jsonData = new
  204. {
  205. Eval_Main = Eval_MainData,
  206. };
  207. return Success(jsonData);
  208. }
  209. #endregion
  210. #region 提交数据
  211. /// <summary>
  212. /// 删除实体数据
  213. /// <param name="keyValue">主键</param>
  214. /// <summary>
  215. /// <returns></returns>
  216. [HttpPost]
  217. [AjaxOnly]
  218. public ActionResult DeleteForm(string keyValue)
  219. {
  220. ask_MainIBLL.DeleteEntity(keyValue);
  221. return Success("删除成功!");
  222. }
  223. [HttpPost]
  224. [AjaxOnly]
  225. public ActionResult SubmitForm(string keyValue)
  226. {
  227. if (ask_MainIBLL.HasEnabled(keyValue))
  228. return Fail("操作失败!仅允许启用一条数据。");
  229. ask_MainIBLL.ChangeFormStatus(keyValue, true);
  230. return Success("操作成功!");
  231. }
  232. [HttpPost]
  233. [AjaxOnly]
  234. public ActionResult UnSubmitForm(string keyValue)
  235. {
  236. ask_MainIBLL.ChangeFormStatus(keyValue, false);
  237. return Success("操作成功!");
  238. }
  239. /// <summary>
  240. /// 保存实体数据(新增、修改)
  241. /// <param name="keyValue">主键</param>
  242. /// <summary>
  243. /// <returns></returns>
  244. [HttpPost]
  245. [ValidateAntiForgeryToken]
  246. [AjaxOnly]
  247. public ActionResult SaveForm(string keyValue, string strEntity)
  248. {
  249. var userinfo = LoginUserInfo.Get();
  250. Eval_MainEntity entity = strEntity.ToObject<Eval_MainEntity>();
  251. entity.UID = userinfo.userId;
  252. entity.UName = userinfo.realName;
  253. entity.VCreateTime = DateTime.Now;
  254. entity.Status = false;
  255. ask_MainIBLL.SaveEntity(keyValue, entity);
  256. return Success("保存成功!");
  257. }
  258. [HttpPost]
  259. [ValidateAntiForgeryToken]
  260. [AjaxOnly]
  261. [ValidateInput(false)]
  262. public ActionResult StudentSubmitForm(string answerlist, string VID, string LessonNo, string EmpNo)
  263. {
  264. var userinfo = LoginUserInfo.Get();
  265. //判断当前课程、教师是否已评
  266. if (ask_MainIBLL.GetQuestionResultCount(VID,userinfo.account,EmpNo,LessonNo).Count()>0)
  267. {
  268. return Fail("检测到您已对当前教师课程进行过评教操作,请勿重复提交。");
  269. }
  270. List<Eval_QuestionResultEntity> entity = answerlist.ToObject<List<Eval_QuestionResultEntity>>();
  271. ask_MainIBLL.SaveEval_QuestionResultEntity(entity, VID, LessonNo, EmpNo, userinfo.account, userinfo.realName, userinfo.iPAddress);
  272. return Success("保存成功!");
  273. }
  274. #endregion
  275. }
  276. }