Index: lams_build/lib/lams/lams-learning.jar =================================================================== RCS file: /usr/local/cvsroot/lams_build/lib/lams/lams-learning.jar,v diff -u -r1.35.4.1 -r1.35.4.2 Binary files differ Index: lams_learning/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_learning/conf/language/lams/ApplicationResources.properties,v diff -u -r1.1.2.3 -r1.1.2.4 --- lams_learning/conf/language/lams/ApplicationResources.properties 3 Apr 2007 05:08:32 -0000 1.1.2.3 +++ lams_learning/conf/language/lams/ApplicationResources.properties 10 Apr 2007 05:03:52 -0000 1.1.2.4 @@ -73,6 +73,7 @@ label.close.button =Close mynotes.journals.title =Journals mynotes.entry.no.title.label =No Title -message.progress.broken=An error has occurred and you cannot continue without LAMS recalculating your current activity. The lesson may be currently under edit. Please select "Resume" or close and reopen this window to continue. +message.progress.broken=An error has occurred and you cannot continue without LAMS recalculating your current activity. A staff member may be editing the lesson. +message.progress.broken.try.resume=Please select "Resume" or close and reopen this window to continue. If this error re-occurs, wait a few minutes and then try again. #======= End labels: Exported 67 labels for en AU ===== Index: lams_learning/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== RCS file: /usr/local/cvsroot/lams_learning/conf/language/lams/ApplicationResources_en_AU.properties,v diff -u -r1.1.2.2 -r1.1.2.3 --- lams_learning/conf/language/lams/ApplicationResources_en_AU.properties 3 Apr 2007 05:08:32 -0000 1.1.2.2 +++ lams_learning/conf/language/lams/ApplicationResources_en_AU.properties 10 Apr 2007 05:03:52 -0000 1.1.2.3 @@ -73,6 +73,7 @@ label.close.button =Close mynotes.journals.title =Journals mynotes.entry.no.title.label =No Title -message.progress.broken=An error has occurred and you cannot continue without LAMS recalculating your current activity. The lesson may be currently under edit. Please select "Resume" or close and reopen this window to continue. +message.progress.broken=An error has occurred and you cannot continue without LAMS recalculating your current activity. A staff member may be editing the lesson. +message.progress.broken.try.resume=Please select "Resume" or close and reopen this window to continue. If this error re-occurs, wait a few minutes and then try again. #======= End labels: Exported 67 labels for en AU ===== Index: lams_learning/src/java/org/lamsfoundation/lams/learning/progress/ProgressEngine.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/progress/ProgressEngine.java,v diff -u -r1.21.4.3 -r1.21.4.4 --- lams_learning/src/java/org/lamsfoundation/lams/learning/progress/ProgressEngine.java 30 Mar 2007 05:02:17 -0000 1.21.4.3 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/progress/ProgressEngine.java 10 Apr 2007 05:03:22 -0000 1.21.4.4 @@ -108,21 +108,26 @@ LearningDesign ld = progress.getLesson().getLearningDesign(); - if(ld.getFirstActivity()==null) + if (progress.getLesson().getLockedForEdit()) { + // special case - currently setting up the stop gates for live edit. + return clearProgressNowhereToGoNotCompleted(progress,"setUpStartPoint"); + } else if(ld.getFirstActivity()==null) { throw new ProgressException("Could not find first activity for " +"learning design ["+ld.getTitle()+"], id[" +ld.getLearningDesignId().longValue() +"]"); - - if ( progress.getCompletedActivities().contains(ld.getFirstActivity()) ) { + } else if ( progress.getCompletedActivities().contains(ld.getFirstActivity()) ) { // special case - recalculating the appropriate current activity. return calculateProgress(progress.getUser(), ld.getFirstActivity(), progress); } else if ( canDoActivity(ld, ld.getFirstActivity()) ) { + // normal case progress.setCurrentActivity(ld.getFirstActivity()); progress.setNextActivity(ld.getFirstActivity()); setActivityAttempted(progress, ld.getFirstActivity()); return progress; } else { + // special case - trying to get to a whole new activity (past the stop gate) + // during a live edit return clearProgressNowhereToGoNotCompleted(progress,"setUpStartPoint"); } } @@ -131,6 +136,10 @@ * if the learning design is marked for edit (due to live edit) and the activity isn't read * only. This case should only occur if you have snuck past the stop gates while live edit * was being set up. Hopefully never! + * + * See the live edit documentation on the wiki for more details on the Lesson.lockedForEdit + * and LearningDesign.activityReadOnly flags. These are set up in AuthoringService.setupEditOnFlyLock() + * * @param design * @param activity * @return @@ -140,7 +149,10 @@ } /** - * Oh, dear - nowhere to go. Probably because I failed canDoActivity(). + * Oh, dear - nowhere to go. Probably because the sequence is being edited + * while I'm trying to move to an untouched activity, or it is in the process + * of setting up the stop gates for live edit. + * * Set the current activity and next activity to null, and the progress * engine should then show the "Sequence Broken" screen. * Index: lams_learning/src/java/org/lamsfoundation/lams/learning/service/ICoreLearnerService.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/service/ICoreLearnerService.java,v diff -u -r1.5 -r1.5.4.1 --- lams_learning/src/java/org/lamsfoundation/lams/learning/service/ICoreLearnerService.java 8 Nov 2006 06:39:58 -0000 1.5 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/service/ICoreLearnerService.java 10 Apr 2007 05:03:22 -0000 1.5.4.1 @@ -26,6 +26,8 @@ import java.util.List; +import org.lamsfoundation.lams.learning.progress.ProgressEngine; +import org.lamsfoundation.lams.learning.progress.ProgressException; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.GateActivity; import org.lamsfoundation.lams.lesson.LearnerProgress; @@ -128,30 +130,31 @@ /** * Complete the activity in the progress engine and delegate to the progress - * engine to calculate the next activity in the learning design. This - * process might be triggerred by system controlled the activity, such as - * grouping and gate. This method should be used when we don't have an activity - * or a lesson that is already part of the Hibernate session. + * engine to calculate the next activity in the learning design. + * It is currently triggered by various progress engine related action classes, + * which then calculate the url to go to next, based on the ActivityMapping + * class. * * @param learnerId the learner who are running this activity in the design. * @param activity the activity is being run. * @param lessonId lesson id - * @return the url for next activity. + * @return the updated learner progress */ - public String completeActivity(Integer learnerId,Long activityId,Long lessonId); - + public LearnerProgress completeActivity(Integer learnerId,Activity activity,LearnerProgress progress); + /** - * Complete the activity in the progress engine and delegate to the progress - * engine to calculate the next activity in the learning design. This method should - * be used when we t have an activity that is already part of the Hibernate session. - * It is currently triggered by complete tool session progress from tool. + * Same as LearnerProgress completeActivity(Integer learnerId,Activity activity,LearnerProgress progress) + * except that the it works out the current learner's progress from the given lesson id. * + * Use the other method if you already have the learner progress, as this method looks up the learner + * progress. + * * @param learnerId the learner who are running this activity in the design. * @param activity the activity is being run. * @param lessonId lesson id - * @return the url for next activity. + * @return the updated learner progress */ - public String completeActivity(Integer learnerId,Activity activity,Long lessonId); + public LearnerProgress completeActivity(Integer learnerId,Activity activity,Long lessonId); /** * Retrieve all lessons that has been started, suspended or finished. All Index: lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java,v diff -u -r1.61.4.3 -r1.61.4.4 --- lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java 30 Mar 2007 05:02:21 -0000 1.61.4.3 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java 10 Apr 2007 05:03:22 -0000 1.61.4.4 @@ -30,16 +30,13 @@ import java.util.Date; import java.util.Iterator; import java.util.List; -import java.util.Set; import org.apache.log4j.Logger; import org.lamsfoundation.lams.learning.progress.ProgressEngine; import org.lamsfoundation.lams.learning.progress.ProgressException; import org.lamsfoundation.lams.learning.web.util.ActivityMapping; import org.lamsfoundation.lams.learningdesign.Activity; -import org.lamsfoundation.lams.learningdesign.ComplexActivity; import org.lamsfoundation.lams.learningdesign.GateActivity; -import org.lamsfoundation.lams.learningdesign.Group; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.GroupingActivity; import org.lamsfoundation.lams.learningdesign.ToolActivity; @@ -175,6 +172,7 @@ this.lessonService = lessonService; } + //--------------------------------------------------------------------- // Service Methods //--------------------------------------------------------------------- @@ -426,33 +424,38 @@ returnURL = activityMapping.getProgressBrokenURL(); } else { - // in the future, we might want to see if the entire tool session is completed at this point. - returnURL = completeActivity(new Integer(learnerId.intValue()), toolSession.getToolActivity(), toolSession.getLesson().getLessonId()); + Long lessonId = toolSession.getLesson().getLessonId(); + LearnerProgress currentProgress = getProgress(new Integer(learnerId.intValue()), lessonId); + // TODO Cache the learner progress in the session, but mark it with the progress id. Then get the progress out of the session + // for ActivityAction.java.completeActivity(). Update LearningWebUtil to look under the progress id, so we don't get + // a conflict in Preview & Learner. + returnURL = activityMapping.getCompleteActivityURL(toolSession.getToolActivity().getActivityId(), currentProgress.getLearnerProgressId()); + } if ( log.isDebugEnabled() ) { - log.debug("Moving onto next activity after tool session id "+toolSessionId+" learnerId "+learnerId+" url is "+returnURL); + log.debug("CompleteToolSession() for tool session id "+toolSessionId+" learnerId "+learnerId+" url is "+returnURL); } return returnURL; } /** - * @see org.lamsfoundation.lams.learning.service.ICoreLearnerService#completeActivity(java.lang.Integer, java.lang.Long, java.lang.Long) + * Complete the activity in the progress engine and delegate to the progress + * engine to calculate the next activity in the learning design. + * It is currently triggered by various progress engine related action classes, + * which then calculate the url to go to next, based on the ActivityMapping + * class. + * + * @param learnerId the learner who are running this activity in the design. + * @param activity the activity is being run. + * @param lessonId lesson id + * @return the updated learner progress */ - public String completeActivity(Integer learnerId,Long activityId,Long lessonId) { - Activity activity = activityId!=null ? getActivity(activityId) : null; - return completeActivity(learnerId, activity,lessonId); - } - - /** - * @throws - * @see org.lamsfoundation.lams.learning.service.ICoreLearnerService#completeActivity(java.lang.Integer, org.lamsfoundation.lams.learningdesign.Activity, java.lang.Long ) - */ - public String completeActivity(Integer learnerId,Activity activity,Long lessonId) + public LearnerProgress completeActivity(Integer learnerId,Activity activity,LearnerProgress progress) { - LearnerProgress currentProgress = getProgress(new Integer(learnerId.intValue()), lessonId); + LearnerProgress nextLearnerProgress = null; // Need to synchronise the next bit of code so that if the tool calls // this twice in quick succession, with the same parameters, it won't update @@ -461,41 +464,34 @@ // but if its not synchronised, we get db errors if the same tool session is completed twice // (invalid index). I can'tfind another object on which to synchronise - Hibernate does not give me the // same object for tool session or current progress and user is cached via login, not userid. - String returnURL = null; + // bottleneck synchronized (this) { if (activity==null ) { try { - LearnerProgress nextLearnerProgress = progressEngine.setUpStartPoint(currentProgress); - returnURL = activityMapping.getProgressURL(nextLearnerProgress); + nextLearnerProgress = progressEngine.setUpStartPoint(progress); } catch (ProgressException e) { log.error("error occurred in 'setUpStartPoint':"+e.getMessage(),e); throw new LearnerServiceException(e); - } catch (UnsupportedEncodingException e) { - log.error("error occurred in 'getProgressURL':"+e.getMessage(),e); - throw new LearnerServiceException(e); } - } else if (currentProgress.getCompletedActivities().contains(activity)) { - // return close window url - returnURL = activityMapping.getCloseURL(); - } else { - try - { - LearnerProgress nextLearnerProgress = calculateProgress(activity, learnerId); - returnURL = activityMapping.getProgressURL(nextLearnerProgress); - } - catch (UnsupportedEncodingException e) - { - log.error("error occurred in 'getProgressURL':"+e.getMessage(),e); - throw new LearnerServiceException(e); - } + nextLearnerProgress = calculateProgress(activity, learnerId); } //} - return returnURL; + return nextLearnerProgress; } + /** + * @throws + * @see org.lamsfoundation.lams.learning.service.ICoreLearnerService#completeActivity(java.lang.Integer, org.lamsfoundation.lams.learningdesign.Activity, java.lang.Long ) + */ + public LearnerProgress completeActivity(Integer learnerId,Activity activity,Long lessonId) + { + LearnerProgress currentProgress = getProgress(new Integer(learnerId.intValue()), lessonId); + return completeActivity(learnerId, activity, currentProgress); + } + /** * Exit a lesson. * @see org.lamsfoundation.lams.learning.service.ICoreLearnerService#exitLesson(org.lamsfoundation.lams.lesson.LearnerProgress) @@ -699,6 +695,5 @@ } return (LessonDTO[])lessonDTOList.toArray(new LessonDTO[lessonDTOList.size()]); } - } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ActivityAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ActivityAction.java,v diff -u -r1.25.4.1 -r1.25.4.2 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ActivityAction.java 20 Mar 2007 07:05:17 -0000 1.25.4.1 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ActivityAction.java 10 Apr 2007 05:03:21 -0000 1.25.4.2 @@ -24,13 +24,17 @@ /* $$Id$$ */ package org.lamsfoundation.lams.learning.web.action; +import java.io.UnsupportedEncodingException; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.learning.progress.ProgressException; import org.lamsfoundation.lams.learning.service.ICoreLearnerService; +import org.lamsfoundation.lams.learning.service.LearnerServiceException; import org.lamsfoundation.lams.learning.service.LearnerServiceProxy; import org.lamsfoundation.lams.learning.web.form.ActivityForm; import org.lamsfoundation.lams.learning.web.util.ActivityMapping; @@ -39,7 +43,9 @@ import org.lamsfoundation.lams.learningdesign.LearningDesign; import org.lamsfoundation.lams.lesson.LearnerProgress; import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsAction; +import org.lamsfoundation.lams.web.util.AttributeNames; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -90,7 +96,7 @@ return null; } - + /** * Get the ActionMappings. */ @@ -142,6 +148,6 @@ } return progressSummary.toString(); } - + } \ No newline at end of file Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/CompleteActivityAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/CompleteActivityAction.java,v diff -u -r1.14.4.1 -r1.14.4.2 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/CompleteActivityAction.java 28 Mar 2007 06:41:35 -0000 1.14.4.1 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/CompleteActivityAction.java 10 Apr 2007 05:03:21 -0000 1.14.4.2 @@ -24,18 +24,25 @@ /* $$Id$$ */ package org.lamsfoundation.lams.learning.web.action; +import java.io.IOException; +import java.io.UnsupportedEncodingException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.learning.progress.ProgressException; import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.learning.service.LearnerServiceException; import org.lamsfoundation.lams.learning.web.util.ActivityMapping; import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.lesson.LearnerProgress; +import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -54,53 +61,53 @@ /** * Sets the current activity as complete and uses the progress engine to find - * the next activity (may be null). Currently only used when completing an optional activity. + * the next activity (may be null). + * + * Called when completing an optional activity, or triggered by completeToolSession (via a tool call). + * The activity to be marked as complete must + * @throws IOException + * @throws ServletException */ public ActionForward execute( ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, - HttpServletResponse response) { + HttpServletResponse response) throws IOException, ServletException { ActivityMapping actionMappings = getActivityMapping(); - // check token - if (!this.isTokenValid(request, true)) { - // didn't come here from options page - log.info(className+": No valid token in request"); - return mapping.findForward(ActivityMapping.DOUBLE_SUBMIT_ERROR); - } - ICoreLearnerService learnerService = getLearnerService(); Integer learnerId = LearningWebUtil.getUserId(); - LearnerProgress progress = LearningWebUtil.getLearnerProgress(request, learnerService); Activity activity = LearningWebUtil.getActivityFromRequest(request, learnerService); - if (activity == null) { + LearnerProgress progress = LearningWebUtil.getLearnerProgress(request, learnerService); + Lesson lesson = progress.getLesson(); + + if ( lesson.getLockedForEdit() || activity == null ) { // something has gone wrong - maybe due to Live Edit. No more activity so try to resume Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); progress = learnerService.joinLesson(learnerId, lessonID); + } else if ( progress.getCompletedActivities().contains(activity) ){ + response.sendRedirect(actionMappings.getCloseURL()); + return null; } else { - // Set activity as complete try { - progress = learnerService.calculateProgress(activity, learnerId); + progress = learnerService.completeActivity(learnerId, activity,progress); } catch (LearnerServiceException e) { return mapping.findForward("error"); } - LearningWebUtil.putActivityInRequest(request, progress.getNextActivity(), learnerService); } + LearningWebUtil.putActivityInRequest(request, progress.getNextActivity(), learnerService); LearningWebUtil.putLearnerProgressInRequest(request,progress); - // need to do the calculateProgress first as the chooseActivity changes the progress details setupProgressString(actionForm, request); - - ActionForward forward = actionMappings.getProgressForward(progress,true,request, learnerService); - - return forward; + response.sendRedirect(actionMappings.getProgressURL(progress)); + return null; } + } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/GateAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/GateAction.java,v diff -u -r1.14.4.2 -r1.14.4.3 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/GateAction.java 28 Mar 2007 06:41:35 -0000 1.14.4.2 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/GateAction.java 10 Apr 2007 05:03:20 -0000 1.14.4.3 @@ -37,16 +37,20 @@ import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.learning.service.LearnerServiceException; import org.lamsfoundation.lams.learning.service.LearnerServiceProxy; +import org.lamsfoundation.lams.learning.web.util.ActivityMapping; import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.PermissionGateActivity; import org.lamsfoundation.lams.learningdesign.ScheduleGateActivity; import org.lamsfoundation.lams.learningdesign.SynchGateActivity; +import org.lamsfoundation.lams.lesson.LearnerProgress; import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; /** @@ -98,7 +102,15 @@ /** Input parameter. Boolean value */ public static final String PARAM_FORCE_GATE_OPEN = "force"; - //--------------------------------------------------------------------- + /** + * Get the ActionMappings. + */ + protected ActivityMapping getActivityMapping() { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServlet().getServletContext()); + return (ActivityMapping)wac.getBean("activityMapping"); + } + + //--------------------------------------------------------------------- // Struts Dispatch Method //--------------------------------------------------------------------- /** @@ -124,11 +136,13 @@ //initialize service object ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); Activity activity = learnerService.getActivity(activityId); + ActivityMapping actionMappings = getActivityMapping(); if ( activity == null ) { // if this is a temporary stop gate, created for Live Edit, the activity will have been deleted when Live Edit finished // so manually resume the progress. The completeActivity code can cope with a missing activity. - String nextActivityUrl = learnerService.completeActivity(LearningWebUtil.getUserId(),(Activity)null,lessonId); + LearnerProgress progress = learnerService.completeActivity(LearningWebUtil.getUserId(),(Activity)null,lessonId); + String nextActivityUrl = actionMappings.getProgressURL(progress); response.sendRedirect(nextActivityUrl); return null; @@ -146,7 +160,8 @@ // if we reuse our cached entries, hibernate may throw session errors (if the objects are CGLIB entities). if(gateOpen) { - String nextActivityUrl = learnerService.completeActivity(learner.getUserId(),activityId,lesson.getLessonId()); + LearnerProgress progress = learnerService.completeActivity(LearningWebUtil.getUserId(),activity,lesson.getLessonId()); + String nextActivityUrl = actionMappings.getProgressURL(progress); response.sendRedirect(nextActivityUrl); return null; } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/GroupingAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/GroupingAction.java,v diff -u -r1.24.4.1 -r1.24.4.2 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/GroupingAction.java 12 Mar 2007 05:41:18 -0000 1.24.4.1 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/GroupingAction.java 10 Apr 2007 05:03:21 -0000 1.24.4.2 @@ -52,6 +52,8 @@ import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; /** @@ -104,6 +106,13 @@ public static final String WAIT_GROUP = "waitGroup"; public static final String SHOW_GROUP = "showGroup"; + /** + * Get the ActionMappings. + */ + protected ActivityMapping getActivityMapping() { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServlet().getServletContext()); + return (ActivityMapping)wac.getBean("activityMapping"); + } //--------------------------------------------------------------------- // Struts Dispatch Method @@ -259,10 +268,12 @@ LearnerProgress learnerProgress = LearningWebUtil.getLearnerProgress(request,learnerService); Activity groupingActivity = LearningWebUtil.getActivityFromRequest(request,learnerService); Lesson lesson = learnerService.getLessonByActivity(groupingActivity); - - String nextActivityUrl = learnerService.completeActivity(learnerProgress.getUser().getUserId(), - groupingActivity, lesson.getLessonId()); - response.sendRedirect(nextActivityUrl); + + // so manually resume the progress. The completeActivity code can cope with a missing activity. + LearnerProgress progress = learnerService.completeActivity(learnerProgress.getUser().getUserId(), + groupingActivity, lesson.getLessonId()); + String nextActivityUrl = getActivityMapping().getProgressURL(progress); + response.sendRedirect(nextActivityUrl); return null; } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java,v diff -u -r1.37.2.1 -r1.37.2.2 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java 28 Mar 2007 06:41:35 -0000 1.37.2.1 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java 10 Apr 2007 05:03:21 -0000 1.37.2.2 @@ -152,7 +152,6 @@ //initialize service object ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); - FlashMessage message = null; try { //get user and lesson based on request. Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMapping.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMapping.java,v diff -u -r1.31.2.2 -r1.31.2.3 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMapping.java 30 Mar 2007 05:02:20 -0000 1.31.2.2 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMapping.java 10 Apr 2007 05:03:22 -0000 1.31.2.3 @@ -37,7 +37,6 @@ import org.lamsfoundation.lams.learning.service.LearnerServiceException; import org.lamsfoundation.lams.learning.web.action.ActivityAction; import org.lamsfoundation.lams.learningdesign.Activity; -import org.lamsfoundation.lams.learningdesign.ToolActivity; import org.lamsfoundation.lams.lesson.LearnerProgress; import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.tool.exception.LamsToolServiceException; @@ -62,7 +61,9 @@ public class ActivityMapping implements Serializable { - /* These are global struts forwards. */ + private static final long serialVersionUID = 5887602834473598770L; + + /* These are global struts forwards. */ public static final String ERROR = "error"; public static final String NO_SESSION_ERROR = "noSessionError"; public static final String NO_ACCESS_ERROR = "noAccessError"; @@ -375,8 +376,18 @@ } public String getProgressBrokenURL() { - String lamsUrl = Configuration.get(ConfigurationKeys.SERVER_URL) + LEARNING; - String closeUrl = lamsUrl + "/progressBroken.do"; - return closeUrl; + return strutsActionToURL(activityMappingStrategy.getProgressBrokenAction(),null,true); } + + public String getCompleteActivityURL(Long activityId, Long progressId) { + String url = strutsActionToURL(activityMappingStrategy.getCompleteActivityAction(), null, true); + if ( activityId != null ) { + url = WebUtil.appendParameterToURL(url, AttributeNames.PARAM_ACTIVITY_ID, activityId.toString()); + } + if ( progressId != null ) { + url = WebUtil.appendParameterToURL(url, LearningWebUtil.PARAM_PROGRESS_ID, progressId.toString()); + } + return url; + } + } \ No newline at end of file Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMappingStrategy.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMappingStrategy.java,v diff -u -r1.12.4.1 -r1.12.4.2 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMappingStrategy.java 30 Mar 2007 05:02:20 -0000 1.12.4.1 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMappingStrategy.java 10 Apr 2007 05:03:22 -0000 1.12.4.2 @@ -88,4 +88,12 @@ protected String getProgressBrokenAction() { return PROGRESS_BROKEN_ACTION; } + + /** + * Returns the struts action for the "Complete Activity" call. This calls the complete activity action class, which may go + * to a waiting screen (if currently setting up lock gates for live edit) or the next activity. + */ + protected String getCompleteActivityAction() { + return "/CompleteActivity.do"; + } } Index: lams_learning/web/progressBroken.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_learning/web/progressBroken.jsp,v diff -u -r1.1.2.1 -r1.1.2.2 --- lams_learning/web/progressBroken.jsp 28 Mar 2007 06:43:01 -0000 1.1.2.1 +++ lams_learning/web/progressBroken.jsp 10 Apr 2007 05:03:38 -0000 1.1.2.2 @@ -20,14 +20,10 @@ --%> <%@ taglib uri="tags-fmt" prefix="fmt" %> -
-

- +

Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java,v diff -u -r1.102.2.4 -r1.102.2.5 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 26 Mar 2007 06:06:16 -0000 1.102.2.4 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 10 Apr 2007 05:04:48 -0000 1.102.2.5 @@ -1005,7 +1005,7 @@ } }else{ //if group already exist - learnerService.completeActivity(learner.getUserId(),activity,lessonId); + learnerService.completeActivity(learner.getUserId(),activity,lessonId); if ( log.isDebugEnabled()) { log.debug("Grouping activity [" + activity.getActivityId() + "] is completed."); } @@ -1037,6 +1037,7 @@ toolSession = lamsCoreToolService.getToolSessionByActivity(learner,toolActivity); } learnerService.completeToolSession(toolSession.getToolSessionId(),new Long(learner.getUserId().longValue())); + learnerService.completeActivity(learner.getUserId(),activity,lessonId); if ( log.isDebugEnabled()) { log.debug("Tool activity [" + activity.getActivityId() + "] is completed."); }