Ejemplo n.º 1
0
 protected void QuestionOk_Click(object sender, EventArgs e)
 {
     if (ErrQuestionList.Count == 0)
     {
         if (QuestionList.Count > 0)
         {
             QuestionOk.Enabled = false;
             int QuestionNum = 0;
             foreach (QuestionInfo Item in QuestionList)
             {
                 Item.CateId    = CateId;
                 Item.CompanyId = 0;
                 if (Item.Style != "0" && !string.IsNullOrEmpty(Item.Style))
                 {
                     QuestionBLL.AddQuestion(Item);
                     QuestionNum++;
                 }
             }
             ScriptHelper.Alert("成功导入" + QuestionNum.ToString() + "道试题!");
         }
         else
         {
             ScriptHelper.Alert("异常错误,请重新导入!");
         }
     }
     else
     {
         ScriptHelper.Alert("请修正完错误后,再入库!");
     }
 }
Ejemplo n.º 2
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            int queryString = RequestHelper.GetQueryString <int>("ID");

            if (_CourseId.SelectedValue == "-1" || _CourseId.SelectedValue == "")
            {
                ScriptHelper.Alert("请选择课程");
                Response.End();
            }
            QuestionInfo QuestionModel = new QuestionInfo();

            QuestionModel.CateId     = Convert.ToInt32(_CourseId.SelectedValue);
            QuestionModel.QuestionId = queryString;
            QuestionModel.Question   = this.Quetion.Text;
            if (QuestionModel.Question == "")
            {
                ScriptHelper.Alert("请填写题目");
                Response.End();
            }
            QuestionModel.Style     = this.TestType.Text;
            QuestionModel.CompanyId = systemCompanyId;
            if (QuestionModel.Style == "1")
            {
                QuestionModel.A = this.SingleA.Text;
                QuestionModel.B = this.SingleB.Text;
                QuestionModel.C = this.SingleC.Text;
                QuestionModel.D = this.SingleD.Text;

                if (QuestionModel.A == "" || QuestionModel.B == "" || QuestionModel.C == "" || QuestionModel.D == "")
                {
                    ScriptHelper.Alert("请填写选项");
                    Response.End();
                }
                if (QuestionModel.A == QuestionModel.B || QuestionModel.A == QuestionModel.C || QuestionModel.A == QuestionModel.D || QuestionModel.B == QuestionModel.C || QuestionModel.B == QuestionModel.D || QuestionModel.C == QuestionModel.D)
                {
                    ScriptHelper.Alert("请正确填写选项");
                    Response.End();
                }

                string Answer = string.Empty;
                if (SingleAnswerA.Checked)
                {
                    Answer = SingleAnswerA.Value;
                }
                else if (SingleAnswerB.Checked)
                {
                    Answer = SingleAnswerB.Value;
                }
                else if (SingleAnswerC.Checked)
                {
                    Answer = SingleAnswerC.Value;
                }
                else if (SingleAnswerD.Checked)
                {
                    Answer = SingleAnswerD.Value;
                }
                QuestionModel.Answer = Answer;
            }
            else if (QuestionModel.Style == "2")
            {
                QuestionModel.A = this.MultiA.Text;
                QuestionModel.B = this.MultiB.Text;
                QuestionModel.C = this.MultiC.Text;
                QuestionModel.D = this.MultiD.Text;

                if (QuestionModel.A == "" || QuestionModel.B == "" || QuestionModel.C == "" || QuestionModel.D == "")
                {
                    ScriptHelper.Alert("请填写选项");
                    Response.End();
                }
                if (QuestionModel.A == QuestionModel.B || QuestionModel.A == QuestionModel.C || QuestionModel.A == QuestionModel.D || QuestionModel.B == QuestionModel.C || QuestionModel.B == QuestionModel.D || QuestionModel.C == QuestionModel.D)
                {
                    ScriptHelper.Alert("请正确填写选项");
                    Response.End();
                }
                string Answer = string.Empty;
                if (MultiAnswerA.Checked)
                {
                    Answer = Answer + SingleAnswerA.Value;
                }
                if (MultiAnswerB.Checked)
                {
                    Answer = Answer + SingleAnswerB.Value;
                }
                if (MultiAnswerC.Checked)
                {
                    Answer = Answer + SingleAnswerC.Value;
                }
                if (MultiAnswerD.Checked)
                {
                    Answer = Answer + SingleAnswerD.Value;
                }
                QuestionModel.Answer = Answer;
                if (QuestionModel.Answer.Length <= 1)
                {
                    ScriptHelper.Alert("多项选择题的答案不能低于2个选项!");
                    Response.End();
                }
            }
            else if (QuestionModel.Style == "3")
            {
                QuestionModel.Answer = this.JudgeAnswer.Text;
                if (QuestionModel.Answer == "0")
                {
                    QuestionModel.A = JudgeRightAnswer.Text;
                }
            }
            if (QuestionModel.Answer == "")
            {
                ScriptHelper.Alert("请选择标准答案");
                Response.End();
            }
            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (QuestionModel.QuestionId == int.MinValue)
            {
                base.CheckAdminPower("AddQuestion", PowerCheckType.Single);
                int id = QuestionBLL.AddQuestion(QuestionModel);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Question"), id);
                ResponseHelper.Write("<script>alert('" + alertMessage + "');</script>");

                this.TestType.Text             = "1";
                this.Quetion.Text              = string.Empty;
                this.SingleA.Text              = string.Empty;
                this.SingleB.Text              = string.Empty;
                this.SingleC.Text              = string.Empty;
                this.SingleD.Text              = string.Empty;
                this.MultiA.Text               = string.Empty;
                this.MultiB.Text               = string.Empty;
                this.MultiC.Text               = string.Empty;
                this.MultiD.Text               = string.Empty;
                this.JudgeRightAnswer.Text     = string.Empty;
                SingleAnswerA.Checked          = false;
                SingleAnswerB.Checked          = false;
                SingleAnswerC.Checked          = false;
                SingleAnswerD.Checked          = false;
                MultiAnswerA.Checked           = false;
                MultiAnswerB.Checked           = false;
                MultiAnswerC.Checked           = false;
                MultiAnswerD.Checked           = false;
                this.JudgeAnswer.SelectedIndex = -1;
            }
            else
            {
                base.CheckAdminPower("UpdateQuestion", PowerCheckType.Single);
                QuestionBLL.UpdateQuestion(QuestionModel);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Question"), QuestionModel.QuestionId);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
                AdminBasePage.Alert(alertMessage, RequestHelper.RawUrl);
            }
        }