Index: lams_build/lib/lams/lams-learning.jar =================================================================== diff -u -rf9b23e848885c277bcc9de377b94ae3884ce7a6d -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 Binary files differ Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -rb3bc1658a5f22b50782fa3037f71c4920fd72db0 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -684,7 +684,6 @@ gate.setActivityUIID(++maxId); gate.setTitle(title); gate.setGateOpen(false); - gate.setWaitingLearners(null); gate.setGateActivityLevelId(GateActivity.LEARNER_GATE_LEVEL); gate.setApplyGrouping(false); // not nullable so default to false gate.setGroupingSupportType(Activity.GROUPING_SUPPORT_OPTIONAL); Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml =================================================================== diff -u -r033cb28ca5f95395e45a337c3c3ddc70ab6edd49 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml (.../Activity.hbm.xml) (revision 033cb28ca5f95395e45a337c3c3ddc70ab6edd49) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml (.../Activity.hbm.xml) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -224,21 +224,11 @@ - + - + - - - - - - - - - - - + Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/lesson/Lesson.hbm.xml =================================================================== diff -u -rc7798d2b81a0595194a5e905ef6c33e372ad8007 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/lesson/Lesson.hbm.xml (.../Lesson.hbm.xml) (revision c7798d2b81a0595194a5e905ef6c33e372ad8007) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/lesson/Lesson.hbm.xml (.../Lesson.hbm.xml) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -263,18 +263,6 @@ AND (lams_learner_progress.lesson_id = :lessonId) - - - SELECT DISTINCT {learner.*} - FROM lams_user {learner}, - lams_learner_progress, - lams_user_group - WHERE ({learner}.user_id = lams_learner_progress.user_id) - AND (lams_learner_progress.lesson_id = :lessonId) - AND ({learner}.user_id = lams_user_group.user_id) - AND (lams_user_group.group_id = :groupId) - - Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/usermanagement/User.hbm.xml =================================================================== diff -u -ra939bcf145b0e4deab5838f87b047df5ca48c92d -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/usermanagement/User.hbm.xml (.../User.hbm.xml) (revision a939bcf145b0e4deab5838f87b047df5ca48c92d) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/usermanagement/User.hbm.xml (.../User.hbm.xml) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -622,45 +622,4 @@ - - - SELECT DISTINCT {user.*} - FROM lams_user {user}, - lams_learner_progress prog, - lams_learning_activity act, - lams_progress_attempted attempt - WHERE - prog.learner_progress_id = attempt.learner_progress_id - and attempt.activity_id=act.activity_id - and act.activity_id=:activityId - and prog.user_id={user}.user_id - - UNION - - SELECT DISTINCT {user.*} - FROM lams_user {user}, - lams_learner_progress prog, - lams_learning_activity act, - lams_progress_completed completed - WHERE - prog.learner_progress_id = completed.learner_progress_id - and completed.activity_id=act.activity_id - and act.activity_id=:activityId - and prog.user_id={user}.user_id - - - - - SELECT DISTINCT {user.*} - FROM lams_user {user}, - lams_learner_progress prog, - lams_learning_activity act, - lams_progress_completed completed - WHERE - prog.learner_progress_id = completed.learner_progress_id - and completed.activity_id=act.activity_id - and act.activity_id=:activityId - and prog.user_id={user}.user_id - - \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch2040049.sql =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch2040049.sql (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch2040049.sql (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -0,0 +1,15 @@ +-- Turn off autocommit, so nothing is committed if there is an error + +SET AUTOCOMMIT = 0; +SET FOREIGN_KEY_CHECKS=0; + +-- LDEV-3614 The table is used for Gate activities only. It can be optimised to hold only allowed learners. +DELETE FROM lams_activity_learners WHERE allowed_to_pass = 0; + +ALTER TABLE lams_activity_learners DROP COLUMN allowed_to_pass, + RENAME TO lams_gate_allowed_learners; + +-- If there were no errors, commit and restore autocommit to on +SET FOREIGN_KEY_CHECKS=0; +COMMIT; +SET AUTOCOMMIT = 1; \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java =================================================================== diff -u -rfe06d16b234341fc965d9b40494e6a2fb4cb9438 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java (.../Activity.java) (revision fe06d16b234341fc965d9b40494e6a2fb4cb9438) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java (.../Activity.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -573,7 +573,7 @@ /** * @return Returns the branchActivityEntries. */ - public Set getBranchActivityEntries() { + public Set getBranchActivityEntries() { return branchActivityEntries; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ConditionGateActivity.java =================================================================== diff -u -rc135649b64e98c9233da20bdcfb7689598116314 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ConditionGateActivity.java (.../ConditionGateActivity.java) (revision c135649b64e98c9233da20bdcfb7689598116314) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ConditionGateActivity.java (.../ConditionGateActivity.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -49,11 +49,11 @@ Activity parentActivity, Activity libraryActivity, Integer parentUIID, LearningDesign learningDesign, Grouping grouping, Integer activityTypeId, Transition transitionTo, Transition transitionFrom, String languageFile, Boolean stopAfterActivity, Set inputActivities, Integer gateActivityLevelId, - Set waitingLearners, SystemTool sysTool, Set branchActivityEntries) { + SystemTool sysTool, Set branchActivityEntries) { super(activityId, id, description, title, xcoord, ycoord, orderId, createDateTime, learningLibrary, parentActivity, libraryActivity, parentUIID, learningDesign, grouping, activityTypeId, transitionTo, - transitionFrom, languageFile, stopAfterActivity, inputActivities, gateActivityLevelId, waitingLearners, - sysTool, branchActivityEntries); + transitionFrom, languageFile, stopAfterActivity, inputActivities, gateActivityLevelId, sysTool, + branchActivityEntries); super.simpleActivityStrategy = new ConditionGateActivityStrategy(this); } @@ -68,9 +68,9 @@ org.lamsfoundation.lams.learningdesign.Activity parentActivity, org.lamsfoundation.lams.learningdesign.LearningDesign learningDesign, org.lamsfoundation.lams.learningdesign.Grouping grouping, Integer activityTypeId, Transition transitionTo, - Transition transitionFrom, Integer gateActivityLevelId, Set waitingLearners) { + Transition transitionFrom, Integer gateActivityLevelId) { super(activityId, createDateTime, learningLibrary, parentActivity, learningDesign, grouping, activityTypeId, - transitionTo, transitionFrom, gateActivityLevelId, waitingLearners); + transitionTo, transitionFrom, gateActivityLevelId); super.simpleActivityStrategy = new ConditionGateActivityStrategy(this); } @@ -86,14 +86,14 @@ newConditionGateActivity.setGateOpen(new Boolean(false)); newConditionGateActivity.setGateActivityLevelId(this.getGateActivityLevelId()); - if (this.getBranchActivityEntries() != null && this.getBranchActivityEntries().size() > 0) { + if ((this.getBranchActivityEntries() != null) && (this.getBranchActivityEntries().size() > 0)) { newConditionGateActivity.setBranchActivityEntries(new HashSet()); Iterator iter = this.getBranchActivityEntries().iterator(); while (iter.hasNext()) { BranchActivityEntry oldEntry = (BranchActivityEntry) iter.next(); - BranchActivityEntry newEntry = new BranchActivityEntry(null, LearningDesign.addOffset( - oldEntry.getEntryUIID(), uiidOffset), null, newConditionGateActivity, null, - oldEntry.getGateOpenWhenConditionMet()); + BranchActivityEntry newEntry = new BranchActivityEntry(null, + LearningDesign.addOffset(oldEntry.getEntryUIID(), uiidOffset), null, newConditionGateActivity, + null, oldEntry.getGateOpenWhenConditionMet()); if (oldEntry.getCondition() != null) { BranchCondition newCondition = oldEntry.getCondition().clone(uiidOffset); newEntry.setCondition(newCondition); @@ -115,6 +115,7 @@ /** * @see org.lamsfoundation.lams.util.Nullable#isNull() */ + @Override public boolean isNull() { return false; } @@ -123,36 +124,39 @@ public Vector validateActivity(MessageService messageService) { Vector listOfValidationErrors = new Vector(); - if (getInputActivities() == null || getInputActivities().size() == 0) { - listOfValidationErrors.add(new ValidationErrorDTO( - ValidationErrorDTO.CONDITION_GATE_ACTVITY_TOOLINPUT_ERROR_CODE, messageService - .getMessage(ValidationErrorDTO.CONDITION_GATE_ACTVITY_TOOLINPUT), this.getActivityUIID())); + if ((getInputActivities() == null) || (getInputActivities().size() == 0)) { + listOfValidationErrors + .add(new ValidationErrorDTO(ValidationErrorDTO.CONDITION_GATE_ACTVITY_TOOLINPUT_ERROR_CODE, + messageService.getMessage(ValidationErrorDTO.CONDITION_GATE_ACTVITY_TOOLINPUT), + this.getActivityUIID())); } boolean conditionsExist = false; if (getBranchActivityEntries() != null) { for (BranchActivityEntry entry : (Set) getBranchActivityEntries()) { BranchCondition condition = entry.getCondition(); if (condition == null) { - listOfValidationErrors.add(new ValidationErrorDTO( - ValidationErrorDTO.BRANCH_CONDITION_INVALID_ERROR_CODE, messageService - .getMessage(ValidationErrorDTO.BRANCH_CONDITION_INVALID), this.getActivityUIID())); + listOfValidationErrors + .add(new ValidationErrorDTO(ValidationErrorDTO.BRANCH_CONDITION_INVALID_ERROR_CODE, + messageService.getMessage(ValidationErrorDTO.BRANCH_CONDITION_INVALID), + this.getActivityUIID())); } else { conditionsExist = true; if (!condition.isValid()) { - listOfValidationErrors.add(new ValidationErrorDTO( - ValidationErrorDTO.BRANCH_CONDITION_INVALID_ERROR_CODE, messageService - .getMessage(ValidationErrorDTO.BRANCH_CONDITION_INVALID), this - .getActivityUIID())); + listOfValidationErrors + .add(new ValidationErrorDTO(ValidationErrorDTO.BRANCH_CONDITION_INVALID_ERROR_CODE, + messageService.getMessage(ValidationErrorDTO.BRANCH_CONDITION_INVALID), + this.getActivityUIID())); } } } } if (!conditionsExist) { - listOfValidationErrors.add(new ValidationErrorDTO( - ValidationErrorDTO.CONDITION_GATE_ACTVITY_CONDITION_ERROR_CODE, messageService - .getMessage(ValidationErrorDTO.CONDITION_GATE_ACTVITY_CONDITION), this.getActivityUIID())); + listOfValidationErrors + .add(new ValidationErrorDTO(ValidationErrorDTO.CONDITION_GATE_ACTVITY_CONDITION_ERROR_CODE, + messageService.getMessage(ValidationErrorDTO.CONDITION_GATE_ACTVITY_CONDITION), + this.getActivityUIID())); } return listOfValidationErrors; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/GateActivity.java =================================================================== diff -u -rc135649b64e98c9233da20bdcfb7689598116314 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/GateActivity.java (.../GateActivity.java) (revision c135649b64e98c9233da20bdcfb7689598116314) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/GateActivity.java (.../GateActivity.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -24,8 +24,6 @@ package org.lamsfoundation.lams.learningdesign; import java.io.Serializable; -import java.util.HashSet; -import java.util.List; import java.util.Set; import org.apache.commons.lang.builder.ToStringBuilder; @@ -54,30 +52,21 @@ private Boolean gateOpen; /** - * The learners who are waiting at the gate. - */ - private Set waitingLearners; - /** * The learners who passed the gate. */ private Set allowedToPassLearners; - /** - * The learners who reached the gate. - */ - private Set allGateUsers; /** full constructor */ public GateActivity(Long activityId, Integer id, String description, String title, Integer xcoord, Integer ycoord, Integer orderId, java.util.Date createDateTime, LearningLibrary learningLibrary, Activity parentActivity, Activity libraryActivity, Integer parentUIID, LearningDesign learningDesign, Grouping grouping, Integer activityTypeId, Transition transitionTo, Transition transitionFrom, String languageFile, - Boolean stopAfterActivity, Set inputActivities, Integer gateActivityLevelId, Set waitingLearners, - SystemTool sysTool, Set branchActivityEntries) { + Boolean stopAfterActivity, Set inputActivities, Integer gateActivityLevelId, SystemTool sysTool, + Set branchActivityEntries) { super(activityId, id, description, title, xcoord, ycoord, orderId, createDateTime, learningLibrary, parentActivity, libraryActivity, parentUIID, learningDesign, grouping, activityTypeId, transitionTo, transitionFrom, languageFile, stopAfterActivity, inputActivities, branchActivityEntries); this.gateActivityLevelId = gateActivityLevelId; - this.waitingLearners = waitingLearners; systemTool = sysTool; } @@ -91,11 +80,10 @@ org.lamsfoundation.lams.learningdesign.Activity parentActivity, org.lamsfoundation.lams.learningdesign.LearningDesign learningDesign, org.lamsfoundation.lams.learningdesign.Grouping grouping, Integer activityTypeId, Transition transitionTo, - Transition transitionFrom, Integer gateActivityLevelId, Set waitingLearners) { + Transition transitionFrom, Integer gateActivityLevelId) { super(activityId, createDateTime, learningLibrary, parentActivity, learningDesign, grouping, activityTypeId, transitionTo, transitionFrom); this.gateActivityLevelId = gateActivityLevelId; - this.waitingLearners = waitingLearners; } /** @@ -111,24 +99,6 @@ this.gateActivityLevelId = gateActivityLevelId; } - /** - * @return Returns the waitingLearners. - */ - public Set getWaitingLearners() { - if (waitingLearners == null) { - this.setWaitingLearners(new HashSet()); - } - return waitingLearners; - } - - /** - * @param waitingLearners - * The waitingLearners to set. - */ - public void setWaitingLearners(Set waitingLearners) { - this.waitingLearners = waitingLearners; - } - public Boolean getGateOpen() { return gateOpen; } @@ -142,56 +112,19 @@ // --------------------------------------------------------------------- /** - * Add a learner into the waiting or allowed to pass list. - * - * @param learner - * the new learner. - * @param isAllowedToPass - * is the learner allowed to pass the gate - */ - public void addLeaner(User learner, boolean isAllowedToPass) { - boolean add = true; - GateUser gateUser = new GateUser(); - gateUser.setUser(learner); - - if (getWaitingLearners().contains(learner)) { - if (isAllowedToPass) { - gateUser.setAllowedToPass(false); - getAllGateUsers().remove(gateUser); - getWaitingLearners().remove(learner); - } else { - add = false; - } - } else if (getAllowedToPassLearners().contains(learner)) { - // Once a learner was allowed to pass, he/she may never be forbidden back. - add = false; - } - - if (add) { - gateUser.setAllowedToPass(isAllowedToPass); - getAllGateUsers().add(gateUser); - if (isAllowedToPass) { - getAllowedToPassLearners().add(learner); - } else { - getWaitingLearners().add(learner); - } - } - } - - /** * Delegate to strategy class to calculate whether we should open the gate for this learner. * * @param learner * the learner who wants to go through the gate. * @return the gate is open or closed. */ - public boolean shouldOpenGateFor(User learner, List lessonLearners) { + public boolean shouldOpenGateFor(User learner, int expectedLearnerCount, int waitingLearnerCount) { // by default, we close the gate if (getGateOpen() == null) { - this.setGateOpen(Boolean.FALSE); + this.setGateOpen(false); } - - return ((GateActivityStrategy) simpleActivityStrategy).shouldOpenGateFor(learner, lessonLearners); + return ((GateActivityStrategy) simpleActivityStrategy).shouldOpenGateFor(learner, expectedLearnerCount, + waitingLearnerCount); } /** @@ -200,10 +133,8 @@ * * @return the gate is open or closed. */ - public boolean forceGateOpen() { - setGateOpen(Boolean.TRUE); - getAllGateUsers().clear(); - return true; + public void forceGateOpen() { + setGateOpen(true); } // --------------------------------------------------------------------- @@ -214,10 +145,12 @@ return new ToStringBuilder(this).append("activityId", getActivityId()).toString(); } + @Override public SystemTool getSystemTool() { return systemTool; } + @Override public void setSystemTool(SystemTool systemTool) { this.systemTool = systemTool; } @@ -229,25 +162,10 @@ } public Set getAllowedToPassLearners() { - if (allowedToPassLearners == null) { - this.setAllowedToPassLearners(new HashSet()); - } return allowedToPassLearners; } public void setAllowedToPassLearners(Set allowedToPassLearners) { this.allowedToPassLearners = allowedToPassLearners; } - - public Set getAllGateUsers() { - if (allGateUsers == null) { - this.setAllGateUsers(new HashSet()); - } - return allGateUsers; - } - - public void setAllGateUsers(Set allLearners) { - allGateUsers = allLearners; - } - -} +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java =================================================================== diff -u -ree6a40ada6ae3bea48ecdedc5cad0ce3e7a3f3d8 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java (.../Group.java) (revision ee6a40ada6ae3bea48ecdedc5cad0ce3e7a3f3d8) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java (.../Group.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -25,7 +25,6 @@ import java.io.Serializable; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import org.apache.commons.lang.builder.CompareToBuilder; @@ -36,316 +35,316 @@ import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.util.Nullable; -public class Group implements Serializable,Nullable,Comparable { +public class Group implements Serializable, Nullable, Comparable { public final static int STAFF_GROUP_ORDER_ID = 1; public final static String NAME_OF_STAFF_GROUP = "Staff Group"; - + /** identifier field */ private Long groupId; - + private String groupName; /** persistent field */ private int orderId; - /** FLASH generated value. Unique per LearningDesign. - * Required by flash only.*/ + /** + * FLASH generated value. Unique per LearningDesign. Required by flash only. + */ private Integer groupUIID; /** persistent field */ private Grouping grouping; /** persistent field */ - private Set users; + private Set users; /** persistent field */ private Set toolSessions; /** persistent field */ - private Set branchActivities; + private Set branchActivities; - //--------------------------------------------------------------------- + // --------------------------------------------------------------------- // Object creation Methods - //--------------------------------------------------------------------- - + // --------------------------------------------------------------------- + /** full constructor */ - public Group(Long groupId, String groupName, int orderId, Integer groupUIID, Grouping grouping, Set users, Set toolSessions, Set branchActivities) { - this.groupId = groupId; - this.groupName = groupName; - this.orderId = orderId; - this.groupUIID = groupUIID; - this.grouping = grouping; - this.users = users; - this.toolSessions = toolSessions; - this.branchActivities = branchActivities; + public Group(Long groupId, String groupName, int orderId, Integer groupUIID, Grouping grouping, Set users, + Set toolSessions, Set branchActivities) { + this.groupId = groupId; + this.groupName = groupName; + this.orderId = orderId; + this.groupUIID = groupUIID; + this.grouping = grouping; + this.users = users; + this.toolSessions = toolSessions; + this.branchActivities = branchActivities; } /** - * Creation Constructor for initializing learner group without tool sessions - * The order is generated using synchornize method on grouping. If a group of - * this name already exists, returns null. + * Creation Constructor for initializing learner group without tool sessions The order is generated using + * synchornize method on grouping. If a group of this name already exists, returns null. * - * @param grouping the grouping this group belongs to. - * @param users the users in this group. + * @param grouping + * the grouping this group belongs to. + * @param users + * the users in this group. * @return the new learner group */ - public static Group createLearnerGroup(Grouping grouping, String groupName, Set users) - { - int nextOrderId = grouping.getNextGroupOrderIdCheckName(groupName); - if ( nextOrderId > -1 ) { - return new Group(null,groupName,nextOrderId,null,grouping,users,new HashSet(),null); - } - return null; + public static Group createLearnerGroup(Grouping grouping, String groupName, Set users) { + int nextOrderId = grouping.getNextGroupOrderIdCheckName(groupName); + if (nextOrderId > -1) { + return new Group(null, groupName, nextOrderId, null, grouping, users, new HashSet(), null); + } + return null; } - + /** - * Creation Constructor for initializing learner group with tool sessions - * The order is generated using synchornize method on grouping. If a group of - * this name already exists, returns null. + * Creation Constructor for initializing learner group with tool sessions The order is generated using synchornize + * method on grouping. If a group of this name already exists, returns null. * - * @param grouping the grouping this group belongs to. - * @param name of this group - * @param users the users in this group. - * @param toolSessions all tool sessions included in this group + * @param grouping + * the grouping this group belongs to. + * @param name + * of this group + * @param users + * the users in this group. + * @param toolSessions + * all tool sessions included in this group * @return the new learner group */ - public static Group createLearnerGroupWithToolSession(Grouping grouping, String groupName, Set users,Set toolSessions) - { - int nextOrderId = grouping.getNextGroupOrderIdCheckName(groupName); - if ( nextOrderId > -1 ) { - return new Group(null,groupName,nextOrderId,null,grouping,users,toolSessions,null); - } - return null; + public static Group createLearnerGroupWithToolSession(Grouping grouping, String groupName, Set users, + Set toolSessions) { + int nextOrderId = grouping.getNextGroupOrderIdCheckName(groupName); + if (nextOrderId > -1) { + return new Group(null, groupName, nextOrderId, null, grouping, users, toolSessions, null); + } + return null; } - + /** - * Creation constructor for initializing staff group. The order is created - * using default constant. - * @param grouping the grouping this group belongs to. - * @param name of this group - * @param staffs the users in this group. + * Creation constructor for initializing staff group. The order is created using default constant. * - * @return the new staff group. + * @param grouping + * the grouping this group belongs to. + * @param name + * of this group + * @param staffs + * the users in this group. + * + * @return the new staff group. */ - public static Group createStaffGroup(Grouping grouping, String groupName, Set staffs) - { - return new Group(null,groupName, STAFF_GROUP_ORDER_ID,null,grouping,staffs,new HashSet(),null); + public static Group createStaffGroup(Grouping grouping, String groupName, Set staffs) { + return new Group(null, groupName, Group.STAFF_GROUP_ORDER_ID, null, grouping, staffs, new HashSet(), null); } - + /** default constructor */ public Group() { } - //--------------------------------------------------------------------- + // --------------------------------------------------------------------- // Field Access Methods - //--------------------------------------------------------------------- + // --------------------------------------------------------------------- public Long getGroupId() { - return this.groupId; + return this.groupId; } public String getGroupName() { - return groupName; - } + return groupName; + } - public void setGroupName(String groupName) { - this.groupName = groupName; - } + public void setGroupName(String groupName) { + this.groupName = groupName; + } - public void setGroupId(Long groupId) { - this.groupId = groupId; + public void setGroupId(Long groupId) { + this.groupId = groupId; } public int getOrderId() { - return this.orderId; + return this.orderId; } public void setOrderId(int orderId) { - this.orderId = orderId; + this.orderId = orderId; } - public Integer getGroupUIID() { - return this.groupUIID; - } + public Integer getGroupUIID() { + return this.groupUIID; + } - public void setGroupUIID(Integer uiId) { - this.groupUIID = uiId; - } + public void setGroupUIID(Integer uiId) { + this.groupUIID = uiId; + } public org.lamsfoundation.lams.learningdesign.Grouping getGrouping() { - return this.grouping; + return this.grouping; } public void setGrouping(org.lamsfoundation.lams.learningdesign.Grouping grouping) { - this.grouping = grouping; + this.grouping = grouping; } /** - * @hibernate.set lazy="true" inverse="true" cascade="none" - * table = "lams_user_group" + * @hibernate.set lazy="true" inverse="true" cascade="none" table = "lams_user_group" * @hibernate.collection-key column="group_id" - * @hibernate.collection-many-to-many column="user_id" - * class="org.lamsfoundation.lams.usermanagement.User" + * @hibernate.collection-many-to-many column="user_id" class="org.lamsfoundation.lams.usermanagement.User" */ - public Set getUsers() { - return this.users; + public Set getUsers() { + return this.users; } public void setUsers(Set userGroups) { - this.users = userGroups; + this.users = userGroups; } - /** - * @hibernate.set - * lazy="true" - * inverse="true" - * cascade="none" - * @hibernate.collection-key - * column="group_id" - * @hibernate.collection-one-to-many - * class="org.lamsfoundation.lams.tool.ToolSession" - * + /** + * @hibernate.set lazy="true" inverse="true" cascade="none" + * @hibernate.collection-key column="group_id" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.tool.ToolSession" + * */ public Set getToolSessions() { - return this.toolSessions; + return this.toolSessions; } public void setToolSessions(Set toolSessions) { - this.toolSessions = toolSessions; + this.toolSessions = toolSessions; } - /** Maps the branch activities appropriate for this Group. Normally there is only one branch - * per branching activity that is applicable to a group, but this may be changed in the future. - * If the group is applied to multiple branching activities, then there will be multiple - * branches - one for each branching activity. - * - * @hibernate.set - * lazy="true" - * inverse="true" - * cascade="all-delete-orphane" - * @hibernate.collection-key - * column="group_id" - * @hibernate.collection-one-to-many - * class="org.lamsfoundation.lams.learningdesign.BranchActivityEntry" - * + /** + * Maps the branch activities appropriate for this Group. Normally there is only one branch per branching activity + * that is applicable to a group, but this may be changed in the future. If the group is applied to multiple + * branching activities, then there will be multiple branches - one for each branching activity. + * + * @hibernate.set lazy="true" inverse="true" cascade="all-delete-orphane" + * @hibernate.collection-key column="group_id" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.learningdesign.BranchActivityEntry" + * */ - public Set getBranchActivities() { - return this.branchActivities; - } - public void setBranchActivities(Set branchActivities) { - this.branchActivities = branchActivities; - } + public Set getBranchActivities() { + return this.branchActivities; + } + public void setBranchActivities(Set branchActivities) { + this.branchActivities = branchActivities; + } + + @Override public String toString() { - return new ToStringBuilder(this) - .append("groupId", getGroupId()) - .append("groupName", getGroupName()) - .append("groupUIID", getGroupUIID()) - .toString(); + return new ToStringBuilder(this).append("groupId", getGroupId()).append("groupName", getGroupName()) + .append("groupUIID", getGroupUIID()).toString(); } + @Override public boolean equals(Object other) { - if ( (this == other ) ) return true; - if ( !(other instanceof Group) ) return false; - Group castOther = (Group) other; - return new EqualsBuilder() - .append(this.getOrderId(), castOther.getOrderId()) - .append(this.getGroupId(), castOther.getGroupId()) - .append(this.getGroupName(), castOther.getGroupName()) - .append(this.getGroupUIID(), castOther.getGroupUIID()) - .isEquals(); + if ((this == other)) { + return true; + } + if (!(other instanceof Group)) { + return false; + } + Group castOther = (Group) other; + return new EqualsBuilder().append(this.getOrderId(), castOther.getOrderId()) + .append(this.getGroupId(), castOther.getGroupId()).append(this.getGroupName(), castOther.getGroupName()) + .append(this.getGroupUIID(), castOther.getGroupUIID()).isEquals(); } + @Override public int hashCode() { - return new HashCodeBuilder() - .append(getGroupId()) - .append(getGroupName()) - .append(getOrderId()) - .append(getGroupUIID()) - .toHashCode(); + return new HashCodeBuilder().append(getGroupId()).append(getGroupName()).append(getOrderId()) + .append(getGroupUIID()).toHashCode(); } - + /** * Sort the groups using order id. + * * @see java.lang.Comparable#compareTo(java.lang.Object) */ - public int compareTo(Object o) - { - Group castOther = (Group)o; - return new CompareToBuilder() - .append(this.getOrderId(), castOther.getOrderId()) - .append(this.getGroupId(), castOther.getGroupId()) - .append(this.getGroupName(), castOther.getGroupName()) - .append(this.getGroupUIID(), castOther.getGroupUIID()) - .toComparison(); + @Override + public int compareTo(Object o) { + Group castOther = (Group) o; + return new CompareToBuilder().append(this.getOrderId(), castOther.getOrderId()) + .append(this.getGroupId(), castOther.getGroupId()).append(this.getGroupName(), castOther.getGroupName()) + .append(this.getGroupUIID(), castOther.getGroupUIID()).toComparison(); } - //--------------------------------------------------------------------- + // --------------------------------------------------------------------- // Field Access Methods - //--------------------------------------------------------------------- + // --------------------------------------------------------------------- /** * Return whether the target user is in this group or not. - * @param learner the target user + * + * @param learner + * the target user * @return boolean value to indicate whether the user is in. */ - public boolean hasLearner(User learner) - { - return this.getUsers().contains(learner); + public boolean hasLearner(User learner) { + return this.getUsers().contains(learner); } /** * @see org.lamsfoundation.lams.util.Nullable#isNull() */ - public boolean isNull() - { - return false; + @Override + public boolean isNull() { + return false; } - - public GroupDTO getGroupDTO(boolean setupUserList){ - return new GroupDTO(this, setupUserList); + + public GroupDTO getGroupDTO(boolean setupUserList) { + return new GroupDTO(this, setupUserList); } - - /** May this group be deleted or a user from this group deleted? It should not be - * deleted if there are tool sessions attached */ + + /** + * May this group be deleted or a user from this group deleted? It should not be deleted if there are tool sessions + * attached + */ public boolean mayBeDeleted() { - return getToolSessions().size() == 0; + return getToolSessions().size() == 0; } - /** May this group be deleted or a user from this group deleted? It should not be - * deleted if there are tool sessions attached */ + /** + * May this group be deleted or a user from this group deleted? It should not be deleted if there are tool sessions + * attached + */ public boolean isUsedForActivity() { - return getToolSessions().size() == 0; + return getToolSessions().size() == 0; } - /** Create a copy of this group, without copying the users or tool sessions. - * Copies any group to branch mappings, updating the group but not the activity. */ + /** + * Create a copy of this group, without copying the users or tool sessions. Copies any group to branch mappings, + * updating the group but not the activity. + */ @SuppressWarnings("unchecked") - public Group createCopy(Grouping newGrouping) { - - Group newGroup = new Group(null, this.getGroupName(), this.getOrderId(), this.getGroupUIID(), - newGrouping, null, null, null); - - return newGroup; + public Group createCopy(Grouping newGrouping) { + + Group newGroup = new Group(null, this.getGroupName(), this.getOrderId(), this.getGroupUIID(), newGrouping, null, + null, null); + + return newGroup; } - /** Allocate this group to the given branch, in a branching activity. This creates the BranchActivityEntry record and adds it - * to the branchActivities set. EntryUIID will only be populated if this is called from authoring + /** + * Allocate this group to the given branch, in a branching activity. This creates the BranchActivityEntry record and + * adds it to the branchActivities set. EntryUIID will only be populated if this is called from authoring */ - public BranchActivityEntry allocateBranchToGroup(Integer entryUIID, SequenceActivity branch, BranchingActivity branchingActivity) { - BranchActivityEntry entry = new BranchActivityEntry(null, entryUIID, branch, (BranchingActivity) branchingActivity, this); - if ( getBranchActivities() == null ) { - setBranchActivities(new HashSet()); - } - getBranchActivities().add(entry); - return entry; + public BranchActivityEntry allocateBranchToGroup(Integer entryUIID, SequenceActivity branch, + BranchingActivity branchingActivity) { + BranchActivityEntry entry = new BranchActivityEntry(null, entryUIID, branch, branchingActivity, this); + if (getBranchActivities() == null) { + setBranchActivities(new HashSet()); + } + getBranchActivities().add(entry); + return entry; } - - /** - * Remove the branch with which this group is associated. - * Actually calls the SequenceActivity to do the removal as it is the SequenceActivity that has the hibernate cascade. - * So its the activity that must be saved, not the group. Method left here to make it easier to find. + + /** + * Remove the branch with which this group is associated. Actually calls the SequenceActivity to do the removal as + * it is the SequenceActivity that has the hibernate cascade. So its the activity that must be saved, not the group. + * Method left here to make it easier to find. */ public void removeGroupFromBranch(SequenceActivity branch) { - branch.removeGroupFromBranch(this); + branch.removeGroupFromBranch(this); } } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/PermissionGateActivity.java =================================================================== diff -u -rc135649b64e98c9233da20bdcfb7689598116314 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/PermissionGateActivity.java (.../PermissionGateActivity.java) (revision c135649b64e98c9233da20bdcfb7689598116314) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/PermissionGateActivity.java (.../PermissionGateActivity.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -24,7 +24,6 @@ package org.lamsfoundation.lams.learningdesign; import java.io.Serializable; -import java.util.Date; import java.util.Set; import org.apache.commons.lang.builder.ToStringBuilder; @@ -43,11 +42,11 @@ Activity parentActivity, Activity libraryActivity, Integer parentUIID, LearningDesign learningDesign, Grouping grouping, Integer activityTypeId, Transition transitionTo, Transition transitionFrom, String languageFile, Boolean stopAfterActivity, Set inputActivities, Integer gateActivityLevelId, - Set waitingLearners, SystemTool sysTool, Set branchActivityEntries) { + SystemTool sysTool, Set branchActivityEntries) { super(activityId, id, description, title, xcoord, ycoord, orderId, createDateTime, learningLibrary, parentActivity, libraryActivity, parentUIID, learningDesign, grouping, activityTypeId, transitionTo, - transitionFrom, languageFile, stopAfterActivity, inputActivities, gateActivityLevelId, waitingLearners, - sysTool, branchActivityEntries); + transitionFrom, languageFile, stopAfterActivity, inputActivities, gateActivityLevelId, sysTool, + branchActivityEntries); super.simpleActivityStrategy = new PermissionGateActivityStrategy(this); } @@ -62,9 +61,9 @@ org.lamsfoundation.lams.learningdesign.Activity parentActivity, org.lamsfoundation.lams.learningdesign.LearningDesign learningDesign, org.lamsfoundation.lams.learningdesign.Grouping grouping, Integer activityTypeId, Transition transitionTo, - Transition transitionFrom, Integer gateActivityLevelId, Set waitingLearners) { + Transition transitionFrom, Integer gateActivityLevelId) { super(activityId, createDateTime, learningLibrary, parentActivity, learningDesign, grouping, activityTypeId, - transitionTo, transitionFrom, gateActivityLevelId, waitingLearners); + transitionTo, transitionFrom, gateActivityLevelId); super.simpleActivityStrategy = new PermissionGateActivityStrategy(this); } @@ -73,6 +72,7 @@ * * @return PermissionGateActivity Returns a deep-copy of the originalActivity */ + @Override public Activity createCopy(int uiidOffset) { PermissionGateActivity newPermissionGateActivity = new PermissionGateActivity(); copyToNewActivity(newPermissionGateActivity, uiidOffset); @@ -82,13 +82,15 @@ } + @Override public String toString() { return new ToStringBuilder(this).append("activityId", getActivityId()).toString(); } /** * @see org.lamsfoundation.lams.util.Nullable#isNull() */ + @Override public boolean isNull() { return false; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ScheduleGateActivity.java =================================================================== diff -u -raead34144651a924f76d7bca8645327e6820d226 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ScheduleGateActivity.java (.../ScheduleGateActivity.java) (revision aead34144651a924f76d7bca8645327e6820d226) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ScheduleGateActivity.java (.../ScheduleGateActivity.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -80,12 +80,11 @@ Activity parentActivity, Activity libraryActivity, Integer parentUIID, LearningDesign learningDesign, Grouping grouping, Integer activityTypeId, Transition transitionTo, Transition transitionFrom, String languageFile, Boolean stopAfterActivity, Set inputActivities, Integer gateActivityLevelId, - Long gateStartTimeOffset, Long gateEndTimeOffset, Set waitingLearners, SystemTool sysTool, - Set branchActivityEntries) { + Long gateStartTimeOffset, Long gateEndTimeOffset, SystemTool sysTool, Set branchActivityEntries) { super(activityId, id, description, title, xcoord, ycoord, orderId, createDateTime, learningLibrary, parentActivity, libraryActivity, parentUIID, learningDesign, grouping, activityTypeId, transitionTo, - transitionFrom, languageFile, stopAfterActivity, inputActivities, gateActivityLevelId, waitingLearners, - sysTool, branchActivityEntries); + transitionFrom, languageFile, stopAfterActivity, inputActivities, gateActivityLevelId, sysTool, + branchActivityEntries); // validate pre-condition. if ((gateStartTimeOffset != null) && (gateEndTimeOffset != null) && (gateStartTimeOffset.intValue() > gateEndTimeOffset.intValue())) { @@ -103,16 +102,14 @@ } /** minimal constructor */ - @SuppressWarnings("rawtypes") public ScheduleGateActivity(Long activityId, java.util.Date createDateTime, org.lamsfoundation.lams.learningdesign.LearningLibrary learningLibrary, org.lamsfoundation.lams.learningdesign.Activity parentActivity, org.lamsfoundation.lams.learningdesign.LearningDesign learningDesign, org.lamsfoundation.lams.learningdesign.Grouping grouping, Integer activityTypeId, Transition transitionTo, - Transition transitionFrom, Integer gateActivityLevelId, Long gateStartTimeOffset, Long gateEndTimeOffset, - Set waitingLearners) { + Transition transitionFrom, Integer gateActivityLevelId, Long gateStartTimeOffset, Long gateEndTimeOffset) { super(activityId, createDateTime, learningLibrary, parentActivity, learningDesign, grouping, activityTypeId, - transitionTo, transitionFrom, gateActivityLevelId, waitingLearners); + transitionTo, transitionFrom, gateActivityLevelId); if ((gateStartTimeOffset != null) && (gateEndTimeOffset != null) && (gateStartTimeOffset.intValue() > gateEndTimeOffset.intValue())) { throw new IllegalStateException("End time offset must be larger" + " than start time offset"); @@ -253,12 +250,12 @@ if (isScheduledByTimeOffset()) { if (getGateStartTimeOffset().equals(getGateEndTimeOffset())) { listOfValidationErrors.add(new ValidationErrorDTO(ValidationErrorDTO.SCHEDULE_GATE_ERROR_CODE, - messageService.getMessage(ValidationErrorDTO.SCHEDULE_GATE_ERROR_TYPE1_KEY), this - .getActivityUIID())); + messageService.getMessage(ValidationErrorDTO.SCHEDULE_GATE_ERROR_TYPE1_KEY), + this.getActivityUIID())); } else if (getGateStartTimeOffset().compareTo(getGateEndTimeOffset()) > 0) { listOfValidationErrors.add(new ValidationErrorDTO(ValidationErrorDTO.SCHEDULE_GATE_ERROR_CODE, - messageService.getMessage(ValidationErrorDTO.SCHEDULE_GATE_ERROR_TYPE2_KEY), this - .getActivityUIID())); + messageService.getMessage(ValidationErrorDTO.SCHEDULE_GATE_ERROR_TYPE2_KEY), + this.getActivityUIID())); } } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java =================================================================== diff -u -rc135649b64e98c9233da20bdcfb7689598116314 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java (.../SequenceActivity.java) (revision c135649b64e98c9233da20bdcfb7689598116314) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java (.../SequenceActivity.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -46,7 +46,7 @@ private static Logger log = Logger.getLogger(SequenceActivity.class); - private Set branchEntries; + private Set branchEntries; private SystemTool systemTool; /** full constructor */ @@ -55,7 +55,8 @@ Activity parentActivity, Activity libraryActivity, Integer parentUIID, LearningDesign learningDesign, Grouping grouping, Integer activityTypeId, Transition transitionTo, Transition transitionFrom, String languageFile, Boolean stopAfterActivity, Set inputActivities, Set activities, - Activity defaultActivity, Set branchEntries, SystemTool systemTool, Set branchActivityEntries) { + Activity defaultActivity, Set branchEntries, SystemTool systemTool, + Set branchActivityEntries) { super(activityId, id, description, title, xcoord, ycoord, orderId, createDateTime, learningLibrary, parentActivity, libraryActivity, parentUIID, learningDesign, grouping, activityTypeId, transitionTo, transitionFrom, languageFile, stopAfterActivity, inputActivities, activities, defaultActivity, @@ -98,9 +99,9 @@ Iterator iter = this.getBranchEntries().iterator(); while (iter.hasNext()) { BranchActivityEntry oldEntry = (BranchActivityEntry) iter.next(); - BranchActivityEntry newEntry = new BranchActivityEntry(null, LearningDesign.addOffset( - oldEntry.getEntryUIID(), uiidOffset), newSequenceActivity, oldEntry.getBranchingActivity(), - oldEntry.getGroup()); + BranchActivityEntry newEntry = new BranchActivityEntry(null, + LearningDesign.addOffset(oldEntry.getEntryUIID(), uiidOffset), newSequenceActivity, + oldEntry.getBranchingActivity(), oldEntry.getGroup()); if (oldEntry.getCondition() != null) { BranchCondition newCondition = oldEntry.getCondition().clone(uiidOffset); newEntry.setCondition(newCondition); @@ -144,7 +145,7 @@ * @hibernate.collection-key column="sequence_activity_id" * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.learningdesign.BranchActivityEntry" */ - public Set getBranchEntries() { + public Set getBranchEntries() { return branchEntries; } @@ -202,10 +203,10 @@ public Vector validateActivity(MessageService messageService) { Vector listOfValidationErrors = new Vector(); if (getActivities() != null && getActivities().size() > 0 && getDefaultActivity() == null) { - listOfValidationErrors.add(new ValidationErrorDTO( - ValidationErrorDTO.SEQUENCE_ACTIVITY_MUST_HAVE_FIRST_ACTIVITY_ERROR_CODE, messageService - .getMessage(ValidationErrorDTO.SEQUENCE_ACTIVITY_MUST_HAVE_FIRST_ACTIVITY), this - .getActivityUIID())); + listOfValidationErrors.add( + new ValidationErrorDTO(ValidationErrorDTO.SEQUENCE_ACTIVITY_MUST_HAVE_FIRST_ACTIVITY_ERROR_CODE, + messageService.getMessage(ValidationErrorDTO.SEQUENCE_ACTIVITY_MUST_HAVE_FIRST_ACTIVITY), + this.getActivityUIID())); } return listOfValidationErrors; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/SynchGateActivity.java =================================================================== diff -u -rc135649b64e98c9233da20bdcfb7689598116314 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/SynchGateActivity.java (.../SynchGateActivity.java) (revision c135649b64e98c9233da20bdcfb7689598116314) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/SynchGateActivity.java (.../SynchGateActivity.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -24,7 +24,6 @@ package org.lamsfoundation.lams.learningdesign; import java.io.Serializable; -import java.util.Date; import java.util.Set; import org.apache.commons.lang.builder.ToStringBuilder; @@ -46,8 +45,8 @@ Integer gateActivityLevelId, Set waitingLearners, SystemTool sysTool, Set branchActivityEntries) { super(activityId, id, description, title, xcoord, ycoord, orderId, createDateTime, learningLibrary, parentActivity, libraryActivity, parentUIID, learningDesign, grouping, activityTypeId, transitionTo, - transitionFrom, languageFile, stopAfterActivity, inputActivities, gateActivityLevelId, waitingLearners, - sysTool, branchActivityEntries); + transitionFrom, languageFile, stopAfterActivity, inputActivities, gateActivityLevelId, sysTool, + branchActivityEntries); super.simpleActivityStrategy = new SynchGateActivityStrategy(this); } @@ -64,7 +63,7 @@ org.lamsfoundation.lams.learningdesign.Grouping grouping, Integer activityTypeId, Transition transitionTo, Transition transitionFrom, Integer gateActivityLevelId, Set waitingLearners) { super(activityId, createDateTime, learningLibrary, parentActivity, learningDesign, grouping, activityTypeId, - transitionTo, transitionFrom, gateActivityLevelId, waitingLearners); + transitionTo, transitionFrom, gateActivityLevelId); super.simpleActivityStrategy = new SynchGateActivityStrategy(this); } @@ -73,6 +72,7 @@ * * @return SynchGateActivity Returns a deep-copy of the originalActivity */ + @Override public Activity createCopy(int uiidOffset) { SynchGateActivity newSynchGateActivity = new SynchGateActivity(); copyToNewActivity(newSynchGateActivity, uiidOffset); @@ -81,13 +81,15 @@ return newSynchGateActivity; } + @Override public String toString() { return new ToStringBuilder(this).append("activityId", getActivityId()).toString(); } /** * @see org.lamsfoundation.lams.util.Nullable#isNull() */ + @Override public boolean isNull() { return false; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/SystemGateActivity.java =================================================================== diff -u -rc135649b64e98c9233da20bdcfb7689598116314 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/SystemGateActivity.java (.../SystemGateActivity.java) (revision c135649b64e98c9233da20bdcfb7689598116314) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/SystemGateActivity.java (.../SystemGateActivity.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -24,7 +24,6 @@ package org.lamsfoundation.lams.learningdesign; import java.io.Serializable; -import java.util.Date; import java.util.Set; import org.apache.commons.lang.builder.ToStringBuilder; @@ -43,11 +42,11 @@ Activity parentActivity, Activity libraryActivity, Integer parentUIID, LearningDesign learningDesign, Grouping grouping, Integer activityTypeId, Transition transitionTo, Transition transitionFrom, String languageFile, Boolean stopAfterActivity, Set inputActivities, Integer gateActivityLevelId, - Set waitingLearners, SystemTool sysTool, Set branchActivityEntries) { + SystemTool sysTool, Set branchActivityEntries) { super(activityId, id, description, title, xcoord, ycoord, orderId, createDateTime, learningLibrary, parentActivity, libraryActivity, parentUIID, learningDesign, grouping, activityTypeId, transitionTo, - transitionFrom, languageFile, stopAfterActivity, inputActivities, gateActivityLevelId, waitingLearners, - sysTool, branchActivityEntries); + transitionFrom, languageFile, stopAfterActivity, inputActivities, gateActivityLevelId, sysTool, + branchActivityEntries); super.simpleActivityStrategy = new SystemGateActivityStrategy(this); } @@ -62,9 +61,9 @@ org.lamsfoundation.lams.learningdesign.Activity parentActivity, org.lamsfoundation.lams.learningdesign.LearningDesign learningDesign, org.lamsfoundation.lams.learningdesign.Grouping grouping, Integer activityTypeId, Transition transitionTo, - Transition transitionFrom, Integer gateActivityLevelId, Set waitingLearners) { + Transition transitionFrom, Integer gateActivityLevelId) { super(activityId, createDateTime, learningLibrary, parentActivity, learningDesign, grouping, activityTypeId, - transitionTo, transitionFrom, gateActivityLevelId, waitingLearners); + transitionTo, transitionFrom, gateActivityLevelId); super.simpleActivityStrategy = new SystemGateActivityStrategy(this); } @@ -73,6 +72,7 @@ * * @return SystemGateActivity Returns a deep-copy of the originalActivity */ + @Override public Activity createCopy(int uiidOffset) { SystemGateActivity newSysGateActivity = new SystemGateActivity(); copyToNewActivity(newSysGateActivity, uiidOffset); @@ -81,13 +81,15 @@ return newSysGateActivity; } + @Override public String toString() { return new ToStringBuilder(this).append("activityId", getActivityId()).toString(); } /** * @see org.lamsfoundation.lams.util.Nullable#isNull() */ + @Override public boolean isNull() { return false; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java =================================================================== diff -u -r3bad0299455b529e69571b8627c4c5986cb0123c -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 3bad0299455b529e69571b8627c4c5986cb0123c) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -1789,12 +1789,10 @@ ((SynchGateActivity) act).setGateActivityLevelId(actDto.getGateActivityLevelID()); // always set false ((SynchGateActivity) act).setGateOpen(false); - ((SynchGateActivity) act).setWaitingLearners(null); ((SynchGateActivity) act).setSystemTool(systemToolDAO.getSystemToolByID(SystemTool.SYNC_GATE)); break; case Activity.SCHEDULE_GATE_ACTIVITY_TYPE: ((ScheduleGateActivity) act).setGateActivityLevelId(actDto.getGateActivityLevelID()); - ((ScheduleGateActivity) act).setWaitingLearners(null); // always set false ((ScheduleGateActivity) act).setGateOpen(false); @@ -1806,13 +1804,11 @@ case Activity.PERMISSION_GATE_ACTIVITY_TYPE: ((PermissionGateActivity) act).setGateActivityLevelId(actDto.getGateActivityLevelID()); ((PermissionGateActivity) act).setGateOpen(false); - ((PermissionGateActivity) act).setWaitingLearners(null); ((PermissionGateActivity) act).setSystemTool(systemToolDAO.getSystemToolByID(SystemTool.PERMISSION_GATE)); break; case Activity.CONDITION_GATE_ACTIVITY_TYPE: ((ConditionGateActivity) act).setGateActivityLevelId(actDto.getGateActivityLevelID()); ((ConditionGateActivity) act).setGateOpen(false); - ((ConditionGateActivity) act).setWaitingLearners(null); ((ConditionGateActivity) act).setSystemTool(systemToolDAO.getSystemToolByID(SystemTool.PERMISSION_GATE)); break; case Activity.PARALLEL_ACTIVITY_TYPE: Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ConditionGateActivityStrategy.java =================================================================== diff -u -r209087915bc219f430c282ad00e5d1e6462f9b5f -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ConditionGateActivityStrategy.java (.../ConditionGateActivityStrategy.java) (revision 209087915bc219f430c282ad00e5d1e6462f9b5f) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ConditionGateActivityStrategy.java (.../ConditionGateActivityStrategy.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -24,7 +24,6 @@ package org.lamsfoundation.lams.learningdesign.strategy; import java.util.ArrayList; -import java.util.List; import org.lamsfoundation.lams.learningdesign.ContributionTypes; import org.lamsfoundation.lams.learningdesign.GateActivity; @@ -36,28 +35,30 @@ */ public class ConditionGateActivityStrategy extends GateActivityStrategy { - public ConditionGateActivityStrategy(GateActivity gateActivity) { - super(gateActivity); - } + public ConditionGateActivityStrategy(GateActivity gateActivity) { + super(gateActivity); + } - //--------------------------------------------------------------------- - // Overriden methods - //--------------------------------------------------------------------- - /** - * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, java.util.ArrayList) - */ - @Override - protected void setUpContributionType(ArrayList contributionTypes) { - contributionTypes.add(ContributionTypes.CONDITION_GATE); - } + // --------------------------------------------------------------------- + // Overriden methods + // --------------------------------------------------------------------- + /** + * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, + * java.util.ArrayList) + */ + @Override + protected void setUpContributionType(ArrayList contributionTypes) { + contributionTypes.add(ContributionTypes.CONDITION_GATE); + } - /** - * Since the gate is open only for individuals and never for the whole class, this method returns false. - * - * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#isOpenConditionMet() - */ - @Override - protected boolean isOpenConditionMet(List lessonLearners) { - return false; - } -} + /** + * Since the gate is open only for individuals and never for the whole class, this method returns false + * . + * + * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#isOpenConditionMet() + */ + @Override + protected boolean isOpenConditionMet(int expectedLearnerCount, int waitingLearnerCount) { + return false; + } +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GateActivityStrategy.java =================================================================== diff -u -r88e98be30293b57a81d4a8a6e5cdaf5c62e97883 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GateActivityStrategy.java (.../GateActivityStrategy.java) (revision 88e98be30293b57a81d4a8a6e5cdaf5c62e97883) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GateActivityStrategy.java (.../GateActivityStrategy.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -23,87 +23,88 @@ package org.lamsfoundation.lams.learningdesign.strategy; import java.util.ArrayList; -import java.util.List; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.GateActivity; import org.lamsfoundation.lams.usermanagement.User; /** - * Activity strategy that deal with the calculation of all sub gate activities. - * It is abstract calculation layer for all concrete gate activities. + * Activity strategy that deal with the calculation of all sub gate activities. It is abstract calculation layer for all + * concrete gate activities. * * @author Jacky Fang - * @since 2005-4-6 + * @since 2005-4-6 * @version 1.1 * */ public abstract class GateActivityStrategy extends SimpleActivityStrategy { - protected GateActivity gateActivity = null; + protected GateActivity gateActivity = null; - public GateActivityStrategy(GateActivity gateActivity) { - this.gateActivity = gateActivity; - } + public GateActivityStrategy(GateActivity gateActivity) { + this.gateActivity = gateActivity; + } - //--------------------------------------------------------------------- - // Template methods - //--------------------------------------------------------------------- - /** - * Returns wether we should open the gate or close the gate. It's implementation depends on the type of the gate we - * are dealing with. Generally, it needs the check up the current gate status. If the gate is already opened, we - * will keep it open for current learner. Otherwise, we need to validate the open condition for this learner. + // --------------------------------------------------------------------- + // Template methods + // --------------------------------------------------------------------- + /** + * Returns wether we should open the gate or close the gate for the given learner. It's implementation depends on + * the type of the gate we are dealing with. Generally, it needs the check up the current gate status. If the gate + * is already opened, we will keep it open for current learner. Otherwise, we need to validate the open condition + * for this learner. * * @param learner - * the learner who just arrived at the gate. + * the learner who arrived at the gate. * @param activity * the gate activity. * @param lessonLearners * all learners who have started the lesson * @return whether we should open it or not. */ - public boolean shouldOpenGateFor(User learner, List lessonLearners) { - gateActivity.addLeaner(learner, false); + public boolean shouldOpenGateFor(User learner, int expectedLearnerCount, int waitingLearnerCount) { + boolean isOpen = gateActivity.getGateOpen(); - boolean isOpen = gateActivity.getGateOpen().booleanValue(); - - if (!isOpen) { - if (isOpenConditionMet(lessonLearners)) { - gateActivity.setGateOpen(new Boolean(true)); - } else { - return gateActivity.getAllowedToPassLearners().contains(learner); + if (isOpen) { + if (!gateActivity.getAllowedToPassLearners().isEmpty()) { + gateActivity.getAllowedToPassLearners().clear(); } + return true; + } else if (isOpenConditionMet(expectedLearnerCount, waitingLearnerCount)) { + gateActivity.setGateOpen(true); + if (!gateActivity.getAllowedToPassLearners().isEmpty()) { + gateActivity.getAllowedToPassLearners().clear(); + } + return true; + } else { + return gateActivity.getAllowedToPassLearners().contains(learner); } - - gateActivity.getAllGateUsers().clear(); - gateActivity.getWaitingLearners().clear(); - gateActivity.getAllowedToPassLearners().clear(); - return isOpen; } // --------------------------------------------------------------------- - // Abstract methods - //--------------------------------------------------------------------- - /** - * Check up the open condition according the gate type. - * @return return true if the condition is met. - */ - protected abstract boolean isOpenConditionMet(List lessonLearners); + // Abstract methods + // --------------------------------------------------------------------- + /** + * Check up the open condition according the gate type. + * + * @return return true if the condition is met. + */ + protected abstract boolean isOpenConditionMet(int expectedLearnerCount, int waitingLearnerCount); - //--------------------------------------------------------------------- - // Overidden methods - //--------------------------------------------------------------------- - /** - * @see org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, java.util.ArrayList) - */ - @Override - protected abstract void setUpContributionType(ArrayList contributionTypes); + // --------------------------------------------------------------------- + // Overidden methods + // --------------------------------------------------------------------- + /** + * @see org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, + * java.util.ArrayList) + */ + @Override + protected abstract void setUpContributionType(ArrayList contributionTypes); - /** - * Get the activity for this strategy. The activity should be set - * when the strategy is created. - */ - @Override - protected Activity getActivity() { - return gateActivity; - } + /** + * Get the activity for this strategy. The activity should be set when the strategy is created. + */ + @Override + protected Activity getActivity() { + return gateActivity; + } } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/PermissionGateActivityStrategy.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/PermissionGateActivityStrategy.java (.../PermissionGateActivityStrategy.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/PermissionGateActivityStrategy.java (.../PermissionGateActivityStrategy.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -24,50 +24,44 @@ package org.lamsfoundation.lams.learningdesign.strategy; import java.util.ArrayList; -import java.util.List; import org.lamsfoundation.lams.learningdesign.ContributionTypes; import org.lamsfoundation.lams.learningdesign.GateActivity; /** - * Activity strategy that deals with the calculation specific to gate activity. - * The major part of this strategy will be overiding the methods that defined - * in the abstract level. + * Activity strategy that deals with the calculation specific to gate activity. The major part of this strategy will be + * overiding the methods that defined in the abstract level. * * @author Jacky Fang * @author Minhas * @version 1.1 */ public class PermissionGateActivityStrategy extends GateActivityStrategy { - - public PermissionGateActivityStrategy(GateActivity gateActivity) { - super(gateActivity); - } - //--------------------------------------------------------------------- + + public PermissionGateActivityStrategy(GateActivity gateActivity) { + super(gateActivity); + } + + // --------------------------------------------------------------------- // Overriden methods - //--------------------------------------------------------------------- + // --------------------------------------------------------------------- /** - * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, java.util.ArrayList) + * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, + * java.util.ArrayList) */ - protected void setUpContributionType(ArrayList contributionTypes) - { - contributionTypes.add(ContributionTypes.PERMISSION_GATE); + @Override + protected void setUpContributionType(ArrayList contributionTypes) { + contributionTypes.add(ContributionTypes.PERMISSION_GATE); } /** - * Regarding permission gate, we don't validate the open condition for the - * learner because the decision of opening the gate or not comes from the - * teacher. The teacher may open or close the gate at monitoring interface. + * Regarding permission gate, we don't validate the open condition for the learner because the decision of opening + * the gate or not comes from the teacher. The teacher may open or close the gate at monitoring interface. * * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#isOpenConditionMet() */ - protected boolean isOpenConditionMet(List lessonLearners) - { - if ( gateActivity != null ) { - return gateActivity.getGateOpen().booleanValue(); - } - return true; - + @Override + protected boolean isOpenConditionMet(int expectedLearnerCount, int waitingLearnerCount) { + return false; } - -} +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ScheduleGateActivityStrategy.java =================================================================== diff -u -r88e98be30293b57a81d4a8a6e5cdaf5c62e97883 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ScheduleGateActivityStrategy.java (.../ScheduleGateActivityStrategy.java) (revision 88e98be30293b57a81d4a8a6e5cdaf5c62e97883) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ScheduleGateActivityStrategy.java (.../ScheduleGateActivityStrategy.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -23,12 +23,8 @@ package org.lamsfoundation.lams.learningdesign.strategy; import java.util.ArrayList; -import java.util.Calendar; import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; import java.util.Set; -import java.util.TimeZone; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.ContributionTypes; @@ -73,29 +69,26 @@ * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#isOpenConditionMet() */ @Override - protected boolean isOpenConditionMet(List lessonLearners) { - if (gateActivity != null) { - return gateActivity.getGateOpen().booleanValue(); - } - return true; + protected boolean isOpenConditionMet(int expectedLearnerCount, int waitingLearnerCount) { + return false; } - @SuppressWarnings({ "rawtypes" }) @Override - public boolean shouldOpenGateFor(User learner, List lessonLearners) { + public boolean shouldOpenGateFor(User learner, int expectedLearnerCount, int waitingLearnerCount) { ScheduleGateActivity scheduleGate = (ScheduleGateActivity) gateActivity; if (Boolean.TRUE.equals((scheduleGate.getGateActivityCompletionBased()))) { - Date previousActivityCompletionTime = getPreviousActivityCompletionDate(scheduleGate, learner); + Date previousActivityCompletionTime = ScheduleGateActivityStrategy + .getPreviousActivityCompletionDate(scheduleGate, learner); if (previousActivityCompletionTime != null) { Date openTime = scheduleGate.getGateOpenTime(previousActivityCompletionTime); if (openTime.compareTo(new Date()) <= 0) { - gateActivity.addLeaner(learner, true); + gateActivity.getAllowedToPassLearners().add(learner); return true; } } return false; } - return super.shouldOpenGateFor(learner, lessonLearners); + return super.shouldOpenGateFor(learner, expectedLearnerCount, waitingLearnerCount); } @SuppressWarnings({ "unchecked" }) @@ -111,4 +104,4 @@ } return null; } -} +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SynchGateActivityStrategy.java =================================================================== diff -u -rb7f7602861fe7878357b23f98b48ed5807b5b1d7 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SynchGateActivityStrategy.java (.../SynchGateActivityStrategy.java) (revision b7f7602861fe7878357b23f98b48ed5807b5b1d7) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SynchGateActivityStrategy.java (.../SynchGateActivityStrategy.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -23,65 +23,44 @@ package org.lamsfoundation.lams.learningdesign.strategy; import java.util.ArrayList; -import java.util.List; import org.lamsfoundation.lams.learningdesign.ContributionTypes; import org.lamsfoundation.lams.learningdesign.GateActivity; - /** - * Activity strategy that deals with the calculation specific to schedule gate - * activity. The major part of this strategy will be overiding the methods that - * defined in the abstract level. + * Activity strategy that deals with the calculation specific to schedule gate activity. The major part of this strategy + * will be overiding the methods that defined in the abstract level. * * @author Jacky Fang * @author Fiona Malikoff */ -public class SynchGateActivityStrategy extends GateActivityStrategy -{ - private static final int MINIMUM_NUMBER_OF_LEARNERS = 2; - - public SynchGateActivityStrategy(GateActivity gateActivity) { - super(gateActivity); - } +public class SynchGateActivityStrategy extends GateActivityStrategy { + public SynchGateActivityStrategy(GateActivity gateActivity) { + super(gateActivity); + } - //--------------------------------------------------------------------- + // --------------------------------------------------------------------- // Overriden methods - //--------------------------------------------------------------------- + // --------------------------------------------------------------------- /** - *

