Index: lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java =================================================================== diff -u -ree35ce3afcea957fc919c15fb254ae593cdb44c2 -reae819648876ce003b2797c2d2f387e10897e0b1 --- lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java (.../AuthoringAction.java) (revision ee35ce3afcea957fc919c15fb254ae593cdb44c2) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java (.../AuthoringAction.java) (revision eae819648876ce003b2797c2d2f387e10897e0b1) @@ -405,7 +405,7 @@ Integer userID = getUserId(); User user = (User) getUserManagementService().findById(User.class, userID); Lesson lesson = getMonitoringService().initializeLessonWithoutLDcopy(title, "", learningDesignID, user, - null, false, false, true, false, false, true, true, null, null); + null, false, false, true, false, false, true, true, false, null, null); Organisation organisation = getMonitoringService().getOrganisation(organisationID); List staffList = new LinkedList(); Index: lams_central/src/java/org/lamsfoundation/lams/webservice/LessonManagerSoapBindingImpl.java =================================================================== diff -u -rf3c1df459a445f75ad8279cf72cf5a1e97bd3112 -reae819648876ce003b2797c2d2f387e10897e0b1 --- lams_central/src/java/org/lamsfoundation/lams/webservice/LessonManagerSoapBindingImpl.java (.../LessonManagerSoapBindingImpl.java) (revision f3c1df459a445f75ad8279cf72cf5a1e97bd3112) +++ lams_central/src/java/org/lamsfoundation/lams/webservice/LessonManagerSoapBindingImpl.java (.../LessonManagerSoapBindingImpl.java) (revision eae819648876ce003b2797c2d2f387e10897e0b1) @@ -57,93 +57,102 @@ */ public class LessonManagerSoapBindingImpl implements LessonManager { - private static MessageContext context = MessageContext.getCurrentContext(); - - private static IntegrationService integrationService = (IntegrationService) WebApplicationContextUtils.getRequiredWebApplicationContext(((HttpServlet)context.getProperty(HTTPConstants.MC_HTTP_SERVLET)).getServletContext()) - .getBean("integrationService"); + private static MessageContext context = MessageContext.getCurrentContext(); - private static IMonitoringService monitoringService = (IMonitoringService) WebApplicationContextUtils.getRequiredWebApplicationContext(((HttpServlet)context.getProperty(HTTPConstants.MC_HTTP_SERVLET)).getServletContext()) - .getBean("monitoringService"); + private static IntegrationService integrationService = (IntegrationService) WebApplicationContextUtils + .getRequiredWebApplicationContext( + ((HttpServlet) LessonManagerSoapBindingImpl.context.getProperty(HTTPConstants.MC_HTTP_SERVLET)) + .getServletContext()).getBean("integrationService"); - public Long startLesson(String serverId, String datetime, String hashValue, String username, - long ldId, String courseId, String title, String desc, String countryIsoCode, - String langIsoCode, String customCSV) throws RemoteException { - try { - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); - Authenticator.authenticate(serverMap, datetime, username, hashValue); - ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username); - ExtCourseClassMap orgMap = integrationService.getExtCourseClassMap(serverMap, userMap, courseId, - countryIsoCode, langIsoCode, null, LoginRequestDispatcher.METHOD_MONITOR); - // 1. init lesson - Lesson lesson = monitoringService.initializeLesson(title, desc, ldId, orgMap.getOrganisation() - .getOrganisationId(), userMap.getUser().getUserId(), customCSV, false, false, true, false, false, - false, false, null, null); - // 2. create lessonClass for lesson - createLessonClass(lesson, orgMap.getOrganisation(), userMap.getUser()); - // 3. start lesson - monitoringService.startLesson(lesson.getLessonId(), userMap.getUser().getUserId()); - return lesson.getLessonId(); - } catch (Exception e) { - throw new RemoteException(e.getMessage(), e); - } + private static IMonitoringService monitoringService = (IMonitoringService) WebApplicationContextUtils + .getRequiredWebApplicationContext( + ((HttpServlet) LessonManagerSoapBindingImpl.context.getProperty(HTTPConstants.MC_HTTP_SERVLET)) + .getServletContext()).getBean("monitoringService"); + + @Override + public Long startLesson(String serverId, String datetime, String hashValue, String username, long ldId, + String courseId, String title, String desc, String countryIsoCode, String langIsoCode, String customCSV) + throws RemoteException { + try { + ExtServerOrgMap serverMap = LessonManagerSoapBindingImpl.integrationService.getExtServerOrgMap(serverId); + Authenticator.authenticate(serverMap, datetime, username, hashValue); + ExtUserUseridMap userMap = LessonManagerSoapBindingImpl.integrationService.getExtUserUseridMap(serverMap, + username); + ExtCourseClassMap orgMap = LessonManagerSoapBindingImpl.integrationService.getExtCourseClassMap(serverMap, + userMap, courseId, countryIsoCode, langIsoCode, null, LoginRequestDispatcher.METHOD_MONITOR); + // 1. init lesson + Lesson lesson = LessonManagerSoapBindingImpl.monitoringService.initializeLesson(title, desc, ldId, orgMap + .getOrganisation().getOrganisationId(), userMap.getUser().getUserId(), customCSV, false, false, + true, false, false, false, false, false, null, null); + // 2. create lessonClass for lesson + createLessonClass(lesson, orgMap.getOrganisation(), userMap.getUser()); + // 3. start lesson + LessonManagerSoapBindingImpl.monitoringService.startLesson(lesson.getLessonId(), userMap.getUser() + .getUserId()); + return lesson.getLessonId(); + } catch (Exception e) { + throw new RemoteException(e.getMessage(), e); } + } - public Long scheduleLesson(String serverId, String datetime, String hashValue, String username, - long ldId, String courseId, String title, String desc, String startDate, - String countryIsoCode, String langIsoCode, String customCSV) throws RemoteException { - try { - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); - Authenticator.authenticate(serverMap, datetime, username, hashValue); - ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username); - ExtCourseClassMap orgMap = integrationService.getExtCourseClassMap(serverMap, userMap, courseId, - countryIsoCode, langIsoCode, null, LoginRequestDispatcher.METHOD_MONITOR); - // 1. init lesson - Lesson lesson = monitoringService.initializeLesson(title, desc, ldId, orgMap.getOrganisation() - .getOrganisationId(), userMap.getUser().getUserId(), customCSV, false, false, true, false, false, - false, false, null, null); - // 2. create lessonClass for lesson - createLessonClass(lesson, orgMap.getOrganisation(), userMap.getUser()); - // 3. schedule lesson - Date date = DateUtil.convertFromLAMSFlashFormat(startDate); - monitoringService.startLessonOnSchedule(lesson.getLessonId(), date, userMap.getUser().getUserId()); - return lesson.getLessonId(); - } catch (Exception e) { - throw new RemoteException(e.getMessage(), e); - } + @Override + public Long scheduleLesson(String serverId, String datetime, String hashValue, String username, long ldId, + String courseId, String title, String desc, String startDate, String countryIsoCode, String langIsoCode, + String customCSV) throws RemoteException { + try { + ExtServerOrgMap serverMap = LessonManagerSoapBindingImpl.integrationService.getExtServerOrgMap(serverId); + Authenticator.authenticate(serverMap, datetime, username, hashValue); + ExtUserUseridMap userMap = LessonManagerSoapBindingImpl.integrationService.getExtUserUseridMap(serverMap, + username); + ExtCourseClassMap orgMap = LessonManagerSoapBindingImpl.integrationService.getExtCourseClassMap(serverMap, + userMap, courseId, countryIsoCode, langIsoCode, null, LoginRequestDispatcher.METHOD_MONITOR); + // 1. init lesson + Lesson lesson = LessonManagerSoapBindingImpl.monitoringService.initializeLesson(title, desc, ldId, orgMap + .getOrganisation().getOrganisationId(), userMap.getUser().getUserId(), customCSV, false, false, + true, false, false, false, false, false, null, null); + // 2. create lessonClass for lesson + createLessonClass(lesson, orgMap.getOrganisation(), userMap.getUser()); + // 3. schedule lesson + Date date = DateUtil.convertFromLAMSFlashFormat(startDate); + LessonManagerSoapBindingImpl.monitoringService.startLessonOnSchedule(lesson.getLessonId(), date, userMap + .getUser().getUserId()); + return lesson.getLessonId(); + } catch (Exception e) { + throw new RemoteException(e.getMessage(), e); } + } - public boolean deleteLesson(String serverId, String datetime, String hashValue, - String username, long lsId) throws RemoteException { - try { - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); - Authenticator.authenticate(serverMap, datetime, username, hashValue); - ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username); - monitoringService.removeLesson(lsId, userMap.getUser().getUserId()); - return true; - } catch (Exception e) { - throw new RemoteException(e.getMessage(), e); - } + @Override + public boolean deleteLesson(String serverId, String datetime, String hashValue, String username, long lsId) + throws RemoteException { + try { + ExtServerOrgMap serverMap = LessonManagerSoapBindingImpl.integrationService.getExtServerOrgMap(serverId); + Authenticator.authenticate(serverMap, datetime, username, hashValue); + ExtUserUseridMap userMap = LessonManagerSoapBindingImpl.integrationService.getExtUserUseridMap(serverMap, + username); + LessonManagerSoapBindingImpl.monitoringService.removeLesson(lsId, userMap.getUser().getUserId()); + return true; + } catch (Exception e) { + throw new RemoteException(e.getMessage(), e); } + } - @SuppressWarnings("unchecked") - private void createLessonClass(Lesson lesson, Organisation organisation, User creator) { - List staffList = new LinkedList(); - staffList.add(creator); - List learnerList = new LinkedList(); - IUserManagementService userManagementService = (IUserManagementService) WebApplicationContextUtils - .getRequiredWebApplicationContext( - ((HttpServlet) context - .getProperty(HTTPConstants.MC_HTTP_SERVLET)) - .getServletContext()).getBean( - "userManagementService"); - Vector learnerVector = userManagementService - .getUsersFromOrganisationByRole(organisation - .getOrganisationId(), Role.LEARNER, false, true); - learnerList.addAll(learnerVector); - monitoringService.createLessonClassForLesson(lesson.getLessonId(), organisation, - organisation.getName() + "Learners", learnerList, organisation.getName() + "Staff", - staffList, creator.getUserId()); + @SuppressWarnings("unchecked") + private void createLessonClass(Lesson lesson, Organisation organisation, User creator) { + List staffList = new LinkedList(); + staffList.add(creator); + List learnerList = new LinkedList(); + IUserManagementService userManagementService = (IUserManagementService) WebApplicationContextUtils + .getRequiredWebApplicationContext( + ((HttpServlet) LessonManagerSoapBindingImpl.context.getProperty(HTTPConstants.MC_HTTP_SERVLET)) + .getServletContext()).getBean("userManagementService"); + Vector learnerVector = userManagementService.getUsersFromOrganisationByRole( + organisation.getOrganisationId(), Role.LEARNER, false, true); + learnerList.addAll(learnerVector); + LessonManagerSoapBindingImpl.monitoringService.createLessonClassForLesson(lesson.getLessonId(), organisation, + organisation.getName() + "Learners", learnerList, organisation.getName() + "Staff", staffList, + creator.getUserId()); - } + } } Index: lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonJoinServlet.java =================================================================== diff -u -rf3c1df459a445f75ad8279cf72cf5a1e97bd3112 -reae819648876ce003b2797c2d2f387e10897e0b1 --- lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonJoinServlet.java (.../LessonJoinServlet.java) (revision f3c1df459a445f75ad8279cf72cf5a1e97bd3112) +++ lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonJoinServlet.java (.../LessonJoinServlet.java) (revision eae819648876ce003b2797c2d2f387e10897e0b1) @@ -18,11 +18,11 @@ * * http://www.gnu.org/licenses/gpl.txt * **************************************************************** - */ - -/* $Id$ */ -package org.lamsfoundation.lams.webservice.xml; + */ +/* $Id$ */ +package org.lamsfoundation.lams.webservice.xml; + import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; @@ -66,290 +66,302 @@ import org.springframework.web.context.support.WebApplicationContextUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; - + /** * @author jliew - * + * * @web:servlet name="LessonJoinServlet" * @web:servlet-mapping url-pattern="/services/xml/LessonJoin/*" */ public class LessonJoinServlet extends HttpServlet { - - private static final long serialVersionUID = -8013072844129192750L; - private static Logger log = Logger.getLogger(LessonJoinServlet.class); - private static ILessonService lessonService = null; - private static IUserManagementService userService = null; - private static IMonitoringService monitoringService = null; - private static IntegrationService integrationService = null; - - public void init() throws ServletException { - lessonService = (ILessonService) WebApplicationContextUtils - .getRequiredWebApplicationContext(getServletContext()).getBean( - "lessonService"); - - userService = (IUserManagementService) WebApplicationContextUtils - .getRequiredWebApplicationContext(getServletContext()).getBean( - "userManagementService"); - - monitoringService = (IMonitoringService) WebApplicationContextUtils - .getRequiredWebApplicationContext(getServletContext()).getBean( - "monitoringService"); - - integrationService = (IntegrationService) WebApplicationContextUtils - .getRequiredWebApplicationContext(getServletContext()).getBean( - "integrationService"); - } - - public synchronized void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - - PrintWriter out = response.getWriter(); - response.setContentType("text/xml"); - response.setCharacterEncoding("UTF8"); - - String serverId = request.getParameter(CentralConstants.PARAM_SERVER_ID); - String datetime = request.getParameter(CentralConstants.PARAM_DATE_TIME); - String hashValue = request.getParameter(CentralConstants.PARAM_HASH_VALUE); - String username = request.getParameter(CentralConstants.PARAM_USERNAME); - String orgId = request.getParameter(CentralConstants.PARAM_COURSE_ID); - String ldId = request.getParameter(CentralConstants.PARAM_LEARNING_DESIGN_ID); - String learnerSize = request.getParameter(CentralConstants.PARAM_LEARNER_SIZE); - - DocumentBuilderFactory factory = null; - DocumentBuilder builder = null; - Document document = null; - Element element = null; - - try { - // Create xml document - factory = DocumentBuilderFactory.newInstance(); - builder = factory.newDocumentBuilder(); - document = builder.newDocument(); - element = document.createElement("status"); - - // validation - if (StringUtils.isBlank(username)) { - log.debug("Missing parameter: " + CentralConstants.PARAM_USERNAME); - element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); - element.setAttribute(CentralConstants.ATTR_RESULT_TEXT, "Missing parameter: " + CentralConstants.PARAM_USERNAME); - } else if (StringUtils.isBlank(orgId)) { - log.debug("Missing parameter: " + CentralConstants.PARAM_COURSE_ID); - element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); - element.setAttribute(CentralConstants.ATTR_RESULT_TEXT, "Missing parameter: " + CentralConstants.PARAM_COURSE_ID); - } else if (StringUtils.isBlank(ldId)) { - log.debug("Missing parameter: " + CentralConstants.PARAM_LEARNING_DESIGN_ID); - element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); - element.setAttribute(CentralConstants.ATTR_RESULT_TEXT, "Missing parameter: " + CentralConstants.PARAM_LEARNING_DESIGN_ID); - } else if (StringUtils.isBlank(learnerSize)) { - log.debug("Missing parameter: " + CentralConstants.PARAM_LEARNER_SIZE); - element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); - element.setAttribute(CentralConstants.ATTR_RESULT_TEXT, "Missing parameter: " + CentralConstants.PARAM_LEARNER_SIZE); - } - - // authenticate integrated server - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); - Authenticator.authenticate(serverMap, datetime, hashValue); - - User user = userService.getUserByLogin(username); - if (user != null) { - // add user to organisation if not already a member - addUserToOrg(user, Integer.valueOf(orgId)); - - // get list of lessons based on ldId - List lessons = lessonService.getLessonsByOriginalLearningDesign(Long.valueOf(ldId), Integer.valueOf(orgId)); - if (lessons != null && lessons.size() > 0) { - - // add to first lesson where lesson size < learnerSize - if (addUserToLesson(lessons, Integer.valueOf(learnerSize).intValue(), Integer.valueOf(orgId), user)) { - // success result code - element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "1"); - } - - // check if need to create new lesson - String resultCode = element.getAttribute(CentralConstants.ATTR_RESULT_CODE); - if (StringUtils.isBlank(resultCode)) { - if (createNewLesson(lessons, Long.valueOf(ldId).longValue(), Integer.valueOf(orgId), user)) { - // success result code - element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "1"); - } - } - } - } else { - log.debug("Couldn't find user with username '" + username + "'."); - element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); - element.setAttribute(CentralConstants.ATTR_RESULT_TEXT, "no username"); - } - - // result code shouldn't be blank at this point, but just in case - String resultCode = element.getAttribute(CentralConstants.ATTR_RESULT_CODE); - if (StringUtils.isBlank(resultCode)) element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); - - } catch (ParserConfigurationException e) { - log.error(e, e); - } catch (AuthenticationException e) { - log.debug(e); - element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); - element.setAttribute(CentralConstants.ATTR_RESULT_TEXT, "server authentication error"); - } finally { - if (document != null) { - document.appendChild(element); - // write out the xml document. - try { - DOMSource domSource = new DOMSource(document); - StringWriter writer = new StringWriter(); - StreamResult result = new StreamResult(writer); - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - transformer.transform(domSource, result); - - out.write(writer.toString()); - } catch (TransformerConfigurationException e) { - log.error(e, e); - } catch (TransformerException e) { - log.error(e, e); - } + private static final long serialVersionUID = -8013072844129192750L; + private static Logger log = Logger.getLogger(LessonJoinServlet.class); + private static ILessonService lessonService = null; + private static IUserManagementService userService = null; + private static IMonitoringService monitoringService = null; + private static IntegrationService integrationService = null; + + @Override + public void init() throws ServletException { + LessonJoinServlet.lessonService = (ILessonService) WebApplicationContextUtils.getRequiredWebApplicationContext( + getServletContext()).getBean("lessonService"); + + LessonJoinServlet.userService = (IUserManagementService) WebApplicationContextUtils + .getRequiredWebApplicationContext(getServletContext()).getBean("userManagementService"); + + LessonJoinServlet.monitoringService = (IMonitoringService) WebApplicationContextUtils + .getRequiredWebApplicationContext(getServletContext()).getBean("monitoringService"); + + LessonJoinServlet.integrationService = (IntegrationService) WebApplicationContextUtils + .getRequiredWebApplicationContext(getServletContext()).getBean("integrationService"); + } + + @Override + public synchronized void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, + IOException { + + PrintWriter out = response.getWriter(); + response.setContentType("text/xml"); + response.setCharacterEncoding("UTF8"); + + String serverId = request.getParameter(CentralConstants.PARAM_SERVER_ID); + String datetime = request.getParameter(CentralConstants.PARAM_DATE_TIME); + String hashValue = request.getParameter(CentralConstants.PARAM_HASH_VALUE); + String username = request.getParameter(CentralConstants.PARAM_USERNAME); + String orgId = request.getParameter(CentralConstants.PARAM_COURSE_ID); + String ldId = request.getParameter(CentralConstants.PARAM_LEARNING_DESIGN_ID); + String learnerSize = request.getParameter(CentralConstants.PARAM_LEARNER_SIZE); + + DocumentBuilderFactory factory = null; + DocumentBuilder builder = null; + Document document = null; + Element element = null; + + try { + // Create xml document + factory = DocumentBuilderFactory.newInstance(); + builder = factory.newDocumentBuilder(); + document = builder.newDocument(); + element = document.createElement("status"); + + // validation + if (StringUtils.isBlank(username)) { + LessonJoinServlet.log.debug("Missing parameter: " + CentralConstants.PARAM_USERNAME); + element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); + element.setAttribute(CentralConstants.ATTR_RESULT_TEXT, "Missing parameter: " + + CentralConstants.PARAM_USERNAME); + } else if (StringUtils.isBlank(orgId)) { + LessonJoinServlet.log.debug("Missing parameter: " + CentralConstants.PARAM_COURSE_ID); + element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); + element.setAttribute(CentralConstants.ATTR_RESULT_TEXT, "Missing parameter: " + + CentralConstants.PARAM_COURSE_ID); + } else if (StringUtils.isBlank(ldId)) { + LessonJoinServlet.log.debug("Missing parameter: " + CentralConstants.PARAM_LEARNING_DESIGN_ID); + element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); + element.setAttribute(CentralConstants.ATTR_RESULT_TEXT, "Missing parameter: " + + CentralConstants.PARAM_LEARNING_DESIGN_ID); + } else if (StringUtils.isBlank(learnerSize)) { + LessonJoinServlet.log.debug("Missing parameter: " + CentralConstants.PARAM_LEARNER_SIZE); + element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); + element.setAttribute(CentralConstants.ATTR_RESULT_TEXT, "Missing parameter: " + + CentralConstants.PARAM_LEARNER_SIZE); + } + + // authenticate integrated server + ExtServerOrgMap serverMap = LessonJoinServlet.integrationService.getExtServerOrgMap(serverId); + Authenticator.authenticate(serverMap, datetime, hashValue); + + User user = LessonJoinServlet.userService.getUserByLogin(username); + if (user != null) { + // add user to organisation if not already a member + addUserToOrg(user, Integer.valueOf(orgId)); + + // get list of lessons based on ldId + List lessons = LessonJoinServlet.lessonService.getLessonsByOriginalLearningDesign(Long.valueOf(ldId), + Integer.valueOf(orgId)); + if ((lessons != null) && (lessons.size() > 0)) { + + // add to first lesson where lesson size < learnerSize + if (addUserToLesson(lessons, Integer.valueOf(learnerSize).intValue(), Integer.valueOf(orgId), user)) { + // success result code + element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "1"); + } + + // check if need to create new lesson + String resultCode = element.getAttribute(CentralConstants.ATTR_RESULT_CODE); + if (StringUtils.isBlank(resultCode)) { + if (createNewLesson(lessons, Long.valueOf(ldId).longValue(), Integer.valueOf(orgId), user)) { + // success result code + element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "1"); } + } } - - } - - private void addUserToOrg(User user, Integer orgId) { - UserOrganisation uo = userService.getUserOrganisation(user.getUserId(), orgId); - if (uo == null) { - ArrayList rolesList = new ArrayList(); - rolesList.add(Role.ROLE_LEARNER.toString()); - userService.setRolesForUserOrganisation(user, orgId, rolesList); + } else { + LessonJoinServlet.log.debug("Couldn't find user with username '" + username + "'."); + element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); + element.setAttribute(CentralConstants.ATTR_RESULT_TEXT, "no username"); + } + + // result code shouldn't be blank at this point, but just in case + String resultCode = element.getAttribute(CentralConstants.ATTR_RESULT_CODE); + if (StringUtils.isBlank(resultCode)) { + element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); + } + + } catch (ParserConfigurationException e) { + LessonJoinServlet.log.error(e, e); + } catch (AuthenticationException e) { + LessonJoinServlet.log.debug(e); + element.setAttribute(CentralConstants.ATTR_RESULT_CODE, "0"); + element.setAttribute(CentralConstants.ATTR_RESULT_TEXT, "server authentication error"); + } finally { + if (document != null) { + document.appendChild(element); + + // write out the xml document. + try { + DOMSource domSource = new DOMSource(document); + StringWriter writer = new StringWriter(); + StreamResult result = new StreamResult(writer); + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + transformer.transform(domSource, result); + + out.write(writer.toString()); + } catch (TransformerConfigurationException e) { + LessonJoinServlet.log.error(e, e); + } catch (TransformerException e) { + LessonJoinServlet.log.error(e, e); } + } } - private Boolean addUserToLesson(List lessons, int learnerSize, Integer orgId, User user) { - for (int i=0; i rolesList = new ArrayList(); + rolesList.add(Role.ROLE_LEARNER.toString()); + LessonJoinServlet.userService.setRolesForUserOrganisation(user, orgId, rolesList); } - - private Boolean createNewLesson(List lessons, long ldId, Integer orgId, User user) { - // create new lesson - String lessonName; - String lessonDescription; - Boolean enableLessonIntro; - Boolean displayDesignImage; - Boolean learnerExportAvailable; - Boolean learnerPresenceAvailable; - Boolean learnerImAvailable; - Boolean liveEditEnabled; - Boolean enableNotifications; - Integer ownerUserId; - Organisation org = (Organisation)userService.findById(Organisation.class, orgId); - String learnerGroupName; - ArrayList learnerList = new ArrayList(); - learnerList.add(user); - String staffGroupName; - List staffList; - - if (lessons.size() > 0) { - // use existing lesson's settings - Lesson l = (Lesson)lessons.get(lessons.size()-1); - lessonName = incrementLessonName(l.getLessonName()); - lessonDescription = l.getLessonDescription(); - enableLessonIntro = l.isEnableLessonIntro(); - displayDesignImage = l.isDisplayDesignImage(); - learnerExportAvailable = l.getLearnerExportAvailable(); - learnerPresenceAvailable = l.getLearnerPresenceAvailable(); - learnerImAvailable = l.getLearnerImAvailable(); - liveEditEnabled = l.getLiveEditEnabled(); - enableNotifications = l.getEnableLessonNotifications(); - ownerUserId = l.getUser().getUserId(); - learnerGroupName = l.getLessonClass().getLearnersGroup().getGroupName(); - staffGroupName = l.getLessonClass().getStaffGroup().getGroupName(); - staffList = getListFromSet(l.getLessonClass().getStaffGroup().getUsers()); - } else { - // create new lesson settings - LearningDesign ld = (LearningDesign)userService.findById(LearningDesign.class, ldId); - lessonName = ld.getTitle(); - lessonDescription = ld.getDescription(); - enableLessonIntro = false; - displayDesignImage = false; - learnerExportAvailable = true; - learnerPresenceAvailable = false; - learnerImAvailable = false; - liveEditEnabled = false; - enableNotifications = false; - ownerUserId = ld.getUser().getUserId(); - learnerGroupName = org.getName() + " Learners"; - staffGroupName = org.getName() + " Staff"; - Vector userDTOs = userService.getUsersFromOrganisationByRole(orgId, Role.MONITOR, false, false); - staffList = getUsersFromDTOs(userDTOs); + } + + private Boolean addUserToLesson(List lessons, int learnerSize, Integer orgId, User user) { + for (int i = 0; i < lessons.size(); i++) { + Lesson l = (Lesson) lessons.get(i); + int size = l.getLessonClass().getLearnersGroup().getUsers().size(); + if (size < learnerSize) { + // verify lesson's org is the same as the course the user has signed up for + Organisation org = l.getOrganisation(); + if (!org.getOrganisationId().equals(orgId)) { + continue; } - Lesson lesson = monitoringService.initializeLesson(lessonName, lessonDescription, - ldId, orgId, ownerUserId, null, enableLessonIntro, displayDesignImage, learnerExportAvailable, learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, enableNotifications, null, null); - monitoringService.createLessonClassForLesson(lesson.getLessonId().longValue(), org, - learnerGroupName, learnerList, staffGroupName, staffList, ownerUserId); - monitoringService.startLesson(lesson.getLessonId().longValue(), ownerUserId); - if (log.isDebugEnabled()) { - log.debug("Started new lesson (id: " + lesson.getLessonId() - + ", name: '" + lesson.getLessonName() + "') with '" + user.getLogin() + "' as learner."); + + // add user to lesson (method is idempotent) + l.getLessonClass().addLearner(user); + + if (LessonJoinServlet.log.isDebugEnabled()) { + LessonJoinServlet.log.debug("Added " + user.getLogin() + " to lesson (id: " + l.getLessonId() + + ", name: '" + l.getLessonName() + "')"); } return true; + } } - - private String incrementLessonName(String name) { - String newName = name; - if (!StringUtils.isBlank(name)) { - int i = name.lastIndexOf(' '); - if (i >= 0) { - String counterStr = name.substring(i).trim(); - try { - int counterInt = Integer.parseInt(counterStr); - counterInt++; - newName = (name.substring(0, i) + " " + counterInt); - } catch (NumberFormatException e) { - newName = name + " 2"; - } - } else { - newName = name + " 2"; - } - } - log.debug("Created new lesson name '" + newName + "' from original '" + name + "'"); - return newName; + return false; + } + + private Boolean createNewLesson(List lessons, long ldId, Integer orgId, User user) { + // create new lesson + String lessonName; + String lessonDescription; + Boolean enableLessonIntro; + Boolean displayDesignImage; + Boolean learnerExportAvailable; + Boolean learnerPresenceAvailable; + Boolean learnerImAvailable; + Boolean liveEditEnabled; + Boolean enableNotifications; + Boolean learnerRestart; + Integer ownerUserId; + Organisation org = (Organisation) LessonJoinServlet.userService.findById(Organisation.class, orgId); + String learnerGroupName; + ArrayList learnerList = new ArrayList(); + learnerList.add(user); + String staffGroupName; + List staffList; + + if (lessons.size() > 0) { + // use existing lesson's settings + Lesson l = (Lesson) lessons.get(lessons.size() - 1); + lessonName = incrementLessonName(l.getLessonName()); + lessonDescription = l.getLessonDescription(); + enableLessonIntro = l.isEnableLessonIntro(); + displayDesignImage = l.isDisplayDesignImage(); + learnerExportAvailable = l.getLearnerExportAvailable(); + learnerPresenceAvailable = l.getLearnerPresenceAvailable(); + learnerImAvailable = l.getLearnerImAvailable(); + liveEditEnabled = l.getLiveEditEnabled(); + enableNotifications = l.getEnableLessonNotifications(); + learnerRestart = l.getLearnerRestart(); + ownerUserId = l.getUser().getUserId(); + learnerGroupName = l.getLessonClass().getLearnersGroup().getGroupName(); + staffGroupName = l.getLessonClass().getStaffGroup().getGroupName(); + staffList = getListFromSet(l.getLessonClass().getStaffGroup().getUsers()); + } else { + // create new lesson settings + LearningDesign ld = (LearningDesign) LessonJoinServlet.userService.findById(LearningDesign.class, ldId); + lessonName = ld.getTitle(); + lessonDescription = ld.getDescription(); + enableLessonIntro = false; + displayDesignImage = false; + learnerExportAvailable = true; + learnerPresenceAvailable = false; + learnerImAvailable = false; + liveEditEnabled = false; + enableNotifications = false; + learnerRestart = false; + ownerUserId = ld.getUser().getUserId(); + learnerGroupName = org.getName() + " Learners"; + staffGroupName = org.getName() + " Staff"; + Vector userDTOs = LessonJoinServlet.userService.getUsersFromOrganisationByRole(orgId, Role.MONITOR, false, + false); + staffList = getUsersFromDTOs(userDTOs); } - - private List getListFromSet(Set users) { - ArrayList list = new ArrayList(); - Iterator i = users.iterator(); - while (i.hasNext()) { - User user = (User)i.next(); - list.add(user); - } - return list; + Lesson lesson = LessonJoinServlet.monitoringService.initializeLesson(lessonName, lessonDescription, ldId, + orgId, ownerUserId, null, enableLessonIntro, displayDesignImage, learnerExportAvailable, + learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, enableNotifications, learnerRestart, + null, null); + LessonJoinServlet.monitoringService.createLessonClassForLesson(lesson.getLessonId().longValue(), org, + learnerGroupName, learnerList, staffGroupName, staffList, ownerUserId); + LessonJoinServlet.monitoringService.startLesson(lesson.getLessonId().longValue(), ownerUserId); + if (LessonJoinServlet.log.isDebugEnabled()) { + LessonJoinServlet.log.debug("Started new lesson (id: " + lesson.getLessonId() + ", name: '" + + lesson.getLessonName() + "') with '" + user.getLogin() + "' as learner."); } - - private List getUsersFromDTOs(Vector userDTOs) { - ArrayList list = new ArrayList(); - for (Object o : userDTOs) { - UserDTO dto = (UserDTO)o; - User user = (User)userService.findById(User.class, dto.getUserID()); - list.add(user); + return true; + } + + private String incrementLessonName(String name) { + String newName = name; + if (!StringUtils.isBlank(name)) { + int i = name.lastIndexOf(' '); + if (i >= 0) { + String counterStr = name.substring(i).trim(); + try { + int counterInt = Integer.parseInt(counterStr); + counterInt++; + newName = (name.substring(0, i) + " " + counterInt); + } catch (NumberFormatException e) { + newName = name + " 2"; } - return list; + } else { + newName = name + " 2"; + } } + LessonJoinServlet.log.debug("Created new lesson name '" + newName + "' from original '" + name + "'"); + return newName; + } + private List getListFromSet(Set users) { + ArrayList list = new ArrayList(); + Iterator i = users.iterator(); + while (i.hasNext()) { + User user = (User) i.next(); + list.add(user); + } + return list; + } + + private List getUsersFromDTOs(Vector userDTOs) { + ArrayList list = new ArrayList(); + for (Object o : userDTOs) { + UserDTO dto = (UserDTO) o; + User user = (User) LessonJoinServlet.userService.findById(User.class, dto.getUserID()); + list.add(user); + } + return list; + } + } - \ No newline at end of file Index: lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java =================================================================== diff -u -raa31a59324fc166448b0359ff000d73b727a5bdf -reae819648876ce003b2797c2d2f387e10897e0b1 --- lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision aa31a59324fc166448b0359ff000d73b727a5bdf) +++ lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision eae819648876ce003b2797c2d2f387e10897e0b1) @@ -141,8 +141,8 @@ // Custom CSV string to be used for tool adapters String customCSV = request.getParameter(CentralConstants.PARAM_CUSTOM_CSV); - - //parameters used for creating user at joinLesson method + + // parameters used for creating user at joinLesson method String firstNames = request.getParameter("firstNames"); String lastNames = request.getParameter("lastNames"); String emails = request.getParameter("emails"); @@ -213,8 +213,7 @@ } else if (method.equals(CentralConstants.METHOD_JOIN_LESSON)) { Thread t = new Thread(new AddUsersToLessonThread(serverId, datetime, username, hashValue, lsIdStr, - courseId, country, lang, learnerIds, monitorIds, firstNames, lastNames, emails, - request)); + courseId, country, lang, learnerIds, monitorIds, firstNames, lastNames, emails, request)); t.start(); element = document.createElement(CentralConstants.ELEM_LESSON); @@ -223,37 +222,37 @@ } else if (method.equals("toolOutputsAllUsers")) { lsId = new Long(lsIdStr); element = getToolOutputs(document, serverId, datetime, hashValue, username, lsId, courseId, false, null); - + } else if (method.equals("authoredToolOutputsAllUsers")) { lsId = new Long(lsIdStr); element = getToolOutputs(document, serverId, datetime, hashValue, username, lsId, courseId, true, null); - + } else if (method.equals("toolOutputsUser")) { lsId = new Long(lsIdStr); - element = getToolOutputs(document, serverId, datetime, hashValue, username, lsId, courseId, - false, outputsUser); - + element = getToolOutputs(document, serverId, datetime, hashValue, username, lsId, courseId, false, + outputsUser); + } else if (method.equals("authoredToolOutputsUser")) { lsId = new Long(lsIdStr); - element = getToolOutputs(document, serverId, datetime, hashValue, username, lsId, courseId, - true, outputsUser); - - } else if (method.equals(CentralConstants.METHOD_VERIFY_EXT_SERVER)) { + element = getToolOutputs(document, serverId, datetime, hashValue, username, lsId, courseId, true, + outputsUser); + + } else if (method.equals(CentralConstants.METHOD_VERIFY_EXT_SERVER)) { verify(serverId, datetime, hashValue); response.setContentType("text/html"); outputStream.write(1); outputStream.flush(); outputStream.close(); return; - + } else { String msg = "Method :" + method + " is not recognised"; LessonManagerServlet.log.error(msg); response.sendError(HttpServletResponse.SC_BAD_REQUEST, msg); } document.appendChild(element); - + // write out the xml document. DOMImplementationLS domImplementation = (DOMImplementationLS) document.getImplementation(); LSSerializer lsSerializer = domImplementation.createLSSerializer(); @@ -318,8 +317,9 @@ Organisation organisation = orgMap.getOrganisation(); // 1. init lesson - Lesson lesson = monitoringService.initializeLesson(title, desc, ldId, organisation.getOrganisationId(), - user.getUserId(), customCSV, false, false, true, false, false, true, false, null, null); + Lesson lesson = LessonManagerServlet.monitoringService.initializeLesson(title, desc, ldId, + organisation.getOrganisationId(), user.getUserId(), customCSV, false, false, true, false, false, + true, false, false, null, null); // 2. create lessonClass for lesson createLessonClass(lesson, organisation, user); // 3. start lesson @@ -343,14 +343,15 @@ ExtCourseClassMap orgMap = LessonManagerServlet.integrationService.getExtCourseClassMap(serverMap, userMap, courseId, countryIsoCode, langIsoCode, null, LoginRequestDispatcher.METHOD_MONITOR); // 1. init lesson - Lesson lesson = monitoringService.initializeLesson(title, desc, ldId, orgMap.getOrganisation() - .getOrganisationId(), userMap.getUser().getUserId(), customCSV, false, false, true, false, false, - true, false, null, null); + Lesson lesson = LessonManagerServlet.monitoringService.initializeLesson(title, desc, ldId, orgMap + .getOrganisation().getOrganisationId(), userMap.getUser().getUserId(), customCSV, false, false, + true, false, false, true, false, false, null, null); // 2. create lessonClass for lesson createLessonClass(lesson, orgMap.getOrganisation(), userMap.getUser()); // 3. schedule lesson Date date = DateUtil.convertFromLAMSFlashFormat(startDate); - monitoringService.startLessonOnSchedule(lesson.getLessonId(), date, userMap.getUser().getUserId()); + LessonManagerServlet.monitoringService.startLessonOnSchedule(lesson.getLessonId(), date, userMap.getUser() + .getUserId()); return lesson.getLessonId(); } catch (Exception e) { throw new RemoteException(e.getMessage(), e); @@ -649,6 +650,7 @@ this.request = request; } + @Override public void run() { addUsersToLesson(serverId, datetime, username, hashValue, lsIdStr, courseId, country, lang, learnerIds, monitorIds, firstNames, lastNames, emails, request); @@ -669,21 +671,20 @@ */ public Boolean addUsersToLesson(String serverId, String datetime, String requestorUsername, String hashValue, String lsIdStr, String courseId, String countryIsoCode, String langIsoCode, String learnerIds, - String monitorIds, String firstNames, String lastNames, String emails, - HttpServletRequest request) { + String monitorIds, String firstNames, String lastNames, String emails, HttpServletRequest request) { try { // get Server map ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); // authenticate Authenticator.authenticate(serverMap, datetime, requestorUsername, hashValue); - + String[] learnerIdArray = (learnerIds != null) ? learnerIds.split(",") : new String[0]; String[] monitorIdArray = (monitorIds != null) ? monitorIds.split(",") : new String[0]; String[] firstNameArray = (firstNames != null) ? firstNames.split(",") : new String[0]; String[] lastNameArray = (lastNames != null) ? lastNames.split(",") : new String[0]; String[] emailArray = (emails != null) ? emails.split(",") : new String[0]; - + // in case there is firstNames available - check all arrays have the same length, as otherwise it's // prone to ArrayOutOfBounds exceptions if ((firstNames != null) @@ -727,7 +728,7 @@ } i++; } - + return true; } catch (UserInfoFetchException e) { LessonManagerServlet.log.error(e, e); @@ -746,17 +747,18 @@ LessonManagerServlet.log.debug("Adding user '" + username + "' as " + method + " to lesson with id '" + lsIdStr + "'."); } - + ExtUserUseridMap userMap = null; - if (firstName == null && lastName == null) { - userMap = integrationService.getExtUserUseridMap(serverMap, username); + if ((firstName == null) && (lastName == null)) { + userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, username); } else { final boolean usePrefix = true; - userMap = integrationService.getImplicitExtUserUseridMap(serverMap, username, firstName, lastName, - langIsoCode, countryIsoCode, email, usePrefix); + userMap = LessonManagerServlet.integrationService.getImplicitExtUserUseridMap(serverMap, username, + firstName, lastName, langIsoCode, countryIsoCode, email, usePrefix); } - -// ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, username); + + // ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, + // username); // adds user to group ExtCourseClassMap orgMap = LessonManagerServlet.integrationService.getExtCourseClassMap(serverMap, userMap, courseId, countryIsoCode, langIsoCode, null, method); @@ -794,21 +796,23 @@ * @param lessonId * @param courseID * @param isAuthoredToolOutputs - * @param outputsUser if outputsUser is null return results for the whole lesson, otherwise - for the specified learner + * @param outputsUser + * if outputsUser is null return results for the whole lesson, otherwise - for the specified learner * @return * @throws Exception */ @SuppressWarnings("unchecked") public Element getToolOutputs(Document document, String serverId, String datetime, String hashValue, - String username, Long lessonId, String courseID, boolean isAuthoredToolOutputs, String outputsUser) throws Exception { - - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + String username, Long lessonId, String courseID, boolean isAuthoredToolOutputs, String outputsUser) + throws Exception { + + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); Authenticator.authenticate(serverMap, datetime, username, hashValue); - Lesson lesson = lessonService.getLesson(lessonId); + Lesson lesson = LessonManagerServlet.lessonService.getLesson(lessonId); if (lesson == null) { // TODO: handle this error instead of throwing an exception - log.debug("No lesson exists for: " + lessonId + ". Cannot get tool outputs report."); + LessonManagerServlet.log.debug("No lesson exists for: " + lessonId + ". Cannot get tool outputs report."); throw new Exception("Lesson with lessonID: " + lessonId + " could not be found for learner progresses"); } @@ -818,17 +822,19 @@ // if outputsUser is null we build results for the whole lesson, otherwise - for the specified learner if (outputsUser != null) { - ExtUserUseridMap userMap = integrationService.getExistingExtUserUseridMap(serverMap, outputsUser); + ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExistingExtUserUseridMap(serverMap, + outputsUser); if (userMap == null) { // TODO: handle this error instead of throwing an exception - log.debug("No user exists for: " + outputsUser + ". Cannot get tool outputs report."); + LessonManagerServlet.log.debug("No user exists for: " + outputsUser + + ". Cannot get tool outputs report."); throw new Exception("No user exists for: " + outputsUser + ". Cannot get tool outputs report."); } learners.add(userMap.getUser()); } else { learners.addAll(lesson.getAllLearners()); - log.debug("Getting tool ouputs report for: " + lessonId + ". With learning design: " + LessonManagerServlet.log.debug("Getting tool ouputs report for: " + lessonId + ". With learning design: " + lesson.getLearningDesign().getLearningDesignId()); } @@ -838,15 +844,16 @@ toolOutputsElement.setAttribute(CentralConstants.ATTR_LESSON_ID, "" + lessonId); toolOutputsElement.setAttribute("name", lesson.getLessonName()); - List learnerProgresses = lessonService.getUserProgressForLesson(lesson.getLessonId()); - List toolSessions = toolService.getToolSessionsByLesson(lesson); + List learnerProgresses = LessonManagerServlet.lessonService.getUserProgressForLesson(lesson + .getLessonId()); + List toolSessions = LessonManagerServlet.toolService.getToolSessionsByLesson(lesson); // map contains pairs toolContentId -> toolOutputDefinitions Map> toolOutputDefinitionsMap = new TreeMap>(); for (ToolActivity activity : activities) { Long toolContentId = activity.getToolContentId(); if (toolOutputDefinitionsMap.get(toolContentId) == null) { - SortedMap toolOutputDefinitions = toolService + SortedMap toolOutputDefinitions = LessonManagerServlet.toolService .getOutputDefinitionsFromTool(toolContentId, ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_CONDITION); toolOutputDefinitionsMap.put(toolContentId, toolOutputDefinitions); @@ -897,37 +904,37 @@ return toolOutputsElement; } - + /** - * Returns lesson tool activities. It works almost the same as lesson.getLearningDesign().getActivities() except it solves - * problem with first activity unable to cast to ToolActivity. + * Returns lesson tool activities. It works almost the same as lesson.getLearningDesign().getActivities() except it + * solves problem with first activity unable to cast to ToolActivity. */ private Set getLessonActivities(Lesson lesson) { Set activities = new TreeSet(); Set toolActivities = new TreeSet(); - + /* * Hibernate CGLIB is failing to load the first activity in the sequence as a ToolActivity for some mysterious * reason Causes a ClassCastException when you try to cast it, even if it is a ToolActivity. * * THIS IS A HACK to retrieve the first tool activity manually so it can be cast as a ToolActivity - if it is * one */ - Activity firstActivity = monitoringService.getActivityById(lesson.getLearningDesign().getFirstActivity() - .getActivityId()); + Activity firstActivity = LessonManagerServlet.monitoringService.getActivityById(lesson.getLearningDesign() + .getFirstActivity().getActivityId()); activities.add(firstActivity); activities.addAll(lesson.getLearningDesign().getActivities()); - + for (Activity activity : activities) { if (activity instanceof ToolActivity) { ToolActivity toolActivity = (ToolActivity) activity; toolActivities.add(toolActivity); } } - + return toolActivities; } - + /** * Verifies external server. Also it has a WSDL analog * org.lamsfoundation.lams.webservice.VerificationServiceSoapBindingImpl @@ -940,7 +947,7 @@ */ private boolean verify(String serverId, String datetime, String hash) throws Exception { try { - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); Authenticator.authenticate(serverMap, datetime, hash); return true; } catch (Exception e) { @@ -960,7 +967,8 @@ * @return */ private Element getActivityOutputsElement(Document document, ToolActivity activity, User learner, - LearnerProgress progress, ToolSession toolSession, Map toolOutputDefinitions, boolean isAuthoredToolOutputs) { + LearnerProgress progress, ToolSession toolSession, Map toolOutputDefinitions, + boolean isAuthoredToolOutputs) { Element activityElement = document.createElement("Activity"); activityElement.setAttribute("title", activity.getTitle()); activityElement.setAttribute("activityId", activity.getActivityId().toString()); @@ -973,7 +981,8 @@ boolean completed = progress.getProgressState(activity) == LearnerProgress.ACTIVITY_COMPLETED; activityElement.setAttribute("completed", "" + completed); - activityAttempted = completed || (progress.getProgressState(activity) == LearnerProgress.ACTIVITY_ATTEMPTED); + activityAttempted = completed + || (progress.getProgressState(activity) == LearnerProgress.ACTIVITY_ATTEMPTED); activityElement.setAttribute("attempted", "" + activityAttempted); } else { @@ -993,14 +1002,15 @@ if (activityEvaluations != null) { for (ActivityEvaluation evaluation : activityEvaluations) { if (outputName.equals(evaluation.getToolOutputDefinition())) { - ToolOutput toolOutput = toolService.getOutputFromTool(outputName, toolSession, - learner.getUserId()); + ToolOutput toolOutput = LessonManagerServlet.toolService.getOutputFromTool( + outputName, toolSession, learner.getUserId()); activityElement.appendChild(getOutputElement(document, toolOutput, definition)); } } } } else { - ToolOutput toolOutput = toolService.getOutputFromTool(outputName, toolSession, learner.getUserId()); + ToolOutput toolOutput = LessonManagerServlet.toolService.getOutputFromTool(outputName, + toolSession, learner.getUserId()); if (toolOutput != null) { activityElement.appendChild(getOutputElement(document, toolOutput, definition)); @@ -1010,8 +1020,8 @@ } } catch (RuntimeException e) { - log.error("Runtime exception when attempted to get outputs for activity: " + activity.getActivityId() - + ", continuing for other activities", e); + LessonManagerServlet.log.error("Runtime exception when attempted to get outputs for activity: " + + activity.getActivityId() + ", continuing for other activities", e); } }