コード例 #1
0
        public ActionResult UserItemInfo(int UserID)
        {
            ItemScale ItemInfo = new ItemScale();

            ItemInfo.Fortysix = new List <double>();
            ItemInfo.SScale   = new List <double>();
            ItemInfo.UScale   = new List <double>();

            ItemInfo.Fortysix.Add(12.4);
            ItemInfo.Fortysix.Add(9.87);
            ItemInfo.Fortysix.Add(8.64);
            ItemInfo.Fortysix.Add(12.4);
            ItemInfo.Fortysix.Add(13.6);
            ItemInfo.Fortysix.Add(12.4);
            ItemInfo.Fortysix.Add(18.5);
            ItemInfo.Fortysix.Add(12.4);
            ItemInfo.Fortysix.Add(12.4);

            int ItemTypeNum = _paper.SelectItemType().Count;

            for (int i = 1; i <= ItemTypeNum; i++)
            {
                List <CEDTS_TestAnswerTypeInfo> UItem = _paper.SelectTATByPeriod(BeginTime, EndTime, UserID, i);
                List <CEDTS_TestAnswerTypeInfo> SItem = _paper.SelectATATByPeriod(BeginTime, EndTime, i);
                if (UItem.Count != 0)
                {
                    double u1 = 0.0;
                    double s1 = 0.0;
                    foreach (var item in UItem)
                    {
                        u1 += item.CorrectRate.Value;
                    }
                    foreach (var item in SItem)
                    {
                        s1 += item.CorrectRate.Value;
                    }
                    u1 = u1 / UItem.Count;
                    s1 = s1 / SItem.Count;
                    switch (i)
                    {
                    case 1:
                        s1 = s1 * 1 * ItemInfo.Fortysix[0];
                        u1 = u1 * 1 * ItemInfo.Fortysix[0];
                        break;

                    case 2:
                        s1 = s1 * 1 * ItemInfo.Fortysix[1];
                        u1 = u1 * 1 * ItemInfo.Fortysix[1];
                        break;

                    case 3:
                        s1 = s1 * 1 * ItemInfo.Fortysix[2];
                        u1 = u1 * 1 * ItemInfo.Fortysix[2];
                        break;

                    case 4:
                        s1 = s1 * 1 * ItemInfo.Fortysix[3];
                        u1 = u1 * 1 * ItemInfo.Fortysix[3];
                        break;

                    case 5:
                        s1 = s1 * 1 * ItemInfo.Fortysix[4];
                        u1 = u1 * 1 * ItemInfo.Fortysix[4];
                        break;

                    case 6:
                        s1 = s1 * 1 * ItemInfo.Fortysix[5];
                        u1 = u1 * 1 * ItemInfo.Fortysix[5];
                        break;

                    case 7:
                        s1 = s1 * 1.5 * ItemInfo.Fortysix[6];
                        u1 = u1 * 1 * ItemInfo.Fortysix[6];
                        break;

                    case 8:
                        s1 = s1 * 0.5 * ItemInfo.Fortysix[8];
                        u1 = u1 * 1 * ItemInfo.Fortysix[8];
                        break;

                    case 9:
                        s1 = s1 * 1 * ItemInfo.Fortysix[7];
                        u1 = u1 * 1 * ItemInfo.Fortysix[7];
                        break;

                    default:
                        break;
                    }
                    string ss = s1 + "";
                    if (ss.Length > 4)
                    {
                        ss = ss.Substring(0, ss.IndexOf('.') + 3);
                    }

                    ItemInfo.SScale.Add(double.Parse(ss));
                    string uu = u1 + "";
                    if (uu.Length > 4)
                    {
                        uu = uu.Substring(0, uu.IndexOf('.') + 3);
                    }
                    ItemInfo.UScale.Add(double.Parse(uu));
                }
                else
                {
                    ItemInfo.SScale.Add(0.00);
                    ItemInfo.UScale.Add(0.00);
                }
            }
            double temp1 = ItemInfo.SScale[7];

            ItemInfo.SScale[7] = ItemInfo.SScale[8];
            ItemInfo.SScale[8] = temp1;
            double temp2 = ItemInfo.UScale[7];

            ItemInfo.UScale[7] = ItemInfo.UScale[8];
            ItemInfo.UScale[8] = temp2;
            return(Json(ItemInfo));
        }