Beispiel #1
0
        // GET: QuarterReport
        /// <summary>
        /// Returns an individual quarter report for a student
        /// </summary>
        /// <param name="id">Student ID to generate Report for</param>
        /// <returns>Report data</returns>
        public ActionResult QuarterReport(string id = null)
        {
            var CurrentId = DataSourceBackend.Instance.IdentityBackend.GetCurrentStudentID(HttpContext);

            if (DataSourceBackend.Instance.IdentityBackend.BlockExecptForRole(CurrentId, UserRoleEnum.TeacherUser))
            {
                return(RedirectToAction("Login", "Admin"));
            }

            var myStudent = DataSourceBackend.Instance.StudentBackend.Read(id);

            if (myStudent == null)
            {
                return(RedirectToAction("Error", "Home"));
            }


            var myReport = new QuarterReportViewModel()
            {
                StudentId         = id,
                SelectedQuarterId = 1
            };

            var myReturn = ReportBackend.Instance.GenerateQuarterReport(myReport);

            return(View(myReturn));
        }
Beispiel #2
0
        public void Models_QuarterReportViewModel_Default_Instantiate_Should_Pass()
        {
            // Act
            var result = new QuarterReportViewModel();

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
Beispiel #3
0
        public ActionResult QuarterReport([Bind(Include =
                                                    "StudentId," +
                                                    "SelectedQuarterId" +
                                                    "")] QuarterReportViewModel data)
        {
            if (data == null)
            {
                // Send to error page
                return(RedirectToAction("Error", "Home"));
            }

            //generate the report
            var myReturn = ReportBackend.Instance.GenerateQuarterReport(data);

            return(View(myReturn));
        }
Beispiel #4
0
        public void Controller_Admin_Quarter_Report_Post_Data_Is_Null_Should_Return_Error_Page()
        {
            // Arrange
            AdminController        controller = new AdminController();
            QuarterReportViewModel data       = null;

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            var result = (RedirectToRouteResult)controller.QuarterReport(data);

            // Assert
            Assert.AreEqual("Error", result.RouteValues["action"], TestContext.TestName);
        }
Beispiel #5
0
        public void Controller_Admin_Quarter_Report_Post_Selected_ID_Is_4_Should_Pass()
        {
            // Arrange
            AdminController controller = new AdminController();
            var             data       = new QuarterReportViewModel()
            {
                StudentId         = DataSourceBackend.Instance.StudentBackend.GetDefault().Id,
                SelectedQuarterId = 4
            };

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            var result = controller.QuarterReport(data);

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
Beispiel #6
0
        public void Models_QuarterReportViewModel_Get_Set_Check_All_Fields_Should_Pass()
        {
            // Arrange

            // Act
            // Set all the fields for a BaseReportViewModel
            var test = new QuarterReportViewModel
            {
                SelectedQuarterId = 1,
                Quarters          = new List <SelectListItem>()
            };

            var expectedSelectedSemesterId = 1;

            // Assert

            //Check each value
            Assert.AreEqual(test.SelectedQuarterId, expectedSelectedSemesterId, "SelectedQuarterId " + TestContext.TestName);

            Assert.IsNotNull(test.Quarters, "Quarters " + TestContext.TestName);
        }
Beispiel #7
0
        public ActionResult QuarterReport([Bind(Include =
                                                    "StudentId," +
                                                    "SelectedQuarterId" +
                                                    "")] QuarterReportViewModel data)
        {
            var CurrentId = DataSourceBackend.Instance.IdentityBackend.GetCurrentStudentID(HttpContext);

            if (DataSourceBackend.Instance.IdentityBackend.BlockExecptForRole(CurrentId, UserRoleEnum.TeacherUser))
            {
                return(RedirectToAction("Login", "Admin"));
            }

            if (data == null)
            {
                // Send to error page
                return(RedirectToAction("Error", "Home"));
            }

            //generate the report
            var myReturn = ReportBackend.Instance.GenerateQuarterReport(data);

            return(View(myReturn));
        }
Beispiel #8
0
        // GET: QuarterReport
        /// <summary>
        /// Returns an individual quarter report for a student
        /// </summary>
        /// <param name="id">Student ID to generate Report for</param>
        /// <returns>Report data</returns>
        public ActionResult QuarterReport(string id = null)
        {
            var CurrentId = DataSourceBackend.Instance.IdentityBackend.GetCurrentStudentID(HttpContext);

            // Todo: Remove when identity is fully hooked up
            // Hack, to keep the current system working, while the identity system is slowly hooked up everywhere.  If the user is not logged in, then the passed in user will work, if the user is logged in, then the passed in user is ignored.
            if (string.IsNullOrEmpty(CurrentId))
            {
                CurrentId = id;
            }

            ViewBag.StudentId = CurrentId;  //TODO: Remove this when identity is fully hooked up

            if (DataSourceBackend.Instance.IdentityBackend.BlockExecptForRole(CurrentId, UserRoleEnum.StudentUser))
            {
                return(RedirectToAction("Roster", "Portal"));
            }

            var myStudent = DataSourceBackend.Instance.StudentBackend.Read(CurrentId);

            if (myStudent == null)
            {
                return(RedirectToAction("Error", "Home"));
            }


            var myReport = new QuarterReportViewModel()
            {
                StudentId         = CurrentId,
                SelectedQuarterId = 1
            };

            var myReturn = ReportBackend.Instance.GenerateQuarterReport(myReport);

            return(View(myReturn));
        }
Beispiel #9
0
        public void Backend_ReportBackend_Generate_Quarter_Report_Quarter_Id_Is_4_Should_Pass()
        {
            //arrange
            var dateTimeHelper = DateTimeHelper.Instance;

            dateTimeHelper.EnableForced(true);
            dateTimeHelper.SetForced(new DateTime(2018, 10, 20, 0, 0, 0));
            var dateTimeUTCNow = dateTimeHelper.GetDateTimeNowUTC();

            var reportBackend = ReportBackend.Instance;
            var testReport    = new QuarterReportViewModel
            {
                SelectedQuarterId = 4
            };
            var testStudent = DataSourceBackend.Instance.StudentBackend.GetDefault();

            testReport.Student   = testStudent;
            testReport.StudentId = testStudent.Id;

            var dayNow = dateTimeUTCNow.Date;                                                      //today's date

            var thisMonday = dayNow.AddDays(-7 - ((dayNow.DayOfWeek - DayOfWeek.Monday + 7) % 7)); //this Monday's date

            var attendanceMon = new AttendanceModel
            {
                In      = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddHours(9)),
                Out     = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddHours(12)),
                Emotion = EmotionStatusEnum.VeryHappy
            };
            var attendanceTue = new AttendanceModel
            {
                In      = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(1).AddHours(10)),
                Out     = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(1).AddHours(12)),
                Emotion = EmotionStatusEnum.Happy
            };
            var attendanceWed = new AttendanceModel
            {
                In      = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(2).AddHours(10)),
                Out     = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(2).AddHours(12)),
                Emotion = EmotionStatusEnum.Neutral
            };
            var attendanceThu = new AttendanceModel
            {
                In      = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(3).AddHours(10)),
                Out     = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(3).AddHours(12)),
                Emotion = EmotionStatusEnum.Sad
            };
            var attendanceFri = new AttendanceModel
            {
                In      = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(4).AddHours(10)),
                Out     = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(4).AddHours(12)),
                Emotion = EmotionStatusEnum.VerySad
            };

            testStudent.Attendance.Add(attendanceMon);
            testStudent.Attendance.Add(attendanceTue);
            testStudent.Attendance.Add(attendanceWed);
            testStudent.Attendance.Add(attendanceThu);
            testStudent.Attendance.Add(attendanceFri);

            testReport.DateEnd = dateTimeUTCNow;

            //act
            var result = reportBackend.GenerateQuarterReport(testReport);

            //reset
            DataSourceBackend.Instance.Reset();

            //assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
