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 void
checkRowLength
(String[] row, int expectedLength, RosterStudentsCSVController.RosterSourceType sourceType) static RosterStudent
fromChicoCanvasCSVRow
(String[] row) static RosterStudent
fromCSVRow
(String[] row, RosterStudentsCSVController.RosterSourceType sourceType) static RosterStudent
fromOregonStateCSVRow
(String[] row) static RosterStudent
fromUCSBEgradesCSVRow
(String[] row) static String
getFirstName
(String fullName) Get everything except up to and not including the last space in the full name.static String
getLastName
(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:
-
-
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.JsonProcessingException
IOException
com.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
-
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
-