From 655c5b70ed9a7b4e12cad112d1acad97572bdb17 Mon Sep 17 00:00:00 2001 From: Darinka Loncar <149894872+darinkaloncar@users.noreply.github.com> Date: Mon, 27 May 2024 09:41:10 -0700 Subject: [PATCH 1/9] [Add] method for forming grid --- LangLang/BusinessLogic/UseCases/PdfService.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/LangLang/BusinessLogic/UseCases/PdfService.cs b/LangLang/BusinessLogic/UseCases/PdfService.cs index 4e602a8..4efadd4 100644 --- a/LangLang/BusinessLogic/UseCases/PdfService.cs +++ b/LangLang/BusinessLogic/UseCases/PdfService.cs @@ -49,6 +49,19 @@ public PdfGrid DataToGrid(Dictionary data) } return grid; } - + public PdfGrid DataToGrid(Dictionary> data) + { + PdfGrid grid = new PdfGrid(); + grid.Columns.Add(4); + foreach (var item in data) + { + PdfGridRow row = grid.Rows.Add(); + row.Cells[0].Value = item.Key; + row.Cells[1].Value = item.Value[0].ToString(); + row.Cells[2].Value = item.Value[1].ToString(); + row.Cells[3].Value = item.Value[2].ToString(); + } + return grid; + } } } From 0b365e755af725abd782e0186cf311f6b855592c Mon Sep 17 00:00:00 2001 From: Darinka Loncar <149894872+darinkaloncar@users.noreply.github.com> Date: Mon, 27 May 2024 09:41:48 -0700 Subject: [PATCH 2/9] [Update] method for generating a report of course grades --- LangLang/BusinessLogic/UseCases/ReportService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LangLang/BusinessLogic/UseCases/ReportService.cs b/LangLang/BusinessLogic/UseCases/ReportService.cs index dad98fc..3cfc21b 100644 --- a/LangLang/BusinessLogic/UseCases/ReportService.cs +++ b/LangLang/BusinessLogic/UseCases/ReportService.cs @@ -89,9 +89,9 @@ public double CalculatePassingPercentage(Course course) return (passed / attended)*100; } - public Dictionary> GetAverageGradesOfCourses() + public Dictionary> GetAverageGradesOfCourses() { - Dictionary> averages = new(); + Dictionary> averages = new(); CourseService courseService = new(); List courses = courseService.GetCoursesHeldInLastYear(); GradeService gradeService = new(); @@ -102,7 +102,7 @@ public Dictionary> GetAverageGradesOfCourses() avg.Add(gradeService.GetAverageKnowledgeGrade(course)); avg.Add(gradeService.GetAverageActivityGrade(course)); avg.Add(tutorRatingService.GetAverageTutorRating(course)); - averages.Add(course, avg); + averages.Add(course.ToPdfString(), avg); } return averages; } From 86812383f588d2c5a83e4943726194cd7c0019d2 Mon Sep 17 00:00:00 2001 From: Darinka Loncar <149894872+darinkaloncar@users.noreply.github.com> Date: Mon, 27 May 2024 09:42:57 -0700 Subject: [PATCH 3/9] [Add] method for sending course grades report to director --- LangLang/BusinessLogic/UseCases/SenderService.cs | 12 ++++++++++++ .../DirectorViewModels/ReportsViewModel.cs | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/LangLang/BusinessLogic/UseCases/SenderService.cs b/LangLang/BusinessLogic/UseCases/SenderService.cs index cab8127..6d1dc4d 100644 --- a/LangLang/BusinessLogic/UseCases/SenderService.cs +++ b/LangLang/BusinessLogic/UseCases/SenderService.cs @@ -37,6 +37,18 @@ public void SendResults(ExamSlot exam) EmailService.SendEmail(student.Profile.Email, subject, body); } } + public void SendAverageCourseGrades(Director director) + { + var reportService = new ReportService(); + var pdfService = new PdfService(); + + var reportName = "Average grades and tutor rating per course"; + var headers = new string[] { "Course", "Average knowledge grade", "Average activity grade", "Average tutor rating" }; + + var document = PdfService.GeneratePdf>>(reportService.GetAverageGradesOfCourses(), headers, reportName, data => pdfService.DataToGrid(data)); + EmailService.SendEmail(director.Profile.Email, reportName, "", document); + + } public void SendAveragePoints(Director director) { diff --git a/LangLang/WPF/ViewModels/DirectorViewModels/ReportsViewModel.cs b/LangLang/WPF/ViewModels/DirectorViewModels/ReportsViewModel.cs index c951099..74bf378 100644 --- a/LangLang/WPF/ViewModels/DirectorViewModels/ReportsViewModel.cs +++ b/LangLang/WPF/ViewModels/DirectorViewModels/ReportsViewModel.cs @@ -25,6 +25,13 @@ public void SentAveragePenaltyPoints() ShowSuccess(); } + public void SentAverageCourseGrades() + { + var senderService = new SenderService(); + senderService.SendAverageCourseGrades(_director); + ShowSuccess(); + } + private void ShowSuccess() { MessageBox.Show("Successfully completed!", "Notification", MessageBoxButton.OK, MessageBoxImage.Information); From 4cc27292d328fd2f3d077d6488278290ce3f522f Mon Sep 17 00:00:00 2001 From: Darinka Loncar <149894872+darinkaloncar@users.noreply.github.com> Date: Mon, 27 May 2024 09:43:36 -0700 Subject: [PATCH 4/9] [Update] button for sending the report and implement click action listener --- LangLang/WPF/Views/DirectorView/Tabs/Reports.xaml | 2 +- LangLang/WPF/Views/DirectorView/Tabs/Reports.xaml.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/LangLang/WPF/Views/DirectorView/Tabs/Reports.xaml b/LangLang/WPF/Views/DirectorView/Tabs/Reports.xaml index 29601f1..2c25ff3 100644 --- a/LangLang/WPF/Views/DirectorView/Tabs/Reports.xaml +++ b/LangLang/WPF/Views/DirectorView/Tabs/Reports.xaml @@ -26,7 +26,7 @@