Пример #1
0
 // Token: 0x060000A4 RID: 164 RVA: 0x0000F8A4 File Offset: 0x0000DAA4
 protected override void View()
 {
     if (this.ispost)
     {
         this.examresult = ExamBll.GetExamResult(this.resultid);
         if (this.examresult.id == 0)
         {
             this.ShowErr("对不起,该考试不存在或已被删除。");
         }
         else if (this.examresult.uid != this.userid)
         {
             this.ShowErr("对不起,您不是该考试的主人。");
         }
         else if (this.examresult.status == 1)
         {
             this.ShowErr("对不起,该考试已完成,不能重复提交。");
         }
         else
         {
             this.examresult.utime   = FPRequest.GetInt("utime");
             this.examresult.endtime = DbUtils.GetDateTime();
             this.examresult.status  = 1;
             if (DbHelper.ExecuteUpdate <ExamResult>(this.examresult) > 0)
             {
                 List <ExamResultTopic> examResultTopicList = ExamBll.GetExamResultTopicList(this.resultid);
                 int num = 0;
                 foreach (ExamResultTopic examResultTopic in examResultTopicList)
                 {
                     if (examResultTopic.questions == 0)
                     {
                         num++;
                     }
                     else
                     {
                         examResultTopicList[num].answerlist  = "";
                         examResultTopicList[num].scorelist   = "";
                         examResultTopicList[num].correctlist = "";
                         List <ExamQuestion> questionList = QuestionBll.GetQuestionList(examResultTopic.questionlist);
                         string[]            array        = FPUtils.SplitString(examResultTopic.optionlist, "|", questionList.Count);
                         int num2 = 0;
                         foreach (ExamQuestion examQuestion in questionList)
                         {
                             string text = FPRequest.GetString("answer_" + examQuestion.id);
                             if (num2 == 0)
                             {
                                 ExamResultTopic examResultTopic2 = examResultTopicList[num];
                                 examResultTopic2.answerlist += text;
                             }
                             else
                             {
                                 ExamResultTopic examResultTopic3 = examResultTopicList[num];
                                 examResultTopic3.answerlist = examResultTopic3.answerlist + "§" + text;
                             }
                             if (examResultTopicList[num].scorelist != "")
                             {
                                 ExamResultTopic examResultTopic4 = examResultTopicList[num];
                                 examResultTopic4.scorelist += "|";
                             }
                             examQuestion.optionlist = array[num2];
                             int    num3 = 0;
                             double num4 = 0.0;
                             if (examQuestion.type == 1 || examQuestion.type == 2)
                             {
                                 num3 = examQuestion.ascount;
                                 examQuestion.answer = this.OptionAnswer(array[num2], examQuestion.answer);
                                 if (text == examQuestion.answer && text != "")
                                 {
                                     num4 = examResultTopic.perscore;
                                 }
                                 this.examresult.score1 += num4;
                             }
                             else if (examQuestion.type == 3)
                             {
                                 num3 = examQuestion.ascount;
                                 if (text == examQuestion.answer && text != "")
                                 {
                                     num4 = examResultTopic.perscore;
                                 }
                                 this.examresult.score1 += num4;
                             }
                             else if (examQuestion.type == 4)
                             {
                                 string[] array2;
                                 if (examQuestion.upperflg == 1)
                                 {
                                     array2 = FPUtils.SplitString(examQuestion.answer, ",");
                                 }
                                 else
                                 {
                                     array2 = FPUtils.SplitString(examQuestion.answer.ToLower(), ",");
                                 }
                                 text = exampost.DelSameAnser(text);
                                 string[] array3;
                                 if (examQuestion.upperflg == 1)
                                 {
                                     array3 = FPUtils.SplitString(text, ",", array2.Length);
                                 }
                                 else
                                 {
                                     array3 = FPUtils.SplitString(text.ToLower(), ",", array2.Length);
                                 }
                                 if (examQuestion.orderflg == 1)
                                 {
                                     for (int i = 0; i < array3.Length; i++)
                                     {
                                         if (FPUtils.InArray(array3[i], array2[i], "|"))
                                         {
                                             num3++;
                                         }
                                     }
                                 }
                                 else
                                 {
                                     for (int i = 0; i < array3.Length; i++)
                                     {
                                         if (FPUtils.InArray(array3[i], examQuestion.answer.Replace("|", ",")))
                                         {
                                             num3++;
                                         }
                                     }
                                 }
                                 if (num3 > 0)
                                 {
                                     if (examQuestion.ascount <= 0)
                                     {
                                         examQuestion.ascount = 1;
                                     }
                                     num4 = Math.Round(examResultTopic.perscore / (double)examQuestion.ascount * (double)num3, 1);
                                     this.examresult.score2 += num4;
                                 }
                             }
                             else if (examQuestion.type == 5)
                             {
                                 foreach (string value in FPUtils.SplitString(examQuestion.answerkey))
                                 {
                                     if (text.IndexOf(value) >= 0)
                                     {
                                         num3++;
                                     }
                                 }
                                 if (num3 > 0 && text != "")
                                 {
                                     if (examQuestion.ascount > 0)
                                     {
                                         examQuestion.ascount = 1;
                                     }
                                     num4 = Math.Round(examResultTopic.perscore / (double)examQuestion.ascount * (double)num3, 1);
                                     this.examresult.score2 += num4;
                                 }
                             }
                             else if (examQuestion.type == 6)
                             {
                                 for (int k = 0; k < examQuestion.title.Length; k++)
                                 {
                                     if (text.IndexOf(examQuestion.title.Substring(k, 1)) >= 0)
                                     {
                                         num3++;
                                     }
                                 }
                                 if (num3 > 0)
                                 {
                                     num4 = Math.Round(examResultTopic.perscore / (double)examQuestion.title.Length * (double)num3, 1);
                                     this.examresult.score2 += num4;
                                 }
                             }
                             this.examresult.score          += num4;
                             examResultTopicList[num].score += num4;
                             ExamResultTopic examResultTopic5 = examResultTopicList[num];
                             examResultTopic5.scorelist += num4.ToString();
                             if (examResultTopicList[num].correctlist != "")
                             {
                                 ExamResultTopic examResultTopic6 = examResultTopicList[num];
                                 examResultTopic6.correctlist += "|";
                             }
                             bool flag = false;
                             if (num4 >= examResultTopic.perscore * 0.6)
                             {
                                 ExamResultTopic examResultTopic7 = examResultTopicList[num];
                                 examResultTopic7.correctlist += "1";
                             }
                             else
                             {
                                 ExamResultTopic examResultTopic8 = examResultTopicList[num];
                                 examResultTopic8.correctlist += "0";
                                 examResultTopicList[num].wrongs++;
                                 this.examresult.wrongs++;
                                 if (text == "")
                                 {
                                     this.examresult.unanswer++;
                                 }
                                 flag = true;
                             }
                             string sqlstring;
                             if (flag)
                             {
                                 sqlstring = string.Format("UPDATE [{0}Exam_ExamQuestion] SET [exams]=[exams]+1,[wrongs]=[wrongs]+1 WHERE [id]={1}", DbConfigs.Prefix, examQuestion.id);
                             }
                             else
                             {
                                 sqlstring = string.Format("UPDATE [{0}Exam_ExamQuestion] SET [exams]=[exams]+1 WHERE [id]={1}", DbConfigs.Prefix, examQuestion.id);
                             }
                             DbHelper.ExecuteSql(sqlstring);
                             examQuestion.useranswer = text;
                             SortInfo sortInfo = SortBll.GetSortInfo(examQuestion.sortid);
                             ExamBll.UpdateExamLog(sortInfo, this.userid, examQuestion, flag);
                             num2++;
                         }
                         DbHelper.ExecuteUpdate <ExamResultTopic>(examResultTopicList[num]);
                         num++;
                     }
                 }
                 this.expinfo               = ExamBll.GetExamExpByScore(this.examresult.score, this.examresult.examid);
                 this.examresult.exnote     = this.expinfo.comment;
                 this.examresult.exp        = this.expinfo.exp;
                 this.examresult.getcredits = this.expinfo.credits;
                 StringBuilder stringBuilder = new StringBuilder();
                 stringBuilder.AppendFormat("UPDATE [{0}Exam_ExamResult] SET [score1]={1},[score2]={2},[score]={3},[wrongs]={4},[exp]={5},[exnote]='{6}' WHERE [id]={7}|", new object[]
                 {
                     DbConfigs.Prefix,
                     this.examresult.score1,
                     this.examresult.score2,
                     this.examresult.score,
                     this.examresult.wrongs,
                     this.examresult.exp,
                     this.examresult.exnote,
                     this.examresult.id
                 });
                 stringBuilder.AppendFormat("UPDATE [{0}Exam_ExamInfo] SET [score]=[score]+{1} WHERE [id]={2}", DbConfigs.Prefix, this.examresult.score, this.examresult.examid);
                 this.msg = DbHelper.ExecuteSql(stringBuilder.ToString());
                 if (this.examresult.exp > 0)
                 {
                     UserBll.UpdateUserExp(this.examresult.uid, this.examresult.exp);
                 }
                 if (this.examresult.getcredits > 0)
                 {
                     UserBll.UpdateUserCredit(new CreditInfo
                     {
                         uid     = this.examresult.uid,
                         name    = "考试奖励积分",
                         type    = 0,
                         credits = this.examresult.getcredits,
                         doid    = this.userid,
                         doname  = this.username
                     });
                 }
                 if (this.msg != "")
                 {
                     this.ShowErr(this.msg);
                 }
             }
         }
     }
 }
