Index: lams_build/lib/lams/lams-monitoring.jar =================================================================== RCS file: /usr/local/cvsroot/lams_build/lib/lams/lams-monitoring.jar,v diff -u -r1.38 -r1.39 Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java,v diff -u -r1.65 -r1.66 --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java 2 Jun 2008 06:25:55 -0000 1.65 +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java 10 Jun 2008 01:23:45 -0000 1.66 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java,v diff -u -r1.72 -r1.73 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 23 May 2008 01:43:55 -0000 1.72 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 10 Jun 2008 01:24:02 -0000 1.73 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java,v diff -u -r1.131 -r1.132 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 28 May 2008 02:07:14 -0000 1.131 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 10 Jun 2008 01:24:02 -0000 1.132 @@ -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: