Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayActivityAction.java =================================================================== diff -u -r9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6 -r0b15f95c45e3f984eb6b422bb035fb6d9f824e82 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayActivityAction.java (.../DisplayActivityAction.java) (revision 9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayActivityAction.java (.../DisplayActivityAction.java) (revision 0b15f95c45e3f984eb6b422bb035fb6d9f824e82) @@ -49,6 +49,9 @@ * on which LoadToolActivityAction relies. If you try to go straight to LoadToolActivityAction * then the data won't be in the request. * + * Request values: lessonID (mandatory), InitialDisplay (optional - Set to "true" for normal + * display, set to "false" when you want it to assume it is inside parallel frameset. Defaults to true). + * * XDoclet definition: * * ----------------XDoclet Tags-------------------- @@ -70,6 +73,7 @@ //--------------------------------------------------------------------- private static Logger log = Logger.getLogger(DisplayActivityAction.class); + public static final String PARAM_INITIAL_DISPLAY = "initialDisplay"; /** * Gets an activity from the request (attribute) and forwards onto a * display action using the ActionMappings class. If no activity is @@ -91,11 +95,14 @@ lessonId = WebUtil.readLongParam(request,"progressId"); } LearnerProgress learnerProgress = learnerService.getProgress(learnerId, lessonId); - LearningWebUtil.putLearnerProgressInRequest(request, learnerProgress); + + // Normally this is used to display the initial page, so initialDisplay=true. But if called from the + // special handling for completed activities (ie close window) then we need to set it to false. + boolean displayParallelFrames = WebUtil.readBooleanParam(request, PARAM_INITIAL_DISPLAY, true); ActivityMapping actionMappings = LearnerServiceProxy.getActivityMapping(getServlet().getServletContext()); - ActionForward forward =actionMappings.getProgressForward(learnerProgress,false,true,request,learnerService); + ActionForward forward =actionMappings.getProgressForward(learnerProgress,false,displayParallelFrames,request,learnerService); setupProgressString(actionForm, request); if(log.isDebugEnabled()) Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java =================================================================== diff -u -r9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6 -r0b15f95c45e3f984eb6b422bb035fb6d9f824e82 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java (.../LearnerAction.java) (revision 9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java (.../LearnerAction.java) (revision 0b15f95c45e3f984eb6b422bb035fb6d9f824e82) @@ -92,8 +92,7 @@ //--------------------------------------------------------------------- // Class level constants - Struts forward //--------------------------------------------------------------------- - private static final String DISPLAY_ACTIVITY = "displayActivity"; - + private static IAuditService auditService; private ActionForward redirectToURL(ActionMapping mapping, HttpServletResponse response, String url) throws IOException, ServletException { @@ -171,7 +170,8 @@ LearningWebUtil.putLearnerProgressInRequest(request,learnerProgress); - String url = "learning/" + mapping.findForward(DISPLAY_ACTIVITY).getPath() + "?lessonID=" + lessonID; + ActivityMapping activityMapping = LearnerServiceProxy.getActivityMapping(this.getServlet().getServletContext()); + String url = "learning/" + activityMapping.getDisplayActivityAction(lessonID); redirectToURL(mapping, response, url); @@ -234,7 +234,8 @@ //serialize a acknowledgement flash message with the path of display next //activity - message = new FlashMessage("joinLesson", mapping.findForward(DISPLAY_ACTIVITY).getPath()); + ActivityMapping activityMapping = LearnerServiceProxy.getActivityMapping(this.getServlet().getServletContext()); + message = new FlashMessage("joinLesson", activityMapping.getDisplayActivityAction(null)); } catch (Exception e ) { message = handleException(e, "joinLesson", learnerService); @@ -528,7 +529,6 @@ //getting requested object according to coming parameters Integer learnerId = LearningWebUtil.getUserId(); - User learner = (User)LearnerServiceProxy.getUserManagementService(getServlet().getServletContext()).findById(User.class,learnerId); //get parameters Long fromActivityId = null; @@ -568,7 +568,7 @@ if ( log.isDebugEnabled() ) { log.debug("Force move for learner "+learnerId+" lesson "+lessonId+". "); } - flashMessage = new FlashMessage("forceMove", mapping.findForward(DISPLAY_ACTIVITY).getPath()); + flashMessage = new FlashMessage("forceMove", activityMapping.getDisplayActivityAction(null)); } catch (Exception e) { flashMessage = handleException(e, "forceMove", learnerService); } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMapping.java =================================================================== diff -u -re023857e217082f46fd3235d5673129ffccf6ff4 -r0b15f95c45e3f984eb6b422bb035fb6d9f824e82 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMapping.java (.../ActivityMapping.java) (revision e023857e217082f46fd3235d5673129ffccf6ff4) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMapping.java (.../ActivityMapping.java) (revision 0b15f95c45e3f984eb6b422bb035fb6d9f824e82) @@ -36,6 +36,7 @@ import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.learning.service.LearnerServiceException; import org.lamsfoundation.lams.learning.web.action.ActivityAction; +import org.lamsfoundation.lams.learning.web.action.DisplayActivityAction; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.lesson.LearnerProgress; import org.lamsfoundation.lams.lesson.Lesson; @@ -300,6 +301,10 @@ return actionForward; } + /** Takes a Struts forward containing the path such as /DisplayRequest.do and turns it into a full URL including servername */ + protected String strutsForwardToURL(ActionForward forward) { + return Configuration.get(ConfigurationKeys.SERVER_URL) + LEARNING + forward.getPath(); + } /** * Calculate the activity url for progress view at learner side. * @param learner the learner who owns the progress data @@ -334,8 +339,37 @@ this.activityMappingStrategy = activityMappingStrategy; } - public ActionForward getCloseForward() { - return strutsActionToForward(this.activityMappingStrategy.getCloseWindowAction(), null, false); + /** If the activity is already completed it could be one of five cases: + * (1) the user has opened just the one activity in in a popup window from the progress bar, in which case we want to close the window + * (2) the user has opened up a parallel activity in a popup window from the progress bar, and the completed activity + * is one of the contained activities. In this case we want to display the "wait" message or close depending on the activity + * in the other frame. + * (3) the activity was force completed while the user was doing the activity. This case includes "standalone" activities + activities in a parallel frameset + * (4) the activity is part of a parallel activity and the other activity isn't completed. + * In cases (3) and (4) we want to do whatever we would normally do, apart from completing the activity, but we + * know whether it is (1),(2) or (3),(4) until we get back to a jsp and can check the window name. + * so prepare the urls for (2), (3) and (4) then call the close window screen and it will sort it out. + */ + public ActionForward getCloseForward(Activity justCompletedActivity, Long lessonId) throws UnsupportedEncodingException { + + String closeWindowURLAction = activityMappingStrategy.getCloseWindowAction(); + + // Always calculate the url for the "normal" next case as we won't know till we reach the close window if we need it. + String action = getDisplayActivityAction(lessonId); + action = strutsActionToURL(action,null,true); + action = WebUtil.appendParameterToURL(action, DisplayActivityAction.PARAM_INITIAL_DISPLAY, "false"); + action = URLEncoder.encode(action, "UTF-8"); + closeWindowURLAction = WebUtil.appendParameterToURL(closeWindowURLAction, "nextURL", action); + + // If we are in the parallel frameset then we might need the nextURL, or we might need the "waiting" url. + if ( justCompletedActivity.getParentActivity() != null && justCompletedActivity.getParentActivity().isParallelActivity() ) { + action = getActivityMappingStrategy().getWaitingAction(); + action = strutsActionToURL(action,null,true); + action = URLEncoder.encode(action, "UTF-8"); + closeWindowURLAction = WebUtil.appendParameterToURL(closeWindowURLAction, "waitURL", action); + } + + return strutsActionToForward(closeWindowURLAction, null, false); } public String getProgressBrokenURL() { @@ -352,5 +386,17 @@ } return url; } - + + /** + * Get the "bootstrap" activity action. This is the action called when the user first joins a lesson, and sets up + * the necessary request details based on the user's progress details. If lessonID is not null then it is appended onto the string. + * If this is for a JSP call then the lessonID is needed, if it is for Flash then it is not needed as Flash will add the id. + */ + public String getDisplayActivityAction(Long lessonID) { + if ( lessonID != null) { + return WebUtil.appendParameterToURL("/DisplayActivity.do",AttributeNames.PARAM_LESSON_ID,lessonID.toString()); + } else { + return "/DisplayActivity.do"; + } + } } \ No newline at end of file Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMappingStrategy.java =================================================================== diff -u -r9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6 -r0b15f95c45e3f984eb6b422bb035fb6d9f824e82 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMappingStrategy.java (.../ActivityMappingStrategy.java) (revision 9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMappingStrategy.java (.../ActivityMappingStrategy.java) (revision 0b15f95c45e3f984eb6b422bb035fb6d9f824e82) @@ -27,7 +27,6 @@ import java.io.Serializable; import org.lamsfoundation.lams.learningdesign.Activity; -import org.lamsfoundation.lams.lesson.LearnerProgress; /** * @author daveg @@ -96,4 +95,12 @@ protected String getCompleteActivityAction() { return "/CompleteActivity.do"; } + + /** + * Get the "bootstrap" activity action. This is the action called when the user first joins a lesson, and sets up + * the necessary request details based on the user's progress details. + */ + protected String getDisplayActivityAction() { + return "/DisplayActivity.do"; + } } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/LearningWebUtil.java =================================================================== diff -u -r9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6 -r0b15f95c45e3f984eb6b422bb035fb6d9f824e82 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/LearningWebUtil.java (.../LearningWebUtil.java) (revision 9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/LearningWebUtil.java (.../LearningWebUtil.java) (revision 0b15f95c45e3f984eb6b422bb035fb6d9f824e82) @@ -60,6 +60,8 @@ // Class level constants - session attributes //--------------------------------------------------------------------- public static final String PARAM_PROGRESS_ID = "progressID"; +// public static final String POPUP_WINDOW_NAME = "LearnerActivity"; +// public static final String LEARNER_WINDOW_NAME = "lWindow"; /** * Helper method to retrieve the user data. Gets the id from the user details @@ -188,27 +190,29 @@ /** "Complete" an activity from the web layer's perspective. Used for CompleteActivityAction and the Gate and Grouping actions. * Calls the learningService to actually complete the activity and progress. * @param redirect Should this call redirect to the next screen (true) or use a forward (false) + * @param windowName Name of the window that triggered this code. Normally LearnerActivity (the popup window) or lWindow (normal learner window) * @throws UnsupportedEncodingException * */ public static ActionForward completeActivity(HttpServletRequest request, HttpServletResponse response, ActivityMapping actionMappings, LearnerProgress currentProgress, Activity currentActivity, Integer learnerId, ICoreLearnerService learnerService, boolean redirect) throws LearnerServiceException, UnsupportedEncodingException { - LearnerProgress newProgress=null; - Lesson lesson = currentProgress.getLesson(); + LearnerProgress progress=currentProgress; + Lesson lesson = progress.getLesson(); if ( currentActivity == null ) { - newProgress = learnerService.joinLesson(learnerId, lesson.getLessonId()); - } else if ( currentProgress.getCompletedActivities().contains(currentActivity) ){ - return actionMappings.getCloseForward(); + progress = learnerService.joinLesson(learnerId, lesson.getLessonId()); + } else if ( progress.getCompletedActivities().contains(currentActivity) ) { + return actionMappings.getCloseForward(currentActivity, lesson.getLessonId()); } else { // Set activity as complete - newProgress = learnerService.completeActivity(learnerId, currentActivity,currentProgress); + progress = learnerService.completeActivity(learnerId, currentActivity,progress); } - LearningWebUtil.putActivityInRequest(request, newProgress.getNextActivity(), learnerService); - LearningWebUtil.putLearnerProgressInRequest(request,newProgress); - return actionMappings.getProgressForward(newProgress, redirect, false, request, learnerService); + LearningWebUtil.putActivityInRequest(request, progress.getNextActivity(), learnerService); + LearningWebUtil.putLearnerProgressInRequest(request,progress); + return actionMappings.getProgressForward(progress, redirect, false, request, learnerService); } + } Index: lams_learning/web/close.jsp =================================================================== diff -u -rca73a51b45e6071a6a9edd5da8b0d61bf3a39929 -r0b15f95c45e3f984eb6b422bb035fb6d9f824e82 --- lams_learning/web/close.jsp (.../close.jsp) (revision ca73a51b45e6071a6a9edd5da8b0d61bf3a39929) +++ lams_learning/web/close.jsp (.../close.jsp) (revision 0b15f95c45e3f984eb6b422bb035fb6d9f824e82) @@ -20,10 +20,27 @@ --%> <%@ taglib uri="tags-fmt" prefix="fmt" %> - +<%@ taglib uri="tags-core" prefix="c" %> + +

@@ -34,4 +51,3 @@ -