Пример #1
0
 public ActionResult List(ListGrades request)
 {
     request.Query();
     return(View(request));
 }
Пример #2
0
        private void GetPaperInfo()
        {
            //获取试卷信息
            CurrentPaper = ExamHandle.TryGetData <T_Paper>(Sql.GET_PAPER_KEY, PaperKey).SingleOrDefault();

            //获取所有题目
            DataRow[] questions = ExamHandle.TryGetData(Sql.GET_QUESTIONS, CurrentPaper.Key).Select();

            //获取标准答案
            DataRow[] sta_answer = ExamHandle.TryGetData(Sql.GET_STA_ANSWER, CurrentPaper.Mould_Key).Select();

            //获取考生答案
            DataRow[] user_answer = ExamHandle.TryGetData(Sql.GET_USER_ANSWER, CurrentPaper.Key).Select();

            //重组考生答案
            var u_answer = new DataTable();

            u_answer.Columns.Add("F_QUESTION_KEY");
            u_answer.Columns.Add("F_TRADE_NO");

            u_answer.Columns.Add("F_LOCATION");
            u_answer.Columns.Add("F_CHANNEL");
            u_answer.Columns.Add("F_IOFLAG");
            u_answer.Columns.Add("F_OBJCODE");

            u_answer.Columns.Add("F_DOMAIN");
            u_answer.Columns.Add("F_DOMAIN_VALUE");

            foreach (DataRow item in user_answer)
            {
                //考生答案--发送时
                var sendData = item["F_CIPHERTEXT1"].ToString();
                //考生答案--返回时
                var receiveDat = item["F_CIPHERTEXT2"].ToString();

                var arraySendData = sendData.Split(new string[] { "%*%" }, System.StringSplitOptions.RemoveEmptyEntries);

                //PageData:考生答案--发送--界面;
                var PageData = string.Empty;
                //MessageData: 考生答案--发送--弹出窗口们;
                var ChildrenPageData = string.Empty;

                if (arraySendData != null)
                {
                    if (arraySendData.Length == 1)
                    {
                        PageData = arraySendData[0];
                    }
                    else if (arraySendData.Length == 2)
                    {
                        PageData         = arraySendData[0];
                        ChildrenPageData = arraySendData[1];
                    }
                }

                //主界面;
                string[] arrayPageData;
                if (!string.IsNullOrWhiteSpace(PageData))
                {
                    arrayPageData = PageData.Split(new string[] { "]*]" }, StringSplitOptions.RemoveEmptyEntries);
                    //界面;
                    foreach (string c in arrayPageData)
                    {
                        DataRow row = u_answer.NewRow();
                        row["F_QUESTION_KEY"] = item["F_QUESTION_KEY"].ToString();
                        row["F_TRADE_NO"]     = item["F_TRADE_NO"].ToString();
                        row["F_LOCATION"]     = "主界面";
                        row["F_CHANNEL"]      = "0";
                        row["F_IOFLAG"]       = "In";
                        row["F_OBJCODE"]      = "";
                        row["F_DOMAIN"]       = c.Split(new string[] { "=*=" }, StringSplitOptions.RemoveEmptyEntries)[0];
                        row["F_DOMAIN_VALUE"] = c.Split(new string[] { "=*=" }, StringSplitOptions.None)[1];
                        u_answer.Rows.Add(row);
                    }
                }
                //弹出页们;
                string[] arrayChildrenPageData;
                if (!string.IsNullOrWhiteSpace(ChildrenPageData))
                {
                    arrayChildrenPageData = ChildrenPageData.Split(new string[] { "#*#" }, StringSplitOptions.RemoveEmptyEntries);
                    if (arrayChildrenPageData != null && arrayChildrenPageData.Length > 0)
                    {
                        foreach (var oneChildPageData in arrayChildrenPageData)
                        {
                            var arrayOneChildIndexAddData = oneChildPageData.Split(new string[] { ":*:" }, StringSplitOptions.RemoveEmptyEntries);
                            if (arrayOneChildIndexAddData != null && arrayOneChildIndexAddData.Length == 2)
                            {
                                var arrayOneChildData = arrayOneChildIndexAddData[1].Split(new string[] { "]*]" }, StringSplitOptions.RemoveEmptyEntries);
                                if (arrayOneChildData != null && arrayOneChildData.Length > 0)
                                {
                                    foreach (string c in arrayOneChildData)
                                    {
                                        DataRow row = u_answer.NewRow();
                                        row["F_QUESTION_KEY"] = item["F_QUESTION_KEY"].ToString();
                                        row["F_TRADE_NO"]     = item["F_TRADE_NO"].ToString();
                                        row["F_LOCATION"]     = "弹出页";
                                        row["F_CHANNEL"]      = arrayOneChildIndexAddData[0];
                                        row["F_IOFLAG"]       = "In";
                                        row["F_OBJCODE"]      = "";
                                        row["F_DOMAIN"]       = c.Split(new string[] { "=*=" }, StringSplitOptions.RemoveEmptyEntries)[0];
                                        row["F_DOMAIN_VALUE"] = c.Split(new string[] { "=*=" }, StringSplitOptions.None)[1];
                                        u_answer.Rows.Add(row);
                                    }
                                }
                            }
                        }
                    }
                }

                //打印们
                var arrayPrintPagesData = receiveDat.Split(new string[] { "#*#" }, StringSplitOptions.RemoveEmptyEntries);
                if (arrayPrintPagesData != null && arrayPrintPagesData.Length > 0)
                {
                    foreach (var onePrintPage in arrayPrintPagesData)
                    {
                        var arrayOnePrintPageIndexAddData = onePrintPage.Split(new string[] { ":*:" }, StringSplitOptions.RemoveEmptyEntries);
                        if (arrayOnePrintPageIndexAddData != null && arrayOnePrintPageIndexAddData.Length == 2)
                        {
                            var arrayOnePrintPageData = arrayOnePrintPageIndexAddData[1].Split(new string[] { "]*]" }, StringSplitOptions.RemoveEmptyEntries);
                            if (arrayOnePrintPageData != null && arrayOnePrintPageData.Length > 0)
                            {
                                foreach (string c in arrayOnePrintPageData)
                                {
                                    DataRow row = u_answer.NewRow();
                                    row["F_QUESTION_KEY"] = item["F_QUESTION_KEY"].ToString();
                                    row["F_TRADE_NO"]     = item["F_TRADE_NO"].ToString();
                                    row["F_LOCATION"]     = "打印页";
                                    row["F_CHANNEL"]      = arrayOnePrintPageIndexAddData[0];
                                    row["F_IOFLAG"]       = "Out";
                                    row["F_OBJCODE"]      = "";
                                    row["F_DOMAIN"]       = c.Split(new string[] { "=*=" }, StringSplitOptions.RemoveEmptyEntries)[0];
                                    row["F_DOMAIN_VALUE"] = c.Split(new string[] { "=*=" }, StringSplitOptions.None)[1];
                                    u_answer.Rows.Add(row);
                                }
                            }
                        }
                    }
                }
            }

            /*
             * var arr1 = item["F_CIPHERTEXT1"].ToString().Split(new string[] { "@KSXT#" }, System.StringSplitOptions.None)[0].Split(new char[] { ']' }, System.StringSplitOptions.RemoveEmptyEntries).ToList();
             * foreach (var c in arr1)
             * {
             *  DataRow row = u_answer.NewRow();
             *  row["F_CIPHERTEXT_TYPE"] = "0";
             *  row["F_QUESTION_KEY"] = item["F_QUESTION_KEY"].ToString();
             *  row["F_TRADE_NO"] = item["F_TRADE_NO"].ToString();
             *  row["F_DOMAIN"] = c.Split('=')[0].Substring(2);
             *  row["F_DOMAIN_VALUE"] = c.Split('=')[1];
             *  u_answer.Rows.Add(row);
             * }
             * var arr2 = item["F_CIPHERTEXT2"].ToString().Split(new string[] { "@KSXT#" }, System.StringSplitOptions.None)[0].Split(new char[] { ']' }, System.StringSplitOptions.RemoveEmptyEntries).ToList();
             * foreach (var c in arr2)
             * {
             *  DataRow row = u_answer.NewRow();
             *  row["F_CIPHERTEXT_TYPE"] = "1";
             *  row["F_QUESTION_KEY"] = item["F_QUESTION_KEY"].ToString();
             *  row["F_TRADE_NO"] = item["F_TRADE_NO"].ToString();
             *  if (c.Split('=').Length == 2) //大于长度再截取
             *  {
             *      if (c.Split('=')[0].Length > 2)
             *      {
             *          row["F_DOMAIN"] = c.Split('=')[0].Substring(2);
             *      }
             *      else
             *      {
             *          break;
             *      }
             *      row["F_DOMAIN_VALUE"] = c.Split('=')[1];
             *  }
             *  else
             *  {
             *      break;
             *  }
             *  u_answer.Rows.Add(row);
             * }
             * var arr3 = item["F_CIPHERTEXT1"].ToString().Split(new string[] { "@KSXT#" }, System.StringSplitOptions.None)[1].Split(new char[] { '|' }, System.StringSplitOptions.None).ToList();
             *
             * for (int i = 0; i < arr3.Count(); i++)
             * {
             *  DataRow row = u_answer.NewRow();
             *  row["F_CIPHERTEXT_TYPE"] = "4";
             *  row["F_QUESTION_KEY"] = item["F_QUESTION_KEY"].ToString();
             *  row["F_TRADE_NO"] = item["F_TRADE_NO"].ToString();
             *  row["F_DOMAIN"] = i;
             *  row["F_DOMAIN_VALUE"] = arr3[i];
             *  u_answer.Rows.Add(row);
             * }
             * var arr4 = item["F_CIPHERTEXT2"].ToString().Split(new string[] { "@KSXT#" }, System.StringSplitOptions.None)[1].Split(new char[] { '|' }, System.StringSplitOptions.None).ToList();
             * for (int i = 0; i < arr4.Count(); i++)
             * {
             *  DataRow row = u_answer.NewRow();
             *  row["F_CIPHERTEXT_TYPE"] = "5";
             *  row["F_QUESTION_KEY"] = item["F_QUESTION_KEY"].ToString();
             *  row["F_TRADE_NO"] = item["F_TRADE_NO"].ToString();
             *  row["F_DOMAIN"] = i;
             *  row["F_DOMAIN_VALUE"] = arr4[i];
             *  u_answer.Rows.Add(row);
             * }
             */
            ListGrades.Add(new Grades()
            {
                Question   = "题号",
                Totalscore = "满分",
                Realscore  = "得分"
            });
            foreach (DataRow question in questions)
            {
                // 本题判分点
                List <DataRow> sta_point = new List <DataRow>();
                foreach (var xx in sta_answer)
                {
                    if (question["T_QUESTION_COLLECTION.F_KEY"].ToString() == xx["A.F_QUESTION_KEY"].ToString())
                    {
                        sta_point.Add(xx);
                    }
                }

                // 本题的总分
                double questionScore = double.Parse(question["T_INTEGRANT_QUESTION.F_SCORE"].ToString());

                {
                    this.AddDetail("****************************************************************");
                    this.AddDetail("****************************************************************");
                    this.AddDetail("****************************************************************");
                    this.AddDetail(question["T_QUESTION_COLLECTION.F_KEY"].ToString());
                    this.AddDetail(question["T_QUESTION_COLLECTION.F_QUESTION"].ToString() + "(" + sta_point.Count + "个判分点,共计" + questionScore + "分)");
                    //foreach (var item in sta_point)
                    //    this.AddDetail("" + item["T_TRADE_VALUE_STA.F_VALUE_TYPE"].ToString() + "," + item["T_TRADE_VALUE_STA.F_DOMAIN"].ToString() + "," + item["T_TRADE_VALUE_STA.F_DOMAIN_VALUE"].ToString() + "");

                    this.AddDetail("================================================================");
                }



                List <DataRow> result1 = new List <DataRow>();

                foreach (DataRow sta_porint_row in sta_point)
                {
                    //日志字符串
                    StringBuilder detail = new StringBuilder();
                    #region 标准答案
                    string staValueKey    = sta_porint_row["B.F_KEY"].ToString();
                    string staQuestionKey = sta_porint_row["A.F_QUESTION_KEY"].ToString();
                    string staTrade       = sta_porint_row["A.F_MENU_NO"].ToString();

                    string staLocation   = sta_porint_row["B.F_LOCATION"].ToString();
                    string staChannel    = sta_porint_row["B.F_CHANNEL"].ToString();
                    string staIoFlag     = sta_porint_row["B.F_IOFLAG"].ToString();
                    string staObjCode    = sta_porint_row["B.F_OBJCODE"].ToString();
                    string staFldCode    = sta_porint_row["B.F_FLDCODE"].ToString();
                    string staFldValue   = sta_porint_row["F_FLDVALUE"].ToString();
                    double staProportion = double.Parse(sta_porint_row["B.F_PROPORTION"].ToString()) / 100 * double.Parse(sta_porint_row["A.F_PROPORTION"].ToString()) / 100;
                    #endregion

                    #region 考生答案
                    string usrQuestionKey = string.Empty;
                    string usrTrade       = string.Empty;
                    string usrIOFlag      = string.Empty;
                    string usrLocation    = string.Empty;
                    string usrChannel     = string.Empty;
                    string usrFldCode     = string.Empty;
                    string usrFldValue    = string.Empty;
                    #endregion

                    #region  日志变量
                    string logUserTrade    = string.Empty;
                    string logIOFlag       = string.Empty;
                    string logLocation     = string.Empty;
                    string logChannel      = string.Empty;
                    string logUserFldCode  = string.Empty;
                    string logUserFldValue = string.Empty;
                    #endregion


                    DataRow[]      d           = u_answer.Select("F_QUESTION_KEY = '" + staQuestionKey + "'");
                    List <DataRow> listDataRow = d.ToList();
                    int            count       = 0;
                    foreach (DataRow user_answer_row in listDataRow)
                    {
                        count          = listDataRow.IndexOf(user_answer_row);
                        usrQuestionKey = user_answer_row["F_QUESTION_KEY"].ToString();
                        usrTrade       = user_answer_row["F_TRADE_NO"].ToString();
                        usrIOFlag      = user_answer_row["F_IOFLAG"].ToString();
                        usrLocation    = user_answer_row["F_LOCATION"].ToString();
                        usrChannel     = user_answer_row["F_CHANNEL"].ToString();
                        usrFldCode     = user_answer_row["F_DOMAIN"].ToString();
                        usrFldValue    = user_answer_row["F_DOMAIN_VALUE"].ToString();
                        //题目 相等(相同)
                        if (staQuestionKey == usrQuestionKey)
                        {
                            //交易 相等(相同)
                            if (staTrade == usrTrade)
                            {
                                //日志
                                logUserTrade = usrTrade;

                                //输入输出 相等(相同)
                                if (staIoFlag == usrIOFlag)
                                {
                                    //日志
                                    logIOFlag = usrIOFlag;

                                    //取值方式 相等(相同)[主界面、弹出页、打印页]
                                    if (staLocation == usrLocation)
                                    {
                                        //日志
                                        logLocation = usrLocation;

                                        //索引 相等(相同)[1,2,3……]
                                        if (staChannel == usrChannel)
                                        {
                                            //日志
                                            logChannel = usrChannel;

                                            //采分点 相等(相同)
                                            if (staFldCode.Trim() == usrFldCode.Trim())
                                            {
                                                //日志
                                                logUserFldCode  = usrFldCode;
                                                logUserFldValue = usrFldValue;

                                                //采分点的值 相等(相同)
                                                if (staFldValue.Trim() == usrFldValue.Trim())
                                                {
                                                    result1.Add(sta_porint_row);
                                                    break;
                                                }
                                                else if (staFldValue.IndexOf("@") > -1)
                                                {
                                                    int      n        = this.GetIndex(sta_point, sta_porint_row);
                                                    int      trade    = int.Parse(sta_porint_row["A.F_SORT"].ToString());
                                                    string[] varNames = question["T_INTEGRANT_QUESTION.F_VARIABLE"].ToString().Split('|')[1].Split(new string[] { "\\" }, System.StringSplitOptions.None);

                                                    if (trade >= varNames.Length || n >= varNames[trade].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Length)
                                                    {
                                                        this.AddDetail("此题答案的变量和题目中所需要的变量个数不一致。");
                                                        break;
                                                    }
                                                    string u = varNames[trade].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)[n];

                                                    var c = Ariable.Where((x) => { return(x.Name == u); }).ToArray();

                                                    if (c.Length != 1)
                                                    {
                                                        staFldValue = "匹配标准答案变量错误";
                                                        break;
                                                    }

                                                    staFldValue = staFldValue.Replace("@", c[0].Value);

                                                    if (staFldValue.Trim() == usrFldValue.Trim())
                                                    {
                                                        result1.Add(sta_porint_row);
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //string logUserTrade = string.Empty;
                    //string logIOFlag = string.Empty;
                    //string logLocation = string.Empty;
                    //string logChannel = string.Empty;
                    //string logUserFldCode = string.Empty;
                    //string logUserFldValue = string.Empty;

                    // 有错误才记下来
                    if (staFldValue.Trim() != logUserFldValue.Trim())
                    {
                        detail.AppendLine("----------------");
                        // detail.AppendLine(staValue.Trim() != logUserValue.Trim() ? "错误" : "");
                        detail.AppendLine("分值" + (questionScore * staProportion) + "");
                        detail.AppendLine("标准答案:交易=" + staTrade + ",输入/输出=" + staIoFlag + ",主界面/弹出页/打印页=" + staLocation + ",索引=" + staChannel + ",采分点=" + staFldCode + ",采分点值=" + staFldValue + ",交易明细GUID=" + staValueKey + "");
                        detail.AppendLine("用户答案:交易=" + logUserTrade + ",输入/输出=" + logIOFlag + ",主界面/弹出页/打印页=" + logLocation + ",索引=" + logChannel + ",采分点=" + logUserFldCode + ",采分点值=" + logUserFldValue + ",交易明细GUID=" + staValueKey + "");
                        detail.AppendLine("----------------");
                        this.AddDetail(detail.ToString());
                    }
                }

                double thisScore = 0;
                foreach (DataRow resultItem in result1)
                {
                    double p = double.Parse(resultItem["A.F_PROPORTION"].ToString()) / 100 * double.Parse(resultItem["B.F_PROPORTION"].ToString()) / 100;

                    thisScore += questionScore * p;
                    Score     += questionScore * p;
                }
                ListGrades.Add(new Grades()
                {
                    Question   = "第" + ListGrades.Count.ToString() + "题",
                    Totalscore = Convert.ToSingle(question["T_INTEGRANT_QUESTION.F_SCORE"]).ToString("f3"),
                    Realscore  = thisScore.ToString("f3")
                });
            }


            // todo
            if (Score > 100)
            {
                Score = 100;
            }

            // 保留两位小数
            Score = double.Parse(Score.ToString("f2"));

            // 最后答案更新到数据库中
            if (!ExamHandle.TryExecute(Sql.UPDATE_PAPERSCORE, Score.ToString(), logText.ToString(), PaperKey))
            {
                Messenger.Default.Send("保存得分出现错误.");
            }
        }