public void Save() { try { if (!HasChanges()) { return; } var other = new Gradebook(); other.ReadXml("gradebook.xml"); if (other.Config.Guid != Config.Guid) { if (CheckMerge(other)) { return; } } } catch (Exception exc) { } var guid = Guid.NewGuid(); Config.Guid = guid.ToString(); WriteXml("gradebook.xml"); Maintenance.BackupFile("gradebook.xml", CurrentUserName); /*Student.WriteXml("studentTable.xml"); * Grade.WriteXml("gradeTable.xml"); * Course.WriteXml("courseTable.xml"); */ }
private bool CheckMerge(Gradebook other) { // handles may overwrite other changes on same lines var changes = GetChanges(); other.Merge(changes, false); other.Save(); Read(); return(true); }
public static Gradebook Read() { var rv = new Gradebook(); try { rv.ReadXml("gradebook.xml"); rv.AcceptChanges(); } catch (System.Exception) { return null; } return rv; }
public static Gradebook Read() { var rv = new Gradebook(); try { rv.ReadXml("gradebook.xml"); rv.AcceptChanges(); } catch (System.Exception) { return(null); } return(rv); }
public SDScoreViewModel(Gradebook.SelfDevelopmentRow row) { _row = row; }
public CourseViewModel(Gradebook.CourseRow courseRow) { CourseRow = courseRow; }
public TestDemoFactory() { _gradebook = DemoFactory.CreateDemo(); }
internal void Reset() { _gradebook = null; UserViewModel.Reset(); }
public GradebookViewModel(Gradebook gradebook) { _gradebook = gradebook; }
public static 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; }
public StudentViewModel(Gradebook.StudentRow studentRow) { _studentRow = studentRow; }
private bool CheckMerge(Gradebook other) { // handles may overwrite other changes on same lines var changes = GetChanges(); other.Merge(changes, false); other.Save(); Read(); return true; }
public void Save() { try { if (!HasChanges()) return; var other = new Gradebook(); other.ReadXml("gradebook.xml"); if (other.Config.Guid != Config.Guid) { if (CheckMerge(other)) return; } } catch (Exception exc) { } var guid = Guid.NewGuid(); Config.Guid = guid.ToString(); WriteXml("gradebook.xml"); Maintenance.BackupFile("gradebook.xml", CurrentUserName); /*Student.WriteXml("studentTable.xml"); Grade.WriteXml("gradeTable.xml"); Course.WriteXml("courseTable.xml"); */ }
public GradeViewModel(Gradebook.GradeRow gradeRow) { _gradeRow = gradeRow; }