/// <summary>
        /// Return the list of students with the status of logged in or out
        /// </summary>
        /// <returns></returns>
        // GET: Kiosk
        public ActionResult Index()
        {
            //TODO: Need to add a check here to validate if the request comes from a validated login or not.

            var myDataList = DataSourceBackend.Instance.StudentBackend.Index();

            var previousDateUTC = DataSourceBackend.Instance.KioskSettingsBackend.GetLatestDate();
            var previousDate    = UTCConversionsBackend.UtcToKioskTime(previousDateUTC).Date;

            var currentDateUTC = DateTimeHelper.Instance.GetDateTimeNowUTC();
            var currentDate    = UTCConversionsBackend.UtcToKioskTime(currentDateUTC).Date;

            // Compare the current date with the last saved date from KioskSettings
            if (DateTime.Compare(previousDate, currentDate) != 0) //If date has changed
            {
                DataSourceBackend.Instance.StudentBackend.ResetStatusAndProcessNewAttendance();

                // Save the update date back to KioskSettings
                DataSourceBackend.Instance.KioskSettingsBackend.UpdateLatestDate(currentDateUTC);
            }

            var myReturn = new AdminReportIndexViewModel(myDataList);

            return(View(myReturn));
        }
Exemple #2
0
        /// <summary>
        /// Calendar Index
        /// </summary>
        /// <returns></returns>
        // GET: Calendar
        public ActionResult Index()
        {
            var CurrentId = DataSourceBackend.Instance.IdentityBackend.GetCurrentStudentID(HttpContext);

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

            var mySchoolDaysData = Backend.DataSourceBackend.Instance.SchoolCalendarBackend.Index();

            // Removed null check: the data is OK to be count=0 but not possible to be null
            //if (mySchoolDaysData == null)
            //{
            //    // Send to Error Page
            //    return RedirectToAction("Error", "Home");
            //}

            var myData = new SchoolCalendarViewModel
            {
                SchoolDays  = mySchoolDaysData,
                CurrentDate = UTCConversionsBackend.UtcToKioskTime(DateTimeHelper.Instance.GetDateTimeNowUTC())
            };

            myData.FirstDay = SchoolDismissalSettingsBackend.Instance.GetDefault().DayFirst;
            myData.LastDay  = SchoolDismissalSettingsBackend.Instance.GetDefault().DayLast;

            //Get the First and last month, and set the dates to the first of those months.
            var dateStart = DateTime.Parse(myData.FirstDay.Month.ToString() + "/01/" +
                                           myData.FirstDay.Year.ToString());

            // Go to the month after the last date
            var dateEnd = DateTime.Parse((myData.LastDay.Month + 1).ToString() + "/01/" +
                                         myData.LastDay.Year.ToString());

            dateEnd.AddDays(-1); // Back up 1 day to be the last day of the month

            DateTime currentDate = new DateTime();

            currentDate = dateStart;

            // For every day from the start of the school year, until the end of the school year or now...
            while (currentDate.CompareTo(dateEnd) < 0)
            {
                if (currentDate.Day == 1)
                {
                    // For each month, build a list of the days for that month
                    var temp = myData.SchoolDays.Where(m => m.Date.Month == currentDate.Month).ToList();
                    myData.Months.Add(temp);
                }

                currentDate = currentDate.AddDays(1);
            }

            return(View(myData));
        }
Exemple #3
0
        /// <summary>
        /// AttendanceUpdate Page
        /// </summary>
        /// <param name="id">Attendance Id</param>
        /// <returns>Attendance Record as a Attendance Model</returns>
        // GET: Portal

        public ActionResult AttendanceUpdate(string id, string item)
        {
            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"));
            }

            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Error", "Home"));
            }

            if (string.IsNullOrEmpty(item))
            {
                return(RedirectToAction("Error", "Home"));
            }

            //get the attendance with given id
            var myAttendance = DataSourceBackend.Instance.StudentBackend.ReadAttendance(CurrentId, item);

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

            //Create a new attendance to hold converted times
            var myReturn = new AttendanceModel
            {
                StudentId  = myAttendance.StudentId,
                Id         = myAttendance.Id,
                In         = UTCConversionsBackend.UtcToKioskTime(myAttendance.In),
                Out        = UTCConversionsBackend.UtcToKioskTime(myAttendance.Out),
                Emotion    = myAttendance.Emotion,
                EmotionUri = Emotion.GetEmotionURI(myAttendance.Emotion),

                IsNew = myAttendance.IsNew
            };

            return(View(myReturn));
        }
