Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java =================================================================== diff -u -r64600592f85fa369e9038df63988734e6ccc0c3e -r11fc453f24005ba4f0a47a127d563df7663f7606 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 64600592f85fa369e9038df63988734e6ccc0c3e) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 11fc453f24005ba4f0a47a127d563df7663f7606) @@ -57,149 +57,148 @@ 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"; + 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; - /** 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 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 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 @@ -208,227 +207,217 @@ * 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 @@ -438,30 +427,33 @@ * @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 @@ -471,650 +463,706 @@ * @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(); + + String module = WebUtil.readStrParam(request,"module",false); + ArrayList