Index: lams_common/src/java/org/lamsfoundation/lams/learning/service/ICoreLearnerService.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learning/service/ICoreLearnerService.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learning/service/ICoreLearnerService.java (revision 24e3879be322523d08055711ab6fa8968047782b) @@ -0,0 +1,326 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General License version 2.0 + * as published by the Free Software Foundation. + * + * 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 License for more details. + * + * You should have received a copy of the GNU General License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.learning.service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.BranchingActivity; +import org.lamsfoundation.lams.learningdesign.GateActivity; +import org.lamsfoundation.lams.learningdesign.Group; +import org.lamsfoundation.lams.learningdesign.Grouping; +import org.lamsfoundation.lams.learningdesign.SequenceActivity; +import org.lamsfoundation.lams.learningdesign.dao.IActivityDAO; +import org.lamsfoundation.lams.learningdesign.dto.ActivityURL; +import org.lamsfoundation.lams.learningdesign.dto.GateActivityDTO; +import org.lamsfoundation.lams.lesson.LearnerProgress; +import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.lesson.dto.LessonDTO; +import org.lamsfoundation.lams.tool.exception.LamsToolServiceException; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; + +/** + * + * All Learner service methods that are available within the core. These methods may require all the tool's Spring + * context files to be loaded, in addition to the core Spring context files. Hence it should only be used from + * lams-learning, lams-monitoring, lams-central wars. + */ +public interface ICoreLearnerService extends ILearnerService { + /** Get the user service. Used when the action needs the real user object, not just the userId */ + IUserManagementService getUserManagementService(); + + /** + * Gets the lesson object for the given key. + * + */ + Lesson getLesson(Long lessonID); + + /** + * Joins a User to a a new lesson as a learner + * + * @param learnerId + * the Learner's userID + * @param lessionID + * identifies the Lesson to start + * @throws LearnerServiceException + * in case of problems. + */ + LearnerProgress joinLesson(Integer learnerId, Long lessonID); + + /** + * This method navigate through all the tool activities for the given activity. For each tool activity, we look up + * the database to check up the existance of correspondent tool session. If the tool session doesn't exist, we + * create a new tool session instance. + * + * @param learnerProgress + * the learner progress we are processing. + * @throws LamsToolServiceException + */ + void createToolSessionsIfNecessary(Activity activity, LearnerProgress learnerProgress); + + /** + * Returns the current progress data of the User. + * + * @param learnerId + * the Learner's userID + * @param lessonId + * the Lesson to get progress from. + * @return LearnerProgess contains the learner's progress for the lesson. + * @throws LearnerServiceException + * in case of problems. + */ + LearnerProgress getProgress(Integer learnerId, Long lessonId); + + /** + * Get the last attempt ID for the given learner and lesson. + */ + Integer getProgressArchiveMaxAttemptID(Integer userId, Long lessonId); + + /** + * Returns the current progress data, in the DTO format required by the jsp progress screen, of the User. + * + * @param learnerId + * the Learner's userID + * @param lessonId + * the Lesson to get progress from. + * @return Array of two objects. [0] List, [1] Activity ID of the current activity + * @throws LearnerServiceException + * in case of problems. + */ + Object[] getStructuredActivityURLs(Integer learnerId, Long lessonId); + + List getStructuredActivityURLs(Long lessonId); + + /** + * Return the current progress data against progress id. + * + * @param progressId + * @return + */ + LearnerProgress getProgressById(Long progressId); + + /** + * Marks an activity as attempted. Called when a user selects an OptionsActivity. + * + * @param learnerId + * the Learner's userID + * @param lessonId + * the Lesson to get progress from. + * @param activity + * the activity being attempted. + * @param clearCompletedFlag + * If the lesson is completed but this activity is unstarted, should we mark it as incomplete? Used for + * branching and optional sequences for skipped sequences (e.g. force completed branching) + * @return LearnerProgress + */ + LearnerProgress chooseActivity(Integer learnerId, Long lessonId, Activity activity, Boolean clearCompletedFlag); + + /** + * Calculates learner progress and returns the data required to be displayed to the learner (including URL(s)). This + * method is included in the interface for testing purposes. + * + * @param completedActivityID + * identifies the activity just completed + * @param learner + * the Learner + * @throws LearnerServiceException + * in case of problems. + */ + void calculateProgress(Activity completedActivity, Integer learnerId, LearnerProgress learnerProgress); + + /** + * 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. + */ + void completeActivity(Integer learnerId, Activity activity, Long progressID); + + /** + * If specified activity is set to produce ToolOutput, calculates and stores mark to gradebook. + * + * @param toolActivity + * @param progress + */ + void updateGradebookMark(Activity activity, LearnerProgress progress); + + /** + * Retrieve all lessons that has been started, suspended or finished. All finished but archived lesson should not be + * loaded. + * + * @param learner + * the user who intend to start a lesson + * @return a list of active lessons. + */ + LessonDTO[] getActiveLessonsFor(Integer learnerId); + + /** + * Returns an activity according to the activity id. + * + * @param activityId + * the activity id. + * @return the activity requested. + */ + Activity getActivity(Long activityId); + + /** + * Perform grouping for the learners who have started the lesson, based on the grouping activity. + * + * @param lessonId + * lesson id + * @param groupingActivityId + * the activity that has create grouping. + * @param learnerId + * the learner who triggers the grouping. + * @param forceGrouping + * if forceGrouping==true and the lesson is a preview lesson then the groupings is done irrespective of + * the grouping type + * @return true if grouping done, false if waiting for grouping to occur + */ + boolean performGrouping(Long lessonId, Long groupingActivityId, Integer learnerId, boolean forceGrouping); + + /** + * Perform grouping for the learner, depending on his/hers choice. + * + * @param lessonId + * lesson id + * @param groupingActivityId + * the activity that create grouping. + * @param groupId + * id of the group chosen by the learner + * @param learnerId + * the learner who triggers the grouping. + * @return true if the learner was successfully added to the group; false if the group was empty + * @throws LearnerServiceException + */ + boolean learnerChooseGroup(Long lessonId, Long groupingActivityId, Long groupId, Integer learnerId) + throws LearnerServiceException; + + /** + * Returns the maximum number of learners per group in learner's choice grouping. + * + * @param lessonId + * id of the lesson + * @param groupingId + * id of the grouping activity + * @return the maximum number of learners per group;null if the requirement for equal number of + * learners in groups was not set + */ + Integer calculateMaxNumberOfLearnersPerGroup(Long lessonId, Grouping grouping); + + Grouping getGrouping(Long groupingId); + + /** + * Check up the gate status to go through the gate. This also updates the gate. This method should be used when we + * do not have an grouping activity that is already part of the Hibernate session. + * + * @param gateid + * the gate that current learner is facing. It could be synch gate, schedule gate or permission gate. + * @param knocker + * the learner who wants to go through the gate. + * @param forceGate + * if forceGate==true and the lesson is a preview lesson then the gate is opened straight away. + * @return Updated gate details + */ + GateActivityDTO knockGate(Long gateActivityId, User knocker, boolean forceGate); + + /** + * Check up the gate status to go through the gate. This also updates the gate. This method should be used when we + * do have an grouping activity that is already part of the Hibernate session. + * + * @param gate + * the gate that current learner is facing. It could be synch gate, schedule gate or permission gate. + * Don't supply the actual gate from the cached web version as it might be out of date or not attached to + * the session + * @param knocker + * the learner who wants to go through the gate. + * @param forceGate + * if forceGate==true and the lesson is a preview lesson then the gate is opened straight away. + * @return Updated gate details + */ + GateActivityDTO knockGate(GateActivity gateActivity, User knocker, boolean forceGate); + + Set getGroupsForGate(GateActivity gate); + + /** + * Get the lesson for this activity. If the activity is not part of a lesson (ie is from an authoring design then it + * will return null. + */ + Lesson getLessonByActivity(Activity activity); + + /** + * + * @param learnerId + * the learner who triggers the move + * @param lessonId + * lesson id + * @param fromActivity + * Activity moving from + * @param toActivity + * Activity moving to (being run) + * @return updated Learner Progress + */ + LearnerProgress moveToActivity(Integer learnerId, Long lessonId, Activity fromActivity, Activity toActivity); + + /** + * Work out which branch to which a user should go. If the current lesson is a preview lesson, it will force the + * user to a branch if at all possible. + * + * @param lesson + * current lesson. + * @param BranchingActivity + * the branching activity + * @param learnerId + * the learner who triggers the grouping. + * @throws LearnerServiceException + */ + SequenceActivity determineBranch(Lesson lesson, BranchingActivity branchingActivity, Integer learnerId) + throws LearnerServiceException; + + /** + * Select a particular branch - we are in preview mode and the author has selected a particular activity. + * + * @param lesson + * current lesson. + * @param BranchingActivity + * the branching activity + * @param learnerId + * the learner who triggers the grouping. + * @return branchId of the desired branch + * @throws LearnerServiceException + */ + SequenceActivity selectBranch(Lesson lesson, BranchingActivity branchingActivity, Integer learnerId, Long branchId) + throws LearnerServiceException; + + /* Added for RepopulateProgressMarksServlet - can be removed later */ + String[] recalcProgressForLearner(Lesson lesson, ArrayList activityList, LearnerProgress learnerProgress, + boolean updateGradebookForAll); + + boolean isKumaliveDisabledForOrganisation(Integer organisationId); + + IActivityDAO getActivityDAO(); + +} Index: lams_common/src/java/org/lamsfoundation/lams/learning/service/ILearnerService.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learning/service/ILearnerService.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learning/service/ILearnerService.java (revision 24e3879be322523d08055711ab6fa8968047782b) @@ -0,0 +1,57 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.learning.service; + +import org.lamsfoundation.lams.learningdesign.dto.ActivityPositionDTO; +import org.lamsfoundation.lams.tool.ToolOutput; + +/** + * Learner service methods available to tools. These methods should work fine as long as the web context contains the + * core Spring context files. + */ +public interface ILearnerService { + /** + * Marks an tool session as complete and calculates the next activity against the learning design. This method is + * for tools to redirect the client on complete. + * + * Do not change learnerId to Integer (to match the other calls) as all the tools expect this to be a Long. + * + * @param toolSessionId + * , session ID for completed tool + * @param learnerId + * the learner who is completing the tool session. + * @return the URL for the next activity + * @throws LearnerServiceException + * in case of problems. + */ + public String completeToolSession(Long toolSessionId, Long learnerId); + + ToolOutput getToolInput(Long requestingToolContentId, Integer assigmentId, Integer learnerId); + + ActivityPositionDTO getActivityPosition(Long activityId); + + ActivityPositionDTO getActivityPositionByToolSessionId(Long toolSessionId); + + void createCommandForLearner(Long lessonId, String userName, String jsonCommand); +} Index: lams_common/src/java/org/lamsfoundation/lams/learning/service/LearnerServiceException.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learning/service/LearnerServiceException.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learning/service/LearnerServiceException.java (revision 24e3879be322523d08055711ab6fa8968047782b) @@ -0,0 +1,73 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.learning.service; + +/** + * Type of exception thrown by the learning service. + * + * @author chris + */ +public class LearnerServiceException extends java.lang.RuntimeException { + + /** + * Creates a new instance of LearnerServiceException without detail message. + */ + public LearnerServiceException() { + } + + /** + * Constructs an instance of LearnerServiceException with the specified detail message. + * + * @param msg + * the detail message. + */ + public LearnerServiceException(String msg) { + super(msg); + } + + /** + * Constructs an instance of LearnerServiceException + * for wrapping both the customized error message and + * throwable exception object. + * + * @param message + * @param cause + */ + public LearnerServiceException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs an instance of LearnerServiceException + * for wrapping an throwable exception object. + * + * @param message + * @param cause + */ + public LearnerServiceException(Throwable cause) { + super(cause); + } + +} Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/ActivityPositionDTO.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/ActivityPositionDTO.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/ActivityPositionDTO.java (revision 24e3879be322523d08055711ab6fa8968047782b) @@ -0,0 +1,60 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.learning.web.bean; + +/** + * Marks activity position within Learning Design. It can be extended to find out exact position (for example, 4th + * activity of total 10). + * + * @author Marcin Cieslak + */ +public class ActivityPositionDTO { + private Boolean last; + private Boolean first; + private Integer activityCount; + + public Boolean getLast() { + return last; + } + + public void setLast(Boolean last) { + this.last = last; + } + + public Boolean getFirst() { + return first; + } + + public void setFirst(Boolean first) { + this.first = first; + } + + public Integer getActivityCount() { + return activityCount; + } + + public void setActivityCount(Integer activityCount) { + this.activityCount = activityCount; + } +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/ActivityURL.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/ActivityURL.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/ActivityURL.java (revision 24e3879be322523d08055711ab6fa8968047782b) @@ -0,0 +1,152 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.learning.web.bean; + +import java.util.List; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Display bean for an activity. Holds the URL used to display the activity along with title, description and a + * completion flag. + * + * If used for the learner progress screen, the defaultURL will always be false. + * + * @author daveg + * + */ +public class ActivityURL { + private String type; + private Long activityId; + private String url; + private String title; + private String description; + private boolean complete; + private boolean floating; + private byte status; + private boolean defaultURL; + private List childActivities; + + public ActivityURL() { + } + + public ActivityURL(Long activityId, String url) { + this.activityId = activityId; + this.url = url; + this.floating = false; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public boolean isComplete() { + return complete; + } + + public void setComplete(boolean complete) { + this.complete = complete; + } + + public boolean isFloating() { + return floating; + } + + public boolean getFloating() { + return floating; + } + + public void setFloating(boolean floating) { + this.floating = floating; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Long getActivityId() { + return activityId; + } + + public void setActivityId(Long activityId) { + this.activityId = activityId; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isDefaultURL() { + return defaultURL; + } + + public void setDefaultURL(boolean defaultURL) { + this.defaultURL = defaultURL; + } + + public byte getStatus() { + return status; + } + + public void setStatus(byte status) { + this.status = status; + } + + /** Get a list of the urls for the child activities. Only used on the jsp progress display page */ + public List getChildActivities() { + return childActivities; + } + + public void setChildActivities(List childActivities) { + this.childActivities = childActivities; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("activityId", activityId).append("title", title).append("url", url) + .toString(); + } + +} Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/GateActivityDTO.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/GateActivityDTO.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/GateActivityDTO.java (revision 24e3879be322523d08055711ab6fa8968047782b) @@ -0,0 +1,65 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.learning.web.bean; + +import org.lamsfoundation.lams.learningdesign.GateActivity; + +/** + * DTO wrapping a normal Gate Activity class, with an extra "calculated" field added for the learning module's gate + * screen. + * + */ +public class GateActivityDTO { + private GateActivity gate; + + private Integer expectedLearnerCount; + private Integer waitingLearnerCount; + private boolean allowToPass; + + public GateActivityDTO(GateActivity gate, Integer expectedLearnerCount, Integer waitingLearnerCount, + boolean allowToPass) { + this.gate = gate; + + this.expectedLearnerCount = expectedLearnerCount; + this.waitingLearnerCount = waitingLearnerCount; + + this.allowToPass = allowToPass || gate.getGateOpen(); + } + + public GateActivity getGate() { + return gate; + } + + public Integer getExpectedLearnerCount() { + return expectedLearnerCount; + } + + public Integer getWaitingLearnerCount() { + return waitingLearnerCount; + } + + public boolean getAllowToPass() { + return allowToPass; + } +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/util/WebUtil.java =================================================================== diff -u -rb3c871874679a1d784db0d7dfac2fdabe65baf83 -r24e3879be322523d08055711ab6fa8968047782b --- lams_common/src/java/org/lamsfoundation/lams/util/WebUtil.java (.../WebUtil.java) (revision b3c871874679a1d784db0d7dfac2fdabe65baf83) +++ lams_common/src/java/org/lamsfoundation/lams/util/WebUtil.java (.../WebUtil.java) (revision 24e3879be322523d08055711ab6fa8968047782b) @@ -1,28 +1,29 @@ package org.lamsfoundation.lams.util; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.security.Principal; import java.util.HashMap; import java.util.Map.Entry; +import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.tomcat.util.json.JSONException; import org.apache.tomcat.util.json.JSONObject; +import org.lamsfoundation.lams.learning.service.ILearnerService; +import org.lamsfoundation.lams.learningdesign.dto.ActivityPositionDTO; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; /** * helper methods useful for servlets @@ -619,4 +620,22 @@ return decodedLessonId; } + + /** + * Finds activity position within Learning Design and stores it as request attribute. + */ + public static ActivityPositionDTO putActivityPositionInRequestByToolSessionId(Long toolSessionId, + HttpServletRequest request, ServletContext context) { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(context); + ILearnerService learnerService = (ILearnerService) wac.getBean("learnerService"); + if (learnerService == null) { + log.warn("Can not set activity position, no Learner service in servlet context."); + return null; + } + ActivityPositionDTO positionDTO = learnerService.getActivityPositionByToolSessionId(toolSessionId); + if (positionDTO != null) { + request.setAttribute(AttributeNames.ATTR_ACTIVITY_POSITION, positionDTO); + } + return positionDTO; + } } \ No newline at end of file Index: lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml =================================================================== diff -u -r5b60c76a61d420733e2c4c96513249cb9a65a484 -r24e3879be322523d08055711ab6fa8968047782b --- lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml (.../learningApplicationContext.xml) (revision 5b60c76a61d420733e2c4c96513249cb9a65a484) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml (.../learningApplicationContext.xml) (revision 24e3879be322523d08055711ab6fa8968047782b) @@ -55,6 +55,7 @@ + Fisheye: Tag 24e3879be322523d08055711ab6fa8968047782b refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/service/ICoreLearnerService.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 24e3879be322523d08055711ab6fa8968047782b refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/service/ILearnerService.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java =================================================================== diff -u -r60355e9a91260c605e1a55e1f2329dd69fea08b9 -r24e3879be322523d08055711ab6fa8968047782b --- lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java (.../LearnerService.java) (revision 60355e9a91260c605e1a55e1f2329dd69fea08b9) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java (.../LearnerService.java) (revision 24e3879be322523d08055711ab6fa8968047782b) @@ -39,12 +39,11 @@ import org.lamsfoundation.lams.gradebook.service.IGradebookService; import org.lamsfoundation.lams.learning.command.dao.ICommandDAO; import org.lamsfoundation.lams.learning.command.model.Command; +import org.lamsfoundation.lams.learning.kumalive.model.Kumalive; +import org.lamsfoundation.lams.learning.kumalive.service.IKumaliveService; import org.lamsfoundation.lams.learning.progress.ProgressBuilder; import org.lamsfoundation.lams.learning.progress.ProgressEngine; import org.lamsfoundation.lams.learning.progress.ProgressException; -import org.lamsfoundation.lams.learning.web.bean.ActivityPositionDTO; -import org.lamsfoundation.lams.learning.web.bean.ActivityURL; -import org.lamsfoundation.lams.learning.web.bean.GateActivityDTO; import org.lamsfoundation.lams.learning.web.util.ActivityMapping; import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; import org.lamsfoundation.lams.learningdesign.Activity; @@ -71,6 +70,9 @@ import org.lamsfoundation.lams.learningdesign.dao.IDataFlowDAO; import org.lamsfoundation.lams.learningdesign.dao.IGroupUserDAO; import org.lamsfoundation.lams.learningdesign.dao.IGroupingDAO; +import org.lamsfoundation.lams.learningdesign.dto.ActivityPositionDTO; +import org.lamsfoundation.lams.learningdesign.dto.ActivityURL; +import org.lamsfoundation.lams.learningdesign.dto.GateActivityDTO; import org.lamsfoundation.lams.lesson.CompletedActivityProgress; import org.lamsfoundation.lams.lesson.LearnerProgress; import org.lamsfoundation.lams.lesson.Lesson; @@ -118,6 +120,7 @@ private static HashMap syncMap = new HashMap(); private IGradebookService gradebookService; private ILogEventService logEventService; + private IKumaliveService kumaliveService; // --------------------------------------------------------------------- // Inversion of Control Methods - Constructor injection @@ -217,6 +220,10 @@ public void setLogEventService(ILogEventService logEventService) { this.logEventService = logEventService; } + + public void setKumaliveService(IKumaliveService kumaliveService) { + this.kumaliveService = kumaliveService; + } // --------------------------------------------------------------------- // Service Methods @@ -1389,7 +1396,9 @@ commandDAO.insert(command); } - @Override + /** + * Used by CommandWebsocketServer. + */ public List getCommandsForLesson(Long lessonId, Date laterThan) { return commandDAO.getNewCommands(lessonId, laterThan); } @@ -1596,6 +1605,12 @@ return status; } + + @Override + public boolean isKumaliveDisabledForOrganisation(Integer organisationId) { + Kumalive kumalive = kumaliveService.getKumaliveByOrganisation(organisationId); + return kumalive == null || kumalive.getFinished(); + } @Override public IActivityDAO getActivityDAO() { Fisheye: Tag 24e3879be322523d08055711ab6fa8968047782b refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerServiceException.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 24e3879be322523d08055711ab6fa8968047782b refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/web/bean/ActivityPositionDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 24e3879be322523d08055711ab6fa8968047782b refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/web/bean/ActivityURL.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 24e3879be322523d08055711ab6fa8968047782b refers to a dead (removed) revision in file `lams_learning/src/java/org/lamsfoundation/lams/learning/web/bean/GateActivityDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/LearningWebUtil.java =================================================================== diff -u -r16593058f78a135e25dae055f0fc16c4bed4da42 -r24e3879be322523d08055711ab6fa8968047782b --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/LearningWebUtil.java (.../LearningWebUtil.java) (revision 16593058f78a135e25dae055f0fc16c4bed4da42) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/util/LearningWebUtil.java (.../LearningWebUtil.java) (revision 24e3879be322523d08055711ab6fa8968047782b) @@ -35,9 +35,9 @@ import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.learning.service.ILearnerService; import org.lamsfoundation.lams.learning.service.LearnerServiceException; -import org.lamsfoundation.lams.learning.web.bean.ActivityPositionDTO; -import org.lamsfoundation.lams.learning.web.bean.ActivityURL; import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.dto.ActivityPositionDTO; +import org.lamsfoundation.lams.learningdesign.dto.ActivityURL; import org.lamsfoundation.lams.lesson.LearnerProgress; import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.usermanagement.User; @@ -220,22 +220,4 @@ } return positionDTO; } - - /** - * Finds activity position within Learning Design and stores it as request attribute. - */ - public static ActivityPositionDTO putActivityPositionInRequestByToolSessionId(Long toolSessionId, - HttpServletRequest request, ServletContext context) { - WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(context); - ILearnerService learnerService = (ILearnerService) wac.getBean("learnerService"); - if (learnerService == null) { - LearningWebUtil.log.warn("Can not set activity position, no Learner service in servlet context."); - return null; - } - ActivityPositionDTO positionDTO = learnerService.getActivityPositionByToolSessionId(toolSessionId); - if (positionDTO != null) { - request.setAttribute(AttributeNames.ATTR_ACTIVITY_POSITION, positionDTO); - } - return positionDTO; - } } \ No newline at end of file