public IActionResult StudentList()
        {
            ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
            ViewBag.Students        = GetStudents();

            return(View());
        }
        public IActionResult AssignmentAttempt(string id, string Answer, string CourseID) // id is Assignment id
        {
            try
            {
                ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);

                if (Request.Method == "POST")
                {
                    SubmitAssignment(id, Answer, CourseID);
                    ViewBag.SuccessMessage = $"Successfully Submitted Assignment!";
                    ViewBag.SubmitYes      = true;
                    ViewBag.BackCourseID   = CourseID;
                }
                else
                {
                    ViewBag.AssignmentDetails = GetAssignmentByID(id);
                }
            }
            catch (ValidationException e)
            {
                ViewBag.Message   = "There is an issue(s) with the submission, please see the following details:";
                ViewBag.Exception = e;
                ViewBag.Error     = true;
            }

            return(View());
        }
        public IActionResult InstructorList()
        {
            ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
            ViewBag.Instructors     = GetInstructors();

            return(View());
        }
        public IActionResult StudentDashboard()
        {
            try
            {
                ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
            }
            catch (ValidationException e)
            {
                ViewBag.Message   = "There is an issue(s) with the submission, please see the following details:";
                ViewBag.Exception = e;
                ViewBag.Error     = true;
            }

            return(View());
        }
        public async Task <IActionResult> CourseEdit(int?id)
        {
            ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
            using (LearningManagementContext context = new LearningManagementContext())
            {
                if (id == null)
                {
                    return(NotFound());
                }

                var course = await context.Courses.FindAsync(id);

                if (course == null)
                {
                    ViewBag.CourseExists = false;
                    return(View(course));
                }

                ViewBag.CourseExists = true;

                // Create a list based on first name and last name from the User table that has a role equal to 2 (which is "Instructor")
                var instructors = new SelectList(context.Users.Where(x => x.Role == 2)
                                                 .OrderBy(y => y.LastName)
                                                 .ToDictionary(us => us.ID, us => us.FirstName + " " + us.LastName), "Key", "Value", course.UserID);
                ViewBag.Instructors       = instructors;
                ViewBag.CourseName        = course.CourseName;
                ViewBag.Subject           = course.Subject;
                ViewBag.StartDate         = course.StartDate;
                ViewBag.EndDate           = course.EndDate;
                ViewBag.CourseDescription = course.CourseDescription;

                // Create list of GradeLevels
                var gradeLevels = new List <string>()
                {
                    "Kindergarten", "Grade 1", "Grade 2", "Grade 3", "Grade 4", "Grade 5", "Grade 6", "Grade 7", "Grade 8", "Grade 9", "Grade 10", "Grade 11", "Grade 12"
                };
                // Populate dropdown list for grade levels.
                var gradeLevelList = new SelectList(gradeLevels.ToDictionary(g => g, g => g), "Key", "Value", course.GradeLevel);
                ViewBag.GradeLevels = gradeLevelList;

                ViewBag.GradeLevel      = course.GradeLevel;
                ViewBag.CurrentCapacity = course.CurrentCapacity;
                ViewBag.MaxCapacity     = course.MaxCapacity;

                return(View());
            }
        }
        /* ---------------------------------Administrator Student Actions -----------------------------------------------------*/

        /// <summary>
        /// Populates StudentDetail view based on studentID
        /// </summary>
        /// <param name="studentID"></param>
        /// <returns>Student details on StudentDetail View</returns>
        public IActionResult StudentDetail(int studentID)
        {
            try
            {
                ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
                User student = GetStudentByID(studentID);
                ViewBag.Student        = student;
                ViewBag.StudentCourses = GetEnrolledCoursesByStudentID(student.ID);
            }
            catch (ValidationException e)
            {
                ViewBag.Message   = "There is an issue(s) with the submission, please see the following details:";
                ViewBag.Exception = e;
                ViewBag.Error     = true;
            }
            return(View());
        }
 public IActionResult InstructorDetail(int instructorID)
 {
     try
     {
         ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
         User instructor = GetInstructorByID(instructorID);
         ViewBag.Instructor        = instructor;
         ViewBag.InstructorCourses = GetCoursesByInstructorID(instructor.ID);
     }
     catch (ValidationException e)
     {
         ViewBag.Message   = "There is an issue(s) with the submission, please see the following details:";
         ViewBag.Exception = e;
         ViewBag.Error     = true;
     }
     return(View());
 }
        public IActionResult CourseList(string subjectFilter, string gradeFilter)
        {
            ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
            var gradeLevels = new List <string>()
            {
                "Kindergarten", "Grade 1", "Grade 2", "Grade 3", "Grade 4", "Grade 5", "Grade 6", "Grade 7", "Grade 8", "Grade 9", "Grade 10", "Grade 11", "Grade 12"
            };
            var gradeLevelList = new SelectList(gradeLevels.ToDictionary(g => g, g => g), "Key", "Value", gradeLevels);

            ViewBag.GradeLevels = gradeLevelList;

            var courseSubjects = new List <string>()
            {
                "English", "Math", "Science", "Social Studies"
            };
            var courseSubjectsList = new SelectList(courseSubjects.ToDictionary(s => s, s => s), "Key", "Value", courseSubjects);

            ViewBag.CourseSubjects = courseSubjectsList;

            if (gradeLevels.Contains(gradeFilter) && !courseSubjects.Contains(subjectFilter))
            {
                ViewBag.Courses = GetCoursesByGrade(gradeFilter);
                ViewBag.Filter  = true;
            }

            else if (courseSubjects.Contains(subjectFilter) && !gradeLevels.Contains(gradeFilter))
            {
                ViewBag.Courses = GetCoursesBySubject(subjectFilter);
                ViewBag.Filter  = true;
            }

            else if (courseSubjects.Contains(subjectFilter) && gradeLevels.Contains(gradeFilter))
            {
                ViewBag.Courses = GetCoursesByGradeAndSubject(subjectFilter, gradeFilter);
                ViewBag.Filter  = true;
            }

            else
            {
                ViewBag.Courses = GetCoursesAll();
                ViewBag.Filter  = false;
            }
            return(View("CourseList"));
        }
