An action servlet to support the dummy monitoring page dummy.jsp.
+ * + * ----------------XDoclet Tags-------------------- + * + * @struts:action path="/dummy" + * name="DummyForm" + * parameter="method" + * validate="false" + * @struts.action-exception key="error.system.monitor" scope="request" + * type="org.lamsfoundation.lams.monitoring.service.MonitoringServiceException" + * path=".systemError" + * handler="org.lamsfoundation.lams.web.util.CustomStrutsExceptionHandler" + * @struts:action-forward name="dummy" path="/dummy.jsp" + * + * ----------------XDoclet Tags-------------------- + */ +public class DummyMonitoringAction extends LamsDispatchAction +{ + //--------------------------------------------------------------------- + // Instance variables + //--------------------------------------------------------------------- + private static Logger log = Logger.getLogger(DummyMonitoringAction.class); + + private IMonitoringService monitoringService; + private IUserManagementService usermanageService; + + //--------------------------------------------------------------------- + // Class level constants - session attributes + //--------------------------------------------------------------------- + // input parameters + // output parameters + private static final String DUMMY_FORWARD = "dummy"; + private static final String LESSONS_PARAMETER = "lessons"; + + private static final Integer ORGANIZATION_ID = new Integer(1); + + + //--------------------------------------------------------------------- + // Struts Dispatch Method + //--------------------------------------------------------------------- + /** + * The Struts dispatch method that initialised and start a lesson. + * It will start a lesson with the current user as the staff and learner. + * + * @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{ + + setupServices(); + + // set up all the data needed + DummyForm dummyForm = (DummyForm) form; + Long ldId = dummyForm.getLearningDesignId(); + if ( ldId == null ) + throw new IOException("Learning design id must be set"); + + String title = dummyForm.getTitle(); + if ( title == null ) title = "lesson"; + String desc = dummyForm.getDesc(); + if ( desc == null ) desc = "description"; + + User user = getUser(); + Organisation organisation = usermanageService.getOrganisationById(ORGANIZATION_ID); + + // initialize the lesson + Lesson testLesson = monitoringService.initializeLesson(title,desc,ldId.longValue(),user); + + // create the lesson class + LinkedList learners = new LinkedList(); + learners.add(user); + LinkedList staffs = new LinkedList(); + staffs.add(user); + testLesson = monitoringService.createLessonClassForLesson(testLesson.getLessonId().longValue(), + organisation, + learners, + staffs); + + // start the lesson. + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + monitoringService.startlesson(testLesson.getLessonId().longValue()); + + // now got back to the dummy screen with an updated list of lessons to the user + return unspecified(mapping, form, request, response); + + } + + /** Default method for this action. Gets a list of all the current lessons for this user and forwards to dummy.jsp */ + public ActionForward unspecified(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws IOException{ + setupServices(); + + User user = getUser(); + List lessons = monitoringService.getAllLessons(user.getUserId()); + request.getSession().setAttribute(LESSONS_PARAMETER,lessons); + return mapping.findForward(DUMMY_FORWARD); + } + + private void setupServices() { + + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); + this.usermanageService= (IUserManagementService) wac.getBean("userManagementService"); + + } + private User getUser() throws IOException { + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + if ( user != null ) { + return usermanageService.getUserById(user.getUserID()); + } + throw new IOException("Unable to get user. User in session manager is "+user); + } +/* public ActionForward getLessonDetails(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws IOException{ + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); + String wddxPacket = monitoringService.getLessonDetails(lessonID); + return outputPacket(mapping, request, response, wddxPacket, "details"); + } + public ActionForward getLessonLearners(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws IOException{ + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); + String wddxPacket = monitoringService.getLessonLearners(lessonID); + return outputPacket(mapping, request, response, wddxPacket, "details"); + } + public ActionForward getLearningDesignDetails(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws IOException{ + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); + String wddxPacket = monitoringService.getLearningDesignDetails(lessonID); + return outputPacket(mapping, request, response, wddxPacket, "details"); + } + public ActionForward getAllLearnersProgress(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws IOException{ + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); + String wddxPacket = monitoringService.getAllLearnersProgress(lessonID); + return outputPacket(mapping, request, response, wddxPacket, "details"); + } + public ActionForward getAllContributeActivities(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws IOException{ + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); + String wddxPacket = monitoringService.getAllContributeActivities(lessonID); + return outputPacket(mapping, request, response, wddxPacket, "details"); + } + public ActionForward getLearnerActivityURL(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws IOException,LamsToolServiceException{ + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + Integer userID = new Integer(WebUtil.readIntParam(request,"userID")); + Long activityID = new Long(WebUtil.readLongParam(request,"activityID")); + String wddxPacket = monitoringService.getLearnerActivityURL(activityID,userID); + return outputPacket(mapping, request, response, wddxPacket, "details"); + } + public ActionForward getActivityContributionURL(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws IOException{ + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + Long activityID = new Long(WebUtil.readLongParam(request,"activityID")); + String wddxPacket = monitoringService.getActivityContributionURL(activityID); + return outputPacket(mapping, request, response, wddxPacket, "details"); + } + public ActionForward moveLesson(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws IOException{ + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); + Integer userID = new Integer(WebUtil.readIntParam(request,"userID")); + Integer targetWorkspaceFolderID = new Integer(WebUtil.readIntParam(request,"folderID")); + String wddxPacket = monitoringService.moveLesson(lessonID,targetWorkspaceFolderID,userID); + return outputPacket(mapping, request, response, wddxPacket, "details"); + } + public ActionForward renameLesson(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws IOException{ + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + Long lessonID = new Long(WebUtil.readLongParam(request,"lessonID")); + Integer userID = new Integer(WebUtil.readIntParam(request,"userID")); + String name = WebUtil.readStrParam(request,"name"); + String wddxPacket = monitoringService.renameLesson(lessonID,name,userID); + return outputPacket(mapping, request, response, wddxPacket, "details"); + } + + public ActionForward checkGateStatus(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws IOException { + + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + Long activityID = new Long(WebUtil.readLongParam(request, "activityID")); + Long lessonID = new Long(WebUtil.readLongParam(request, "lessonID")); + String wddxPacket = monitoringService.checkGateStatus(activityID, lessonID); + // request.setAttribute(USE_JSP_OUTPUT, "1"); + return outputPacket(mapping, request, response, wddxPacket, "details"); + + } + + public ActionForward releaseGate(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws IOException { + this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + Long activityID = new Long(WebUtil.readLongParam(request, "activityID")); + String wddxPacket = monitoringService.releaseGate(activityID); + // request.setAttribute(USE_JSP_OUTPUT, "1"); + return outputPacket(mapping, request, response, wddxPacket, "details"); + } +*/ +} Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java =================================================================== diff -u -r6e5832d17263bc6c6f7683733e91e22f97eab569 -r4ffb4f1a2bfc99e753289a089a51c92129409397 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 6e5832d17263bc6c6f7683733e91e22f97eab569) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 4ffb4f1a2bfc99e753289a089a51c92129409397) @@ -158,7 +158,7 @@ HttpServletRequest request, HttpServletResponse response)throws IOException{ this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - String wddxPacket = monitoringService.getAllLessons(); + String wddxPacket = monitoringService.getAllLessonsWDDX(); return outputPacket(mapping, request, response, wddxPacket, "details"); } public ActionForward getLessonDetails(ActionMapping mapping, Index: lams_monitoring/test/java/org/lamsfoundation/lams/monitoring/service/TestMonitoringService.java =================================================================== diff -u -r6faa51252d8f8117db65e0a58ff295def4cf7af9 -r4ffb4f1a2bfc99e753289a089a51c92129409397 --- lams_monitoring/test/java/org/lamsfoundation/lams/monitoring/service/TestMonitoringService.java (.../TestMonitoringService.java) (revision 6faa51252d8f8117db65e0a58ff295def4cf7af9) +++ lams_monitoring/test/java/org/lamsfoundation/lams/monitoring/service/TestMonitoringService.java (.../TestMonitoringService.java) (revision 4ffb4f1a2bfc99e753289a089a51c92129409397) @@ -62,11 +62,11 @@ private final Integer TEST_LEARNER_ID = new Integer(2); private final Integer TEST_STAFF_ID = new Integer(3); // values when demo'ing the progress engine - //private final long TEST_LEARNING_DESIGN_ID = 2; - //private final long TEST_COPIED_LEARNING_DESIGN_ID = 3; + private final long TEST_LEARNING_DESIGN_ID = 2; + private final long TEST_COPIED_LEARNING_DESIGN_ID = 3; // values when testing the progress engine - private final long TEST_LEARNING_DESIGN_ID = 1; - private final long TEST_COPIED_LEARNING_DESIGN_ID = 2; + //private final long TEST_LEARNING_DESIGN_ID = 1; + //private final long TEST_COPIED_LEARNING_DESIGN_ID = 2; private final Integer TEST_ORGANIZATION_ID = new Integer(1); private final Long TEST_SCHEDULE_GATE_ID = new Long(27); private final Long TEST_LESSION_ID = new Long(1); // "Test_Lesson" from insert_test_data script @@ -224,7 +224,7 @@ } public void testGetAllLessons()throws IOException{ - String packet = monitoringService.getAllLessons(); + String packet = monitoringService.getAllLessonsWDDX(); System.out.print(packet); } public void testGetLessonDetails() throws IOException{ Index: lams_monitoring/web/WEB-INF/lams.tld =================================================================== diff -u --- lams_monitoring/web/WEB-INF/lams.tld (revision 0) +++ lams_monitoring/web/WEB-INF/lams.tld (revision 4ffb4f1a2bfc99e753289a089a51c92129409397) @@ -0,0 +1,27 @@ + + + +