From 98fb87dd9ff046b93edef3f4758cb1fa57031930 Mon Sep 17 00:00:00 2001 From: Geoffrey Kwan Date: Wed, 4 Oct 2023 16:58:21 -0400 Subject: [PATCH] fix(Student Data): Student data does not save if in multiple workgroups in a run (#241) --- .../controllers/InformationController.java | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/InformationController.java b/src/main/java/org/wise/portal/presentation/web/controllers/InformationController.java index 574b20e2d..4ffdc2b21 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/InformationController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/InformationController.java @@ -205,8 +205,8 @@ public void handleGetConfigWISE5Preview(HttpServletRequest request, HttpServletR @GetMapping("/config/studentRun/{runId}") public void getConfigWISE5StudentRun(HttpServletRequest request, HttpServletResponse response, - @PathVariable("runId") RunImpl run) throws ObjectNotFoundException, IOException, - JSONException { + @PathVariable("runId") RunImpl run) + throws ObjectNotFoundException, IOException, JSONException { JSONObject config = new JSONObject(); config.put("mode", "studentRun"); getRunConfigParameters(request, config, run); @@ -411,8 +411,8 @@ private JSONArray getClassmateUserInfosJSONArray(Run run, Workgroup workgroup, U JSONArray studentsNotInWorkgroup = new JSONArray(); for (User user : period.getMembers()) { if (!workgroupService.isUserInAnyWorkgroupForRun(user, run)) { - JSONObject userJSONInfo = - createUserJSONInfo(user, isAllowedToViewStudentNames(run, loggedInUser)); + JSONObject userJSONInfo = createUserJSONInfo(user, + isAllowedToViewStudentNames(run, loggedInUser)); studentsNotInWorkgroup.put(userJSONInfo); } } @@ -781,11 +781,9 @@ private void addDummyUserInfoToConfig(JSONObject config) { } /** - * Gets the workgroup for the currently-logged in user so that she may view the VLE. - * + * Gets the workgroup for the logged in user * @param run - * @return Workgroup for the currently-logged in user - * @throws ObjectNotFoundException + * @return Workgroup for the logged in user */ private Workgroup getWorkgroup(Run run) { Workgroup workgroup = null; @@ -793,16 +791,9 @@ private Workgroup getWorkgroup(Run run) { if (context.getAuthentication().getPrincipal() instanceof UserDetails) { UserDetails userDetails = (UserDetails) context.getAuthentication().getPrincipal(); User user = userService.retrieveUser(userDetails); - List workgroupListByRunAndUser = workgroupService.getWorkgroupListByRunAndUser(run, user); - - if (workgroupListByRunAndUser.size() == 1) { - workgroup = workgroupListByRunAndUser.get(0); - } else if (workgroupListByRunAndUser.size() > 1) { - // this user is in more than one workgroup so we will just get the last one - workgroup = workgroupListByRunAndUser.get(workgroupListByRunAndUser.size() - 1); - } + workgroup = workgroupListByRunAndUser.get(0); } return workgroup; }