public void CreateReportCard(string outFilename, MarkingPeriod period) { var currentSubjects = _student.Grades.GroupBy(g => g.Subject) .Where(subject => subject.Any(subGrade => subGrade.IsCurrentForPeriod(period.Key))) .OrderBy(subject => Maintenance.GetSubjectIndex(subject.Key)); var gradeReportFields = currentSubjects.Select((subject, i) => { var thisYearsGrades = subject.Where(subGrade => subGrade.ShouldShowOnReportCard(period)) .Select(subGrade => subGrade.GetGradeReportFields(period.Key, i + 1)); return(thisYearsGrades.SelectMany(x => x)); }).SelectMany(x => x); var outputProperties = gradeReportFields.Concat(GetPDFFields(this)) .Concat(GetReportLevelFields(period.Key)) .Concat(GetSelfDevFields(period.Key)); if (outFilename == null) { var tempDir = Path.GetTempPath(); Directory.CreateDirectory(tempDir); string tempFileName = Path.Combine(tempDir, GetDefaultReportCardFilename(period.Key) + "-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"); PDFWriter.WritePDF(tempFileName, outputProperties.ToDictionary(p => p.Key, p => p.Value)); Process.Start(tempFileName); } else { PDFWriter.WritePDF(outFilename, outputProperties.ToDictionary(p => p.Key, p => p.Value)); } }
public ActionResult <MarkingPeriod> GetMarkingPeriod(MarkingPeriod markingPeriod) { MarkingPeriod markingPeriodModel = new MarkingPeriod(); try { if (markingPeriod.SchoolId > 0) { markingPeriodModel = _markingPeriodService.GetMarkingPeriod(markingPeriod); } else { markingPeriodModel.TenantId = markingPeriod.TenantId; markingPeriodModel._token = markingPeriod._token; markingPeriodModel._tenantName = markingPeriod._tenantName; markingPeriodModel._failure = true; markingPeriodModel._message = "Please enter valid school id"; } } catch (Exception es) { markingPeriodModel._failure = true; markingPeriodModel._message = es.Message; } return(markingPeriodModel); }
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(); }
private District PrepareCommonViewDataForSchoolPerson(StartupData startupData) { //TODO: render data for demo school var district = PrepareCommonViewData(); ViewData[ViewConstants.UNSHOWN_NOTIFICATIONS_COUNT] = startupData.UnshownNotificationsCount; var mps = startupData.MarkingPeriods; MarkingPeriod markingPeriod = mps.Where(x => x.StartDate <= Context.NowSchoolYearTime).OrderBy(x => x.StartDate).LastOrDefault(); if (markingPeriod != null && SchoolLocator.Context.SchoolLocalId.HasValue) { PrepareJsonData(MarkingPeriodViewData.Create(markingPeriod), ViewConstants.MARKING_PERIOD); var gradingPeriod = startupData.GradingPeriod; if (gradingPeriod != null) { PrepareJsonData(ShortGradingPeriodViewData.Create(gradingPeriod), ViewConstants.GRADING_PERIOD); } } PrepareJsonData(AlphaGradeViewData.Create(startupData.AlphaGrades), ViewConstants.ALPHA_GRADES); PrepareJsonData(AlternateScoreViewData.Create(startupData.AlternateScores), ViewConstants.ALTERNATE_SCORES); PrepareJsonData(GradingPeriodViewData.Create(startupData.GradingPeriods), ViewConstants.GRADING_PERIODS); PrepareJsonData(MarkingPeriodViewData.Create(mps), ViewConstants.MARKING_PERIODS); var sy = SchoolLocator.SchoolYearService.GetCurrentSchoolYear(); PrepareJsonData(SchoolYearViewData.Create(sy), ViewConstants.SCHOOL_YEAR); PrepareJsonData(SchoolLocator.SchoolYearService.GetYears(), ViewConstants.YEARS); return(district); }
internal bool HasCourse(CourseRow courseRow, MarkingPeriod mp) { if (courseRow == null) { return(true); } return(GetGradeRows().Any(c => c.CourseRow.CourseKey == courseRow.CourseKey)); }
//public static GradingStudentClassSummaryViewData Create(StudentClassGradeStats gradingStatsPerDate // , MarkingPeriod currentMp, IList<GradingClassSummaryViewData> gradingPerMp) //{ // return new GradingStudentClassSummaryViewData // { // CurrentMarkingPeriod = MarkingPeriodViewData.Create(currentMp), // AvgPerDate = GradingStatsByDateViewData.Create(gradingStatsPerDate.GradeAvgPerDates), // GradingPerMp = gradingPerMp // }; //} public static GradingStudentClassSummaryViewData Create(MarkingPeriod currentMp, IList <AnnouncementViewData> announcementsView , ClassGradingBoxesViewData gradingPeriodBoxes) { return(new GradingStudentClassSummaryViewData { CurrentMarkingPeriod = MarkingPeriodViewData.Create(currentMp), Announcements = announcementsView, GradingPeriodBoxes = gradingPeriodBoxes }); }
internal bool AttendedDuring(MarkingPeriod mp) { DateTime enrolled = DateEnrolled; DateTime?withdrawn = null; if (!IsDateWithdrawnNull()) { withdrawn = DateWithdrawn; } return(enrolled < mp.EndDate && (withdrawn == null || withdrawn > mp.EndDate)); }
public Notification BuildEndMarkingPeriodNotification(DateTime created, MarkingPeriod markingPeriod, Person recipient, int endDays, bool nextMarkingPeriodExist, bool nextMpNotAssignedToClass) { var otherModel = new { EndDays = endDays, NextMarkingPeriodNotExist = nextMarkingPeriodExist, NotAssignedToClass = nextMpNotAssignedToClass }; return(BuildNotificationFromTemplate(NotificationTemplateProvider.END_MARKINGPERIOD_NOTIFICATION_TO_ADMIN, NotificationType.MarkingPeriodEnding, recipient, null, null, markingPeriod, null, null, otherModel)); }
public static MarkingPeriodViewData Create(MarkingPeriod markingPeriod) { var res = new MarkingPeriodViewData { Id = markingPeriod.Id, Name = markingPeriod.Name, StartDate = markingPeriod.StartDate, EndDate = markingPeriod.EndDate, Description = markingPeriod.Description, WeekDays = markingPeriod.WeekDays }; return(res); }
public MarkingPeriod GetMarkingPeriod(MarkingPeriod markingPeriod) { MarkingPeriod markingPeriodModel = new MarkingPeriod(); try { var MarkingperiodViews = this.context?.SchoolYears.Where(x => x.SchoolId == markingPeriod.SchoolId && x.TenantId == markingPeriod.TenantId && x.AcademicYear == markingPeriod.AcademicYear).Select(x => new SchoolYearView() { SchoolId = x.SchoolId, MarkingPeriodId = x.MarkingPeriodId, ShortName = x.ShortName, Title = x.Title, TenantId = x.TenantId, IsParent = true, DoesComments = x.DoesComments, DoesExam = x.DoesExam, DoesGrades = x.DoesGrades, EndDate = x.EndDate, PostStartDate = x.PostStartDate, PostEndDate = x.PostEndDate, StartDate = x.StartDate, Children = this.context.Semesters.Where(y => y.YearId == x.MarkingPeriodId && y.AcademicYear == markingPeriod.AcademicYear).Select(y => new SchoolSemesterView() { TenantId = y.TenantId, DoesComments = y.DoesComments, DoesExam = y.DoesExam, DoesGrades = y.DoesGrades, StartDate = y.StartDate, EndDate = y.EndDate, PostStartDate = y.PostStartDate, PostEndDate = y.PostEndDate, Title = y.Title, SchoolId = y.SchoolId, YearId = (int)y.YearId, MarkingPeriodId = y.MarkingPeriodId, IsParent = false, ShortName = y.ShortName, Children = this.context.Quarters.Where(z => z.SemesterId == y.MarkingPeriodId && z.AcademicYear == markingPeriod.AcademicYear).Select(z => new SchoolQuarterView() { MarkingPeriodId = z.MarkingPeriodId, SemesterId = (int)z.SemesterId, IsParent = false, SchoolId = z.SchoolId, Title = z.Title, ShortName = z.ShortName, TenantId = z.TenantId, DoesComments = z.DoesComments, DoesExam = z.DoesExam, DoesGrades = z.DoesGrades, StartDate = z.StartDate, EndDate = z.EndDate, PostStartDate = z.PostStartDate, PostEndDate = z.PostEndDate, Children = this.context.ProgressPeriods.Where(a => a.QuarterId == z.MarkingPeriodId && a.AcademicYear == markingPeriod.AcademicYear).Select(a => new SchoolProgressPeriodView() { IsParent = false, MarkingPeriodId = a.MarkingPeriodId, SchoolId = a.SchoolId, QuarterId = a.QuarterId, ShortName = a.ShortName, TenantId = a.TenantId, Title = a.Title, DoesComments = a.DoesComments, DoesExam = a.DoesExam, DoesGrades = a.DoesGrades, StartDate = a.StartDate, EndDate = a.EndDate, PostStartDate = a.PostStartDate, PostEndDate = a.PostEndDate }).ToList() }).ToList() }).ToList() }).ToList(); markingPeriodModel.schoolYearsView = MarkingperiodViews; markingPeriodModel._tenantName = markingPeriod._tenantName; markingPeriodModel._token = markingPeriod._token; markingPeriodModel._failure = false; markingPeriodModel.TenantId = markingPeriod.TenantId; markingPeriodModel.SchoolId = markingPeriod.SchoolId; } catch (Exception es) { markingPeriodModel._failure = true; markingPeriodModel._message = es.Message; } return(markingPeriodModel); }
internal static MarkingPeriods DemoMarkingPeriod() { var rv = new MarkingPeriods(); for (int year = 2011; year <= 2013; year++) { for (int quarter = 1; quarter <= 4; quarter++) { var key = new MarkingPeriodKey(quarter, year); var mp = new MarkingPeriod(key, ApproximateStartDate(key), ApproximateEndDate(key), 45); rv.Add(mp); } } return(rv); }
public IEnumerable <KeyValuePair <string, string> > GetGradeReportFields(MarkingPeriodKey period, int rowIndex) { yield return(new KeyValuePair <string, string>( string.Format(MarkingPeriodKey.Parse(MarkingPeriod.ToString()).Quarter + "Row{0}", rowIndex), LetterGrade + (!string.IsNullOrEmpty(SpecialGrade) ? "\n" + SpecialGrade : ""))); if (IsCurrentForPeriod(period)) { yield return(new KeyValuePair <string, string>( "SubjectRow" + rowIndex, Subject)); yield return(new KeyValuePair <string, string>( "CommentRow" + rowIndex, Comment)); yield return(new KeyValuePair <string, string>( "TeacherRow" + rowIndex, Teacher)); } }
private void OnGenerateReportCard(object sender, RoutedEventArgs e) { if (!UserViewModel.CurrentUser.CanExportReportCards) { MessageBox.Show("You do not have permission to export a report card!"); return; } var report = (StudentReport)grdStudentReport.SelectedItem; MarkingPeriod mp = MarkingPeriod.Current; if (report != null) { mp = MarkingPeriods.Singleton.Find(MarkingPeriodKey.Parse(report.Quarter)); } try { var reportCard = new ReportCard(_student); reportCard.CreateReportCard(null, mp); } catch (System.IO.IOException) { MessageBox.Show("Error writing the report card! Check to ensure you have permission to write to this folder and that the file is not currently in use."); } }
public MarkingPeriod GetMarkingPeriod(MarkingPeriod markingPeriod) { MarkingPeriod markingPeriodModel = new MarkingPeriod(); try { if (TokenManager.CheckToken(markingPeriod._tenantName + markingPeriod._userName, markingPeriod._token)) { markingPeriodModel = this.markingperiodRepository.GetMarkingPeriod(markingPeriod); } else { markingPeriodModel._failure = true; markingPeriodModel._message = TOKENINVALID; } } catch (Exception es) { markingPeriodModel._failure = true; markingPeriodModel._message = es.Message; } return(markingPeriodModel); }
internal bool AttendedDuring(MarkingPeriod mp) { return _studentRow.AttendedDuring(mp); }
private Notification BuildNotificationFromTemplate(string templateName, NotificationType type, Person recipient, Announcement announcement = null , Guid?applicationId = null, MarkingPeriod markingPeriod = null, PrivateMessage privateMessage = null, Person asker = null, object other = null, string baseUrl = null) { var parameters = new List <string> { GetBaseUrlByRole(recipient, baseUrl) }; var notification = new NotificationDetails { PersonRef = recipient.Id, Person = recipient, RoleRef = recipient.RoleRef, Shown = false, Type = type, Created = serviceLocator.Context.NowSchoolTime }; if (announcement != null) { notification.AnnouncementRef = announcement.Id; notification.Announcement = announcement; } if (applicationId.HasValue) { //notification.Application = application; notification.ApplicationRef = applicationId; } if (markingPeriod != null) { notification.MarkingPeriod = markingPeriod; notification.MarkingPeriodRef = markingPeriod.Id; } if (privateMessage != null) { notification.PrivateMessage = privateMessage; notification.PrivateMessageRef = privateMessage.Id; } if (asker != null) { notification.QuestionPerson = asker; notification.QuestionPersonRef = asker.Id; parameters.Add(GetRelativeUrlByRole(asker)); } var model = new { Notification = notification, Other = other }; string message = RenderService.Render(templateName, model, parameters); notification.Message = message; return(notification); }
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 static MarkingPeriods DemoMarkingPeriod() { var rv = new MarkingPeriods(); for (int year = 2011; year <= 2013; year++) { for (int quarter = 1; quarter <= 4; quarter++) { var key = new MarkingPeriodKey(quarter, year); var mp = new MarkingPeriod(key, ApproximateStartDate(key), ApproximateEndDate(key), 45); rv.Add(mp); } } return rv; }
public bool ShouldShowOnReportCard(MarkingPeriod period) { return MarkingPeriod.Key.EndingSchoolYear == period.Key.EndingSchoolYear && MarkingPeriod.EndDate <= period.EndDate; }
public MarkingPeriod GetMarkingPeriod(MarkingPeriod markingPeriod) { MarkingPeriod markingPeriodModel = new MarkingPeriod(); try { var MarkingperiodData = this.context?.SchoolYears.Include(x => x.Semesters).ThenInclude(p => p.Quarters).ThenInclude(a => a.ProgressPeriods).Where(x => x.SchoolId == markingPeriod.SchoolId && x.TenantId == markingPeriod.TenantId && x.AcademicYear == markingPeriod.AcademicYear).ToList(); if (MarkingperiodData.Count > 0) { foreach (var year in MarkingperiodData) { SchoolYearView schoolYearView = new SchoolYearView(); schoolYearView.TenantId = year.TenantId; schoolYearView.SchoolId = year.SchoolId; schoolYearView.MarkingPeriodId = year.MarkingPeriodId; schoolYearView.Title = year.Title; schoolYearView.ShortName = year.ShortName; schoolYearView.DoesComments = year.DoesComments; schoolYearView.DoesExam = year.DoesExam; schoolYearView.DoesGrades = year.DoesGrades; schoolYearView.StartDate = year.StartDate; schoolYearView.EndDate = year.EndDate; schoolYearView.PostEndDate = year.PostEndDate; schoolYearView.PostStartDate = year.PostStartDate; schoolYearView.IsParent = true; var semesterList = year.Semesters.ToList(); foreach (var semester in semesterList) { SchoolSemesterView schoolSemesterView = new SchoolSemesterView(); schoolSemesterView.TenantId = semester.TenantId; schoolSemesterView.SchoolId = semester.SchoolId; schoolSemesterView.MarkingPeriodId = semester.MarkingPeriodId; schoolSemesterView.Title = semester.Title; schoolSemesterView.YearId = (int)semester.YearId; schoolSemesterView.ShortName = semester.ShortName; schoolSemesterView.DoesComments = semester.DoesComments; schoolSemesterView.DoesExam = semester.DoesExam; schoolSemesterView.DoesGrades = semester.DoesGrades; schoolSemesterView.StartDate = semester.StartDate; schoolSemesterView.EndDate = semester.EndDate; schoolSemesterView.PostEndDate = semester.PostEndDate; schoolSemesterView.PostStartDate = semester.PostStartDate; schoolSemesterView.IsParent = false; schoolYearView.Children.Add(schoolSemesterView); var quaterList = semester.Quarters.ToList(); foreach (var quarter in quaterList) { SchoolQuarterView schoolQuarterView = new SchoolQuarterView(); schoolQuarterView.TenantId = quarter.TenantId; schoolQuarterView.SchoolId = quarter.SchoolId; schoolQuarterView.MarkingPeriodId = quarter.MarkingPeriodId; schoolQuarterView.Title = quarter.Title; schoolQuarterView.SemesterId = (int)quarter.SemesterId; schoolQuarterView.ShortName = quarter.ShortName; schoolQuarterView.DoesComments = quarter.DoesComments; schoolQuarterView.DoesExam = quarter.DoesExam; schoolQuarterView.DoesGrades = quarter.DoesGrades; schoolQuarterView.StartDate = quarter.StartDate; schoolQuarterView.EndDate = quarter.EndDate; schoolQuarterView.PostEndDate = quarter.PostEndDate; schoolQuarterView.PostStartDate = quarter.PostStartDate; schoolQuarterView.IsParent = false; schoolSemesterView.Children.Add(schoolQuarterView); var ProgressPeriodList = quarter.ProgressPeriods.ToList(); foreach (var progressPeriod in ProgressPeriodList) { SchoolProgressPeriodView schoolProgressPeriodView = new SchoolProgressPeriodView(); schoolProgressPeriodView.TenantId = progressPeriod.TenantId; schoolProgressPeriodView.SchoolId = progressPeriod.SchoolId; schoolProgressPeriodView.MarkingPeriodId = progressPeriod.MarkingPeriodId; schoolProgressPeriodView.Title = progressPeriod.Title; schoolProgressPeriodView.QuarterId = (int)progressPeriod.QuarterId; schoolProgressPeriodView.ShortName = progressPeriod.ShortName; schoolProgressPeriodView.DoesComments = progressPeriod.DoesComments; schoolProgressPeriodView.DoesExam = progressPeriod.DoesExam; schoolProgressPeriodView.DoesGrades = progressPeriod.DoesGrades; schoolProgressPeriodView.StartDate = progressPeriod.StartDate; schoolProgressPeriodView.EndDate = progressPeriod.EndDate; schoolProgressPeriodView.PostEndDate = progressPeriod.PostEndDate; schoolProgressPeriodView.PostStartDate = progressPeriod.PostStartDate; schoolProgressPeriodView.IsParent = false; schoolQuarterView.Children.Add(schoolProgressPeriodView); } } } markingPeriodModel.schoolYearsView.Add(schoolYearView); } } if (markingPeriodModel.schoolYearsView.Count > 0) { markingPeriodModel._tenantName = markingPeriod._tenantName; markingPeriodModel._token = markingPeriod._token; markingPeriodModel._failure = false; markingPeriodModel.TenantId = markingPeriod.TenantId; markingPeriodModel.SchoolId = markingPeriod.SchoolId; } else { markingPeriodModel._tenantName = markingPeriod._tenantName; markingPeriodModel._token = markingPeriod._token; markingPeriodModel._failure = true; markingPeriodModel.TenantId = markingPeriod.TenantId; markingPeriodModel.SchoolId = markingPeriod.SchoolId; markingPeriodModel._message = NORECORDFOUND; } } catch (Exception es) { markingPeriodModel.schoolYearsView = null; markingPeriodModel._failure = true; markingPeriodModel._message = es.Message; } return(markingPeriodModel); }
internal bool AttendedDuring(MarkingPeriod mp) { DateTime enrolled = DateEnrolled; DateTime? withdrawn = null; if (!IsDateWithdrawnNull()) withdrawn = DateWithdrawn; return (enrolled < mp.EndDate && (withdrawn == null || withdrawn > mp.EndDate)); }
internal bool HasCourse(CourseRow courseRow, MarkingPeriod mp) { if (courseRow == null) return true; return GetGradeRows().Any(c => c.CourseRow.CourseKey == courseRow.CourseKey); }
internal bool AttendedDuring(MarkingPeriod mp) { return(_studentRow.AttendedDuring(mp)); }
public bool ShouldShowOnReportCard(MarkingPeriod period) { return(MarkingPeriod.Key.EndingSchoolYear == period.Key.EndingSchoolYear && MarkingPeriod.EndDate <= period.EndDate); }