Exemple #4
0
        /// <summary>
        /// Index Page
        /// </summary>
        /// <param name="id">Student Id</param>
        /// <returns>Student Record as a Student View Model</returns>
        // GET: Portal
        public ActionResult Index(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("Roster", "Portal"));
            }

            var myReturn = new StudentDisplayViewModel(myStudent);

            //Set the last log in time and emotion status img uri
            if (myReturn.Attendance.Any())
            {
                myReturn.LastLogIn = UTCConversionsBackend.UtcToKioskTime(myReturn.Attendance.OrderByDescending(m => m.In).FirstOrDefault().In);
            }

            var myWeeklyReport = new WeeklyReportViewModel()
            {
                StudentId      = CurrentId,
                SelectedWeekId = 1
            };

            var myMonthlyReport = new MonthlyReportViewModel()
            {
                StudentId       = CurrentId,
                SelectedMonthId = 1
            };

            myReturn.WeeklyAttendanceScore  = ReportBackend.Instance.GenerateWeeklyReport(myWeeklyReport).Stats.PercAttendedHours;
            myReturn.MonthlyAttendanceScore = ReportBackend.Instance.GenerateMonthlyReport(myMonthlyReport).Stats.PercAttendedHours;

            return(View(myReturn));
        }
        /// <summary>
        /// Shows the login confirmation screen
        /// </summary>
        /// <param name="id">Student ID</param>
        /// <returns></returns>
        public ActionResult ConfirmLogin(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Error", "Home"));
            }

            var myDataList       = DataSourceBackend.Instance.StudentBackend.Read(id);
            var StudentViewModel = new StudentDisplayViewModel(myDataList)
            {
                LastDateTime = UTCConversionsBackend.UtcToKioskTime(DateTimeHelper.Instance.GetDateTimeNowUTC())
            };

            return(View(StudentViewModel));
        }
        public AttendanceDetailsViewModel Initialize(string id, string item)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(null);
            }

            if (string.IsNullOrEmpty(item))
            {
                return(null);
            }

            //get the attendance with given id
            var myAttendance = DataSourceBackend.Instance.StudentBackend.ReadAttendance(id, item);

            if (myAttendance == null)
            {
                return(null);
            }

            var studentId = myAttendance.StudentId;
            var student   = DataSourceBackend.Instance.StudentBackend.Read(studentId);
            // Not possible to be null, because ReadAttendance returns with the student Id
            //if (student == null)
            //{
            //    return null;
            //}

            var ret = new AttendanceDetailsViewModel
            {
                Attendance = new AttendanceModel
                {
                    StudentId  = myAttendance.StudentId,
                    Id         = myAttendance.Id,
                    In         = UTCConversionsBackend.UtcToKioskTime(myAttendance.In),
                    Out        = UTCConversionsBackend.UtcToKioskTime(myAttendance.Out),
                    Emotion    = myAttendance.Emotion,
                    EmotionUri = Emotion.GetEmotionURI(myAttendance.Emotion),

                    IsNew = myAttendance.IsNew
                },
                Name = student.Name,

                AvatarComposite = student.AvatarComposite
            };

            return(ret);
        }
