Esempio n. 1
0
        private void DelExamStudent()
        {
            var obj = new
            {
                code = 0,
                msg  = ""
            };

            try
            {
                int id  = Request.Form["id"].AsInt();
                var bll = new BLL.examResultBLL();
                Models.examResult examResult = new Models.examResult
                {
                    id = id
                };
                bll.Delete(examResult);
            }
            catch (Exception ex)
            {
                obj = new
                {
                    code = 99,
                    msg  = ex.ToString()
                };
            }
            ResponseJson(obj);
        }
Esempio n. 2
0
        private void ImportStudent()
        {
            var obj = new
            {
                code = 0,
                msg  = ""
            };

            try
            {
                string data = Request.Form["data"];
                int    examDescription_id       = Request.Form["examDescription_id"].AsInt();
                List <Models.userInfo> dataList = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Models.userInfo> >(data);
                var bill = new BLL.examResultBLL();
                bill.BeginTransaction();
                try
                {
                    foreach (var dd in dataList)
                    {
                        bill.Insert(new Models.examResult
                        {
                            examDescription_id = examDescription_id,
                            scode = dd.code,
                            kszt  = "待考"
                        });
                    }
                    bill.Commit();
                }
                catch (Exception ex)
                {
                    bill.Rollback();
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                obj = new
                {
                    code = 99,
                    msg  = ex.Message
                };
            }

            ResponseJson(obj);
        }
Esempio n. 3
0
        private void HandInExam()
        {
            var obj = new { code = 0, msg = "" };

            try
            {
                string  data = Request.Form["data"];
                JObject jo   = JObject.Parse(data);
                Dictionary <int, string> dic = new Dictionary <int, string>();
                int pid         = Request.Form["pid"].AsInt();
                int examDesc_id = Request.Form["examDesc_id"].AsInt();
                foreach (JProperty jp in jo.Properties())
                {
                    string name = jp.Name;
                    string val  = jp.Value.ToString();

                    if (name.Substring(0, 1) == "r") //单选
                    {
                        int id = name.Replace("r_", "").AsInt();
                        dic.Add(id, val);
                    }
                    else if (name.Substring(0, 1) == "k") //判断题
                    {
                        int id = name.Replace("k_", "").AsInt();
                        dic.Add(id, val);
                    }
                    else if (name.Substring(0, 1) == "c") //多选
                    {
                        int       id      = name.Replace("c_", "").Replace("[A]", "").Replace("[B]", "").Replace("[C]", "").Replace("[D]", "").AsInt();
                        ArrayList tmpList = new ArrayList();
                        if (dic.ContainsKey(id))
                        {
                            string tmp_val;
                            dic.TryGetValue(id, out tmp_val);
                            string[] tmp_arr = tmp_val.Split(',');
                            tmpList.AddRange(tmp_arr);
                            dic.Remove(id);
                        }
                        if (val == "on")
                        {
                            if (name.Contains("[A]"))
                            {
                                tmpList.Add("A");
                            }
                            if (name.Contains("[B]"))
                            {
                                tmpList.Add("B");
                            }
                            if (name.Contains("[C]"))
                            {
                                tmpList.Add("C");
                            }
                            if (name.Contains("[D]"))
                            {
                                tmpList.Add("D");
                            }
                        }
                        if (tmpList.Count > 0)
                        {
                            tmpList.Sort();
                            dic.Add(id, string.Join(",", tmpList.ToArray()));
                        }
                    }
                }
                //获取试卷信息
                var tmp_exam_desc = new BLL.examDescriptionBLL().SingleQuery(new object[] { examDesc_id });
                //获取本次考试信息
                var examResult = new BLL.examResultBLL().SingleQuery(new object[] { pid });
                //定义变量
                List <Models.examResultDetail> resultDetailList = new List <Models.examResultDetail>();
                //计算答案及分值
                foreach (var d in dic)
                {
                    Models.examResultDetail resultDetail = new Models.examResultDetail();
                    resultDetail.isCorrect = 0;
                    resultDetail.score     = 0;
                    var tmp_exam = tmp_exam_desc.ExamList.Find(a => a.id == d.Key);
                    if (tmp_exam != null && tmp_exam.correctResult == d.Value)
                    {
                        resultDetail.isCorrect = 1;
                        resultDetail.score     = tmp_exam.score;
                    }
                    resultDetail.pid          = pid;
                    resultDetail.exam_id      = d.Key;
                    resultDetail.chooseResult = d.Value;
                    resultDetailList.Add(resultDetail);
                }
                //更新考试状态及总分
                examResult.kszt  = "已考";
                examResult.jssj  = DateTime.Now;
                examResult.score = resultDetailList.Sum(a => a.score);

                new BLL.examResultBLL().SaveExamResult(examResult, resultDetailList);
            }
            catch (Exception ex)
            {
                obj = new
                {
                    code = 99,
                    msg  = ex.Message
                };
            }

            ResponseJson(obj);
        }