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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe team regular expression that matches every team. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeleteAssignment(Long id, Long courseId) getAssignments(Long courseId) Lists the assignments of a course, sorted by repository prefix.launchAssignmentJob(Long courseId, Long assignmentId) 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.postAssignment(Long courseId, String repoPrefix, AssignmentType asnType, Visibility visibility, Permission permission, RepositoryCreationOption createReposFor, String teamRegex, Boolean requireSignedCommit) Creates an assignment and starts the job that creates its repositories.updateAssignment(Long courseId, Long assignmentId, String repoPrefix, Visibility visibility, Permission permission, RepositoryCreationOption createReposFor, String teamRegex, Boolean requireSignedCommit) Updates an assignment and starts the job that creates its repositories.
-
Field Details
-
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) 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 forrepoPrefix- each repository created begins with this prefixasnType- 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 repositoriescreateReposFor- INDIVIDUAL only: whom to create repositories forteamRegex- TEAM only: only teams whose names match get a repositoryrequireSignedCommit- whether the repositories must require signed commits (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) 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 toassignmentId- the ID of the assignmentrepoPrefix- each repository created begins with this prefixvisibility- the visibility of the repositories (public vs private)permission- the permission that students, or teams, have on the repositoriescreateReposFor- INDIVIDUAL only: whom to create repositories forteamRegex- TEAM only: only teams whose names match get a repositoryrequireSignedCommit- whether the repositories must require signed commits; 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 toassignmentId- the ID of the assignment- Returns:
- the assignment, with its new last job id, and the job that was started
- Throws:
EntityNotFoundException
-
deleteAssignment
-