Пример #1
0
        /// <summary>
        /// 获取[结业考试]题目信息
        /// </summary>
        /// <param name="iTrainingId"></param>
        /// <param name="strVerson"></param>
        /// <returns></returns>
        private List<Course_UnitTest> GetExamCourseUnitTest(int iTrainingId = 0, string strVerson = "")
        {
            var List_Course_UnitTest = new List<Course_UnitTest>();
            var unitTestBll = new Course_UnitTestBLL();
            var strOrderBy = "CreateDate";
            var stbSqlWhere = new StringBuilder();
            if (!string.IsNullOrEmpty(strVerson))
            {
                stbSqlWhere.AppendFormat(" TrainingId = {0} AND Verson = '{1}'", iTrainingId, strVerson);
            }
            else
            {
                stbSqlWhere.AppendFormat(" Display = 1 AND Delflag = 0 AND TrainingId = {0}", iTrainingId);
            }

            List_Course_UnitTest = unitTestBll.GetList(stbSqlWhere.ToString(), strOrderBy);
            ViewBag.List_Course_UnitTest = List_Course_UnitTest;
            ViewBag.ExamRecordCount = List_Course_UnitTest.Count;
            ViewBag.ExamTrainingId = List_Course_UnitTest == null || List_Course_UnitTest.Count <= 0 ? 0 : List_Course_UnitTest[0].TrainingId;
            return List_Course_UnitTest;
        }
Пример #2
0
        /// <summary>
        /// 提交答案到用户答案表
        /// </summary>
        /// <param name="listResultOther"></param>
        /// <param name="iId">总分表的Id</param>
        /// <returns></returns>
        private bool SaveMember_CourseContentTestAnswer(List<Member_CourseContentTestAnswerOther> listResultOther, int iId)
        {
            var unitTestBll = new Course_UnitTestBLL();
            var TestAnswerBll = new Member_CourseContentTestAnswerBLL();

            int iAccountId = 0;
            bool bolRes = false;

            iAccountId = Code.SiteCache.Instance.LoginInfo.UserId;

            foreach (var item in listResultOther)
            {
                var Model_Answer = new Member_CourseContentTestAnswer();

                //获取该题目的正确答案
                var Model_Test = unitTestBll.GetModel(item.Id, string.Empty);

                double dblGetCreTmp = 0;
                double.TryParse(item.Credits, out dblGetCreTmp);

                Model_Answer.AnswerResult = iId;
                Model_Answer.Question = item.Id;
                Model_Answer.Answer = item.Answer;
                Model_Answer.Result = Model_Test.QTtype == 4 ? true : Model_Test.Answer == item.Answer;//比对正确答案  若是问答题,直接设置为True
                Model_Answer.AccountId = iAccountId;
                Model_Answer.Delflag = false;
                Model_Answer.CreateDate = DateTime.Now;

                //将数据插入到学员答题内容表,用户的[结业考试]答案保存
                bolRes = TestAnswerBll.Add(Model_Answer);
            }

            return bolRes;
        }
Пример #3
0
 public ActionResult ExamQuesModel(int Id)
 {
     Course_UnitTest model = new Course_UnitTestBLL().GetModel(Id,"Display = 1 and Delflag = 0");
     return Json(new { Data = model }, JsonRequestBehavior.AllowGet);
 }
