private void FillStudents(string target, MarkingPeriod mp, string gradeLevel, CourseViewModel course)
        {
            var students = Gradebook.Students;
            students = students.OrderBy(s => s.Name);
            if (chkMyStudents.IsChecked == true)
                students = students.Where(s => s.HasTeacher(UserViewModel.CurrentUser));
            if (course != null)
                students = students.Where(s => s.HasCourse(course, mp));

            if (gradeLevel != "All")
                students = students.Where(s => s.GradeLevel == gradeLevel);

            if (mp != null)
                students = students.Where(s => s.AttendedDuring(mp));

            if (!string.IsNullOrWhiteSpace(target))
            {
                target = target.ToUpper();
                students = students.Where(s => s.Name.ToUpper().Contains(target) || s.GradeLevel.ToUpper().Contains(target));
            }

            lst.ItemsSource = students;
            staCount.Content = "Students: " + students.Count();
        }
 internal bool HasCourse(CourseViewModel course, StaticModel.MarkingPeriod mp)
 {
     return _studentRow.HasCourse(course.CourseRow, mp);
 }
        static public Gradebook CreateDemo()
        {
            _rnd = new Random(1116);
            var rv         = new Gradebook();
            var firstNames = new List <string>()
            {
                "Dan", "Kelly", "Allegra", "Ramsey", "Max", "Lexi", "Indy"
            };
            var lastNames = new List <string>()
            {
                "Alpha", "Beta", "Gamma", "Delta", "Epsilon", "Zeta", "Eta", "Theta", "Iota", "Kappa", "Lambda", "Mu", "Nu", "Xi", "Omicron", "Pi", "Rho", "Sigma", "Tau", "Upsilon", "Phi", "Chi", "Psi", "Omega"
            };
            var dobStart = DateTime.Now.AddYears(-14);
            var dobEnd   = DateTime.Now.AddYears(-5);
            int iCourse  = 1000;

            var homeroomTeachers = new Dictionary <string, string>();
            int iClassroom       = 0;

            foreach (var gradeLevel in Maintenance.GradeLevelShorts)
            {
                homeroomTeachers.Add(gradeLevel, Maintenance.Users.Where(u => u.Role == RoleEnum.ClassroomInstructor).Select(t => t.Name).ToList()[iClassroom++]);
            }
            foreach (var quarter in MarkingPeriods.Singleton.Where(q => q.EndDate <= MarkingPeriod.Current.EndDate).OrderByDescending(q => q.ToString()))
            {
                foreach (var gradeLevel in Maintenance.GradeLevelShorts)
                {
                    foreach (var subject in Maintenance.Subjects)
                    {
                        var teacher = string.Empty;
                        if (CourseViewModel.ClassroomCourse(subject))
                        {
                            teacher = homeroomTeachers[gradeLevel];
                        }
                        else if (CourseViewModel.SmallGroupCourse(subject))
                        {
                            teacher = RandString(Maintenance.Users.Where(u => u.Role == RoleEnum.SmallGroupInstructor).Select(t => t.Name).ToList());
                        }
                        else if (CourseViewModel.SpecialCourse(subject))
                        {
                            teacher = RandString(Maintenance.Users.Where(u => u.Role == RoleEnum.SpecialInstructor).Select(t => t.Name).ToList());
                        }
                        else
                        {
                            teacher = null;
                        }

                        rv.Course.AddCourseRow((iCourse++).ToString(), subject, quarter.ToString(), RandString(Maintenance.Groups), teacher, Maintenance.GradeLevelNumber(gradeLevel));
                    }
                }
            }

            var extraComments = new List <string>()
            {
                "", "always", "never", "great", "usually", "best"
            };

            for (int iStudent = 0; iStudent < 100; iStudent++)
            {
                var name       = firstNames[iStudent % 7] + " " + lastNames[iStudent % (lastNames.Count)];
                var dob        = dobStart.AddDays(iStudent * (dobEnd - dobStart).TotalDays / 100);
                var enrolled   = dob.AddYears(5);
                var gradeLevel = AddGradeLevel(Maintenance.GradeLevelShorts[0], (DateTime.Today.Year - enrolled.Year));
                if (gradeLevel == null)
                {
                    //handle k better
                    gradeLevel = Maintenance.GradeLevelShorts.Last();
                }

                var student = rv.Student.AddStudentRow(Gradebook.MakeStudentKey(name, dob), name, dob, iStudent + " Fake St", "Bel Air, MD 22222", gradeLevel, enrolled, DateTime.MaxValue);

                foreach (var course in rv.Course.OrderByDescending(c => c.Quarter))
                {
                    var mpk       = MarkingPeriodKey.Parse(course.Quarter);
                    var mp        = MarkingPeriods.Singleton.Find(mpk);
                    var diffYears = MarkingPeriodKey.Current.EndingSchoolYear - mpk.EndingSchoolYear;

                    if (course.Level == Maintenance.GradeLevelNumber(AddGradeLevel(student.GradeLevel, 0 - diffYears)))
                    {
                        if (_rnd.NextDouble() < .1)
                        {
                            rv.Attendance.AddAttendanceRow(student, mp.StartDate.AddDays(_rnd.Next(0, 30)), AttendanceStatus.Absent.ToString());
                        }
                        if (_rnd.NextDouble() < .1)
                        {
                            rv.Attendance.AddAttendanceRow(student, mp.StartDate.AddDays(_rnd.Next(0, 30)), AttendanceStatus.Tardy.ToString());
                        }

                        if (mpk.Equals(MarkingPeriodKey.Current) && _rnd.Next(0, 2) == 0)
                        {
                            rv.Grade.AddGradeRow(student, course, string.Empty, string.Empty, string.Empty, ApprovalStage.Open.ToString());
                        }
                        else
                        {
                            var stage = ApprovalStage.Office;
                            if (mpk.Equals(MarkingPeriodKey.Current))
                            {
                                if (_rnd.Next(0, 2) == 0)
                                {
                                    stage = ApprovalStage.Instructor;
                                }
                                else
                                {
                                    stage = ApprovalStage.Classroom;
                                }
                            }

                            var specialGrade = string.Empty;
                            if (CourseViewModel.HasSpecialGrade(course.SubjectName))
                            {
                                if (course.SubjectName == "Reading")
                                {
                                    specialGrade = (int.Parse(course.Level) + _rnd.Next(0, 5)).ToString() + "-" + _rnd.Next(1, 10);
                                }
                                else if (course.SubjectName == "Math")
                                {
                                    specialGrade = (int.Parse(course.Level) + _rnd.Next(0, 5)).ToString() + "(" + _rnd.Next(1, 2).ToString() + ")";
                                }
                                else if (course.SubjectName == "Written Expression")
                                {
                                    specialGrade = "Paragraph";
                                }
                            }
                            rv.Grade.AddGradeRow(student, course, RandString(Maintenance.LetterGrades.Keys.ToList(), 3), specialGrade, Maintenance.FormatCommentFromList(RandString(Maintenance.Comments)) + " " + RandString(extraComments), stage.ToString());
                        }
                    }
                }
                var  quarters = MarkingPeriods.Singleton.OrderByDescending(q => q.ToString());
                bool withdraw = false;
                if (iStudent % 33 == 0)
                {
                    quarters = MarkingPeriods.Singleton.OrderBy(q => q.ToString());
                    withdraw = true;
                }

                foreach (var quarter in quarters)
                {
                    if (enrolled > quarter.EndDate)
                    {
                        continue;
                    }
                    foreach (var area in Maintenance.SelfDevelopmentAreas)
                    {
                        rv.SelfDevelopment.AddSelfDevelopmentRow(student, area, quarter.ToString(), _rnd.Next(3, 5), "Jekyll");
                    }

                    if (_rnd.NextDouble() > .9)
                    {
                        if (withdraw)
                        {
                            student.DateWithdrawn = quarter.EndDate.AddMonths(-1);
                        }
                        else
                        {
                            student.DateEnrolled = quarter.EndDate.AddMonths(-2);
                        }
                        //if (student.DateEnrolled > DateTime.Today)
                        //    student.DateEnrolled = DateTime.Today.AddDays(-1);
                        break;
                    }
                }
            }
            return(rv);
        }
Beispiel #4
0
 internal bool HasCourse(CourseViewModel course, StaticModel.MarkingPeriod mp)
 {
     return(_studentRow.HasCourse(course.CourseRow, mp));
 }