Ejemplo n.º 1
0
        //returns a stat model for absent charts for practice with averages for benchmarks for attendance
        //each chart uses the color randomizer for cool color changing properties
        public StatsModel AbsentChart()
        {
            //List of Jpeg Charts to Display
            StatsModel stats = new StatsModel();
            //Attendance pie chart

            var                    user  = Session["Users"] as Users;
            List <Users>           users = usersBLL.GetUsers().FindAll(m => m.TeamID == user.TeamID && m.RoleID != (int)Role.Coach);
            List <CountAttendance> count = new List <CountAttendance>();

            //store each players practice attendance ratios in a list for each player on the team
            foreach (Users player in users)
            {
                CountAttendance checkAttendance = MeaningfulCalculation.GetPracticeAttendanceUser(player.TeamID, player.UserID);
                count.Add(checkAttendance);
            }
            //get x and y values in array
            ArrayList xValue = new ArrayList();

            int[] yValue        = new int[count.Count];
            int[] absent        = new int[count.Count];
            int[] average       = new int[count.Count];
            int[] absentAverage = new int[count.Count];
            int   x             = 0;

            foreach (CountAttendance attendance in count)
            {
                xValue.Add(attendance.FullName.ToString());
                yValue[x] = attendance.NumPresent;
                absent[x] = attendance.NumAbsent;
                x++;
            }

            // place the names number present absent and the averages for line graphs
            stats.xValue  = xValue;
            stats.Present = yValue;
            for (x = 0; x < stats.xValue.Count; x++)
            {
                average[x]       = yValue.Sum() / yValue.Count();
                absentAverage[x] = absent.Sum() / absent.Count();
            }
            stats.Average       = average;
            stats.Absent        = absent;
            stats.AverageAbsent = absentAverage;


            //store in Session
            return(stats);
        }
Ejemplo n.º 2
0
        public static CountAttendance GetPracticeAttendanceUser(int teamid, int userid)
        {
            //create count attendance variable
            CountAttendance count = new CountAttendance();

            //get the users full name
            count.FullName = usersBLL.GetUsers().Find(m => m.UserID == userid).FullName;
            //get the total attendance for the team
            List <PracticeAttended> getAttendance = attendance.getPracticeAttendaned(teamid);
            //store in a list the total times the user has been present
            List <PracticeAttended> userPresent = getAttendance.FindAll(m => m.UserID == userid).FindAll(m => m.Attended == true);
            //store in a list the total times the user has been absent
            List <PracticeAttended> userAbsent = getAttendance.FindAll(m => m.UserID == userid).FindAll(m => m.Attended == false);
            //make another list to get the total number of times attendance has been tracked for the user
            List <PracticeAttended> total = new List <PracticeAttended>();

            //add both present and absent list to total
            total.AddRange(userPresent);
            total.AddRange(userAbsent);
            //count the number of absences and store in count
            count.NumAbsent = userAbsent.Count;
            //count the number of present
            count.NumPresent = userPresent.Count;
            //count the total number of times attendance has been tracked
            count.total = total.Count;
            //get a ratio of percentage absent
            if (count.total == 0)
            {
                count.AbsentRatio = 0;
                //get a percentage ratio of present
                count.PresentRatio = 0;
                //return attendance count for statistics
            }
            else
            {
                count.AbsentRatio = count.NumAbsent / count.total;
                //get a percentage ratio of present
                count.PresentRatio = count.NumAbsent / count.total;
                //return attendance count for statistics
            }

            return(count);
        }