Ejemplo n.º 1
0
        /// <summary>
        /// Check the student's quiz question answer and save progress if correct.
        /// </summary>
        /// <param name="ID">Invitation ID</param>
        /// <param name="QuizQuestionID">Quiz Question ID</param>
        /// <param name="AnswerID">Answer ID</param>
        /// <returns></returns>
        public ActionResult CompleteQuizQuestion(int ID, int QuizQuestionID, int AnswerID)
        {
            tblInvitation            Invitation     = _ODB.tblInvitations.Where(e => e.ID == ID).SingleOrDefault();
            tblQuizQuestion          Question       = _ODB.tblQuizQuestions.Where(e => e.ID == QuizQuestionID).SingleOrDefault();
            tblQuizQuestionAnswer    Answer         = Question.tblQuizQuestionAnswers.Where(e => e.ID == AnswerID).SingleOrDefault();
            tblCompletedQuizQuestion existingAnswer = Invitation.tblCompletedQuizQuestions.Where(e => e.QuizQuestionID == QuizQuestionID).SingleOrDefault();

            if (Invitation.ENumber == Current.User.ENumber || Current.User.IsAdmin || Current.User.IsStaff)
            {
                if (existingAnswer == null)
                {
                    if (AnswerID != -1 && Answer != null)
                    {
                        if (Answer.Correct)
                        {
                            tblCompletedQuizQuestion CompletedQuestion = new tblCompletedQuizQuestion();
                            CompletedQuestion.tblInvitation   = Invitation;
                            CompletedQuestion.tblQuizQuestion = Question;
                            CompletedQuestion.DateCompleted   = DateTime.Now;
                            _ODB.tblCompletedQuizQuestions.AddObject(CompletedQuestion);
                            _ODB.SaveChanges();
                            Logging.Log(Logging.LogType.Audit, string.Format("User {0} completed Quiz Question ID {1} for Invitation {2}. tblCompletedQuizQuestion.ID = {3}", Current.User.Username, Question.ID, Invitation.ID, CompletedQuestion.ID));
                            if (Invitation.HasPendingQuiz)
                            {
                                this.ShowPageMessage(string.Format("Correct! The answer was '{0}'. Please answer the next question", Answer.Answer));
                                return(this.RedirectToAction <StudentController>(c => c.Quiz(Invitation.ID)));
                            }
                            else
                            {
                                this.ShowPageMessage("You have completed the required Quiz.");
                                return(this.RedirectToAction <StudentController>(c => c.Invitation(Invitation.ID)));
                            }
                        }
                        else
                        {
                            this.ShowPageError(string.Format("The answer you provided was not correct: '{0}'. Please choose another answer.", Answer.Answer));
                        }
                    }
                    else
                    {
                        this.ShowPageError("Could not find an answer with the submitted values. Please choose an answer. If no answer choices are available for this question, please contact: [email protected]");
                    }
                }
                else
                {
                    this.ShowPageError("The submitted quiz question has already been completed.");
                }
            }
            else
            {
                this.ShowPageError("You are not authorized to view Quiz material for this Invitation");
            }

            return(this.RedirectToAction <StudentController>(c => c.Quiz(Invitation.ID)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a Reservation given a student's invitation ID and the selected Event Date ID
        /// </summary>
        /// <param name="ID">Invitation ID</param>
        /// <param name="EventDateID">Event Date ID</param>
        /// <returns>ActionResult</returns>
        public ActionResult CreateReservation(int ID, int EventDateID)
        {
            tblInvitation Invitation = _ODB.tblInvitations.Where(e => e.ID == ID).SingleOrDefault();
            tblEventDate  EventDate  = _ODB.tblEventDates.Where(e => e.ID == EventDateID).SingleOrDefault();

            if (Invitation != null && EventDate != null)
            {
                if (Invitation.ENumber == Current.User.ENumber || Current.User.IsAdmin || Current.User.IsStaff)
                {
                    tblReservation existingReservation = _ODB.tblReservations.Where(e => e.InvitationID == Invitation.ID).SingleOrDefault();
                    if (existingReservation == null)
                    {
                        if (EventDate.HasOpenSlots)
                        {
                            tblReservation Reservation = new tblReservation();
                            Reservation.tblEventDate  = EventDate;
                            Reservation.tblInvitation = Invitation;
                            Reservation.IsCancelled   = false;
                            Reservation.IsConfirmed   = false;
                            _ODB.tblReservations.AddObject(Reservation);
                            _ODB.SaveChanges();
                            Logging.Log(Logging.LogType.Audit, string.Format("User {0} created a Reservation with ID {1} for Invitation {2} for EventDate {3}", Current.User.Username, Reservation.ID, Invitation.ID, EventDate.ID));
                            this.ShowPageMessage("Your event reservation was successfully created!");
                            return(this.RedirectToAction <StudentController>(c => c.Reservation(Reservation.ID)));
                        }
                        else
                        {
                            this.ShowPageError(string.Format("The selected event date '{0}' no longer has an open slot for event '{1}'. Please select another event date.", existingReservation.tblEventDate.DateOfEvent.ToShortDateString(), existingReservation.tblEventDate.tblEvent.Name));
                        }
                    }
                    else
                    {
                        this.ShowPageError("A reservation already exists for the selected Invitation. Please update the reservation to change event dates.");
                    }
                }
                else
                {
                    this.ShowPageError("You are not authorized to view create reservations for this Invitation");
                }
            }
            else
            {
                this.ShowPageError("Either the Invitation or the Event Date could not be retrieved given the specified IDs.");
            }

            if (Invitation != null)
            {
                return(this.RedirectToAction <StudentController>(c => c.Invitation(Invitation.ID)));
            }
            else
            {
                return(this.RedirectToAction <StudentController>(c => c.Index()));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Change the event date for a given reservation and new event id
        /// </summary>
        /// <param name="ID">Reservation ID</param>
        /// <param name="EventDateID">Event Date ID</param>
        /// <returns>ActionResult</returns>
        public ActionResult ChangeReservation(int ID, int EventDateID)
        {
            tblReservation Reservation = _ODB.tblReservations.Where(e => e.ID == ID).SingleOrDefault();
            tblInvitation  Invitation  = Reservation != null ? Reservation.tblInvitation : null;
            tblEventDate   EventDate   = _ODB.tblEventDates.Where(e => e.ID == EventDateID).SingleOrDefault();

            if (Invitation != null && EventDate != null)
            {
                if (Invitation.ENumber == Current.User.ENumber || Current.User.IsAdmin || Current.User.IsStaff)
                {
                    if (Reservation != null)
                    {
                        if (EventDate.HasOpenSlots)
                        {
                            // delete unpaid guests to avoid conflicts with the number of allowed guests with different event dates, but yet preserve paid guests
                            List <tblGuest> GuestsToDelete = Reservation.tblGuests.Where(e => !e.HasPaid).ToList();
                            GuestsToDelete.ForEach(e => _ODB.tblGuests.DeleteObject(e));
                            Reservation.tblEventDate = EventDate;
                            _ODB.SaveChanges();
                            Logging.Log(Logging.LogType.Audit, string.Format("User {0} Changed the Event Date for Reservation with ID {1} for Invitation {2} for EventDate {3}", Current.User.Username, Reservation.ID, Invitation.ID, EventDate.ID));
                            this.ShowPageMessage("Your event date for your reservation was successfully changed!");
                            return(this.RedirectToAction <StudentController>(c => c.Reservation(Reservation.ID)));
                        }
                        else
                        {
                            this.ShowPageError(string.Format("The selected event date '{0}' no longer has an open slot for event '{1}'. Please select another event date.", Reservation.tblEventDate.DateOfEvent.ToShortDateString(), Reservation.tblEventDate.tblEvent.Name));
                            return(this.RedirectToAction <StudentController>(c => c.Reservation(Reservation.ID)));
                        }
                    }
                    else
                    {
                        this.ShowPageError("A reservation could not be found by the given ID.");
                    }
                }
                else
                {
                    this.ShowPageError("You are not authorized to view create reservations for this Invitation");
                }
            }
            else
            {
                this.ShowPageError("Either the Invitation or the Event Date could not be retrieved given the specified IDs.");
            }

            if (Invitation != null)
            {
                return(this.RedirectToAction <StudentController>(c => c.Invitation(Invitation.ID)));
            }
            else
            {
                return(this.RedirectToAction <StudentController>(c => c.Index()));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Displays Event Invitation Details to Student
        /// </summary>
        /// <param name="ID">Invitation ID</param>
        /// <returns>ActionResult</returns>
        public ActionResult Invitation(int ID)
        {
            tblInvitation StudentInvitation = _ODB.tblInvitations.Where(e => e.ID == ID).SingleOrDefault();

            if (StudentInvitation.ENumber == Current.User.ENumber || Current.User.IsAdmin || Current.User.IsStaff)
            {
                Logging.Log(Logging.LogType.Audit, string.Format("User {1} with ENumber {0} is viewing Student Event Invitation with ID {2} for event '{3}'", Current.User.ENumber, Current.User.Username, ID, StudentInvitation.tblEvent.Name));
                return(View(StudentInvitation));
            }
            else
            {
                this.ShowPageError("You do not have permission to access that Invitation");
                return(this.RedirectToAction <StudentController>(c => c.Index()));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Mark the selected launch page as completed for the current student.
        /// </summary>
        /// <param name="ID">Invitation ID</param>
        /// <param name="LaunchPageID">Launch Page ID</param>
        /// <returns></returns>
        public ActionResult CompleteLaunchPage(int ID, int LaunchPageID)
        {
            tblInvitation          Invitation   = _ODB.tblInvitations.Where(e => e.ID == ID).SingleOrDefault();
            tblLaunchPage          LaunchPage   = _ODB.tblLaunchPages.Where(e => e.ID == LaunchPageID).SingleOrDefault();
            tblCompletedLaunchPage existingPage = Invitation.tblCompletedLaunchPages.Where(e => e.LaunchPageID == LaunchPageID).SingleOrDefault();

            if (Invitation.ENumber == Current.User.ENumber || Current.User.IsAdmin)
            {
                if (existingPage == null)
                {
                    tblCompletedLaunchPage CompletedPage = new tblCompletedLaunchPage();
                    CompletedPage.tblInvitation = Invitation;
                    CompletedPage.tblLaunchPage = LaunchPage;
                    CompletedPage.DateCompleted = DateTime.Now;
                    _ODB.tblCompletedLaunchPages.AddObject(CompletedPage);
                    _ODB.SaveChanges();
                    Logging.Log(Logging.LogType.Audit, string.Format("User {0} completed Launch Page ID {1} for Invitation {2}. tblCompletedLaunchPage.ID = {3}", Current.User.Username, LaunchPage.ID, Invitation.ID, CompletedPage.ID));
                    if (Invitation.HasPendingLaunch)
                    {
                        return(this.RedirectToAction <StudentController>(c => c.Launch(Invitation.ID)));
                    }
                    else
                    {
                        this.ShowPageMessage("You have completed the required LAUNCH module.");
                        return(this.RedirectToAction <StudentController>(c => c.Invitation(Invitation.ID)));
                    }
                }
                else
                {
                    this.ShowPageError("The submitted launch page has already been completed.");
                }
            }
            else
            {
                this.ShowPageError("You are not authorized to view Launch material for this Invitation");
            }

            return(this.RedirectToAction <StudentController>(c => c.Launch(Invitation.ID)));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// View current/incomplete quiz question for student
        /// </summary>
        /// <param name="ID">Invitation ID</param>
        /// <returns></returns>
        public ActionResult Quiz(int ID)
        {
            tblInvitation Invitation = _ODB.tblInvitations.Where(e => e.ID == ID).SingleOrDefault();

            if (Invitation.ENumber == Current.User.ENumber)
            {
                tblQuizQuestion Question = null;
                if (Invitation != null)
                {
                    Question = Invitation.CurrentQuizQuestion;
                    return(View("Quiz", new Tuple <tblInvitation, tblQuizQuestion>(Invitation, Question)));
                }
                else
                {
                    this.ShowPageError("Could not find an orientation invitation for the given ID");
                }
            }
            else
            {
                this.ShowPageError("You are not authorized to view quiz material for this Invitation");
            }

            return(this.RedirectToAction <StudentController>(c => c.Index()));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Allows the student to review a previously viewed & submitted launch page
        /// </summary>
        /// <param name="ID">Invitation ID</param>
        /// <param name="LaunchPageID">Launch Page ID</param>
        /// <returns></returns>
        public ActionResult ReviewLaunchPage(int ID, int LaunchPageID)
        {
            tblInvitation Invitation = _ODB.tblInvitations.Where(e => e.ID == ID).SingleOrDefault();
            tblLaunchPage Page       = null;

            if (Invitation.ENumber == Current.User.ENumber)
            {
                if (Invitation != null)
                {
                    Page = Invitation.CompletedLaunchPages.Where(e => e.ID == LaunchPageID).SingleOrDefault();
                    return(View("Launch", new Tuple <tblInvitation, tblLaunchPage>(Invitation, Page)));
                }
                else
                {
                    this.ShowPageError("Could not find an orientation invitation for the given ID");
                }
            }
            else
            {
                this.ShowPageError("You are not authorized to view Launch material for this Invitation");
            }

            return(this.RedirectToAction <StudentController>(c => c.Index()));
        }