Exemplo n.º 1
0
        public string ExamRecord()
        {
            JxLib.UserExamController userExamController = new JxLib.UserExamController();
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];

            DatabaseLib.Tools tools = new DatabaseLib.Tools();

            System.Collections.Hashtable data = tools.paramToData(context.Request.Form);

            string user_id = context.Request.Cookies["user_id"].Value;

            data["StudentID"] = user_id;

            userExamController.ExamLog(data);

            Models.Result result = new Models.Result();

            if (userExamController.Result)
            {
                result.code = "200";
            }
            else
            {
                result.code = "0";
            }

            result.message = userExamController.Message;

            return Newtonsoft.Json.JsonConvert.SerializeObject(result).Replace("\"", "'");
        }
Exemplo n.º 2
0
        public ActionResult ExamMenu()
        {
            JxLib.UserExamController userExamController = new JxLib.UserExamController();
            JxLib.ExamController examController = new JxLib.ExamController();

            CacheLib.Cookie cookie = new CacheLib.Cookie();

            string user_id = cookie.GetCookie("user_id");

            System.Collections.Hashtable item = userExamController.getMySequenceExamLog(user_id);
            int count = examController.getAll().Count;

            ViewData["count"] = count;

            if (item == null)
                ViewData["exam_id"] = "1";
            else
                ViewData["exam_id"] = item["ExamID"].ToString();

            ViewData["title"] = "科目一考试练习";

            return View();
        }
Exemplo n.º 3
0
        public ActionResult SimulateExamStart()
        {
            JxLib.ExamController examController = new JxLib.ExamController();
            JxLib.UserExamController userExamController = new JxLib.UserExamController();
            CacheLib.Cookie cookie = new CacheLib.Cookie();

            System.Collections.Hashtable data = new System.Collections.Hashtable();
            string user_id = cookie.GetCookie("user_id");
            //深大驾校测试代码
            //data.Add("SchoolID", "1");
            //data.Add("StudentID", "00001");
            data.Add("StudentID", user_id);
            //插入数据,考试结束
            string strExamID = userExamController.ExamStart(data);

            List<System.Collections.Hashtable> list = examController.getTestExam();

            System.Text.StringBuilder strExams = new System.Text.StringBuilder();

            int index = 1;

            foreach (System.Collections.Hashtable item in list)
            {
                Models.ExamA exam_a = null;
                Models.ExamB exam_b = null;

                if (CommonLib.Common.Validate.IsNullString(item["OptionC"]) == "")
                {
                    Models.Answer answerA = null;

                    if (item["Answer"].ToString().IndexOf("A") > -1)
                    {
                        answerA = new Models.Answer
                        {
                            title = item["OptionA"].ToString(),
                            correct = true
                        };
                    }
                    else
                    {
                        answerA = new Models.Answer
                        {
                            title = item["OptionA"].ToString(),
                            correct = false
                        };

                    }

                    string strAnswerA = Newtonsoft.Json.JsonConvert.SerializeObject(answerA);

                    Models.Answer answerB = null;

                    if (item["Answer"].ToString().IndexOf("B") > -1)
                    {
                        answerB = new Models.Answer
                        {
                            title = item["OptionB"].ToString(),
                            correct = true
                        };
                    }
                    else
                    {
                        answerB = new Models.Answer
                        {
                            title = item["OptionB"].ToString(),
                            correct = false
                        };

                    }

                    Models.AnswersA answers = new Models.AnswersA
                    {
                        A = answerA,
                        B = answerB
                    };

                    exam_a = new Models.ExamA
                    {
                        no = index.ToString(),
                        exam_id = item["ExamID"].ToString(),
                        total = this.EXAMCOUNT.ToString(),
                        title = item["ExamText"].ToString(),
                        img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]),
                        video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]),
                        answers = answers
                    };

                    if (index > 1)
                        strExams.Append(",");

                    strExams.Append(Newtonsoft.Json.JsonConvert.SerializeObject(exam_a));
                }
                else
                {
                    Models.Answer answerA = null;

                    if (item["Answer"].ToString().IndexOf("A") > -1)
                    {
                        answerA = new Models.Answer
                        {
                            title = item["OptionA"].ToString(),
                            correct = true
                        };
                    }
                    else
                    {
                        answerA = new Models.Answer
                        {
                            title = item["OptionA"].ToString(),
                            correct = false
                        };

                    }

                    Models.Answer answerB = null;

                    if (item["Answer"].ToString().IndexOf("B") > -1)
                    {
                        answerB = new Models.Answer
                        {
                            title = item["OptionB"].ToString(),
                            correct = true
                        };
                    }
                    else
                    {
                        answerB = new Models.Answer
                        {
                            title = item["OptionB"].ToString(),
                            correct = false
                        };

                    }

                    Models.Answer answerC = null;

                    if (item["Answer"].ToString().IndexOf("C") > -1)
                    {
                        answerC = new Models.Answer
                        {
                            title = item["OptionC"].ToString(),
                            correct = true
                        };
                    }
                    else
                    {
                        answerC = new Models.Answer
                        {
                            title = item["OptionC"].ToString(),
                            correct = false
                        };

                    }

                    Models.Answer answerD = null;

                    if (item["Answer"].ToString().IndexOf("D") > -1)
                    {
                        answerD = new Models.Answer
                        {
                            title = item["OptionD"].ToString(),
                            correct = true
                        };
                    }
                    else
                    {
                        answerD = new Models.Answer
                        {
                            title = item["OptionD"].ToString(),
                            correct = false
                        };

                    }

                    Models.AnswersB answers = new Models.AnswersB
                    {
                        A = answerA,
                        B = answerB,
                        C = answerC,
                        D = answerD
                    };

                    exam_b = new Models.ExamB
                    {
                        no = index.ToString(),
                        exam_id = item["ExamID"].ToString(),
                        total = this.EXAMCOUNT.ToString(),
                        title = item["ExamText"].ToString(),
                        img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]),
                        video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]),
                        answers = answers
                    };

                    if (index > 1)
                        strExams.Append(",");

                    strExams.Append(Newtonsoft.Json.JsonConvert.SerializeObject(exam_b));
                }

                index++;
            }

            string tmp = strExams.ToString().Replace("[", "{").Replace("]", "}");

            ViewData["exams"] = tmp;
            ViewData["exam_id"] = strExamID;
            ViewData["title"] = "开始考试";

            return View();
        }