Пример #4
0
        public ActionResult ExemExeclTemp(int TrainingId)
        {
            Course_UnitTestBLL course_UnitTestBLL = new Course_UnitTestBLL();
            string msg = "";
            HttpPostedFileBase excel = Request.Files[0];
            string fileName = Server.MapPath(Code.UploadCore.UploadAttach(excel, ref msg));
            int GroupId = Code.SiteCache.Instance.GroupId;
            int OrganId = Code.SiteCache.Instance.ManageOrganId;

            DataTable dt = ReadExcel(fileName);
            if (dt.Columns[0].ColumnName.ToString() != "类型" || dt.Columns[1].ColumnName.ToString() != "题目内容" || dt.Columns[2].ColumnName.ToString() != "答案内容" || dt.Columns[3].ColumnName.ToString() != "正确答案序号" || dt.Columns[4].ColumnName.ToString() != "权重")
            {
                return Content("no:导入的格式不正确!");
            }
            else
            {
                List<Course_UnitTest> list = new List<Course_UnitTest>();
                if (dt.Rows.Count == 0)
                {
                    return Content("no:无导入数据!");
                }
                else
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        try
                        {
                            for (int k = 0; k < dt.Columns.Count; k++)
                            {
                                if (string.IsNullOrEmpty(dt.Rows[i][k].ToString()))
                                {
                                    return Content("no:导入的数据有空值!");
                                }
                            }

                            Course_UnitTest model = new Course_UnitTest();
                            model.TrainingId = TrainingId;
                            model.Verson = "-1";
                            if (dt.Rows[i][2].ToString().Trim().IndexOf(',') > 0)
                            {
                                string[] Questions = dt.Rows[i][2].ToString().Trim().Split(',');
                                model.Question = "[";
                                for (int c = 0; c < Questions.Length; c++)
                                {
                                    model.Question += "{Id:" + (c + 1) + ",Content:'" + Questions[c] + "'},";
                                }

                                model.Question = model.Question.TrimEnd(',') + "]";
                            }
                            else
                            {
                                model.Question = dt.Rows[i][2].ToString().Trim();
                            }

                            model.Answer = dt.Rows[i][3].ToString().Trim();

                            switch (dt.Rows[i][0].ToString().Trim())
                            {
                                case "单选题":
                                    model.QTtype = 1;
                                    break;
                                case "多选题":
                                    model.QTtype = 2;
                                    break;
                                case "判断题":
                                    model.QTtype = 3;
                                    model.Question = "[{Id:1,Content:'1'},{Id:2,Content:'0'}]";
                                    break;
                                case "问答题":
                                    model.QTtype = 4;
                                    model.Question = "";
                                    model.Answer = "";
                                    break;
                                default:
                                    break;
                            }
                            model.Content = dt.Rows[i][1].ToString().Trim();

                            if (Regex.IsMatch(dt.Rows[i][4].ToString(), @"^[+-]?\d*[.]?\d*$"))
                            {
                                model.Credit = Convert.ToDouble(dt.Rows[i][4]);
                            }
                            else
                            {
                                return Content("no:权重必须是数字类型!");
                            }

                            if (dt.Rows[i][4].ToString().Length > 2)
                            {
                                return Content("no:权重数字长度不能超过五位数!");
                            }

                            if (dt.Rows[i][4].ToString() == "0")
                            {
                                return Content("no:第" + (i + 1) + "行的权重不能为0!");
                            }

                            model.Display = true;
                            model.Delflag = false;
                            model.CreateDate = DateTime.Now;
                            list.Add(model);
                        }
                        catch (Exception ex)
                        {
                            return Content("no:" + ex);
                        }
                    }

                    int count = course_UnitTestBLL.AddExem(list);
                    if (count > 0)
                    {
                        return Content("yes:成功导入" + list.Count + "行数据");
                    }
                    else
                    {
                        return Content("no:导入失败");
                    }

                }
            }
        }
