Exemple #1
0
        public void SuccessReport_TwoClasses_TwoStudents_BothReceiveA_CompletedCourseCountIsTwo_EachClassCompletedAndPassedCountIsOne_DroppedIsZero_UniqueIsOne()
        {
            var classWithGradeList = new List <ClassWithGradeDTO>()
            {
                new ClassWithGradeDTO()
                {
                    CourseName     = "History",
                    CRN            = 111,
                    DepartmentName = "History Dept",
                    FinalGrade     = Grade.A
                },
                new ClassWithGradeDTO()
                {
                    CourseName     = "English",
                    CRN            = 123,
                    DepartmentName = "English Dept",
                    FinalGrade     = Grade.A
                },
            };

            var results = ReportsBusinessLogic.SuccessReport(classWithGradeList);

            Assert.Equal(2, results.Count);
            Assert.Equal(1, results.Where(x => x.CRN == 111).FirstOrDefault().CompletedCourseCount);
            Assert.Equal(1, results.Where(x => x.CRN == 111).FirstOrDefault().PassedSuccessfullyCount);
            Assert.Equal(0, results.Where(x => x.CRN == 111).FirstOrDefault().DroppedStudentCount);
            Assert.Equal(1, results.Where(x => x.CRN == 111).FirstOrDefault().UniqueStudentCount);
            Assert.Equal(1, results.Where(x => x.CRN == 123).FirstOrDefault().CompletedCourseCount);
            Assert.Equal(1, results.Where(x => x.CRN == 123).FirstOrDefault().PassedSuccessfullyCount);
            Assert.Equal(0, results.Where(x => x.CRN == 123).FirstOrDefault().DroppedStudentCount);
            Assert.Equal(1, results.Where(x => x.CRN == 123).FirstOrDefault().UniqueStudentCount);
        }
Exemple #2
0
        public async Task <IActionResult> SuccessReport(int semesterId)
        {
            var studentCourses = from item in _sessionRepo.GetAll()
                                 from course in item.SessionClasses
                                 where item.SemesterCode == semesterId
                                 select new
            {
                item.PersonId,
                course.Class,
                course.Class.Department,
            };

            List <ClassWithGradeDTO> classessWithGrades = new List <ClassWithGradeDTO>();

            foreach (var item in studentCourses.Distinct())
            {
                try
                {
                    var grade = await _bannerService.GetStudentGrade(item.PersonId, item.Class.CRN, semesterId);

                    classessWithGrades.Add(grade);
                }
                catch
                {
                    throw new TCSException("Something went wrong");
                }
            }

            return(Ok(ReportsBusinessLogic.SuccessReport(classessWithGrades)));
        }
Exemple #3
0
        public async Task <IActionResult> SuccessReport([FromRoute] int semesterCode)
        {
            var tasks = _sessionRepo.GetAll(x => x.SemesterCode == semesterCode &&
                                            x.Person.PersonType == PersonType.Student)
                        .SelectMany(x => x.SessionClasses.Select(s => new { x.PersonId, s.Class.CRN }))
                        .Distinct()
                        .Select(x => _bannerService.GetStudentGrade(x.PersonId, x.CRN, semesterCode));

            var classGrades = await Task.WhenAll(tasks);

            return(Ok(ReportsBusinessLogic.SuccessReport(classGrades)));
        }
Exemple #4
0
        public void SuccessReport_APassedInClassGradeIsNull_ShouldNotFailDueToNull()
        {
            var classWithGradeList = new List <ClassWithGradeDTO>()
            {
                new ClassWithGradeDTO()
                {
                    CourseName     = "CS101",
                    CRN            = 1324,
                    DepartmentName = "STEM",
                    FinalGrade     = Grade.A
                },
                null,
            };
            var results = ReportsBusinessLogic.SuccessReport(classWithGradeList);

            Assert.NotEmpty(results);
        }
Exemple #5
0
        public void SuccessReport_OneClass_StudentReceivedI_ClassPassedSuccessfullyIsOne_ClassCompletedSuccessfullyIsOne_DroppedStudentCountIsZero_UniqueCountIsOne()
        {
            var classWithGradeList = new List <ClassWithGradeDTO>()
            {
                new ClassWithGradeDTO()
                {
                    CourseName     = "History",
                    CRN            = 111,
                    DepartmentName = "History Dept",
                    FinalGrade     = Grade.I
                }
            };

            var results = ReportsBusinessLogic.SuccessReport(classWithGradeList);

            Assert.Equal(1, results.Where(x => x.CRN == 111).FirstOrDefault().CompletedCourseCount);
            Assert.Equal(1, results.Where(x => x.CRN == 111).FirstOrDefault().PassedSuccessfullyCount);
            Assert.Equal(0, results.Where(x => x.CRN == 111).FirstOrDefault().DroppedStudentCount);
            Assert.Equal(1, results.Where(x => x.CRN == 111).FirstOrDefault().UniqueStudentCount);
        }