Exemple #7
0
        // GET: Attendance/Create
        //Create a new attendance
        public ActionResult Create(string id)
        {
            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)
            {
                // Send to Error Page
                return(RedirectToAction("Error", "Home"));
            }

            //current date
            var myDate = UTCConversionsBackend.UtcToKioskTime(DateTimeHelper.Instance.GetDateTimeNowUTC()).Date;
            //the school day model
            var      schoolDay = DataSourceBackend.Instance.SchoolCalendarBackend.ReadDate(myDate);
            DateTime defaultStart;
            DateTime defaultEnd;

            var myDefaultDismissalSettings = DataSourceBackend.Instance.SchoolDismissalSettingsBackend.GetDefault();

            if (schoolDay == null)
            {
                defaultStart = myDate.Add(myDefaultDismissalSettings.StartNormal);
                defaultEnd   = myDate.Add(myDefaultDismissalSettings.EndNormal);
            }
            else
            {
                defaultStart = myDate.Add(schoolDay.TimeStart);
                defaultEnd   = myDate.Add(schoolDay.TimeEnd);
            }

            var myData = new AttendanceModel
            {
                StudentId = id,
                In        = defaultStart,
                Out       = defaultEnd,
            };

            return(View(myData));
        }
        public void Backend_ReportBackend_GenerateLeaderboard_Valid_Data_Should_Pass()
        {
            //arrange
            var studentList = DataSourceBackend.Instance.StudentBackend.Index();

            var dayNow = UTCConversionsBackend.UtcToKioskTime(DateTime.UtcNow).Date;           //today's date

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

            var attendanceMon = new AttendanceModel
            {
                In  = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddHours(8)),
                Out = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddHours(9)),
            };
            var attendanceTue = new AttendanceModel
            {
                In  = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddHours(10)),
                Out = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddHours(12)),
            };

            var student1 = studentList.Where <StudentModel>(x => x.Name == "Doug").FirstOrDefault();

            student1.Attendance.Add(attendanceMon);
            DataSourceBackend.Instance.StudentBackend.Update(student1);

            var student2 = studentList.Where <StudentModel>(x => x.Name == "Jea").FirstOrDefault();

            student2.Attendance.Add(attendanceMon);
            student2.Attendance.Add(attendanceTue);
            DataSourceBackend.Instance.StudentBackend.Update(student2);

            //act
            var result = ReportBackend.Instance.GenerateLeaderboard();

            //reset
            DataSourceBackend.Instance.StudentBackend.Reset();

            Assert.IsNotNull(result[1].Name, TestContext.TestName);

            //assert
            // TODO:  Need to rework this test, after getting the date/time wrapped.

            //Assert.AreEqual(student1.Name, result[1].Name, TestContext.TestName);
            //Assert.AreEqual(student2.Name, result[0].Name, TestContext.TestName);
        }
Exemple #9
0
        // GET: Attendance/Read/. Read the attendance history of the student
        public ActionResult Read(string id)
        {
            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 myReturn = new StudentDisplayViewModel(myStudent);

            var attendanceListOrdered = myReturn.Attendance.OrderByDescending(m => m.In);

            //Deep copy Attendance list and convert time zone
            var myAttendanceModels = new List <AttendanceModel>();

            foreach (var item in attendanceListOrdered)
            {
                var myAttendance = new AttendanceModel()
                {
                    //deep copy the AttendanceModel and convert time zone
                    In         = UTCConversionsBackend.UtcToKioskTime(item.In),
                    Out        = UTCConversionsBackend.UtcToKioskTime(item.Out),
                    Id         = item.Id,
                    StudentId  = myStudent.Id,
                    Emotion    = item.Emotion,
                    EmotionUri = Emotion.GetEmotionURI(item.Emotion)
                };

                myAttendance.Id = item.Id;

                myAttendanceModels.Add(myAttendance);
            }

            myReturn.Attendance = myAttendanceModels;

            return(View(myReturn));
        }
