// Token: 0x06000052 RID: 82 RVA: 0x00008B8C File Offset: 0x00006D8C
        protected override void View()
        {
            this.examtopic   = DbHelper.ExecuteModel <ExamTopic>(this.examtopicid);
            this.examinfo    = DbHelper.ExecuteModel <ExamInfo>(this.examtopic.examid);
            this.sortinfo    = SortBll.GetSortInfo(this.examinfo.sortid);
            this.channelinfo = ChannelBll.GetChannelInfo("exam_question");
            this.channelid   = this.channelinfo.id;
            this.sortlist    = SortBll.GetSortList(this.channelid, 0);
            if (this.ispost)
            {
                string          text     = "";
                string          text2    = "";
                SqlParam        sqlParam = DbHelper.MakeAndWhere("channelid", this.channelid);
                List <SortInfo> list     = DbHelper.ExecuteList <SortInfo>(new SqlParam[]
                {
                    sqlParam
                });
                int num = 0;
                foreach (SortInfo sortInfo in list)
                {
                    int @int = FPRequest.GetInt("randomcount_" + sortInfo.id);
                    if (@int > 0)
                    {
                        if (text != "")
                        {
                            text += ",";
                        }
                        text += sortInfo.id;
                        if (text2 != "")
                        {
                            text2 += ",";
                        }
                        text2 += @int;
                        num   += @int;
                    }
                }
                if (num > this.examtopic.questions - this.examtopic.curquestions)
                {
                    this.ShowErr("设定的随机题数不能大于总随机题数。");
                    return;
                }
                if (this.action == "save")
                {
                    SqlParam[] sqlparams = new SqlParam[]
                    {
                        DbHelper.MakeSet("randomsort", text),
                        DbHelper.MakeSet("randomcount", text2),
                        DbHelper.MakeSet("randoms", num),
                        DbHelper.MakeAndWhere("id", this.examtopicid)
                    };
                    DbHelper.ExecuteUpdate <ExamTopic>(sqlparams);
                    base.AddMsg("随机题设置保存成功!");
                    this.examtopic.randomsort  = text;
                    this.examtopic.randomcount = text2;
                    this.link = string.Concat(new object[]
                    {
                        "examtopicrandom.aspx?examtopicid=",
                        this.examtopicid,
                        "&paper=",
                        this.paper
                    });
                }
                else if (this.action == "create")
                {
                    string text3  = this.examtopic.questionlist;
                    int[]  array  = FPUtils.SplitInt(text);
                    int[]  array2 = FPUtils.SplitInt(text2, ",", array.Length);
                    for (int i = 0; i < array.Length; i++)
                    {
                        if (array2[i] > 0)
                        {
                            string questionRandom = QuestionBll.GetQuestionRandom(this.channelid, array2[i], this.examtopic.type.ToString(), array[i], text3);
                            if (questionRandom != "")
                            {
                                text3 += ((text3 == "") ? questionRandom : ("," + questionRandom));
                            }
                        }
                    }
                    this.examtopic.questionlist = text3;
                    this.examtopic.curquestions = FPUtils.SplitInt(this.examtopic.questionlist).Length;
                    SqlParam[] sqlparams = new SqlParam[]
                    {
                        DbHelper.MakeSet("questionlist", this.examtopic.questionlist),
                        DbHelper.MakeSet("curquestions", this.examtopic.curquestions),
                        DbHelper.MakeSet("randomsort", ""),
                        DbHelper.MakeSet("randomcount", ""),
                        DbHelper.MakeSet("randoms", 0),
                        DbHelper.MakeAndWhere("id", this.examtopicid)
                    };
                    DbHelper.ExecuteUpdate <ExamTopic>(sqlparams);
                    base.AddMsg("生成随机题目成功!");
                    this.link = string.Concat(new object[]
                    {
                        "examtopicmanage.aspx?examid=",
                        this.examtopic.examid,
                        "&paper=",
                        this.paper,
                        "&examtopicid=",
                        this.examtopicid
                    });
                }
            }
            int[] array3 = FPUtils.SplitInt(this.examtopic.randomsort);
            int[] array4 = FPUtils.SplitInt(this.examtopic.randomcount, ",", array3.Length);
            for (int i = 0; i < array3.Length; i++)
            {
                this.randomlist.Add(array3[i], array4[i]);
            }
            SqlParam sqlParam2 = DbHelper.MakeAndWhere("id", WhereType.In, this.examtopic.questionlist);

            this.questionlist = DbHelper.ExecuteList <ExamQuestion>(new SqlParam[]
            {
                sqlParam2
            });
            foreach (ExamQuestion examQuestion in this.questionlist)
            {
                if (this.curlist.ContainsKey(examQuestion.sortid))
                {
                    this.curlist[examQuestion.sortid] = this.curlist[examQuestion.sortid] + 1;
                }
                else
                {
                    this.curlist.Add(examQuestion.sortid, 1);
                }
            }
            base.SaveRightURL();
        }
Exemple #2
0
 // Token: 0x060000DE RID: 222 RVA: 0x00015D6C File Offset: 0x00013F6C
 protected override void View()
 {
     this.examconfig = ExamConifgs.GetExamConfig();
     if (this.examconfig.teststatus == 0)
     {
         this.ShowErr("对不起,考试系统已关闭了用户练习。");
     }
     else
     {
         this.channelinfo = ChannelBll.GetChannelInfo("exam_question");
         if (this.channelinfo.id == 0)
         {
             this.ShowErr("对不起,目前系统尚未创建题目库频道。");
         }
         else
         {
             this.starttime = DbUtils.GetDateTime();
             if (this.limit == 0)
             {
                 this.limit = 50;
             }
             if (this.limit < 5)
             {
                 this.ShowErr("为了更能准确体现您的能力,每次练习题目不能少于5题。");
             }
             else if (this.limit > this.examconfig.testcount)
             {
                 this.ShowErr("对不起,每次练习题目数不得超过" + this.examconfig.testcount + "题。");
             }
             else
             {
                 string questionRandom = QuestionBll.GetQuestionRandom(this.channelinfo.id, this.limit, this.type, this.sidlist);
                 if (questionRandom != "")
                 {
                     SqlParam     sqlParam = DbHelper.MakeAndWhere("id", WhereType.In, questionRandom);
                     OrderByParam orderby  = DbHelper.MakeOrderBy("type", OrderBy.ASC);
                     this.questionlist = DbHelper.ExecuteList <ExamQuestion>(orderby, new SqlParam[]
                     {
                         sqlParam
                     });
                     foreach (ExamQuestion examQuestion in this.questionlist)
                     {
                         if (this.qidlist != "")
                         {
                             this.qidlist += ",";
                         }
                         this.qidlist += examQuestion.id;
                     }
                     int num  = this.examconfig.testtime * 60;
                     int num2 = num / 3600;
                     int num3 = (num - num2 * 3600) / 60;
                     int num4 = (num - num2 * 3600 - num3 * 60) % 60;
                     this.thetime = string.Concat(new string[]
                     {
                         num2.ToString("00"),
                         ":",
                         num3.ToString("00"),
                         ":",
                         num4.ToString("00")
                     });
                 }
                 else
                 {
                     this.ShowErr("对不起,抽起的题库没有题目。");
                 }
             }
         }
     }
 }