Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r471b903caa3365758fbdec0a22440b1b0b3f2947 -r7e7ebcac9617605be0b38b6b43e5a3488732d8b0 Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java =================================================================== diff -u -r9d95acc370aaf50efff1ff08f51751cffd302604 -r7e7ebcac9617605be0b38b6b43e5a3488732d8b0 --- lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision 9d95acc370aaf50efff1ff08f51751cffd302604) +++ lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision 7e7ebcac9617605be0b38b6b43e5a3488732d8b0) @@ -63,6 +63,7 @@ import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.CentralConstants; +import org.lamsfoundation.lams.util.CommonConstants; import org.lamsfoundation.lams.util.DateUtil; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.session.SessionManager; @@ -1312,9 +1313,9 @@ boolean hasNumericToolOutput = false; for (ToolActivity activity : activities) { String toolSignature = activity.getTool().getToolSignature(); - hasNumericToolOutput |= CentralConstants.TOOL_SIGNATURE_ASSESSMENT.equals(toolSignature) - || CentralConstants.TOOL_SIGNATURE_MCQ.equals(toolSignature) - || CentralConstants.TOOL_SIGNATURE_SCRATCHIE.equals(toolSignature); + hasNumericToolOutput |= CommonConstants.TOOL_SIGNATURE_ASSESSMENT.equals(toolSignature) + || CommonConstants.TOOL_SIGNATURE_MCQ.equals(toolSignature) + || CommonConstants.TOOL_SIGNATURE_SCRATCHIE.equals(toolSignature); } // Create the root node of the xml document Index: lams_common/src/java/org/lamsfoundation/lams/questions/QuestionExporter.java =================================================================== diff -u -r680618a9fdce78c912bed8d720fbd169519e2c40 -r7e7ebcac9617605be0b38b6b43e5a3488732d8b0 --- lams_common/src/java/org/lamsfoundation/lams/questions/QuestionExporter.java (.../QuestionExporter.java) (revision 680618a9fdce78c912bed8d720fbd169519e2c40) +++ lams_common/src/java/org/lamsfoundation/lams/questions/QuestionExporter.java (.../QuestionExporter.java) (revision 7e7ebcac9617605be0b38b6b43e5a3488732d8b0) @@ -41,7 +41,7 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.lamsfoundation.lams.util.CentralConstants; +import org.lamsfoundation.lams.util.CommonConstants; import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.FileUtil; @@ -100,9 +100,9 @@ try { String fileName = FileUtil.getFileName(packagePath); fileName = FileUtil.encodeFilenameForDownload(request, fileName); - response.setContentType(CentralConstants.RESPONSE_CONTENT_TYPE_DOWNLOAD); - response.setHeader(CentralConstants.HEADER_CONTENT_DISPOSITION, - CentralConstants.HEADER_CONTENT_ATTACHMENT + fileName); + response.setContentType(CommonConstants.RESPONSE_CONTENT_TYPE_DOWNLOAD); + response.setHeader(CommonConstants.HEADER_CONTENT_DISPOSITION, + CommonConstants.HEADER_CONTENT_ATTACHMENT + fileName); // write out the ZIP to respose error FileUtils.copyFile(packageFile, response.getOutputStream()); Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== diff -u -r33c320461eb25493b3c38170ec23291cb0d953c6 -r7e7ebcac9617605be0b38b6b43e5a3488732d8b0 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 33c320461eb25493b3c38170ec23291cb0d953c6) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 7e7ebcac9617605be0b38b6b43e5a3488732d8b0) @@ -49,12 +49,11 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.log4j.Logger; -import org.lamsfoundation.lams.authoring.service.IAuthoringService; +import org.lamsfoundation.lams.authoring.IAuthoringService; import org.lamsfoundation.lams.dao.IBaseDAO; import org.lamsfoundation.lams.events.EmailNotificationArchive; import org.lamsfoundation.lams.events.dao.EventDAO; -import org.lamsfoundation.lams.learning.service.ICoreLearnerService; -import org.lamsfoundation.lams.learning.web.bean.GateActivityDTO; +import org.lamsfoundation.lams.learning.service.ILearnerService; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.BranchActivityEntry; import org.lamsfoundation.lams.learningdesign.BranchCondition; @@ -75,6 +74,7 @@ import org.lamsfoundation.lams.learningdesign.dao.IGroupUserDAO; import org.lamsfoundation.lams.learningdesign.dao.IGroupingDAO; import org.lamsfoundation.lams.learningdesign.dao.ILearningDesignDAO; +import org.lamsfoundation.lams.learningdesign.dto.GateActivityDTO; import org.lamsfoundation.lams.lesson.CompletedActivityProgress; import org.lamsfoundation.lams.lesson.LearnerProgress; import org.lamsfoundation.lams.lesson.Lesson; @@ -141,7 +141,7 @@ * @since 2/02/2005 * @version 1.1 */ -public class MonitoringService implements IMonitoringService { +public class MonitoringService implements IMonitoringFullService { // --------------------------------------------------------------------- // Instance variables @@ -175,7 +175,7 @@ private IAuthoringService authoringService; - private ICoreLearnerService learnerService; + private ILearnerService learnerService; private ILessonService lessonService; @@ -247,7 +247,7 @@ * * @param learnerService */ - public void setLearnerService(ICoreLearnerService learnerService) { + public void setLearnerService(ILearnerService learnerService) { this.learnerService = learnerService; } @@ -365,7 +365,7 @@ securityService.isGroupMonitor(organisationId, userID, "intializeLesson", true); - LearningDesign originalLearningDesign = authoringService.getLearningDesign(new Long(learningDesignId)); + LearningDesign originalLearningDesign = learningDesignDAO.getLearningDesignById(new Long(learningDesignId)); if (originalLearningDesign == null) { throw new MonitoringServiceException( "Learning design for id=" + learningDesignId + " is missing. Unable to initialize lesson."); @@ -403,7 +403,7 @@ public Lesson initializeLessonForPreview(String lessonName, String lessonDescription, long learningDesignId, Integer userID, String customCSV, Boolean learnerPresenceAvailable, Boolean learnerImAvailable, Boolean liveEditEnabled) { - LearningDesign originalLearningDesign = authoringService.getLearningDesign(new Long(learningDesignId)); + LearningDesign originalLearningDesign = learningDesignDAO.getLearningDesignById(new Long(learningDesignId)); if (originalLearningDesign == null) { throw new MonitoringServiceException( "Learning design for id=" + learningDesignId + " is missing. Unable to initialize lesson."); @@ -421,7 +421,7 @@ Boolean learnerPresenceAvailable, Boolean learnerImAvailable, Boolean liveEditEnabled, Boolean enableLessonNotifications, Boolean forceLearnerRestart, Boolean allowLearnerRestart, Boolean gradebookOnComplete, Integer scheduledNumberDaysToLessonFinish, Lesson precedingLesson) { - LearningDesign learningDesign = authoringService.getLearningDesign(learningDesignID); + LearningDesign learningDesign = learningDesignDAO.getLearningDesignById(learningDesignID); if (learningDesign == null) { throw new MonitoringServiceException( "Learning design for id=" + learningDesignID + " is missing. Unable to initialize lesson."); @@ -445,7 +445,7 @@ // copy the current learning design LearningDesign copiedLearningDesign = authoringService.copyLearningDesign(originalLearningDesign, new Integer(copyType), user, workspaceFolder, true, null, customCSV); - authoringService.saveLearningDesign(copiedLearningDesign); + learningDesignDAO.insertOrUpdate(copiedLearningDesign); // Make all efforts to make sure it has a title String title = lessonName != null ? lessonName : copiedLearningDesign.getTitle(); @@ -777,8 +777,25 @@ return newMaxId; } - @Override - public ScheduleGateActivity runGateScheduler(ScheduleGateActivity scheduleGate, Date schedulingStartTime, + /** + *

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

