Class AssignmentsController

java.lang.Object
edu.ucsb.cs156.frontiers.controllers.ApiController
edu.ucsb.cs156.frontiers.controllers.AssignmentsController

@RequestMapping("/api/assignments") @RestController public class AssignmentsController extends ApiController
Assignments of a course, and the jobs that create their repositories. Creating or editing an assignment saves it and starts the job that creates its individual or team repositories, and the id of that job is kept as the assignment's last job id.
  • Field Details

    • DEFAULT_TEAM_REGEX

      public static final String DEFAULT_TEAM_REGEX
      The team regular expression that matches every team.
      See Also:
  • Constructor Details

    • AssignmentsController

      public AssignmentsController()
  • Method Details

    • getAssignments

      @PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @GetMapping("") public List<Assignment> getAssignments(@RequestParam Long courseId) throws EntityNotFoundException
      Lists the assignments of a course, sorted by repository prefix.
      Parameters:
      courseId - the ID of the course
      Returns:
      the assignments of the course
      Throws:
      EntityNotFoundException
    • postAssignment

      @PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @PostMapping("/post") public AssignmentWithJob postAssignment(@RequestParam Long courseId, @RequestParam String repoPrefix, @RequestParam AssignmentType asnType, @RequestParam Visibility visibility, @RequestParam Permission permission, @RequestParam(required=false) RepositoryCreationOption createReposFor, @RequestParam(required=false) String teamRegex, @RequestParam(required=false) Boolean requireSignedCommit, @RequestParam(required=false) Boolean restrictPrsToContributors) throws EntityNotFoundException
      Creates an assignment and starts the job that creates its repositories.

      For an INDIVIDUAL assignment, createReposFor says whom repositories are created for (default STUDENTS_ONLY) and teamRegex must not be given. For a TEAM assignment, teamRegex is the regular expression that team names must match (default ".*", every team) and createReposFor must not be given.

      Parameters:
      courseId - the ID of the course the assignment is for
      repoPrefix - each repository created begins with this prefix
      asnType - the assignment type (individual vs team)
      visibility - the visibility of the repositories (public vs private)
      permission - the permission that students, or teams, have on the repositories
      createReposFor - INDIVIDUAL only: whom to create repositories for
      teamRegex - TEAM only: only teams whose names match get a repository
      requireSignedCommit - whether the repositories must require signed commits (default false)
      restrictPrsToContributors - TEAM only: whether pull requests are restricted to users with Write access (default false)
      Returns:
      the created assignment, with the id of the job as its last job id, and that job
      Throws:
      EntityNotFoundException
    • updateAssignment

      @PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @PutMapping("/put") public AssignmentWithJob updateAssignment(@RequestParam Long courseId, @RequestParam Long assignmentId, @RequestParam String repoPrefix, @RequestParam Visibility visibility, @RequestParam Permission permission, @RequestParam(required=false) RepositoryCreationOption createReposFor, @RequestParam(required=false) String teamRegex, @RequestParam(required=false) Boolean requireSignedCommit, @RequestParam(required=false) Boolean restrictPrsToContributors) throws EntityNotFoundException
      Updates an assignment and starts the job that creates its repositories. The assignment type cannot be changed: to change an individual assignment to a team one, or the other way round, delete the assignment and create a new one. The same rules as for creating apply to createReposFor and teamRegex, according to the assignment's type.
      Parameters:
      courseId - the ID of the course the assignment belongs to
      assignmentId - the ID of the assignment
      repoPrefix - each repository created begins with this prefix
      visibility - the visibility of the repositories (public vs private)
      permission - the permission that students, or teams, have on the repositories
      createReposFor - INDIVIDUAL only: whom to create repositories for
      teamRegex - TEAM only: only teams whose names match get a repository
      requireSignedCommit - whether the repositories must require signed commits; if it is not given the assignment keeps its setting
      restrictPrsToContributors - TEAM only: whether pull requests are restricted to users with Write access; if it is not given the assignment keeps its setting
      Returns:
      the updated assignment, with the id of the job as its last job id, and that job
      Throws:
      EntityNotFoundException
    • launchAssignmentJob

      @PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @PostMapping("/launch") public AssignmentWithJob launchAssignmentJob(@RequestParam Long courseId, @RequestParam Long assignmentId) throws EntityNotFoundException
      Starts the job that creates the repositories of an existing assignment again, for example to pick up students who have joined since the last run, and records it as the assignment's last job.
      Parameters:
      courseId - the ID of the course the assignment belongs to
      assignmentId - the ID of the assignment
      Returns:
      the assignment, with its new last job id, and the job that was started
      Throws:
      EntityNotFoundException
    • deleteAssignment

      @PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @DeleteMapping("/{id}") public Object deleteAssignment(@PathVariable Long id, @RequestParam Long courseId)