Exemplo n.º 4
0
        public ActionResult SequenceExam()
        {
            JxLib.ExamController examController = new JxLib.ExamController();

            List<System.Collections.Hashtable> list = examController.getAll();

            //System.Text.StringBuilder strExams = new System.Text.StringBuilder();

            //int index = 1;

            //foreach (System.Collections.Hashtable item in list)
            //{
            //    Models.ExamA exam_a = null;
            //    Models.ExamB exam_b = null;

            //    if (CommonLib.Common.Validate.IsNullString(item["OptionC"]) == "")
            //    {
            //        Models.Answer answerA = null;

            //        if (item["Answer"].ToString().IndexOf("A") > -1)
            //        {
            //            answerA = new Models.Answer
            //            {
            //                title = item["OptionA"].ToString(),
            //                correct = true
            //            };
            //        }
            //        else
            //        {
            //            answerA = new Models.Answer
            //            {
            //                title = item["OptionA"].ToString(),
            //                correct = false
            //            };

            //        }

            //        string strAnswerA = Newtonsoft.Json.JsonConvert.SerializeObject(answerA);

            //        Models.Answer answerB = null;

            //        if (item["Answer"].ToString().IndexOf("B") > -1)
            //        {
            //            answerB = new Models.Answer
            //            {
            //                title = item["OptionB"].ToString(),
            //                correct = true
            //            };
            //        }
            //        else
            //        {
            //            answerB = new Models.Answer
            //            {
            //                title = item["OptionB"].ToString(),
            //                correct = false
            //            };

            //        }

            //        Models.AnswersA answers = new Models.AnswersA
            //        {
            //            A = answerA,
            //            B = answerB
            //        };

            //        exam_a = new Models.ExamA
            //        {
            //            no = index.ToString(),
            //            exam_id = item["ExamID"].ToString(),
            //            total = list.Count.ToString(),
            //            title = item["ExamText"].ToString(),
            //            img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]),
            //            video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]),
            //            answers = answers
            //        };

            //        if (index > 1)
            //            strExams.Append(",");

            //        strExams.Append(Newtonsoft.Json.JsonConvert.SerializeObject(exam_a));
            //    }
            //    else
            //    {
            //        Models.Answer answerA = null;

            //        if (item["Answer"].ToString().IndexOf("A") > -1)
            //        {
            //            answerA = new Models.Answer
            //            {
            //                title = item["OptionA"].ToString(),
            //                correct = true
            //            };
            //        }
            //        else
            //        {
            //            answerA = new Models.Answer
            //            {
            //                title = item["OptionA"].ToString(),
            //                correct = false
            //            };

            //        }

            //        Models.Answer answerB = null;

            //        if (item["Answer"].ToString().IndexOf("B") > -1)
            //        {
            //            answerB = new Models.Answer
            //            {
            //                title = item["OptionB"].ToString(),
            //                correct = true
            //            };
            //        }
            //        else
            //        {
            //            answerB = new Models.Answer
            //            {
            //                title = item["OptionB"].ToString(),
            //                correct = false
            //            };

            //        }

            //        Models.Answer answerC = null;

            //        if (item["Answer"].ToString().IndexOf("C") > -1)
            //        {
            //            answerC = new Models.Answer
            //            {
            //                title = item["OptionC"].ToString(),
            //                correct = true
            //            };
            //        }
            //        else
            //        {
            //            answerC = new Models.Answer
            //            {
            //                title = item["OptionC"].ToString(),
            //                correct = false
            //            };

            //        }

            //        Models.Answer answerD = null;

            //        if (item["Answer"].ToString().IndexOf("D") > -1)
            //        {
            //            answerD = new Models.Answer
            //            {
            //                title = item["OptionD"].ToString(),
            //                correct = true
            //            };
            //        }
            //        else
            //        {
            //            answerD = new Models.Answer
            //            {
            //                title = item["OptionD"].ToString(),
            //                correct = false
            //            };

            //        }

            //        Models.AnswersB answers = new Models.AnswersB
            //        {
            //            A = answerA,
            //            B = answerB,
            //            C = answerC,
            //            D = answerD
            //        };

            //        exam_b = new Models.ExamB
            //        {
            //            no = index.ToString(),
            //            exam_id = item["ExamID"].ToString(),
            //            total = list.Count.ToString(),
            //            title = item["ExamText"].ToString(),
            //            img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]),
            //            video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]),
            //            answers = answers
            //        };

            //        if (index > 1)
            //            strExams.Append(",");

            //        strExams.Append(Newtonsoft.Json.JsonConvert.SerializeObject(exam_b));
            //    }

            //    index++;
            //}

            //string tmp = strExams.ToString().Replace("[", "{").Replace("]", "}");

            //ViewData["exams"] = tmp;

            CacheLib.Cookie cookie = new CacheLib.Cookie();
            JxLib.UserExamController userExamController = new JxLib.UserExamController();

            //实际运行代码
            string user_id = cookie.GetCookie("user_id");
            //开发测试代码
            //string user_id = "00001";

            //cookie.AddCookie("user_id", "00001");

            System.Collections.Hashtable sequenceExamLog = userExamController.getMySequenceExamLog(user_id);

            string exam_id = "1";

            if (sequenceExamLog != null)
            {
                exam_id = sequenceExamLog["ExamID"].ToString();
            }

            ViewData["index"] = exam_id;
            ViewData["count"] = list.Count;
            ViewData["title"] = "训练习题";

            return View();
        }
Exemplo n.º 5
0
        public ActionResult MyExam()
        {
            JxLib.UserExamController userExamController = new JxLib.UserExamController();
            CacheLib.Cookie cookie = new CacheLib.Cookie();

            string user_id = cookie.GetCookie("user_id");

            List<System.Collections.Hashtable> list = userExamController.getMyExam(user_id);

            ViewData["data"] = list;

            int ok_count = 0;

            foreach (System.Collections.Hashtable item in list)
            {
                string score = CommonLib.Common.Validate.IsNullString(item["Score"]);

                if (score == "")
                    continue;

                if (Int32.Parse(score) > this.PASSSCORE)
                {
                    ok_count++;
                }
            }

            ViewData["need_count"] = 3 - ok_count;
            ViewData["ok_count"] = ok_count;
            ViewData["title"] = "我的成绩";

            return View();
        }