Index: lams_central/src/java/org/lamsfoundation/lams/util/CentralConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/util/CentralConstants.java,v diff -u -r1.3.2.1 -r1.3.2.2 --- lams_central/src/java/org/lamsfoundation/lams/util/CentralConstants.java 12 Dec 2007 04:27:20 -0000 1.3.2.1 +++ lams_central/src/java/org/lamsfoundation/lams/util/CentralConstants.java 9 Jan 2008 05:51:40 -0000 1.3.2.2 @@ -67,6 +67,8 @@ public static final String METHOD_STUDENT_PROGRESS = "studentProgress"; + public static final String METHOD_SINGLE_STUDENT_PROGRESS = "singleStudentProgress"; + public static final String PARAM_MODE = "mode"; public static final String PARAM_FILEPATH = "filePath"; Index: lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java,v diff -u -r1.2.4.1 -r1.2.4.2 --- lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java 12 Dec 2007 04:27:44 -0000 1.2.4.1 +++ lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java 9 Jan 2008 05:51:41 -0000 1.2.4.2 @@ -174,8 +174,15 @@ lsId = new Long(lsIdStr); element = getAllStudentProgress(document, serverId, datetime, hashValue, username, lsId, courseId); + } + else if (method.equals(CentralConstants.METHOD_SINGLE_STUDENT_PROGRESS)) { + lsId = new Long(lsIdStr); + element = getSingleStudentProgress(document, serverId, datetime, hashValue, + username, lsId, courseId); - } else { + }else { + + String msg = "Method :" + method + " is not recognised"; log.error(msg); response.sendError(response.SC_BAD_REQUEST, msg); @@ -345,8 +352,7 @@ // get the username with the integration prefix removed - String userNoPrefixName = learnerProgress.getUserName(). - substring(prefix.length()+1); + String userNoPrefixName = learnerProgress.getUserName().substring(prefix.length()+1); ExtUserUseridMap learnerMap = integrationService.getExtUserUseridMap( serverMap, userNoPrefixName); @@ -383,7 +389,71 @@ } + public Element getSingleStudentProgress(Document document, String serverId, String datetime, + String hashValue, String username, long lsId, String courseID) + throws RemoteException + { + try { + ExtServerOrgMap serverMap = integrationService + .getExtServerOrgMap(serverId); + Authenticator + .authenticate(serverMap, datetime, username, hashValue); + ExtUserUseridMap userMap = integrationService.getExtUserUseridMap( + serverMap, username); + Lesson lesson = lessonService.getLesson(lsId); + + Element element = document.createElement(CentralConstants.ELEM_LESSON_PROGRESS); + element.setAttribute(CentralConstants.ATTR_LESSON_ID, "" + lsId); + + String prefix = serverMap.getPrefix(); + + + if(lesson!=null) + { + int activitiesTotal = lesson.getLearningDesign().getActivities().size(); + Iterator iterator = lesson.getLearnerProgresses().iterator(); + + while(iterator.hasNext()){ + LearnerProgress learnProg = (LearnerProgress)iterator.next(); + LearnerProgressDTO learnerProgress = learnProg.getLearnerProgressData(); + + if (learnerProgress.getUserName().equals(prefix + "_" + userMap.getExtUsername())) + { + Element learnerProgElem = document.createElement(CentralConstants.ELEM_LEARNER_PROGRESS); + + int completedActivities = learnerProgress.getCompletedActivities().length; + int attemptedActivities = learnerProgress.getAttemptedActivities().length; + + if(learnerProgElem.getNodeType()== Node.ELEMENT_NODE) + { + learnerProgElem.setAttribute(CentralConstants.ATTR_LESSON_COMPLETE , "" + learnerProgress.getLessonComplete()); + learnerProgElem.setAttribute(CentralConstants.ATTR_ACTIVITY_COUNT , "" + activitiesTotal); + learnerProgElem.setAttribute(CentralConstants.ATTR_ACTIVITIES_COMPLETED , "" + completedActivities); + learnerProgElem.setAttribute(CentralConstants.ATTR_ACTIVITIES_ATTEMPTED , "" + attemptedActivities); + //learnerProgElem.setAttribute(CentralConstants.ATTR_CURRENT_ACTIVITY , currActivity); + learnerProgElem.setAttribute(CentralConstants.ATTR_STUDENT_ID, "" + userMap.getSid()); + learnerProgElem.setAttribute(CentralConstants.ATTR_COURSE_ID, courseID); + learnerProgElem.setAttribute(CentralConstants.ATTR_USERNAME, username); + learnerProgElem.setAttribute(CentralConstants.ATTR_LESSON_ID, "" + lsId); + } + + element.appendChild(learnerProgElem); + } + } + } + else{ + throw new Exception("Lesson with lessonID: " + lsId + " could not be found for learner progresses"); + } + + return element; + + } catch (Exception e) { + throw new RemoteException(e.getMessage(), e); + } + + } + public boolean deleteLesson(String serverId, String datetime, String hashValue, String username, long lsId) throws RemoteException {