+ *
  • 1. Initialize the resource needed by scheduling job by setting them into the job data map.
  • + *
  • 2. Create customized triggers for the scheduling.
  • + *
  • 3. start the scheduling job
  • + * + * @param scheduleGate + * the gate that needs to be scheduled. + * @param schedulingStartTime + * the time on which the gate open should be based if an offset is used. For starting a lesson, this is + * the lessonStartTime. For live edit, it is now. + * @param lessonName + * the name lesson incorporating this gate - used for the description of the Quartz job. Optional. + * @returns An updated gate, that should be saved by the calling code. + */ + private ScheduleGateActivity runGateScheduler(ScheduleGateActivity scheduleGate, Date schedulingStartTime, String lessonName) { if (MonitoringService.log.isDebugEnabled()) { MonitoringService.log.debug("Running scheduler for gate " + scheduleGate.getActivityId() + "..."); @@ -909,13 +926,6 @@ } @Override - public void finishLesson(long lessonId, Integer userId) { - securityService.isLessonMonitor(lessonId, userId, "finish lesson", true); - Lesson requestedLesson = lessonDAO.getLesson(new Long(lessonId)); - setLessonState(requestedLesson, Lesson.FINISHED_STATE, userId); - } - - @Override public void archiveLesson(long lessonId, Integer userId) { securityService.isLessonMonitor(lessonId, userId, "archive lesson", true); Lesson requestedLesson = lessonDAO.getLesson(new Long(lessonId)); @@ -1190,15 +1200,6 @@ } @Override - public Boolean toggleLiveEditEnabled(long lessonId, Integer userId, Boolean liveEditEnabled) { - securityService.isLessonMonitor(lessonId, userId, "set live edit available", true); - Lesson requestedLesson = lessonDAO.getLesson(new Long(lessonId)); - requestedLesson.setLiveEditEnabled(liveEditEnabled != null ? liveEditEnabled : Boolean.FALSE); - lessonDAO.updateLesson(requestedLesson); - return requestedLesson.getLiveEditEnabled(); - } - - @Override public Boolean toggleGradebookOnComplete(long lessonId, Integer userId, Boolean gradebookOnComplete) { securityService.isLessonMonitor(lessonId, userId, "set gradebook on complete", true); Lesson requestedLesson = lessonDAO.getLesson(new Long(lessonId)); @@ -1792,11 +1793,10 @@ break; case MonitoringConstants.COURSE_TYPE_HAVENT_STARTED_ANY_LESSONS: - List allUSers = learnerService.getUserManagementService().getUsersFromOrganisation(orgId); + List allUSers = userManagementService.getUsersFromOrganisation(orgId); Set usersStartedAtLest1Lesson = new TreeSet(); - Organisation org = (Organisation) learnerService.getUserManagementService().findById(Organisation.class, - orgId); + Organisation org = getOrganisation(orgId); Set lessons = org.getLessons(); for (Lesson les : lessons) { Activity firstActivity = les.getLearningDesign().getFirstActivity(); @@ -2371,8 +2371,16 @@ lessonService.removeLearnersFromGroup(grouping, groupId, learners); } - @Override - public void removeUsersFromBranch(Long sequenceActivityID, String learnerIDs[]) throws LessonServiceException { + /** + * Remove learners from a branch. Assumes there should only be one group for this branch. Use for Teacher Chosen + * Branching. Don't use for Group Based Branching as there could be more than one group for the branch. + * + * @param sequenceActivityID + * Activity id of the sequenceActivity representing this branch + * @param learnerIDs + * the IDS of the learners to be added. + */ + private void removeUsersFromBranch(Long sequenceActivityID, String learnerIDs[]) throws LessonServiceException { SequenceActivity branch = (SequenceActivity) getActivityById(sequenceActivityID); if (branch == null) { Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GateAction.java =================================================================== diff -u -r471b903caa3365758fbdec0a22440b1b0b3f2947 -r7e7ebcac9617605be0b38b6b43e5a3488732d8b0 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GateAction.java (.../GateAction.java) (revision 471b903caa3365758fbdec0a22440b1b0b3f2947) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GateAction.java (.../GateAction.java) (revision 7e7ebcac9617605be0b38b6b43e5a3488732d8b0) @@ -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; @@ -345,9 +346,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);