public ActionResult DeleteCourse(int id)
 {
     cs = new CourseRegistration();
     cs.DeleteCourse2(id);
     CourseCardList.GenerateInstructorCourseList();
     return(RedirectToAction("InstructorCView"));
 }
Exemple #2
0
        public ActionResult Verify(User u)
        {
            //Encrypt password functionality
            byte[] data = System.Text.Encoding.ASCII.GetBytes(u.Password);
            data = new System.Security.Cryptography.SHA256Managed().ComputeHash(data);
            String hash = System.Text.Encoding.ASCII.GetString(data);

            gds = new LMS_GRINDEntities1();
            var query = gds.ulUsers.Where(x => x.email_address == u.Email && x.user_password == hash);

            if (query.Any())
            {
                foreach (ulUser user in query)
                {
                    // Set static name variables
                    Name.user_id       = user.ulUser_id;
                    Name.first_name    = user.first_name;
                    Name.last_name     = user.last_name;
                    Name.role          = user.role;
                    Name.email         = user.email_address;
                    Name.birthdate     = user.birthdate;
                    Name.streetAddress = user.street_address;
                    Name.phoneNum      = user.phone_num;
                    Name.bio           = user.bio;
                    Name.link1         = user.link1;
                    Name.link2         = user.link2;
                    Name.link3         = user.link3;
                    Name.profileImage  = user.profileImage;
                    Name.linkTitle1    = user.linkTitle1;
                    Name.linkTitle2    = user.linkTitle2;
                    Name.linkTitle3    = user.linkTitle3;
                }

                if (Name.role == "Student")
                {
                    ViewBag.ErrorMessage = "";
                    ToDoList.GenerateStudentToDoList();
                    CourseCardList.GenerateStudentCourseList();
                    return(View("StudentView"));
                }
                else
                {
                    ViewBag.ErrorMessage = "";
                    ToDoList.GenerateInstructorToDoList();
                    CourseCardList.GenerateInstructorCourseList();
                    return(View("InstructorView"));
                }
            }
            else
            {
                ViewBag.ErrorMessage = "Incorrect user credentials or account not yet created";
                return(View("Login"));
            }
        }
        public ActionResult InstructorAssignment(int id)
        {
            gds = new LMS_GRINDEntities1();
            var courseNum  = gds.Courses.Where(x => x.course_id == id).Select(x => x.course_num).FirstOrDefault();
            var courseName = gds.Courses.Where(x => x.course_id == id).Select(x => x.course_name).FirstOrDefault();

            CourseCardList.GenerateInstructorCourseList();
            AssignmentList.GenerateInstructorAssignmentList(id);
            @ViewBag.CourseId   = id;
            @ViewBag.CourseNum  = courseNum;
            @ViewBag.CourseName = courseName;
            return(View("InstructorAssignmentView"));
        }
        public void SaveCourse2(string courseNum, string courseName, string courseDesc,
                                int courseCredits, int maxCapacity, string courseLocation,
                                int courseRoom, int departments, string monday, string tuesday, string wednesday,
                                string thursday, string friday, TimeSpan startTime, TimeSpan endTime, int instructor_id)
        {
            LMS_GRINDEntities1 gds = new LMS_GRINDEntities1();
            Cours course           = new Cours();

            course.course_name  = courseName;
            Course.courseName   = courseName;
            course.course_desc  = courseDesc;
            Course.courseDesc   = courseDesc;
            course.course_num   = courseNum;
            Course.courseNum    = courseNum;
            course.max_capacity = maxCapacity;
            Course.maxCapacity  = maxCapacity;
            course.dept_id      = departments;
            course.num_credits  = courseCredits;
            Course.numCredits   = courseCredits;
            course.days_of_week = monday + tuesday + wednesday + thursday + friday;
            Course.meetingDays  = monday + tuesday + wednesday + thursday + friday;
            course.start_time   = startTime;
            Course.startTime    = startTime;
            course.end_time     = endTime;
            Course.endTime      = endTime;
            course.building     = courseLocation;
            Course.location     = courseLocation;
            course.room_no      = courseRoom;
            Course.roomNum      = courseRoom;

            gds.Courses.Add(course);
            gds.SaveChanges();

            Course.courseId = course.course_id;

            InstructorCours insCourse = new InstructorCours();

            InstructorCourseContext.courseId = course.course_id;
            insCourse.course_id = course.course_id;
            InstructorCourseContext.instructorId = instructor_id;
            insCourse.instructor_id    = instructor_id;
            Course.instructorFullName  = Name.first_name + " " + Name.last_name;
            Course.instructorLastName  = Name.last_name;
            Course.instructorFirstName = Name.first_name;

            gds.InstructorCourses.Add(insCourse);
            gds.SaveChanges();

            CourseCardList.GenerateInstructorCourseList();
        }
        public ActionResult InstructorCview(string search)
        {
            gds = new LMS_GRINDEntities1();
            var departments = (from d in gds.Departments    // select all departments
                               select d);

            if (!String.IsNullOrEmpty(search))
            {
                departments = departments.Where(x => x.dept_name.Contains(search)); // filter based on search
            }

            CourseCardList.GenerateInstructorCourseList();

            return(View("InstructorCview", departments.ToList().OrderBy(x => x.dept_name)));
        }
        public ActionResult SaveAssignment(string assignmentName,
                                           string assignmentDesc, int maxPoints, DateTime dueDate, string assignmentType, string submissionType)
        {
            var courseId   = int.Parse(Request.Form["CourseId"]);
            var courseNum  = Request.Form["CourseNum"];
            var courseName = Request.Form["CourseName"];


            gds = new LMS_GRINDEntities1();
            Assignment newAssignment = new Assignment();

            var query = from course in gds.Courses
                        join insCourse in gds.InstructorCourses
                        on course.course_id equals insCourse.course_id
                        where course.course_id == courseId
                        select new
            {
                instructorCourseID = insCourse.instructor_course_id
            };

            foreach (var insCourse in query)
            {
                newAssignment.instructor_course_id = insCourse.instructorCourseID;
            }

            newAssignment.assignment_name = assignmentName;
            newAssignment.assignment_desc = assignmentDesc;
            newAssignment.max_points      = maxPoints;
            newAssignment.due_date        = dueDate;
            newAssignment.assignment_type = assignmentType;
            newAssignment.submission_type = submissionType;
            gds.Assignments.Add(newAssignment);
            gds.SaveChanges();


            AssignmentList.GenerateInstructorAssignmentList(courseId);
            CourseCardList.GenerateInstructorCourseList();

            @ViewBag.CourseNum  = courseNum;
            @ViewBag.CourseName = courseName;
            @ViewBag.CourseId   = courseId;

            ToDoList.GenerateInstructorToDoList();

            return(RedirectToAction("InstructorCourseDetail", "CoursesAndRegistration", new { id = courseId }));
        }
        public ActionResult UpdateCourse(int id, string courseNum, string courseName, string courseDesc,
                                         int courseCredits, int maxCapacity, string courseLocation,
                                         int courseRoom, int departments, string monday, string tuesday, string wednesday,
                                         string thursday, string friday, TimeSpan startTime, TimeSpan endTime)
        {
            gds = new LMS_GRINDEntities1();
            Cours course = gds.Courses.Where(x => x.course_id == id).FirstOrDefault();

            try
            {
                course.course_name  = courseName;
                course.course_desc  = courseDesc;
                course.course_num   = courseNum;
                course.max_capacity = maxCapacity;
                course.dept_id      = departments;
                course.num_credits  = courseCredits;
                course.days_of_week = monday + tuesday + wednesday + thursday + friday;
                course.start_time   = startTime;
                course.end_time     = endTime;
                course.building     = courseLocation;
                course.room_no      = courseRoom;

                ViewBag.selectedCourse = course;
                Department department = gds.Departments.Where(x => x.dept_id == course.dept_id).FirstOrDefault();
                ViewBag.courseDepartment = department;

                gds.SaveChanges();
                CourseCardList.GenerateInstructorCourseList();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                    }
                }
            }
            catch
            {
                return(View("EditCourseView"));
            }
            return(View("InstructorCourseInformationView"));
            //return View("InstructorCview");
        }
        public ActionResult DeleteAssignment(int id)
        {
            gds = new LMS_GRINDEntities1();
            Assignment assignment = gds.Assignments.Where(x => x.assignment_id == id).FirstOrDefault();
            int        insCourse  = gds.Assignments.Where(x => x.assignment_id == id).Select(x => x.instructor_course_id).FirstOrDefault();
            int        courseId   = gds.InstructorCourses.Where(x => x.instructor_course_id == insCourse).Select(x => x.course_id).FirstOrDefault();
            var        courseNum  = gds.Courses.Where(x => x.course_id == courseId).Select(x => x.course_num).FirstOrDefault();
            var        courseName = gds.Courses.Where(x => x.course_id == courseId).Select(x => x.course_name).FirstOrDefault();

            gds.Assignments.Remove(assignment);
            gds.SaveChanges();

            //Delete from assignments table, and student assignments table
            //TODO: implement delete from studentAssignments table'
            ViewBag.CourseNum  = courseNum;
            ViewBag.CourseName = courseName;
            ViewBag.CourseId   = courseId;
            AssignmentList.GenerateInstructorAssignmentList(courseId);
            CourseCardList.GenerateInstructorCourseList();
            ToDoList.GenerateInstructorToDoList();
            return(RedirectToAction("InstructorCourseDetail", "CoursesAndRegistration", new { id = courseId }));
        }
        /// <summary>
        /// Display course details for instructor
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Display details of the selected course</returns>
        public ActionResult InstructorCourseDetail(int id)
        {
            gds = new LMS_GRINDEntities1();
            Cours      course     = gds.Courses.Where(x => x.course_id == id).FirstOrDefault();
            Department department = gds.Departments.Where(x => x.dept_id == course.dept_id).FirstOrDefault();
            int        ic_id      = gds.InstructorCourses.Where(x => x.course_id == id).Select(x => x.instructor_course_id).FirstOrDefault();

            CourseCardList.GenerateInstructorCourseList();
            AssignmentList.GenerateInstructorAssignmentList(id);

            // Calculate overall spread of letter grades for students in course
            LetterGradeList.GenerateCourseLetterGrades(id);
            ViewBag.percentA         = LetterGradeList.PercentA;
            ViewBag.percentB         = LetterGradeList.PercentB;
            ViewBag.percentC         = LetterGradeList.PercentC;
            ViewBag.percentD         = LetterGradeList.PercentD;
            ViewBag.percentF         = LetterGradeList.PercentF;
            ViewBag.percentUngraded  = LetterGradeList.PercentUngraded;
            ViewBag.selectedCourse   = course;
            ViewBag.courseDepartment = department;
            return(View("InstructorCourseDetailView"));
        }