Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java =================================================================== diff -u -ra0d8b80b02b4edb5d86bd8f231b585501dba9108 -r64600592f85fa369e9038df63988734e6ccc0c3e --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision a0d8b80b02b4edb5d86bd8f231b585501dba9108) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 64600592f85fa369e9038df63988734e6ccc0c3e) @@ -57,148 +57,149 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; - /** - *

The action servlet that provide all the monitoring functionalities. It - * interact with the teacher via flash and JSP monitoring interface.

+ *

+ * The action servlet that provide all the monitoring functionalities. It + * interact with the teacher via flash and JSP monitoring interface. + *

* * @author Jacky Fang - * @since 2005-4-15 + * @since 2005-4-15 * @version 1.1 * * ----------------XDoclet Tags-------------------- * - * @struts:action path="/monitoring" - * parameter="method" - * validate="false" + * @struts:action path="/monitoring" parameter="method" validate="false" * @struts.action-forward name = "previewdeleted" path = "/previewdeleted.jsp" * @struts.action-forward name = "notsupported" path = ".notsupported" * @struts.action-forward name = "timeChart" path = "/timeChart.jsp" * * ----------------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 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 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.

- * If initialization is successed, this method will return a WDDX message which includes the ID of new lesson. + * 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, "learnerPresencePortfolio", false); - Boolean learnerImAvailable = WebUtil.readBooleanParam(request, "learnerImPortfolio", false); - Boolean liveEditEnabled = WebUtil.readBooleanParam(request, "liveEditEnabled", false); - Lesson newLesson = monitoringService.initializeLesson(title,desc,learnerExportAvailable,ldId,organisationId,getUserId(), null, learnerPresenceAvailable, learnerImAvailable, liveEditEnabled); - - 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, "learnerPresencePortfolio", false); + Boolean learnerImAvailable = WebUtil.readBooleanParam(request, "learnerImPortfolio", false); + Boolean liveEditEnabled = WebUtil.readBooleanParam(request, "liveEditEnabled", false); + Lesson newLesson = monitoringService.initializeLesson(title, desc, learnerExportAvailable, ldId, + organisationId, getUserId(), null, learnerPresenceAvailable, learnerImAvailable, liveEditEnabled); + + 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 @@ -207,217 +208,227 @@ * 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); - String dateStr = WebUtil.readStrParam(request, MonitoringConstants.PARAM_LESSON_FINISH_DATE); - Date finishDate = DateFormat.getInstance().parse(dateStr); - monitoringService.finishLessonOnSchedule(lessonId,finishDate,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); + String dateStr = WebUtil.readStrParam(request, MonitoringConstants.PARAM_LESSON_FINISH_DATE); + Date finishDate = DateFormat.getInstance().parse(dateStr); + monitoringService.finishLessonOnSchedule(lessonId, finishDate, 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 @@ -427,33 +438,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 @@ -463,648 +471,650 @@ * @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; + } + /** *

*

*

- * 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, 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. + * + * @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; + + /** + * 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 getDictionaryXML(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException { - - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - MessageService messageService = monitoringService.getMessageService(); - - ArrayList languageCollection = new ArrayList(); - languageCollection.add(new String("chart.btn.activity.split")); - languageCollection.add(new String("chart.btn_completion.rate")); - languageCollection.add(new String("chart.series.completed.time")); - languageCollection.add(new String("chart.series.average.time")); - languageCollection.add(new String("chart.series.duration")); - languageCollection.add(new String("chart.legend.average")); - languageCollection.add(new String("show.average.checkbox")); - languageCollection.add(new String("search.learner.textbox")); - languageCollection.add(new String("chart.learner.linear.axis.title")); - languageCollection.add(new String("chart.learner.category.axis.title")); - languageCollection.add(new String("chart.learner.datatip.average")); - - languageCollection.add(new String("label.learner")); - languageCollection.add(new String("time.chart.panel.title")); - languageCollection.add(new String("chart.time.format.hours")); - languageCollection.add(new String("chart.time.format.minutes")); - languageCollection.add(new String("chart.time.format.seconds")); - languageCollection.add(new String("label.completed")); - - String languageOutput = ""; - - for(int i = 0; i < languageCollection.size(); i++){ - languageOutput += "" + messageService.getMessage(languageCollection.get(i)) + ""; - } - - languageOutput += ""; - - PrintWriter writer = response.getWriter(); - writer.println(languageOutput); - 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(); + + ArrayList languageCollection = new ArrayList(); + languageCollection.add(new String("chart.btn.activity.split")); + languageCollection.add(new String("chart.btn_completion.rate")); + languageCollection.add(new String("chart.series.completed.time")); + languageCollection.add(new String("chart.series.average.time")); + languageCollection.add(new String("chart.series.duration")); + languageCollection.add(new String("chart.legend.average")); + languageCollection.add(new String("show.average.checkbox")); + languageCollection.add(new String("search.learner.textbox")); + languageCollection.add(new String("chart.learner.linear.axis.title")); + languageCollection.add(new String("chart.learner.category.axis.title")); + languageCollection.add(new String("chart.learner.datatip.average")); + + languageCollection.add(new String("label.learner")); + languageCollection.add(new String("time.chart.panel.title")); + languageCollection.add(new String("chart.time.format.hours")); + languageCollection.add(new String("chart.time.format.minutes")); + languageCollection.add(new String("chart.time.format.seconds")); + languageCollection.add(new String("label.completed")); + + String languageOutput = ""; + + for (int i = 0; i < languageCollection.size(); i++) { + languageOutput += "" + + messageService.getMessage(languageCollection.get(i)) + ""; + } + + languageOutput += ""; + + PrintWriter writer = response.getWriter(); + writer.println(languageOutput); + return null; } - - public ActionForward getAllCompletedActivities(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); - Long learnerID = WebUtil.readLongParam(request,"learnerID",true); - wddxPacket = monitoringService.getAllCompletedActivities(lessonID, learnerID, getUserId()); - - }catch (Exception e) { - wddxPacket = handleException(e, "getAllLearnersProgress", monitoringService).serializeMessage(); - } - - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; - + + public ActionForward getAllCompletedActivities(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); + Long learnerID = WebUtil.readLongParam(request, "learnerID", true); + wddxPacket = monitoringService.getAllCompletedActivities(lessonID, learnerID, getUserId()); + + } catch (Exception e) { + wddxPacket = handleException(e, "getAllLearnersProgress", monitoringService).serializeMessage(); + } + + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; + } - - /** Get the first batch of learner progress data learners in a lesson. This is called by the learner progress tab in monitoring */ - public ActionForward getInitialLearnersProgress(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.getInitialLearnersProgress(lessonID, getUserId()); - }catch (Exception e) { - wddxPacket = handleException(e, "getInitialLearnersProgress", monitoringService).serializeMessage(); - } - - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + + /** + * Get the first batch of learner progress data learners in a lesson. This + * is called by the learner progress tab in monitoring + */ + public ActionForward getInitialLearnersProgress(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.getInitialLearnersProgress(lessonID, getUserId()); + } catch (Exception e) { + wddxPacket = handleException(e, "getInitialLearnersProgress", monitoringService).serializeMessage(); + } + + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - /** Get a followup batch of learner progress data learners in a lesson. This is called by the learner progress tab in monitoring */ - public ActionForward getAdditionalLearnersProgress(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); - Integer lastUserID = WebUtil.readIntParam(request,"lastUserID",false); - wddxPacket = monitoringService.getAdditionalLearnersProgress(lessonID, lastUserID, getUserId()); - }catch (Exception e) { - wddxPacket = handleException(e, "getAdditionalLearnersProgress", monitoringService).serializeMessage(); - } - - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + + /** + * Get a followup batch of learner progress data learners in a lesson. This + * is called by the learner progress tab in monitoring + */ + public ActionForward getAdditionalLearnersProgress(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); + Integer lastUserID = WebUtil.readIntParam(request, "lastUserID", false); + wddxPacket = monitoringService.getAdditionalLearnersProgress(lessonID, lastUserID, getUserId()); + } catch (Exception e) { + wddxPacket = handleException(e, "getAdditionalLearnersProgress", monitoringService).serializeMessage(); + } + + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - public ActionForward getAllContributeActivities(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response)throws IOException{ - - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - String wddxPacket = null; - try { - Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); - wddxPacket = monitoringService.getAllContributeActivities(lessonID); - } catch (Exception e) { - FlashMessage flashMessage = handleException(e, "getAllContributeActivities", monitoringService); - wddxPacket = flashMessage.serializeMessage(); - } - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + + public ActionForward getAllContributeActivities(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + String wddxPacket = null; + try { + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + wddxPacket = monitoringService.getAllContributeActivities(lessonID); + } catch (Exception e) { + FlashMessage flashMessage = handleException(e, "getAllContributeActivities", monitoringService); + wddxPacket = flashMessage.serializeMessage(); + } + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - - /** Calls the server to bring up the learner progress page. - * Assumes destination is a new window. The userid that comes from - * Flash is the user id of the learner for which we are calculating - * the url. This is different to all the other calls. + + /** + * Calls the server to bring up the learner progress page. Assumes + * destination is a new window. The userid that comes from Flash is the user + * id of the learner for which we are calculating the url. This is different + * to all the other calls. */ - public ActionForward getLearnerActivityURL(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response)throws IOException,LamsToolServiceException{ + public ActionForward getLearnerActivityURL(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, LamsToolServiceException { - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - Integer learnerUserID = new Integer(WebUtil.readIntParam(request,AttributeNames.PARAM_USER_ID)); - Long activityID = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_ACTIVITY_ID)); - Long lessonID = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID)); - - String url = monitoringService.getLearnerActivityURL(lessonID,activityID,learnerUserID,getUserId()); - return redirectToURL(mapping, response, url); + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + Integer learnerUserID = new Integer(WebUtil.readIntParam(request, AttributeNames.PARAM_USER_ID)); + Long activityID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_ACTIVITY_ID)); + Long lessonID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID)); + + String url = monitoringService.getLearnerActivityURL(lessonID, activityID, learnerUserID, getUserId()); + return redirectToURL(mapping, response, url); } - /** Calls the server to bring up the activity's monitoring page. Assumes destination is a new window */ - public ActionForward getActivityMonitorURL(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response)throws IOException,LamsToolServiceException{ - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - Long activityID = new Long(WebUtil.readLongParam(request,"activityID")); - Long lessonID = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID)); - String contentFolderID = WebUtil.readStrParam(request, "contentFolderID"); - String url = monitoringService.getActivityMonitorURL(lessonID,activityID,contentFolderID,getUserId()); - - return redirectToURL(mapping, response, url); + + /** + * Calls the server to bring up the activity's monitoring page. Assumes + * destination is a new window + */ + public ActionForward getActivityMonitorURL(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, LamsToolServiceException { + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + Long activityID = new Long(WebUtil.readLongParam(request, "activityID")); + Long lessonID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID)); + String contentFolderID = WebUtil.readStrParam(request, "contentFolderID"); + String url = monitoringService.getActivityMonitorURL(lessonID, activityID, contentFolderID, getUserId()); + + return redirectToURL(mapping, response, url); } - /** Calls the server to bring up the activity's define later page. Assumes destination is a new window */ - public ActionForward getActivityDefineLaterURL(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response)throws IOException,LamsToolServiceException{ - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - Long activityID = new Long(WebUtil.readLongParam(request,"activityID")); - Long lessonID = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID)); - - String url = monitoringService.getActivityDefineLaterURL(lessonID,activityID,getUserId()); - return redirectToURL(mapping, response, url); + + /** + * Calls the server to bring up the activity's define later page. Assumes + * destination is a new window + */ + public ActionForward getActivityDefineLaterURL(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, LamsToolServiceException { + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + Long activityID = new Long(WebUtil.readLongParam(request, "activityID")); + Long lessonID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID)); + + String url = monitoringService.getActivityDefineLaterURL(lessonID, activityID, getUserId()); + return redirectToURL(mapping, response, url); } - public ActionForward moveLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response)throws IOException{ - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - String wddxPacket = null; - try { - Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); - Integer userID = getUserId(); - Integer targetWorkspaceFolderID = new Integer(WebUtil.readIntParam(request,"folderID")); - wddxPacket = monitoringService.moveLesson(lessonID,targetWorkspaceFolderID,userID); - } catch (Exception e) { - FlashMessage flashMessage = handleException(e, "moveLesson", monitoringService); - wddxPacket = flashMessage.serializeMessage(); - } - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + public ActionForward moveLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + String wddxPacket = null; + try { + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + Integer userID = getUserId(); + Integer targetWorkspaceFolderID = new Integer(WebUtil.readIntParam(request, "folderID")); + wddxPacket = monitoringService.moveLesson(lessonID, targetWorkspaceFolderID, userID); + } catch (Exception e) { + FlashMessage flashMessage = handleException(e, "moveLesson", monitoringService); + wddxPacket = flashMessage.serializeMessage(); + } + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - public ActionForward renameLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response)throws IOException{ - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - String wddxPacket = null; - try { - Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); - Integer userID = getUserId(); - String name = WebUtil.readStrParam(request,"name"); - wddxPacket = monitoringService.renameLesson(lessonID,name,userID); - } catch (Exception e) { - FlashMessage flashMessage = handleException(e, "renameLesson", monitoringService); - wddxPacket = flashMessage.serializeMessage(); - } - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + + public ActionForward renameLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + String wddxPacket = null; + try { + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + Integer userID = getUserId(); + String name = WebUtil.readStrParam(request, "name"); + wddxPacket = monitoringService.renameLesson(lessonID, name, userID); + } catch (Exception e) { + FlashMessage flashMessage = handleException(e, "renameLesson", monitoringService); + wddxPacket = flashMessage.serializeMessage(); + } + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - - public ActionForward checkGateStatus(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException { - - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - String wddxPacket = null; - try { - Long activityID = new Long(WebUtil.readLongParam(request, "activityID")); - Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); - wddxPacket = monitoringService.checkGateStatus(activityID, lessonID); - } catch (Exception e) { - FlashMessage flashMessage = handleException(e, "checkGateStatus", monitoringService); - wddxPacket = flashMessage.serializeMessage(); - } - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; - + + public ActionForward checkGateStatus(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + String wddxPacket = null; + try { + Long activityID = new Long(WebUtil.readLongParam(request, "activityID")); + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + wddxPacket = monitoringService.checkGateStatus(activityID, lessonID); + } catch (Exception e) { + FlashMessage flashMessage = handleException(e, "checkGateStatus", monitoringService); + wddxPacket = flashMessage.serializeMessage(); + } + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; + } - - public ActionForward releaseGate(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException { - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - String wddxPacket = null; - try { - Long activityID = new Long(WebUtil.readLongParam(request, "activityID")); - wddxPacket = monitoringService.releaseGate(activityID); - } catch (Exception e) { - FlashMessage flashMessage = handleException(e, "releaseGate", monitoringService); - wddxPacket = flashMessage.serializeMessage(); - } - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + + public ActionForward releaseGate(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + String wddxPacket = null; + try { + Long activityID = new Long(WebUtil.readLongParam(request, "activityID")); + wddxPacket = monitoringService.releaseGate(activityID); + } catch (Exception e) { + FlashMessage flashMessage = handleException(e, "releaseGate", monitoringService); + wddxPacket = flashMessage.serializeMessage(); + } + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - public ActionForward startPreviewLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException { - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - FlashMessage flashMessage = null; - - try { - - Integer userID = getUserId(); - long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); - - /** InitializeLessonServlet handles the Lesson initialisation process. - * Create Lesson Class and start Lesson Preview. */ - - if(new Long(lessonID) != null) { - - monitoringService.createPreviewClassForLesson(userID, lessonID); - monitoringService.startLesson(lessonID, getUserId()); - - flashMessage = new FlashMessage("startPreviewSession",new Long(lessonID)); - - } else { - flashMessage = handleCriticalError("startPreviewSession", "error.system.error", monitoringService); - } - - } catch (Exception e) { - flashMessage = handleException(e, "startPreviewSession", monitoringService); - } - - PrintWriter writer = response.getWriter(); - writer.println(flashMessage.serializeMessage()); - return null; + public ActionForward startPreviewLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + FlashMessage flashMessage = null; + + try { + + Integer userID = getUserId(); + long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + + /** + * InitializeLessonServlet handles the Lesson initialisation + * process. Create Lesson Class and start Lesson Preview. + */ + + if (new Long(lessonID) != null) { + + monitoringService.createPreviewClassForLesson(userID, lessonID); + monitoringService.startLesson(lessonID, getUserId()); + + flashMessage = new FlashMessage("startPreviewSession", new Long(lessonID)); + + } else { + flashMessage = handleCriticalError("startPreviewSession", "error.system.error", monitoringService); + } + + } catch (Exception e) { + flashMessage = handleException(e, "startPreviewSession", monitoringService); } - /** Delete all old preview lessons and their related data, across all - * organisations. - * Should go to a monitoring webservice maybe ? */ - public ActionForward deleteOldPreviewLessons(ActionMapping mapping, - ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { - - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - int numDeleted = monitoringService.deleteAllOldPreviewLessons(); - request.setAttribute(NUM_DELETED, Integer.toString(numDeleted)); - return mapping.findForward(PREVIEW_DELETED_REPORT_SCREEN); + PrintWriter writer = response.getWriter(); + writer.println(flashMessage.serializeMessage()); + return null; + } + + /** + * Delete all old preview lessons and their related data, across all + * organisations. Should go to a monitoring webservice maybe ? + */ + public ActionForward deleteOldPreviewLessons(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + int numDeleted = monitoringService.deleteAllOldPreviewLessons(); + request.setAttribute(NUM_DELETED, Integer.toString(numDeleted)); + return mapping.findForward(PREVIEW_DELETED_REPORT_SCREEN); + } + + /** + * Get AuditService bean. + * + * @return + */ + private IAuditService getAuditService() { + if (auditService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + auditService = (IAuditService) ctx.getBean("auditService"); } - - /** - * Get AuditService bean. - * @return - */ - private IAuditService getAuditService(){ - if(auditService==null){ - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); - auditService = (IAuditService) ctx.getBean("auditService"); - } - return auditService; - } - - /** - * Set whether or not the export portfolio button is available in learner. Expects parameters lessonID - * and learnerExportPortfolio. + return auditService; + } + + /** + * Set whether or not the export portfolio button is available in learner. + * Expects parameters lessonID and learnerExportPortfolio. */ - public ActionForward learnerExportPortfolioAvailable(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { + public ActionForward learnerExportPortfolioAvailable(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - FlashMessage flashMessage = null; - try { - Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); - Integer userID = getUserId(); - Boolean learnerExportPortfolioAvailable = WebUtil.readBooleanParam(request,"learnerExportPortfolio",false); - monitoringService.setLearnerPortfolioAvailable(lessonID, userID, learnerExportPortfolioAvailable); - - flashMessage = new FlashMessage("learnerExportPortfolioAvailable", "learnerExportPortfolioAvailable"); - } catch (Exception e) { - flashMessage = handleException(e, "renameLesson", monitoringService); - } - String wddxPacket = flashMessage.serializeMessage(); - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + FlashMessage flashMessage = null; + try { + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + Integer userID = getUserId(); + Boolean learnerExportPortfolioAvailable = WebUtil + .readBooleanParam(request, "learnerExportPortfolio", false); + monitoringService.setLearnerPortfolioAvailable(lessonID, userID, learnerExportPortfolioAvailable); + + flashMessage = new FlashMessage("learnerExportPortfolioAvailable", "learnerExportPortfolioAvailable"); + } catch (Exception e) { + flashMessage = handleException(e, "renameLesson", monitoringService); + } + String wddxPacket = flashMessage.serializeMessage(); + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - - /** - * Set whether or not the presence available button is available in learner. Expects parameters lessonID - * and presenceAvailable. + + /** + * Set whether or not the presence available button is available in learner. + * Expects parameters lessonID and presenceAvailable. */ - public ActionForward presenceAvailable(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { + public ActionForward presenceAvailable(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - FlashMessage flashMessage = null; - try { - Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); - Integer userID = getUserId(); - Boolean presenceAvailable = WebUtil.readBooleanParam(request,"presenceAvailable",false); - monitoringService.setPresenceAvailable(lessonID, userID, presenceAvailable); + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + FlashMessage flashMessage = null; + try { + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + Integer userID = getUserId(); + Boolean presenceAvailable = WebUtil.readBooleanParam(request, "presenceAvailable", false); + monitoringService.setPresenceAvailable(lessonID, userID, presenceAvailable); - flashMessage = new FlashMessage("presenceAvailable", "presenceAvailable"); - } catch (Exception e) { - flashMessage = handleException(e, "presenceAvailable", monitoringService); - } - String wddxPacket = flashMessage.serializeMessage(); - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + flashMessage = new FlashMessage("presenceAvailable", "presenceAvailable"); + } catch (Exception e) { + flashMessage = handleException(e, "presenceAvailable", monitoringService); + } + String wddxPacket = flashMessage.serializeMessage(); + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - /** - * Set whether or not the presence available button is available in learner. Expects parameters lessonID - * and presenceImAvailable. + /** + * Set whether or not the presence available button is available in learner. + * Expects parameters lessonID and presenceImAvailable. */ - public ActionForward presenceImAvailable(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { + public ActionForward presenceImAvailable(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - FlashMessage flashMessage = null; - try { - Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); - Integer userID = getUserId(); - Boolean presenceImAvailable = WebUtil.readBooleanParam(request,"presenceImAvailable",false); - monitoringService.setPresenceImAvailable(lessonID, userID, presenceImAvailable); - - flashMessage = new FlashMessage("presenceImAvailable", "presenceImAvailable"); - } catch (Exception e) { - flashMessage = handleException(e, "presenceImAvailable", monitoringService); - } - String wddxPacket = flashMessage.serializeMessage(); - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + FlashMessage flashMessage = null; + try { + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + Integer userID = getUserId(); + Boolean presenceImAvailable = WebUtil.readBooleanParam(request, "presenceImAvailable", false); + monitoringService.setPresenceImAvailable(lessonID, userID, presenceImAvailable); + + flashMessage = new FlashMessage("presenceImAvailable", "presenceImAvailable"); + } catch (Exception e) { + flashMessage = handleException(e, "presenceImAvailable", monitoringService); + } + String wddxPacket = flashMessage.serializeMessage(); + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; } - - /** - * Set whether or not the presence available button is available in learner. Expects parameters lessonID - * and presenceAvailable. + + /** + * Set whether or not the presence available button is available in learner. + * Expects parameters lessonID and presenceAvailable. */ - public ActionForward liveEditAvailable(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { + public ActionForward liveEditAvailable(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - FlashMessage flashMessage = null; - try { - Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); - Integer userID = getUserId(); - Boolean liveEditAvailable = WebUtil.readBooleanParam(request,"liveEditAvailable",false); - monitoringService.setLiveEditEnabled(lessonID, userID, liveEditAvailable); - - flashMessage = new FlashMessage("liveEditAvailable", "liveEditAvailable"); - } catch (Exception e) { - flashMessage = handleException(e, "liveEditAvailable", monitoringService); - } - String wddxPacket = flashMessage.serializeMessage(); - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; - } - - /** Open Time Chart display */ - public ActionForward viewTimeChart(ActionMapping mapping, - ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { - - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - - try { - - long lessonID = WebUtil.readLongParam(request, "lessonID"); - - // check monitor privledges - monitoringService.openTimeChart(lessonID, getUserId()); - - request.setAttribute("lessonID", lessonID); - request.setAttribute("learnerID", WebUtil.readLongParam(request, "learnerID", true)); - - } catch (Exception e) { - request.setAttribute("errorName","MonitoringAction"); - request.setAttribute("errorMessage", e.getMessage()); + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + FlashMessage flashMessage = null; + try { + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + Integer userID = getUserId(); + Boolean liveEditAvailable = WebUtil.readBooleanParam(request, "liveEditAvailable", false); + monitoringService.setLiveEditEnabled(lessonID, userID, liveEditAvailable); - return mapping.findForward(ERROR); - } - - return mapping.findForward(TIME_CHART_SCREEN); + flashMessage = new FlashMessage("liveEditAvailable", "liveEditAvailable"); + } catch (Exception e) { + flashMessage = handleException(e, "liveEditAvailable", monitoringService); } + String wddxPacket = flashMessage.serializeMessage(); + PrintWriter writer = response.getWriter(); + writer.println(wddxPacket); + return null; + } + + /** Open Time Chart display */ + public ActionForward viewTimeChart(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + + try { + + long lessonID = WebUtil.readLongParam(request, "lessonID"); + + // check monitor privledges + monitoringService.openTimeChart(lessonID, getUserId()); + + request.setAttribute("lessonID", lessonID); + request.setAttribute("learnerID", WebUtil.readLongParam(request, "learnerID", true)); + + } catch (Exception e) { + request.setAttribute("errorName", "MonitoringAction"); + request.setAttribute("errorMessage", e.getMessage()); + + return mapping.findForward(ERROR); + } + + return mapping.findForward(TIME_CHART_SCREEN); + } }