Class StudentController
java.lang.Object
edu.ucsb.cs156.happiercows.controllers.ApiController
edu.ucsb.cs156.happiercows.controllers.StudentController
@RequestMapping("/api/student")
@RestController
public class StudentController
extends ApiController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeleteStudent(Long id) getStudentById(Long id) postStudent(StudentDTO studentDTO) studentsForCourse(Long courseId) updateStudent(Long id, StudentDTO studentDTO) uploadStudentsCsv(Long courseId, org.springframework.web.multipart.MultipartFile file) Bulk-adds roster students to a course from an uploaded CSV file.Methods inherited from class ApiController
genericMessage, getCurrentUser, handleBadRequest, handleForbidden, handleGenericException
-
Constructor Details
-
StudentController
public StudentController()
-
-
Method Details
-
allStudents
-
studentsForCourse
@PreAuthorize("hasRole('ROLE_ADMIN')") @GetMapping("/course/{courseId}") public Iterable<StudentWithLastLogin> studentsForCourse(@PathVariable Long courseId) -
getStudentById
-
postStudent
@PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping("") public Student postStudent(@RequestBody StudentDTO studentDTO) -
updateStudent
@PreAuthorize("hasRole('ROLE_ADMIN')") @PutMapping("/{id}") public Student updateStudent(@PathVariable Long id, @RequestBody StudentDTO studentDTO) -
deleteStudent
-
uploadStudentsCsv
@PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping(value="/upload/csv", consumes="multipart/form-data") public CsvUploadResult uploadStudentsCsv(@RequestParam Long courseId, @RequestParam("file") org.springframework.web.multipart.MultipartFile file) throws IOException Bulk-adds roster students to a course from an uploaded CSV file. The CSV's header row is used to auto-detect which school's roster export format it is (seeStudentCsvFormat); rows whose email is already on the course roster are skipped rather than duplicated.- Parameters:
courseId- the course to add the students tofile- the uploaded CSV file- Returns:
- a summary of how many students were created, and which emails were skipped as already-on-roster
- Throws:
IOException
-