Exemple #9
0
        public IActionResult AssignmentList(string cid, string uid)
        {
            ViewBag.CourseId = cid;

            try
            {
                ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
                int studentId = StudentController.GetStudentId(cid, uid);
                /* Call function to get student name ~ */
                ViewBag.SubmittedAssignments = StudentController.GetSubmittedAssignments(studentId.ToString());
            }
            catch (ValidationException e)
            {
                ViewBag.Message   = "There is an issue(s) with the submission, please see the following details:";
                ViewBag.Exception = e;
                ViewBag.Error     = true;
            }

            return(View());
        }
        public IActionResult CourseCreate(string instructor, string courseName, string subject, string courseDescription, string gradeLevel, DateTime?startDate, DateTime?endDate, int currentCapacity, int maxCapacity)
        {
            ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
            using (LearningManagementContext context = new LearningManagementContext())
            {
                // Create a list based on first name and last name from the User table that has a role equal to 2 (which is "Instructor")
                var instructors = new SelectList(context.Users.Where(x => x.Role == 2)
                                                 .OrderBy(y => y.LastName)
                                                 .ToDictionary(us => us.ID, us => us.FirstName + " " + us.LastName), "Key", "Value", instructor);
                ViewBag.Instructors = instructors;
                ViewBag.CourseName  = courseName;

                // Create list of Subjects
                var courseSubjects = new List <string>()
                {
                    "English", "Math", "Science", "Social Studies"
                };
                // Populate dropdown list for subjects.
                var courseSubjectsList = new SelectList(courseSubjects.ToDictionary(s => s, s => s), "Key", "Value", courseSubjects);
                ViewBag.CourseSubjects = courseSubjectsList;

                ViewBag.Subject           = subject;
                ViewBag.StartDate         = startDate;
                ViewBag.EndDate           = endDate;
                ViewBag.CourseDescription = courseDescription;

                // Create list of GradeLevels
                var gradeLevels = new List <string>()
                {
                    "Kindergarten", "Grade 1", "Grade 2", "Grade 3", "Grade 4", "Grade 5", "Grade 6", "Grade 7", "Grade 8", "Grade 9", "Grade 10", "Grade 11", "Grade 12"
                };
                // Populate dropdown list for grade levels.
                var gradeLevelList = new SelectList(gradeLevels.ToDictionary(g => g, g => g), "Key", "Value", gradeLevel);
                ViewBag.GradeLevels = gradeLevelList;

                ViewBag.GradeLevel  = gradeLevel;
                ViewBag.MaxCapacity = maxCapacity;
            }
            return(View());
        }
Exemple #11
0
        public IActionResult CourseDetail(string id) // passing CourseID
        {
            try
            {
                ViewBag.UserInformation    = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
                ViewBag.SingleCourseDetail = GetCourseDetailsByID(id);
                if (ViewBag.SingleCourseDetail != null)
                {
                    // Get students enrolled in this course
                    ViewBag.StudentsForCourse    = GetStudentsByCourseID(id);
                    ViewBag.AssignmentsForCourse = GetAssignmentsByCourseID(id);
                }
            }
            catch (ValidationException e)
            {
                ViewBag.Message   = "There is an issue(s) with the submission, please see the following details:";
                ViewBag.Exception = e;
                ViewBag.Error     = true;
            }

            return(View());
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
            using (LearningManagementContext context = new LearningManagementContext())
            {
                var course = await context.Courses.FindAsync(id);

                try
                {
                    if (course.StartDate < DateTime.Today)
                    {
                        exception.ValidationExceptions.Add(new Exception("Error: Cannot delete a course that is in progress."));
                    }

                    else if (course.EndDate > DateTime.Today && course.StartDate < DateTime.Today)
                    {
                        exception.ValidationExceptions.Add(new Exception("Error: Cannot delete a course that is in progress."));
                    }

                    if (exception.ValidationExceptions.Count > 0)
                    {
                        throw exception;
                    }
                    context.Courses.Remove(course);
                    await context.SaveChangesAsync();

                    return(RedirectToAction(nameof(CourseList)));
                }

                catch (ValidationException e)
                {
                    ViewBag.Message   = "There exist problem(s) with your submission, see below.";
                    ViewBag.Exception = e;
                    ViewBag.Error     = true;
                }
                return(View(course));
            }
        }
Exemple #13
0
        public IActionResult AssignmentCreate(string Question, string DueDate, string TotalScore, string id) // passing CourseID
        {
            ViewBag.PassingCourseID = id;

            try
            {
                ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
                if (Request.Method == "POST")
                {
                    CreateNewAssignment(Question, DueDate, TotalScore, id);
                    ViewBag.Message           = $"Successfully Created Assignment!";
                    ViewBag.AssignmentCreated = true;
                }
            }
            catch (ValidationException e)
            {
                ViewBag.Message   = "There is an issue(s) with the submission, please see the following details:";
                ViewBag.Exception = e;
                ViewBag.Error     = true;
            }

            return(View());
        }
        public async Task <IActionResult> CourseDelete(int?id)
        {
            ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
            using (LearningManagementContext context = new LearningManagementContext())
            {
                if (id == null)
                {
                    return(NotFound());
                }

                var course = await context.Courses
                             .FirstOrDefaultAsync(m => m.ID == id);

                if (course == null)
                {
                    ViewBag.CourseExists = false;
                    return(View());
                }

                ViewBag.CourseExists = true;
                return(View(course));
            }
        }
        public IActionResult CourseDetail(string id) // passing CourseID
        {
            List <Submit> submittedAssignments;

            try
            {
                ViewBag.UserInformation    = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
                ViewBag.SingleCourseDetail = GetCourseDetailsByID(id);
                if (ViewBag.SingleCourseDetail != null)
                {
                    int studentId = GetStudentId(id, User.Identity.Name);
                    submittedAssignments = GetSubmittedAssignments(studentId.ToString());

                    List <int> submittedIds = new List <int>();

                    int i = 0;
                    foreach (Submit submit in submittedAssignments)
                    {
                        submittedIds.Add(submit.AssignmentID);
                        i++;
                    }

                    // Get Assignments for this course Calling this function from instructor controller
                    ViewBag.AssignmentsForCourse = InstructorController.GetAssignmentsByCourseID(id);
                    ViewBag.SubmittedAssignments = submittedAssignments;
                    ViewBag.SubmittedIds         = submittedIds;
                }
            }
            catch (ValidationException e)
            {
                ViewBag.Message   = "There is an issue(s) with the submission, please see the following details:";
                ViewBag.Exception = e;
                ViewBag.Error     = true;
            }

            return(View());
        }
