Index: lams_monitoring/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r2a0ac10fbc2946f7b4a70504cda4b72a761a4679 -r2a41cf4278b6f1becbc45e7708b6c8e4b2116e41 --- lams_monitoring/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 2a0ac10fbc2946f7b4a70504cda4b72a761a4679) +++ lams_monitoring/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 2a41cf4278b6f1becbc45e7708b6c8e4b2116e41) @@ -405,6 +405,6 @@ tour.progress.email.confure.content =Set up the dates to automatically send emails with a summary of learners progress to all monitors for this lesson. error.date.in.past =Selected date is in the past. -audit.lesson.removed =Lesson "{0}" ({1}) status changed to removed. audit.lesson.removed.permanently =Lesson "{0}" ({1}) removed permanently. +audit.lesson.status.changed=Lesson "{0}" ({1}) status changed from "{2}" to "{3}" #======= End labels: Exported 398 labels for en AU ===== Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== diff -u -r2a0ac10fbc2946f7b4a70504cda4b72a761a4679 -r2a41cf4278b6f1becbc45e7708b6c8e4b2116e41 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 2a0ac10fbc2946f7b4a70504cda4b72a761a4679) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 2a41cf4278b6f1becbc45e7708b6c8e4b2116e41) @@ -147,6 +147,7 @@ private static final String AUDIT_LESSON_CREATED_KEY = "audit.lesson.created"; private static final String AUDIT_LESSON_REMOVED_KEY = "audit.lesson.removed"; private static final String AUDIT_LESSON_REMOVED_PERMANENTLY_KEY = "audit.lesson.removed.permanently"; + private static final String AUDIT_LESSON_STATUS_CHANGED = "audit.lesson.status.changed"; private ILessonDAO lessonDAO; @@ -386,6 +387,7 @@ forceLearnerRestart, allowLearnerRestart, scheduledNumberDaysToLessonFinish, precedingLesson); Long initializedLearningDesignId = initializedLesson.getLearningDesign().getLearningDesignId(); + auditLogLessonStateChange(initializedLesson,null, initializedLesson.getLessonStateId()); logEventService.logEvent(LogEvent.TYPE_TEACHER_LESSON_CREATE, userID, initializedLearningDesignId, initializedLesson.getLessonId(), null); @@ -667,6 +669,7 @@ if (MonitoringService.log.isDebugEnabled()) { MonitoringService.log.debug("=============Lesson " + lessonId + " started==============="); } + auditLogLessonStateChange(requestedLesson,null, requestedLesson.getLessonStateId()); logEventService.logEvent(LogEvent.TYPE_TEACHER_LESSON_START, userId, null, lessonId, null); } @@ -814,13 +817,41 @@ * @param status */ private void setLessonState(Lesson requestedLesson, Integer status) { + auditLogLessonStateChange(requestedLesson, requestedLesson.getLessonStateId(), status); requestedLesson.setPreviousLessonStateId(requestedLesson.getLessonStateId()); requestedLesson.setLessonStateId(status); lessonDAO.updateLesson(requestedLesson); logEventService.logEvent(LogEvent.TYPE_TEACHER_LESSON_CHANGE_STATE, requestedLesson.getUser().getUserId(), null, requestedLesson.getLessonId(), null); } + private void auditLogLessonStateChange(Lesson lesson, Integer previousStatus, Integer newStatus) { + String fromState = getStateDescription(previousStatus); + String toState = getStateDescription(newStatus); + writeAuditLog(MonitoringService.AUDIT_LESSON_STATUS_CHANGED, + new Object[] { lesson.getLessonName(), lesson.getLessonId(), fromState, toState }); + } + + private String getStateDescription(Integer status) { + if (status != null) { + if (status.equals(Lesson.CREATED)) + return messageService.getMessage("lesson.state.created"); + if (status.equals(Lesson.NOT_STARTED_STATE)) + return messageService.getMessage("lesson.state.scheduled"); + if (status.equals(Lesson.STARTED_STATE)) + return messageService.getMessage("lesson.state.started"); + if (status.equals(Lesson.SUSPENDED_STATE)) + return messageService.getMessage("lesson.state.suspended"); + if (status.equals(Lesson.FINISHED_STATE)) + return messageService.getMessage("lesson.state.finished"); + if (status.equals(Lesson.ARCHIVED_STATE)) + return messageService.getMessage("lesson.state.archived"); + if (status.equals(Lesson.REMOVED_STATE)) + return messageService.getMessage("lesson.state.removed"); + } + return "-"; + } + /** * Sets a lesson back to its previous state. Used when we "unsuspend" or "unarchive" * @@ -829,37 +860,46 @@ */ private void revertLessonState(Lesson requestedLesson) { Integer currentStatus = requestedLesson.getLessonStateId(); + Integer newStatus; if (requestedLesson.getPreviousLessonStateId() != null) { if (requestedLesson.getPreviousLessonStateId().equals(Lesson.NOT_STARTED_STATE) && requestedLesson.getScheduleStartDate().before(new Date())) { requestedLesson.setLessonStateId(Lesson.STARTED_STATE); + newStatus = Lesson.STARTED_STATE; } else { requestedLesson.setLessonStateId(requestedLesson.getPreviousLessonStateId()); + newStatus = requestedLesson.getPreviousLessonStateId(); } requestedLesson.setPreviousLessonStateId(null); } else { if ((requestedLesson.getStartDateTime() != null) && (requestedLesson.getScheduleStartDate() != null)) { requestedLesson.setLessonStateId(Lesson.STARTED_STATE); + newStatus = Lesson.STARTED_STATE; } else if (requestedLesson.getScheduleStartDate() != null) { if (requestedLesson.getScheduleStartDate().after(new Date())) { requestedLesson.setLessonStateId(Lesson.NOT_STARTED_STATE); + newStatus = Lesson.NOT_STARTED_STATE; } else { requestedLesson.setLessonStateId(Lesson.STARTED_STATE); + newStatus = Lesson.STARTED_STATE; } } else if (requestedLesson.getStartDateTime() != null) { requestedLesson.setLessonStateId(Lesson.STARTED_STATE); + newStatus = Lesson.STARTED_STATE; } else { requestedLesson.setLessonStateId(Lesson.CREATED); + newStatus = Lesson.CREATED; } requestedLesson.setPreviousLessonStateId(currentStatus); } lessonDAO.updateLesson(requestedLesson); + auditLogLessonStateChange(requestedLesson,currentStatus, newStatus); logEventService.logEvent(LogEvent.TYPE_TEACHER_LESSON_CHANGE_STATE, requestedLesson.getUser().getUserId(), null, requestedLesson.getLessonId(), null); } @@ -869,9 +909,6 @@ securityService.isLessonMonitor(lessonId, userId, "remove lesson", true); Lesson requestedLesson = lessonDAO.getLesson(new Long(lessonId)); setLessonState(requestedLesson, Lesson.REMOVED_STATE); - - writeAuditLog(MonitoringService.AUDIT_LESSON_REMOVED_KEY, - new Object[] { requestedLesson.getLessonName(), requestedLesson.getLessonId() }); } @SuppressWarnings("unchecked")