Index: lams_central/src/java/org/lamsfoundation/lams/web/OrganisationGroupAction.java =================================================================== diff -u -r2d50303390a6ea1ec157a3a1390ecf3833c0339c -r0cd138ac45434e284914fd7fe263c345012412a6 --- lams_central/src/java/org/lamsfoundation/lams/web/OrganisationGroupAction.java (.../OrganisationGroupAction.java) (revision 2d50303390a6ea1ec157a3a1390ecf3833c0339c) +++ lams_central/src/java/org/lamsfoundation/lams/web/OrganisationGroupAction.java (.../OrganisationGroupAction.java) (revision 0cd138ac45434e284914fd7fe263c345012412a6) @@ -101,7 +101,14 @@ public ActionForward viewGroupings(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Long activityID = WebUtil.readLongParam(request, AttributeNames.PARAM_ACTIVITY_ID, true); - boolean lessonGroupsExist = getLessonGrouping(request, activityID, false) != null; + Grouping lessonGrouping = getLessonGrouping(request, activityID, false); + + // if this grouping is used for branching then it should use groups set in authoring. It will be possible to + // remove users from the groups, but not delete groups due to the branching relationships + boolean isUsedForBranching = lessonGrouping != null && lessonGrouping.isUsedForBranching(); + request.setAttribute(GroupingAJAXAction.PARAM_USED_FOR_BRANCHING, isUsedForBranching); + + boolean lessonGroupsExist = lessonGrouping != null; if (lessonGroupsExist) { // this is lesson mode and user have already chosen a grouping before, so show it return viewGroups(mapping, form, request, response); @@ -139,8 +146,8 @@ } request.setAttribute(AttributeNames.PARAM_ORGANISATION_ID, organisationId); - // if this is a chosen group and lesson is created using integrations - show groups received from LMS instead of actual LAMS ones - if (getIntegrationService().isIntegratedServerGroupFetchingAvailable(lessonId)) { + // if it's not a group-based branching and lesson is created using integrations - show groups received from LMS instead of actual LAMS ones + if (!isUsedForBranching && getIntegrationService().isIntegratedServerGroupFetchingAvailable(lessonId)) { if (lessonId == null) { //it's when a learner clicks back button on groups page @@ -245,6 +252,11 @@ lessonGroups = null; } + + // if this grouping is used for branching then it should use groups set in authoring. It will be possible to + // remove users from the groups, but not delete groups due to the branching relationships + boolean isUsedForBranching = lessonGrouping.isUsedForBranching(); + request.setAttribute(GroupingAJAXAction.PARAM_USED_FOR_BRANCHING, isUsedForBranching); JSONArray orgGroupsJSON = new JSONArray(); Collection learners = null; @@ -601,10 +613,6 @@ if ((grouping != null) && (grouping.getGroups() != null)) { Set groups = grouping.getGroups(); - // not very obvious place to use it, but it made most sense - boolean isUsedForBranching = grouping.isUsedForBranching(); - request.setAttribute(GroupingAJAXAction.PARAM_USED_FOR_BRANCHING, isUsedForBranching); - return !groups.isEmpty() && (allowDefault || !isDefaultChosenGrouping(grouping)) ? grouping : null; } }