Exemplo n.º 1
0
        public void getInstructorSectionsAPITest()
        {
            Instructor instructor = proxy.getInstructor(1);

            Section[] sections = this.proxy.getInstructorSections(instructor);
            Assert.IsNotNull(sections);
        }
        public ActionResult SectionsList()
        {
            ViewData["title"] = "Enrollment Dashboard";

            IProxy proxy = new APIProxy();

            //If the user and role aren't null
            if (Session["user"] != null && Session["role"] != null)
            {
                User currentUser = (User)Session["user"];
                //If the user is a student
                if (String.Equals("student", (string)Session["Role"], StringComparison.OrdinalIgnoreCase))
                {
                    Student student = proxy.getStudent(currentUser.ID);
                    currentSections = proxy.getStudentSections(student);
                }
                //If the user is an instructor
                else if (String.Equals("professor", (string)Session["Role"], StringComparison.OrdinalIgnoreCase))
                {
                    Instructor instructor = proxy.getInstructor(currentUser.ID);
                    currentSections = proxy.getInstructorSections(instructor);
                }
                //If the user is an admin
                else if (String.Equals("admin", (string)Session["Role"], StringComparison.OrdinalIgnoreCase))
                {
                }
            }



            return(View(currentSections));
        }
Exemplo n.º 3
0
        public ActionResult Create(int instructorID, int maxStudents, int courseID, string termCode, int classroomID)
        {
            if (!loggedIn())
            {
                return(RedirectToAction("Index", "Login", new { redirectAction = "Index", redirectController = "Section" }));
            }
            if (!checkPermission("professor") && !checkPermission("admin"))
            {
                return(RedirectToAction("AccessDenied", "Home"));
            }

            Course     course     = proxy.getCourse(courseID);
            Instructor instructor = proxy.getInstructor(instructorID);
            Term       term       = proxy.getTerm(termCode);
            Location   location   = proxy.getLocation(classroomID);

            bool success = true;

            if (course != null && instructor != null && term != null && location != null)
            {
                Section section = new Section(0, maxStudents, term.ID, instructorID, courseID, classroomID, true);
                int     id      = proxy.createSection(section);
                if (id == -1 || proxy.getSection(id) == null)
                {
                    success = false;
                }
            }
            else
            {
                success = false;
            }

            if (success)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(RedirectToAction("Create", new { courseID = courseID, message = "There was an error creating the section" }));
            }
        }