CourseworkController.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.CourseworkServices;
  7. using EMISOnline.ViewModel.ExamView;
  8. using EMISOnline.ViewModel;
  9. using System.Web.Script.Serialization;
  10. using EMISOnline.ViewModel.Coursework;
  11. namespace EMISOnline.Web.Controllers.Manage
  12. {
  13. [Authorization]
  14. public partial class CourseworkController : Controller
  15. {
  16. public ICourseworkServices ICourseworkServices { get; set; }
  17. //
  18. // GET: /Coursework/
  19. public ActionResult CourseworkAdd(decimal? workid)
  20. {
  21. CourseworkAddView view = new CourseworkAddView();
  22. if (workid.HasValue){
  23. view = ICourseworkServices.getCourseWork(workid.Value);
  24. }
  25. return View(view);
  26. }
  27. public ActionResult CourseworkList()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 列表查询
  33. /// </summary>
  34. /// <param name="pararms"></param>
  35. /// <returns></returns>
  36. [HttpPost]
  37. public ActionResult List(string testname, int page, int rows)
  38. {
  39. var result = ICourseworkServices.GetCourseworkList(testname, page, rows);
  40. return Json(result);
  41. }
  42. [HttpPost]
  43. public ActionResult CourseworkAdd(CourseworkAddView CourseworkAddView)
  44. {
  45. try
  46. {
  47. var user = ((EMISOnline.Utility.FormValidate.CustomPrincipal)HttpContext.User);
  48. ICourseworkServices.ExamSettingSave(CourseworkAddView, user.LoginID);
  49. return Json(new ReturnMessage()
  50. {
  51. IsSuccess = true,
  52. Message = "保存成功!",
  53. RedictUrl = Url.Content("~/Coursework/CourseworkList")
  54. });
  55. }
  56. catch (Exception ex)
  57. {
  58. return Json(new ReturnMessage()
  59. {
  60. IsSuccess = false,
  61. Message = "保存失败:" + ex.Message
  62. });
  63. }
  64. }
  65. public ActionResult Review(decimal workid)
  66. {
  67. ViewBag.workid = workid;
  68. return View();
  69. }
  70. /// <summary>
  71. /// 列表查询
  72. /// </summary>
  73. /// <param name="pararms"></param>
  74. /// <returns></returns>
  75. [HttpPost]
  76. public ActionResult ReviewList(string testname,decimal workid, int page, int rows)
  77. {
  78. var result = ICourseworkServices.GetReviewList(testname,workid, page, rows);
  79. return Json(result);
  80. }
  81. public ActionResult ShowPaper(decimal ResultID)
  82. {
  83. var result = ICourseworkServices.GetCourseWorkResult(ResultID);
  84. //获取考试试卷(原动态卷)
  85. var testpaper = ICourseworkServices.getPaper(result.workid.Value);
  86. var questions = ICourseworkServices.ShowPaperQuestion(result.workid.Value, testpaper.test_paper_id);
  87. ViewBag.questions = questions;
  88. return View();
  89. }
  90. private Dictionary<string, string> Answers
  91. {
  92. get
  93. {
  94. if (Session["Answers"] == null)
  95. {
  96. var dic = new Dictionary<string, string>();
  97. Session["Answers"] = dic;
  98. return dic;
  99. }
  100. return Session["Answers"] as Dictionary<string, string>;
  101. }
  102. }
  103. private decimal[] QeustionSet
  104. {
  105. get
  106. {
  107. return Session["QeustionSet"] as decimal[];
  108. }
  109. set
  110. {
  111. Session["QeustionSet"] = value;
  112. }
  113. }
  114. }
  115. }