Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ToolActivity.java =================================================================== diff -u -rc135649b64e98c9233da20bdcfb7689598116314 -r42844312f7e8f8330c1b4892a8e036ff6b0813d8 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ToolActivity.java (.../ToolActivity.java) (revision c135649b64e98c9233da20bdcfb7689598116314) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ToolActivity.java (.../ToolActivity.java) (revision 42844312f7e8f8330c1b4892a8e036ff6b0813d8) @@ -41,6 +41,7 @@ import org.lamsfoundation.lams.tool.NonGroupedToolSession; import org.lamsfoundation.lams.tool.Tool; import org.lamsfoundation.lams.tool.ToolSession; +import org.lamsfoundation.lams.tool.exception.LamsToolServiceException; import org.lamsfoundation.lams.usermanagement.User; /** @@ -163,68 +164,64 @@ } /** - * Factory method to create a new tool session for a single user when he is - * running current activity. Does not check to see if a tool session already - * exists. + * Factory method to create a new tool session for a single user when he is running current activity. Does not check + * to see if a tool session already exists. *
- * If the activity has groupingSupportType = GROUPING_SUPPORT_NONE then a - * new tool session is created for each learner. + * If the activity has groupingSupportType = GROUPING_SUPPORT_NONE then a new tool session is created for each + * learner. *
- * If the activity has groupingSupportType = GROUPING_SUPPORT_REQUIRED then - * a new tool session is created for each group of learners. It will fall - * back to a class group if no grouping is found - the user interface should - * not have allowed this! + * If the activity has groupingSupportType = GROUPING_SUPPORT_REQUIRED then a new tool session is created for each + * group of learners. It will fall back to a class group if no grouping is found - the user interface should not + * have allowed this! *
- * If the activity has groupingSupportType = GROUPING_SUPPORT_OPTIONAL then - * a new tool session is created for each group of learners. If no grouping - * is available then a whole of class group is created. + * If the activity has groupingSupportType = GROUPING_SUPPORT_OPTIONAL then a new tool session is created for each + * group of learners. If no grouping is available then a whole of class group is created. *
- * If groupingSupportType is not set then defaults to GROUPING_SUPPORT_NONE. - * If for some reason a grouped session if also does the equivalent of - * GROUPING_SUPPORT_NONE. This way the system will still function, if not as - * expected! + * If groupingSupportType is not set then defaults to GROUPING_SUPPORT_NONE. If for some reason a grouped session if + * also does the equivalent of GROUPING_SUPPORT_NONE. This way the system will still function, if not as expected! *
*
* @param learner
- * the user who should be using this tool session.
+ * the user who should be using this tool session.
* @return the new tool session.
*/
+ @SuppressWarnings("unchecked")
public ToolSession createToolSessionForActivity(User learner, Lesson lesson) {
Date now = new Date(System.currentTimeMillis());
Integer supportType = getGroupingSupportType();
ToolSession session = null;
if (supportType != null
- && (supportType.intValue() == GROUPING_SUPPORT_REQUIRED || supportType.intValue() == GROUPING_SUPPORT_OPTIONAL)) {
+ && (supportType.equals(GROUPING_SUPPORT_REQUIRED) || supportType.equals(GROUPING_SUPPORT_OPTIONAL))) {
// Both cases create a small group if a grouping exists, otherwise creates a class group.
- Group learners = null;
+ Group group = null;
if (getApplyGrouping().booleanValue()) {
- learners = this.getGroupFor(learner);
- }
+ group = this.getGroupFor(learner);
+ if (group == null || group.isNull()) {
+ throw new LamsToolServiceException("Activity " + getActivityId()
+ + " requires existing grouping but no group for user " + learner.getUserId()
+ + " exists yet.");
+ }
- if (supportType.intValue() == GROUPING_SUPPORT_REQUIRED && learners == null) {
- log
- .error("Activity "
- + getActivityId()
- + " requires grouping (groupingSupportType=GROUPING_SUPPORT_REQUIRED) but no grouping was available. "
- + " applyGrouping = " + getApplyGrouping() + " grouping = " + getGrouping()
- + ". Falling back to a class grouping.");
- }
+ for (ToolSession toolSession : (Set