Example #1
0
 public Int64 Insert(OEExamPaper item, out ErrorEntity ErrInfo)
 {
     //Error Judge Define
     if (item.FContentClassId == 0)
     {
         ErrInfo = new ErrorEntity("EP010001", "试卷所属内容类别不能为空!");
         return -1;
     }
     if (string.IsNullOrEmpty(item.FPaperName))
     {
         ErrInfo = new ErrorEntity("EP010002", "试卷名称不能为空!");
         return -1;
     }
     if (item.FPaperTotal == 0)
     {
         ErrInfo = new ErrorEntity("EP010003", "试卷总分不能为空或者等于零!");
         return -1;
     }
     if (item.FPassScore == 0)
     {
         ErrInfo = new ErrorEntity("EP010004", "试卷通过分数设定不能为空或者等于零");
         return -1;
     }
     if (item.FExamTime == 0)
     {
         ErrInfo = new ErrorEntity("EP010005", "考试时间不能为空或者等于零!");
         return -1;
     }
     NameValueCollection parameters = new NameValueCollection();
     parameters.Add("FContentClassId", item.FContentClassId.ToString());
     parameters.Add("FPaperName", item.FPaperName);
     parameters.Add("FPaperTotal", item.FPaperTotal.ToString());
     parameters.Add("FPaperExtractWay", item.FPaperExtractWay);
     parameters.Add("FChooseItemWay", item.FChooseItemWay);
     parameters.Add("FPassScore", item.FPassScore.ToString());
     parameters.Add("FPaperContent", item.FPaperContent);
     parameters.Add("AUserId", item.AUserId.ToString());
     parameters.Add("FPaperStatus", item.FPaperStatus);
     parameters.Add("FExamTime", item.FExamTime.ToString());
     parameters.Add("FExamType", item.FExamType);
     parameters.Add("FExamAgain", item.FExamAgain);
     return Insert(parameters, out ErrInfo);
 }
 public void GetDetailSet()
 {
     string _paperid = Parameters["ppaperid"];
     OEPaperDetailSetBiz biz = new OEPaperDetailSetBiz();
     List<OEPaperDetailSet> lists = new List<OEPaperDetailSet>();
     lists = biz.Select(_paperid);
     //获取paper关于在线模式的设定
     OEExamPaper item = new OEExamPaper();
     OEExamPaperBiz pbiz = new OEExamPaperBiz();
     item = pbiz.Select(_paperid);
     string _operation = "";
     for (int i = 0; i < lists.Count; i++)
     {
         _operation = "<a href='javascript:void(0)' onclick='adjugedifficulty(" + _paperid + "," + lists[i].FDetailSetId.ToString() + ")'>调整难度等级</a>";
         if (item.FExamType == "0")
         {
             _operation += "&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:void(0)' onclick='setquestion(" + _paperid + "," + lists[i].FDetailSetId.ToString() + ")'>指定题目</a>";
         }
         else
         {
             _operation += "&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:void(0)' onclick='setchoosen(" + _paperid + "," + lists[i].FDetailSetId.ToString() + ")'>设置备选题目</a>";
         }
         lists[i].FOperation = _operation;
     }
     Response.Write(Utils.ConvertToJson(lists));
 }
 public void SavePage1()
 {
     string _paperid = Parameters["ppaperid"];
     string _pagename = Parameters["ppagename"];
     string _contentclassid = Parameters["pcontentclassid"];
     string _total = Parameters["ptotal"];
     string _examtype = Parameters["pexamtype"];
     string _extractway = Parameters["pextractway"];
     string _chooseitemway = Parameters["pchooseitemway"];
     string _examtime = Parameters["pexamtime"];
     string _papercontent = Parameters["ppapercontent"];
     string _examagain = Parameters["pexamagain"];
     string _passscore = Parameters["ppassscore"];
     OEExamPaper item = new OEExamPaper();
     item.FChooseItemWay = _chooseitemway;
     item.FContentClassId = string.IsNullOrEmpty(_contentclassid) ? 0 : Convert.ToInt64(_contentclassid);
     item.FExamAgain = _examagain;
     item.FExamTime = string.IsNullOrEmpty(_examtime) ? 0 : Convert.ToInt32(_examtime);
     item.FExamType = _examtype;
     item.FPaperContent = _papercontent;
     item.FPaperExtractWay = _extractway;
     item.FPaperId = string.IsNullOrEmpty(_paperid) ? 0 : Convert.ToInt64(_paperid);
     item.FPaperName = _pagename;
     item.FPaperTotal = string.IsNullOrEmpty(_total) ? 0 : Convert.ToDecimal(_total);
     item.FPassScore = string.IsNullOrEmpty(_passscore) ? 0 : Convert.ToDecimal(_passscore);
     item.AUserId = Convert.ToInt64(userid);
     OEExamPaperBiz biz = new OEExamPaperBiz();
     ErrorEntity ErrInfo = new ErrorEntity();
     if (item.FPaperId == 0)
     {
         item.FPaperStatus = "2";
         Int64 result = biz.Insert(item, out ErrInfo);
         if (ErrInfo.ErrorCode == RespCode.Success)
         {
             ErrInfo.ErrorMessage = result.ToString();
         }
     }
     else
     {
         item.FPaperTime = DateTime.Today;
         biz.Update(item, out ErrInfo);
         if (ErrInfo.ErrorCode == RespCode.Success)
         {
             ErrInfo.ErrorMessage = item.FPaperId.ToString();
         }
     }
     Response.Write(ErrInfo.ToJson());
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string _paperid = Parameters["pid"];
         if (string.IsNullOrEmpty(_paperid))
         {
             gsitem = new OEExamPaper();
             gsitem.FPaperTotal = 100;
             gsitem.FPassScore = 60;
             gsitem.FExamTime = 120;
             gsitem.FExamType = "0";
             gsitem.FPaperExtractWay = "0";
             gsitem.FChooseItemWay = "0";
             gsitem.FExamAgain = "0";
         }
         else
         {
             OEExamPaperBiz biz = new OEExamPaperBiz();
             gsitem = biz.Select(_paperid);
         }
     }
 }
        public void SaveInfo2()
        {
            string _banklist = Parameters["pbanklist"];
            string _ratelist = Parameters["pratelist"];
            string _typelist = Parameters["ptypelist"];
            string _numlist = Parameters["pnumlist"];
            string _scorelist = Parameters["pscorelist"];
            string _paperid = Parameters["ppaperid"];
            string[] bankarray;
            string[] ratearray;
            string[] typearray;
            string[] numarray;
            string[] scorearray;
            bankarray = _banklist.Split(',');
            ratearray = _ratelist.Split(',');
            typearray = _typelist.Split(',');
            numarray = _numlist.Split(',');
            scorearray = _scorelist.Split(',');
            OECombineBankBiz bbiz = new OECombineBankBiz();
            ErrorEntity ErrInfo = new ErrorEntity();
            //check total rate ?= 100
            int _rate = 0;
            for (int i = 0; i < ratearray.Length; i++)
            {
                _rate += string.IsNullOrEmpty(ratearray[i]) ? 0 : Convert.ToInt32(ratearray[i]);
            }
            if (_rate != 100)
            {
                ErrInfo = new ErrorEntity("EP020001", "题库分配比例不等于100%,请检查相关设定!");
                Response.Write(ErrInfo.ToJson());
                return;
            }
            //check all type of question's totalscore ?= papertotal
            OEExamPaperBiz pbiz = new OEExamPaperBiz();
            OEExamPaper pitem = new OEExamPaper();
            pitem = pbiz.Select(_paperid);
            if(pitem == null)
            {
                ErrInfo = new ErrorEntity("EP020002","试卷基本信息尚未设定,请先设定基本信息!");
                Response.Write(ErrInfo.ToJson());
                return;
            }
            decimal papertotal = pitem.FPaperTotal;
            decimal _scoretotal = 0;
            for (int i = 0; i < scorearray.Length; i++)
            {
                _scoretotal += ((string.IsNullOrEmpty(scorearray[i]) ? 0 : Convert.ToDecimal(scorearray[i])) * (string.IsNullOrEmpty(numarray[i]) ? 0 : Convert.ToDecimal(numarray[i])));
            }
            if (_scoretotal != papertotal)
            {
                ErrInfo = new ErrorEntity("EP020003", "各题型的得分设定不等于试卷总分,请检查相关设定!");
                Response.Write(ErrInfo.ToJson());
                return;
            }

            //delete old choosebank
            NameValueCollection where = new NameValueCollection();
            where.Add("FPaperId", _paperid);
            bbiz.Delete(where, out ErrInfo);

            //delete od question type
            OECombineTypeBiz tbiz = new OECombineTypeBiz();
            tbiz.Delete(where, out ErrInfo);

            //insert new choosebank
            for (int i = 0; i < bankarray.Length;i++ )
            {
                if (!string.IsNullOrEmpty(bankarray[i]))
                {
                    OECombineBank item = new OECombineBank();
                    item.FPaperId = Convert.ToInt64(_paperid);
                    item.FQBankId = Convert.ToInt64(bankarray[i]);
                    item.FQBnakRate = Convert.ToDecimal(ratearray[i]);
                    bbiz.Insert(item, out ErrInfo);
                }
            }

            //insert new question type
            for (int i = 0; i < typearray.Length; i++)
            {
                if (!string.IsNullOrEmpty(typearray[i]))
                {
                    OECombineType item = new OECombineType();
                    item.FPaperId = Convert.ToInt64(_paperid);
                    item.FQuestionType = typearray[i];
                    item.FQuestionNum = Convert.ToInt32(numarray[i]);
                    item.FQuestionScore = Convert.ToDecimal(scorearray[i]);
                    tbiz.Insert(item, out ErrInfo);
                }
            }

            //delete old paperdetailset
            OEPaperDetailSetBiz dbiz = new OEPaperDetailSetBiz();
            dbiz.Delete(_paperid, out ErrInfo);
            //insert new paperdetailset
            int j = 1;
            for (int i = 0; i < typearray.Length; i++)
            {
                if (!string.IsNullOrEmpty(typearray[i]))
                {
                    for (int m = 1; m <= Convert.ToInt32(numarray[i]); m++)
                    {
                        OEPaperDetailSet item = new OEPaperDetailSet();
                        item.FPaperId = Convert.ToInt64(_paperid);
                        item.FDetailSetId = j;
                        item.FQuestionType = typearray[i];
                        item.FDifficulty = "0";
                        item.FScore = Convert.ToDecimal(scorearray[i]);
                        dbiz.Insert(item, out ErrInfo);
                        //检测备选题型不符合,将删除备选题目设定
                        List<OEChooseQuestion> choosequestion = new List<OEChooseQuestion>();
                        OEChooseQuestionBiz cqbiz = new OEChooseQuestionBiz();
                        NameValueCollection cqwhere = new NameValueCollection();
                        cqwhere.Add("FPaperId", _paperid);
                        cqwhere.Add("FDetailId", j.ToString());
                        choosequestion = cqbiz.Select(cqwhere);
                        if (choosequestion.Count > 0)
                        {
                            if (choosequestion[0].FQuestionType != item.FQuestionType)
                            {
                                cqbiz.Delete(cqwhere, out ErrInfo);
                            }
                        }
                        j++;
                    }
                }
            }

            Response.Write(ErrInfo.ToJson());
        }