Index: lams_monitoring/conf/language/lams/ApplicationResources.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/conf/language/lams/ApplicationResources.properties,v
diff -u -r1.13 -r1.14
--- lams_monitoring/conf/language/lams/ApplicationResources.properties 21 May 2008 08:47:33 -0000 1.13
+++ lams_monitoring/conf/language/lams/ApplicationResources.properties 23 May 2008 01:43:55 -0000 1.14
@@ -71,5 +71,6 @@
label.grouping.general.instructions.line2 =To create a group, type a group name and click Add Group. Repeat as required. Select a group, then select students from Column 2 and click Add selected to group. Select students in Column 3 and click Remove selected members from group to remove them from the group membership. The changes are saved when you click any of the buttons.
label.grouping.general.instructions.heading =General Instructions:
+label.grouping.general.instructions.branching=You cannot add or remove groups for this grouping as it is used for Branching and adding and removing groups would affect the group to branch setup. You can only add/remove users to the existing groups.
#======= End labels: Exported 64 labels for en AU =====
Index: lams_monitoring/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/conf/language/lams/ApplicationResources_en_AU.properties,v
diff -u -r1.13 -r1.14
--- lams_monitoring/conf/language/lams/ApplicationResources_en_AU.properties 21 May 2008 08:47:33 -0000 1.13
+++ lams_monitoring/conf/language/lams/ApplicationResources_en_AU.properties 23 May 2008 01:43:55 -0000 1.14
@@ -73,3 +73,4 @@
#======= End labels: Exported 64 labels for en AU =====
+label.grouping.general.instructions.branching=You cannot add or remove groups for this grouping as it is used for Branching and adding and removing groups would affect the group to branch setup. You can only add/remove users to the existing groups.
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java,v
diff -u -r1.71 -r1.72
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 15 Feb 2008 07:13:21 -0000 1.71
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 23 May 2008 01:43:55 -0000 1.72
@@ -541,7 +541,7 @@
* @param name group name
* @throws LessonServiceException
*/
- public abstract void addGroup(Long activityID, String name) throws LessonServiceException;
+ public abstract void addGroup(Long activityID, String name, boolean overrideMaxNumberOfGroups) throws LessonServiceException, MonitoringServiceException;
/** 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.
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java,v
diff -u -r1.128 -r1.129
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 14 Apr 2008 06:34:36 -0000 1.128
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 23 May 2008 01:43:55 -0000 1.129
@@ -1937,8 +1937,8 @@
* @return Sorted set of Users, sorted by surname
*/
public SortedSet getClassMembersNotGrouped(Long lessonID, Long activityID, boolean useCreateGrouping) {
-
- Grouping grouping = getGroupingForActivity(activityID, useCreateGrouping,"getClassMembersNotGrouped");
+ Activity activity = getActivityById(activityID);
+ Grouping grouping = getGroupingForActivity(activity, useCreateGrouping,"getClassMembersNotGrouped");
// get all the learners in the class, irrespective of whether they have joined the lesson or not.
// then go through each group and remove the grouped users from the activeLearners set.
@@ -1981,8 +1981,7 @@
* If it is a teacher chosen branching activity and the grouping doesn't exist, it creates
* one.
*/
- private Grouping getGroupingForActivity(Long activityID, boolean useCreateGrouping, String methodName) {
- Activity activity = getActivityById(activityID);
+ private Grouping getGroupingForActivity(Activity activity, boolean useCreateGrouping, String methodName) {
if ( useCreateGrouping && (activity == null || !activity.isGroupingActivity()) ) {
String error = methodName+": Trying to use the create grouping option but the activity isn't a grouping activity. Activity was "+activity;
log.error(error);
@@ -2016,10 +2015,25 @@
* one.
* @param activityID id of the grouping activity
* @param name group name
- * @throws LessonServiceException
+ * @throws LessonServiceException, MonitoringServiceException
*/
- public void addGroup(Long activityID, String name) throws LessonServiceException {
- Grouping grouping = getGroupingForActivity(activityID, true,"addGroup");
+ public void addGroup(Long activityID, String name, boolean overrideMaxNumberOfGroups) throws LessonServiceException, MonitoringServiceException {
+ Activity activity = getActivityById(activityID);
+ Grouping grouping = getGroupingForActivity(activity, true,"addGroup");
+ if ( overrideMaxNumberOfGroups ) {
+ // Is this grouping used for branching. If it is, must honour the groups
+ // set in authoring or some groups won't have a branch.
+ if ( grouping.getMaxNumberOfGroups() != null && grouping.getMaxNumberOfGroups() > 0 && grouping.getGroups() != null && grouping.getGroups().size() >= grouping.getMaxNumberOfGroups() ) {
+ boolean usedForBranching = grouping.isUsedForBranching();
+ if ( ! usedForBranching ) {
+ log.info("Setting max number of groups to null for grouping "+grouping+" we have been asked to add a group in excess of the max number of groups (probably via the Chosen Grouping screen).");
+ grouping.setMaxNumberOfGroups(null); // must be null and not 0 or the groups will be lost via Live Edit.
+ } else {
+ log.error("Request made to add a group which would be more than the max number of groups for the grouping "+grouping+". This grouping is used for branching so we can't increase the max group number.");
+ throw new MonitoringServiceException("Cannot increase the number of groups for the grouping "+grouping+" as this grouping is used for a branching activity.");
+ }
+ }
+ }
lessonService.createGroup(grouping, name);
}
@@ -2037,14 +2051,15 @@
* @throws LessonServiceException
**/
public void removeGroup(Long activityID, Long groupId) throws LessonServiceException {
- Grouping grouping = getGroupingForActivity(activityID, true,"removeGroup");
+ Activity activity = getActivityById(activityID);
+ Grouping grouping = getGroupingForActivity(activity, 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[]) throws LessonServiceException {
-
- Grouping grouping = getGroupingForActivity(activityID, true, "addUsersToGroup");
+ Activity activity = getActivityById(activityID);
+ Grouping grouping = getGroupingForActivity(activity, true, "addUsersToGroup");
ArrayList learners = createUserList(activityID, learnerIDs,"add");
lessonService.performGrouping(grouping, groupId, learners);
}
@@ -2123,8 +2138,8 @@
/** 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[]) throws LessonServiceException {
-
- Grouping grouping = getGroupingForActivity(activityID, true,"removeUsersFromGroup");
+ Activity activity = getActivityById(activityID);
+ Grouping grouping = getGroupingForActivity(activity, true,"removeUsersFromGroup");
ArrayList learners = createUserList(activityID, learnerIDs,"remove");
lessonService.removeLearnersFromGroup(grouping, groupId, learners);
}
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingAJAXAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingAJAXAction.java,v
diff -u -r1.9 -r1.10
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingAJAXAction.java 10 Oct 2007 07:12:15 -0000 1.9
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingAJAXAction.java 23 May 2008 01:43:55 -0000 1.10
@@ -90,6 +90,7 @@
public static final String PARAM_GROUPS = "groups";
public static final String PARAM_MEMBERS = "members";
public static final String PARAM_MAY_DELETE = "mayDelete";
+ public static final String PARAM_USED_FOR_BRANCHING = "usedForBranching";
private Integer getUserId(HttpServletRequest request) {
HttpSession ss = SessionManager.getSession();
@@ -134,7 +135,6 @@
request.setAttribute(PARAM_ACTIVITY_DESCRIPTION, activity.getDescription());
if ( grouping.isChosenGrouping() ) {
- request.setAttribute(PARAM_MAX_NUM_GROUPS, grouping.getMaxNumberOfGroups());
// can I remove groups/users - can't if tool sessions have been created
Set groups = grouping.getGroups();
Iterator iter = groups.iterator();
@@ -143,7 +143,17 @@
Group group = (Group) iter.next();
mayDelete = group.mayBeDeleted();
}
+
+ // is this grouping used for branching. If it is, must honour the groups
+ // set in authoring or some groups won't have a branch. mayDelete can still
+ // be true or false as you can remove users from groups, you just can't remove
+ // groups due to the branching relationship.
+ boolean usedForBranching = grouping.isUsedForBranching();
+
request.setAttribute(PARAM_MAY_DELETE, mayDelete);
+ request.setAttribute(PARAM_USED_FOR_BRANCHING, usedForBranching);
+ request.setAttribute(PARAM_MAX_NUM_GROUPS, grouping.getMaxNumberOfGroups());
+
return mapping.findForward(CHOSEN_GROUPING_SCREEN);
} else {
@@ -281,7 +291,9 @@
/**
* Add a new group. Designed to respond to an AJAX call.
- *
+ * If the teacher wants to add more groups than the number of groups set in authoring, and this grouping
+ * isn't used for branching then reset the max number of groups to avoid that validation.
+ *
* Input parameters: activityID, name (group name)
*
* Output format: no data returned - just the header
@@ -293,7 +305,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);
+ monitoringService.addGroup(activityID, name, true);
writeAJAXResponse(response,"");
return null;
}