Exemple #16
0
        public IActionResult AssignmentMark(string submitId, string Remarks, string ScoreObtained, string TotalScore, string courseId)
        {
            try
            {
                ViewBag.BackCourseID              = courseId;
                ViewBag.UserInformation           = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
                ViewBag.SubmittedAssignmentAnswer = GetSubmittedAssignmentBySubmitID(submitId);

                if (Request.Method == "POST")
                {
                    SubmitAssignmentScoreAndRemarks(submitId, Remarks, ScoreObtained, TotalScore);
                    ViewBag.Message   = $"Successfully Submitted Assignment!";
                    ViewBag.SubmitYes = true;
                }
            }
            catch (ValidationException e)
            {
                ViewBag.Message   = "There is an issue(s) with the submission, please see the following details:";
                ViewBag.Exception = e;
                ViewBag.Error     = true;
            }

            return(View());
        }
        public async Task <IActionResult> CourseCreate(string instructor, string courseName, string subject, string courseDescription, string gradeLevel, DateTime?startDate, DateTime?endDate, int currentCapacity, int maxCapacity, [Bind("ID,UserID,CourseName,Subject,CourseDescription,GradeLevel,StartDate,EndDate,MaxCapacity")] Course course)
        {
            ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
            using (LearningManagementContext context = new LearningManagementContext())
            {
                instructor = instructor != null?instructor.Trim() : null;

                courseName = courseName != null?courseName.Trim() : null;

                subject = subject != null?subject.Trim() : null;

                courseDescription = courseDescription != null?courseDescription.Trim() : null;

                if (ModelState.IsValid)
                {
                    try
                    {
                        if (course.MaxCapacity <= 0)
                        {
                            exception.ValidationExceptions.Add(new Exception("Invalid Maximum Capacity: Course must have a minimum of 1 student"));
                        }
                        else
                        {
                            if (course.CurrentCapacity > course.MaxCapacity)
                            {
                                exception.ValidationExceptions.Add(new Exception("Invalid Current Capacity: Current capacity cannot exceed maximum capacity"));
                            }
                            else
                            {
                                if (course.StartDate > course.EndDate)
                                {
                                    exception.ValidationExceptions.Add(new Exception("Invalid Start Date: Course start date cannot be set past the end date"));
                                }

                                else
                                {
                                    if (course.StartDate < DateTime.Today)
                                    {
                                        exception.ValidationExceptions.Add(new Exception("Invalid Start Date: Course start date cannot be set prior to todays date"));
                                    }

                                    else
                                    {
                                        if (course.EndDate < DateTime.Today)
                                        {
                                            exception.ValidationExceptions.Add(new Exception("Invalid End Date: Course end date cannot be set prior to todays date"));
                                        }

                                        else
                                        {
                                            if (context.Courses.Any(x => x.CourseName == course.CourseName))
                                            {
                                                exception.ValidationExceptions.Add(new Exception("Invalid Course Name: That course already exists"));
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        if (exception.ValidationExceptions.Count > 0)
                        {
                            throw exception;
                        }
                        context.Add(course);
                        await context.SaveChangesAsync();

                        ViewBag.Message = $"Successfully created course!";
                    }
                    catch (ValidationException e)
                    {
                        ViewBag.Message   = "There is an issue(s) with the submission, please see the following details:";
                        ViewBag.Exception = e;
                        ViewBag.Error     = true;
                    }

                    var instructors = new SelectList(context.Users.Where(x => x.Role == 2)
                                                     .OrderBy(y => y.LastName)
                                                     .ToDictionary(us => us.ID, us => us.FirstName + " " + us.LastName), "Key", "Value", instructor);
                    ViewBag.Instructors = instructors;
                    ViewBag.CourseName  = courseName;

                    // Create list of Subjects
                    var courseSubjects = new List <string>()
                    {
                        "English", "Math", "Science", "Social Studies"
                    };
                    // Populate dropdown list for subjects.
                    var courseSubjectsList = new SelectList(courseSubjects.ToDictionary(s => s, s => s), "Key", "Value", courseSubjects);
                    ViewBag.CourseSubjects = courseSubjectsList;

                    ViewBag.Subject           = subject;
                    ViewBag.StartDate         = startDate;
                    ViewBag.EndDate           = endDate;
                    ViewBag.CourseDescription = courseDescription;

                    // Create list of GradeLevels
                    var gradeLevels = new List <string>()
                    {
                        "Kindergarten", "Grade 1", "Grade 2", "Grade 3", "Grade 4", "Grade 5", "Grade 6", "Grade 7", "Grade 8", "Grade 9", "Grade 10", "Grade 11", "Grade 12"
                    };
                    // Populate dropdown list for grade levels.
                    var gradeLevelList = new SelectList(gradeLevels.ToDictionary(g => g, g => g), "Key", "Value", gradeLevel);
                    ViewBag.GradeLevels = gradeLevelList;

                    ViewBag.GradeLevel = gradeLevel;
                    //ViewBag.CurrentCapacity = currentCapacity;
                    ViewBag.MaxCapacity = maxCapacity;
                }
            }
            return(View(course));
        }
        public async Task <IActionResult> CourseEdit(int id, [Bind("ID,UserID,CourseName,Subject,CourseDescription,GradeLevel,StartDate,EndDate,CurrentCapacity,MaxCapacity")] Course course)
        {
            ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
            course.CourseName       = course.CourseName != null?course.CourseName.Trim() : null;

            course.Subject = course.Subject != null?course.Subject.Trim() : null;

            course.CourseDescription = course.CourseDescription != null?course.CourseDescription.Trim() : null;

            using (LearningManagementContext context = new LearningManagementContext())
            {
                if (id != course.ID)
                {
                    return(NotFound());
                }

                if (ModelState.IsValid)
                {
                    try
                    {
                        if (course.MaxCapacity <= 0)
                        {
                            exception.ValidationExceptions.Add(new Exception("Invalid Maximum Capacity: Course must have a minimum of 1 student."));
                        }
                        else
                        {
                            if (course.CurrentCapacity > course.MaxCapacity)
                            {
                                exception.ValidationExceptions.Add(new Exception("Invalid Current Capacity: Current capacity cannot exceed maximum capacity."));
                            }
                            else
                            {
                                if (course.StartDate > course.EndDate)
                                {
                                    exception.ValidationExceptions.Add(new Exception("Invalid Start Date: Course start date cannot be after end date."));
                                }
                            }
                        }

                        if (exception.ValidationExceptions.Count > 0)
                        {
                            throw exception;
                        }

                        ViewBag.CourseExists = true;

                        context.Update(course);
                        await context.SaveChangesAsync();

                        ViewBag.Message = $"Successfully updated course!";
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!(context.Courses.Any(x => x.ID == id)))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw exception;
                        }
                    }
                    catch (ValidationException e)
                    {
                        ViewBag.Message   = "There is an issue(s) with the submission, please see the following details:";
                        ViewBag.Exception = e;
                        ViewBag.Error     = true;
                    }

                    // Create a list based on first name and last name from the User table that has a role equal to 2 (which is "Instructor")
                    var instructors = new SelectList(context.Users.Where(x => x.Role == 2)
                                                     .OrderBy(y => y.LastName)
                                                     .ToDictionary(us => us.ID, us => us.FirstName + " " + us.LastName), "Key", "Value", course.UserID);
                    ViewBag.Instructors       = instructors;
                    ViewBag.CourseName        = course.CourseName;
                    ViewBag.Subject           = course.Subject;
                    ViewBag.StartDate         = course.StartDate;
                    ViewBag.EndDate           = course.EndDate;
                    ViewBag.CourseDescription = course.CourseDescription;

                    // Create list of GradeLevels
                    var gradeLevels = new List <string>()
                    {
                        "Kindergarten", "Grade 1", "Grade 2", "Grade 3", "Grade 4", "Grade 5", "Grade 6", "Grade 7", "Grade 8", "Grade 9", "Grade 10", "Grade 11", "Grade 12"
                    };
                    // Populate dropdown list for grade levels.
                    var gradeLevelList = new SelectList(gradeLevels.ToDictionary(g => g, g => g), "Key", "Value", course.GradeLevel);
                    ViewBag.GradeLevels = gradeLevelList;

                    ViewBag.GradeLevel      = course.GradeLevel;
                    ViewBag.CurrentCapacity = course.CurrentCapacity;
                    ViewBag.MaxCapacity     = course.MaxCapacity;
                }
            }
            return(View());
        }
 public IActionResult AdministratorDashboard()
 {
     ViewBag.UserInformation = SharedFunctionsController.GetUserNameBySignInID(User.Identity.Name);
     return(View());
 }