Class RosterStudentsCSVController
java.lang.Object
edu.ucsb.cs156.frontiers.controllers.ApiController
edu.ucsb.cs156.frontiers.controllers.RosterStudentsCSVController
@RequestMapping("/api/rosterstudents")
@RestController
public class RosterStudentsCSVController
extends ApiController
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckRowLength(String[] row, int expectedLength, RosterStudentsCSVController.RosterSourceType sourceType) static RosterStudentfromChicoCanvasCSVRow(String[] row) static RosterStudentfromCSVRow(String[] row, RosterStudentsCSVController.RosterSourceType sourceType) static RosterStudentfromOregonStateCSVRow(String[] row) static RosterStudentfromRosterDownloadCSVRow(String[] row) static RosterStudentfromUCSBEgradesCSVRow(String[] row) static StringgetFirstName(String fullName) Get everything except up to and not including the last space in the full name.static StringgetLastName(String fullName) Get everything after the last space in the full name.getRosterSourceType(String[] headers) org.springframework.http.ResponseEntity<LoadResult> uploadRosterStudentsCSV(Long courseId, org.springframework.web.multipart.MultipartFile file) Upload Roster students for Course in any supported format.Methods inherited from class edu.ucsb.cs156.frontiers.controllers.ApiController
doesCurrentUserHaveRole, genericMessage, getCurrentUser, handleEntityNotFoundException, handleIllegalArgument, handleNoLinkedOrgException, handleUnsupportedOperation, isCurrentUserAdmin
-
Field Details
-
UCSB_EGRADES_HEADERS
- See Also:
-
CHICO_CANVAS_HEADERS
- See Also:
-
OREGON_STATE_HEADERS
- See Also:
-
ROSTER_DOWNLOAD_HEADERS
- See Also:
-
-
Constructor Details
-
RosterStudentsCSVController
public RosterStudentsCSVController()
-
-
Method Details
-
getRosterSourceType
-
uploadRosterStudentsCSV
@PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @PostMapping(value="/upload/csv", consumes="multipart/form-data") public org.springframework.http.ResponseEntity<LoadResult> uploadRosterStudentsCSV(@RequestParam Long courseId, @RequestParam("file") org.springframework.web.multipart.MultipartFile file) throws com.fasterxml.jackson.core.JsonProcessingException, IOException, com.opencsv.exceptions.CsvException Upload Roster students for Course in any supported format. It is important to keep the code in this method consistent with the code for adding a single roster student- Parameters:
courseId-file-- Returns:
- Throws:
com.fasterxml.jackson.core.JsonProcessingExceptionIOExceptioncom.opencsv.exceptions.CsvException
-
fromCSVRow
public static RosterStudent fromCSVRow(String[] row, RosterStudentsCSVController.RosterSourceType sourceType) -
checkRowLength
public static void checkRowLength(String[] row, int expectedLength, RosterStudentsCSVController.RosterSourceType sourceType) -
fromUCSBEgradesCSVRow
-
fromChicoCanvasCSVRow
-
fromOregonStateCSVRow
-
fromRosterDownloadCSVRow
-
getFirstName
Get everything except up to and not including the last space in the full name. If the string contains no spaces, return an empty string.- Parameters:
fullName-- Returns:
-
getLastName
Get everything after the last space in the full name. If the string contains no spaces, return the entire input string as the result.- Parameters:
fullName-- Returns:
- best estimate of last name
-