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.

Eval_MainController.cs 11 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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. /// <summary>
  122. /// 快速复制
  123. /// <summary>
  124. /// <returns></returns>
  125. [HttpGet]
  126. public ActionResult CopyForm()
  127. {
  128. ViewBag.VSerial = "EvaluationTeach_" + CommonHelper.CreateNo();
  129. return View();
  130. }
  131. #endregion
  132. #region 获取数据
  133. [HttpGet]
  134. public ActionResult GenerateNearByAcademic()
  135. {
  136. return Success(Learun.Util.WebHelper.GenerateNearByAcademic());
  137. }
  138. /// <summary>
  139. /// 获取页面显示列表数据
  140. /// <summary>
  141. /// <param name="queryJson">查询参数</param>
  142. /// <returns></returns>
  143. [HttpGet]
  144. [AjaxOnly]
  145. public ActionResult GetPageList(string pagination, string queryJson)
  146. {
  147. Pagination paginationobj = pagination.ToObject<Pagination>();
  148. var data = ask_MainIBLL.GetPageList(paginationobj, queryJson);
  149. var jsonData = new
  150. {
  151. rows = data,
  152. total = paginationobj.total,
  153. page = paginationobj.page,
  154. records = paginationobj.records
  155. };
  156. return Success(jsonData);
  157. }
  158. [HttpGet]
  159. [AjaxOnly]
  160. public ActionResult GetStudentPageList(string pagination, string queryJson)
  161. {
  162. var data = ask_MainIBLL.GetStudentPageList(null, queryJson);
  163. return Success(data);
  164. }
  165. [HttpGet]
  166. [AjaxOnly]
  167. public ActionResult GetAnswerPageList(string pagination, string queryJson)
  168. {
  169. Pagination paginationobj = pagination.ToObject<Pagination>();
  170. var data = ask_MainIBLL.GetAnswerPageList(paginationobj, queryJson);
  171. var jsonData = new
  172. {
  173. rows = data,
  174. total = paginationobj.total,
  175. page = paginationobj.page,
  176. records = paginationobj.records
  177. };
  178. return Success(jsonData);
  179. }
  180. [HttpGet]
  181. [AjaxOnly]
  182. public ActionResult GetTeacherIndexPageList(string pagination, string queryJson)
  183. {
  184. var data = ask_MainIBLL.GetTeacherIndexPageList2(null, queryJson);
  185. return Success(data);
  186. }
  187. [HttpGet]
  188. [AjaxOnly]
  189. public ActionResult GetTeacherIndexPageList2(string pagination, string queryJson)
  190. {
  191. var data = ask_MainIBLL.GetTeacherIndexPageList2(null, queryJson);
  192. var data2 = data.GroupBy(x => x.EmpNo).Select(x => new Eval_QuestionResultEntity()
  193. {
  194. EmpNo = x.Key,
  195. EmpName = x.Select(y => y.EmpName).FirstOrDefault(),
  196. LessonNo = String.Join(",", x.Select(y => y.LessonNo).ToArray()),
  197. StudentCount = x.Select(y => y.StudentCount).Sum(),
  198. EvalCount = x.Select(y => y.EvalCount).Sum(),
  199. EvalTotalScore = x.Select(y => y.EvalTotalScore).Sum(),
  200. 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
  201. });
  202. return Success(data2);
  203. }
  204. /// <summary>
  205. /// 获取表单数据
  206. /// <summary>
  207. /// <returns></returns>
  208. [HttpGet]
  209. [AjaxOnly]
  210. public ActionResult GetFormData(string keyValue)
  211. {
  212. var Eval_MainData = ask_MainIBLL.GetEval_MainEntity(keyValue);
  213. var jsonData = new
  214. {
  215. Eval_Main = Eval_MainData,
  216. };
  217. return Success(jsonData);
  218. }
  219. #endregion
  220. #region 提交数据
  221. /// <summary>
  222. /// 删除实体数据
  223. /// <param name="keyValue">主键</param>
  224. /// <summary>
  225. /// <returns></returns>
  226. [HttpPost]
  227. [AjaxOnly]
  228. public ActionResult DeleteForm(string keyValue)
  229. {
  230. ask_MainIBLL.DeleteEntity(keyValue);
  231. return Success("删除成功!");
  232. }
  233. [HttpPost]
  234. [AjaxOnly]
  235. public ActionResult CleanForm(string VID)
  236. {
  237. //ask_MainIBLL.Clean(VID);
  238. return Success("操作成功!");
  239. }
  240. [HttpPost]
  241. [AjaxOnly]
  242. public ActionResult SubmitForm(string keyValue)
  243. {
  244. if (ask_MainIBLL.HasEnabled(keyValue))
  245. return Fail("操作失败!仅允许启用一条数据。");
  246. ask_MainIBLL.ChangeFormStatus(keyValue, true);
  247. return Success("操作成功!");
  248. }
  249. [HttpPost]
  250. [AjaxOnly]
  251. public ActionResult UnSubmitForm(string keyValue)
  252. {
  253. ask_MainIBLL.ChangeFormStatus(keyValue, false);
  254. return Success("操作成功!");
  255. }
  256. /// <summary>
  257. /// 保存实体数据(新增、修改)
  258. /// <param name="keyValue">主键</param>
  259. /// <summary>
  260. /// <returns></returns>
  261. [HttpPost]
  262. [ValidateAntiForgeryToken]
  263. [AjaxOnly]
  264. public ActionResult SaveForm(string keyValue, string strEntity)
  265. {
  266. var userinfo = LoginUserInfo.Get();
  267. Eval_MainEntity entity = strEntity.ToObject<Eval_MainEntity>();
  268. entity.UID = userinfo.userId;
  269. entity.UName = userinfo.realName;
  270. entity.VCreateTime = DateTime.Now;
  271. entity.Status = false;
  272. ask_MainIBLL.SaveEntity(keyValue, entity);
  273. return Success("保存成功!");
  274. }
  275. [HttpPost]
  276. [ValidateAntiForgeryToken]
  277. [AjaxOnly]
  278. [ValidateInput(false)]
  279. public ActionResult StudentSubmitForm(string answerlist, string VID, string LessonNo, string EmpNo)
  280. {
  281. var userinfo = LoginUserInfo.Get();
  282. //判断当前课程、教师是否已评
  283. if (ask_MainIBLL.GetQuestionResultCount(VID,userinfo.account,EmpNo,LessonNo).Count()>0)
  284. {
  285. return Fail("检测到您已对当前教师课程进行过评教操作,请勿重复提交。");
  286. }
  287. List<Eval_QuestionResultEntity> entity = answerlist.ToObject<List<Eval_QuestionResultEntity>>();
  288. ask_MainIBLL.SaveEval_QuestionResultEntity(entity, VID, LessonNo, EmpNo, userinfo.account, userinfo.realName, userinfo.iPAddress);
  289. return Success("保存成功!");
  290. }
  291. /// <summary>
  292. /// 整体复制
  293. /// </summary>
  294. /// <param name="keyValue"></param>
  295. /// <returns></returns>
  296. [HttpPost]
  297. [AjaxOnly]
  298. public ActionResult DoAllCopy(string keyValue)
  299. {
  300. ask_MainIBLL.DoAllCopy(keyValue);
  301. return Success("操作成功!");
  302. }
  303. #endregion
  304. }
  305. }