Пример #2
0
 // Token: 0x060000E2 RID: 226 RVA: 0x000161B4 File Offset: 0x000143B4
 protected override void View()
 {
     this.channelinfo = ChannelBll.GetChannelInfo("exam_question");
     if (this.channelinfo.id == 0)
     {
         this.ShowErr("对不起,目前系统尚未创建题目库频道。");
     }
     else if (this.ispost)
     {
         if (this.qidlist == "")
         {
             this.ShowErr("对不起,题目为空不能提交。");
         }
         else
         {
             List <ExamQuestion> questionList = QuestionBll.GetQuestionList(this.qidlist);
             this.examresult.uid         = this.userid;
             this.examresult.channelid   = this.channelinfo.id;
             this.examresult.examid      = 0;
             this.examresult.examtype    = 0;
             this.examresult.showanswer  = 1;
             this.examresult.allowdelete = 1;
             this.examresult.examname    = ((this.testtype == 1) ? "专项智能练习" : "快速智能练习");
             this.examresult.examtime    = FPRequest.GetInt("utime") / 60;
             this.examresult.total       = 100.0;
             this.examresult.passmark    = 60.0;
             this.examresult.credits     = 0;
             this.examresult.questions   = questionList.Count;
             this.examresult.utime       = FPRequest.GetInt("utime");
             this.examresult.starttime   = FPRequest.GetDateTime("starttime");
             this.examresult.endtime     = DbUtils.GetDateTime();
             this.examresult.status      = 1;
             this.examresult.id          = DbHelper.ExecuteInsert <ExamResult>(this.examresult);
             if (this.examresult.id > 0)
             {
                 ExamResultTopic examResultTopic = new ExamResultTopic();
                 examResultTopic.resultid     = this.examresult.id;
                 examResultTopic.type         = 0;
                 examResultTopic.title        = ((this.testtype == 1) ? "专项智能练习" : "快速智能练习");
                 examResultTopic.perscore     = Math.Round(this.examresult.total / (double)this.examresult.questions, 1);
                 examResultTopic.display      = 1;
                 examResultTopic.questions    = questionList.Count;
                 examResultTopic.questionlist = this.qidlist;
                 int num = 0;
                 foreach (ExamQuestion examQuestion in QuestionBll.GetQuestionList(examResultTopic.questionlist))
                 {
                     if (examResultTopic.optionlist != "")
                     {
                         ExamResultTopic examResultTopic2 = examResultTopic;
                         examResultTopic2.optionlist += "|";
                     }
                     if (examQuestion.type == 1 || examQuestion.type == 2)
                     {
                         ExamResultTopic examResultTopic3 = examResultTopic;
                         examResultTopic3.optionlist += this.OptionInt(examQuestion.ascount);
                     }
                     else
                     {
                         ExamResultTopic examResultTopic4 = examResultTopic;
                         examResultTopic4.optionlist += "*";
                     }
                     string text = FPRequest.GetString("answer_" + examQuestion.id);
                     if (num == 0)
                     {
                         ExamResultTopic examResultTopic5 = examResultTopic;
                         examResultTopic5.answerlist += text;
                     }
                     else
                     {
                         ExamResultTopic examResultTopic6 = examResultTopic;
                         examResultTopic6.answerlist = examResultTopic6.answerlist + "§" + text;
                     }
                     if (examResultTopic.scorelist != "")
                     {
                         ExamResultTopic examResultTopic7 = examResultTopic;
                         examResultTopic7.scorelist += "|";
                     }
                     int    num2 = 0;
                     double num3 = 0.0;
                     if (examQuestion.type <= 3)
                     {
                         if (text == examQuestion.answer && text != "")
                         {
                             num2 = examQuestion.ascount;
                             num3 = examResultTopic.perscore;
                             this.examresult.score1 += num3;
                         }
                     }
                     else if (examQuestion.type == 4)
                     {
                         string[] array;
                         if (examQuestion.upperflg == 1)
                         {
                             array = FPUtils.SplitString(examQuestion.answer, ",");
                         }
                         else
                         {
                             array = FPUtils.SplitString(examQuestion.answer.ToLower(), ",");
                         }
                         text = testpost.DelSameAnser(text);
                         string[] array2;
                         if (examQuestion.upperflg == 1)
                         {
                             array2 = FPUtils.SplitString(text, ",", array.Length);
                         }
                         else
                         {
                             array2 = FPUtils.SplitString(text.ToLower(), ",", array.Length);
                         }
                         if (examQuestion.orderflg == 1)
                         {
                             for (int i = 0; i < array2.Length; i++)
                             {
                                 if (FPUtils.InArray(array2[i], array[i], "|"))
                                 {
                                     num2++;
                                 }
                             }
                         }
                         else
                         {
                             for (int i = 0; i < array2.Length; i++)
                             {
                                 if (FPUtils.InArray(array2[i], examQuestion.answer.Replace("|", ",")))
                                 {
                                     num2++;
                                 }
                             }
                         }
                         if (num2 > 0)
                         {
                             if (examQuestion.ascount <= 0)
                             {
                                 examQuestion.ascount = 1;
                             }
                             num3 = Math.Round(examResultTopic.perscore / (double)examQuestion.ascount * (double)num2, 1);
                             this.examresult.score2 += num3;
                         }
                     }
                     else if (examQuestion.type == 5)
                     {
                         foreach (string value in FPUtils.SplitString(examQuestion.answerkey))
                         {
                             if (text.IndexOf(value) >= 0)
                             {
                                 num2++;
                             }
                         }
                         if (num2 > 0 && text != "")
                         {
                             if (examQuestion.ascount > 0)
                             {
                                 examQuestion.ascount = 1;
                             }
                             num3 = Math.Round(examResultTopic.perscore / (double)examQuestion.ascount * (double)num2, 1);
                             this.examresult.score2 += num3;
                         }
                     }
                     else if (examQuestion.type == 6)
                     {
                         for (int k = 0; k < examQuestion.title.Length; k++)
                         {
                             if (text.IndexOf(examQuestion.title.Substring(k, 1)) >= 0)
                             {
                                 num2++;
                             }
                         }
                         if (num2 > 0)
                         {
                             num3 = Math.Round(examResultTopic.perscore / (double)examQuestion.title.Length * (double)num2, 1);
                             this.examresult.score2 += num3;
                         }
                     }
                     this.examresult.score += num3;
                     examResultTopic.score += num3;
                     ExamResultTopic examResultTopic8 = examResultTopic;
                     examResultTopic8.scorelist += num3.ToString();
                     if (examResultTopic.correctlist != "")
                     {
                         ExamResultTopic examResultTopic9 = examResultTopic;
                         examResultTopic9.correctlist += "|";
                     }
                     bool flag = false;
                     if (num3 >= examResultTopic.perscore * 0.6)
                     {
                         ExamResultTopic examResultTopic10 = examResultTopic;
                         examResultTopic10.correctlist += "1";
                     }
                     else
                     {
                         ExamResultTopic examResultTopic11 = examResultTopic;
                         examResultTopic11.correctlist += "0";
                         examResultTopic.wrongs++;
                         this.examresult.wrongs++;
                         if (text == "")
                         {
                             this.examresult.unanswer++;
                         }
                         flag = true;
                     }
                     string sqlstring;
                     if (flag)
                     {
                         sqlstring = string.Format("UPDATE [{0}Exam_ExamQuestion] SET [exams]=[exams]+1,[wrongs]=[wrongs]+1 WHERE [id]={1}", DbConfigs.Prefix, examQuestion.id);
                     }
                     else
                     {
                         sqlstring = string.Format("UPDATE [{0}Exam_ExamQuestion] SET [exams]=[exams]+1 WHERE [id]={1}", DbConfigs.Prefix, examQuestion.id);
                     }
                     DbHelper.ExecuteSql(sqlstring);
                     examQuestion.useranswer = text;
                     SortInfo sortInfo = SortBll.GetSortInfo(examQuestion.sortid);
                     ExamBll.UpdateExamLog(sortInfo, this.userid, examQuestion, flag);
                     num++;
                 }
                 DbHelper.ExecuteInsert <ExamResultTopic>(examResultTopic);
                 SqlParam[] sqlparams = new SqlParam[]
                 {
                     DbHelper.MakeSet("score1", this.examresult.score1),
                     DbHelper.MakeSet("score2", this.examresult.score2),
                     DbHelper.MakeSet("score", this.examresult.score),
                     DbHelper.MakeSet("wrongs", this.examresult.wrongs),
                     DbHelper.MakeAndWhere("id", this.examresult.id)
                 };
                 DbHelper.ExecuteUpdate <ExamResult>(sqlparams);
             }
         }
     }
 }