Пример #5
0
        public ActionResult DeleteUnitTest(int id)
        {
            Course_UnitTestBLL bll = new Course_UnitTestBLL();

            if (bll.Delete(id))
            {
                return Json(new { Result = true, Msg = "删除成功!" }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(new { Result = false, Msg = "删除失败!" }, JsonRequestBehavior.AllowGet);
            }
        }
Пример #6
0
        public ActionResult EditUnitTest(Course_Test model)
        {
            Course_UnitTestBLL bll = new Course_UnitTestBLL();

            if (bll.UpdateCourseTest(model))
            {
                return Json(new { Result = true, Msg = "修改成功!" }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(new { Result = false, Msg = "修改失败!" }, JsonRequestBehavior.AllowGet);
            }
        }
Пример #7
0
        public ActionResult CourseActivityExamQues(int TrainingId, int UnitContent)
        {
            //ViewBag.Title = "添加结业考试试题";
            Course_DetailBLL bll = new Course_DetailBLL();
            Course_UnitTestBLL bll_UnitTest = new Course_UnitTestBLL();

            //指定课程的课程ID
            ViewBag.TrainingId = TrainingId;
            //指定活动单元的ID
            ViewBag.UnitContent = UnitContent;
            //获取指定课程ID对应的课程单元信息
            ViewBag.TrainingInfo = bll.GetTrainingInfoById(Convert.ToInt32(TrainingId));
            //获取指定课程ID对应的课程试题信息
            ViewBag.ExamQuesInfo = bll_UnitTest.GetExamQuesInfo(Convert.ToInt32(TrainingId));

            return View();
        }
Пример #8
0
        public ActionResult CourseActivityExamEdit(int TrainingId, int UnitId)
        {
            //ViewBag.Title = "结业考试编辑";
            Course_DetailBLL bll_CourseDetail = new Course_DetailBLL();
            Course_UnitContentBLL bll = new Course_UnitContentBLL();
            Course_UnitTestBLL bll_UnitTest = new Course_UnitTestBLL();

            //指定课程的课程ID
            ViewBag.TrainingId = TrainingId;
            //获取指定课程ID对应的课程单元信息
            ViewBag.TrainingInfo = bll_CourseDetail.GetTrainingInfoById(Convert.ToInt32(TrainingId));
            //获取结业考试Model
            ViewBag.ActivityExamModel = bll.GetModel(Convert.ToInt32(UnitId), "Delflag = 0");
            //指定课程是否已经添加试题
            ViewBag.IsExistsExamQues = bll_UnitTest.IsExistsExamQues(Convert.ToInt32(TrainingId));

            return View();
        }
Пример #9
0
        public ActionResult AddEaxmQues(Course_UnitTest model)
        {
            Course_UnitTestBLL bll = new Course_UnitTestBLL();

            if (bll.Add(model))
            {
                return Json(new { Result = true, Msg = "新增成功!" }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(new { Result = false, Msg = "新增失败!" }, JsonRequestBehavior.AllowGet);
            }
        }
Пример #10
0
        public ActionResult SetExamVerson(int TrainingId)
        {
            Course_UnitTestBLL bll = new Course_UnitTestBLL();

            if (bll.SetVerson(TrainingId))
            {
                return Json(new { Result = true, Msg = "您已经完成结业试题制作!" }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(new { Result = false, Msg = "结业试题制作失败!" }, JsonRequestBehavior.AllowGet);
            }
        }
        /// <summary>
        /// 获取[结业考试]题目信息
        /// </summary>
        /// <returns></returns>
        private List<Course_UnitTest> GetExamCourseUnitTest(int iTrainingId = 0)
        {
            var List_Course_UnitTest = new List<Course_UnitTest>();
            var unitTestBll = new Course_UnitTestBLL();
            var strOrderBy = "CreateDate";
            var stbSqlWhere = new StringBuilder();
            stbSqlWhere.AppendFormat("Display = 1 AND Delflag = 0 AND TrainingId={0}", iTrainingId);

            List_Course_UnitTest = unitTestBll.GetList(stbSqlWhere.ToString(), strOrderBy);
            ViewBag.List_Course_UnitTest = List_Course_UnitTest;
            ViewBag.ExamRecordCount = List_Course_UnitTest.Count;
            ViewBag.ExamTrainingId = List_Course_UnitTest == null || List_Course_UnitTest.Count <= 0 ? 0 : List_Course_UnitTest[0].TrainingId;
            return List_Course_UnitTest;
        }