Beispiel #10
0
        /// <summary>
        /// Generate Weekly report
        /// </summary>
        /// <param name="report"></param>
        /// <returns></returns>
        public QuarterReportViewModel GenerateQuarterReport(QuarterReportViewModel report)
        {
            //set student
            report.Student = DataSourceBackend.Instance.StudentBackend.Read(report.StudentId);

            //settings
            var settings = SchoolDismissalSettingsBackend.Instance.GetDefault();

            report.Quarters = new List <SelectListItem>();

            var q1 = new SelectListItem {
                Value = "1", Text = "Quarter 1"
            };

            //add to the select list
            report.Quarters.Add(q1);

            if (report.SelectedQuarterId == 1)
            {
                //set the first and last day of this quarter according to school dismissal settings
                report.DateStart = settings.Q1Start.Date;
                report.DateEnd   = settings.Q2Start.Date.AddDays(-1);
            }

            var q2 = new SelectListItem {
                Value = "2", Text = "Quarter 2"
            };

            //add to the select list
            report.Quarters.Add(q2);

            if (report.SelectedQuarterId == 2)
            {
                //set the first and last day of this quarter according to school dismissal settings
                report.DateStart = settings.Q2Start.Date;
                report.DateEnd   = settings.Q3Start.Date.AddDays(-1);
            }

            var q3 = new SelectListItem {
                Value = "3", Text = "Quarter 3"
            };

            //add to the select list
            report.Quarters.Add(q3);

            if (report.SelectedQuarterId == 3)
            {
                //set the first and last day of this quarter according to school dismissal settings
                report.DateStart = settings.Q3Start.Date;
                report.DateEnd   = settings.Q4Start.Date.AddDays(-1);
            }

            var q4 = new SelectListItem {
                Value = "4", Text = "Quarter 4"
            };

            //add to the select list
            report.Quarters.Add(q4);

            if (report.SelectedQuarterId == 4)
            {
                //set the first and last day of this quarter according to school dismissal settings
                report.DateStart = settings.Q4Start.Date;
                report.DateEnd   = settings.DayLast.Date;
            }

            //Generate report for this semester
            GenerateReportFromStartToEnd(report);

            return(report);
        }