Пример #3
0
        // Token: 0x060000B8 RID: 184 RVA: 0x00011E2C File Offset: 0x0001002C
        protected override void View()
        {
            if (this.ispost)
            {
                if (!this.isperm)
                {
                    this.ShowErrMsg("对不起,您没有权限阅卷。");
                    return;
                }
                this.examresult = ExamBll.GetExamResult(this.resultid);
                if (this.examresult.id == 0)
                {
                    this.ShowErrMsg("对不起,该考试不存在或已被删除。");
                    return;
                }
                int status = this.examresult.status;
                this.examresult.status = 2;
                this.examresult.exnote = FPRequest.GetString("exnote");
                if (DbHelper.ExecuteUpdate <ExamResult>(this.examresult) <= 0)
                {
                    this.ShowErrMsg("保存出现错误。");
                    return;
                }
                List <ExamResultTopic> examResultTopicList = ExamBll.GetExamResultTopicList(this.resultid);
                int    num   = 0;
                double score = this.examresult.score;
                this.examresult.score  = 0.0;
                this.examresult.score1 = 0.0;
                this.examresult.score2 = 0.0;
                this.examresult.wrongs = 0;
                foreach (ExamResultTopic examResultTopic in examResultTopicList)
                {
                    if (examResultTopic.questions == 0)
                    {
                        num++;
                    }
                    else
                    {
                        int[]    array  = FPUtils.SplitInt(examResultTopic.questionlist);
                        string[] array2 = FPUtils.SplitString(examResultTopic.answerlist, "§", array.Length);
                        string[] array3 = FPUtils.SplitString(examResultTopic.scorelist, "|", array.Length);
                        examResultTopicList[num].scorelist   = "";
                        examResultTopicList[num].correctlist = "";
                        examResultTopicList[num].score       = 0.0;
                        int num2 = 0;
                        foreach (ExamQuestion examQuestion in QuestionBll.GetQuestionList(examResultTopic.questionlist))
                        {
                            string a = array2[num2];
                            if (examResultTopicList[num].scorelist != "")
                            {
                                ExamResultTopic examResultTopic2 = examResultTopicList[num];
                                examResultTopic2.scorelist += "|";
                            }
                            double num3 = 0.0;
                            if (examQuestion.type == 1 || examQuestion.type == 2)
                            {
                                num3 = (double)FPRequest.GetFloat("score_" + examQuestion.id);
                                this.examresult.score1 += num3;
                            }
                            else if (examQuestion.type == 3)
                            {
                                num3 = (double)FPRequest.GetFloat("score_" + examQuestion.id);
                                this.examresult.score1 += num3;
                            }
                            else if (examQuestion.type == 4)
                            {
                                num3 = (double)FPRequest.GetFloat("score_" + examQuestion.id);
                                this.examresult.score1 += num3;
                            }
                            else if (examQuestion.type == 5)
                            {
                                num3 = (double)FPRequest.GetFloat("score_" + examQuestion.id);
                                this.examresult.score2 += num3;
                            }
                            else if (examQuestion.type == 6)
                            {
                                num3 = (double)FPRequest.GetFloat("score_" + examQuestion.id);
                                this.examresult.score2 += num3;
                            }
                            this.examresult.score          += num3;
                            examResultTopicList[num].score += num3;
                            ExamResultTopic examResultTopic3 = examResultTopicList[num];
                            examResultTopic3.scorelist += num3.ToString();
                            if (examResultTopicList[num].correctlist != "")
                            {
                                ExamResultTopic examResultTopic4 = examResultTopicList[num];
                                examResultTopic4.correctlist += "|";
                            }
                            bool iswrong = false;
                            if (num3 >= examResultTopic.perscore * 0.6)
                            {
                                ExamResultTopic examResultTopic5 = examResultTopicList[num];
                                examResultTopic5.correctlist += "1";
                            }
                            else
                            {
                                ExamResultTopic examResultTopic6 = examResultTopicList[num];
                                examResultTopic6.correctlist += "0";
                                examResultTopicList[num].wrongs++;
                                this.examresult.wrongs++;
                                if (a == "")
                                {
                                    this.examresult.unanswer++;
                                }
                                iswrong = true;
                            }
                            SortInfo sortInfo = SortBll.GetSortInfo(examQuestion.sortid);
                            ExamBll.UpdateExamLog(sortInfo, this.examresult.uid, examQuestion, iswrong);
                            num2++;
                        }
                        DbHelper.ExecuteUpdate <ExamResultTopic>(examResultTopicList[num]);
                        num++;
                    }
                }
                ExpInfo       examExpByScore = ExamBll.GetExamExpByScore(this.examresult.score, this.examresult.examid);
                StringBuilder stringBuilder  = new StringBuilder();
                if (status == 0)
                {
                    stringBuilder.AppendFormat("UPDATE [{0}Exam_ExamResult] SET [score1]={1},[score2]={2},[score]={3},[wrongs]={4},[exp]={5} WHERE [id]={6}|", new object[]
                    {
                        DbConfigs.Prefix,
                        this.examresult.score1,
                        this.examresult.score2,
                        this.examresult.score,
                        this.examresult.wrongs,
                        examExpByScore.exp,
                        this.examresult.id
                    });
                    stringBuilder.AppendFormat("UPDATE [{0}Exam_ExamInfo] SET [exams]=[exams]+1,[score]=[score]+{1} WHERE [id]={2}", DbConfigs.Prefix, this.examresult.score, this.examresult.examid);
                }
                else
                {
                    stringBuilder.AppendFormat("UPDATE [{0}Exam_ExamResult] SET [score1]={1},[score2]={2},[score]={3},[exp]={4} WHERE [id]={5}|", new object[]
                    {
                        DbConfigs.Prefix,
                        this.examresult.score1,
                        this.examresult.score2,
                        this.examresult.score,
                        examExpByScore.exp,
                        this.examresult.id
                    });
                    stringBuilder.AppendFormat("UPDATE [{0}Exam_ExamInfo] SET [score]=[score]-{1} WHERE [id]={2}|", DbConfigs.Prefix, score, this.examresult.examid);
                    stringBuilder.AppendFormat("UPDATE [{0}Exam_ExamInfo] SET [score]=[score]+{1} WHERE [id]={2}", DbConfigs.Prefix, this.examresult.score, this.examresult.examid);
                    stringBuilder.AppendFormat("UPDATE [{0}WMS_UserInfo] SET [exp]=[exp]-{1} WHERE [id]={2}", DbConfigs.Prefix, this.examresult.exp, this.examresult.uid);
                }
                this.msg = DbHelper.ExecuteSql(stringBuilder.ToString());
                UserBll.UpdateUserExp(this.examresult.uid, examExpByScore.exp);
                if (this.msg != "")
                {
                    this.ShowErrMsg(this.msg);
                    return;
                }
            }
            Hashtable hashtable = new Hashtable();

            hashtable["error"]   = 0;
            hashtable["message"] = "";
            base.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            base.Response.Write(JsonMapper.ToJson(hashtable));
            base.Response.End();
        }