Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -ra7351da17f548464a76295a73e9cc17450a6ff39 -re1683b7e5ac777deb10d15b0bf41182587ca8373 Binary files differ Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml =================================================================== diff -u -ra7351da17f548464a76295a73e9cc17450a6ff39 -re1683b7e5ac777deb10d15b0bf41182587ca8373 --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml (.../Activity.hbm.xml) (revision a7351da17f548464a76295a73e9cc17450a6ff39) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml (.../Activity.hbm.xml) (revision e1683b7e5ac777deb10d15b0bf41182587ca8373) @@ -273,7 +273,7 @@ @hibernate.collection-key column="sequence_activity_id" @hibernate.collection-one-to-many class="org.lamsfoundation.lams.learningdesign.GroupBranchActivityEntry" - + Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/Grouper.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -re1683b7e5ac777deb10d15b0bf41182587ca8373 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/Grouper.java (.../Grouper.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/Grouper.java (.../Grouper.java) (revision e1683b7e5ac777deb10d15b0bf41182587ca8373) @@ -145,14 +145,15 @@ } /** - * Create an empty group for the given grouping. If the group name is not supplied - * or the group name already exists then nothing happens. Trims the name of the group before creating - * the group. + * Create an empty group for the given grouping. Trims the name of the group before creating the group. + * If the group name group name already exists then it appends a datetime string to make the name unique. Gives + * it 5 attempts to make it unique then gives up. * * Throws a GroupingException if name is null or blank. * * @param grouping (mandatory) * @param name (mandatory) + * @param forceName (mandatory) */ public Group createGroup(Grouping grouping, String name) throws GroupingException { @@ -161,8 +162,32 @@ log.warn("Tried to add a group with no name to grouping "+grouping+". Not creating group."); return null; } - Group newGroup = Group.createLearnerGroup(grouping,trimmedName,new HashSet()); - grouping.getGroups().add(newGroup); + Set emptySet = new HashSet(); + Group newGroup = Group.createLearnerGroup(grouping,trimmedName,emptySet); + + if ( newGroup == null ) { + trimmedName = trimmedName + " " + new Long(System.currentTimeMillis()).toString(); + newGroup = Group.createLearnerGroup(grouping, trimmedName, emptySet); + } + + if ( newGroup == null ) { + // what, still not unique? Okay try sticking a number on the end. Try 5 times then give up + log.warn("Having trouble creating a unique name for a group. Have tried "+trimmedName); + int attempt = 1; + while ( newGroup == null && attempt < 5) { + newGroup = Group.createLearnerGroup(grouping, trimmedName+" "+new Integer(attempt).toString(), emptySet); + } + if ( newGroup == null ) { + String error = "Unable to create a unique name for a group. Tried 5 variations on "+trimmedName+" now giving up."; + log.error(error); + throw new GroupingException(error); + + } + } + + if ( newGroup != null ) + grouping.getGroups().add(newGroup); + return newGroup; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java =================================================================== diff -u -ra7351da17f548464a76295a73e9cc17450a6ff39 -re1683b7e5ac777deb10d15b0bf41182587ca8373 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java (.../SequenceActivity.java) (revision a7351da17f548464a76295a73e9cc17450a6ff39) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java (.../SequenceActivity.java) (revision e1683b7e5ac777deb10d15b0bf41182587ca8373) @@ -24,11 +24,13 @@ package org.lamsfoundation.lams.learningdesign; import java.io.Serializable; -import java.util.Date; +import java.util.Iterator; import java.util.Set; import java.util.SortedSet; +import java.util.TreeSet; import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.log4j.Logger; import org.lamsfoundation.lams.learningdesign.strategy.SequenceActivityStrategy; @@ -38,6 +40,8 @@ */ public class SequenceActivity extends ComplexActivity implements Serializable { + private static Logger log = Logger.getLogger(SequenceActivity.class); + /** nullable persistent field */ private Activity firstActivity; @@ -166,7 +170,7 @@ * Get the set of the branch to group mappings used for this branching activity. The set contains GroupBranchActivityEntry entries * * @hibernate.set lazy="true" inverse="true" cascade="none" - * @hibernate.collection-key column="branch_activity_id" + * @hibernate.collection-key column="sequence_activity_id" * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.learningdesign.GroupBranchActivityEntry" */ public Set getBranchEntries() { @@ -177,4 +181,37 @@ this.branchEntries = branchEntries; } + /** Get the groups related to this sequence activity, related via the BranchEntries */ + public SortedSet getGroupsForBranch() { + + Set mappingEntries = getBranchEntries(); + TreeSet sortedGroups = new TreeSet(); + + if ( mappingEntries != null ) { + Iterator mappingIter = mappingEntries.iterator(); + if ( mappingIter.hasNext() ) { + sortedGroups.add(((GroupBranchActivityEntry) mappingIter.next()).getGroup()); + } + } + + return sortedGroups; + } + + /** For chosen and tool based branching, we expect there to be only one group per branch, so get the single group. + * If there is more than one group, put out a warning and return the first group for this sequence activity, + * related via the BranchEntries */ + public Group getSoleGroupForBranch() { + + SortedSet groups = getGroupsForBranch(); + if ( groups.size() > 1 ) { + log.warn("Branch "+this+" has more than one group. This is unexpected. Using only the first group."); + } + Iterator iter = groups.iterator(); + if ( iter.hasNext() ) { + return (Group) iter.next(); + } + + return null; + } + } Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java =================================================================== diff -u -ra94909694731838faabd950b35db3ec905f28529 -re1683b7e5ac777deb10d15b0bf41182587ca8373 --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision a94909694731838faabd950b35db3ec905f28529) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision e1683b7e5ac777deb10d15b0bf41182587ca8373) @@ -28,6 +28,7 @@ import java.util.List; import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.Group; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.GroupingActivity; import org.lamsfoundation.lams.lesson.Lesson; @@ -133,14 +134,14 @@ */ public void removeLearnersFromGroup(Grouping grouping, Long groupId, List learners) throws LessonServiceException; - - /** Create an empty group for the given grouping. If the group name is not supplied - * or the group name already exists then nothing happens. + /** Create an empty group for the given grouping. If the group name already exists + * then it will force the name to be unique. * - * @param grouping the grouping in which to create the group. (mandatory) + * @param grouping the grouping. (mandatory) * @param groupName (mandatory) + * @return the new group */ - public void createGroup(Grouping grouping, String name) throws LessonServiceException; + public Group createGroup(Grouping grouping, String name) throws LessonServiceException; /** * Remove a group for the given grouping. If the group is already used (e.g. a tool session exists) Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java =================================================================== diff -u -ra94909694731838faabd950b35db3ec905f28529 -re1683b7e5ac777deb10d15b0bf41182587ca8373 --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision a94909694731838faabd950b35db3ec905f28529) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision e1683b7e5ac777deb10d15b0bf41182587ca8373) @@ -292,29 +292,31 @@ } } - /** Create an empty group for the given grouping. If the group name is not supplied - * or the group name already exists then nothing happens. + /** Create an empty group for the given grouping. Create an empty group for the given grouping. + * If the group name already exists then it will force the name to be unique. * * @param grouping the grouping. (mandatory) * @param groupName (mandatory) + * @return the new group */ - public void createGroup(Grouping grouping, String name) throws LessonServiceException + public Group createGroup(Grouping grouping, String name) throws LessonServiceException { + Group newGroup = null; if ( grouping != null ) { // get the real objects, not the CGLIB version grouping = groupingDAO.getGroupingById(grouping.getGroupingId()); Grouper grouper = grouping.getGrouper(); if ( grouper != null ) { try { - grouper.createGroup(grouping, name); + newGroup = grouper.createGroup(grouping, name); } catch ( GroupingException e ) { throw new LessonServiceException(e); } } groupingDAO.update(grouping); } + return newGroup; } - /** * Remove a group for the given grouping. If the group is already used (e.g. a tool session exists) * then it throws a GroupingException. Index: lams_monitoring/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r37f37232425f69438bd363e73a66ab7a8ada3345 -re1683b7e5ac777deb10d15b0bf41182587ca8373 --- lams_monitoring/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 37f37232425f69438bd363e73a66ab7a8ada3345) +++ lams_monitoring/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision e1683b7e5ac777deb10d15b0bf41182587ca8373) @@ -57,6 +57,14 @@ export.portfolio.generation.complete.message =Portfolio generated. Your browser should be downloading the file now. When the file is saved please close this window. audit.lesson.created =Lesson "{0}" created with learning design "{1}", export portfolio for learner set to {2}. audit.learner.portfolio.set =Lesson "{0}" has the export portfolio for learner set to {1}. +# temporary additions for teacher chosen branching +label.branching.general.instructions =Place the lesson participants in their branches. Initially you can add and remove users, but once a participant starts one of the branches then you will not be able to remove users from any branches. If you try to remove someone from a branch and they will not remove then check their progress - if they start using the branch while you are on this screen you will not get any errors but you will not be able to remove them from the branch. You will still be able to add users to branches. +label.branching.branch.heading =Branch +label.branching.non.allocated.users.heading =Students without a Branch +label.branching.allocated.users.heading =Members of selected Branch +label.branching.no.groups.created =No groups have been created. +button.branching.add.user.to.branch =Add selected to Branch +button.branching.remove.user.from.branch =Remove selected from Branch #======= End labels: Exported 51 labels for en AU ===== Index: lams_monitoring/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r37f37232425f69438bd363e73a66ab7a8ada3345 -re1683b7e5ac777deb10d15b0bf41182587ca8373 --- lams_monitoring/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 37f37232425f69438bd363e73a66ab7a8ada3345) +++ lams_monitoring/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision e1683b7e5ac777deb10d15b0bf41182587ca8373) @@ -57,6 +57,13 @@ export.portfolio.generation.complete.message =Portfolio generated. Your browser should be downloading the file now. When the file is saved please close this window. audit.lesson.created =Lesson "{0}" created with learning design "{1}", export portfolio for learner set to {2}. audit.learner.portfolio.set =Lesson "{0}" has the export portfolio for learner set to {1}. +# temporary additions for teacher chosen branching +label.branching.general.instructions =Place the lesson participants in their branches. Initially you can add and remove users, but once a participant starts one of the branches then you will not be able to remove users from any branches. If you try to remove someone from a branch and they will not remove then check their progress - if they start using the branch while you are on this screen you will not get any errors but you will not be able to remove them from the branch. You will still be able to add users to branches. +label.branching.branch.heading =Branch +label.branching.non.allocated.users.heading =Students without a Branch +label.branching.allocated.users.heading =Members of selected Branch +label.branching.no.groups.created =No groups have been created. +button.branching.add.user.to.branch =Add selected to Branch +button.branching.remove.user.from.branch =Remove selected from Branch - #======= End labels: Exported 51 labels for en AU ===== Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java =================================================================== diff -u -r7f65c5834b2d8aaee5e26b1f49a1c634c1c6cb15 -re1683b7e5ac777deb10d15b0bf41182587ca8373 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 7f65c5834b2d8aaee5e26b1f49a1c634c1c6cb15) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision e1683b7e5ac777deb10d15b0bf41182587ca8373) @@ -485,7 +485,7 @@ public abstract int deleteAllOldPreviewLessons(); /* ************ Supports the Chosen Groupings and Branching **********************************/ - /** Get all the active learners in the lesson who are not in a group. + /** Get all the active learners in the lesson who are not in a group or in a branch. * * If the activity is a grouping activity, then set useCreatingGrouping = true to * base the list on the create grouping. Otherwise leave it false and it will use the @@ -500,34 +500,44 @@ /** Add a new group to a grouping activity. If name already exists or the name is blank, does not add a new group. * - * If the activity is a grouping activity, then set useCreatingGrouping = true to - * base the list on the create grouping. Otherwise leave it false and it will use the - * grouping applied to the activity - this is used for branching activities. - * * @param activityID id of the activity * @param name group name * @throws LessonServiceException */ - public abstract void addGroup(Long activityID, String name, boolean useCreateGrouping) throws LessonServiceException; + public abstract void addGroup(Long activityID, String name) throws LessonServiceException; /** Remove a group to from a grouping activity. If the group does not exists then nothing happens. * If the group is already used (e.g. a tool session exists) then it throws a LessonServiceException. * - * If the activity is a grouping activity, then set useCreatingGrouping = true to - * base the list on the create grouping. Otherwise leave it false and it will use the - * grouping applied to the activity - this is used for branching activities. - * * @param activityID id of the activity * @param name group name * @throws LessonServiceException **/ - public abstract void removeGroup(Long activityID, Long groupID, boolean useCreateGrouping) throws LessonServiceException; + public abstract void removeGroup(Long activityID, Long groupID) throws LessonServiceException; /** Add learners to a group. Doesn't necessarily check if the user is already in another group. */ - public abstract void addUsersToGroup(Long activityID, Long groupID, String learnerIDs[], boolean useCreateGrouping) throws LessonServiceException ; + public abstract void addUsersToGroup(Long activityID, Long groupID, String learnerIDs[]) throws LessonServiceException ; /** Remove a user to a group. If the user is not in the group, then nothing is changed. * @throws LessonServiceException */ - public abstract void removeUsersFromGroup(Long activityID, Long groupID, String learnerIDs[], boolean useCreateGrouping) throws LessonServiceException; + public abstract void removeUsersFromGroup(Long activityID, Long groupID, String learnerIDs[]) throws LessonServiceException; + /** Add learners to a branch. Doesn't necessarily check if the user is already in another branch. + * Assumes there should only be one group for this branch. Use for Teacher Chosen Branching. Don't use + * for Group Based Branching as there could be more than one group for the branch. + * + * @param sequenceActivityID Activity id of the sequenceActivity representing this branch + * @param learnerIDs the IDS of the learners to be added. + */ + public void addUsersToBranch(Long sequenceActivityID, String learnerIDs[]) throws LessonServiceException; + + /** Remove learners from a branch. + * Assumes there should only be one group for this branch. Use for Teacher Chosen Branching. Don't use + * for Group Based Branching as there could be more than one group for the branch. + * + * @param sequenceActivityID Activity id of the sequenceActivity representing this branch + * @param learnerIDs the IDS of the learners to be added. + */ + public void removeUsersFromBranch(Long sequenceActivityID, String learnerIDs[]) throws LessonServiceException; + } Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== diff -u -r7651b7a24448e75a74e89ed815d8f9f1d7328636 -re1683b7e5ac777deb10d15b0bf41182587ca8373 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 7651b7a24448e75a74e89ed815d8f9f1d7328636) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision e1683b7e5ac777deb10d15b0bf41182587ca8373) @@ -49,14 +49,17 @@ import org.lamsfoundation.lams.dao.IBaseDAO; import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.BranchingActivity; import org.lamsfoundation.lams.learningdesign.ChosenGrouping; import org.lamsfoundation.lams.learningdesign.ComplexActivity; import org.lamsfoundation.lams.learningdesign.GateActivity; import org.lamsfoundation.lams.learningdesign.Group; +import org.lamsfoundation.lams.learningdesign.GroupBranchActivityEntry; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.GroupingActivity; import org.lamsfoundation.lams.learningdesign.LearningDesign; import org.lamsfoundation.lams.learningdesign.ScheduleGateActivity; +import org.lamsfoundation.lams.learningdesign.SequenceActivity; import org.lamsfoundation.lams.learningdesign.ToolActivity; import org.lamsfoundation.lams.learningdesign.dao.IActivityDAO; import org.lamsfoundation.lams.learningdesign.dao.IGroupingDAO; @@ -1942,8 +1945,8 @@ * @param name group name * @throws LessonServiceException */ - public void addGroup(Long activityID, String name, boolean useCreateGrouping) throws LessonServiceException { - Grouping grouping = getGroupingForActivity(activityID, useCreateGrouping,"addGroup"); + public void addGroup(Long activityID, String name) throws LessonServiceException { + Grouping grouping = getGroupingForActivity(activityID, true,"addGroup"); lessonService.createGroup(grouping, name); } @@ -1960,20 +1963,20 @@ * @param name group name * @throws LessonServiceException **/ - public void removeGroup(Long activityID, Long groupId, boolean useCreateGrouping) throws LessonServiceException { - Grouping grouping = getGroupingForActivity(activityID, useCreateGrouping,"removeGroup"); + public void removeGroup(Long activityID, Long groupId) throws LessonServiceException { + Grouping grouping = getGroupingForActivity(activityID, true,"removeGroup"); lessonService.removeGroup(grouping, groupId); } /** Add learners to a group. Doesn't necessarily check if the user is already in another group. */ - public void addUsersToGroup(Long activityID, Long groupId, String learnerIDs[], boolean useCreateGrouping) throws LessonServiceException { + public void addUsersToGroup(Long activityID, Long groupId, String learnerIDs[]) throws LessonServiceException { - Grouping grouping = getGroupingForActivity(activityID, useCreateGrouping,"addUsersToGroup"); + Grouping grouping = getGroupingForActivity(activityID, true, "addUsersToGroup"); ArrayList learners = createUserList(activityID, learnerIDs,"add"); lessonService.performGrouping(grouping, groupId, learners); } - private ArrayList createUserList(Long activityID, String[] learnerIDs, String addRemoveText) { + private ArrayList createUserList(Long activityIDForErrorMessage, String[] learnerIDs, String addRemoveTextForErrorMessage) { ArrayList learners = new ArrayList(); for ( String strlearnerID: learnerIDs ) { boolean added = false; @@ -1986,18 +1989,93 @@ } } catch ( NumberFormatException e ) { } if ( ! added ) { - log.warn("Unable to "+addRemoveText+" learner "+strlearnerID+" for group in grouping activity "+activityID+" as learner cannot be found."); + log.warn("Unable to "+addRemoveTextForErrorMessage+" learner "+strlearnerID + +" for group in related to activity "+activityIDForErrorMessage+" as learner cannot be found."); } } return learners; } + /** Add learners to a branch. Doesn't necessarily check if the user is already in another branch. + * Assumes there should only be one group for this branch. Use for Teacher Chosen Branching. Don't use + * for Group Based Branching as there could be more than one group for the branch. + * + * @param sequenceActivityID Activity id of the sequenceActivity representing this branch + * @param learnerIDs the IDS of the learners to be added. + */ + public void addUsersToBranch(Long sequenceActivityID, String learnerIDs[]) throws LessonServiceException { + + SequenceActivity branch = (SequenceActivity) getActivityById(sequenceActivityID); + if ( branch == null ) { + String error = "addUsersToBranch: Branch missing. ActivityID was "+sequenceActivityID; + log.error(error); + throw new MonitoringServiceException(error); + } + + Group group = branch.getSoleGroupForBranch(); + Grouping grouping = null; + if ( group == null ) { + // create a new group and a matching mapping entry + Activity parentActivity = branch.getParentActivity(); + if ( parentActivity == null || !parentActivity.isBranchingActivity()) { + String error = "addUsersToBranch: Branching activity missing or not a branching activity. Branch was "+branch+" parent activity was "+parentActivity; + log.error(error); + throw new MonitoringServiceException(error); + } + BranchingActivity branchingActivity = (BranchingActivity) getActivityById(parentActivity.getActivityId()); + grouping = branchingActivity.getGrouping(); + + group = lessonService.createGroup(grouping, branch.getTitle()); + + GroupBranchActivityEntry entry = new GroupBranchActivityEntry(null, null, group, branch, (BranchingActivity) branchingActivity); + if ( group.getBranchActivities() == null ) { + group.setBranchActivities(new HashSet()); + } + group.getBranchActivities().add(entry); + groupingDAO.update(group); + + } else { + grouping = group.getGrouping(); + } + + ArrayList learners = createUserList(sequenceActivityID, learnerIDs,"add"); + lessonService.performGrouping(grouping, group.getGroupId(), learners); + } + /** Remove a user to a group. If the user is not in the group, then nothing is changed. * @throws LessonServiceException */ - public void removeUsersFromGroup(Long activityID, Long groupId, String learnerIDs[], boolean useCreateGrouping) throws LessonServiceException { + public void removeUsersFromGroup(Long activityID, Long groupId, String learnerIDs[]) throws LessonServiceException { - Grouping grouping = getGroupingForActivity(activityID, useCreateGrouping,"removeUsersFromGroup"); + Grouping grouping = getGroupingForActivity(activityID, true,"removeUsersFromGroup"); ArrayList learners = createUserList(activityID, learnerIDs,"remove"); lessonService.removeLearnersFromGroup(grouping, groupId, learners); } + + /** Remove learners from a branch. + * Assumes there should only be one group for this branch. Use for Teacher Chosen Branching. Don't use + * for Group Based Branching as there could be more than one group for the branch. + * + * @param sequenceActivityID Activity id of the sequenceActivity representing this branch + * @param learnerIDs the IDS of the learners to be added. + */ + public void removeUsersFromBranch(Long sequenceActivityID, String learnerIDs[]) throws LessonServiceException { + + SequenceActivity branch = (SequenceActivity) getActivityById(sequenceActivityID); + if ( branch == null ) { + String error = "addUsersToBranch: Branch missing. ActivityID was "+sequenceActivityID; + log.error(error); + throw new MonitoringServiceException(error); + } + + Group group = branch.getSoleGroupForBranch(); + Grouping grouping = null; + if ( group != null ) { + grouping = group.getGrouping(); + ArrayList learners = createUserList(sequenceActivityID, learnerIDs,"remove"); + lessonService.removeLearnersFromGroup(grouping, group.getGroupId(), learners); + } else { + log.warn("Trying to remove users "+learnerIDs+" from branch "+branch+" but no group exists for this branch, so the users can't be in the group!"); + } + + } } \ No newline at end of file Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/ChosenBranchingAJAXAction.java =================================================================== diff -u -r7651b7a24448e75a74e89ed815d8f9f1d7328636 -re1683b7e5ac777deb10d15b0bf41182587ca8373 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/ChosenBranchingAJAXAction.java (.../ChosenBranchingAJAXAction.java) (revision 7651b7a24448e75a74e89ed815d8f9f1d7328636) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/ChosenBranchingAJAXAction.java (.../ChosenBranchingAJAXAction.java) (revision e1683b7e5ac777deb10d15b0bf41182587ca8373) @@ -107,7 +107,7 @@ response.setContentType("text/html"); PrintWriter writer = response.getWriter(); // set it to unicode - if (output.length()>0) { + if (output != null && output.length()>0) { writer.println(output); } } @@ -116,16 +116,6 @@ writeAJAXResponse(response, "OK"); } - private Grouping getGrouping(ChosenBranchingActivity activity) { - Grouping grouping = activity.getGrouping(); - if ( grouping == null ) { - String error = "Chosen branching activity missing grouping. Activity was "+activity+" Grouping was "+grouping; - log.error(error); - throw new MonitoringServiceException(error); - } - return grouping; - } - /** * Start the process of doing the chosen grouping * @@ -135,7 +125,6 @@ ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - String type = WebUtil.readStrParam(request, PARAM_TYPE); Long activityID = WebUtil.readLongParam(request, AttributeNames.PARAM_ACTIVITY_ID); Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); @@ -208,22 +197,12 @@ for ( SequenceActivity branch : sortedBranches ) { Long branchId = branch.getActivityId(); String name = branch.getTitle(); - Integer numberOfMembers = null; - - Set mappingEntries = branch.getBranchEntries(); - if ( mappingEntries != null ) { - if ( mappingEntries.size() > 0 ) { - log.warn("Branch "+branch+" for branching activity "+activity+" has more than one group. This should not happen. Using only the first group."); - mappingEntries = new TreeSet(); - } - - Iterator mappingIter = mappingEntries.iterator(); - if ( mappingIter.hasNext() ) { - Group group = ((GroupBranchActivityEntry) mappingIter.next()).getGroup(); - numberOfMembers = group.getUsers().size(); - } - } + int numberOfMembers = 0; + Group group = branch.getSoleGroupForBranch(); + if ( group != null ) + numberOfMembers = group.getUsers().size(); + if ( ! first ) { branchesOutput=branchesOutput+";"; } else { @@ -278,20 +257,7 @@ IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); SequenceActivity branch = (SequenceActivity) monitoringService.getActivityById(branchID); - Set mappingEntries = branch.getBranchEntries(); - Group group = null; - - if ( mappingEntries != null ) { - if ( mappingEntries.size() > 0 ) { - log.warn("Branch "+branch+" for branching activity "+branch+" has more than one group. This should not happen. Using only the first group."); - mappingEntries = new TreeSet(); - } - - Iterator mappingIter = mappingEntries.iterator(); - if ( mappingIter.hasNext() ) { - group = ((GroupBranchActivityEntry) mappingIter.next()).getGroup(); - } - } + Group group = branch.getSoleGroupForBranch(); String userOutput = null; if ( group != null ) { @@ -343,28 +309,13 @@ HttpServletResponse response) throws IOException, ServletException, LessonServiceException { Long branchID = WebUtil.readLongParam(request, PARAM_BRANCH_ID); - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - SequenceActivity branch = (SequenceActivity) monitoringService.getActivityById(branchID); - Set mappingEntries = branch.getBranchEntries(); - Group group = null; - - if ( mappingEntries != null ) { - if ( mappingEntries.size() > 0 ) { - log.warn("Branch "+branch+" for branching activity "+branch+" has more than one group. This should not happen. Using only the first group."); - mappingEntries = new TreeSet(); - } - - Iterator mappingIter = mappingEntries.iterator(); - if ( mappingIter.hasNext() ) { - group = ((GroupBranchActivityEntry) mappingIter.next()).getGroup(); - } - } - String members = WebUtil.readStrParam(request, PARAM_MEMBERS, true); if ( members != null ) { String[] membersSplit = members.split(","); -// monitoringService.addUsersToGroup(activityID, groupID, membersSplit, false); + + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + monitoringService.addUsersToBranch(branchID, membersSplit); } writeAJAXOKResponse(response); @@ -374,23 +325,25 @@ /** * Remove a list of users from a group. Designed to respond to an AJAX call. * - * Input parameters: activityID, name: group name, members: comma separated list of users + * Input parameters: branchID, members: comma separated list of users * * Output format: no data returned - just the header */ public ActionForward removeMembers(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, LessonServiceException { -// Long activityID = WebUtil.readLongParam(request, AttributeNames.PARAM_ACTIVITY_ID); -// Long groupID = WebUtil.readLongParam(request, AttributeNames.PARAM_GROUP_ID); -// String members = WebUtil.readStrParam(request, PARAM_MEMBERS, true); -// if ( members != null ) { -// String[] membersSplit = members.split(","); -// IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); -// monitoringService.removeUsersFromGroup(activityID, groupID, membersSplit, false); -// } -// writeAJAXOKResponse(response); + Long branchID = WebUtil.readLongParam(request, PARAM_BRANCH_ID); + + String members = WebUtil.readStrParam(request, PARAM_MEMBERS, true); + if ( members != null ) { + String[] membersSplit = members.split(","); + + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + monitoringService.removeUsersFromBranch(branchID, membersSplit); + } + + writeAJAXOKResponse(response); return null; } Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingAJAXAction.java =================================================================== diff -u -r7f65c5834b2d8aaee5e26b1f49a1c634c1c6cb15 -re1683b7e5ac777deb10d15b0bf41182587ca8373 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingAJAXAction.java (.../GroupingAJAXAction.java) (revision 7f65c5834b2d8aaee5e26b1f49a1c634c1c6cb15) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingAJAXAction.java (.../GroupingAJAXAction.java) (revision e1683b7e5ac777deb10d15b0bf41182587ca8373) @@ -306,7 +306,7 @@ Long activityID = WebUtil.readLongParam(request, AttributeNames.PARAM_ACTIVITY_ID); String name = WebUtil.readStrParam(request, PARAM_NAME); IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - monitoringService.addGroup(activityID, name, true); + monitoringService.addGroup(activityID, name); writeAJAXResponse(response,""); return null; } @@ -326,7 +326,7 @@ Long groupID = WebUtil.readLongParam(request, AttributeNames.PARAM_GROUP_ID); IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - monitoringService.removeGroup(activityID, groupID, true); + monitoringService.removeGroup(activityID, groupID); writeAJAXOKResponse(response); return null; } @@ -348,7 +348,7 @@ if ( members != null ) { String[] membersSplit = members.split(","); IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - monitoringService.addUsersToGroup(activityID, groupID, membersSplit, true); + monitoringService.addUsersToGroup(activityID, groupID, membersSplit); } writeAJAXOKResponse(response); return null; @@ -371,7 +371,7 @@ if ( members != null ) { String[] membersSplit = members.split(","); IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - monitoringService.removeUsersFromGroup(activityID, groupID, membersSplit, true); + monitoringService.removeUsersFromGroup(activityID, groupID, membersSplit); } writeAJAXOKResponse(response); return null; Index: lams_monitoring/web/branching/chosenSelection.jsp =================================================================== diff -u -r7f65c5834b2d8aaee5e26b1f49a1c634c1c6cb15 -re1683b7e5ac777deb10d15b0bf41182587ca8373 --- lams_monitoring/web/branching/chosenSelection.jsp (.../chosenSelection.jsp) (revision 7f65c5834b2d8aaee5e26b1f49a1c634c1c6cb15) +++ lams_monitoring/web/branching/chosenSelection.jsp (.../chosenSelection.jsp) (revision e1683b7e5ac777deb10d15b0bf41182587ca8373) @@ -32,34 +32,18 @@ <c:out value="${title}"/> - - -