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 Details

    • StudentController

      public StudentController()
  • Method Details

    • allStudents

      @PreAuthorize("hasRole('ROLE_ADMIN')") @GetMapping("/all") public Iterable<Student> allStudents()
    • studentsForCourse

      @PreAuthorize("hasRole('ROLE_ADMIN')") @GetMapping("/course/{courseId}") public Iterable<StudentWithLastLogin> studentsForCourse(@PathVariable Long courseId)
    • getStudentById

      @PreAuthorize("hasRole('ROLE_ADMIN')") @GetMapping("/{id}") public Student getStudentById(@PathVariable Long id)
    • 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

      @PreAuthorize("hasRole('ROLE_ADMIN')") @DeleteMapping("/{id}") public Object deleteStudent(@PathVariable Long id)
    • 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 (see StudentCsvFormat); rows whose email is already on the course roster are skipped rather than duplicated.
      Parameters:
      courseId - the course to add the students to
      file - the uploaded CSV file
      Returns:
      a summary of how many students were created, and which emails were skipped as already-on-roster
      Throws:
      IOException