Index: lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java =================================================================== diff -u -re1247e4495087eea41d597f90365d50b5b104b19 -r061455c7b3bf7a09ab42621cbb2e71890346c55f --- lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java (.../ObjectExtractor.java) (revision e1247e4495087eea41d597f90365d50b5b104b19) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java (.../ObjectExtractor.java) (revision 061455c7b3bf7a09ab42621cbb2e71890346c55f) @@ -24,6 +24,7 @@ import java.text.ParseException; import java.util.ArrayList; +import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -106,15 +107,14 @@ * @author Manpreet Minhas * @author Mailing Truong * - * This is a utility class for extracting the information from the JSON packet sent by Authoring. + * This is a utility class for extracting the information from the JSON packet sent by Authoring. * - * The following rules are applied: The client sends a subset of all possible data. If a field is included, then - * the value associated with this field should be persisted (the value maybe a new value or an unchanged value) - * If a field is not included then the server should assume that the value is unchanged. If the value of a field - * is one of the special null values, then null should be persisted. + * The following rules are applied: The client sends a subset of all possible data. If a field is included, then the + * value associated with this field should be persisted (the value maybe a new value or an unchanged value) If a field + * is not included then the server should assume that the value is unchanged. If the value of a field is one of the + * special null values, then null should be persisted. * - * Object extractor has member data, so it should not be used as a singleton. - * + * Object extractor has member data, so it should not be used as a singleton. */ public class ObjectExtractor implements IObjectExtractor { @@ -329,8 +329,8 @@ if (copyTypeID == null) { copyTypeID = LearningDesign.COPY_TYPE_NONE; } - if ((learningDesign != null) && (learningDesign.getCopyTypeID() != null) - && !learningDesign.getCopyTypeID().equals(copyTypeID) && !learningDesign.getEditOverrideLock()) { + if ((learningDesign != null) && (learningDesign.getCopyTypeID() != null) && !learningDesign.getCopyTypeID() + .equals(copyTypeID) && !learningDesign.getEditOverrideLock()) { throw new ObjectExtractorException( "Unable to save learning design. Cannot change copy type on existing design."); } @@ -459,8 +459,9 @@ ComplexActivity complex = defaultActivityMap.get(defaultChildUIID); Activity defaultActivity = newActivityMap.get(defaultChildUIID); if (defaultActivity == null) { - String msg = "Unable to find the default child activity (" + defaultChildUIID - + ") for the activity (" + complex + ") referred to in First Child to Sequence map."; + String msg = + "Unable to find the default child activity (" + defaultChildUIID + ") for the activity (" + + complex + ") referred to in First Child to Sequence map."; throw new ObjectExtractorException(msg); } else { complex.setDefaultActivity(defaultActivity); @@ -474,9 +475,9 @@ defaultActivity.setOrderId(1); int nextOrderId = 2; - Activity nextActivity = defaultActivity.getTransitionFrom() != null - ? defaultActivity.getTransitionFrom().getToActivity() - : null; + Activity nextActivity = + defaultActivity.getTransitionFrom() != null ? defaultActivity.getTransitionFrom() + .getToActivity() : null; while (nextActivity != null) { boolean removed = unprocessedChildren.remove(nextActivity); if (!removed) { @@ -486,9 +487,8 @@ break; } nextActivity.setOrderId(nextOrderId++); - nextActivity = nextActivity.getTransitionFrom() != null - ? nextActivity.getTransitionFrom().getToActivity() - : null; + nextActivity = nextActivity.getTransitionFrom() != null ? nextActivity.getTransitionFrom() + .getToActivity() : null; } if (unprocessedChildren.size() > 0) { @@ -520,8 +520,8 @@ } private void intialiseBranchActivityMappings() { - oldbranchActivityEntryList = branchActivityEntryDAO - .getEntriesByLearningDesign(learningDesign.getLearningDesignId()); + oldbranchActivityEntryList = branchActivityEntryDAO.getEntriesByLearningDesign( + learningDesign.getLearningDesignId()); } /** @@ -566,16 +566,17 @@ Activity activity = oldActivityMap.get(uiid); if (toolSessions.size() > 1) { - throw new ObjectExtractorException("More than one tool session exists for activity " - + activity.getTitle() + " (" + uiid - + ") but this shouldn't be possible. Cannot delete this tool session so editing is not allowed!"); + throw new ObjectExtractorException( + "More than one tool session exists for activity " + activity.getTitle() + " (" + + uiid + + ") but this shouldn't be possible. Cannot delete this tool session so editing is not allowed!"); } else if (toolSessions.size() == 1) { ToolSession toolSession = (ToolSession) toolSessions.get(0); if (activity.isGroupingActivity()) { - throw new ObjectExtractorException("Activity " + activity.getTitle() + " (" - + activity.getActivityUIID() - + ") has a tool session but it is grouped. Cannot delete this tool session so editing is not allowed!"); + throw new ObjectExtractorException( + "Activity " + activity.getTitle() + " (" + activity.getActivityUIID() + + ") has a tool session but it is grouped. Cannot delete this tool session so editing is not allowed!"); } // all okay, do ahead and delete the tool session @@ -635,29 +636,29 @@ createRandomGrouping((RandomGrouping) grouping, groupingDetails); } else if (grouping.isChosenGrouping()) { createChosenGrouping((ChosenGrouping) grouping, groupingDetails); - } - - else if (grouping.isLearnerChoiceGrouping()) { + } else if (grouping.isLearnerChoiceGrouping()) { createLearnerChoiceGrouping((LearnerChoiceGrouping) grouping, groupingDetails); } else { createLessonClass((LessonClass) grouping, groupingDetails); } grouping.setMaxNumberOfGroups(JsonUtil.optInt(groupingDetails, "maxNumberOfGroups")); - Set groupsToDelete = new HashSet<>(grouping.getGroups()); + Set existingGroups = new HashSet<>(grouping.getGroups()); + grouping.getGroups().clear(); ArrayNode groupsList = JsonUtil.optArray(groupingDetails, "groups"); if (groupsList != null) { for (JsonNode groupDetails : groupsList) { - Group group = extractGroupObject((ObjectNode) groupDetails, grouping); + Group group = extractGroupObject((ObjectNode) groupDetails, existingGroups); + group.setGrouping(grouping); groups.put(group.getGroupUIID(), group); - groupsToDelete.remove(group); + existingGroups.remove(group); } } - if (groupsToDelete.size() > 0) { - Iterator iter = groupsToDelete.iterator(); + if (existingGroups.size() > 0) { + Iterator iter = existingGroups.iterator(); while (iter.hasNext()) { Group group = (Group) iter.next(); if (group.getBranchActivities() != null) { @@ -668,13 +669,13 @@ } group.getBranchActivities().clear(); } - grouping.getGroups().remove(group); + groupDAO.deleteGroup(group); } } return grouping; } - private Group extractGroupObject(ObjectNode groupDetails, Grouping grouping) { + private Group extractGroupObject(ObjectNode groupDetails, Collection groups) { Group group = null; Integer groupUIID = JsonUtil.optInt(groupDetails, AuthoringJsonTags.GROUP_UIID); @@ -688,10 +689,10 @@ // worst case, which is the group // is created at runtime but then modified in authoring (and has has a // new UI ID added) is handled. - if ((grouping.getGroups() != null) && (grouping.getGroups().size() > 0)) { + if ((groups != null) && (groups.size() > 0)) { Group uiid_match = null; Group id_match = null; - Iterator iter = grouping.getGroups().iterator(); + Iterator iter = groups.iterator(); while ((uiid_match == null) && iter.hasNext()) { Group possibleGroup = (Group) iter.next(); if (groupUIID != null && groupUIID.equals(possibleGroup.getGroupUIID())) { @@ -706,11 +707,9 @@ if (group == null) { group = new Group(); - grouping.getGroups().add(group); } group.setGroupName(JsonUtil.optString(groupDetails, AuthoringJsonTags.GROUP_NAME)); - group.setGrouping(grouping); group.setGroupUIID(groupUIID); group.setOrderId(JsonUtil.optInt(groupDetails, AuthoringJsonTags.ORDER_ID, 0)); @@ -871,8 +870,9 @@ Activity parentActivity = newActivityMap.get(parentUIID); if (parentActivity == null) { - throw new ObjectExtractorException("Parent activity " + parentUIID + " missing for activity " - + existingActivity.getTitle() + ": " + existingActivity.getActivityUIID()); + throw new ObjectExtractorException( + "Parent activity " + parentUIID + " missing for activity " + existingActivity.getTitle() + + ": " + existingActivity.getActivityUIID()); } existingActivity.setParentActivity(parentActivity); existingActivity.setParentUIID(parentUIID); @@ -1129,8 +1129,8 @@ private void buildOptionsActivity(OptionsActivity optionsActivity, ObjectNode activityDetails) { optionsActivity.setMaxNumberOfOptions(JsonUtil.optInt(activityDetails, AuthoringJsonTags.MAX_OPTIONS)); optionsActivity.setMinNumberOfOptions(JsonUtil.optInt(activityDetails, AuthoringJsonTags.MIN_OPTIONS)); - optionsActivity - .setOptionsInstructions(JsonUtil.optString(activityDetails, AuthoringJsonTags.OPTIONS_INSTRUCTIONS)); + optionsActivity.setOptionsInstructions( + JsonUtil.optString(activityDetails, AuthoringJsonTags.OPTIONS_INSTRUCTIONS)); } private void buildOptionsWithSequencesActivity(OptionsWithSequencesActivity optionsActivity, @@ -1157,8 +1157,8 @@ // copy content if its the default one Long toolContentId = JsonUtil.optLong(activityDetails, AuthoringJsonTags.TOOL_CONTENT_ID); if ((toolContentId == null) || toolContentId.equals(tool.getDefaultToolContentId())) { - if ((toolActivity.getToolContentId() == null) - || toolActivity.getToolContentId().equals(tool.getDefaultToolContentId())) { + if ((toolActivity.getToolContentId() == null) || toolActivity.getToolContentId() + .equals(tool.getDefaultToolContentId())) { toolContentId = getLamsCoreToolService().notifyToolToCopyContent(toolActivity, null); } else { toolContentId = toolActivity.getToolContentId(); @@ -1236,10 +1236,10 @@ if (existingTransition == null) { if (false/* - * It will eventually be implemented in Authoring. Now we need to check what kind of transition are - * we - * dealing with transitionType.equals(Transition.DATA_TRANSITION_TYPE) - */) { + * It will eventually be implemented in Authoring. Now we need to check what kind of transition are + * we + * dealing with transitionType.equals(Transition.DATA_TRANSITION_TYPE) + */) { transition = new DataTransition(); } else { transition = new Transition(); @@ -1300,8 +1300,8 @@ * activity but not a too activity. These cases should be picked up by Authoring, but just in case. */ private void cleanupTransition(Transition transition) { - if ((transition.getFromActivity() != null) - && transition.equals(transition.getFromActivity().getTransitionFrom())) { + if ((transition.getFromActivity() != null) && transition.equals( + transition.getFromActivity().getTransitionFrom())) { transition.getFromActivity().setTransitionFrom(null); } if ((transition.getToActivity() != null) && transition.equals(transition.getToActivity().getTransitionTo())) { @@ -1550,8 +1550,8 @@ Integer conditionUIID = JsonUtil.optInt(conditionDetails, AuthoringJsonTags.CONDITION_UIID); String conditionType = JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_TYPE); - if (BranchCondition.OUTPUT_TYPE_COMPLEX.equals(conditionType) - || BranchCondition.OUTPUT_TYPE_STRING.equals(conditionType)) { + if (BranchCondition.OUTPUT_TYPE_COMPLEX.equals(conditionType) || BranchCondition.OUTPUT_TYPE_STRING.equals( + conditionType)) { // This is different than "conditionID" !!! Long newConditionID = condition == null ? JsonUtil.optLong(conditionDetails, AuthoringJsonTags.CONDITION_ID) @@ -1579,8 +1579,8 @@ JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_EXACT_MATCH_VALUE)); } else { condition.setConditionUIID(conditionUIID); - condition - .setDisplayName(JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_DISPLAY_NAME)); + condition.setDisplayName( + JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_DISPLAY_NAME)); condition.setEndValue(JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_END_VALUE)); condition.setExactMatchValue( JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_EXACT_MATCH_VALUE)); Index: lams_central/web/css/_authoring_base.scss =================================================================== diff -u -reff4591166587e12af17581dc551a6104673cceb -r061455c7b3bf7a09ab42621cbb2e71890346c55f --- lams_central/web/css/_authoring_base.scss (.../_authoring_base.scss) (revision eff4591166587e12af17581dc551a6104673cceb) +++ lams_central/web/css/_authoring_base.scss (.../_authoring_base.scss) (revision 061455c7b3bf7a09ab42621cbb2e71890346c55f) @@ -120,7 +120,7 @@ } input.propertiesContentFieldLearnerCount, input.propertiesContentFieldGroupCount { - width: 40px; + width: 50px; } tr.propertiesContentRowGateSchedule input.spinner { @@ -779,5 +779,4 @@ span.hoverEdit +span+ i { visibility: hidden; } -} - +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java =================================================================== diff -u -re226c52b735351f433827ce6b4c040714f3e6046 -r061455c7b3bf7a09ab42621cbb2e71890346c55f --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java (.../Group.java) (revision e226c52b735351f433827ce6b4c040714f3e6046) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java (.../Group.java) (revision 061455c7b3bf7a09ab42621cbb2e71890346c55f) @@ -118,9 +118,9 @@ * synchornize method on grouping. If a group of this name already exists, returns null. * * @param grouping - * the grouping this group belongs to. + * the grouping this group belongs to. * @param users - * the users in this group. + * the users in this group. * @return the new learner group */ public static Group createLearnerGroup(Grouping grouping, String groupName, Set users) { @@ -137,13 +137,13 @@ * method on grouping. If a group of this name already exists, returns null. * * @param grouping - * the grouping this group belongs to. + * the grouping this group belongs to. * @param name - * of this group + * of this group * @param users - * the users in this group. + * the users in this group. * @param toolSessions - * all tool sessions included in this group + * all tool sessions included in this group * @return the new learner group */ public static Group createLearnerGroupWithToolSession(Grouping grouping, String groupName, Set users, @@ -159,12 +159,11 @@ * Creation constructor for initializing staff group. The order is created using default constant. * * @param grouping - * the grouping this group belongs to. + * the grouping this group belongs to. * @param name - * of this group + * of this group * @param staffs - * the users in this group. - * + * the users in this group. * @return the new staff group. */ public static Group createStaffGroup(Grouping grouping, String groupName, Set staffs) { @@ -264,14 +263,13 @@ } 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(); + .append(this.getGroupId(), castOther.getGroupId()).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(getOrderId()).append(getGroupId()).append(getGroupUIID()).toHashCode(); } /** @@ -281,20 +279,21 @@ */ @Override public int compareTo(Group group) { - return new CompareToBuilder() - .append(StringUtils.lowerCase(this.getGroupName()), StringUtils.lowerCase(group.getGroupName())) - .append(this.getOrderId(), group.getOrderId()).append(this.getGroupId(), group.getGroupId()) - .append(this.getGroupUIID(), group.getGroupUIID()).toComparison(); + return new CompareToBuilder().append(StringUtils.lowerCase(this.getGroupName()), + StringUtils.lowerCase(group.getGroupName())).append(this.getOrderId(), group.getOrderId()) + .append(this.getGroupId(), group.getGroupId()).append(this.getGroupUIID(), group.getGroupUIID()) + .toComparison(); } // --------------------------------------------------------------------- // Field Access Methods // --------------------------------------------------------------------- + /** * Return whether the target user is in this group or not. * * @param learner - * the target user + * the target user * @return boolean value to indicate whether the user is in. */ public boolean hasLearner(User learner) { @@ -361,4 +360,4 @@ public void removeGroupFromBranch(SequenceActivity branch) { branch.removeGroupFromBranch(this); } -} +} \ No newline at end of file