Check up the waiting learners list and lesson learner list. If all - * lesson learner appears in the waiting list, we assume the open condition - * for the sync gate is met. A minimum no. of learners must also be waiting at - * the gate to prevent one from racing through it before others have even started - * (LDEV-1773).

- * - *

Given that the list of lessonLearners is everyone who has started - * the lesson, we can assume that # waiting is less than or equal to # in lesson. - * So if the two sets have some number of users, then open the gate. Small - * chance that the two sets won't match due to a bug elsewhere but not - * worth testing for here

. + *

+ * Check up the waiting learners list and lesson learner list. If all lesson learner appears in the waiting list, we + * assume the open condition for the sync gate is met. + *

* * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#isOpenConditionMet() */ - protected boolean isOpenConditionMet(List lessonLearners) - { - int numWaiting = gateActivity.getWaitingLearners().size(); - if ( gateActivity != null ) { - int numLesson = lessonLearners!=null?lessonLearners.size():0; - if ( numWaiting < numLesson ) { - return false; - } - } - return (numWaiting >= MINIMUM_NUMBER_OF_LEARNERS ? true : false); + @Override + protected boolean isOpenConditionMet(int expectedLearnerCount, int waitingLearnerCount) { + return waitingLearnerCount >= expectedLearnerCount; } - + /** - * @see org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, java.util.ArrayList) + * @see org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, + * java.util.ArrayList) */ - protected void setUpContributionType(ArrayList contributionTypes) - { - contributionTypes.add(ContributionTypes.SYNC_GATE); + @Override + protected void setUpContributionType(ArrayList contributionTypes) { + contributionTypes.add(ContributionTypes.SYNC_GATE); } - - -} +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SystemGateActivityStrategy.java =================================================================== diff -u -r9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SystemGateActivityStrategy.java (.../SystemGateActivityStrategy.java) (revision 9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SystemGateActivityStrategy.java (.../SystemGateActivityStrategy.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -24,50 +24,44 @@ package org.lamsfoundation.lams.learningdesign.strategy; import java.util.ArrayList; -import java.util.List; import org.lamsfoundation.lams.learningdesign.ContributionTypes; import org.lamsfoundation.lams.learningdesign.GateActivity; /** - * Activity strategy that deals with the calculation specific to gate activity. - * The major part of this strategy will be overiding the methods that defined - * in the abstract level. + * Activity strategy that deals with the calculation specific to gate activity. The major part of this strategy will be + * overiding the methods that defined in the abstract level. * * @author Jacky Fang * @author Minhas * @version 1.1 */ public class SystemGateActivityStrategy extends GateActivityStrategy { - - public SystemGateActivityStrategy(GateActivity gateActivity) { - super(gateActivity); - } - //--------------------------------------------------------------------- + + public SystemGateActivityStrategy(GateActivity gateActivity) { + super(gateActivity); + } + + // --------------------------------------------------------------------- // Overriden methods - //--------------------------------------------------------------------- + // --------------------------------------------------------------------- /** - * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, java.util.ArrayList) + * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, + * java.util.ArrayList) */ - protected void setUpContributionType(ArrayList contributionTypes) - { - contributionTypes.add(ContributionTypes.SYSTEM_GATE); + @Override + protected void setUpContributionType(ArrayList contributionTypes) { + contributionTypes.add(ContributionTypes.SYSTEM_GATE); } /** - * Regarding permission gate, we don't validate the open condition for the - * learner because the decision of opening the gate or not comes from the - * teacher. The teacher may open or close the gate at monitoring interface. + * Regarding permission gate, we don't validate the open condition for the learner because the decision of opening + * the gate or not comes from the teacher. The teacher may open or close the gate at monitoring interface. * * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#isOpenConditionMet() */ - protected boolean isOpenConditionMet(List lessonLearners) - { - if ( gateActivity != null ) { - return gateActivity.getGateOpen().booleanValue(); - } - return true; - + @Override + protected boolean isOpenConditionMet(int expectedLearnerCount, int waitingLearnerCount) { + return false; } - -} +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILearnerProgressDAO.java =================================================================== diff -u -r2f67a20e73128f03e7b4221ca09426c14bef2abf -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILearnerProgressDAO.java (.../ILearnerProgressDAO.java) (revision 2f67a20e73128f03e7b4221ca09426c14bef2abf) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILearnerProgressDAO.java (.../ILearnerProgressDAO.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -143,13 +143,19 @@ List getLearnerProgressForLessons(List lessonIds); /** - * Get all the users records where the user has attempted the given activity. Uses the progress records to determine - * the users. + * Get all the users records where the user has attempted the given activity, but has not completed it yet. Uses the + * progress records to determine the users. + */ + List getLearnersAttemptedActivity(Activity activity); + + /** + * Get all the users records where the user has ever attempted the given activity. Uses the progress records to + * determine the users. * * @param activityId * @return List */ - List getLearnersHaveAttemptedActivity(Activity activity); + List getLearnersAttemptedOrCompletedActivity(Activity activity); /** * Count of the number of users that have attempted or completed an activity. Useful for activities that don't have Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java =================================================================== diff -u -r2f67a20e73128f03e7b4221ca09426c14bef2abf -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java (.../ILessonDAO.java) (revision 2f67a20e73128f03e7b4221ca09426c14bef2abf) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java (.../ILessonDAO.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -124,17 +124,6 @@ List getActiveLearnerByLesson(long lessonId); /** - * Returns the all the learners that have started the requested lesson and are in the given group. - * - * @param lessonId - * the id of the requested lesson. - * @param groupId - * the id of the requested group. - * @return the list of learners. - */ - List getActiveLearnerByLessonAndGroup(long lessonId, long groupId); - - /** * Returns the count of all the learners that have started the requested lesson. * * @param lessonId Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LearnerProgressDAO.java =================================================================== diff -u -r2f67a20e73128f03e7b4221ca09426c14bef2abf -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LearnerProgressDAO.java (.../LearnerProgressDAO.java) (revision 2f67a20e73128f03e7b4221ca09426c14bef2abf) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LearnerProgressDAO.java (.../LearnerProgressDAO.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -55,6 +55,12 @@ private final static String LOAD_LEARNERS_LATEST_COMPLETED_BY_LESSON = "SELECT p.user FROM LearnerProgress p WHERE " + "p.lessonComplete > 0 and p.lesson.id = :lessonId ORDER BY p.finishDate DESC"; + private final static String LOAD_LEARNERS_ATTEMPTED_ACTIVITY = "SELECT prog.user FROM LearnerProgress prog, " + + " Activity act join prog.attemptedActivities attAct where act.id = :activityId and index(attAct) = act"; + + private final static String LOAD_LEARNERS_COMPLETED_ACTIVITY = "SELECT prog.user FROM LearnerProgress prog, " + + " Activity act join prog.completedActivities compAct where act.id = :activityId and index(compAct) = act"; + private final static String COUNT_COMPLETED_PROGRESS_BY_LESSON = "select count(*) from LearnerProgress p " + " where p.lessonComplete > 0 and p.lesson.id = :lessonId"; @@ -243,14 +249,25 @@ @Override @SuppressWarnings("unchecked") - public List getLearnersHaveAttemptedActivity(Activity activity) { - List learners = getSession().getNamedQuery("usersAttemptedActivity") + public List getLearnersAttemptedOrCompletedActivity(Activity activity) { + List users = getSession().createQuery(LearnerProgressDAO.LOAD_LEARNERS_ATTEMPTED_ACTIVITY) .setLong("activityId", activity.getActivityId().longValue()).list(); + users.addAll(getSession().createQuery(LearnerProgressDAO.LOAD_LEARNERS_COMPLETED_ACTIVITY) + .setLong("activityId", activity.getActivityId().longValue()).list()); - return learners; + return users; } @Override + @SuppressWarnings("unchecked") + public List getLearnersAttemptedActivity(Activity activity) { + List users = getSession().createQuery(LearnerProgressDAO.LOAD_LEARNERS_ATTEMPTED_ACTIVITY) + .setLong("activityId", activity.getActivityId().longValue()).list(); + + return users; + } + + @Override public Integer getNumUsersAttemptedActivity(Activity activity) { Object value = getSession().createQuery(LearnerProgressDAO.COUNT_ATTEMPTED_ACTIVITY) .setLong("activityId", activity.getActivityId().longValue()).uniqueResult(); Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java =================================================================== diff -u -r2f67a20e73128f03e7b4221ca09426c14bef2abf -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java (.../LessonDAO.java) (revision 2f67a20e73128f03e7b4221ca09426c14bef2abf) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java (.../LessonDAO.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -146,18 +146,6 @@ } /** - * @see org.lamsfoundation.lams.lesson.dao.ILessonDAO#getActiveLearnerByLessonAndGroup(long, long) - */ - @Override - public List getActiveLearnerByLessonAndGroup(long lessonId, long groupId) { - Query query = getSession().getNamedQuery("activeLearnersByGroup"); - query.setLong("lessonId", lessonId); - query.setLong("groupId", groupId); - List result = query.list(); - return result; - } - - /** * @see org.lamsfoundation.lams.lesson.dao.ILessonDAO#getActiveLearnerByLesson(long) Note: Hibernate 3.1 * query.uniqueResult() returns Integer, Hibernate 3.2 query.uniqueResult() returns Long */ Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java =================================================================== diff -u -r2f67a20e73128f03e7b4221ca09426c14bef2abf -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision 2f67a20e73128f03e7b4221ca09426c14bef2abf) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -65,11 +65,6 @@ List getActiveLessonLearners(Long lessonId); /** - * Get all the learners who have started the lesson and are part of a given group. They may not be currently online. - */ - List getActiveLessonLearnersByGroup(Long lessonId, Long groupId); - - /** * Get the count of all the learners who have started the lesson. They may not be currently online. */ Integer getCountActiveLessonLearners(Long lessonId); @@ -324,7 +319,7 @@ * give the users in all tool sessions for an activity (if it is a tool activity) or it will give all the users who * have attempted an activity that doesn't have any tool sessions, i.e. system activities such as branching. */ - List getLearnersHaveAttemptedActivity(Activity activity) throws LessonServiceException; + List getLearnersAttemptedOrCompletedActivity(Activity activity) throws LessonServiceException; /** * Gets the count of the users who have attempted an activity. This is based on the progress engine records. This Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java =================================================================== diff -u -r2f67a20e73128f03e7b4221ca09426c14bef2abf -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision 2f67a20e73128f03e7b4221ca09426c14bef2abf) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -112,11 +112,6 @@ } @Override - public List getActiveLessonLearnersByGroup(Long lessonId, Long groupId) { - return lessonDAO.getActiveLearnerByLessonAndGroup(lessonId, groupId); - } - - @Override public Integer getCountActiveLessonLearners(Long lessonId) { return lessonDAO.getCountActiveLearnerByLesson(lessonId); } @@ -571,8 +566,8 @@ } @Override - public List getLearnersHaveAttemptedActivity(Activity activity) throws LessonServiceException { - return learnerProgressDAO.getLearnersHaveAttemptedActivity(activity); + public List getLearnersAttemptedOrCompletedActivity(Activity activity) throws LessonServiceException { + return learnerProgressDAO.getLearnersAttemptedOrCompletedActivity(activity); } @Override Index: lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java (.../LamsCoreToolService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java (.../LamsCoreToolService.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -34,7 +34,6 @@ import org.lamsfoundation.lams.learningdesign.ActivityEvaluation; import org.lamsfoundation.lams.learningdesign.ComplexActivity; import org.lamsfoundation.lams.learningdesign.GateActivity; -import org.lamsfoundation.lams.learningdesign.GateUser; import org.lamsfoundation.lams.learningdesign.Group; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.GroupingActivity; @@ -291,11 +290,10 @@ } } else if (activity.isGateActivity()) { GateActivity gateActivity = (GateActivity) activity; - Iterator gateUserIterator = gateActivity.getAllGateUsers().iterator(); + Iterator gateUserIterator = gateActivity.getAllowedToPassLearners().iterator(); boolean removed = false; while (gateUserIterator.hasNext()) { - User user = gateUserIterator.next().getUser(); - // there can be more than one entry (why?!), so do not "break" + User user = gateUserIterator.next(); if (learner.getUserId().equals(user.getUserId())) { removed = true; gateUserIterator.remove(); @@ -325,9 +323,9 @@ return false; } else if (activity.isGateActivity()) { GateActivity gateActivity = (GateActivity) activity; - return !gateActivity.getAllGateUsers().isEmpty(); + return !gateActivity.getAllowedToPassLearners().isEmpty(); } - + // just check the flag return isActivityReadOnlyFlag(activity); } Index: lams_learning/conf/xdoclet/struts-forms.xml =================================================================== diff -u -r88e98be30293b57a81d4a8a6e5cdaf5c62e97883 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_learning/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision 88e98be30293b57a81d4a8a6e5cdaf5c62e97883) +++ lams_learning/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -8,7 +8,7 @@ - + Index: lams_learning/src/java/org/lamsfoundation/lams/learning/service/ICoreLearnerService.java =================================================================== diff -u -r6f762597a7a0333d56b1e5d6e802333af681df31 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_learning/src/java/org/lamsfoundation/lams/learning/service/ICoreLearnerService.java (.../ICoreLearnerService.java) (revision 6f762597a7a0333d56b1e5d6e802333af681df31) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/service/ICoreLearnerService.java (.../ICoreLearnerService.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -25,11 +25,13 @@ package org.lamsfoundation.lams.learning.service; import java.util.List; +import java.util.Set; import org.lamsfoundation.lams.learning.web.bean.GateActivityDTO; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.BranchingActivity; import org.lamsfoundation.lams.learningdesign.GateActivity; +import org.lamsfoundation.lams.learningdesign.Group; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.SequenceActivity; import org.lamsfoundation.lams.lesson.LearnerProgress; @@ -234,15 +236,6 @@ public Activity getActivity(Long activityId); /** - * Returns all the active learners by the lesson id. - * - * @param lessonId - * the requested lesson id. - * @return the list of learners. - */ - public List getActiveLearnersByLesson(long lessonId); - - /** * Perform grouping for the learners who have started the lesson, based on the grouping activity. * * @param lessonId @@ -319,16 +312,8 @@ */ public GateActivityDTO knockGate(GateActivity gateActivity, User knocker, boolean forceGate); - /** - * Get all the learners who may come through this gate. For a Group Based branch and the Teacher Grouped branch, it - * is the group of users in the Branch's group, but only the learners who have started the lesson. Otherwise we just - * get all learners who have started the lesson. - * - * @param gate - * activity - * @return List of User - */ - public List getLearnersForGate(GateActivity gate); + + public Set getGroupsForGate(GateActivity gate); /** * Get the learner url for a particular activity. Index: lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java =================================================================== diff -u -r8cb13884a046af1fee45dc7ab6e6f5a7f21c07c9 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java (.../LearnerService.java) (revision 8cb13884a046af1fee45dc7ab6e6f5a7f21c07c9) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java (.../LearnerService.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -29,6 +29,7 @@ import java.util.Calendar; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -823,8 +824,8 @@ Lesson lesson = getLesson(lessonId); int learnerCount = lesson.getAllLearners().size(); int groupCount = grouping.getGroups().size(); - maxNumberOfLearnersPerGroup = learnerCount / groupCount - + (learnerCount % groupCount == 0 ? 0 : 1); + maxNumberOfLearnersPerGroup = (learnerCount / groupCount) + + ((learnerCount % groupCount) == 0 ? 0 : 1); } } } else { @@ -900,21 +901,31 @@ */ @Override public GateActivityDTO knockGate(GateActivity gate, User knocker, boolean forceGate) { - Lesson lesson = getLessonByActivity(gate); - List lessonLearners = getLearnersForGate(gate, lesson); - boolean gateOpen = false; if (forceGate) { + Lesson lesson = getLessonByActivity(gate); if (lesson.isPreviewLesson()) { // special case for preview - if forceGate is true then brute force open the gate - gateOpen = gate.forceGateOpen(); + gate.setGateOpen(true); + gateOpen = true; } } + Integer expectedLearnerCount = null; + Integer waitingLearnerCount = null; + if (!gateOpen) { + waitingLearnerCount = learnerProgressDAO.getNumUsersAttemptedActivity(gate); + + expectedLearnerCount = 0; + Set learnerGroups = getGroupsForGate(gate); + for (Group learnerGroup : learnerGroups) { + expectedLearnerCount += learnerGroup.getUsers().size(); + } + // normal case - knock the gate. - gateOpen = gate.shouldOpenGateFor(knocker, lessonLearners); + gateOpen = gate.shouldOpenGateFor(knocker, expectedLearnerCount, waitingLearnerCount); if (!gateOpen) { // only for a condition gate gateOpen = determineConditionGateStatus(gate, knocker); @@ -924,21 +935,18 @@ // update gate including updating the waiting list and gate status in // the database. activityDAO.update(gate); - return new GateActivityDTO(gate, lessonLearners, gateOpen); + return new GateActivityDTO(gate, expectedLearnerCount, waitingLearnerCount, gateOpen); } /** - * Get all the learners who may come through this gate. For a Group Based branch and the Teacher Grouped branch, it - * is the group of users in the Branch's group, but only the learners who have started the lesson. Otherwise we just - * get all learners who have started the lesson. - * - * @param gate - * @param lesson - * @return List of User + * Get all the groups of learners who may come through this gate. For a Group Based branch and the Teacher Grouped + * branch, it is the group of users in the Branch's group. Otherwise we just get all learners in the lesson. */ - private List getLearnersForGate(GateActivity gate, Lesson lesson) { + @Override + public Set getGroupsForGate(GateActivity gate) { + Lesson lesson = getLessonByActivity(gate); + Set result = new HashSet(); - List lessonLearners = null; Activity branchActivity = gate.getParentBranch(); while ((branchActivity != null) && !(branchActivity.getParentActivity().isChosenBranchingActivity() || branchActivity.getParentActivity().isGroupBranchingActivity())) { @@ -949,34 +957,17 @@ // set up list based on branch - all members of a group attached to the branch are destined for the gate SequenceActivity branchSequence = (SequenceActivity) activityDAO .getActivityByActivityId(branchActivity.getActivityId(), SequenceActivity.class); - Set branchEntries = branchSequence.getBranchEntries(); - Iterator entryIterator = branchEntries.iterator(); - while (entryIterator.hasNext()) { - BranchActivityEntry branchActivityEntry = (BranchActivityEntry) entryIterator.next(); + for (BranchActivityEntry branchActivityEntry : branchSequence.getBranchEntries()) { Group group = branchActivityEntry.getGroup(); if (group != null) { - List groupLearners = lessonService.getActiveLessonLearnersByGroup(lesson.getLessonId(), - group.getGroupId()); - if (lessonLearners == null) { - lessonLearners = groupLearners; - } else { - lessonLearners.addAll(groupLearners); - } + result.add(group); } } - } else { - lessonLearners = getActiveLearnersByLesson(lesson.getLessonId()); + result.add(lesson.getLessonClass().getLearnersGroup()); } - return lessonLearners; - } - /** - * @see org.lamsfoundation.lams.learning.service.ICoreLearnerService#getWaitingGateLearners(org.lamsfoundation.lams.learningdesign.GateActivity) - */ - @Override - public List getLearnersForGate(GateActivity gate) { - return getLearnersForGate(gate, getLessonByActivity(gate)); + return result; } /** @@ -992,14 +983,6 @@ } /** - * @see org.lamsfoundation.lams.learning.service.ICoreLearnerService#getActiveLearnersByLesson(long) - */ - @Override - public List getActiveLearnersByLesson(long lessonId) { - return lessonService.getActiveLessonLearners(lessonId); - } - - /** * Get the lesson for this activity. If the activity is not part of a lesson (ie is from an authoring design then it * will return null. */ @@ -1247,15 +1230,10 @@ if (toolSession != null) { - Set branchEntries = conditionGate.getBranchActivityEntries(); - // Go through each condition until we find one that passes and that opens the gate. // Cache the tool output so that we aren't calling it over an over again. Map toolOutputMap = new HashMap(); - Iterator entryIterator = branchEntries.iterator(); - - while (entryIterator.hasNext()) { - BranchActivityEntry entry = entryIterator.next(); + for (BranchActivityEntry entry : conditionGate.getBranchActivityEntries()) { BranchCondition condition = entry.getCondition(); String conditionName = condition.getName(); ToolOutput toolOutput = toolOutputMap.get(conditionName); @@ -1277,7 +1255,7 @@ // save the learner to the "allowed to pass" list so we don't check the conditions over and // over // again (maybe we should??) - conditionGate.addLeaner(learner, true); + conditionGate.getAllowedToPassLearners().add(learner); } break; } @@ -1407,12 +1385,12 @@ groupingDAO.update(grouping); } if (learnerChoiceGrouping.getEqualNumberOfLearnersPerGroup()) { - maxNumberOfLearnersPerGroup = learnerCount / groupCount + (learnerCount % groupCount == 0 ? 0 : 1); + maxNumberOfLearnersPerGroup = (learnerCount / groupCount) + ((learnerCount % groupCount) == 0 ? 0 : 1); } } else { maxNumberOfLearnersPerGroup = learnerChoiceGrouping.getLearnersPerGroup(); - int desiredGroupCount = learnerCount / maxNumberOfLearnersPerGroup - + (learnerCount % maxNumberOfLearnersPerGroup == 0 ? 0 : 1); + int desiredGroupCount = (learnerCount / maxNumberOfLearnersPerGroup) + + ((learnerCount % maxNumberOfLearnersPerGroup) == 0 ? 0 : 1); if (desiredGroupCount > groupCount) { ((LearnerChoiceGrouper) grouping.getGrouper()).createGroups(learnerChoiceGrouping, desiredGroupCount - groupCount); @@ -1513,7 +1491,8 @@ } } - isLast = completedSubactivities == parentOptionsActivity.getMaxNumberOfOptionsNotNull() - 1; + isLast = completedSubactivities == (parentOptionsActivity.getMaxNumberOfOptionsNotNull() + - 1); } } } else if (parentActivity.isBranchingActivity() || parentActivity.isParallelActivity()) { Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/GateAction.java =================================================================== diff -u -raead34144651a924f76d7bca8645327e6820d226 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/GateAction.java (.../GateAction.java) (revision aead34144651a924f76d7bca8645327e6820d226) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/GateAction.java (.../GateAction.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -45,6 +45,7 @@ import org.lamsfoundation.lams.learning.web.util.ActivityMapping; import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.GateActivity; import org.lamsfoundation.lams.learningdesign.ScheduleGateActivity; import org.lamsfoundation.lams.learningdesign.strategy.ScheduleGateActivityStrategy; import org.lamsfoundation.lams.lesson.LearnerProgress; @@ -75,7 +76,7 @@ * @since 2005-4-7 * @version 1.1 * - * ----------------XDoclet Tags-------------------- + * ----------------XDoclet Tags-------------------- * * @struts:action name="GateForm" path="/gate" parameter="method" validate="false" * @@ -139,23 +140,23 @@ if (activity != null) { // knock the gate - GateActivityDTO gate = learnerService.knockGate(activityId, learner, forceGate); + GateActivityDTO gateDTO = learnerService.knockGate(activityId, learner, forceGate); - if (gate == null) { + if (gateDTO == null) { throw new LearnerServiceException("Gate missing. gate id [" + activityId + "]"); } // if the gate is closed, ask the learner to wait ( updating the cached learner progress on the way ) - if (!gate.getAllowToPass()) { - ActionForward forward = findViewByGateType(mapping, (DynaActionForm) form, gate, lesson); + if (!gateDTO.getAllowToPass()) { + ActionForward forward = findViewByGateType(mapping, (DynaActionForm) form, gateDTO, lesson); LearningWebUtil.setupProgressInRequest((DynaActionForm) form, request, learnerProgress); return forward; } } // gate is open, so let the learner go to the next activity ( updating the cached learner progress on the way ) - return LearningWebUtil.completeActivity(request, response, actionMappings, learnerProgress, activity, learner - .getUserId(), learnerService, true); + return LearningWebUtil.completeActivity(request, response, actionMappings, learnerProgress, activity, + learner.getUserId(), learnerService, true); } @@ -166,40 +167,41 @@ * Dispatch view the according to the gate type. * * @param mapping - * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to - * send the end-user. + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to send + * the end-user. * @param gateForm - * The ActionForm class that will contain any data submitted by the end-user via a form. + * The ActionForm class that will contain any data submitted by the end-user via a form. * @param permissionGate - * the gate activity object + * the gate activity object * @param totalNumActiveLearners - * total number of active learners in the lesson (may not all be logged in) + * total number of active learners in the lesson (may not all be logged in) * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go * next. */ - private ActionForward findViewByGateType(ActionMapping mapping, DynaActionForm gateForm, GateActivityDTO gate, + private ActionForward findViewByGateType(ActionMapping mapping, DynaActionForm gateForm, GateActivityDTO gateDTO, Lesson lesson) { - gateForm.set("totalLearners", new Integer(gate.getExpectedLearners().size())); - gateForm.set("waitingLearners", new Integer(gate.getWaitingLearners().size())); + gateForm.set("totalLearners", gateDTO.getExpectedLearnerCount()); + gateForm.set("waitingLearners", gateDTO.getWaitingLearnerCount()); gateForm.set("previewLesson", lesson.isPreviewLesson()); gateForm.set("monitorCanOpenGate", true); + GateActivity gate = gateDTO.getGate(); gateForm.set(AttributeNames.PARAM_ACTIVITY_ID, gate.getActivityId()); gateForm.set(AttributeNames.PARAM_LESSON_ID, lesson.getLessonId()); gateForm.set("gate", gate); if (gate.isSynchGate()) { return mapping.findForward(GateAction.VIEW_SYNCH_GATE); } else if (gate.isScheduleGate()) { - ScheduleGateActivity scheduleGate = (ScheduleGateActivity) gate.getGateActivity(); + ScheduleGateActivity scheduleGate = (ScheduleGateActivity) gate; if (Boolean.TRUE.equals(scheduleGate.getGateActivityCompletionBased())) { // so it is in seconds gateForm.set("startOffset", scheduleGate.getGateStartTimeOffset() * 60); - - ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet() - .getServletContext()); + + ICoreLearnerService learnerService = LearnerServiceProxy + .getLearnerService(getServlet().getServletContext()); User learner = LearningWebUtil.getUser(learnerService); Date reachTime = ScheduleGateActivityStrategy.getPreviousActivityCompletionDate(scheduleGate, learner); gateForm.set("reachDate", reachTime); - + Calendar startingTime = new GregorianCalendar(TimeZone.getDefault()); startingTime.setTime(reachTime); startingTime.add(Calendar.MINUTE, scheduleGate.getGateStartTimeOffset().intValue()); @@ -228,5 +230,4 @@ + "] - the type [" + gate.getActivityTypeId() + "] is not a gate type"); } } - -} +} \ No newline at end of file Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/bean/GateActivityDTO.java =================================================================== diff -u -rc135649b64e98c9233da20bdcfb7689598116314 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/bean/GateActivityDTO.java (.../GateActivityDTO.java) (revision c135649b64e98c9233da20bdcfb7689598116314) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/bean/GateActivityDTO.java (.../GateActivityDTO.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -23,275 +23,43 @@ /* $Id$ */ package org.lamsfoundation.lams.learning.web.bean; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Set; - -import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.GateActivity; -import org.lamsfoundation.lams.learningdesign.Group; -import org.lamsfoundation.lams.learningdesign.Grouping; -import org.lamsfoundation.lams.learningdesign.LearningDesign; -import org.lamsfoundation.lams.learningdesign.LearningLibrary; -import org.lamsfoundation.lams.learningdesign.Transition; -import org.lamsfoundation.lams.learningdesign.dto.AuthoringActivityDTO; -import org.lamsfoundation.lams.learningdesign.dto.BranchActivityEntryDTO; -import org.lamsfoundation.lams.learningdesign.dto.LibraryActivityDTO; -import org.lamsfoundation.lams.learningdesign.dto.ProgressActivityDTO; -import org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy; -import org.lamsfoundation.lams.tool.SystemTool; -import org.lamsfoundation.lams.usermanagement.User; /** - * DTO wrapping a normal Gate Activity class, with an extra "calculated" field added for the learning module's gate screen. + * DTO wrapping a normal Gate Activity class, with an extra "calculated" field added for the learning module's gate + * screen. * */ public class GateActivityDTO { + private GateActivity gate; - private List expectedLearners; - private GateActivity gateActivity; - private boolean allowToPass; + private Integer expectedLearnerCount; + private Integer waitingLearnerCount; + private boolean allowToPass; - public GateActivityDTO(GateActivity gateActivity, List lessonLearners, boolean allowToPass) { - this.gateActivity = gateActivity; - expectedLearners = lessonLearners; - this.allowToPass = allowToPass; - } + public GateActivityDTO(GateActivity gate, Integer expectedLearnerCount, Integer waitingLearnerCount, + boolean allowToPass) { + this.gate = gate; - /** - * Temporary value of the expected number of learners. This may change every time - * the gate is knocked, and is NOT persisted to the database. It is calculated when this - * DTO is created by the knockGate() method in LearnerService. - */ - public List getExpectedLearners() { - return expectedLearners; - } + this.expectedLearnerCount = expectedLearnerCount; + this.waitingLearnerCount = waitingLearnerCount; - public void setExpectedLearners(List tempExpectedLearnerCount) { - expectedLearners = tempExpectedLearnerCount; - } + this.allowToPass = allowToPass || gate.getGateOpen(); + } - @Override - public boolean equals(Object other) { - return gateActivity.equals(other); - } + public GateActivity getGate() { + return gate; + } - public Integer getActivityCategoryID() { - return gateActivity.getActivityCategoryID(); - } + public Integer getExpectedLearnerCount() { + return expectedLearnerCount; + } - public Long getActivityId() { - return gateActivity.getActivityId(); - } + public Integer getWaitingLearnerCount() { + return waitingLearnerCount; + } - public Integer getActivityTypeId() { - return gateActivity.getActivityTypeId(); - } - - public Integer getActivityUIID() { - return gateActivity.getActivityUIID(); - } - - public Set getAllToolActivities() { - return gateActivity.getAllToolActivities(); - } - - public Boolean getApplyGrouping() { - return gateActivity.getApplyGrouping(); - } - - public Set getAuthoringActivityDTOSet(ArrayList branchMappings, - String languageCode) { - return gateActivity.getAuthoringActivityDTOSet(branchMappings, languageCode); - } - - public Date getCreateDateTime() { - return gateActivity.getCreateDateTime(); - } - - public String getDescription() { - return gateActivity.getDescription(); - } - - public Integer getGateActivityLevelId() { - return gateActivity.getGateActivityLevelId(); - } - - public Boolean getGateOpen() { - return gateActivity.getGateOpen(); - } - - public Group getGroupFor(User learner) { - return gateActivity.getGroupFor(learner); - } - - public Grouping getGrouping() { - return gateActivity.getGrouping(); - } - - public Integer getGroupingSupportType() { - return gateActivity.getGroupingSupportType(); - } - - public Integer getGroupingUIID() { - return gateActivity.getGroupingUIID(); - } - - public String getHelpText() { - return gateActivity.getHelpText(); - } - - public Set getInputActivities() { - return gateActivity.getInputActivities(); - } - - public ArrayList getInputActivityUIIDs() { - return gateActivity.getInputActivityUIIDs(); - } - - public String getLanguageFile() { - return gateActivity.getLanguageFile(); - } - - public LearningDesign getLearningDesign() { - return gateActivity.getLearningDesign(); - } - - public LearningLibrary getLearningLibrary() { - return gateActivity.getLearningLibrary(); - } - - public Activity getLibraryActivity() { - return gateActivity.getLibraryActivity(); - } - - public LibraryActivityDTO getLibraryActivityDTO(String languageCode) { - return gateActivity.getLibraryActivityDTO(languageCode); - } - - public String getLibraryActivityUiImage() { - return gateActivity.getLibraryActivityUiImage(); - } - - public Integer getOrderId() { - return gateActivity.getOrderId(); - } - - public Activity getParentActivity() { - return gateActivity.getParentActivity(); - } - - public Activity getParentBranch() { - return gateActivity.getParentBranch(); - } - - public Integer getParentUIID() { - return gateActivity.getParentUIID(); - } - - public ProgressActivityDTO getProgressActivityData() { - return gateActivity.getProgressActivityData(); - } - - public Boolean getReadOnly() { - return gateActivity.getReadOnly(); - } - - public SimpleActivityStrategy getSimpleActivityStrategy() { - return gateActivity.getSimpleActivityStrategy(); - } - - public SystemTool getSystemTool() { - return gateActivity.getSystemTool(); - } - - public String getTitle() { - return gateActivity.getTitle(); - } - - public Integer getToolInputActivityUIID() { - return gateActivity.getToolInputActivityUIID(); - } - - public Transition getTransitionFrom() { - return gateActivity.getTransitionFrom(); - } - - public Transition getTransitionTo() { - return gateActivity.getTransitionTo(); - } - - public Set getWaitingLearners() { - return gateActivity.getWaitingLearners(); - } - - public Integer getXcoord() { - return gateActivity.getXcoord(); - } - - public Integer getYcoord() { - return gateActivity.getYcoord(); - } - - @Override - public int hashCode() { - return gateActivity.hashCode(); - } - - public boolean isActivityReadOnly() { - return gateActivity.isActivityReadOnly(); - } - - public boolean isGateActivity() { - return gateActivity.isGateActivity(); - } - - public boolean isSystemToolActivity() { - return gateActivity.isSystemToolActivity(); - } - - @Override - public String toString() { - return gateActivity.toString(); - } - - /** Get the wrapped up gate activity - the web layer shouldn't use this call, it should use one of the other methods to get - * the gate's details. */ - public GateActivity getGateActivity() { - return gateActivity; - } - - /** Set the wrapped up gate activity */ - public void setGateActivity(GateActivity gateActivity) { - this.gateActivity = gateActivity; - } - - public boolean isPermissionGate() { - return gateActivity.isPermissionGate(); - } - - public boolean isScheduleGate() { - return gateActivity.isScheduleGate(); - } - - public boolean isSynchGate() { - return gateActivity.isSynchGate(); - } - - public boolean isConditionGate() { - return gateActivity.isConditionGate(); - } - - public boolean isSystemGate() { - return gateActivity.isSystemGate(); - } - - public boolean getAllowToPass() { - return getGateOpen() || allowToPass; - } - - public void setAllowToPass(boolean allowToPass) { - this.allowToPass = allowToPass; - } + public boolean getAllowToPass() { + return allowToPass; + } } \ No newline at end of file Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java =================================================================== diff -u -r2f67a20e73128f03e7b4221ca09426c14bef2abf -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 2f67a20e73128f03e7b4221ca09426c14bef2abf) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -669,13 +669,18 @@ * Activity id of the branchingActivity */ SortedSet getGroupsNotAssignedToBranch(Long branchingActivityID) throws LessonServiceException; - + /** - * Get the list of users who have attempted an activity. This is based on the progress engine records. This will + * Get all the users records where the user has attempted the given activity, but has not completed it yet. Uses the + * progress records to determine the users. + */ + List getLearnersAttemptedActivity(Activity activity); + + /** * give the users in all tool sessions for an activity (if it is a tool activity) or it will give all the users who * have attempted an activity that doesn't have any tool sessions, i.e. system activities such as branching. */ - List getLearnersHaveAttemptedActivity(Activity activity) throws LessonServiceException; + List getLearnersAttemptedOrCompletedActivity(Activity activity) throws LessonServiceException; /** Get the record of the learner's progress for a particular lesson */ LearnerProgress getLearnerProgress(Integer learnerId, Long lessonId); Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== diff -u -r2f67a20e73128f03e7b4221ca09426c14bef2abf -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 2f67a20e73128f03e7b4221ca09426c14bef2abf) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -1010,7 +1010,7 @@ GateActivity gate = (GateActivity) activityDAO.getActivityByActivityId(gateId); if ((gate != null) && (userId != null) && (userId >= 0)) { User user = (User) baseDAO.find(User.class, userId); - gate.addLeaner(user, true); + gate.getAllowedToPassLearners().add(user); activityDAO.update(gate); } return gate; @@ -1576,7 +1576,7 @@ case MonitoringConstants.LESSON_TYPE_HAVENT_REACHED_PARTICULAR_ACTIVITY: Activity activity = learnerService.getActivity(activityId); allUsers = lesson.getAllLearners(); - List usersAttemptedActivity = lessonService.getLearnersHaveAttemptedActivity(activity); + List usersAttemptedActivity = lessonService.getLearnersAttemptedOrCompletedActivity(activity); users = CollectionUtils.subtract(allUsers, usersAttemptedActivity); break; @@ -1607,7 +1607,7 @@ for (Lesson les : lessons) { Activity firstActivity = les.getLearningDesign().getFirstActivity(); List usersStartedFirstActivity = learnerProgressDAO - .getLearnersHaveAttemptedActivity(firstActivity); + .getLearnersAttemptedOrCompletedActivity(firstActivity); usersStartedAtLest1Lesson.addAll(usersStartedFirstActivity); } @@ -2344,9 +2344,14 @@ } @Override - public List getLearnersHaveAttemptedActivity(Activity activity) throws LessonServiceException { - return lessonService.getLearnersHaveAttemptedActivity(activity); + public List getLearnersAttemptedActivity(Activity activity){ + return learnerProgressDAO.getLearnersAttemptedActivity(activity); } + + @Override + public List getLearnersAttemptedOrCompletedActivity(Activity activity) throws LessonServiceException { + return lessonService.getLearnersAttemptedOrCompletedActivity(activity); + } @Override public LearnerProgress getLearnerProgress(Integer learnerId, Long lessonId) { Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringServiceProxy.java =================================================================== diff -u -r1b117caf4135f53248542cbc97d71aac448f3de9 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringServiceProxy.java (.../MonitoringServiceProxy.java) (revision 1b117caf4135f53248542cbc97d71aac448f3de9) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringServiceProxy.java (.../MonitoringServiceProxy.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -28,6 +28,7 @@ import org.lamsfoundation.lams.authoring.service.IAuthoringService; import org.lamsfoundation.lams.learning.service.ICoreLearnerService; +import org.lamsfoundation.lams.lesson.service.ILessonService; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -71,8 +72,8 @@ } public static final IUserManagementService getUserManagementService(ServletContext servletContext) { - return (IUserManagementService) MonitoringServiceProxy - .getDomainService(servletContext, "userManagementService"); + return (IUserManagementService) MonitoringServiceProxy.getDomainService(servletContext, + "userManagementService"); } public static final IAuthoringService getAuthoringService(ServletContext servletContext) { @@ -91,4 +92,7 @@ return wac.getBean(serviceName); } -} + public static final ILessonService getLessonService(ServletContext servletContext) { + return (ILessonService) MonitoringServiceProxy.getDomainService(servletContext, "lessonService"); + } +} \ No newline at end of file Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/BranchingAction.java =================================================================== diff -u -r1af4378c901cea902392d4ef17f9d990f25e16f3 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/BranchingAction.java (.../BranchingAction.java) (revision 1af4378c901cea902392d4ef17f9d990f25e16f3) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/BranchingAction.java (.../BranchingAction.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -170,7 +170,7 @@ if ( group.getUsers() == null ) { group.setUsers(new HashSet()); } - List learners = monitoringService.getLearnersHaveAttemptedActivity(branch); + List learners = monitoringService.getLearnersAttemptedOrCompletedActivity(branch); group.getUsers().addAll(learners); groups.add(group); } Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GateAction.java =================================================================== diff -u -raead34144651a924f76d7bca8645327e6820d226 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GateAction.java (.../GateAction.java) (revision aead34144651a924f76d7bca8645327e6820d226) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GateAction.java (.../GateAction.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -27,8 +27,9 @@ import java.io.IOException; import java.util.Calendar; import java.util.Collection; -import java.util.Date; import java.util.GregorianCalendar; +import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.TimeZone; @@ -42,8 +43,10 @@ import org.apache.struts.action.DynaActionForm; import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.learningdesign.GateActivity; +import org.lamsfoundation.lams.learningdesign.Group; import org.lamsfoundation.lams.learningdesign.ScheduleGateActivity; import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.lesson.service.ILessonService; import org.lamsfoundation.lams.monitoring.service.IMonitoringService; import org.lamsfoundation.lams.monitoring.service.MonitoringServiceException; import org.lamsfoundation.lams.monitoring.service.MonitoringServiceProxy; @@ -63,7 +66,7 @@ *
  • 1.View the status of an sync gate, the lams should show how many learners are waiting and the size of the total * class.
  • *
  • 2.View the status of the permission gate, the lams shows the number of the learners waiting in front of the - * gates.
  • + * gates. *
  • 3.View the status of the schedule gate, the lams shows the gate status. If the schedule has been triggerred. The * teacher should be able to change the trigger.
  • *

    @@ -72,7 +75,7 @@ * @since 2005-4-15 * @version 1.1 * - * ----------------XDoclet Tags-------------------- + * ----------------XDoclet Tags-------------------- * * @struts:action name="GateForm" path="/gate" parameter="method" scope="session" validate="false" * @struts:action-forward name="viewSynchGate" path=".viewSynchGate" @@ -90,6 +93,7 @@ private IMonitoringService monitoringService; private ICoreLearnerService learnerService; + private ILessonService lessonService; // --------------------------------------------------------------------- // Class level constants - Struts forward // --------------------------------------------------------------------- @@ -124,15 +128,15 @@ * * * @param mapping - * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to - * send the end-user. + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to send + * the end-user. * * @param form - * The ActionForm class that will contain any data submitted by the end-user via a form. + * The ActionForm class that will contain any data submitted by the end-user via a form. * @param request - * A standard Servlet HttpServletRequest class. + * A standard Servlet HttpServletRequest class. * @param response - * A standard Servlet HttpServletResponse class. + * A standard Servlet HttpServletResponse class. * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go * next. * @throws IOException @@ -159,9 +163,6 @@ throw new MonitoringServiceException("Gate activity missing. Activity id" + gateId); } - // setup the total learners - int totalLearners = learnerService.getLearnersForGate(gate).size(); - gateForm.set(GateAction.TOTAL_LEARNERS_FORM_FIELD, new Integer(totalLearners)); gateForm.set(GateAction.ACTIVITY_FORM_FIELD, gateIdLong); gateForm.set(GateAction.LOCAL_FILES, Boolean.FALSE); @@ -172,15 +173,15 @@ * Open the gate if is closed. * * @param mapping - * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to - * send the end-user. + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to send + * the end-user. * * @param form - * The ActionForm class that will contain any data submitted by the end-user via a form. + * The ActionForm class that will contain any data submitted by the end-user via a form. * @param request - * A standard Servlet HttpServletRequest class. + * A standard Servlet HttpServletRequest class. * @param response - * A standard Servlet HttpServletResponse class. + * A standard Servlet HttpServletResponse class. * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go * next. * @throws IOException @@ -201,14 +202,14 @@ * Allows a single learner to pass the gate. * * @param mapping - * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to - * send the end-user. + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to send + * the end-user. * @param form - * he ActionForm class that will contain any data submitted by the end-user via a form. + * he ActionForm class that will contain any data submitted by the end-user via a form. * @param request - * A standard Servlet HttpServletRequest class. + * A standard Servlet HttpServletRequest class. * @param response - * A standard Servlet HttpServletRequest class. + * A standard Servlet HttpServletRequest class. * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go * next. * @throws IOException @@ -244,46 +245,64 @@ * Dispatch view the according to the gate type. * * @param mapping - * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to - * send the end-user. + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to send + * the end-user. * @param gateForm - * The ActionForm class that will contain any data submitted by the end-user via a form. + * The ActionForm class that will contain any data submitted by the end-user via a form. * @param permissionGate - * the gate acitivty object + * the gate acitivty object * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go * next. */ private ActionForward findViewByGateType(ActionMapping mapping, DynaActionForm gateForm, GateActivity gate) { + lessonService = MonitoringServiceProxy.getLessonService(getServlet().getServletContext()); + // reset all the other fields, so that the following code only has to set up its own values (LDEV-1237) gateForm.set(GateAction.READ_ONLY, Boolean.FALSE); gateForm.set("gate", null); - gateForm.set("waitingLearners", null); gateForm.set("waitingLearnerList", null); gateForm.set("allowedToPassLearnerList", null); gateForm.set("forbiddenLearnerList", null); gateForm.set("startingTime", null); gateForm.set("endingTime", null); - Set waitingLearnersList = gate.getWaitingLearners(); gateForm.set("gate", gate); - gateForm.set("waitingLearners", new Integer(waitingLearnersList.size())); + // setup the total learners + int totalLearners = 0; + for (Group group : learnerService.getGroupsForGate(gate)) { + // users collection is extra-lazy, so checking its size will not trigger full load + totalLearners += group.getUsers().size(); + } + gateForm.set(GateAction.TOTAL_LEARNERS_FORM_FIELD, totalLearners); + // dispatch the view according to the type of the gate. if (gate.isSynchGate()) { + Integer waitingLearnerCount = lessonService.getCountLearnersHaveAttemptedActivity(gate); + gateForm.set("waitingLearners", waitingLearnerCount); return mapping.findForward(GateAction.VIEW_SYNCH_GATE); } else if (gate.isScheduleGate()) { + Integer waitingLearnerCount = lessonService.getCountLearnersHaveAttemptedActivity(gate); + gateForm.set("waitingLearners", waitingLearnerCount); return viewScheduleGate(mapping, gateForm, (ScheduleGateActivity) gate); } else if (gate.isPermissionGate() || gate.isSystemGate() || gate.isConditionGate()) { + List waitingLearnersList = monitoringService.getLearnersAttemptedActivity(gate); + gateForm.set("waitingLearners", waitingLearnersList.size()); gateForm.set("waitingLearnerList", waitingLearnersList); gateForm.set("allowedToPassLearnerList", gate.getAllowedToPassLearners()); - Collection forbiddenUsers = learnerService.getLearnersForGate(gate); + Set learnerGroups = learnerService.getGroupsForGate(gate); + Collection forbiddenUsers = new HashSet(); + for (Group learnerGroup : learnerGroups) { + // only here users are fetched from DB as it is an extra-lazy collection + forbiddenUsers.addAll(learnerGroup.getUsers()); + } forbiddenUsers.removeAll(gate.getAllowedToPassLearners()); gateForm.set("forbiddenLearnerList", forbiddenUsers); if (gate.isConditionGate()) { return mapping.findForward(GateAction.VIEW_CONDITION_GATE); - } else { - return mapping.findForward(GateAction.VIEW_PERMISSION_GATE); } + + return mapping.findForward(GateAction.VIEW_PERMISSION_GATE); } else { throw new MonitoringServiceException("Invalid gate activity. " + "gate id [" + gate.getActivityId() + "] - the type [" + gate.getActivityTypeId() + "] is not a gate type"); @@ -315,7 +334,7 @@ startingTime.add(Calendar.MINUTE, scheduleGate.getGateStartTimeOffset().intValue()); gateForm.set("startingTime", startingTime.getTime()); } - + return mapping.findForward(GateAction.VIEW_SCHEDULE_GATE); } } \ No newline at end of file Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/SequenceAction.java =================================================================== diff -u -r3a4c502dd96ac40fd96827f36bc450158b145113 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/SequenceAction.java (.../SequenceAction.java) (revision 3a4c502dd96ac40fd96827f36bc450158b145113) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/SequenceAction.java (.../SequenceAction.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -107,7 +107,7 @@ // only show the group names if this is a group based branching activity - the names // are meaningless for chosen and tool based branching - List learners = monitoringService.getLearnersHaveAttemptedActivity(activity); + List learners = monitoringService.getLearnersAttemptedOrCompletedActivity(activity); request.setAttribute(PARAM_LEARNERS, learners); return mapping.findForward(VIEW_SEQUENCE); } Index: lams_monitoring/web/gate/gateInfo.jsp =================================================================== diff -u -r2f6c67e31d0c35ddcfb8b4ae9f53d162c6472f4c -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_monitoring/web/gate/gateInfo.jsp (.../gateInfo.jsp) (revision 2f6c67e31d0c35ddcfb8b4ae9f53d162c6472f4c) +++ lams_monitoring/web/gate/gateInfo.jsp (.../gateInfo.jsp) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -39,7 +39,7 @@ - +

    Index: lams_monitoring/web/gate/permissionGateContent.jsp =================================================================== diff -u -rb9a5084dfc1510cefec305104580add4c26762ea -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_monitoring/web/gate/permissionGateContent.jsp (.../permissionGateContent.jsp) (revision b9a5084dfc1510cefec305104580add4c26762ea) +++ lams_monitoring/web/gate/permissionGateContent.jsp (.../permissionGateContent.jsp) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -54,6 +54,7 @@

    + Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java =================================================================== diff -u -r7593a8e2fd4aacb20168191679ffe6e723e08826 -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 7593a8e2fd4aacb20168191679ffe6e723e08826) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) @@ -1569,7 +1569,7 @@ boolean isHtmlFormat = forum.isAllowRichEditor(); if (forum.isNotifyLearnersOnForumPosting()) { - List learners = lessonService.getLearnersHaveAttemptedActivity(activity); + List learners = lessonService.getLearnersAttemptedOrCompletedActivity(activity); if ((learners != null) && !learners.isEmpty()) { ArrayList learnerIds = new ArrayList(); for (User learner : learners) {