Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
diff -u -rcc06a4607a9719604c6036369062bb40df272be7 -r0a29fecdac875617ddbb0f0dda8d098e63991c50
--- lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision cc06a4607a9719604c6036369062bb40df272be7)
+++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 0a29fecdac875617ddbb0f0dda8d098e63991c50)
@@ -351,6 +351,8 @@
label.instructions =Lesson instructions
label.cancel =Cancel
label.display.lesson.design =Display learning design image?
+index.remove.lesson.confirm1 =You are about to remove this lesson. Are you sure?
+index.remove.lesson.confirm2 =Once you remove this lesson you CANNOT bring it back. Are you positive that you want to remove this lesson?
#======= End labels: Exported 345 labels for en AU =====
Index: lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java
===================================================================
diff -u -rff3bd28c7a274dd7d1bc46152ae5900166edac8c -r0a29fecdac875617ddbb0f0dda8d098e63991c50
--- lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java (.../DisplayGroupAction.java) (revision ff3bd28c7a274dd7d1bc46152ae5900166edac8c)
+++ lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java (.../DisplayGroupAction.java) (revision 0a29fecdac875617ddbb0f0dda8d098e63991c50)
@@ -391,6 +391,13 @@
lessonLinks.add(new IndexLinkBean("index.conditions", conditionsLink, "thickbox" + orgId,
"mycourses-conditions-img", "index.conditions.tooltip"));
}
+
+ // Add delete lesson option
+ if (isGroupManagerOrMonitor) {
+ String removeLessonLink = "javascript:removeLesson(" + bean.getId() + ")";
+ lessonLinks.add(new IndexLinkBean("index.remove.lesson", removeLessonLink, null,
+ "mycourses-removelesson-img", "index.remove.lesson.tooltip"));
+ }
if (lessonLinks.size() > 0) {
bean.setLinks(lessonLinks);
Index: lams_central/web/main.jsp
===================================================================
diff -u -rc0ae190cb1f4081bcf86fa46b07d1cbbd43ce250 -r0a29fecdac875617ddbb0f0dda8d098e63991c50
--- lams_central/web/main.jsp (.../main.jsp) (revision c0ae190cb1f4081bcf86fa46b07d1cbbd43ce250)
+++ lams_central/web/main.jsp (.../main.jsp) (revision 0a29fecdac875617ddbb0f0dda8d098e63991c50)
@@ -76,6 +76,28 @@
});
});
+ function removeLesson(lessonID) {
+
+ if (confirm("
* The action servlet that provide all the monitoring functionalities. It interact with the teacher via flash and JSP @@ -78,352 +79,344 @@ * @struts.action-forward name = "notsupported" path = ".notsupported" * @struts.action-forward name = "timeChart" path = "/timeChart.jsp" * - * ----------------XDoclet Tags-------------------- + * ----------------XDoclet Tags-------------------- */ -public class MonitoringAction extends LamsDispatchAction -{ - - //--------------------------------------------------------------------- +public class MonitoringAction extends LamsDispatchAction { + + // --------------------------------------------------------------------- // Instance variables - //--------------------------------------------------------------------- - - //--------------------------------------------------------------------- + // --------------------------------------------------------------------- + + // --------------------------------------------------------------------- // Class level constants - Struts forward - //--------------------------------------------------------------------- - private static final String PREVIEW_DELETED_REPORT_SCREEN = "previewdeleted"; - private static final String NOT_SUPPORTED_SCREEN = "notsupported"; - private static final String TIME_CHART_SCREEN = "timeChart"; - private static final String ERROR = "error"; - - /** See deleteOldPreviewLessons */ - public static final String NUM_DELETED = "numDeleted"; - - private static IAuditService auditService; - - private static ITimezoneService timezoneService; + // --------------------------------------------------------------------- + private static final String PREVIEW_DELETED_REPORT_SCREEN = "previewdeleted"; + private static final String NOT_SUPPORTED_SCREEN = "notsupported"; + private static final String TIME_CHART_SCREEN = "timeChart"; + private static final String ERROR = "error"; - private Integer getUserId() { - HttpSession ss = SessionManager.getSession(); - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - return user != null ? user.getUserID() : null; + /** See deleteOldPreviewLessons */ + public static final String NUM_DELETED = "numDeleted"; + + private static IAuditService auditService; + + private static ITimezoneService timezoneService; + + private Integer getUserId() { + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + return user != null ? user.getUserID() : null; + } + + private FlashMessage handleException(Exception e, String methodKey, IMonitoringService monitoringService) { + log.error("Exception thrown " + methodKey, e); + auditService = getAuditService(); + auditService.log(MonitoringAction.class.getName() + ":" + methodKey, e.toString()); + + if (e instanceof UserAccessDeniedException) { + return new FlashMessage(methodKey, monitoringService.getMessageService().getMessage( + "error.user.noprivilege"), FlashMessage.ERROR); + } else { + String[] msg = new String[1]; + msg[0] = e.getMessage(); + return new FlashMessage(methodKey, monitoringService.getMessageService().getMessage("error.system.error", + msg), FlashMessage.CRITICAL_ERROR); } - - private FlashMessage handleException(Exception e, String methodKey, IMonitoringService monitoringService) { - log.error("Exception thrown "+methodKey,e); - auditService = getAuditService(); - auditService.log(MonitoringAction.class.getName()+":"+methodKey, e.toString()); - - if ( e instanceof UserAccessDeniedException ) { - return new FlashMessage(methodKey, - monitoringService.getMessageService().getMessage("error.user.noprivilege"), - FlashMessage.ERROR); - } else { - String[] msg = new String[1]; - msg[0] = e.getMessage(); - return new FlashMessage(methodKey, - monitoringService.getMessageService().getMessage("error.system.error", msg), - FlashMessage.CRITICAL_ERROR); - } - } - - private FlashMessage handleCriticalError(String methodKey, String messageKey, IMonitoringService monitoringService) { - String message = monitoringService.getMessageService().getMessage(messageKey); - log.error("Error occured "+methodKey+" error "); - auditService = getAuditService(); - auditService.log(MonitoringAction.class.getName()+":"+methodKey, message); - - return new FlashMessage(methodKey, - message, - FlashMessage.CRITICAL_ERROR); - } - - private ActionForward redirectToURL(ActionMapping mapping, HttpServletResponse response, String url) throws IOException { - if ( url != null ) { - String fullURL = WebUtil.convertToFullURL(url); - response.sendRedirect(response.encodeRedirectURL(fullURL)); - return null; - } else { - return mapping.findForward(NOT_SUPPORTED_SCREEN); - } - } + } - //--------------------------------------------------------------------- + private FlashMessage handleCriticalError(String methodKey, String messageKey, IMonitoringService monitoringService) { + String message = monitoringService.getMessageService().getMessage(messageKey); + log.error("Error occured " + methodKey + " error "); + auditService = getAuditService(); + auditService.log(MonitoringAction.class.getName() + ":" + methodKey, message); + + return new FlashMessage(methodKey, message, FlashMessage.CRITICAL_ERROR); + } + + private ActionForward redirectToURL(ActionMapping mapping, HttpServletResponse response, String url) + throws IOException { + if (url != null) { + String fullURL = WebUtil.convertToFullURL(url); + response.sendRedirect(response.encodeRedirectURL(fullURL)); + return null; + } else { + return mapping.findForward(NOT_SUPPORTED_SCREEN); + } + } + + // --------------------------------------------------------------------- // Struts Dispatch Method - //--------------------------------------------------------------------- + // --------------------------------------------------------------------- /** - * This STRUTS action method will initialize a lesson for specific learning design with the given lesson title - * and lesson description.
+ * This STRUTS action method will initialize a lesson for specific learning design with the given lesson title and + * lesson description. + *
* If initialization is successed, this method will return a WDDX message which includes the ID of new 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. + * @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 * @deprecated */ - public ActionForward initializeLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { + public ActionForward initializeLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - FlashMessage flashMessage = null; - - try { - String title = WebUtil.readStrParam(request,"lessonName"); - if ( title == null ) title = "lesson"; - String desc = WebUtil.readStrParam(request,"lessonDescription", true); - if ( desc == null ) desc = "description"; - Integer organisationId = WebUtil.readIntParam(request,"organisationID",true); - long ldId = WebUtil.readLongParam(request, AttributeNames.PARAM_LEARNINGDESIGN_ID); - Boolean learnerExportAvailable = WebUtil.readBooleanParam(request, "learnerExportPortfolio", false); - Boolean learnerPresenceAvailable = WebUtil.readBooleanParam(request, "learnerPresenceAvailable", false); - Boolean learnerImAvailable = WebUtil.readBooleanParam(request, "learnerImAvailable", false); - Boolean liveEditEnabled = WebUtil.readBooleanParam(request, "liveEditEnabled", false); - Lesson newLesson = monitoringService.initializeLesson(title, desc, ldId, organisationId, getUserId(), null, - Boolean.FALSE, Boolean.FALSE, learnerExportAvailable, learnerPresenceAvailable, learnerImAvailable, - liveEditEnabled, Boolean.FALSE, null, null); - - flashMessage = new FlashMessage("initializeLesson",newLesson.getLessonId()); - } catch (Exception e) { - flashMessage = handleException(e, "initializeLesson", monitoringService); - } - - String message = flashMessage.serializeMessage(); - - PrintWriter writer = response.getWriter(); - writer.println(message); - return null; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + FlashMessage flashMessage = null; + + try { + String title = WebUtil.readStrParam(request, "lessonName"); + if (title == null) + title = "lesson"; + String desc = WebUtil.readStrParam(request, "lessonDescription", true); + if (desc == null) + desc = "description"; + Integer organisationId = WebUtil.readIntParam(request, "organisationID", true); + long ldId = WebUtil.readLongParam(request, AttributeNames.PARAM_LEARNINGDESIGN_ID); + Boolean learnerExportAvailable = WebUtil.readBooleanParam(request, "learnerExportPortfolio", false); + Boolean learnerPresenceAvailable = WebUtil.readBooleanParam(request, "learnerPresenceAvailable", false); + Boolean learnerImAvailable = WebUtil.readBooleanParam(request, "learnerImAvailable", false); + Boolean liveEditEnabled = WebUtil.readBooleanParam(request, "liveEditEnabled", false); + Lesson newLesson = monitoringService.initializeLesson(title, desc, ldId, organisationId, getUserId(), null, + Boolean.FALSE, Boolean.FALSE, learnerExportAvailable, learnerPresenceAvailable, learnerImAvailable, + liveEditEnabled, Boolean.FALSE, null, null); + + flashMessage = new FlashMessage("initializeLesson", newLesson.getLessonId()); + } catch (Exception e) { + flashMessage = handleException(e, "initializeLesson", monitoringService); + } + + String message = flashMessage.serializeMessage(); + + PrintWriter writer = response.getWriter(); + writer.println(message); + return null; } - /** - * 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 flash component. This method will delegate to the Spring service - * bean to complete all the steps for starting a lesson. Finally, a wddx - * acknowledgement message will be serialized and sent back to the flash - * component. + * 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 flash component. This method will delegate to the Spring service bean to + * complete all the steps for starting a lesson. Finally, a wddx acknowledgement message will be serialized and sent + * back to the flash component. * - * @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. + * @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 */ - public ActionForward startLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - FlashMessage flashMessage = null; - - try { - long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); - monitoringService.startLesson(lessonId, getUserId()); - flashMessage = new FlashMessage("startLesson",Boolean.TRUE); - } catch (Exception e) { - flashMessage = handleException(e, "startLesson", monitoringService); - } - - String message = flashMessage.serializeMessage(); - - PrintWriter writer = response.getWriter(); - writer.println(message); - return null; + public ActionForward startLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + FlashMessage flashMessage = null; + + try { + long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + monitoringService.startLesson(lessonId, getUserId()); + flashMessage = new FlashMessage("startLesson", Boolean.TRUE); + } catch (Exception e) { + flashMessage = handleException(e, "startLesson", monitoringService); + } + + String message = flashMessage.serializeMessage(); + + PrintWriter writer = response.getWriter(); + writer.println(message); + return null; } + /** - * The Struts dispatch method that starts a lesson on schedule that has been created - * beforehand. + * The Struts dispatch method that starts a lesson on schedule that has been created beforehand. * - * @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. + * @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 - * @throws + * @throws */ - public ActionForward startOnScheduleLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - FlashMessage flashMessage = null; - - try { - long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); - - String dateStr = WebUtil.readStrParam(request, MonitoringConstants.PARAM_LESSON_START_DATE); - Date startDate = DateUtil.convertFromLAMSFlashFormat(dateStr); - - monitoringService.startLessonOnSchedule(lessonId, startDate, getUserId()); - flashMessage = new FlashMessage("startOnScheduleLesson",Boolean.TRUE); - }catch (Exception e) { - flashMessage = handleException(e, "startOnScheduleLesson", monitoringService); - } - - String message = flashMessage.serializeMessage(); - - - PrintWriter writer = response.getWriter(); - writer.println(message); - return null; + public ActionForward startOnScheduleLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + FlashMessage flashMessage = null; + + try { + long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + + String dateStr = WebUtil.readStrParam(request, MonitoringConstants.PARAM_LESSON_START_DATE); + Date startDate = DateUtil.convertFromLAMSFlashFormat(dateStr); + + monitoringService.startLessonOnSchedule(lessonId, startDate, getUserId()); + flashMessage = new FlashMessage("startOnScheduleLesson", Boolean.TRUE); + } catch (Exception e) { + flashMessage = handleException(e, "startOnScheduleLesson", monitoringService); + } + + String message = flashMessage.serializeMessage(); + + PrintWriter writer = response.getWriter(); + writer.println(message); + return null; } - + /** - * The Struts dispatch method that finsh a lesson on schedule that has been started - * beforehand. + * The Struts dispatch method that finsh a lesson on schedule that has been started beforehand. * - * @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. + * @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 - * @throws + * @throws */ - public ActionForward finishOnScheduleLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - FlashMessage flashMessage = null; - - try { - long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); - int scheduledNumberDaysToLessonFinish = WebUtil.readIntParam(request, MonitoringConstants.PARAM_SCHEDULED_NUMBER_DAYS_TO_LESSON_FINISH); - monitoringService.finishLessonOnSchedule(lessonId,scheduledNumberDaysToLessonFinish,getUserId()); - flashMessage = new FlashMessage("finishOnScheduleLesson",Boolean.TRUE); - }catch (Exception e) { - flashMessage = handleException(e, "finishOnScheduleLesson", monitoringService); - } - - String message = flashMessage.serializeMessage(); - - PrintWriter writer = response.getWriter(); - writer.println(message); - return null; + public ActionForward finishOnScheduleLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + FlashMessage flashMessage = null; + + try { + long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + int scheduledNumberDaysToLessonFinish = WebUtil.readIntParam(request, + MonitoringConstants.PARAM_SCHEDULED_NUMBER_DAYS_TO_LESSON_FINISH); + monitoringService.finishLessonOnSchedule(lessonId, scheduledNumberDaysToLessonFinish, getUserId()); + flashMessage = new FlashMessage("finishOnScheduleLesson", Boolean.TRUE); + } catch (Exception e) { + flashMessage = handleException(e, "finishOnScheduleLesson", monitoringService); + } + + String message = flashMessage.serializeMessage(); + + PrintWriter writer = response.getWriter(); + writer.println(message); + return null; } - + /** - * The Struts dispatch method to archive a lesson. A wddx - * acknowledgement message will be serialized and sent back to the flash - * component. + * The Struts dispatch method to archive a lesson. A wddx acknowledgement message will be serialized and sent back + * to the flash component. * - * @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. + * @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 */ - public ActionForward archiveLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - FlashMessage flashMessage = null; - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - - try { - long lessonId = WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID); - monitoringService.archiveLesson(lessonId, getUserId()); - flashMessage = new FlashMessage("archiveLesson",Boolean.TRUE); - } catch (Exception e) { - flashMessage = handleException(e, "archiveLesson", monitoringService); - } - - String message = flashMessage.serializeMessage(); - - - PrintWriter writer = response.getWriter(); - writer.println(message); - return null; + public ActionForward archiveLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + FlashMessage flashMessage = null; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + + try { + long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + monitoringService.archiveLesson(lessonId, getUserId()); + flashMessage = new FlashMessage("archiveLesson", Boolean.TRUE); + } catch (Exception e) { + flashMessage = handleException(e, "archiveLesson", monitoringService); + } + + String message = flashMessage.serializeMessage(); + + PrintWriter writer = response.getWriter(); + writer.println(message); + return null; } + /** - * The Struts dispatch method to "unarchive" a lesson. Returns it back to - * its previous state. A wddx acknowledgement message will be serialized and sent back to the flash - * component. + * The Struts dispatch method to "unarchive" a lesson. Returns it back to its previous state. A wddx acknowledgement + * message will be serialized and sent back to the flash component. * - * @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. + * @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 */ - public ActionForward unarchiveLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - FlashMessage flashMessage = null; - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - - try { - long lessonId = WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID); - monitoringService.unarchiveLesson(lessonId, getUserId()); - flashMessage = new FlashMessage("unarchiveLesson",Boolean.TRUE); - } catch (Exception e) { - flashMessage = handleException(e, "unarchiveLesson", monitoringService); - } - - String message = flashMessage.serializeMessage(); - - PrintWriter writer = response.getWriter(); - writer.println(message); - return null; + public ActionForward unarchiveLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + FlashMessage flashMessage = null; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + + try { + long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + monitoringService.unarchiveLesson(lessonId, getUserId()); + flashMessage = new FlashMessage("unarchiveLesson", Boolean.TRUE); + } catch (Exception e) { + flashMessage = handleException(e, "unarchiveLesson", monitoringService); + } + + String message = flashMessage.serializeMessage(); + + PrintWriter writer = response.getWriter(); + writer.println(message); + return null; } + /** - * The purpose of suspending is to hide the lesson from learners temporarily. - * It doesn't make any sense to suspend a created or a not started (ie scheduled) - * lesson as they will not be shown on the learner interface anyway! If the teacher - * tries to suspend a lesson that is not in the STARTED_STATE, then an error should - * be returned to Flash. + * The purpose of suspending is to hide the lesson from learners temporarily. It doesn't make any sense to suspend a + * created or a not started (ie scheduled) lesson as they will not be shown on the learner interface anyway! If the + * teacher tries to suspend a lesson that is not in the STARTED_STATE, then an error should be returned to Flash. * * @param mapping * @param form @@ -433,33 +426,30 @@ * @throws IOException * @throws ServletException */ - public ActionForward suspendLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - FlashMessage flashMessage = null; - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - - try { - long lessonId = WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID); - monitoringService.suspendLesson(lessonId, getUserId()); - flashMessage = new FlashMessage("suspendLesson",Boolean.TRUE); - } catch (Exception e) { - flashMessage = handleException(e, "suspendLesson", monitoringService); - } - - String message = flashMessage.serializeMessage(); - - - PrintWriter writer = response.getWriter(); - writer.println(message); - return null; - } + public ActionForward suspendLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + FlashMessage flashMessage = null; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + + try { + long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + monitoringService.suspendLesson(lessonId, getUserId()); + flashMessage = new FlashMessage("suspendLesson", Boolean.TRUE); + } catch (Exception e) { + flashMessage = handleException(e, "suspendLesson", monitoringService); + } + + String message = flashMessage.serializeMessage(); + + PrintWriter writer = response.getWriter(); + writer.println(message); + return null; + } + /** - * Unsuspend a lesson which state must be Lesson.SUPSENDED_STATE. Otherwise a error message will return to - * flash client. + * Unsuspend a lesson which state must be Lesson.SUPSENDED_STATE. Otherwise a error message will return to flash + * client. * * @param mapping * @param form @@ -469,304 +459,342 @@ * @throws IOException * @throws ServletException */ - public ActionForward unsuspendLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - FlashMessage flashMessage = null; - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - - try { - long lessonId = WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID); - monitoringService.unsuspendLesson(lessonId, getUserId()); - flashMessage = new FlashMessage("unsuspendLesson",Boolean.TRUE); - } catch (Exception e) { - flashMessage = handleException(e, "unsuspendLesson", monitoringService); - } - - String message = flashMessage.serializeMessage(); - - PrintWriter writer = response.getWriter(); - writer.println(message); - return null; - } + public ActionForward unsuspendLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + FlashMessage flashMessage = null; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + + try { + long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + monitoringService.unsuspendLesson(lessonId, getUserId()); + flashMessage = new FlashMessage("unsuspendLesson", Boolean.TRUE); + } catch (Exception e) { + flashMessage = handleException(e, "unsuspendLesson", monitoringService); + } + + String message = flashMessage.serializeMessage(); + + PrintWriter writer = response.getWriter(); + writer.println(message); + return null; + } + /** *
- * The STRUTS action will send back a WDDX message after marking the lesson by the given lesson ID
- * as Lesson.REMOVED_STATE
status.
+ * The STRUTS action will send back a WDDX message after marking the lesson by the given lesson ID as
+ * Lesson.REMOVED_STATE
status.
*
* 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. + * + * @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 */ - public ActionForward removeLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException{ - FlashMessage flashMessage = null; - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - - try { - long lessonId = WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID); - monitoringService.removeLesson(lessonId, getUserId()); - flashMessage = new FlashMessage("removeLesson",Boolean.TRUE); - } catch (Exception e) { - flashMessage = handleException(e, "removeLesson", monitoringService); - } - String message = flashMessage.serializeMessage(); - - PrintWriter writer = response.getWriter(); - writer.println(message); - return null; - + public ActionForward removeLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + FlashMessage flashMessage = null; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + + try { + long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + monitoringService.removeLesson(lessonId, getUserId()); + flashMessage = new FlashMessage("removeLesson", Boolean.TRUE); + } catch (Exception e) { + flashMessage = handleException(e, "removeLesson", monitoringService); + } + String message = flashMessage.serializeMessage(); + + PrintWriter writer = response.getWriter(); + writer.println(message); + return null; + } + /** *
+ * The STRUTS action will send back a JSON message after marking the lesson by the given lesson ID as
+ * Lesson.REMOVED_STATE
status.
*
- * This action need a lession ID, Learner ID and Activity ID as input. Activity ID is optional, if it is - * null, all activities for this learner will complete to as end as possible. + * This action need a lession ID as input. *
- * @param form - * @param request A standard Servlet HttpServletRequest class. - * @param response A standard Servlet HttpServletResponse class. + * + * @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 + */ + public ActionForward removeLessonJson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, JSONException, ServletException { + JSONObject jsonObject = new JSONObject(); + Object removeLessonResult = Boolean.TRUE.toString(); + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + + try { + long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + monitoringService.removeLesson(lessonId, getUserId()); + + } catch (Exception e) { + FlashMessage flashMessage = handleException(e, "removeLesson", monitoringService); + removeLessonResult = flashMessage.getMessageValue(); + } + + jsonObject.put("removeLesson", removeLessonResult); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(jsonObject); + return null; + } + + /** + *+ *
+ *+ * This action need a lession ID, Learner ID and Activity ID as input. Activity ID is optional, if it is null, all + * activities for this learner will complete to as end as possible. + *
+ * + * @param form + * @param request + * A standard Servlet HttpServletRequest class. + * @param response + * A standard Servlet HttpServletResponse class. * @return An ActionForward * @throws IOException * @throws ServletException */ - public ActionForward forceComplete(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException{ - FlashMessage flashMessage = null; - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - //get parameters - Long activityId = null; - String actId = request.getParameter(AttributeNames.PARAM_ACTIVITY_ID); - if(actId != null) - try{ - activityId = new Long(Long.parseLong(actId)); - }catch(Exception e){ - activityId = null; - } - - //force complete - try { - long lessonId = WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID); - Integer learnerId = new Integer(WebUtil.readIntParam(request,MonitoringConstants.PARAM_LEARNER_ID)); - Integer requesterId = getUserId(); - String message = monitoringService.forceCompleteLessonByUser(learnerId,requesterId,lessonId,activityId); - if ( log.isDebugEnabled() ) { - log.debug("Force complete for learner "+learnerId+" lesson "+lessonId+". "+message); - } - flashMessage = new FlashMessage("forceComplete",message); - } catch (Exception e) { - flashMessage = handleException(e, "forceComplete", monitoringService); - } - String message = flashMessage.serializeMessage(); - - PrintWriter writer = response.getWriter(); - writer.println(message); - return null; - + public ActionForward forceComplete(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + FlashMessage flashMessage = null; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + // get parameters + Long activityId = null; + String actId = request.getParameter(AttributeNames.PARAM_ACTIVITY_ID); + if (actId != null) + try { + activityId = new Long(Long.parseLong(actId)); + } catch (Exception e) { + activityId = null; + } + + // force complete + try { + long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + Integer learnerId = new Integer(WebUtil.readIntParam(request, MonitoringConstants.PARAM_LEARNER_ID)); + Integer requesterId = getUserId(); + String message = monitoringService.forceCompleteLessonByUser(learnerId, requesterId, lessonId, activityId); + if (log.isDebugEnabled()) { + log.debug("Force complete for learner " + learnerId + " lesson " + lessonId + ". " + message); + } + flashMessage = new FlashMessage("forceComplete", message); + } catch (Exception e) { + flashMessage = handleException(e, "forceComplete", monitoringService); + } + String message = flashMessage.serializeMessage(); + + PrintWriter writer = response.getWriter(); + writer.println(message); + return null; + } - - public ActionForward getLessonDetails(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response)throws IOException{ - - String wddxPacket; - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - try{ - Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); - wddxPacket = monitoringService.getLessonDetails(lessonID, getUserId()); - }catch (Exception e) { - wddxPacket = handleException(e, "getLessonDetails", monitoringService).serializeMessage(); - } - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + + public ActionForward getLessonDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + + String wddxPacket; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + try { + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + wddxPacket = monitoringService.getLessonDetails(lessonID, getUserId()); + } catch (Exception e) { + wddxPacket = handleException(e, "getLessonDetails", monitoringService).serializeMessage(); + } + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - - public ActionForward getLessonLearners(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response)throws IOException{ - String wddxPacket; - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - try{ - Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); - wddxPacket = monitoringService.getLessonLearners(lessonID, getUserId()); - }catch (Exception e) { - wddxPacket = handleException(e, "getLessonLearners", monitoringService).serializeMessage(); - } - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + + public ActionForward getLessonLearners(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + String wddxPacket; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + try { + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + wddxPacket = monitoringService.getLessonLearners(lessonID, getUserId()); + } catch (Exception e) { + wddxPacket = handleException(e, "getLessonLearners", monitoringService).serializeMessage(); + } + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - - public ActionForward getLessonStaff(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response)throws IOException{ - String wddxPacket; - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - try{ - Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); - wddxPacket = monitoringService.getLessonStaff(lessonID, getUserId()); - }catch (Exception e) { - wddxPacket = handleException(e, "getLessonStaff", monitoringService).serializeMessage(); - } - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + + public ActionForward getLessonStaff(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + String wddxPacket; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + try { + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + wddxPacket = monitoringService.getLessonStaff(lessonID, getUserId()); + } catch (Exception e) { + wddxPacket = handleException(e, "getLessonStaff", monitoringService).serializeMessage(); + } + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - - public ActionForward getLearningDesignDetails(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response)throws IOException{ - String wddxPacket; - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - try{ - Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); - wddxPacket = monitoringService.getLearningDesignDetails(lessonID); - }catch (Exception e) { - wddxPacket = handleException(e, "getLearningDesignDetails", monitoringService).serializeMessage(); - } - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + + public ActionForward getLearningDesignDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + String wddxPacket; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + try { + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + wddxPacket = monitoringService.getLearningDesignDetails(lessonID); + } catch (Exception e) { + wddxPacket = handleException(e, "getLearningDesignDetails", monitoringService).serializeMessage(); + } + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } + /** Get the learner progress data for all learners in a lesson. This is called by the sequence tab in monitoring */ - public ActionForward getAllLearnersProgress(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response)throws IOException{ - String wddxPacket; - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - try{ - Long lessonID = WebUtil.readLongParam(request,"lessonID",false); - wddxPacket = monitoringService.getAllLearnersProgress(lessonID, getUserId(), false); - }catch (Exception e) { - wddxPacket = handleException(e, "getAllLearnersProgress", monitoringService).serializeMessage(); - } - - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + public ActionForward getAllLearnersProgress(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + String wddxPacket; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + try { + Long lessonID = WebUtil.readLongParam(request, "lessonID", false); + wddxPacket = monitoringService.getAllLearnersProgress(lessonID, getUserId(), false); + } catch (Exception e) { + wddxPacket = handleException(e, "getAllLearnersProgress", monitoringService).serializeMessage(); + } + + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - - public ActionForward getDictionaryXML(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException { - - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - MessageService messageService = monitoringService.getMessageService(); - - String module = WebUtil.readStrParam(request,"module",false); - - ArrayList