Skip to content
Snippets Groups Projects
Commit ebc24700 authored by CachoobiDoobi's avatar CachoobiDoobi Committed by Otto Visser
Browse files

Add method for reading brightspace csvs

parent 286b8d86
No related branches found
No related tags found
1 merge request!14Resolve "Importing groups from Brightspace"
Pipeline #1010470 failed
......@@ -171,11 +171,10 @@ public class SetupService {
Set<String> groupNames = new HashSet<>();
Map<String, String> groupAssignment = new HashMap<>();
for (List<String> line : lines) {
usernames.add(line.get(0));
groupNames.add(line.get(2));
groupAssignment.put(line.get(0), line.get(2));
}
if(lines.size() < 5)
readGenericCSV(lines, usernames, groupNames, groupAssignment);
else
readBrightspaceCSV(lines, usernames, groupNames, groupAssignment);
if (setupRequestDTO.getGroupSettings() == null)
setupRequestDTO.setGroupSettings(new SetupGroupsDTO());
......@@ -186,6 +185,39 @@ public class SetupService {
return gitlabUserService.getUsersByUsername(gitLabApi, usernames).notFound();
}
/***
* Reads the standard Gitbull CSV template.
*
* @param lines The lines of the import file
* @param usernames The usernames of the students
* @param groupNames The group names of the students
* @param groupAssignment The concatenation of the username and group name
*/
private static void readGenericCSV(List<List<String>> lines, List<String> usernames, Set<String> groupNames, Map<String, String> groupAssignment) {
for (List<String> line : lines) {
usernames.add(line.get(0));
groupNames.add(line.get(2));
groupAssignment.put(line.get(0), line.get(2));
}
}
/***
* Reads the Brightspace CSV template.
*
* @param lines The lines of the import file
* @param usernames The usernames of the students
* @param groupNames The group names of the students
* @param groupAssignment The concatenation of the username and group name
*/
private static void readBrightspaceCSV(List<List<String>> lines, List<String> usernames, Set<String> groupNames, Map<String, String> groupAssignment) {
for (List<String> line : lines) {
usernames.add(line.get(0));
groupNames.add(line.get(6));
groupAssignment.put(line.get(0), line.get(6));
}
}
/**
* Imports the groups and clusters to the setup DTO from an input stream.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment