Index: lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java =================================================================== diff -u -r49c83fb1fa62a2ed7c4de6c2bb2698106d2b3efa -r3d3c8abbcf06fbea4ab6c43ccc6e3d1b7a3e335b --- lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision 49c83fb1fa62a2ed7c4de6c2bb2698106d2b3efa) +++ lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision 3d3c8abbcf06fbea4ab6c43ccc6e3d1b7a3e335b) @@ -202,8 +202,19 @@ verifyPostRequestMethod(request); element = removeAllLessons(document, serverId, datetime, hashValue, username, courseId); - + + } else if (method.equals(CentralConstants.METHOD_REMOVE_USER)) { + verifyPostRequestMethod(request); + + lsId = new Long(lsIdStr); + element = removeUser(document, serverId, datetime, hashValue, username, lsId, userIds); + } else if (method.equals(CentralConstants.METHOD_REMOVE_ALL_USERS)) { + verifyPostRequestMethod(request); + + lsId = new Long(lsIdStr); + element = removeAllUsers(document, serverId, datetime, hashValue, username, lsId); + } else if (method.equals(CentralConstants.METHOD_STUDENT_PROGRESS)) { lsId = new Long(lsIdStr); element = getAllStudentProgress(document, serverId, datetime, hashValue, username, lsId, courseId); @@ -578,7 +589,72 @@ return lessonsElement; } + + /** + * Deletes all lessons from the specified course. + */ + private Element removeUser(Document document, String serverId, String datetime, String hashValue, + String username, long lsId, String userIds) throws Exception { + // Create the root node of the xml document + Element usersElement = document.createElement("Users"); + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); + Authenticator.authenticate(serverMap, datetime, username, hashValue); + +// ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, username); + //check is user monitor? + + String[] extUsernames = (userIds != null) ? userIds.split(",") : new String[0]; + for (String extUsername : extUsernames) { + + ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, extUsername); + Integer userId = userMap.getUser().getUserId(); + // remove user + lessonService.removeLearner(lsId, userId); + + // add userId to output xml document + Element lessonElement = document.createElement("User"); + lessonElement.setAttribute(CentralConstants.PARAM_USER_ID, "" + userId); + lessonElement.setAttribute(CentralConstants.ATTR_DELETED, "true"); + usersElement.appendChild(lessonElement); + } + + return usersElement; + } + + /** + * Deletes all lessons from the specified course. + */ + private Element removeAllUsers(Document document, String serverId, String datetime, String hashValue, + String username, long lsId) throws Exception { + // Create the root node of the xml document + Element usersElement = document.createElement("Users"); + + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); + Authenticator.authenticate(serverMap, datetime, username, hashValue); + +// ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, username); + + Lesson lesson = LessonManagerServlet.lessonService.getLesson(lsId); + Set users = lesson.getAllLearners(); + if (users != null) { + for (User user : users) { + + Integer userId = user.getUserId(); + // remove user + lessonService.removeLearner(lsId, userId); + + // add userId to output xml document + Element lessonElement = document.createElement("User"); + lessonElement.setAttribute(CentralConstants.PARAM_USER_ID, "" + userId); + lessonElement.setAttribute(CentralConstants.ATTR_DELETED, "true"); + usersElement.appendChild(lessonElement); + } + } + + return usersElement; + } + private Long startPreview(String serverId, String datetime, String hashValue, String username, Long ldId, String courseId, String title, String desc, String countryIsoCode, String langIsoCode, String customCSV, boolean presenceEnable, boolean imEnable) throws RemoteException {