Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r6e041b14d83c90f3f910fac33c7755fca1486b3e -r11914f2354254e0e92e2a271453ba2f0e8a35fdc Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java =================================================================== diff -u -rfcdf3f7584d020b2aeb399a8cb0d0b55fb0e6be4 -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java (.../ObjectExtractor.java) (revision fcdf3f7584d020b2aeb399a8cb0d0b55fb0e6be4) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java (.../ObjectExtractor.java) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -23,6 +23,7 @@ /* $$Id$$ */ package org.lamsfoundation.lams.authoring; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; @@ -41,6 +42,7 @@ import org.lamsfoundation.lams.learningdesign.ComplexActivity; import org.lamsfoundation.lams.learningdesign.GateActivity; import org.lamsfoundation.lams.learningdesign.Group; +import org.lamsfoundation.lams.learningdesign.GroupBranchActivityEntry; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.GroupingActivity; import org.lamsfoundation.lams.learningdesign.LearningDesign; @@ -133,14 +135,18 @@ protected HashMap oldActivityMap = new HashMap(); // Activity UIID -> Activity /* cache of groupings - too hard to get them from the db */ protected HashMap groupings = new HashMap(); + protected HashMap groups = new HashMap(); + protected HashMap branchEntries = new HashMap(); /* can't delete as we go as they are linked to other items - keep a list and delete at the end. */ protected Set groupingsToDelete = new HashSet(); protected LearningDesign learningDesign = null; + protected Date modificationDate = null; protected Logger log = Logger.getLogger(ObjectExtractor.class); /** Constructor to be used if Spring method injection is used */ public ObjectExtractor() { + modificationDate = new Date(); } /** Constructor to be used if Spring method injection is not used */ @@ -160,6 +166,7 @@ this.groupDAO = groupDAO; this.transitionDAO = transitionDAO; this.toolSessionDAO = toolSessionDAO; + modificationDate = new Date(); } /** Spring injection methods */ @@ -317,17 +324,13 @@ learningDesign.setOnlineInstructions(WDDXProcessor.convertToString(table,WDDXTAGS.ONLINE_INSTRUCTIONS)); if (keyExists(table, WDDXTAGS.HELP_TEXT)) learningDesign.setHelpText(WDDXProcessor.convertToString(table,WDDXTAGS.HELP_TEXT)); - if (keyExists(table, WDDXTAGS.CREATION_DATE)) - learningDesign.setCreateDateTime(WDDXProcessor.convertToDate(table,WDDXTAGS.CREATION_DATE)); // if (keyExists(table, WDDXTAGS.VERSION)) // learningDesign.setVersion(WDDXProcessor.convertToString(table,WDDXTAGS.VERSION)); //don't receive version from flash anymore(it was hardcode). Get it from lams configuration database. learningDesign.setVersion(Configuration.get(ConfigurationKeys.VERSION)); if (keyExists(table, WDDXTAGS.DURATION)) learningDesign.setDuration(WDDXProcessor.convertToLong(table,WDDXTAGS.DURATION)); - if (keyExists(table, WDDXTAGS.LAST_MODIFIED_DATE)) - learningDesign.setLastModifiedDateTime(WDDXProcessor.convertToDate(table,WDDXTAGS.LAST_MODIFIED_DATE)); if (keyExists(table, WDDXTAGS.DURATION)) learningDesign.setDuration(WDDXProcessor.convertToLong(table,WDDXTAGS.DURATION)); @@ -337,7 +340,12 @@ if (keyExists(table, WDDXTAGS.SAVE_MODE)) mode = WDDXProcessor.convertToInteger(table, WDDXTAGS.SAVE_MODE); - + + // Set creation date and modification date based on the server timezone, not the client. + if ( learningDesign.getCreateDateTime() == null ) + learningDesign.setCreateDateTime(modificationDate); + learningDesign.setLastModifiedDateTime(modificationDate); + Integer userId = getUserId(); if( userId != null ) { @@ -390,11 +398,11 @@ learningDesignDAO.insertOrUpdate(learningDesign); // now process the "parts" of the learning design - //Vector v = (Vector)table.get(WDDXTAGS.GROUPINGS); parseGroupings((Vector)table.get(WDDXTAGS.GROUPINGS)); parseActivities((Vector)table.get(WDDXTAGS.ACTIVITIES)); parseActivitiesToMatchUpParentActivityByParentUIID((Vector)table.get(WDDXTAGS.ACTIVITIES)); parseTransitions((Vector)table.get(WDDXTAGS.TRANSITIONS)); + parseBranchMappings((Vector)table.get(WDDXTAGS.BRANCH_MAPPINGS)); learningDesign.setFirstActivity(learningDesign.calculateFirstActivity()); learningDesignDAO.insertOrUpdate(learningDesign); @@ -420,20 +428,21 @@ /** Initialise the map of tool sessions already in the database. Used to work out what will be deleted * by Hibernate later - useful to clean up any unwanted tool sessions for edit on the fly. */ + @SuppressWarnings("unchecked") private void initialiseToolSessionMap(LearningDesign learningDesign) { if (learningDesign.getEditOverrideLock() && learningDesign.getEditOverrideUser() != null) { Iterator iter = learningDesign.getActivities().iterator(); while ( iter.hasNext() ) { Activity activity = (Activity) iter.next(); oldActivityMap.put(activity.getActivityUIID(), activity); - List toolSessions = toolSessionDAO.getToolSessionByActivity(activity); + List toolSessions = (List) toolSessionDAO.getToolSessionByActivity(activity); if ( toolSessions != null && toolSessions.size() > 0 ) toolSessionMap.put(activity.getActivityUIID(),toolSessions); } } } - /** Delete the old unneeded groupings. Won't be done via a cascase */ + /** Delete the old unneeded groupings. Won't be done via a cascade */ private void deleteUnwantedGroupings() { for ( Grouping grouping: groupingsToDelete) { groupingDAO.delete(grouping); @@ -504,9 +513,6 @@ } } - - - } @@ -540,12 +546,56 @@ createChosenGrouping((ChosenGrouping)grouping,groupingDetails); else createLessonClass((LessonClass)grouping, groupingDetails); - + if (keyExists(groupingDetails,WDDXTAGS.MAX_NUMBER_OF_GROUPS)) grouping.setMaxNumberOfGroups(WDDXProcessor.convertToInteger(groupingDetails,WDDXTAGS.MAX_NUMBER_OF_GROUPS)); - + + List groupsList = (Vector)groupingDetails.get(WDDXTAGS.GROUPS); + if ( groupsList != null && groupsList.size() > 0 ) { + Iterator iter = groupsList.iterator(); + while ( iter.hasNext() ) { + Hashtable groupDetails = (Hashtable)iter.next(); + Group group = extractGroupObject(groupDetails, grouping); + groups.put(group.getGroupUIID(), group); + } + } return grouping; } + + @SuppressWarnings("unchecked") + private Group extractGroupObject(Hashtable groupDetails, Grouping grouping) throws WDDXProcessorConversionException { + + Group group = null; + Integer groupUIID = WDDXProcessor.convertToInteger(groupDetails,WDDXTAGS.GROUP_UIID); + if ( groupUIID == null ) { + throw new WDDXProcessorConversionException("TGroup is missing its UUID. Group "+groupDetails+" grouping "+grouping); + } + Long groupID = WDDXProcessor.convertToLong(groupDetails,WDDXTAGS.GROUP_ID); + + // does it exist already? Check on the ID field as the UIID field may not have + // been set if this grouping was created on the back end (based on a runtime copy of the sequence) + if ( groupID != null && grouping.getGroups() != null && grouping.getGroups().size() > 0 ) { + Iterator iter = grouping.getGroups().iterator(); + while (group == null && iter.hasNext()) { + Group possibleGroup = (Group) iter.next(); + if ( groupUIID.equals(possibleGroup.getGroupId()) ) { + group = possibleGroup; + } + } + } + + if ( group == null ) { + group = new Group(); + grouping.getGroups().add(group); + } + + group.setGroupName(WDDXProcessor.convertToString(groupDetails,WDDXTAGS.GROUP_NAME)); + group.setGrouping(grouping); + group.setGroupUIID(groupUIID); + group.setOrderId(WDDXProcessor.convertToInteger(groupDetails,WDDXTAGS.ORDER_ID)); + return group; + } + private void createRandomGrouping(RandomGrouping randomGrouping,Hashtable groupingDetails) throws WDDXProcessorConversionException{ if (keyExists(groupingDetails, WDDXTAGS.LEARNERS_PER_GROUP)) randomGrouping.setLearnersPerGroup(WDDXProcessor.convertToInteger(groupingDetails,WDDXTAGS.LEARNERS_PER_GROUP)); @@ -567,6 +617,7 @@ * @throws WDDXProcessorConversionException * @throws ObjectExtractorException */ + @SuppressWarnings("unchecked") private void parseActivities(List activitiesList) throws WDDXProcessorConversionException, ObjectExtractorException { @@ -654,6 +705,7 @@ * @param learningDesign * @throws WDDXProcessorConversionException */ + @SuppressWarnings("unchecked") private void parseTransitions(List transitionsList) throws WDDXProcessorConversionException{ HashMap newMap = new HashMap(); @@ -769,8 +821,10 @@ } } - if (keyExists(activityDetails, WDDXTAGS.CREATION_DATE)) - activity.setCreateDateTime(WDDXProcessor.convertToDate(activityDetails,WDDXTAGS.CREATION_DATE)); + // Set creation date based on the server timezone, not the client. + if ( activity.getCreateDateTime() == null ) + activity.setCreateDateTime(modificationDate); + if (keyExists(activityDetails, WDDXTAGS.RUN_OFFLINE)) activity.setRunOffline(WDDXProcessor.convertToBoolean(activityDetails,WDDXTAGS.RUN_OFFLINE)); if (keyExists(activityDetails, WDDXTAGS.ACTIVITY_CATEGORY_ID)) @@ -1002,9 +1056,11 @@ transition.setDescription(WDDXProcessor.convertToString(transitionDetails,WDDXTAGS.DESCRIPTION)); if(keyExists(transitionDetails, WDDXTAGS.TITLE)) transition.setTitle(WDDXProcessor.convertToString(transitionDetails,WDDXTAGS.TITLE)); - if(keyExists(transitionDetails, WDDXTAGS.CREATION_DATE)) - transition.setCreateDateTime(WDDXProcessor.convertToDate(transitionDetails,WDDXTAGS.CREATION_DATE)); + // Set creation date based on the server timezone, not the client. + if ( transition.getCreateDateTime() == null ) + transition.setCreateDateTime(modificationDate); + if ( transition.getToActivity() != null && transition.getFromActivity() != null ) { transition.setLearningDesign(learningDesign); return transition; @@ -1061,45 +1117,6 @@ return false; } - /** - * Helper method to delete an activity from a learning design. Before the activity is deleted, - * any associations with a transition is removed: any transitions to or from the activity - * is deleted. - * @param activityToDelete - * @param design - */ - private void clearTransition(Activity activityToDelete) - { - - Transition transitionFrom = activityToDelete.getTransitionFrom(); - if (transitionFrom != null) - deleteTransition(transitionFrom); - - Transition transitionTo = activityToDelete.getTransitionTo(); - if (transitionTo != null) - deleteTransition(transitionTo); - - } - - /** - * Helper method which deletes a Transition object. Before the transition is deleted, - * any relationship that this transition has with an activity, will be removed. - * @param transition - * @param design - */ - private void deleteTransition(Transition transition) - { - Activity fromActivity = transition.getFromActivity(); - fromActivity.setTransitionFrom(null); - - Activity toActivity = transition.getToActivity(); - toActivity.setTransitionTo(null); - - //This will leave orphan content in the tool tables. It will be removed by the tool content cleaning job, - //which may be run from the admin screen or via a cron job - learningDesign.getTransitions().remove(transition); - } - public void setMode(Integer mode) { this.mode = mode; } @@ -1119,5 +1136,75 @@ UserDTO learner = (UserDTO) ss.getAttribute(AttributeNames.USER); return learner != null ? learner.getUserID() : null; } + + /** + * Parses the mappings used for branching. They map groups to the sequence activities + * that form a branch within a branching activity. + * + * Must be done after all the other parsing as we need to match up activities + * and groups. + * @param branchMappingsList + * @throws WDDXProcessorConversionException + */ + + private void parseBranchMappings(List branchMappingsList) + throws WDDXProcessorConversionException + { + if (branchMappingsList != null) + { + Iterator iterator = branchMappingsList.iterator(); + while(iterator.hasNext()) + { + extractGroupBranchActivityEntry((Hashtable)iterator.next()); + } + } + } + + @SuppressWarnings("unchecked") + private GroupBranchActivityEntry extractGroupBranchActivityEntry(Hashtable details) throws WDDXProcessorConversionException { + + Long entryId = WDDXProcessor.convertToLong(details, WDDXTAGS.GROUP_BRANCH_ACTIVITY_ENTRY_ID); + Integer entryUIID = WDDXProcessor.convertToInteger(details, WDDXTAGS.GROUP_BRANCH_ACTIVITY_ENTRY_UIID); + Integer groupUIID = WDDXProcessor.convertToInteger(details, WDDXTAGS.GROUP_UIID); + Integer sequenceActivityUIID=WDDXProcessor.convertToInteger(details,WDDXTAGS.GROUP_BRANCH_SEQUENCE_ACTIVITY_UIID); + + Group group = groups.get(groupUIID); + if ( group == null ) { + throw new WDDXProcessorConversionException("Group listed in the branch mapping list is missing. Mapping entry UUID "+entryUIID+" groupUIID "+groupUIID); + } + + Activity sequenceActivity = newActivityMap.get(sequenceActivityUIID); + if ( sequenceActivity == null || ! sequenceActivity.isSequenceActivity() ) { + throw new WDDXProcessorConversionException("Activity listed in the branch mapping list is missing. Mapping entry UUID "+entryUIID+" sequenceActivityUIID "+sequenceActivityUIID); + } + if ( ! sequenceActivity.isSequenceActivity() ) { + throw new WDDXProcessorConversionException("Activity listed in the branch mapping list is not a sequence activity. Mapping entry UUID "+entryUIID+" sequenceActivityUIID "+sequenceActivityUIID); + } + + GroupBranchActivityEntry entry = null; + + // does it exist already? Check on the ID field as the UIID field may not have + // been set if this grouping was created on the back end (based on a runtime copy of the sequence) + if ( entryId != null && group.getBranchActivities() != null && group.getBranchActivities().size() > 0 ) { + Iterator iter = group.getBranchActivities().iterator(); + while (entry == null && iter.hasNext()) { + GroupBranchActivityEntry possibleEntry = (GroupBranchActivityEntry) iter.next(); + if ( entryId.equals(possibleEntry.getEntryId()) ) { + entry = possibleEntry; + } + } + } + + if ( entry == null ) { + entry = new GroupBranchActivityEntry(); + group.getBranchActivities().add(entry); + } + entry.setBranchSequenceActivity((SequenceActivity)sequenceActivity); + entry.setGroup(group); + + return entry; + } + + } Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java =================================================================== diff -u -r9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6 -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -25,6 +25,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; @@ -47,11 +48,14 @@ import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.ActivityOrderComparator; import org.lamsfoundation.lams.learningdesign.GateActivity; +import org.lamsfoundation.lams.learningdesign.Group; +import org.lamsfoundation.lams.learningdesign.GroupBranchActivityEntry; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.GroupingActivity; import org.lamsfoundation.lams.learningdesign.LearningDesign; import org.lamsfoundation.lams.learningdesign.License; import org.lamsfoundation.lams.learningdesign.ScheduleGateActivity; +import org.lamsfoundation.lams.learningdesign.SequenceActivity; import org.lamsfoundation.lams.learningdesign.ToolActivity; import org.lamsfoundation.lams.learningdesign.Transition; import org.lamsfoundation.lams.learningdesign.dao.hibernate.ActivityDAO; @@ -749,13 +753,13 @@ /** * Updates the Activity information in the newLearningDesign based - * on the originalLearningDesign + * on the originalLearningDesign. This any grouping details. * * @param originalLearningDesign The LearningDesign to be copied * @param newLearningDesign The copy of the originalLearningDesign */ private void updateDesignActivities(LearningDesign originalLearningDesign, LearningDesign newLearningDesign){ - TreeSet newActivities = new TreeSet(new ActivityOrderComparator()); + HashMap newActivities = new HashMap(); // key is UIID HashMap newGroupings = new HashMap(); // key is UIID Set oldParentActivities = originalLearningDesign.getParentActivities(); @@ -766,23 +770,40 @@ } } + Collection activities = newActivities.values(); + // Go back and find all the grouped activities and assign them the new groupings, based on the UIID. Can't // be done as we go as the grouping activity may be processed after the grouped activity. - for ( Activity activity : newActivities ) { + for ( Activity activity : activities) { Integer groupingUIID = activity.getGroupingUIID(); if ( groupingUIID != null ) { activity.setGrouping(newGroupings.get(groupingUIID)); } } + // Now go back and fix any branch mapping entries - they will still be pointing to old activities. + for ( Grouping grouping: newGroupings.values() ) { + if ( grouping.getGroups().size() > 0 ) { + Iterator iter = grouping.getGroups().iterator(); + while ( iter.hasNext() ) { + Group group = (Group) iter.next(); + if ( group.getBranchActivities().size() > 0 ) { + Iterator iter2 = group.getBranchActivities().iterator(); + while ( iter2.hasNext() ) { + GroupBranchActivityEntry entry = (GroupBranchActivityEntry) iter2.next(); + SequenceActivity oldSequenceActivity = entry.getBranchSequenceActivity(); + entry.setBranchSequenceActivity((SequenceActivity) newActivities.get(oldSequenceActivity.getActivityUIID())); + } + } + } + } + } + // The activities collection in the learning design may already exist (as we have already done a save on the design). // If so, we can't just override the existing collection as the cascade causes an error. - if ( newLearningDesign.getActivities() != null ) { - newLearningDesign.getActivities().clear(); - newLearningDesign.getActivities().addAll(newActivities); - } else { - newLearningDesign.setActivities(newActivities); - } + // newLearningDesign.getActivities() will create a new TreeSet(new ActivityOrderComparator()) if there isn't an existing set + newLearningDesign.getActivities().clear(); + newLearningDesign.getActivities().addAll(activities); } /** As part of updateDesignActivities(), process an activity and, via recursive calls, the activity's child activities. Need to keep track @@ -794,15 +815,15 @@ * @param newGroupings Temporary set of new groupings. Key is the grouping UUID. May not be null. * @param parentActivity This activity's parent activity (if one exists). May be null. */ - private void processActivity(Activity activity, LearningDesign newLearningDesign, Set newActivities, Map newGroupings, Activity parentActivity) { + private void processActivity(Activity activity, LearningDesign newLearningDesign, Map newActivities, Map newGroupings, Activity parentActivity) { Activity newActivity = getActivityCopy(activity, newGroupings); newActivity.setLearningDesign(newLearningDesign); if ( parentActivity != null ) { newActivity.setParentActivity(parentActivity); newActivity.setParentUIID(parentActivity.getActivityUIID()); } activityDAO.insert(newActivity); - newActivities.add(newActivity); + newActivities.put(newActivity.getActivityUIID(),newActivity); Set oldChildActivities = getChildActivities((Activity)activity); if ( oldChildActivities != null ) { Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Group.hbm.xml =================================================================== diff -u -r920894ca746cba5e080023c5cc80167d64d1653d -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Group.hbm.xml (.../Group.hbm.xml) (revision 920894ca746cba5e080023c5cc80167d64d1653d) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Group.hbm.xml (.../Group.hbm.xml) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -65,6 +65,10 @@ + + @hibernate.property column="group_ui_id" length="11" + + @@ -126,5 +130,11 @@ + + + + + + Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/GroupBranchActivityEntry.hbm.xml =================================================================== diff -u --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/GroupBranchActivityEntry.hbm.xml (revision 0) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/GroupBranchActivityEntry.hbm.xml (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -0,0 +1,41 @@ + + + + + + + + + + + + + @hibernate.property column="group_branch_activity_ui_id" length="11" + + + + + + @hibernate.column name="group_id" + + + + + + + @hibernate.column name="activity_id" + + + + + + Index: lams_common/db/model/lams_11.clay =================================================================== diff -u -ra013e19f4975a63a246dbea05b9adda64a274dd1 -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/db/model/lams_11.clay (.../lams_11.clay) (revision a013e19f4975a63a246dbea05b9adda64a274dd1) +++ lams_common/db/model/lams_11.clay (.../lams_11.clay) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -65,10 +65,6 @@ - - - - @@ -106,12 +102,7 @@ - - - - - - + @@ -144,12 +135,7 @@ - - - - - - +
@@ -182,12 +168,7 @@ - - - - - - +
@@ -746,10 +727,6 @@ - - - - @@ -803,12 +780,7 @@ - - - - - - +
@@ -1122,10 +1094,6 @@ - - - - @@ -1142,7 +1110,7 @@
- + @@ -1190,6 +1158,19 @@ + + + + + + + + + + + + + @@ -1206,10 +1187,6 @@ - - - - @@ -1327,10 +1304,6 @@ - - - - @@ -1393,12 +1366,7 @@ - - - - - - +
@@ -1550,10 +1518,6 @@ - - - - @@ -1792,18 +1756,10 @@ - - - - - - - - @@ -1853,10 +1809,6 @@ - - - - @@ -1907,10 +1859,6 @@ - - - - @@ -2214,10 +2162,6 @@ - - - - @@ -2302,10 +2246,6 @@ - - - - @@ -2382,10 +2322,6 @@ - - - - @@ -2468,15 +2404,7 @@ - - - - - - - - - +
@@ -2576,10 +2504,6 @@ - - - - @@ -3558,7 +3482,7 @@
- + @@ -5377,6 +5301,92 @@
+ +Maps a group to an activity. Used for allocating groups to a sequence activity, which forms one branch inside a branching activity. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Index: lams_common/db/sql/create_lams_11_tables.sql =================================================================== diff -u -ra013e19f4975a63a246dbea05b9adda64a274dd1 -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision a013e19f4975a63a246dbea05b9adda64a274dd1) +++ lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -398,6 +398,7 @@ , group_name VARCHAR(255) NOT NULL , grouping_id BIGINT(20) NOT NULL , order_id INT(6) NOT NULL DEFAULT 1 + , group_ui_id INT(11) , PRIMARY KEY (group_id) , INDEX (grouping_id) , CONSTRAINT FK_lams_learning_group_1 FOREIGN KEY (grouping_id) @@ -553,6 +554,21 @@ REFERENCES lams_system_tool (system_tool_id) )TYPE=InnoDB; +CREATE TABLE lams_group_branch_activity ( + entry_id BIGINT(20) NOT NULL AUTO_INCREMENT + , entry_ui_id INT(11) + , group_id BIGINT(20) NOT NULL + , activity_id BIGINT(20) NOT NULL + , UNIQUE UQ_lams_group_activity (activity_id, group_id) + , PRIMARY KEY (entry_id) + , INDEX (group_id) + , CONSTRAINT FK_lams_group_activity_1 FOREIGN KEY (group_id) + REFERENCES lams_group (group_id) + , INDEX (activity_id) + , CONSTRAINT FK_lams_group_activity_2 FOREIGN KEY (activity_id) + REFERENCES lams_learning_activity (activity_id) +)TYPE=InnoDB; + CREATE TABLE lams_lesson ( lesson_id BIGINT(20) NOT NULL AUTO_INCREMENT , learning_design_id BIGINT(20) NOT NULL Index: lams_common/db/sql/updatescripts/alter_21_branching.sql =================================================================== diff -u -r6e041b14d83c90f3f910fac33c7755fca1486b3e -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/db/sql/updatescripts/alter_21_branching.sql (.../alter_21_branching.sql) (revision 6e041b14d83c90f3f910fac33c7755fca1486b3e) +++ lams_common/db/sql/updatescripts/alter_21_branching.sql (.../alter_21_branching.sql) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -1,6 +1,24 @@ -- Script to be run for LAMS 2.1 release, on LAMS 2.0.3 tables. -- Adds all the data needed for branching +ALTER TABLE lams_group +ADD COLUMN group_ui_id INT(11); + +CREATE TABLE lams_group_branch_activity ( + entry_id BIGINT(20) NOT NULL AUTO_INCREMENT + , entry_ui_id INT(11) + , group_id BIGINT(20) NOT NULL + , activity_id BIGINT(20) NOT NULL + , UNIQUE UQ_lams_group_activity (activity_id, group_id) + , PRIMARY KEY (entry_id) + , INDEX (group_id) + , CONSTRAINT FK_lams_group_activity_1 FOREIGN KEY (group_id) + REFERENCES lams_group (group_id) + , INDEX (activity_id) + , CONSTRAINT FK_lams_group_activity_2 FOREIGN KEY (activity_id) + REFERENCES lams_learning_activity (activity_id) +)TYPE=InnoDB; + INSERT INTO lams_learning_activity_type VALUES (10, 'BRANCHING_CHOSEN'); INSERT INTO lams_learning_activity_type VALUES (11, 'BRANCHING_GROUP'); INSERT INTO lams_learning_activity_type VALUES (12, 'BRANCHING_TOOL'); @@ -32,3 +50,5 @@ 'learning/branching.do?method=viewBranching&mode=teacher&type=tool', 'learning/branchingExportPortfolio?mode=learner&type=tool', 'learning/branchingExportPortfolio?mode=teacher&type=tool', 'monitoring/branching.do?method=assignBranch&type=tool', 'monitoring/branching.do?method=assignBranch&type=tool', now()); + + \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/commonContext.xml =================================================================== diff -u -r117b4f3d433dec684bdde042c051f7b2831ad54a -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision 117b4f3d433dec684bdde042c051f7b2831ad54a) +++ lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -47,6 +47,7 @@ org/lamsfoundation/lams/learningdesign/Activity.hbm.xml org/lamsfoundation/lams/learningdesign/Group.hbm.xml org/lamsfoundation/lams/learningdesign/Grouping.hbm.xml + org/lamsfoundation/lams/learningdesign/GroupBranchActivityEntry.hbm.xml org/lamsfoundation/lams/learningdesign/LearningDesign.hbm.xml org/lamsfoundation/lams/learningdesign/LearningLibrary.hbm.xml org/lamsfoundation/lams/learningdesign/Transition.hbm.xml Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ChosenGrouping.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ChosenGrouping.java (.../ChosenGrouping.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ChosenGrouping.java (.../ChosenGrouping.java) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -50,8 +50,7 @@ public Grouping createCopy() { ChosenGrouping chosenGrouping = new ChosenGrouping(); - chosenGrouping.setMaxNumberOfGroups(this.getMaxNumberOfGroups()); - chosenGrouping.setGroupingUIID(this.getGroupingUIID()); + copyGroupingFields(chosenGrouping); return chosenGrouping; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java =================================================================== diff -u -r8b271e1b06efcbe0b323b7071cdecf693e322c60 -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java (.../Group.java) (revision 8b271e1b06efcbe0b323b7071cdecf693e322c60) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java (.../Group.java) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -54,6 +54,10 @@ /** persistent field */ private int orderId; + /** FLASH generated value. Unique per LearningDesign. + * Required by flash only.*/ + private Integer groupUIID; + /** persistent field */ private Grouping grouping; @@ -63,18 +67,23 @@ /** persistent field */ private Set toolSessions; - //--------------------------------------------------------------------- + /** persistent field */ + private Set branchActivities; + + //--------------------------------------------------------------------- // Object creation Methods //--------------------------------------------------------------------- /** full constructor */ - public Group(Long groupId, String groupName, int orderId, Grouping grouping, Set users, Set toolSessions) { + 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; } /** @@ -90,7 +99,7 @@ { int nextOrderId = grouping.getNextGroupOrderIdCheckName(groupName); if ( nextOrderId > -1 ) { - return new Group(null,groupName,nextOrderId,grouping,users,new HashSet()); + return new Group(null,groupName,nextOrderId,null,grouping,users,new HashSet(),null); } return null; } @@ -110,7 +119,7 @@ { int nextOrderId = grouping.getNextGroupOrderIdCheckName(groupName); if ( nextOrderId > -1 ) { - return new Group(null,groupName,nextOrderId,grouping,users,toolSessions); + return new Group(null,groupName,nextOrderId,null,grouping,users,toolSessions,null); } return null; } @@ -126,7 +135,7 @@ */ public static Group createStaffGroup(Grouping grouping, String groupName, Set staffs) { - return new Group(null,groupName, STAFF_GROUP_ORDER_ID,grouping,staffs,new HashSet()); + return new Group(null,groupName, STAFF_GROUP_ORDER_ID,null,grouping,staffs,new HashSet(),null); } /** default constructor */ @@ -179,6 +188,17 @@ this.orderId = orderId; } + /** + * @hibernate.property column="group_ui_id" length="11" + */ + public Integer getGroupUIID() { + return this.groupUIID; + } + + public void setGroupUIID(Integer uiId) { + this.groupUIID = uiId; + } + /** * @hibernate.many-to-one * not-null="true" @@ -227,10 +247,33 @@ 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.GroupBranchActivity" + * + */ + public Set getBranchActivities() { + return this.branchActivities; + } + public void setBranchActivities(Set branchActivities) { + this.branchActivities = branchActivities; + } + public String toString() { return new ToStringBuilder(this) .append("groupId", getGroupId()) .append("groupName", getGroupName()) + .append("groupUIID", getGroupUIID()) .toString(); } @@ -242,6 +285,7 @@ .append(this.getGroupId(), castOther.getGroupId()) .append(this.getGroupName(), castOther.getGroupName()) .append(this.getOrderId(), castOther.getOrderId()) + .append(this.getGroupUIID(), castOther.getGroupUIID()) .isEquals(); } @@ -250,6 +294,7 @@ .append(getGroupId()) .append(getGroupName()) .append(getOrderId()) + .append(getGroupUIID()) .toHashCode(); } @@ -294,4 +339,25 @@ public boolean mayBeDeleted() { 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. */ + @SuppressWarnings("unchecked") + public Group createCopy(Grouping newGrouping) { + + Group newGroup = new Group(null, this.getGroupName(), this.getOrderId(), this.getGroupUIID(), + newGrouping, null, null, null); + + if ( this.getBranchActivities() != null && this.getBranchActivities().size() > 0) { + Iterator iter = this.getBranchActivities().iterator(); + while ( iter.hasNext() ) { + GroupBranchActivityEntry oldEntry = (GroupBranchActivityEntry) iter.next(); + GroupBranchActivityEntry newEntry = new GroupBranchActivityEntry(null, + oldEntry.getEntryUIID(), newGroup, oldEntry.getBranchSequenceActivity()); + newGroup.getBranchActivities().add(newEntry); + } + } + + return newGroup; + } } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/GroupBranchActivityEntry.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/GroupBranchActivityEntry.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/GroupBranchActivityEntry.java (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -0,0 +1,160 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ +package org.lamsfoundation.lams.learningdesign; + +import java.io.Serializable; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.lamsfoundation.lams.learningdesign.dto.GroupBranchActivityEntryDTO; + + +/** + * Models the relationship between a group and a branch for Chosen or Group based branching. + * Links the group to the sequence activity that makes up a branch within a branching activity. + * + * @author Fiona Malikoff + * @version 2.1 + * + * @hibernate.class table="lams_group_branch_activity" +*/ +public class GroupBranchActivityEntry implements Serializable { + + /** identifier field */ + private Long entryId; + + /** persistent field */ + private Integer entryUIID; + + /** persistent field */ + private Group group; + + /** persistent field */ + private SequenceActivity branchSequenceActivity; + + //--------------------------------------------------------------------- + // Object creation Methods + //--------------------------------------------------------------------- + + /** full constructor */ + public GroupBranchActivityEntry(Long entryId, Integer entryUIID, Group group, SequenceActivity branchSequenceActivity) { + this.entryId = entryId; + this.entryUIID = entryUIID; + this.group = group; + this.branchSequenceActivity = branchSequenceActivity; + } + + /** default constructor */ + public GroupBranchActivityEntry() { + } + //--------------------------------------------------------------------- + // Field Access Methods + //--------------------------------------------------------------------- + + /** + * @hibernate.id + * generator-class="native" + * type="java.lang.Long" + * column="entry_id" + * + */ + public Long getEntryId() { + return this.entryId; + } + + public void setEntryId(Long id) { + entryId = id; + } + + /** + * @hibernate.property column="entry_ui_id" length="11" + */ + public Integer getEntryUIID() { + return this.entryUIID; + } + + public void setEntryUIID(Integer entryUIID) { + this.entryUIID = entryUIID; + } + + /** + * @hibernate.many-to-one + * not-null="true" + * @hibernate.column name="group_id" + * + */ + public org.lamsfoundation.lams.learningdesign.Group getGroup() { + return this.group; + } + + public void setGroup(org.lamsfoundation.lams.learningdesign.Group group) { + this.group = group; + } + + /** + * @hibernate.many-to-one + * not-null="true" + * @hibernate.column name="activity_id" + * + */ + public org.lamsfoundation.lams.learningdesign.SequenceActivity getBranchSequenceActivity() { + return this.branchSequenceActivity; + } + + public void setBranchSequenceActivity(org.lamsfoundation.lams.learningdesign.SequenceActivity branchSequenceActivity) { + this.branchSequenceActivity = branchSequenceActivity; + } + + public String toString() { + return new ToStringBuilder(this) + .append("entryId", getEntryId()) + .append("entryUIID", getEntryUIID()) + .append("group", getGroup() != null ? getGroup().getGroupId().toString() : "") + .append("sequence activity", getBranchSequenceActivity() != null ? getBranchSequenceActivity().getActivityId().toString() : "") + .toString(); + } + + public boolean equals(Object other) { + if ( (this == other ) ) return true; + if ( !(other instanceof GroupBranchActivityEntry) ) return false; + GroupBranchActivityEntry castOther = (GroupBranchActivityEntry) other; + return new EqualsBuilder() + .append(this.getEntryId(), castOther.getEntryId()) + .append(this.getEntryUIID(), castOther.getEntryUIID()) + .isEquals(); + } + + public int hashCode() { + return new HashCodeBuilder() + .append(getEntryId()) + .append(getEntryUIID()) + .toHashCode(); + } + + public GroupBranchActivityEntryDTO getGroupBranchActivityDTO() { + return new GroupBranchActivityEntryDTO(this); + } + +} Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/Grouping.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/Grouping.java (.../Grouping.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/Grouping.java (.../Grouping.java) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -111,11 +111,38 @@ } /** Create a deep copy of the this grouping. It should return the same - * subclass as the grouping being copied + * subclass as the grouping being copied. Does not copy the tool sessions. + * Copies the groups but not users in the groups. Copies any group to + * branch mappings, updating the group but not the activity. + * + * Any implementation of this method can call copyGroupingFields(Grouping newGrouping) + * to set max number of groups, grouping UIID, copy the groups + * and the group to branch mappings. + * * @return deep copy of this object */ public abstract Grouping createCopy(); + /** + * Copy all the groups within this grouping to the newGrouping object. + * Copies the groups but not users in the groups. Copies any group to branch + * mappings, updating the group but not the activity. Used by createCopy() + * implementations. + */ + protected void copyGroupingFields(Grouping newGrouping){ + newGrouping.setMaxNumberOfGroups(this.getMaxNumberOfGroups()); + newGrouping.setGroupingUIID(this.getGroupingUIID()); + + if ( this.getGroups() != null && this.getGroups().size() > 0 ) { + Iterator iter = this.getGroups().iterator(); + while ( iter.hasNext() ) { + Group oldGroup = (Group) iter.next(); + Group newGroup = oldGroup.createCopy(newGrouping); + newGrouping.getGroups().add(newGroup); + } + } + } + /** * * Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/RandomGrouping.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/RandomGrouping.java (.../RandomGrouping.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/RandomGrouping.java (.../RandomGrouping.java) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -101,13 +101,12 @@ * @return RandomGrouping The deep copied Grouping object */ public Grouping createCopy(){ - RandomGrouping randomGrouping = new RandomGrouping(); + RandomGrouping randomGrouping = new RandomGrouping(); + copyGroupingFields(randomGrouping); - randomGrouping.setMaxNumberOfGroups(this.getMaxNumberOfGroups()); - randomGrouping.setGroupingUIID(this.getGroupingUIID()); - randomGrouping.setNumberOfGroups(this.getNumberOfGroups()); - randomGrouping.setLearnersPerGroup(this.getLearnersPerGroup()); + randomGrouping.setLearnersPerGroup(this.getLearnersPerGroup()); + return randomGrouping; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/GroupBranchActivityEntryDTO.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/GroupBranchActivityEntryDTO.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/GroupBranchActivityEntryDTO.java (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -0,0 +1,91 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ +package org.lamsfoundation.lams.learningdesign.dto; + +import java.io.Serializable; + +import org.lamsfoundation.lams.learningdesign.GroupBranchActivityEntry; + +/** + * Models the relationship between a group and a branch for Chosen or Group based branching. + * Links the group to the sequence activity that makes up a branch within a branching activity. + * Used by Flash - so we just record the related UI IDs, rather than the actual objects + * as they will appear elsewhere in the design. + * + * @author Fiona Malikoff + * @version 2.1 + * +*/ +public class GroupBranchActivityEntryDTO implements Serializable { + + private Long entryID; + private Integer entryUIID; + private Integer groupUIID; + private Integer sequenceActivityUIID; + + //--------------------------------------------------------------------- + // Object creation Methods + //--------------------------------------------------------------------- + + /** full constructor */ + public GroupBranchActivityEntryDTO(GroupBranchActivityEntry gba) { + this.entryID = gba.getEntryId(); + this.entryUIID = gba.getEntryUIID(); + this.groupUIID = gba.getGroup().getGroupUIID(); + this.sequenceActivityUIID = gba.getBranchSequenceActivity().getActivityUIID(); + } + + public Long getEntryID() { + return this.entryID; + } + + public void setEntryID(Long id) { + entryID = id; + } + + public Integer getGroupUIID() { + return this.groupUIID; + } + + public void setGroupUIID(Integer groupUIID) { + this.groupUIID = groupUIID; + } + + public Integer getSequenceActivityUIID() { + return this.sequenceActivityUIID; + } + + public void setSequenceActivityUIID(Integer sequenceActivityUIID) { + this.sequenceActivityUIID = sequenceActivityUIID; + } + + public Integer getEntryUIID() { + return entryUIID; + } + + public void setEntryUIID(Integer entryUIID) { + this.entryUIID = entryUIID; + } + +} Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/GroupDTO.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/GroupDTO.java (.../GroupDTO.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/GroupDTO.java (.../GroupDTO.java) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -38,11 +38,18 @@ private int orderID; //list of org.lamsfoundation.lams.usermanagement.dto.UserDTO private List userList; + private Integer groupUIID; + /** Get the DTO for this group. Does not include the GroupBranchActivities as they will + * be in a separate array for Flash. + * @param group + */ + @SuppressWarnings("unchecked") public GroupDTO(Group group) { groupID = group.getGroupId(); groupName = group.getGroupName(); orderID = group.getOrderId(); + groupUIID = group.getGroupUIID(); userList = new ArrayList(); if(group.getUsers() != null){ Iterator iter = group.getUsers().iterator(); @@ -69,6 +76,12 @@ public void setOrderID(int orderID) { this.orderID = orderID; } + public Integer getGroupUIID() { + return groupUIID; + } + public void setGroupUIID(Integer groupUIID) { + this.groupUIID = groupUIID; + } public List getUserList() { return userList; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/LearningDesignDTO.java =================================================================== diff -u -r8221a11e9776b23bc5ec1282b5b384779e396e82 -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/LearningDesignDTO.java (.../LearningDesignDTO.java) (revision 8221a11e9776b23bc5ec1282b5b384779e396e82) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/LearningDesignDTO.java (.../LearningDesignDTO.java) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -33,9 +33,12 @@ import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.ActivityDTOOrderComparator; +import org.lamsfoundation.lams.learningdesign.Group; +import org.lamsfoundation.lams.learningdesign.GroupBranchActivityEntry; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.GroupingActivity; import org.lamsfoundation.lams.learningdesign.LearningDesign; +import org.lamsfoundation.lams.learningdesign.SequenceActivity; import org.lamsfoundation.lams.learningdesign.Transition; import org.lamsfoundation.lams.learningdesign.dao.hibernate.ActivityDAO; import org.lamsfoundation.lams.util.wddx.WDDXTAGS; @@ -80,7 +83,8 @@ private ArrayList groupings; private ArrayList activities; private ArrayList transitions; - + private ArrayList branchMappings; + public LearningDesignDTO(){ } public LearningDesignDTO(Long learningDesignId, @@ -141,6 +145,7 @@ this.groupings = new ArrayList(); this.activities = new ArrayList(); this.transitions = new ArrayList(); + this.branchMappings = new ArrayList(); } public LearningDesignDTO(LearningDesign learningDesign, ActivityDAO activityDAO){ this.learningDesignID = learningDesign.getLearningDesignId(); @@ -196,6 +201,7 @@ null; this.lastModifiedDateTime = learningDesign.getLastModifiedDateTime(); + this.branchMappings = new ArrayList(); // data will be set up by populateGroupings this.groupings = populateGroupings(learningDesign,activityDAO); this.activities = populateActivities(learningDesign); this.transitions = populateTransitions(learningDesign); @@ -405,6 +411,21 @@ GroupingActivity groupingActivity = (GroupingActivity) parentIterator.next(); Grouping grouping = groupingActivity.getCreateGrouping(); groupingList.add(grouping.getGroupingDTO()); + + if ( grouping.getGroups().size() > 0 ) { + Iterator iter = grouping.getGroups().iterator(); + while ( iter.hasNext() ) { + Group group = (Group) iter.next(); + if ( group.getBranchActivities().size() > 0 ) { + Iterator iter2 = group.getBranchActivities().iterator(); + while ( iter2.hasNext() ) { + GroupBranchActivityEntry gba = (GroupBranchActivityEntry) iter2.next(); + branchMappings.add(gba.getGroupBranchActivityDTO()); + } + } + } + } + } return groupingList; } Index: lams_common/src/java/org/lamsfoundation/lams/util/wddx/WDDXTAGS.java =================================================================== diff -u -r9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6 -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/src/java/org/lamsfoundation/lams/util/wddx/WDDXTAGS.java (.../WDDXTAGS.java) (revision 9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6) +++ lams_common/src/java/org/lamsfoundation/lams/util/wddx/WDDXTAGS.java (.../WDDXTAGS.java) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -64,6 +64,7 @@ public static final String GROUPINGS ="groupings"; public static final String TRANSITIONS ="transitions"; public static final String ACTIVITIES ="activities"; + public static final String BRANCH_MAPPINGS = "branchMappings"; /*Learning Library specific tags */ public static final String LEARNING_LIBRARY_ID ="learningLibraryID"; @@ -124,7 +125,17 @@ public static final String NUMBER_OF_GROUPS ="numberOfGroups"; public static final String STAFF_GROUP_ID = "staffGroupID"; public static final String GROUPING_DTO = "groupingDTO"; + public static final String GROUPS = "groups"; + public static final String GROUP_ID = "groupID"; + public static final String GROUP_NAME = "groupName"; + public static final String GROUP_USER_LIST = "userList"; + public static final String GROUP_UIID = "groupUIID"; + + public static final String GROUP_BRANCH_ACTIVITY_ENTRY_ID = "entryID"; + public static final String GROUP_BRANCH_ACTIVITY_ENTRY_UIID = "entryUIID"; + public static final String GROUP_BRANCH_SEQUENCE_ACTIVITY_UIID = "sequenceActivityUIID"; + /** Transition specific tags */ public static final String TRANSITION_ID ="transitionID"; public static final String TRANSITION_UIID ="transitionUIID"; Index: lams_common/test/java/org/lamsfoundation/lams/lesson/LessonDataAccessTestCase.java =================================================================== diff -u -rdea9100eb459aedcd96021a4bc1d2d48edff0631 -r11914f2354254e0e92e2a271453ba2f0e8a35fdc --- lams_common/test/java/org/lamsfoundation/lams/lesson/LessonDataAccessTestCase.java (.../LessonDataAccessTestCase.java) (revision dea9100eb459aedcd96021a4bc1d2d48edff0631) +++ lams_common/test/java/org/lamsfoundation/lams/lesson/LessonDataAccessTestCase.java (.../LessonDataAccessTestCase.java) (revision 11914f2354254e0e92e2a271453ba2f0e8a35fdc) @@ -207,9 +207,11 @@ Group staffGroup = new Group(null,//group id TEST_GROUP_NAME_STAFF, TEST_GROUP_ORDER_ID, + null, testLessonClass, staffs, - new HashSet()); + new HashSet(), + null); testLessonClass.setStaffGroup(staffGroup); //create learner class group @@ -219,9 +221,11 @@ Group learnerClassGroup = new Group(null,//group id TEST_GROUP_NAME_LEARNER, testLessonClass.getNextGroupOrderIdCheckName(TEST_GROUP_NAME_LEARNER), + null, testLessonClass, learnergroups, - new HashSet());//tool session, should be empty now + new HashSet(), + null);//tool session, should be empty now learnergroups.add(learnerClassGroup); learnergroups.add(staffGroup);