Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== diff -u -r5423c7eb88d56574ab07ec891ab2eccdcc3e582c -r75765d2caf035efe57e40cad41337756253d488f --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 5423c7eb88d56574ab07ec891ab2eccdcc3e582c) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 75765d2caf035efe57e40cad41337756253d488f) @@ -761,8 +761,15 @@ public void archiveLesson(long lessonId, Integer userId) { securityService.isLessonMonitor(lessonId, userId, "archive lesson", true); Lesson requestedLesson = lessonDAO.getLesson(new Long(lessonId)); - if (!Lesson.ARCHIVED_STATE.equals(requestedLesson.getLessonStateId()) - && !Lesson.REMOVED_STATE.equals(requestedLesson.getLessonStateId())) { + Integer lessonState = requestedLesson.getLessonStateId(); + + // if lesson has 'suspended'('disabled') state - then unsuspend it first so its previous lesson state will be 'started' + if (Lesson.SUSPENDED_STATE.equals(lessonState)) { + unsuspendLesson(lessonId, userId); + } + + if (!Lesson.ARCHIVED_STATE.equals(lessonState) + && !Lesson.REMOVED_STATE.equals(lessonState)) { setLessonState(requestedLesson, Lesson.ARCHIVED_STATE); } } @@ -818,17 +825,21 @@ */ private void revertLessonState(Lesson requestedLesson) { Integer currentStatus = requestedLesson.getLessonStateId(); + if (requestedLesson.getPreviousLessonStateId() != null) { if (requestedLesson.getPreviousLessonStateId().equals(Lesson.NOT_STARTED_STATE) && requestedLesson.getScheduleStartDate().before(new Date())) { requestedLesson.setLessonStateId(Lesson.STARTED_STATE); + } else { requestedLesson.setLessonStateId(requestedLesson.getPreviousLessonStateId()); } requestedLesson.setPreviousLessonStateId(null); + } else { if ((requestedLesson.getStartDateTime() != null) && (requestedLesson.getScheduleStartDate() != null)) { requestedLesson.setLessonStateId(Lesson.STARTED_STATE); + } else if (requestedLesson.getScheduleStartDate() != null) { if (requestedLesson.getScheduleStartDate().after(new Date())) { requestedLesson.setLessonStateId(Lesson.NOT_STARTED_STATE); Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java =================================================================== diff -u -rd4e1329ceddfff71050bbef8bc1d30d65ffcf652 -r75765d2caf035efe57e40cad41337756253d488f --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision d4e1329ceddfff71050bbef8bc1d30d65ffcf652) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 75765d2caf035efe57e40cad41337756253d488f) @@ -210,19 +210,7 @@ * The Struts dispatch method that starts a lesson that has been created beforehand. Most likely, the request to * start lesson should be triggered by the Monitoring This method will delegate to the Spring service bean to * complete all the steps for starting a lesson. - * - * @param mapping - * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to send - * the end-user. - * - * @param form - * The ActionForm class that will contain any data submitted by the end-user via a form. - * @param request - * A standard Servlet HttpServletRequest class. - * @param response - * A standard Servlet HttpServletResponse class. - * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go - * next. + * * @throws IOException * @throws ServletException */ @@ -431,19 +419,7 @@ /** * The Struts dispatch method to archive a lesson. - * - * @param mapping - * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to send - * the end-user. - * - * @param form - * The ActionForm class that will contain any data submitted by the end-user via a form. - * @param request - * A standard Servlet HttpServletRequest class. - * @param response - * A standard Servlet HttpServletResponse class. - * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go - * next. + * * @throws IOException * @throws ServletException */ @@ -452,28 +428,17 @@ long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); try { - getMonitoringService().unsuspendLesson(lessonId, getUserId()); - } catch (SecurityException e) { getMonitoringService().archiveLesson(lessonId, getUserId()); + } catch (SecurityException e) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a monitor in the lesson"); } + return null; } /** * The Struts dispatch method to "unarchive" a lesson. Returns it back to its previous state. - * - * @param mapping - * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to send - * the end-user. - * - * @param form - * The ActionForm class that will contain any data submitted by the end-user via a form. - * @param request - * A standard Servlet HttpServletRequest class. - * @param response - * A standard Servlet HttpServletResponse class. - * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go - * next. + * * @throws IOException * @throws ServletException */ @@ -543,15 +508,7 @@ *
* This action need a lession ID as input. *
- * - * @param form - * The ActionForm class that will contain any data submitted by the end-user via a form. - * @param request - * A standard Servlet HttpServletRequest class. - * @param response - * A standard Servlet HttpServletResponse class. - * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go - * next. + * * @throws IOException * @throws ServletException */ @@ -595,9 +552,7 @@ * * @param form * @param request - * A standard Servlet HttpServletRequest class. * @param response - * A standard Servlet HttpServletResponse class. * @return An ActionForward * @throws IOException * @throws ServletException Index: lams_monitoring/web/includes/javascript/monitorLesson.js =================================================================== diff -u -r9b811cd9e0991c64e1704b374b99811c181297e5 -r75765d2caf035efe57e40cad41337756253d488f --- lams_monitoring/web/includes/javascript/monitorLesson.js (.../monitorLesson.js) (revision 9b811cd9e0991c64e1704b374b99811c181297e5) +++ lams_monitoring/web/includes/javascript/monitorLesson.js (.../monitorLesson.js) (revision 75765d2caf035efe57e40cad41337756253d488f) @@ -172,9 +172,13 @@ */ function changeLessonState(){ var method = null; + + //state chosen in the dropdown menu var state = +$('#lessonStateField').val(); switch (state) { - case 3: //STARTED + + //'activate' is chosen + case 3: switch (lessonStateId) { case 4: //SUSPENDED method = "unsuspendLesson"; @@ -184,13 +188,19 @@ break; } break; + + //'disable' is chosen case 4: method = "suspendLesson"; break; + + //'archive' is chosen case 6: method = "archiveLesson"; break; - case 7: //FINISHED + + //'remove' is chosen + case 7: if (confirm(LABELS.LESSON_REMOVE_ALERT)){ if (confirm(LABELS.LESSON_REMOVE_DOUBLECHECK_ALERT)) { method = "removeLesson"; Index: lams_monitoring/web/monitor.jsp =================================================================== diff -u -rb3e9762e1d505c170ec93179a506adcec6ef03f0 -r75765d2caf035efe57e40cad41337756253d488f --- lams_monitoring/web/monitor.jsp (.../monitor.jsp) (revision b3e9762e1d505c170ec93179a506adcec6ef03f0) +++ lams_monitoring/web/monitor.jsp (.../monitor.jsp) (revision 75765d2caf035efe57e40cad41337756253d488f) @@ -256,39 +256,41 @@