コード例 #1
0
        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());
        }
コード例 #2
0
 public void SaveChooseQ()
 {
     string _idlist = Parameters["pidlist"];
     string _paperid = Parameters["ppaperid"];
     string _detailid = Parameters["pdetailid"];
     OEChooseQuestionBiz biz = new OEChooseQuestionBiz();
     OEChooseQuestion item = new OEChooseQuestion();
     ErrorEntity ErrInfo = new ErrorEntity();
     item.FPaperId = Convert.ToInt64(_paperid);
     item.FDetailId = Convert.ToInt32(_detailid);
     string[] qidarray;
     qidarray = _idlist.Split(',');
     for (int i = 0; i < qidarray.Length; i++)
     {
         if(!string.IsNullOrEmpty(qidarray[i]))
         {
             item.FQuestionId = Convert.ToInt32(qidarray[i]);
             int result = biz.Insert(item, out ErrInfo);
             if (result <= 0)
             {
                 Response.Write(ErrInfo.ToJson());
                 return;
             }
         }
     }
     Response.Write(ErrInfo.ToJson());
 }