Fisheye: Tag 4e049aced5079eff1ff599aa4572624cc0314e59 refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ChooseActivity.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ChooseActivityAction.java =================================================================== diff -u --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ChooseActivityAction.java (revision 0) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/ChooseActivityAction.java (revision 4e049aced5079eff1ff599aa4572624cc0314e59) @@ -0,0 +1,96 @@ +/* +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 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 + +http://www.gnu.org/licenses/gpl.txt +*/ + +package org.lamsfoundation.lams.learning.web.action; + +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.ILearnerService; +import org.lamsfoundation.lams.learning.web.bean.SessionBean; +import org.lamsfoundation.lams.learning.web.form.ActivityForm; +import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.lesson.LearnerProgress; +import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.learning.web.util.ActivityMapping; + +/** + * @author daveg + * + * XDoclet definition: + * + * @struts:action path="/ChooseActivity" name="activityForm" + * validate="false" scope="request" + * + */ +public class ChooseActivityAction extends ActivityAction { + + protected static String className = "ChooseActivity"; + + /** + * Gets an activity from the request (attribute) and forwards onto the required + * jsp (SingleActivity or ParallelActivity). + */ + public ActionForward execute( + ActionMapping mapping, + ActionForm actionForm, + HttpServletRequest request, + HttpServletResponse response) { + ActivityForm form = (ActivityForm) actionForm; + ActivityMapping actionMappings = getActivityMapping(); + + SessionBean sessionBean = getSessionBean(request); + if (sessionBean == null) { + // forward to the no session error page + return mapping.findForward(ActivityMapping.NO_SESSION_ERROR); + } + + // 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); + } + + // Get learner + User learner = sessionBean.getLearner(); + Lesson lesson = sessionBean.getLesson(); + + LearnerProgress progress = getLearnerProgress(request, form); + Activity activity = getActivity(request, form, progress); + + if (activity == null) { + log.error(className+": No activity in request or session"); + return mapping.findForward(ActivityMapping.ERROR); + } + + ILearnerService learnerService = getLearnerService(request); + learnerService.chooseActivity(learner, lesson, activity); + + ActionForward forward = actionMappings.getActivityForward(activity, progress, true); + return forward; + } + +} Fisheye: Tag 4e049aced5079eff1ff599aa4572624cc0314e59 refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/CompleteActivity.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/CompleteActivityAction.java =================================================================== diff -u --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/CompleteActivityAction.java (revision 0) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/CompleteActivityAction.java (revision 4e049aced5079eff1ff599aa4572624cc0314e59) @@ -0,0 +1,112 @@ +/* +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 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 + +http://www.gnu.org/licenses/gpl.txt +*/ + +package org.lamsfoundation.lams.learning.web.action; + +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.ILearnerService; +import org.lamsfoundation.lams.learning.web.bean.SessionBean; +import org.lamsfoundation.lams.learning.web.form.ActivityForm; +import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.lesson.LearnerProgress; +import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.learning.web.util.ActivityMapping; + +/** + * @author daveg + * + * XDoclet definition: + * + * @struts:action path="/CompleteActivity" name="activityForm" + * validate="false" scope="request" + * + */ +public class CompleteActivityAction extends ActivityAction { + + protected static String className = "CompleteActivity"; + + /** + * Sets the current activity as complete and uses the progress engine to find + * the next activity (may be null). Note that the activity being completed may be + * part of a parallel activity. + * Forwards onto the required display action (displayToolActivity, + * displayParallelActivity, etc.). + */ + public ActionForward execute( + ActionMapping mapping, + ActionForm actionForm, + HttpServletRequest request, + HttpServletResponse response) { + ActivityForm form = (ActivityForm)actionForm; + ActivityMapping actionMappings = getActivityMapping(); + + SessionBean sessionBean = getSessionBean(request); + if (sessionBean == null) { + // forward to the no session error page + return mapping.findForward(ActivityMapping.NO_SESSION_ERROR); + } + + // 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); + } + + // Get learner + User learner = sessionBean.getLearner(); + Lesson lesson = sessionBean.getLesson(); + + LearnerProgress progress = getLearnerProgress(request, form); + Activity activity = getActivity(request, form, progress); + + if (activity == null) { + log.error(className+": No activity in request or session"); + return mapping.findForward(ActivityMapping.ERROR); + } + + ILearnerService learnerService = getLearnerService(request); + + // Set activity as complete + try { + progress = learnerService.calculateProgress(activity, learner, lesson); + } + catch (ProgressException e) { + return mapping.findForward("error"); + } + request.setAttribute(ActivityAction.ACTIVITY_REQUEST_ATTRIBUTE, progress.getNextActivity()); + + // Save progress in session for Flash request + sessionBean.setLearnerProgress(progress); + setSessionBean(sessionBean, request); + + ActionForward forward = actionMappings.getProgressForward(progress, true); + + return forward; + } + +} Fisheye: Tag 4e049aced5079eff1ff599aa4572624cc0314e59 refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayActivity.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayActivityAction.java =================================================================== diff -u --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayActivityAction.java (revision 0) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayActivityAction.java (revision 4e049aced5079eff1ff599aa4572624cc0314e59) @@ -0,0 +1,88 @@ +/* +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 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 + +http://www.gnu.org/licenses/gpl.txt +*/ + +package org.lamsfoundation.lams.learning.web.action; + +import javax.servlet.http.*; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.learning.web.bean.SessionBean; +import org.lamsfoundation.lams.learning.web.form.ActivityForm; + +import org.lamsfoundation.lams.usermanagement.*; +import org.lamsfoundation.lams.learning.web.util.ActivityMapping; +import org.lamsfoundation.lams.learningdesign.*; +import org.lamsfoundation.lams.lesson.*; + +/** + * Action class to display an activity. + * + * XDoclet definition: + * + * @struts:action path="/DisplayActivity" name="activityForm" + * validate="false" scope="request" + * + */ +public class DisplayActivityAction extends ActivityAction { + + protected static String className = "DisplayActivity"; + + /** + * Gets an activity from the request (attribute) and forwards onto a + * display action using the ActionMappings class. If no activity is + * in request then use the current activity in learnerProgress. + */ + public ActionForward execute( + ActionMapping mapping, + ActionForm actionForm, + HttpServletRequest request, + HttpServletResponse response) { + ActivityForm form = (ActivityForm) actionForm; + ActivityMapping actionMappings = getActivityMapping(); + + SessionBean sessionBean = getSessionBean(request); + if (sessionBean == null) { + // forward to the no session error page + return mapping.findForward(ActivityMapping.NO_SESSION_ERROR); + } + + // 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; + } + +} \ No newline at end of file Fisheye: Tag 4e049aced5079eff1ff599aa4572624cc0314e59 refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayLoadToolActivity.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 4e049aced5079eff1ff599aa4572624cc0314e59 refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayOptionsActivity.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayOptionsActivityAction.java =================================================================== diff -u --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayOptionsActivityAction.java (revision 0) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayOptionsActivityAction.java (revision 4e049aced5079eff1ff599aa4572624cc0314e59) @@ -0,0 +1,113 @@ +/* +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 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 + +http://www.gnu.org/licenses/gpl.txt +*/ + +package org.lamsfoundation.lams.learning.web.action; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +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.web.bean.ActivityURL; +import org.lamsfoundation.lams.learning.web.form.OptionsActivityForm; + +import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.OptionsActivity; +import org.lamsfoundation.lams.lesson.LearnerProgress; +import org.lamsfoundation.lams.learning.web.util.ActivityMapping; + +/** + * Action class to display an OptionsActivity. + * + * @author daveg + * + * XDoclet definition: + * + * @struts:action path="/DisplayOptionsActivity" name="optionsActivityForm" + * input="/Activity.do" validate="false" scope="request" + * + * @struts:action-forward name="displayOptions" path=".optionsActivity" + * + */ +public class DisplayOptionsActivityAction extends ActivityAction { + + + /** + * Gets an options activity from the request (attribute) and forwards to + * the display JSP. + */ + public ActionForward execute( + ActionMapping mapping, + ActionForm actionForm, + HttpServletRequest request, + HttpServletResponse response) { + OptionsActivityForm form = (OptionsActivityForm)actionForm; + ActivityMapping actionMappings = getActivityMapping(); + + LearnerProgress learnerProgress = getLearnerProgress(request, form); + Activity activity = getActivity(request, form, learnerProgress); + if (!(activity instanceof OptionsActivity)) { + log.error(className+": activity not OptionsActivity "+activity.getActivityId()); + return mapping.findForward(ActivityMapping.ERROR); + } + + OptionsActivity optionsActivity = (OptionsActivity)activity; + + form.setActivityId(activity.getActivityId()); + + List activityURLs = new ArrayList(); + Set subActivities = optionsActivity.getActivities(); + Iterator i = subActivities.iterator(); + int completedCount = 0; + while (i.hasNext()) { + Activity subActivity = (Activity)i.next(); + ActivityURL activityURL = new ActivityURL(); + String url = actionMappings.getActivityURL(subActivity, learnerProgress); + activityURL.setUrl(url); + activityURL.setActivityId(subActivity.getActivityId()); + activityURL.setTitle(subActivity.getTitle()); + activityURL.setDescription(subActivity.getDescription()); + if (learnerProgress.getProgressState(subActivity) == LearnerProgress.ACTIVITY_COMPLETED) { + activityURL.setComplete(true); + completedCount++; + } + activityURLs.add(activityURL); + } + form.setActivityURLs(activityURLs); + if (completedCount >= optionsActivity.getMinNumberOfOptions().intValue()) { + form.setFinished(true); + } + form.setMinimum(optionsActivity.getMinNumberOfOptions().intValue()); + form.setMaximum(optionsActivity.getMaxNumberOfOptions().intValue()); + + this.saveToken(request); + + String forward = "displayOptions"; + return mapping.findForward(forward); + } + +} Fisheye: Tag 4e049aced5079eff1ff599aa4572624cc0314e59 refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayParallelActivity.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayParallelActivityAction.java =================================================================== diff -u --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayParallelActivityAction.java (revision 0) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayParallelActivityAction.java (revision 4e049aced5079eff1ff599aa4572624cc0314e59) @@ -0,0 +1,97 @@ +/* +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 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 + +http://www.gnu.org/licenses/gpl.txt +*/ + +package org.lamsfoundation.lams.learning.web.action; + +import javax.servlet.http.*; + +import java.util.*; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.learning.web.bean.ActivityURL; +import org.lamsfoundation.lams.learning.web.form.ActivityForm; + +import org.lamsfoundation.lams.learningdesign.*; +import org.lamsfoundation.lams.lesson.*; +import org.lamsfoundation.lams.learning.web.util.ActivityMapping; +import org.lamsfoundation.lams.learning.web.util.ParallelActivityMappingStrategy; + +/** + * Action class to display a ParallelActivity. + * + * XDoclet definition: + * + * @struts:action path="/DisplayParallelActivity" name="activityForm" + * validate="false" scope="request" + * + * @struts:action-forward name="displayParallel" path=".parallelActivity" + * + */ +public class DisplayParallelActivityAction extends ActivityAction { + + + /** + * Gets a parallel activity from the request (attribute) and forwards to + * the display JSP. + */ + public ActionForward execute( + ActionMapping mapping, + ActionForm actionForm, + HttpServletRequest request, + HttpServletResponse response) { + ActivityForm form = (ActivityForm)actionForm; + ActivityMapping actionMappings = getActivityMapping(); + actionMappings.setActivityMappingStrategy(new ParallelActivityMappingStrategy()); + + LearnerProgress learnerProgress = getLearnerProgress(request, form); + Activity activity = getActivity(request, form, learnerProgress); + if (!(activity instanceof ParallelActivity)) { + log.error(className+": activity not ParallelActivity "+activity.getActivityId()); + return mapping.findForward(ActivityMapping.ERROR); + } + + ParallelActivity parallelActivity = (ParallelActivity)activity; + + form.setActivityId(activity.getActivityId()); + + List activityURLs = new ArrayList(); + Set subActivities = parallelActivity.getActivities(); + Iterator i = subActivities.iterator(); + while (i.hasNext()) { + Activity subActivity = (Activity)i.next(); + ActivityURL activityURL = new ActivityURL(); + String url = actionMappings.getActivityURL(subActivity, learnerProgress); + activityURL.setUrl(url); + activityURLs.add(activityURL); + } + if (activityURLs.size() == 0) { + log.error(className+": No sub-activity URLs for activity "+activity.getActivityId()); + return mapping.findForward(ActivityMapping.ERROR); + } + form.setActivityURLs(activityURLs); + + String forward = "displayParallel"; + return mapping.findForward(forward); + } + +} \ No newline at end of file Fisheye: Tag 4e049aced5079eff1ff599aa4572624cc0314e59 refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayToolActivity.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayToolActivityAction.java =================================================================== diff -u --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayToolActivityAction.java (revision 0) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/DisplayToolActivityAction.java (revision 4e049aced5079eff1ff599aa4572624cc0314e59) @@ -0,0 +1,79 @@ +/* +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 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 + +http://www.gnu.org/licenses/gpl.txt +*/ + +package org.lamsfoundation.lams.learning.web.action; + +import javax.servlet.http.*; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.learning.web.form.ActivityForm; + +import org.lamsfoundation.lams.learningdesign.*; +import org.lamsfoundation.lams.lesson.*; +import org.lamsfoundation.lams.learning.web.util.ActivityMapping; + +/** + * Action class to forward the user to a Tool. + * + * @author daveg + * + * XDoclet definition: + * + * @struts:action path="/DisplayToolActivity" name="activityForm" + * validate="false" scope="request" + * + */ +public class DisplayToolActivityAction extends ActivityAction { + + /** + * 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) { + ActivityForm form = (ActivityForm)actionForm; + ActivityMapping actionMappings = getActivityMapping(); + + LearnerProgress learnerProgress = getLearnerProgress(request, form); + Activity activity = getActivity(request, form, learnerProgress); + 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 { + response.sendRedirect(url); + } + catch (java.io.IOException e) { + return mapping.findForward(ActivityMapping.ERROR); + } + return null; + } + +} \ No newline at end of file Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LoadToolActivityAction.java =================================================================== diff -u --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LoadToolActivityAction.java (revision 0) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LoadToolActivityAction.java (revision 4e049aced5079eff1ff599aa4572624cc0314e59) @@ -0,0 +1,85 @@ +/* +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 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 + +http://www.gnu.org/licenses/gpl.txt +*/ + +package org.lamsfoundation.lams.learning.web.action; + +import javax.servlet.http.*; + +import java.util.*; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.learning.web.bean.ActivityURL; +import org.lamsfoundation.lams.learning.web.form.ActivityForm; + +import org.lamsfoundation.lams.learningdesign.*; +import org.lamsfoundation.lams.lesson.*; +import org.lamsfoundation.lams.learning.web.util.ActivityMapping; + +/** + * Action class to forward the user to a Tool using an intermediate loading page. + * + * XDoclet definition: + * + * @struts:action path="/LoadToolActivity" name="activityForm" + * validate="false" scope="request" + * + * @struts:action-forward name="displayTool" path=".loadToolActivity" + * + */ +public class LoadToolActivityAction extends ActivityAction { + + /** + * Gets an activity from the request (attribute) and forwards onto a + * loading page. + */ + public ActionForward execute( + ActionMapping mapping, + ActionForm actionForm, + HttpServletRequest request, + HttpServletResponse response) { + ActivityForm form = (ActivityForm)actionForm; + ActivityMapping actionMappings = getActivityMapping(); + + LearnerProgress learnerProgress = getLearnerProgress(request, form); + Activity activity = getActivity(request, form, learnerProgress); + 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 forward = "displayTool"; + return mapping.findForward(forward); + } + +} \ No newline at end of file Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMappingStrategy.java =================================================================== diff -u -r2ca1fa90ed42cdcd0438bad1b8282f39c995d2b1 -r4e049aced5079eff1ff599aa4572624cc0314e59 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMappingStrategy.java (.../ActivityMappingStrategy.java) (revision 2ca1fa90ed42cdcd0438bad1b8282f39c995d2b1) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/ActivityMappingStrategy.java (.../ActivityMappingStrategy.java) (revision 4e049aced5079eff1ff599aa4572624cc0314e59) @@ -65,7 +65,7 @@ } if (activity instanceof ToolActivity) { // get tool URL - strutsAction = "/DisplayLoadToolActivity.do"; + strutsAction = "/LoadToolActivity.do"; //strutsAction = "/DisplayToolActivity.do"; } } Index: lams_learning/test/java/org/lamsfoundation/lams/learning/service/TestLearnerService.java =================================================================== diff -u -r37d57ffca3a7c99569c37287463c82f195923fbd -r4e049aced5079eff1ff599aa4572624cc0314e59 --- lams_learning/test/java/org/lamsfoundation/lams/learning/service/TestLearnerService.java (.../TestLearnerService.java) (revision 37d57ffca3a7c99569c37287463c82f195923fbd) +++ lams_learning/test/java/org/lamsfoundation/lams/learning/service/TestLearnerService.java (.../TestLearnerService.java) (revision 4e049aced5079eff1ff599aa4572624cc0314e59) @@ -79,7 +79,7 @@ private static final long TEST_SR_ACTIVITY_ID = 33; private static final long TEST_SQNA_ACTIVITY_ID = 34; private static final String HOST="http://localhost:8080/lams_learning/"; - private static final String LOAD_TOOL_URL="/DisplayLoadToolActivity.do"; + private static final String LOAD_TOOL_URL="/LoadToolActivity.do"; private static final String PARAM_ACTIVITY_ID="?activityId="; /* * @see TestCase#setUp() Index: lams_learning/web/WEB-INF/struts/struts-config.xml =================================================================== diff -u -r37af5b14c1ca675771b0e28c941c75d338427b8c -r4e049aced5079eff1ff599aa4572624cc0314e59 --- lams_learning/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision 37af5b14c1ca675771b0e28c941c75d338427b8c) +++ lams_learning/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision 4e049aced5079eff1ff599aa4572624cc0314e59) @@ -26,10 +26,6 @@ type="org.lamsfoundation.lams.learning.web.form.TestDblSubmitForm" /> - @@ -93,52 +89,35 @@ - - - - - - - - - - - + javax.servlet.jsp.jstl.fmt.localizationContext org.lamsfoundation.lams.learning.LearningResources @@ -34,6 +35,27 @@ + + HibernateFilter org.springframework.orm.hibernate.support.OpenSessionInViewFilter @@ -47,6 +69,26 @@ + HibernateFilter *.do @@ -62,51 +104,80 @@ project's merge dir. --> - - - context - org.springframework.web.context.ContextLoaderServlet - 1 - - - action - org.apache.struts.action.ActionServlet - - config - /WEB-INF/struts/struts-config.xml - - - debug - 999 - - - detail - 2 - - - validate - true - - 2 - + + + + context + org.springframework.web.context.ContextLoaderServlet + 1 + + + action + org.apache.struts.action.ActionServlet + + config + /WEB-INF/struts/struts-config.xml + + + debug + 999 + + + detail + 2 + + + validate + true + + 2 + + + + + + action + *.do + + 120 @@ -125,6 +196,26 @@ --> + http://jakarta.apache.org/struts/struts-bean