123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- using System;
- using System.Text;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using System.Collections;
- using Bowin.Common.Data;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Utility;
- using Bowin.Web.Controls.Mvc;
- using EMIS.Web.Controls;
- using EMIS.Utility;
- using EMIS.ViewModel;
- using EMIS.ViewModel.EvaluationManage.StudentEvaluation;
- using EMIS.CommonLogic.StudentWeb.Evaluation;
- using EMIS.CommonLogic.EvaluationManage.EvaluationSetting;
- using EMIS.CommonLogic.EvaluationManage.EvaluationTable;
- namespace EMIS.Web.Controllers.StudentWeb.Evaluation
- {
- [Authorization]
- public class StudentEvaluationEnterController : Controller
- {
- public Lazy<IStudentEvaluationEnterServices> StudentEvaluationEnterServices { get; set; }
- public Lazy<IEvaluationNeedServices> EvaluationNeedServices { get; set; }
- public Lazy<IEvaluationTargetServices> EvaluationTargetServices { get; set; }
- public Lazy<IEvaluationNormServices> EvaluationNormServices { get; set; }
- public Lazy<IEvaluationProjectServices> EvaluationProjectServices { get; set; }
- public Lazy<IEvaluationControlServices> EvaluationControlServices { get; set; }
- /// <summary>
- /// 进入评价(学生)页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 进入评价(学生)列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- return base.Json(StudentEvaluationEnterServices.Value.GetStudentEvaluationEnterViewGrid(configuretView, user.UserID, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 进入评价编辑
- /// </summary>
- /// <param name="evaluationStudentID"></param>
- /// <param name="evaluationStudentSettingID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult EnterEdit(Guid? evaluationStudentID, Guid? evaluationStudentSettingID)
- {
- try
- {
- var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- if (user == null)
- {
- throw new Exception("登录超时,请退出系统重新登录。");
- }
- var evaluationControlView = EvaluationControlServices.Value.GetEvaluationControlView();
- if (evaluationControlView == null)
- {
- throw new Exception("当前教学质量评价活动对应的评价学年学期已结束。");
- }
- else
- {
- EvaluationStudentView evaluationStudentView = new EvaluationStudentView();
- if (evaluationStudentSettingID.HasValue && evaluationStudentSettingID != Guid.Empty)
- {
- evaluationStudentView = StudentEvaluationEnterServices.Value.GetStudentEvaluationEnterView(user.UserID, evaluationStudentSettingID);
- if (evaluationStudentView == null)
- {
- throw new Exception("进入评价超时,请刷新页面或退出系统重新登录。");
- }
- if (evaluationStudentView.SchoolyearValue > evaluationControlView.SchoolyearValue)
- {
- throw new Exception("当前教学质量评价活动对应的评价学年学期已结束。");
- }
- if (evaluationStudentView.StartTime == null || evaluationStudentView.EndTime == null)
- {
- throw new Exception("当前教学质量评价活动对应的评价时间未开始。");
- }
- if (DateTime.Now < evaluationStudentView.StartTime)
- {
- throw new Exception("当前教学质量评价活动对应的评价时间未开始。");
- }
- if (DateTime.Now > evaluationStudentView.EndTime)
- {
- throw new Exception("当前教学质量评价活动对应的评价时间已结束。");
- }
- if (((evaluationStudentView.Numbered ?? 0) + 1) > (evaluationStudentView.Number ?? 0))
- {
- throw new Exception("当前教学质量评价活动对应的已评次数已评完。");
- }
- var evaluationNeedView = EvaluationNeedServices.Value.GetEvaluationNeedView((int)EMIS.ViewModel.EM_ParticipateType.Student);
- if (evaluationNeedView == null)
- {
- throw new Exception("评价数据有误,请联系辅导员或教学评价负责老师。");
- }
- ViewBag.EvaluationNeedContent = evaluationNeedView.Content;
- }
- else
- {
- throw new Exception("进入评价超时,请刷新页面或退出系统重新登录。");
- }
- return View(evaluationStudentView);
- }
- }
- catch (Exception ex)
- {
- return RedirectToAction("MsgShow", "Common", new
- {
- WindowID = Request["WindowID"],
- msg = "进入教学质量评价活动失败,请按提示原因进行再次尝试操作(原因:" + ex.Message + ")。",
- url = Url.Action("List").AddMenuParameter()
- });
- }
- }
- /// <summary>
- /// 进入评价编辑
- /// </summary>
- /// <param name="evaluationStudentView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult EnterEdit(EvaluationStudentView evaluationStudentView)
- {
- try
- {
- StudentEvaluationEnterServices.Value.StudentEvaluationEnterEdit(evaluationStudentView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "评价成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "评价失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 评价表格标题
- /// </summary>
- /// <returns></returns>
- public JsonResult FormTitle()
- {
- ArrayList formTitleList = new ArrayList();
- formTitleList.Add(new { field = "OrderNo", title = "次序", align = "center", width = "120" });
- formTitleList.Add(new { field = "EvaluationTargetID", title = "评价指标ID", align = "center", width = "20" });
- formTitleList.Add(new { field = "EvaluationTargetWeight", title = "评价指标权重", align = "center", width = "20" });
- formTitleList.Add(new { field = "EvaluationProjectID", title = "评价项目ID", align = "center", width = "20" });
- formTitleList.Add(new { field = "EvaluationProjectName", title = "评价项目", align = "center", width = "350" });
- formTitleList.Add(new { field = "Weight", title = "权重", align = "center", width = "50" });
- formTitleList.Add(new { field = "EvaluationNormName", title = "评分标准", align = "center", width = "385" });
- return Json(new { UpTitle = JsonHelper.ToJSON(formTitleList) }, JsonRequestBehavior.AllowGet);
- }
- /// <summary>
- /// 评价表格内容
- /// </summary>
- /// <param name="evaluationStudentID"></param>
- /// <param name="evaluationTableID"></param>
- /// <returns></returns>
- public JsonResult Content(Guid? evaluationStudentID, Guid? evaluationTableID)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var evaluationTargetViewList = EvaluationTargetServices.Value.GetEvaluationTargetViewList(configuretView, null, null, evaluationTableID, null)
- .Select(x => new { x.EvaluationTargetID, x.EvaluationNormID, x.Name, x.Weight }).ToList();
- int i = 1;
- StringBuilder strRows = new StringBuilder();
- foreach (var evaluationTargetView in evaluationTargetViewList)
- {
- StringBuilder strRowtg = new StringBuilder();
- var tgNormNames = string.Join(" ", EvaluationNormServices.Value.GetEvaluationNormDetailViewList(configuretView, evaluationTargetView.EvaluationNormID).Select(s => s.Name + s.Weight));
- strRowtg.Append("{");
- strRowtg.Append("\"OrderNo\":\"" + evaluationTargetView.Name + "\"");
- strRowtg.Append(",\"EvaluationTargetID\":\"" + evaluationTargetView.EvaluationTargetID + "\"");
- strRowtg.Append(",\"EvaluationTargetWeight\":\"\"");
- strRowtg.Append(",\"EvaluationProjectID\":\"\"");
- strRowtg.Append(",\"EvaluationProjectName\":\"\"");
- strRowtg.Append(",\"Weight\":\"" + evaluationTargetView.Weight + "\"");
- strRowtg.Append(",\"EvaluationNormName\":\"" + tgNormNames + "\"");
- strRowtg.Append("}");
- if (string.IsNullOrEmpty(strRows.ToString()))
- {
- strRows.Append(strRowtg);
- }
- else
- {
- strRows.Append("," + strRowtg);
- }
- var evaluationProjectViewList = EvaluationProjectServices.Value.GetEvaluationProjectViewList(configuretView, null, null, evaluationTableID, evaluationTargetView.EvaluationTargetID)
- .Select(x => new { x.EvaluationProjectID, x.OrderNo, x.Name, x.Weight, x.Code, x.EvaluationTargetID, x.EvaluationTargetWeight }).ToList();
- int j = 1;
- var evaluationNormDetailViewList = EvaluationNormServices.Value.GetEvaluationNormDetailViewList(configuretView, evaluationTargetView.EvaluationNormID).ToList();
- foreach (var evaluationProjectView in evaluationProjectViewList)
- {
- var prNormNames = "";
- if (evaluationStudentID.HasValue && evaluationStudentID != Guid.Empty)
- {
- var evaluationStudentDetailList = StudentEvaluationEnterServices.Value.GetEvaluationStudentDetailList(evaluationStudentID).ToList();
- if (evaluationStudentDetailList != null && evaluationStudentDetailList.Count() > 0)
- {
- var evaluationStudentDetail = evaluationStudentDetailList.Where(x => x.EvaluationProjectID == evaluationProjectView.EvaluationProjectID).SingleOrDefault();
- string normDetailStr = "";
- if (evaluationStudentDetail != null)
- {
- foreach (var evaluationNormDetailView in evaluationNormDetailViewList)
- {
- if (evaluationStudentDetail.Score == evaluationNormDetailView.Weight)
- {
- normDetailStr = evaluationNormDetailView.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + evaluationProjectView.EvaluationTargetID + "' value='" + evaluationNormDetailView.Weight + "' checked='checked' >";
- }
- else
- {
- normDetailStr = evaluationNormDetailView.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + evaluationProjectView.EvaluationTargetID + "' value='" + evaluationNormDetailView.Weight + "'>";
- }
- prNormNames += " " + normDetailStr;
- }
- }
- else
- {
- prNormNames = string.Join(" ", evaluationNormDetailViewList.Select((s, index) => s.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + evaluationProjectView.EvaluationTargetID + "' value='" + s.Weight + "'>"));
- }
- }
- else
- {
- prNormNames = string.Join(" ", evaluationNormDetailViewList.Select((s, index) => s.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + evaluationProjectView.EvaluationTargetID + "' value='" + s.Weight + "'>"));
- }
- }
- else
- {
- prNormNames = string.Join(" ", evaluationNormDetailViewList.Select((s, index) => s.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + evaluationProjectView.EvaluationTargetID + "' value='" + s.Weight + "'>"));
- }
- StringBuilder strRowpr = new StringBuilder();
- strRowpr.Append("{");
- strRowpr.Append("\"OrderNo\":\"" + evaluationProjectView.OrderNo + "\"");
- strRowpr.Append(",\"EvaluationTargetID\":\"" + evaluationProjectView.EvaluationTargetID + "\"");
- strRowpr.Append(",\"EvaluationTargetWeight\":\"" + evaluationProjectView.EvaluationTargetWeight + "\"");
- strRowpr.Append(",\"EvaluationProjectID\":\"" + evaluationProjectView.EvaluationProjectID + "\"");
- strRowpr.Append(",\"EvaluationProjectName\":\"" + evaluationProjectView.Name + "\"");
- strRowpr.Append(",\"Weight\":\"" + evaluationProjectView.Weight + "\"");
- strRowpr.Append(",\"EvaluationNormName\":\"" + prNormNames + "\"");
- strRowpr.Append("}");
- if (string.IsNullOrEmpty(strRows.ToString()))
- {
- strRows.Append(strRowpr);
- }
- else
- {
- strRows.Append("," + strRowpr);
- }
- j++;
- }
- i++;
- }
- return Json(new { rows = strRows.ToString(), total = 0 }, JsonRequestBehavior.AllowGet);
- }
- /// <summary>
- /// 查询对应的评价指标权重总和
- /// </summary>
- /// <param name="evaluationTargetIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetTargetWeightSum(string evaluationTargetIDs)
- {
- List<Guid?> list = evaluationTargetIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
- var evaluationTargetWeightSum = EvaluationTargetServices.Value.GetEvaluationTargetList(list).Sum(x => x.Weight ?? 0);
- return base.Json(evaluationTargetWeightSum.ToString());
- }
- /// <summary>
- /// 查询对应的评价项目权重总和
- /// </summary>
- /// <param name="evaluationTargetID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetProjectWeightSum(string evaluationTargetID)
- {
- var evaluationProjectWeightSum = EvaluationProjectServices.Value.GetEvaluationProjectList(Guid.Parse(evaluationTargetID)).Sum(x => x.Weight ?? 0);
- return base.Json(evaluationProjectWeightSum.ToString());
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var dt = StudentEvaluationEnterServices.Value.GetStudentEvaluationEnterViewList(configuretView, user.UserID)
- .Select(x => new
- {
- x.SchoolyearCode,
- x.MissionClassName,
- x.CourseName,
- x.CourseTypeName,
- x.HandleModeName,
- x.TeachingModeName,
- x.EvaluationTableName,
- x.ParticipateTypeName,
- x.EvaluationTypeName,
- x.StaffName,
- x.TeachingMethodName,
- x.Number,
- x.Numbered
- }).ToTable();
- string[] liststring = {
- "学年学期", "任务班名称", "课程名称", "课程类型", "处理方式", "授课方式", "评价表名", "参评类型", "评价类型",
- "任课教师", "任课方式", "可评次数", "已评次数"
- };
- neh.Export(dt, liststring, "进入评价信息(" + user.LoginID + ")" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|