Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java,v diff -u -r1.27 -r1.28 --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java 30 Apr 2008 06:09:16 -0000 1.27 +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java 6 Jun 2008 03:31:24 -0000 1.28 @@ -237,7 +237,9 @@ */ public void performGrouping(Grouping grouping, String groupName, List learners) throws LessonServiceException { - if ( grouping != null && grouping.isChosenGrouping() ) { + if ( grouping != null ) { + // Ensure we have a real grouping object, not just a CGLIB version (LDEV-1817) + grouping = groupingDAO.getGroupingById(grouping.getGroupingId()); Grouper grouper = grouping.getGrouper(); if ( grouper != null ) { grouper.setCommonMessageService(messageService); @@ -248,10 +250,6 @@ } groupingDAO.update(grouping); } - } else { - String error = "The method performChosenGrouping supports only grouping methods where the supplied list should be used as a single group (currently only ChosenGrouping). Called with wrong grouper "+grouping; - log.error(error); - throw new LessonServiceException(error); } } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java,v diff -u -r1.81 -r1.82 --- lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java 30 May 2008 00:43:30 -0000 1.81 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java 6 Jun 2008 03:31:51 -0000 1.82 @@ -49,7 +49,6 @@ import org.lamsfoundation.lams.learningdesign.Group; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.GroupingActivity; -import org.lamsfoundation.lams.learningdesign.LearningDesign; import org.lamsfoundation.lams.learningdesign.SequenceActivity; import org.lamsfoundation.lams.learningdesign.ToolActivity; import org.lamsfoundation.lams.learningdesign.ToolBranchingActivity; @@ -612,10 +611,24 @@ if ( lesson.isPreviewLesson() ) { ArrayList learnerList = new ArrayList(); learnerList.add(learner); - if ( group != null && group.getGroupId() != null ) - lessonService.performGrouping(grouping, group!=null?group.getGroupId():null, learnerList); - else - lessonService.performGrouping(grouping, group.getGroupName(), learnerList); + if ( group != null ) { + if ( group.getGroupId() != null ) + lessonService.performGrouping(grouping, group.getGroupId(), learnerList); + else + lessonService.performGrouping(grouping, group.getGroupName(), learnerList); + } else { + if ( grouping.getGroups().size() > 0 ) { + // if any group exists, put them in there. + Group aGroup = (Group)grouping.getGroups().iterator().next(); + if ( aGroup.getGroupId() != null ) + lessonService.performGrouping(grouping, aGroup.getGroupId(), learnerList); + else + lessonService.performGrouping(grouping, aGroup.getGroupName(), learnerList); + } else { + // just create a group and stick the user in there! + lessonService.performGrouping(grouping, (String)null, learnerList); + } + } groupingDone = true; } return groupingDone; @@ -993,8 +1006,14 @@ } } - // if no groups exist, then create one and assign it to the branch. - } else { + // if no matching groups exist (just to Define in Monitor), then create one and assign it to the branch. + // if it is a chosen grouping, make sure we allow it to go over the normal number of groups (the real groups will exist + // but it too hard to reuse them.) + } else { + if ( grouping.isChosenGrouping() && grouping.getMaxNumberOfGroups() != null ) { + grouping.setMaxNumberOfGroups(null); + } + Group group = lessonService.createGroup(grouping, selectedBranch.getTitle()); group.allocateBranchToGroup(null, selectedBranch, branchingActivity); if ( ! forceGrouping(lesson, grouping, group, learner) ) { Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LoadToolActivityAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LoadToolActivityAction.java,v diff -u -r1.15 -r1.16 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LoadToolActivityAction.java 12 Jul 2007 00:59:02 -0000 1.15 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LoadToolActivityAction.java 6 Jun 2008 03:31:51 -0000 1.16 @@ -59,6 +59,7 @@ public static final String DEFINE_LATER = "previewDefineLater"; public static final String PARAM_ACTIVITY_URL = "activityURL"; + public static final String PARAM_IS_BRANCHING = "isBranching"; /** * Gets an activity from the request (attribute) and forwards onto a @@ -88,6 +89,7 @@ // preview define later request.setAttribute(AttributeNames.PARAM_TITLE, activity.getTitle()); request.setAttribute(PARAM_ACTIVITY_URL, url); + request.setAttribute(PARAM_IS_BRANCHING, activity.isBranchingActivity()); return mapping.findForward("previewDefineLater"); } else { // normal case