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.195.2.40 -r1.195.2.41 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 2 Mar 2017 10:33:31 -0000 1.195.2.40 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 10 Mar 2017 10:35:10 -0000 1.195.2.41 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java,v diff -u -r1.118.2.55 -r1.118.2.56 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java 6 Feb 2017 11:16:10 -0000 1.118.2.55 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java 10 Mar 2017 10:35:10 -0000 1.118.2.56 @@ -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/monitor.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/web/monitor.jsp,v diff -u -r1.27.2.44 -r1.27.2.45 --- lams_monitoring/web/monitor.jsp 20 Dec 2016 12:20:33 -0000 1.27.2.44 +++ lams_monitoring/web/monitor.jsp 10 Mar 2017 10:35:10 -0000 1.27.2.45 @@ -256,39 +256,41 @@
-
-
-
- - - - - - - - - -
-
-
+
+
+
+ + + + + + + + + +
+
+
+
+ -
+ onClick="javascript:changeLessonState()" + title=''> + + +
- +
:
Index: lams_monitoring/web/includes/javascript/monitorLesson.js =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/web/includes/javascript/monitorLesson.js,v diff -u -r1.44.2.57 -r1.44.2.58 --- lams_monitoring/web/includes/javascript/monitorLesson.js 20 Dec 2016 09:47:40 -0000 1.44.2.57 +++ lams_monitoring/web/includes/javascript/monitorLesson.js 10 Mar 2017 10:35:10 -0000 1.44.2.58 @@ -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";