Class CourseStaffService

java.lang.Object
edu.ucsb.cs156.frontiers.services.CourseStaffService

@Service public class CourseStaffService extends Object
  • Constructor Details

    • CourseStaffService

      public CourseStaffService()
  • Method Details

    • isInstructorStaff

      public static boolean isInstructorStaff(Course course, CourseStaff staff)
      Returns true if a staff member is the course's instructor, matched by email. A course with no instructor email has no instructor staff member.

      This is static so that controllers get the real check even in tests where the CourseStaffService bean is mocked.

      Parameters:
      course - the course
      staff - a staff member of that course
      Returns:
      true if the staff member's email is the course's instructor email
    • ensureInstructorIsStaff

      public void ensureInstructorIsStaff(Course course)
      Makes sure the instructor of a course is on that course's staff list. If the instructor is already a staff member, nothing happens, so this is safe to call more than once.

      The staff member's name is taken from the instructor's User record if they have logged in before; otherwise it is left blank. The org status follows the same rule as adding a staff member by hand: JOINCOURSE if the course is linked to a GitHub org, PENDING if not.

      Parameters:
      course - the course whose instructor should be on staff