Index: lams_build/lib/lams/lams-monitoring.jar =================================================================== diff -u -r9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6 -r57589d9a2eb658f07e1769b487bd47a4eb147673 Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java =================================================================== diff -u -r6f8b165d9fc95cce1c4365c2e7e46d7b93a3e3f4 -r57589d9a2eb658f07e1769b487bd47a4eb147673 --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 6f8b165d9fc95cce1c4365c2e7e46d7b93a3e3f4) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 57589d9a2eb658f07e1769b487bd47a4eb147673) @@ -708,10 +708,11 @@ Long newContentId = lamsCoreToolService.notifyToolToCopyContent(toolActivity, true); toolActivity.setToolContentId(newContentId); - } else if ( activity.isScheduleGate() ) { - //if it is schedule gate, we need to initialize the sheduler for it. - ScheduleGateActivity gateActivity = (ScheduleGateActivity) activityDAO.getActivityByActivityId(activity.getActivityId()); - monitoringService.runGateScheduler(gateActivity,now,lesson.getLessonName()); + } else { + Integer newMaxId = monitoringService.startSystemActivity(activity, design.getMaxID(), now, lesson.getLessonName()); + if ( newMaxId != null ) { + design.setMaxID(newMaxId); + } } activity.setInitialised(Boolean.TRUE); activityDAO.update(activity); Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java =================================================================== diff -u -r4817e3da1eb7dc61568fc813da2eb0cf383aec46 -r57589d9a2eb658f07e1769b487bd47a4eb147673 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 4817e3da1eb7dc61568fc813da2eb0cf383aec46) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 57589d9a2eb658f07e1769b487bd47a4eb147673) @@ -136,6 +136,14 @@ */ public void startLesson(long lessonId, Integer userId) throws UserAccessDeniedException; + + /** Do any normal initialisation needed for gates and branching. Done both when a lesson is started, or for new activities + * added during a Live Edit. Returns a new MaxID for the design if needed. If MaxID is returned, update the design with this + * new value and save the whole design (as initialiseSystemActivities has changed the design). + */ + public Integer startSystemActivity( Activity activity, Integer currentMaxId, Date lessonStartTime, String lessonName ); + + /** *

Runs the system scheduler to start the scheduling for opening gate and * closing gate. It invlovs a couple of steps to start the scheduler:

Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== diff -u -rda0ff1fa820f1d7bd51e5a9fc23eaba18b61228c -r57589d9a2eb658f07e1769b487bd47a4eb147673 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision da0ff1fa820f1d7bd51e5a9fc23eaba18b61228c) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 57589d9a2eb658f07e1769b487bd47a4eb147673) @@ -718,31 +718,14 @@ ToolActivity toolActivity = (ToolActivity) activityDAO.getActivityByActivityId(activity.getActivityId()); initToolSessionIfSuitable(toolActivity, requestedLesson); } - //if it is schedule gate, we need to initialize the sheduler for it. - if(activity.getActivityTypeId().intValue() == Activity.SCHEDULE_GATE_ACTIVITY_TYPE) { - ScheduleGateActivity gateActivity = (ScheduleGateActivity) activityDAO.getActivityByActivityId(activity.getActivityId()); - activity = runGateScheduler(gateActivity,lessonStartTime,requestedLesson.getLessonName()); - } - if ( activity.isBranchingActivity() && activity.getGrouping() == null) { - Integer currentMaxId = design.getMaxID(); - // all branching activities must have a grouping, as the learner will be allocated to a group linked to a sequence (branch) - Grouping grouping = new ChosenGrouping(null, null, null); - grouping.setGroupingUIID(currentMaxId); - grouping.getActivities().add(activity); - activity.setGrouping(grouping); - activity.setGroupingUIID(currentMaxId); - activity.setApplyGrouping(Boolean.TRUE); - groupingDAO.insert(grouping); - activity.setGrouping(grouping); - if ( log.isDebugEnabled() ) { - log.debug( "startLesson: Created chosen grouping "+grouping+" for branching activity "+activity); - } - design.setMaxID(new Integer(currentMaxId.intValue()+1)); + Integer newMaxId = startSystemActivity(activity, design.getMaxID(), lessonStartTime, requestedLesson.getLessonName()); + if ( newMaxId != null ) { + design.setMaxID(newMaxId); designModified = true; - } - - activity.setInitialised(Boolean.TRUE); + } + + activity.setInitialised(Boolean.TRUE); activityDAO.update(activity); } @@ -759,8 +742,37 @@ log.debug("=============Lesson "+lessonId+" started==============="); } + /** Do any normal initialisation needed for gates and branching. Done both when a lesson is started, or for new activities + * added during a Live Edit. Returns a new MaxID for the design if needed. If MaxID is returned, update the design with this + * new value and save the whole design (as initialiseSystemActivities has changed the design). + */ + public Integer startSystemActivity( Activity activity, Integer currentMaxId, Date lessonStartTime, String lessonName ) { + Integer newMaxId = null; + + //if it is schedule gate, we need to initialize the sheduler for it. + if(activity.getActivityTypeId().intValue() == Activity.SCHEDULE_GATE_ACTIVITY_TYPE) { + ScheduleGateActivity gateActivity = (ScheduleGateActivity) activityDAO.getActivityByActivityId(activity.getActivityId()); + activity = runGateScheduler(gateActivity,lessonStartTime,lessonName); + } + if ( activity.isBranchingActivity() && activity.getGrouping() == null) { + // all branching activities must have a grouping, as the learner will be allocated to a group linked to a sequence (branch) + Grouping grouping = new ChosenGrouping(null, null, null); + grouping.setGroupingUIID(currentMaxId); + grouping.getActivities().add(activity); + activity.setGrouping(grouping); + activity.setGroupingUIID(currentMaxId); + activity.setApplyGrouping(Boolean.TRUE); + groupingDAO.insert(grouping); + + activity.setGrouping(grouping); + if ( log.isDebugEnabled() ) { + log.debug( "startLesson: Created chosen grouping "+grouping+" for branching activity "+activity); + } + newMaxId = new Integer(currentMaxId.intValue()+1); + } + return newMaxId; + } - /** *

Runs the system scheduler to start the scheduling for opening gate and * closing gate. It involves a couple of steps to start the scheduler: