Index: lams_learning/conf/xdoclet/struts-actions.xml =================================================================== diff -u -ref88986af21bf84c5fd8770e62b40d03f90aae9e -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision ef88986af21bf84c5fd8770e62b40d03f90aae9e) +++ lams_learning/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -25,7 +25,7 @@ + parameter="/learner.do?method=joinLesson&userId=2&lessonId=2" /> contextConfigLocation /WEB-INF/spring/dataAccessContext.xml /WEB-INF/spring/applicationContext.xml /WEB-INF/spring/learningApplicationContext.xml - /WEB-INF/spring/lessonApplicationContext.xml /WEB-INF/spring/toolApplicationContext.xml + /WEB-INF/spring/lessonApplicationContext.xml /WEB-INF/spring/toolApplicationContext.xml + /WEB-INF/spring/learningDesignApplicationContext.xml Index: lams_learning/lib/lams/lams.jar =================================================================== diff -u -r3b567a2a4db4064f9c2aec96ffd5789ff7634788 -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 Binary files differ Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ActivityAction.java =================================================================== diff -u -r47a0b22c0f3ff85ed2d419ad50912025d55c9cfa -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ActivityAction.java (.../ActivityAction.java) (revision 47a0b22c0f3ff85ed2d419ad50912025d55c9cfa) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ActivityAction.java (.../ActivityAction.java) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -26,13 +26,12 @@ import java.util.*; import org.lamsfoundation.lams.learning.service.ILearnerService; -import org.lamsfoundation.lams.learning.service.LearnerService; import org.lamsfoundation.lams.learning.service.LearnerServiceProxy; import org.lamsfoundation.lams.learning.web.bean.SessionBean; import org.lamsfoundation.lams.learning.web.form.ActivityForm; import org.lamsfoundation.lams.learning.web.util.ActivityMapping; +import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; -import org.lamsfoundation.lams.usermanagement.*; import org.lamsfoundation.lams.web.action.LamsAction; import org.lamsfoundation.lams.lesson.*; import org.lamsfoundation.lams.learningdesign.*; @@ -53,9 +52,7 @@ * Get the learner service. */ protected ILearnerService getLearnerService() { - ILearnerService learnerService = (LearnerService)LearnerServiceProxy.getLearnerService(this.getServlet().getServletContext()); - //learnerService.setRequest(request); - //learnerService.setActionMappings(actionMappings); + ILearnerService learnerService = LearnerServiceProxy.getLearnerService(this.getServlet().getServletContext()); return learnerService; } @@ -73,19 +70,15 @@ * the LearnerService. The LearnerProgress is also stored in the * session so that the Flash requests don't have to reload it. */ - protected LearnerProgress getLearnerProgress(HttpServletRequest request, ActivityForm form) { - LearnerProgress learnerProgress = (LearnerProgress)request.getAttribute(ActivityAction.LEARNER_PROGRESS_REQUEST_ATTRIBUTE); - if (learnerProgress == null) { - SessionBean sessionBean = getSessionBean(request); - User learner = sessionBean.getLearner(); - Lesson lesson = sessionBean.getLesson(); - - ILearnerService learnerService = getLearnerService(); - learnerProgress = learnerService.getProgress(learner, lesson); - - // Save progress in session for Flash request - sessionBean.setLearnerProgress(learnerProgress); - setSessionBean(sessionBean, request); + protected LearnerProgress getLearnerProgress(HttpServletRequest request) { + + LearnerProgress learnerProgress = (LearnerProgress)request.getAttribute(ActivityAction.LEARNER_PROGRESS_REQUEST_ATTRIBUTE); + + if (learnerProgress == null) + { + SessionBean sessionBean = LearningWebUtil.getSessionBean(request,getServlet().getServletContext()); + learnerProgress = sessionBean.getLearnerProgress(); + setSessionBean(sessionBean, request); } return learnerProgress; } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ChooseActivityAction.java =================================================================== diff -u -rf0f13cd7ba427bab1d37dc3a8a14e290c98245ef -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ChooseActivityAction.java (.../ChooseActivityAction.java) (revision f0f13cd7ba427bab1d37dc3a8a14e290c98245ef) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ChooseActivityAction.java (.../ChooseActivityAction.java) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -78,7 +78,7 @@ User learner = sessionBean.getLearner(); Lesson lesson = sessionBean.getLesson(); - LearnerProgress progress = getLearnerProgress(request, form); + LearnerProgress progress = getLearnerProgress(request); Activity activity = getActivity(request, form, progress); if (activity == null) { Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/CompleteActivityAction.java =================================================================== diff -u -rf0f13cd7ba427bab1d37dc3a8a14e290c98245ef -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/CompleteActivityAction.java (.../CompleteActivityAction.java) (revision f0f13cd7ba427bab1d37dc3a8a14e290c98245ef) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/CompleteActivityAction.java (.../CompleteActivityAction.java) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -26,7 +26,6 @@ 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.ILearnerService; import org.lamsfoundation.lams.learning.service.LearnerServiceException; import org.lamsfoundation.lams.learning.web.bean.SessionBean; @@ -82,7 +81,7 @@ User learner = sessionBean.getLearner(); Lesson lesson = sessionBean.getLesson(); - LearnerProgress progress = getLearnerProgress(request, form); + LearnerProgress progress = getLearnerProgress(request); Activity activity = getActivity(request, form, progress); if (activity == null) { @@ -105,7 +104,7 @@ sessionBean.setLearnerProgress(progress); setSessionBean(sessionBean, request); - ActionForward forward = actionMappings.getProgressForward(progress, true); + ActionForward forward = actionMappings.getProgressForward(progress,true,request); return forward; } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayActivityAction.java =================================================================== diff -u -red8afe78a454a4b3b9d2ae039ac12d7ad9dc809a -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayActivityAction.java (.../DisplayActivityAction.java) (revision ed8afe78a454a4b3b9d2ae039ac12d7ad9dc809a) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayActivityAction.java (.../DisplayActivityAction.java) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -27,13 +27,14 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.learning.service.LearnerServiceProxy; import org.lamsfoundation.lams.learning.web.bean.SessionBean; -import org.lamsfoundation.lams.learning.web.form.ActivityForm; import org.lamsfoundation.lams.learning.web.util.ActivityMapping; -//import org.lamsfoundation.lams.learningdesign.*; -//import org.lamsfoundation.lams.lesson.*; +import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; + + /** * Action class to display an activity. * @@ -57,8 +58,6 @@ // Instance variables //--------------------------------------------------------------------- private static Logger log = Logger.getLogger(DisplayActivityAction.class); - - //protected static String className = "DisplayActivity"; /** * Gets an activity from the request (attribute) and forwards onto a @@ -70,41 +69,20 @@ HttpServletRequest request, HttpServletResponse response) { - ActivityForm form = (ActivityForm) actionForm; - ActivityMapping actionMappings = getActivityMapping(); - //TODO check up the learner progress, if not present, get it from db. - SessionBean sessionBean = getSessionBean(request); - // forward to the no session error page - if (sessionBean == null) - return mapping.findForward(ActivityMapping.NO_SESSION_ERROR); + ActivityMapping actionMappings = LearnerServiceProxy.getActivityMapping(this.getServlet().getServletContext()); + SessionBean sessionBean = LearningWebUtil.getSessionBean(request,getServlet().getServletContext()); + if(log.isDebugEnabled()) log.debug("Entering display activity: the session bean is" + sessionBean.toString()); - // Get learner - //User learner = sessionBean.getLearner(); - //Lesson lesson = sessionBean.getLesson(); - //LearnerProgress learnerProgress = getLearnerProgress(request, form); - //Activity activity = getActivity(request, form, learnerProgress); - - //if (activity == null) { - /*log.error(className+": No activity in request or session"); - return mapping.findForward(actionMappings.ERROR);*/ - // Get current activity from learnerProgress - // activity = learnerProgress.getCurrentActivity(); - //} - //setActivity(request, activity); - - //ActionForward forward = actionMappings.getActivityForward(activity, learnerProgress, false); - //return forward; - ActionForward forward =actionMappings.getProgressForward(sessionBean.getLearnerProgress(),false); + ActionForward forward =actionMappings.getProgressForward(sessionBean.getLearnerProgress(),false,request); if(log.isDebugEnabled()) log.debug(forward.toString()); return forward; } - } \ No newline at end of file Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayOptionsActivityAction.java =================================================================== diff -u -r4e049aced5079eff1ff599aa4572624cc0314e59 -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayOptionsActivityAction.java (.../DisplayOptionsActivityAction.java) (revision 4e049aced5079eff1ff599aa4572624cc0314e59) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayOptionsActivityAction.java (.../DisplayOptionsActivityAction.java) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -68,7 +68,7 @@ OptionsActivityForm form = (OptionsActivityForm)actionForm; ActivityMapping actionMappings = getActivityMapping(); - LearnerProgress learnerProgress = getLearnerProgress(request, form); + LearnerProgress learnerProgress = getLearnerProgress(request); Activity activity = getActivity(request, form, learnerProgress); if (!(activity instanceof OptionsActivity)) { log.error(className+": activity not OptionsActivity "+activity.getActivityId()); Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayParallelActivityAction.java =================================================================== diff -u -red8afe78a454a4b3b9d2ae039ac12d7ad9dc809a -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayParallelActivityAction.java (.../DisplayParallelActivityAction.java) (revision ed8afe78a454a4b3b9d2ae039ac12d7ad9dc809a) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayParallelActivityAction.java (.../DisplayParallelActivityAction.java) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -63,7 +63,7 @@ ActivityMapping actionMappings = getActivityMapping(); actionMappings.setActivityMappingStrategy(new ParallelActivityMappingStrategy()); - LearnerProgress learnerProgress = getLearnerProgress(request, form); + LearnerProgress learnerProgress = getLearnerProgress(request); Activity activity = getActivity(request, form, learnerProgress); if (!(activity instanceof ParallelActivity)) { log.error(className+": activity not ParallelActivity "+activity.getActivityId()); Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayToolActivityAction.java =================================================================== diff -u -r4e049aced5079eff1ff599aa4572624cc0314e59 -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayToolActivityAction.java (.../DisplayToolActivityAction.java) (revision 4e049aced5079eff1ff599aa4572624cc0314e59) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayToolActivityAction.java (.../DisplayToolActivityAction.java) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -49,28 +49,31 @@ * Gets a tool activity from the request (attribute) and uses a redirect * to forward the user to the tool. */ - public ActionForward execute( - ActionMapping mapping, - ActionForm actionForm, - HttpServletRequest request, - HttpServletResponse response) { + public ActionForward execute(ActionMapping mapping, + ActionForm actionForm, + HttpServletRequest request, + HttpServletResponse response) + { ActivityForm form = (ActivityForm)actionForm; ActivityMapping actionMappings = getActivityMapping(); - LearnerProgress learnerProgress = getLearnerProgress(request, form); + LearnerProgress learnerProgress = getLearnerProgress(request); Activity activity = getActivity(request, form, learnerProgress); - if (!(activity instanceof ToolActivity)) { + if (!(activity instanceof ToolActivity)) + { log.error(className+": activity not ToolActivity"); return mapping.findForward(ActivityMapping.ERROR); } ToolActivity toolActivity = (ToolActivity)activity; - String url = actionMappings.getToolURL(toolActivity, learnerProgress); - try { + String url = actionMappings.getLearnerToolURL(toolActivity, learnerProgress.getUser()); + try + { response.sendRedirect(url); } - catch (java.io.IOException e) { + catch (java.io.IOException e) + { return mapping.findForward(ActivityMapping.ERROR); } return null; Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java =================================================================== diff -u -r3b567a2a4db4064f9c2aec96ffd5789ff7634788 -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java (.../LearnerAction.java) (revision 3b567a2a4db4064f9c2aec96ffd5789ff7634788) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java (.../LearnerAction.java) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -187,7 +187,7 @@ request.getSession().setAttribute(SessionBean.NAME,new SessionBean(learner, lesson, learnerProgress)); - + //serialize a acknowledgement flash message with the path of display next //activity String lessonJoined = WDDXProcessor.serialize(new FlashMessage("joinLesson", @@ -198,9 +198,10 @@ //we hand over the control to flash. response.getWriter().print(lessonJoined); - //as flash is called the next struts action, we don't need to forward to - //anything. - return null; + + //TODO this should return null once flash side is done, it should be + //called by flash side + return mapping.findForward(DISPLAY_ACTIVITY); } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LoadToolActivityAction.java =================================================================== diff -u -red8afe78a454a4b3b9d2ae039ac12d7ad9dc809a -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LoadToolActivityAction.java (.../LoadToolActivityAction.java) (revision ed8afe78a454a4b3b9d2ae039ac12d7ad9dc809a) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LoadToolActivityAction.java (.../LoadToolActivityAction.java) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -21,13 +21,14 @@ package org.lamsfoundation.lams.learning.web.action; -import javax.servlet.http.*; -import java.util.*; +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.service.LearnerServiceProxy; import org.lamsfoundation.lams.learning.web.bean.ActivityURL; import org.lamsfoundation.lams.learning.web.form.ActivityForm; @@ -58,25 +59,24 @@ HttpServletResponse response) { ActivityForm form = (ActivityForm)actionForm; - ActivityMapping actionMappings = getActivityMapping(); + ActivityMapping actionMappings = LearnerServiceProxy.getActivityMapping(this.getServlet().getServletContext()); - LearnerProgress learnerProgress = getLearnerProgress(request, form); + LearnerProgress learnerProgress = getLearnerProgress(request); Activity activity = getActivity(request, form, learnerProgress); - if (!(activity instanceof ToolActivity)) { + + if (!(activity instanceof ToolActivity)) + { log.error(className+": activity not ToolActivity"); return mapping.findForward(ActivityMapping.ERROR); } ToolActivity toolActivity = (ToolActivity)activity; - + form.setActivityId(activity.getActivityId()); - List activityURLs = new ArrayList(); - String url = actionMappings.getToolURL(toolActivity, learnerProgress); - ActivityURL activityURL = new ActivityURL(); - activityURL.setUrl(url); - activityURLs.add(activityURL); - form.setActivityURLs(activityURLs); + String url = actionMappings.getLearnerToolURL(toolActivity, learnerProgress.getUser()); + + form.addActivityURL(new ActivityURL(activity.getActivityId(),url)); return mapping.findForward("displayTool"); } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/bean/ActivityURL.java =================================================================== diff -u -r36c2ed010b8a3893b895d781be1a219f2380e62d -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/bean/ActivityURL.java (.../ActivityURL.java) (revision 36c2ed010b8a3893b895d781be1a219f2380e62d) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/bean/ActivityURL.java (.../ActivityURL.java) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -36,6 +36,15 @@ private String description; private boolean complete; + public ActivityURL(){} + + public ActivityURL(Long activityId, + String url) + { + this.activityId = activityId; + this.url = url; + } + public boolean isComplete() { return complete; } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/form/ActivityForm.java =================================================================== diff -u -r9db14cc7d6b0e02505eda4bbbb718395cabffccf -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/form/ActivityForm.java (.../ActivityForm.java) (revision 9db14cc7d6b0e02505eda4bbbb718395cabffccf) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/form/ActivityForm.java (.../ActivityForm.java) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -27,6 +27,7 @@ import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.learning.web.bean.ActivityURL; /** * @author daveg @@ -80,4 +81,11 @@ public void setActivityId(Long activityId) { this.activityId = activityId; } + + public void addActivityURL(ActivityURL activityUrl) + { + if(this.activityURLs ==null) + this.activityURLs = new ArrayList(); + this.activityURLs.add(activityUrl); + } } \ No newline at end of file Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMapping.java =================================================================== diff -u -r3b567a2a4db4064f9c2aec96ffd5789ff7634788 -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMapping.java (.../ActivityMapping.java) (revision 3b567a2a4db4064f9c2aec96ffd5789ff7634788) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMapping.java (.../ActivityMapping.java) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -1,34 +1,37 @@ /* -Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -USA + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA -http://www.gnu.org/licenses/gpl.txt -*/ + http://www.gnu.org/licenses/gpl.txt + */ package org.lamsfoundation.lams.learning.web.util; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; +import javax.servlet.http.HttpServletRequest; + import org.apache.struts.action.ActionForward; import org.apache.struts.action.ForwardingActionForward; import org.apache.struts.action.RedirectingActionForward; 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.GroupingActivity; import org.lamsfoundation.lams.learningdesign.ParallelActivity; @@ -52,275 +55,313 @@ * @author daveg * */ -public class ActivityMapping implements Serializable { +public class ActivityMapping implements Serializable +{ - /* These are global struts forwards. */ + /* 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"; public static final String DOUBLE_SUBMIT_ERROR = "doubleSubmitError"; - + private ActivityMappingStrategy activityMappingStrategy = new ActivityMappingStrategy(); - + private ILamsToolService toolService; private String baseURL; + /** + * Creates a Struts ActionForward to display an activity. + * @param activity, the Activity to be displayed + * @param progress, the LearnerProgress associated with the Activity and learner + */ + public ActionForward getActivityForward(Activity activity, + LearnerProgress progress, + boolean redirect) + { + ActionForward actionForward = null; - /** - * Creates a Struts ActionForward to display an activity. - * @param activity, the Activity to be displayed - * @param progress, the LearnerProgress associated with the Activity and learner - */ - public ActionForward getActivityForward(Activity activity, LearnerProgress progress, boolean redirect) { - ActionForward actionForward = null; + //String strutsAction = getActivityAction(activity, progress); + String strutsAction = this.activityMappingStrategy.getActivityAction(activity, + progress); + if (activity instanceof ToolActivity) + { + // always use redirect false for a ToolActivity as ToolDisplayActivity + // does it's own redirect + actionForward = strutsActionToForward(strutsAction, activity, false); + } + else + { + actionForward = strutsActionToForward(strutsAction, + activity, + redirect); + } - //String strutsAction = getActivityAction(activity, progress); - String strutsAction = this.activityMappingStrategy.getActivityAction(activity, progress); - if (activity instanceof ToolActivity) { - // always use redirect false for a ToolActivity as ToolDisplayActivity - // does it's own redirect - actionForward = strutsActionToForward(strutsAction, activity, false); - } - else { - actionForward = strutsActionToForward(strutsAction, activity, redirect); - } - - return actionForward; - } + return actionForward; + } - /** - * Creates a Struts ActionForward to display a next activity. If the - * previous activity was a ParallelActivity then the frames will be - * cleared. - * @param progress, the LearnerProgress associated with the Activity and learner - * @param redirect, If true a RedirectActionForward is used - * @return - */ - public ActionForward getProgressForward(LearnerProgress progress, boolean redirect) { - ActionForward actionForward = null; + /** + * Creates a Struts ActionForward to display a next activity. If the + * previous activity was a ParallelActivity then the frames will be + * cleared. + * @param progress, the LearnerProgress associated with the Activity and learner + * @param redirect, If true a RedirectActionForward is used + * @return + */ + public ActionForward getProgressForward(LearnerProgress progress, + boolean redirect, + HttpServletRequest request) + { + ActionForward actionForward = null; - // TODO: lesson complete client request to clear frames - if (progress.isLessonComplete()) { - // If lesson complete forward to lesson complete action. This action will - // cause a client request to clear ALL frames. - String strutsAction = this.getActivityMappingStrategy().getLessonCompleteAction(); - actionForward = this.strutsActionToForward(strutsAction, null, redirect); - } - else { - Activity nextActivity = progress.getNextActivity(); - Activity previousActivity = progress.getPreviousActivity(); - Activity currentActivity = progress.getCurrentActivity(); - - if (progress.isParallelWaiting()) { - // progress is waiting, goto waiting page - String strutsAction = this.getActivityMappingStrategy().getWaitingAction(); - actionForward = this.strutsActionToForward(strutsAction, null, redirect); - } - else { - // display next activity - if (previousActivity instanceof ParallelActivity) { - // if previous activity was a parallel activity then we need to - // clear frames. - String strutsAction = "/requestDisplay.do"; - String activityURL = this.getActivityURL(nextActivity, progress); - strutsAction += "?url="+activityURL; - actionForward = strutsActionToForward(strutsAction, null, redirect); - } - else { - actionForward = getActivityForward(nextActivity, progress, redirect); - } - } - } + // TODO: lesson complete client request to clear frames + if (progress.isLessonComplete()) + { + // If lesson complete forward to lesson complete action. This action will + // cause a client request to clear ALL frames. + String strutsAction = this.getActivityMappingStrategy() + .getLessonCompleteAction(); + actionForward = this.strutsActionToForward(strutsAction, + null, + redirect); + } + else + { - return actionForward; - } - - /** - * Generates an ActivityURL for an Activity using it's progress. The URL is for - * the client and so includes hostname etc. - * Note that the URL could also be a wait message or a jsp to clear the frames. - * @param activity, the Activity to be displayed - * @param progress, the LearnerProgress associated with the Activity and learner - */ - public String getActivityURL(Activity activity, LearnerProgress progress) - { - String strutsAction = this.activityMappingStrategy.getActivityAction(activity, progress); - return strutsActionToURL(strutsAction, activity, true); - } - - /** - * Generates an ActivityURL for the next Activity using it's progress. The URL - * is for the client and so includes hostname etc. - * Note that this method always returns a LAMS URLs, if a ToolActivity is next - * the URL will be the action for displaying the tool. - * Note that the URL could also be a wait message or a jsp to clear the frames. - * @param progress, the current LearnerProgress. - * @throws UnsupportedEncodingException - */ - public String getProgressURL(LearnerProgress progress) throws UnsupportedEncodingException { - String activityURL = null; - - // TODO: lesson complete - if (progress.isLessonComplete()) - { - // If lesson complete forward to lesson complete action. This action will - // cause a client request to clear ALL frames. - String strutsAction = this.getActivityMappingStrategy().getLessonCompleteAction(); - activityURL = strutsActionToURL(strutsAction, null, true); - } - else - { - //Activity currentActivity = progress.getCurrentActivity(); - - if (progress.isParallelWaiting()) - { - // progress is waiting, goto waiting page - String strutsAction = this.getActivityMappingStrategy().getWaitingAction(); - activityURL = strutsActionToURL(strutsAction, null, true); - } - else - { - // display next activity - activityURL = this.getActivityURL(progress.getNextActivity(), progress); - if (progress.getPreviousActivity() instanceof ParallelActivity) - { - // if previous activity was a parallel activity then we need to - // clear frames. - String strutsAction = "/requestDisplay.do"; - String redirectURL = strutsActionToURL(strutsAction, null, true); - activityURL = URLEncoder.encode(activityURL,"UTF-8"); - activityURL = redirectURL+"?url="+activityURL; - } - } - } - - return activityURL; - } - + if (progress.isParallelWaiting()) + { + // progress is waiting, goto waiting page + String strutsAction = this.getActivityMappingStrategy() + .getWaitingAction(); + actionForward = this.strutsActionToForward(strutsAction, + null, + redirect); + } + else + { + // display next activity + if (progress.getPreviousActivity() instanceof ParallelActivity) + { + // if previous activity was a parallel activity then we need to + // clear frames. + String strutsAction = "/requestDisplay.do"; + String activityURL = this.getActivityURL(progress.getNextActivity(), + progress); + strutsAction += "?url=" + activityURL; + actionForward = strutsActionToForward(strutsAction, + null, + redirect); + } + else + { + actionForward = getActivityForward(progress.getNextActivity(), + progress, + redirect); + //setup activity into request for display + request.setAttribute(ActivityAction.ACTIVITY_REQUEST_ATTRIBUTE, + progress.getNextActivity()); + } + } + } + return actionForward; + } - /** - * Generates an ActivityURL for a Tool Activity. The URL is for the tool and - * not for the tool loading page. The URL also includes toolSessionId and all - * other required data. - * @param activity, the ToolActivity to be displayed - * @param progress, the current LearnerProgress, used to get activity status - */ - public String getToolURL(ToolActivity activity, LearnerProgress progress) { + /** + * Generates an ActivityURL for an Activity using it's progress. The URL is for + * the client and so includes hostname etc. + * Note that the URL could also be a wait message or a jsp to clear the frames. + * @param activity, the Activity to be displayed + * @param progress, the LearnerProgress associated with the Activity and learner + */ + public String getActivityURL(Activity activity, LearnerProgress progress) + { + String strutsAction = this.activityMappingStrategy.getActivityAction(activity, + progress); + return strutsActionToURL(strutsAction, activity, true); + } - ToolSession toolSession; - try - { - // Get tool session using learner and activity - toolSession = toolService.getToolSessionByLearner(progress.getUser(), activity); - } - catch (LamsToolServiceException e) { - // TODO: should throw exception here - return null; - } - // Append toolSessionId to tool URL - return activity.getTool().getLearnerUrl()+"?toolSessionId="+toolSession.getToolSessionId(); - } - - - /** - * Creates a URL for a struts action and an activity. - * @param strutsAction, the struts action path. - * @param activity, the activity the action is for. - * @param useContext, if true prepends the server and context to the URL. - */ - protected String strutsActionToURL(String strutsAction, Activity activity, boolean useContext) { - String url = strutsAction; - - if (activity != null) { - String query = "?activityId="+activity.getActivityId(); - url += query; - } - if (useContext) { - String lamsUrl = getLamsURL(); - url = lamsUrl+url; - } + /** + * Generates an ActivityURL for the next Activity using it's progress. The URL + * is for the client and so includes hostname etc. + * Note that this method always returns a LAMS URLs, if a ToolActivity is next + * the URL will be the action for displaying the tool. + * Note that the URL could also be a wait message or a jsp to clear the frames. + * @param progress, the current LearnerProgress. + * @throws UnsupportedEncodingException + */ + public String getProgressURL(LearnerProgress progress) throws UnsupportedEncodingException + { + String activityURL = null; - return url; - } - - private String getLamsURL() { - return baseURL; - } - - /** - * Creates a Struts ActionForward for an action and activity. - * @param strutsAction, the struts action - * @param activity, activity that is being displayed - * @param redirect, should the action be a client redirect - * @return - */ - protected ActionForward strutsActionToForward(String strutsAction, Activity activity, boolean redirect) { - ActionForward actionForward; - if (redirect) { - String activityURL = strutsActionToURL(strutsAction, activity, false); - actionForward = new RedirectingActionForward(activityURL); - actionForward.setName(WebUtil.getStrutsForwardNameFromPath(strutsAction)); - } - else { - actionForward = new ForwardingActionForward(strutsAction); - actionForward.setName(WebUtil.getStrutsForwardNameFromPath(strutsAction)); - - } - - return actionForward; - } - - /** - * Calculate the activity url for progress view at learner side. - * @param learner the learner who owns the progress data - * @param activity the activity the learner want to view - * @return the url for that tool. - */ - public String calculateActivityURLForProgressView(User learner, Activity activity) - { - //Activity activity = learnerService.getActivity(activityId); - try + // TODO: lesson complete + if (progress.isLessonComplete()) { - if(activity instanceof ToolActivity) + // If lesson complete forward to lesson complete action. This action will + // cause a client request to clear ALL frames. + String strutsAction = this.getActivityMappingStrategy() + .getLessonCompleteAction(); + activityURL = strutsActionToURL(strutsAction, null, true); + } + else + { + //Activity currentActivity = progress.getCurrentActivity(); + + if (progress.isParallelWaiting()) { - ToolSession toolSession = toolService.getToolSessionByActivity(learner,(ToolActivity) activity); - return ((ToolActivity)activity).getTool().getLearnerUrl() - +"&" - +WebUtil.PARAM_TOOL_SESSION_ID - +"=" - +toolSession.getToolSessionId().toString() - +"&" - +WebUtil.PARAM_MODE - +"=" - +ToolAccessMode.LEARNER; + // progress is waiting, goto waiting page + String strutsAction = this.getActivityMappingStrategy() + .getWaitingAction(); + activityURL = strutsActionToURL(strutsAction, null, true); } - else if(activity instanceof GroupingActivity) - //TODO need to be changed when group action servlet is done - return "/viewGrouping.do?"; + else + { + // display next activity + activityURL = this.getActivityURL(progress.getNextActivity(), + progress); + if (progress.getPreviousActivity() instanceof ParallelActivity) + { + // if previous activity was a parallel activity then we need to + // clear frames. + String strutsAction = "/requestDisplay.do"; + String redirectURL = strutsActionToURL(strutsAction, + null, + true); + activityURL = URLEncoder.encode(activityURL, "UTF-8"); + activityURL = redirectURL + "?url=" + activityURL; + } + } } + + return activityURL; + } + + /** + * Generates an ActivityURL for a Tool Activity. The URL is for the tool and + * not for the tool loading page. The URL also includes toolSessionId and all + * other required data. + * @param activity, the ToolActivity to be displayed + * @param progress, the current LearnerProgress, used to get activity status + */ + public String getLearnerToolURL(ToolActivity activity, User learner) + { + + ToolSession toolSession; + try + { + // Get tool session using learner and activity + toolSession = toolService.getToolSessionByLearner(learner, activity); + } catch (LamsToolServiceException e) { //TODO define an exception at web layer throw new LearnerServiceException(e.getMessage()); } - - throw new LearnerServiceException("Fails to get the progress url view" + - " for activity["+activity.getActivityId().longValue()+"]"); - } - - public void setToolService(ILamsToolService toolService) { - this.toolService = toolService; - } - - public void setBaseURL(String baseURL) { - this.baseURL = baseURL; - } - - public ActivityMappingStrategy getActivityMappingStrategy() { - return activityMappingStrategy; - } - - public void setActivityMappingStrategy(ActivityMappingStrategy activityMappingStrategy) { - this.activityMappingStrategy = activityMappingStrategy; - } -} + // Append toolSessionId to tool URL + return activity.getTool().getLearnerUrl() + "&" + + WebUtil.PARAM_TOOL_SESSION_ID + "=" + + toolSession.getToolSessionId().toString() + "&" + + WebUtil.PARAM_MODE + "=" + ToolAccessMode.LEARNER; + } + + /** + * Creates a URL for a struts action and an activity. + * @param strutsAction, the struts action path. + * @param activity, the activity the action is for. + * @param useContext, if true prepends the server and context to the URL. + */ + protected String strutsActionToURL(String strutsAction, + Activity activity, + boolean useContext) + { + String url = strutsAction; + + if (activity != null) + { + String query = "?activityId=" + activity.getActivityId(); + url += query; + } + if (useContext) + { + String lamsUrl = getLamsURL(); + url = lamsUrl + url; + } + + return url; + } + + private String getLamsURL() + { + return baseURL; + } + + /** + * Creates a Struts ActionForward for an action and activity. + * @param strutsAction, the struts action + * @param activity, activity that is being displayed + * @param redirect, should the action be a client redirect + * @return + */ + protected ActionForward strutsActionToForward(String strutsAction, + Activity activity, + boolean redirect) + { + ActionForward actionForward; + if (redirect) + { + String activityURL = strutsActionToURL(strutsAction, + activity, + false); + actionForward = new RedirectingActionForward(activityURL); + actionForward.setName(WebUtil.getStrutsForwardNameFromPath(strutsAction)); + } + else + { + actionForward = new ForwardingActionForward(strutsAction); + actionForward.setName(WebUtil.getStrutsForwardNameFromPath(strutsAction)); + + } + + return actionForward; + } + + /** + * Calculate the activity url for progress view at learner side. + * @param learner the learner who owns the progress data + * @param activity the activity the learner want to view + * @return the url for that tool. + */ + public String calculateActivityURLForProgressView(User learner, + Activity activity) + { + + if (activity instanceof ToolActivity) + { + return getLearnerToolURL(((ToolActivity) activity), learner); + } + else if (activity instanceof GroupingActivity) + //TODO need to be changed when group action servlet is done + return "/viewGrouping.do?"; + + throw new LearnerServiceException("Fails to get the progress url view" + + " for activity[" + activity.getActivityId().longValue() + "]"); + } + + public void setToolService(ILamsToolService toolService) + { + this.toolService = toolService; + } + + public void setBaseURL(String baseURL) + { + this.baseURL = baseURL; + } + + public ActivityMappingStrategy getActivityMappingStrategy() + { + return activityMappingStrategy; + } + + public void setActivityMappingStrategy(ActivityMappingStrategy activityMappingStrategy) + { + this.activityMappingStrategy = activityMappingStrategy; + } +} \ No newline at end of file Index: lams_learning/test/web/WEB-INF/spring/applicationContext.xml =================================================================== diff -u -r47a0b22c0f3ff85ed2d419ad50912025d55c9cfa -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/test/web/WEB-INF/spring/applicationContext.xml (.../applicationContext.xml) (revision 47a0b22c0f3ff85ed2d419ad50912025d55c9cfa) +++ lams_learning/test/web/WEB-INF/spring/applicationContext.xml (.../applicationContext.xml) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -26,7 +26,7 @@ com.mysql.jdbc.Driver - jdbc:mysql://localhost/lams + jdbc:mysql://localhost/lams?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull lams lamsdemo @@ -57,12 +57,13 @@ org/lamsfoundation/lams/learningdesign/LearningDesign.hbm.xml org/lamsfoundation/lams/learningdesign/LearningLibrary.hbm.xml org/lamsfoundation/lams/learningdesign/Transition.hbm.xml + org/lamsfoundation/lams/learningdesign/License.hbm.xml org/lamsfoundation/lams/lesson/LearnerProgress.hbm.xml org/lamsfoundation/lams/lesson/Lesson.hbm.xml - + org/lamsfoundation/lams/tool/Tool.hbm.xml org/lamsfoundation/lams/tool/ToolContent.hbm.xml @@ -147,40 +148,6 @@ - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: lams_learning/web/WEB-INF/lib/commons-lang-2.0.jar =================================================================== diff -u Binary files differ Index: lams_learning/web/WEB-INF/lib/commons-lang.jar =================================================================== diff -u -rc47073639465a5a05b59d8e975d5274e881a908a -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 Binary files differ Index: lams_learning/web/WEB-INF/lib/lams.jar =================================================================== diff -u -r3b567a2a4db4064f9c2aec96ffd5789ff7634788 -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 Binary files differ Index: lams_learning/web/WEB-INF/lib/wddx-1.0a-lfl-0.2.jar =================================================================== diff -u Binary files differ Index: lams_learning/web/WEB-INF/spring/applicationContext.xml =================================================================== diff -u -rdff12756a175de59fb0e8ea5d44e9fc1a3bc7f24 -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/web/WEB-INF/spring/applicationContext.xml (.../applicationContext.xml) (revision dff12756a175de59fb0e8ea5d44e9fc1a3bc7f24) +++ lams_learning/web/WEB-INF/spring/applicationContext.xml (.../applicationContext.xml) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -1,25 +1,4 @@ - - + + + + com.mysql.jdbc.Driver + jdbc:mysql://localhost/lams?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull + lams + lamsdemo + + + - + @@ -79,10 +68,6 @@ org/lamsfoundation/lams/tool/Tool.hbm.xml org/lamsfoundation/lams/tool/ToolContent.hbm.xml org/lamsfoundation/lams/tool/ToolSession.hbm.xml - - - - @@ -163,47 +148,6 @@ - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: lams_learning/web/WEB-INF/spring/learningApplicationContext.xml =================================================================== diff -u -red8afe78a454a4b3b9d2ae039ac12d7ad9dc809a -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/web/WEB-INF/spring/learningApplicationContext.xml (.../learningApplicationContext.xml) (revision ed8afe78a454a4b3b9d2ae039ac12d7ad9dc809a) +++ lams_learning/web/WEB-INF/spring/learningApplicationContext.xml (.../learningApplicationContext.xml) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -19,6 +19,7 @@ + @@ -42,7 +43,7 @@ - + http://localhost:8080/lams_learning/ Index: lams_learning/web/WEB-INF/spring/learningDesignApplicationContext.xml =================================================================== diff -u --- lams_learning/web/WEB-INF/spring/learningDesignApplicationContext.xml (revision 0) +++ lams_learning/web/WEB-INF/spring/learningDesignApplicationContext.xml (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: lams_learning/web/WEB-INF/struts/struts-config.xml =================================================================== diff -u -r32e9a495b2ccacfc4febc13648d255f466742a03 -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision 32e9a495b2ccacfc4febc13648d255f466742a03) +++ lams_learning/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -293,7 +293,7 @@ + parameter="/learner.do?method=joinLesson&userId=2&lessonId=2" /> contextConfigLocation /WEB-INF/spring/dataAccessContext.xml /WEB-INF/spring/applicationContext.xml /WEB-INF/spring/learningApplicationContext.xml - /WEB-INF/spring/lessonApplicationContext.xml /WEB-INF/spring/toolApplicationContext.xml + /WEB-INF/spring/lessonApplicationContext.xml /WEB-INF/spring/toolApplicationContext.xml + /WEB-INF/spring/learningDesignApplicationContext.xml Index: lams_learning/web/main.jsp =================================================================== diff -u -ref88986af21bf84c5fd8770e62b40d03f90aae9e -rfbdb2da2ab69a24876c89c0f37ca8eb30df40990 --- lams_learning/web/main.jsp (.../main.jsp) (revision ef88986af21bf84c5fd8770e62b40d03f90aae9e) +++ lams_learning/web/main.jsp (.../main.jsp) (revision fbdb2da2ab69a24876c89c0f37ca8eb30df40990) @@ -41,7 +41,7 @@ - +