This class act as the proxy between web layer and service layer. It is - * designed to decouple the presentation logic and business logic completely. - * In this way, the presentation tier will no longer be aware of the changes in - * service layer. Therefore we can feel free to switch the business logic - * implementation.
+ *+ * This class act as the proxy between web layer and service layer. It is designed to decouple the presentation logic + * and business logic completely. In this way, the presentation tier will no longer be aware of the changes in service + * layer. Therefore we can feel free to switch the business logic implementation. + *
* * @author Jacky Fang - * @since 2005-4-15 + * @since 2005-4-15 * @version 1.1 * */ -public class MonitoringServiceProxy -{ +public class MonitoringServiceProxy { /** - * Return the monitor domain service object. It will delegate to the Spring - * helper method to retrieve the proper bean from Spring bean factory. - * @param servletContext the servletContext for current application + * Return the monitor domain service object. It will delegate to the Spring helper method to retrieve the proper + * bean from Spring bean factory. + * + * @param servletContext + * the servletContext for current application * @return monitoring service object. */ - public static final IMonitoringService getMonitoringService(ServletContext servletContext) - { - return (IMonitoringService)getDomainService(servletContext,"monitoringService"); + public static final IMonitoringService getMonitoringService(ServletContext servletContext) { + return (IMonitoringService) MonitoringServiceProxy.getDomainService(servletContext, "monitoringService"); } - + /** - * Return the learner domain service object. It will delegate to the Spring - * helper method to retrieve the proper bean from Spring bean factory. - * @param servletContext the servletContext for current application + * Return the learner domain service object. It will delegate to the Spring helper method to retrieve the proper + * bean from Spring bean factory. + * + * @param servletContext + * the servletContext for current application * @return learner service object. */ - public static final ICoreLearnerService getLearnerService(ServletContext servletContext) - { - return (ICoreLearnerService)getDomainService(servletContext,"learnerService"); + public static final ICoreLearnerService getLearnerService(ServletContext servletContext) { + return (ICoreLearnerService) MonitoringServiceProxy.getDomainService(servletContext, "learnerService"); } - + public static final IUserManagementService getUserManagementService(ServletContext servletContext) { - return (IUserManagementService) getDomainService(servletContext, "userManagementService"); + return (IUserManagementService) MonitoringServiceProxy + .getDomainService(servletContext, "userManagementService"); } + public static final IAuthoringService getAuthoringService(ServletContext servletContext) { + return (IAuthoringService) MonitoringServiceProxy.getDomainService(servletContext, "authoringService"); + } + /** - * Retrieve the proper Spring bean from bean factory. - * @param servletContext the servletContext for current application + * Retrieve the proper Spring bean from bean factory. + * + * @param servletContext + * the servletContext for current application * @return the Spring service bean. */ - private static Object getDomainService(ServletContext servletContext,String serviceName) - { - WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); - return wac.getBean(serviceName); + private static Object getDomainService(ServletContext servletContext, String serviceName) { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); + return wac.getBean(serviceName); } } Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java =================================================================== diff -u -rdf0f027b7be924b18e67ae36248b7deada2e6f2d -r1b117caf4135f53248542cbc97d71aac448f3de9 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision df0f027b7be924b18e67ae36248b7deada2e6f2d) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 1b117caf4135f53248542cbc97d71aac448f3de9) @@ -51,10 +51,12 @@ import org.apache.tomcat.util.json.JSONArray; import org.apache.tomcat.util.json.JSONException; import org.apache.tomcat.util.json.JSONObject; +import org.lamsfoundation.lams.authoring.service.IAuthoringService; import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.learning.web.bean.ActivityURL; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.ContributionTypes; +import org.lamsfoundation.lams.learningdesign.exception.LearningDesignException; import org.lamsfoundation.lams.lesson.LearnerProgress; import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.lesson.dto.LessonDetailsDTO; @@ -73,7 +75,9 @@ import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.exception.UserAccessDeniedException; +import org.lamsfoundation.lams.usermanagement.exception.UserException; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.lamsfoundation.lams.util.CentralConstants; import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.DateUtil; @@ -637,7 +641,16 @@ 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); + + // true if old, Flash Monitoring is used; to be removed after new Monitoring is adopted + boolean isPreviousActivity = WebUtil.readBooleanParam(request, "isPreviousActivity", true); + String message = null; + if (isPreviousActivity) { + message = monitoringService.forceCompleteLessonByUser(learnerId, requesterId, lessonId, activityId); + } else { + message = monitoringService.forceCompleteActivitiesByUser(learnerId, requesterId, lessonId, activityId); + } + if (LamsDispatchAction.log.isDebugEnabled()) { LamsDispatchAction.log.debug("Force complete for learner " + learnerId + " lesson " + lessonId + ". " + message); @@ -1272,6 +1285,8 @@ public ActionForward getLessonProgressJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws JSONException, IOException { long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + Long branchingActivityId = WebUtil.readLongParam(request, "branchingActivityID", true); + Lesson lesson = getLessonService().getLesson(lessonId); IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() .getServletContext()); @@ -1282,36 +1297,52 @@ // few details for each activity Map