Exemple #1
0
        public ActionResult UserKPInfo(int UserID)
        {
            List <Knowledge>             KnowList      = new List <Knowledge>();
            List <CEDTS_KnowledgePoints> KnowPointList = _paper.GetAllKnowledges();

            foreach (var kp in KnowPointList)
            {
                string    Name  = string.Empty;
                Knowledge kown  = new Knowledge();
                Regex     regex = new Regex(@"[.\d]");
                Name = regex.Replace(kp.Title, "");
                List <CEDTS_TestAnswerKnowledgePoint> UMiInfo = _paper.SelectTAKByPeriod(BeginTime, EndTime, UserID, kp.KnowledgePointID);
                List <CEDTS_TestAnswerKnowledgePoint> SMiInfo = _paper.SelectATAKByPeriod(BeginTime, EndTime, kp.KnowledgePointID);
                if (UMiInfo.Count != 0)
                {
                    double SMi1 = 0;
                    double UMi1 = 0;
                    foreach (var tak in UMiInfo)
                    {
                        UMi1 += tak.KP_MasterRate.Value;
                    }
                    foreach (var tak in SMiInfo)
                    {
                        SMi1 += tak.KP_MasterRate.Value;
                    }
                    SMi1 = SMi1 / SMiInfo.Count * 100;
                    UMi1 = UMi1 / UMiInfo.Count * 100;
                    string SMi = SMi1 + "";
                    string UMi = UMi1 + "";
                    if (SMi.Length > 4)
                    {
                        SMi = SMi.Substring(0, SMi.IndexOf('.') + 2);
                    }
                    if (UMi.Length > 4)
                    {
                        UMi = UMi.Substring(0, UMi.IndexOf('.') + 2);
                    }
                    kown.KPName = Name;
                    kown.SMi    = double.Parse(SMi);
                    kown.UMi    = double.Parse(UMi);
                    KnowList.Add(kown);
                }
            }
            return(Json(KnowList));
        }