Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== diff -u -r7913826df20868a8bf035076a14ac89d5e615b46 -r33c320461eb25493b3c38170ec23291cb0d953c6 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 7913826df20868a8bf035076a14ac89d5e615b46) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 33c320461eb25493b3c38170ec23291cb0d953c6) @@ -848,6 +848,11 @@ // work out new offset in minutes from lesson start time to the given date Lesson lesson = learnerService.getLessonByActivity(gate); Date lessonStartingTime = lesson.getStartDateTime(); + if (lessonStartingTime == null && Lesson.NOT_STARTED_STATE.equals(lesson.getLessonStateId())) { + // Assume the lesson will start at the scheduled time + lessonStartingTime = lesson.getScheduleStartDate(); + } + if (lessonStartingTime != null) { // Should never be null, so just skip that case. If it was null how did the initial trigger get set up? long offset = (tzSchedulingDatetime.getTime() - lessonStartingTime.getTime()) / 60000; @@ -892,6 +897,11 @@ gate.setGateStartTimeOffset(offset); activityDAO.update(gate); } + } else { + log.error(new StringBuilder( + "Unable to reschedule gate opening time as we are missing the lesson starting time. Schedule gate ") + .append(gate).append(" lesson ").append(lesson.getLessonId()).append(" status ") + .append(lesson.getLessonStateId()).toString()); } } } Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GateAction.java =================================================================== diff -u -r7913826df20868a8bf035076a14ac89d5e615b46 -r33c320461eb25493b3c38170ec23291cb0d953c6 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GateAction.java (.../GateAction.java) (revision 7913826df20868a8bf035076a14ac89d5e615b46) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GateAction.java (.../GateAction.java) (revision 33c320461eb25493b3c38170ec23291cb0d953c6) @@ -29,6 +29,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Collection; +import java.util.Date; import java.util.GregorianCalendar; import java.util.HashSet; import java.util.LinkedList; @@ -354,9 +355,22 @@ learnerService = MonitoringServiceProxy.getLearnerService(getServlet().getServletContext()); Lesson lesson = learnerService.getLessonByActivity(scheduleGate); Calendar startingTime = new GregorianCalendar(TimeZone.getDefault()); - startingTime.setTime(lesson.getStartDateTime()); - startingTime.add(Calendar.MINUTE, scheduleGate.getGateStartTimeOffset().intValue()); - gateForm.set("startingTime", startingTime.getTime()); + Date lessonStartTime = lesson.getStartDateTime(); + if (lessonStartTime == null && Lesson.NOT_STARTED_STATE.equals(lesson.getLessonStateId())) { + // Assume the lesson will start at the scheduled time + lessonStartTime = lesson.getScheduleStartDate(); + } + if (lessonStartTime != null) { + startingTime.setTime(lessonStartTime); + startingTime.add(Calendar.MINUTE, scheduleGate.getGateStartTimeOffset().intValue()); + gateForm.set("startingTime", startingTime.getTime()); + } else { + log.error(new StringBuilder( + "Unable to calculate schedule gate opening time as we are missing the lesson starting time. Schedule gate ") + .append(scheduleGate).append(" lesson ").append(lesson.getLessonId()).append(" status ") + .append(lesson.getLessonStateId()).toString()); + gateForm.set("startingTime", null); + } } return mapping.findForward(GateAction.VIEW_SCHEDULE_GATE); Index: lams_monitoring/web/gate/scheduleGateContent.jsp =================================================================== diff -u -r225d293907a5e2976e367ee3aa790239bad38699 -r33c320461eb25493b3c38170ec23291cb0d953c6 --- lams_monitoring/web/gate/scheduleGateContent.jsp (.../scheduleGateContent.jsp) (revision 225d293907a5e2976e367ee3aa790239bad38699) +++ lams_monitoring/web/gate/scheduleGateContent.jsp (.../scheduleGateContent.jsp) (revision 33c320461eb25493b3c38170ec23291cb0d953c6) @@ -86,7 +86,7 @@ -

+