Index: lams_bb_integration/RELEASE_NOTES.TXT =================================================================== diff -u -r840e92f9895380a9c595ef0c05e19e03a917b7bd -rc238dfeb3d7b217788a342875d43951694b020e2 --- lams_bb_integration/RELEASE_NOTES.TXT (.../RELEASE_NOTES.TXT) (revision 840e92f9895380a9c595ef0c05e19e03a917b7bd) +++ lams_bb_integration/RELEASE_NOTES.TXT (.../RELEASE_NOTES.TXT) (revision c238dfeb3d7b217788a342875d43951694b020e2) @@ -63,4 +63,8 @@ 1.2.6 Release Fixes =================== -* LDEV-3382: Add datetime parameter check to LoginRequest \ No newline at end of file +* LDEV-3382: Add datetime parameter check to LoginRequest + +1.2.7 Release Fixes +=================== +* LDEV-3402: Add "your progress" widget to the lesson page Index: lams_bb_integration/WEB-INF/bb-manifest.xml =================================================================== diff -u -r840e92f9895380a9c595ef0c05e19e03a917b7bd -rc238dfeb3d7b217788a342875d43951694b020e2 --- lams_bb_integration/WEB-INF/bb-manifest.xml (.../bb-manifest.xml) (revision 840e92f9895380a9c595ef0c05e19e03a917b7bd) +++ lams_bb_integration/WEB-INF/bb-manifest.xml (.../bb-manifest.xml) (revision c238dfeb3d7b217788a342875d43951694b020e2) @@ -5,11 +5,11 @@ - + - + Index: lams_bb_integration/build.xml =================================================================== diff -u -re5924606b9ac1343bde0ba579b2861858d2c03af -rc238dfeb3d7b217788a342875d43951694b020e2 --- lams_bb_integration/build.xml (.../build.xml) (revision e5924606b9ac1343bde0ba579b2861858d2c03af) +++ lams_bb_integration/build.xml (.../build.xml) (revision c238dfeb3d7b217788a342875d43951694b020e2) @@ -2,7 +2,7 @@ - + Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java =================================================================== diff -u -re5924606b9ac1343bde0ba579b2861858d2c03af -rc238dfeb3d7b217788a342875d43951694b020e2 --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision e5924606b9ac1343bde0ba579b2861858d2c03af) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision c238dfeb3d7b217788a342875d43951694b020e2) @@ -45,7 +45,9 @@ import org.apache.commons.codec.binary.Hex; import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; +import org.lamsfoundation.ld.integration.dto.LearnerProgressDTO; import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; import blackboard.persist.PersistenceException; import blackboard.platform.context.Context; @@ -339,6 +341,81 @@ } /** + * getLearnerProgress in current lesson through a LAMS webservice + * + * @param ctx + * the blackboard contect, contains session data + * @param lsId + * the lesson id for which you wish to retrieve progress + * + * @return the learning session id + */ + public static LearnerProgressDTO getLearnerProgress(Context ctx, long lsId) { + String serverId = getServerID(); + String serverAddr = getServerAddress(); + String serverKey = getServerKey(); + String courseId = ctx.getCourse().getCourseId(); + String username = ctx.getUser().getUserName(); + + if (serverId == null || serverAddr == null || serverKey == null) { + throw new RuntimeException("Unable to start lesson, one or more lams configuration properties is null"); + } + + try { + + String timestamp = new Long(System.currentTimeMillis()).toString(); + String hash = generateAuthenticationHash(timestamp, username, serverId); + + String serviceURL = serverAddr + "/services/xml/LessonManager?method=singleStudentProgress" + "&serverId=" + + URLEncoder.encode(serverId, "utf8") + "&datetime=" + timestamp + "&username=" + + URLEncoder.encode(username, "utf8") + "&hashValue=" + hash + "&courseId=" + + URLEncoder.encode(courseId, "utf8") + "&lsId=" + new Long(lsId).toString() + "&progressUser=" + + URLEncoder.encode(username, "utf8"); + + logger.info("Retirieving learner progress: " + serviceURL); + + // InputStream is = url.openConnection().getInputStream(); + InputStream is = LamsSecurityUtil.callLamsServer(serviceURL); + + // parse xml response + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document document = db.parse(is); + + // get the lesson id from the response + NamedNodeMap learnerProgress = document.getElementsByTagName("LearnerProgress").item(0).getAttributes(); + boolean lessonComplete = Boolean.parseBoolean(learnerProgress.getNamedItem("lessonComplete").getNodeValue()); + int activitiesCompleted = Integer.parseInt(learnerProgress.getNamedItem("activitiesCompleted").getNodeValue()); + int attemptedActivities = Integer.parseInt(learnerProgress.getNamedItem("attemptedActivities").getNodeValue()); + int activityCount = Integer.parseInt(learnerProgress.getNamedItem("activityCount").getNodeValue()); + + LearnerProgressDTO learnerProgressDto = new LearnerProgressDTO(activityCount, attemptedActivities, + activitiesCompleted, lessonComplete); + + return learnerProgressDto; + + } catch (MalformedURLException e) { + throw new RuntimeException("Unable to start LAMS lesson, bad URL: '" + serverAddr + + "', please check lams.properties", e); + } catch (IllegalStateException e) { + throw new RuntimeException( + "LAMS Server timeout, did not get a response from the LAMS server. Please contact your systems administrator", + e); + } catch (RemoteException e) { + throw new RuntimeException("Unable to start LAMS lesson, RMI Remote Exception", e); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("Unable to start LAMS lesson, Unsupported Encoding Exception", e); + } catch (ConnectException e) { + throw new RuntimeException( + "LAMS Server timeout, did not get a response from the LAMS server. Please contact your systems administrator", + e); + } catch (Exception e) { + throw new RuntimeException("Unable to start LAMS lesson. Please contact your system administrator.", e); + } + + } + + /** * Make a call to LAMS server. * * @param serviceURL Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/dto/LearnerProgressDTO.java =================================================================== diff -u --- lams_bb_integration/src/org/lamsfoundation/ld/integration/dto/LearnerProgressDTO.java (revision 0) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/dto/LearnerProgressDTO.java (revision c238dfeb3d7b217788a342875d43951694b020e2) @@ -0,0 +1,114 @@ +/**************************************************************** + * 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 + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.ld.integration.dto; + +public class LearnerProgressDTO { + + private Long lessonId; + private String lessonName; + private String userName; + private String lastName; + private String firstName; + private Integer learnerId; + private int activityCount; + private int attemptedActivities; + private int activitiesCompleted; + private boolean lessonComplete; + + public LearnerProgressDTO(int activityCount, int attemptedActivities, int activitiesCompleted, + boolean lessonComplete) { + this.lessonId = lessonId; + this.lessonName = lessonName; + this.userName = userName; + this.lastName = lastName; + this.firstName = firstName; + this.learnerId = learnerId; + this.activityCount = activityCount; + this.attemptedActivities = attemptedActivities; + this.activitiesCompleted = activitiesCompleted; + this.lessonComplete = lessonComplete; + } + + /** + * @return Returns the learnerId. + */ + public Integer getLearnerId() { + return learnerId; + } + + /** + * @return Returns the lessonId. + */ + public Long getLessonId() { + return lessonId; + } + + /** + * @return Returns the lessonName. + */ + public String getLessonName() { + return lessonName; + } + + /** + * @return Returns the userName. + */ + public String getUserName() { + return userName; + } + + /** + * @return Returns the attemptedActivities. + */ + public int getAttemptedActivities() { + return attemptedActivities; + } + + /** + * @return Returns the activitiesCompleted. + */ + public int getActivitiesCompleted() { + return activitiesCompleted; + } + + /** + * @return Returns the activityCount. + */ + public int getActivityCount() { + return activityCount; + } + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + + public boolean getLessonComplete() { + return lessonComplete; + } + +} Index: lams_bb_integration/web/modules/learnermonitor.jsp =================================================================== diff -u -r758949bac89d2566ea51b4e39595117815b704cc -rc238dfeb3d7b217788a342875d43951694b020e2 --- lams_bb_integration/web/modules/learnermonitor.jsp (.../learnermonitor.jsp) (revision 758949bac89d2566ea51b4e39595117815b704cc) +++ lams_bb_integration/web/modules/learnermonitor.jsp (.../learnermonitor.jsp) (revision c238dfeb3d7b217788a342875d43951694b020e2) @@ -30,10 +30,42 @@ <%@ page import="blackboard.portal.servlet.*"%> <%@ page import="blackboard.portal.data.*"%> <%@ page import="org.lamsfoundation.ld.integration.blackboard.LamsSecurityUtil"%> +<%@ page import="org.lamsfoundation.ld.integration.dto.LearnerProgressDTO"%> <%@ page errorPage="/error.jsp"%> <%@ taglib uri="/bbNG" prefix="bbNG"%> + + + + + <% // Authorise current user for Course Access (automatic redirect) try{ @@ -133,6 +165,10 @@ } } boolean isScoreAvailable = (current_score != null); + + String strLessonId = request.getParameter("lsid").trim(); + long lessonId = Long.parseLong(strLessonId); + LearnerProgressDTO learnerProgressDto = LamsSecurityUtil.getLearnerProgress(ctx, lessonId); %> <%-- Breadcrumbs --%> @@ -165,11 +201,36 @@ <% } %> - - <% if(isScoreAvailable) { %> -
- You have completed this lesson. -
+ + <%=learnerProgressDto.getActivitiesCompleted()%> out of approximately <%=learnerProgressDto.getActivityCount()%> + ! <%=learnerProgressDto.getAttemptedActivities()%>! <%=learnerProgressDto.getLessonComplete()%> + <% if(learnerProgressDto.getAttemptedActivities() > 0 || learnerProgressDto.getLessonComplete()) { %> +
+
+ Your Lesson Progress +
+ + <% if(!learnerProgressDto.getLessonComplete()) { %> +

+ Lesson is not yet completed. +

+ +

+ You have completed: <%=learnerProgressDto.getActivitiesCompleted()%> out of approximately <%=learnerProgressDto.getActivityCount()%> activities + [*] +

+ +
+ * + Total activities depend on your learning path. +
+ + <% } else { %> +

+ You have completed this lesson. +

+ <% } %> +
<% } %>