public ProjectApprovalReportController()
 {
     exBll       = new ExaminationBLL();
     categoryBLL = new CategoryBLL();
     bigBll      = new BigTypesBLL();
     samllBll    = new SmallTypesBLL();
     unitBll     = new UnitTypesBLL();
 }
        /// <summary>
        /// 在线考试
        /// </summary>
        /// <returns></returns>
        public ActionResult ExamOnline()
        {
            User user   = (User)Session["User"];
            Guid userId = user.ID;

            Guid classId = ObjectToGuid(new StudentBLL().GetStudent(userId).Rows[0]["ClassID"]);    // 获取班级ID

            DataTable table = new ExaminationBLL().GetUnfinishedExam(classId, userId);              // 查询该班级所有未过期的未考测试

            return(View(table));
        }
        /// <summary>
        /// 开始考试
        /// </summary>
        /// <returns></returns>
        public ActionResult BeginExam(Guid guid)
        {
            DataTable table_paper = new ExaminationBLL().GetExamByID(guid);             // 获取试卷信息

            // 检测考试是否过期
            if (table_paper.Rows.Count == 0)
            {
                return(RedirectToAction("../Student/ExamOnline"));
            }
            // 给前台传递试卷信息
            ViewBag.PaperName   = table_paper.Rows[0]["PaperTitle"].ToString();                                                  // 试卷名称
            ViewBag.ReleaseTime = Convert.ToDateTime(table_paper.Rows[0]["ReleaseTime"]).ToString("yyyy年MM月dd日HH时mm分");          // 发布时间
            ViewBag.CourseName  = table_paper.Rows[0]["CourseName"].ToString();                                                  // 科目名
            ViewBag.TeacherName = table_paper.Rows[0]["Name"].ToString();                                                        // 教师名
            ViewBag.RollOutTime = table_paper.Rows[0]["RollOutTime"].ToString();                                                 // 考试时长

            // 选择题信息
            string    single_list  = table_paper.Rows[0]["SingleList"].ToString();
            DataTable single_table = new SingleBLL().GetSingleList(single_list, "desc");                // 选择题信息列表

            // 判断题信息
            string    judge_list  = table_paper.Rows[0]["JudgeList"].ToString();
            DataTable judge_table = new JudgeBLL().GetJudgeList(judge_list, "desc");                    // 判断题信息列表

            // 选择题排序规则
            string    single_option  = table_paper.Rows[0]["SingleOption"].ToString();
            DataTable s_option_table = GetOptionsTable(single_option);                                  // 选择题选项排序规则

            // 判断题排序规则
            string    judge_option   = table_paper.Rows[0]["JudgeOption"].ToString();
            DataTable j_option_table = GetOptionsTable(judge_option);                                   // 判断题选项排序规则

            // 打包提交
            DataSet dataSet = new DataSet();

            dataSet.Tables.Add(single_table);
            dataSet.Tables.Add(s_option_table);
            dataSet.Tables.Add(judge_table);
            dataSet.Tables.Add(j_option_table);


            // 试卷信息
            Session["PaperID"]      = guid;
            Session["PaperOptions"] = dataSet; // 试卷题目所有信息(包含排序规则)

            return(View(dataSet));
        }
        /// <summary>
        /// 考卷发布确认提交
        /// </summary>
        /// <param name="paperTitle">试卷名称</param>
        /// <param name="singleList">选择列表</param>
        /// <param name="judgeList">判断列表</param>
        /// <param name="classId">考试班级</param>
        /// <param name="testTime">考试结束时间</param>
        /// <param name="rollOutTime">考试时长</param>
        /// <returns></returns>
        public ActionResult ReleaseCheck(string paperTitle, string singleList, string judgeList, string classId, string testTime, string rollOutTime)
        {
            #region 取出教师信息,随机排序考题选项
            User user     = (User)Session["User"];
            Guid userId   = user.ID;                                                                        // 教师ID
            Guid courseId = Guid.Parse(new TeacherBLL().GetTeacher(userId).Rows[0]["CourseID"].ToString()); // 科目ID

            string single_options = GetSingleOptionSrot();                                                  // 随机选择题排序规则 例:ABCD,CBDA...
            string judge_options  = GetJudgeOptionSrot();                                                   // 随机判断题排序规则 例:BA,AB...
            #endregion

            // 检测试卷名是否唯一
            bool checkTitle = new ExaminationBLL().CheckExamTitle(paperTitle);
            if (checkTitle)
            {
                return(Content(new AjaxResult
                {
                    state = ResultType.info.ToString(),
                    message = string.Format($"试卷名重复!")
                }.ToJson()));
            }

            // 整合考试信息Model
            ExaminationInfo examination = new ExaminationInfo();
            examination.PaperTitle   = paperTitle.Trim();
            examination.SingleList   = singleList.Substring(0, singleList.Length - 1);
            examination.SingleOption = single_options;
            examination.JudgeList    = judgeList.Substring(0, judgeList.Length - 1);
            examination.JudgeOption  = judge_options;
            examination.ClassID      = Guid.Parse(classId);
            examination.TeacherID    = userId;
            examination.CourseID     = courseId;
            examination.TestTime     = DateTime.Parse(testTime);
            examination.RollOutTime  = rollOutTime;

            // 提交结果
            bool release = new ExaminationBLL().ReleaseExamination(examination);
            switch (release)
            {
            case true:
                return(Content(new AjaxResult
                {
                    state = ResultType.info.ToString(),
                    message = string.Format($"《{paperTitle}》 发布成功!")
                }.ToJson()));

            case false:
                return(Content(new AjaxResult
                {
                    state = ResultType.info.ToString(),
                    message = string.Format($"《{paperTitle}》 发布失败!")
                }.ToJson()));

            default:
                return(Content(new AjaxResult
                {
                    state = ResultType.error.ToString(),
                    message = string.Format($"未知错误!")
                }.ToJson()));
            }
        }