Exemple #10
0
        // GET: Attendance/Detail
        // Read the details of the attendance(time in, time out).
        public ActionResult Details(string id, string item)
        {
            var CurrentId = DataSourceBackend.Instance.IdentityBackend.GetCurrentStudentID(HttpContext);

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

            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Error", "Home"));
            }

            if (string.IsNullOrEmpty(item))
            {
                return(RedirectToAction("Error", "Home"));
            }

            //get the attendance with given id
            var myAttendance = DataSourceBackend.Instance.StudentBackend.ReadAttendance(id, item);

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

            //Create a new attendance to hold converted times
            var myReturn = new AttendanceModel
            {
                StudentId  = myAttendance.StudentId,
                Id         = myAttendance.Id,
                In         = UTCConversionsBackend.UtcToKioskTime(myAttendance.In),
                Out        = UTCConversionsBackend.UtcToKioskTime(myAttendance.Out),
                Emotion    = myAttendance.Emotion,
                EmotionUri = Emotion.GetEmotionURI(myAttendance.Emotion),

                IsNew = myAttendance.IsNew
            };

            return(View(myReturn));
        }
Exemple #11
0
        /// <summary>
        /// Index Page
        /// </summary>
        /// <param name="id">Student Id</param>
        /// <returns>Student Record as a Student View Model</returns>
        // GET: Portal
        public ActionResult Index(string id = null)
        {
            ViewBag.StudentId = id;

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

            if (myStudent == null)
            {
                return(RedirectToAction("Roster", "Portal"));
            }

            var myReturn = new StudentDisplayViewModel(myStudent);

            //Set the last log in time and emotion status img uri
            if (myReturn.Attendance.Any())
            {
                myReturn.LastLogIn = UTCConversionsBackend.UtcToKioskTime(myReturn.Attendance.OrderByDescending(m => m.In).FirstOrDefault().In);
            }

            return(View(myReturn));
        }
Exemple #12
0
        /// <summary>
        /// Attendance Page
        /// </summary>
        /// <param name="id">Student Id</param>
        /// <returns>Student Record as a Student View Model</returns>
        // GET: Portal
        public ActionResult Attendance(string id = null)
        {
            // Temp hold the Student Id for the Nav, until the Nav can call for Identity.
            //ViewBag.StudentId = id;

            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("Roster", "Portal"));
            }

            var myReturn = new StudentDisplayViewModel(myStudent);

            var attendanceListOrdered = myReturn.Attendance.OrderByDescending(m => m.In);

            //Set the last log in time and emotion status img uri
            if (attendanceListOrdered.Any())
            {
                myReturn.LastLogIn = UTCConversionsBackend.UtcToKioskTime(attendanceListOrdered.FirstOrDefault().In);
            }

            //Deep copy Attendance list and convert time zone
            var myAttendanceModels = new List <AttendanceModel>();

            foreach (var item in attendanceListOrdered)
            {
                var myAttendance = new AttendanceModel()
                {
                    //deep copy the AttendanceModel and convert time zone
                    In         = UTCConversionsBackend.UtcToKioskTime(item.In),
                    Out        = UTCConversionsBackend.UtcToKioskTime(item.Out),
                    Id         = item.Id,
                    StudentId  = myStudent.Id,
                    Emotion    = item.Emotion,
                    EmotionUri = Emotion.GetEmotionURI(item.Emotion)
                };

                myAttendance.Id = item.Id;

                myAttendanceModels.Add(myAttendance);
            }

            myReturn.Attendance = myAttendanceModels;

            return(View(myReturn));
        }
Exemple #13
0
        public void Backend_ReportBackend_GenerateOverallReport_Valid_Report_Should_Pass()
        {
            //arrange
            var reportBackend = ReportBackend.Instance;
            var testReport    = new MonthlyReportViewModel();
            var testStudent   = DataSourceBackend.Instance.StudentBackend.GetDefault();

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

            var dayNow = UTCConversionsBackend.UtcToKioskTime(DateTime.UtcNow).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(8)),
                Out     = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddHours(9)),
                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 = DateTime.UtcNow;

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

            //reset
            DataSourceBackend.Instance.Reset();

            //assert
            Assert.IsNotNull(result, TestContext.TestName);
        }