Exemple #1
0
        public ActionResult AllExercise(int?id)
        {
            List <ScoreInfo> scorelist = new List <ScoreInfo>();
            int               UserID   = _user.SelectUserByAccout(User.Identity.Name).UserID;
            List <Guid?>      paclist  = _paper.SelectPaperByPeriod(BeginTime, EndTime, UserID, ClassID);
            List <CEDTS_User> userlist = _user.SelectUserByClassID(ClassID);

            foreach (var user in userlist)
            {
                ScoreInfo eachscore = new ScoreInfo();
                eachscore.UserID    = user.UserID;
                eachscore.StudNum   = user.StudentNumber;
                eachscore.StudName  = user.UserNickname;
                eachscore.TestNames = new List <string>();
                eachscore.TestScore = new List <double>();
                List <CEDTS_Test> usertest = _paper.SelectTestByPeriod(BeginTime, EndTime, user.UserID);
                foreach (var pac in paclist)
                {
                    CEDTS_Paper paper = _paper.GetPaperByID(Guid.Parse(pac.ToString()));
                    eachscore.TestNames.Add(paper.Title);
                    CEDTS_Test test = _paper.GetTestByPaperID(Guid.Parse(pac.ToString()), user.UserID);
                    if (test != null && test.IsFinished == true)
                    {
                        eachscore.TestScore.Add(double.Parse(test.TotalScore.ToString()) / double.Parse(paper.Score.ToString()) * 100);
                    }
                    else
                    {
                        eachscore.TestScore.Add(0);
                    }
                }

                int    donenum    = 0;
                double userscore  = 0.0;
                double totalscore = 0.0;
                foreach (var test in usertest)
                {
                    if (!paclist.Contains(test.PaperID))
                    {
                        List <CEDTS_PaperAssessment> assessment = _paper.SelectPaperAssessmentItem(test.PaperID);
                        foreach (var ass in assessment)
                        {
                            donenum += _paper.SelectQNByAssessmentID(Guid.Parse(ass.AssessmentItemID.ToString()));
                        }
                        userscore  += double.Parse(test.TotalScore.ToString());
                        totalscore += double.Parse(_paper.SelectPaper(test.PaperID).Score.ToString());
                    }
                }
                eachscore.DoneNum = donenum;
                if (totalscore == 0)
                {
                    eachscore.DoneScore = 0.0;
                }
                else
                {
                    eachscore.DoneScore = userscore / totalscore * 100;
                }
                double avescore = 0.0;
                foreach (var score in eachscore.TestScore)
                {
                    avescore += score;
                }
                eachscore.AveScore = (avescore + eachscore.DoneScore) / (eachscore.TestScore.Count + 1);
                scorelist.Add(eachscore);
            }
            ViewData["StartDate"] = BeginTime;
            ViewData["EndDate"]   = EndTime;
            ViewData["ClassName"] = ClassName;
            return(View(_paper.ScoreInfoPaged(id, scorelist)));
        }