Index: lams_bb_integration/WEB-INF/web.xml
===================================================================
diff -u -r19533db96ca9329f6c23dd8551bedbf31f2764bf -rf6a30da76fc0043c9eebf56c23c7f35ff7afaeeb
--- lams_bb_integration/WEB-INF/web.xml (.../web.xml) (revision 19533db96ca9329f6c23dd8551bedbf31f2764bf)
+++ lams_bb_integration/WEB-INF/web.xml (.../web.xml) (revision f6a30da76fc0043c9eebf56c23c7f35ff7afaeeb)
@@ -21,6 +21,10 @@
GradebookSyncServlet
org.lamsfoundation.ld.integration.blackboard.GradebookSyncServlet
+
+ RenderDesignImageServlet
+ org.lamsfoundation.ld.integration.blackboard.RenderDesignImageServlet
+
LamsLearningDesignServlet
@@ -38,5 +42,8 @@
GradebookSyncServlet
/GradebookSync
-
+
+ RenderDesignImageServlet
+ /RenderImage
+
Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java
===================================================================
diff -u -r95c0d30771017e8a809cf954c5235e486092192a -rf6a30da76fc0043c9eebf56c23c7f35ff7afaeeb
--- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision 95c0d30771017e8a809cf954c5235e486092192a)
+++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision f6a30da76fc0043c9eebf56c23c7f35ff7afaeeb)
@@ -233,15 +233,23 @@
String learningDesigns = ""; // empty
try {
- String serviceURL = serverAddr
+ String serviceURLBase = serverAddr
+ "/services/xml/LearningDesignRepository?method=getLearningDesignsJSON" + "&datetime="
+ timestamp + "&username=" + URLEncoder.encode(username, "utf8") + "&serverId="
+ URLEncoder.encode(serverId, "utf8") + "&hashValue=" + hash + "&courseId="
+ URLEncoder.encode(courseId, "UTF8") + "&country=" + country + "&lang=" + lang + "&mode=" + MODE
+ "&firstName=" + URLEncoder.encode(firstName, "UTF-8") + "&lastName="
+ URLEncoder.encode(lastName, "UTF-8") + "&email=" + URLEncoder.encode(email, "UTF-8");
- if (folderId != null) {
- serviceURL += "&folderID=" + folderId;
+ String serviceURL = serviceURLBase;
+
+ boolean isHome = false;
+
+ if (folderId != null ) {
+ if ( folderId.equalsIgnoreCase("home") ) {
+ isHome = true;
+ } else {
+ serviceURL += "&folderID=" + folderId;
+ }
}
InputStream is = LamsSecurityUtil.callLamsServer(serviceURL);
@@ -251,6 +259,22 @@
IOUtils.copy(is, writer, "UTF-8");
learningDesigns = writer.toString();
+ if ( isHome ) {
+ // we are after the designs in the root of the user's personal folder
+ String newFolderId = findPersonalFolderId(learningDesigns);
+ if ( newFolderId != null ) {
+ serviceURL = serviceURLBase + "&folderID=" + newFolderId;
+ is = LamsSecurityUtil.callLamsServer(serviceURL);
+ writer = new StringWriter();
+ IOUtils.copy(is, writer, "UTF-8");
+ learningDesigns = writer.toString();
+ } else {
+ logger.error("Unable to find personal folder ID from learning design response "+learningDesigns);
+ learningDesigns = "{}";
+ }
+ }
+
+
} catch (MalformedURLException e) {
throw new RuntimeException("Unable to get LAMS learning designs, bad URL: '" + serverAddr
+ "', please check lams.properties", e);
@@ -271,6 +295,19 @@
return learningDesigns;
}
+ private static String findPersonalFolderId(String response) {
+ // {"folders":[{"isRunSequencesFolder":false,"name":"Teacher Pontiff","folderID":47},{.........}]}
+ int indexStart = response.indexOf("folderID");
+ if ( indexStart > 0 ) {
+ indexStart += 10;
+ int indexEnd = response.indexOf("}",indexStart);
+ if ( indexEnd > 0 ) {
+ return response.substring(indexStart, indexEnd);
+ }
+ }
+ return null;
+ }
+
/**
* Starts lessons in lams through a LAMS webservice
*
Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/RenderDesignImageServlet.java
===================================================================
diff -u
--- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/RenderDesignImageServlet.java (revision 0)
+++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/RenderDesignImageServlet.java (revision f6a30da76fc0043c9eebf56c23c7f35ff7afaeeb)
@@ -0,0 +1,91 @@
+/****************************************************************
+ * 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.blackboard;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.lamsfoundation.ld.integration.Constants;
+
+import blackboard.base.InitializationException;
+import blackboard.platform.BbServiceException;
+import blackboard.platform.BbServiceManager;
+import blackboard.platform.context.Context;
+import blackboard.platform.context.ContextManager;
+
+/**
+ * Makes a call to LAMS server to get a learning design visual image (svg data)
+ * Looks for either sequence_id for the learning design (sequence) id.
+ */
+public class RenderDesignImageServlet extends HttpServlet {
+
+ private static final long serialVersionUID = -351131323404991332L;
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response) {
+
+ String strLearningDesignId = request.getParameter("sequence_id");
+ if ( strLearningDesignId != null ) {
+ strLearningDesignId.trim();
+ }
+
+ // validate method parameter and associated parameters
+ if ( strLearningDesignId == null || strLearningDesignId.length() == 0 ) {
+ throw new RuntimeException("Requred parameters missing. Add sequence_id for the id of the learning design to be displayed");
+ }
+
+ long learningDesignId = 0;
+ try {
+ learningDesignId = Long.parseLong(strLearningDesignId);
+ } catch ( Exception e ) {
+ throw new RuntimeException("Requred parameters missing. Add sequence_id for the id of the learning design to be displayed",e);
+ }
+
+ ContextManager ctxMgr = null;
+ Context ctx = null;
+ try {
+ // get Blackboard context
+ ctxMgr = (ContextManager) BbServiceManager.lookupService(ContextManager.class);
+ ctx = ctxMgr.setContext(request);
+
+ String learningDesignImageUrl = LamsSecurityUtil.generateRequestLearningDesignImage(ctx, false) + "&ldId=" + learningDesignId;
+ response.sendRedirect(learningDesignImageUrl);
+
+ } catch (InitializationException e) {
+ throw new RuntimeException(e);
+ } catch (BbServiceException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ // make sure context is released
+ if (ctxMgr != null) {
+ ctxMgr.releaseContext();
+ }
+ }
+ }
+}
+
Index: lams_bb_integration/web/modules/start_lesson_proc.jsp
===================================================================
diff -u -r5b93d9a61b07f22f60187ed378b6cc402dfe0c35 -rf6a30da76fc0043c9eebf56c23c7f35ff7afaeeb
--- lams_bb_integration/web/modules/start_lesson_proc.jsp (.../start_lesson_proc.jsp) (revision 5b93d9a61b07f22f60187ed378b6cc402dfe0c35)
+++ lams_bb_integration/web/modules/start_lesson_proc.jsp (.../start_lesson_proc.jsp) (revision f6a30da76fc0043c9eebf56c23c7f35ff7afaeeb)
@@ -86,35 +86,39 @@
String strIsAvailable = request.getParameter("isAvailable");
String strIsGradecenter = request.getParameter("isGradecenter");
String strIsTracked = request.getParameter("isTracked");
- boolean isAvailable = strIsAvailable.equals("true")?true:false;
- boolean isGradecenter = strIsGradecenter.equals("true")?true:false;
- boolean isTracked = strIsTracked.equals("true")?true:false;
+ boolean isAvailable = (strIsAvailable==null || strIsAvailable.equals("true"))?true:false; // default true
+ boolean isGradecenter = (strIsGradecenter!=null && strIsGradecenter.equals("true"))?true:false; // default false
+ boolean isTracked = (strIsTracked!=null && strIsTracked.equals("true"))?true:false; // default false
String isDisplayDesignImage = request.getParameter("isDisplayDesignImage");
- String strStartDate = request.getParameter("lessonAvailability_start_datetime");
- String strEndDate = request.getParameter("lessonAvailability_end_datetime");
+ // Set Availability Dates
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Calendar startDate = Calendar.getInstance();
- Calendar endDate = Calendar.getInstance();
- startDate.setTime(formatter.parse(strStartDate));
- endDate.setTime(formatter.parse(strEndDate));
- String strStartDateCheckbox = request.getParameter("lessonAvailability_start_checkbox");
- String strEndDateCheckbox = request.getParameter("lessonAvailability_end_checkbox");
-
- // Set Availability Dates
// Start Date
- if (strStartDateCheckbox != null){
- if (strStartDateCheckbox.equals("1")){
- bbContent.setStartDate(startDate);
- }
- }
+ String strStartDate = request.getParameter("lessonAvailability_start_datetime");
+ if ( strStartDate != null ) {
+ Calendar startDate = Calendar.getInstance();
+ startDate.setTime(formatter.parse(strStartDate));
+ String strStartDateCheckbox = request.getParameter("lessonAvailability_start_checkbox");
+ if (strStartDateCheckbox != null){
+ if (strStartDateCheckbox.equals("1")){
+ bbContent.setStartDate(startDate);
+ }
+ }
+ }
+
// End Date
- if (strEndDateCheckbox != null){
- if (strEndDateCheckbox.equals("1")){
- bbContent.setEndDate(endDate);
- }
+ String strEndDate = request.getParameter("lessonAvailability_end_datetime");
+ if ( strEndDate != null ) {
+ Calendar endDate = Calendar.getInstance();
+ endDate.setTime(formatter.parse(strEndDate));
+ String strEndDateCheckbox = request.getParameter("lessonAvailability_end_checkbox");
+ if (strEndDateCheckbox != null){
+ if (strEndDateCheckbox.equals("1")){
+ bbContent.setEndDate(endDate);
+ }
+ }
}
// Set the New LAMS Lesson content data (in Blackboard)
@@ -203,6 +207,7 @@
iconUrl="/images/ci/icons/receiptsuccess_u.gif"
title="Start A LAMS Lesson"
recallUrl="<%=strReturnUrl%>">
+
Content successfully added.