Index: lams_bb_integration/.classpath =================================================================== diff -u -r2d8a22624f79146eff859c52775648266d47b826 -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/.classpath (.../.classpath) (revision 2d8a22624f79146eff859c52775648266d47b826) +++ lams_bb_integration/.classpath (.../.classpath) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -7,14 +7,15 @@ - - - - - - - - - + + + + + + + + + + Fisheye: Tag c8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc refers to a dead (removed) revision in file `lams_bb_integration/LICENSE.TXT'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/WEB-INF/bb-manifest.xml =================================================================== diff -u -ra861902df1adee65242a8c37adc1463b99aa7dcb -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/WEB-INF/bb-manifest.xml (.../bb-manifest.xml) (revision a861902df1adee65242a8c37adc1463b99aa7dcb) +++ lams_bb_integration/WEB-INF/bb-manifest.xml (.../bb-manifest.xml) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -3,11 +3,11 @@ - + - + @@ -31,7 +31,6 @@ - @@ -40,8 +39,8 @@ - + Index: lams_bb_integration/WEB-INF/web.xml =================================================================== diff -u -ra861902df1adee65242a8c37adc1463b99aa7dcb -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/WEB-INF/web.xml (.../web.xml) (revision a861902df1adee65242a8c37adc1463b99aa7dcb) +++ lams_bb_integration/WEB-INF/web.xml (.../web.xml) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -14,14 +14,14 @@ org.lamsfoundation.ld.integration.blackboard.LamsActionRequestServlet - + Index: lams_bb_integration/build.xml =================================================================== diff -u -r2d8a22624f79146eff859c52775648266d47b826 -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/build.xml (.../build.xml) (revision 2d8a22624f79146eff859c52775648266d47b826) +++ lams_bb_integration/build.xml (.../build.xml) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -1,7 +1,7 @@ - + Index: lams_bb_integration/lib/commons-codec-1.3.jar =================================================================== diff -u -rc8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc -r8af1746d179f41095b074fef269722c6689b39eb Binary files differ Index: lams_bb_integration/lib/commons-discovery-0.2.jar =================================================================== diff -u -rc8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc -r8af1746d179f41095b074fef269722c6689b39eb Binary files differ Index: lams_bb_integration/lib/commons-logging-1.0.4.jar =================================================================== diff -u -rc8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc -r8af1746d179f41095b074fef269722c6689b39eb Binary files differ Index: lams_bb_integration/lib/log4j-1.2.8.jar =================================================================== diff -u -rc8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc -r8af1746d179f41095b074fef269722c6689b39eb Binary files differ Fisheye: Tag c8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc refers to a dead (removed) revision in file `lams_bb_integration/readme.txt'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/Constants.java =================================================================== diff -u -r2d8a22624f79146eff859c52775648266d47b826 -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/src/org/lamsfoundation/ld/integration/Constants.java (.../Constants.java) (revision 2d8a22624f79146eff859c52775648266d47b826) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/Constants.java (.../Constants.java) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -1,27 +1,31 @@ -/** - * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) - * +/**************************************************************** + * Copyright (C) 2007 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 as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA - * + * * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** */ package org.lamsfoundation.ld.integration; /** - * @author Anthony Xiao + * Constants used for blackboard integration + * + * @author Luke Foxton */ public class Constants { @@ -45,12 +49,6 @@ public static final String METHOD_MONITOR = "monitor"; public static final String METHOD_LEARNER = "learner"; - // Conf file constants - //public static final String CONF_SERVER_ADDRRESS = "lamstwo.serverAddr"; - //public static final String CONF_SERVER_ID = "lamstwo.serverId"; - //public static final String CONF_SERVER_KEY = "lamstwo.serverKey"; - //public static final String CONF_REQUEST_SOURCE = "lamstwo.requestSrc"; - // XML format constnats public static final String ELEM_FOLDER = "Folder"; public static final String ELEM_LEARNING_DESIGN = "LearningDesign"; Fisheye: Tag 8af1746d179f41095b074fef269722c6689b39eb refers to a dead (removed) revision in file `lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/BBDBManager.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsActionRequestServlet.java =================================================================== diff -u -ra861902df1adee65242a8c37adc1463b99aa7dcb -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsActionRequestServlet.java (.../LamsActionRequestServlet.java) (revision a861902df1adee65242a8c37adc1463b99aa7dcb) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsActionRequestServlet.java (.../LamsActionRequestServlet.java) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -24,32 +24,26 @@ package org.lamsfoundation.ld.integration.blackboard; import java.io.IOException; -import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.lamsfoundation.ld.integration.Constants; -import blackboard.persist.BbPersistenceManager; -import blackboard.persist.Id; import blackboard.platform.BbServiceManager; -import blackboard.data.course.Course; import blackboard.platform.context.ContextManager; import blackboard.platform.context.Context; -import blackboard.platform.plugin.PlugInException; -import blackboard.platform.plugin.PlugInUtil; import blackboard.platform.session.BbSession; import blackboard.platform.session.BbSessionManagerService; /** + * Handles requests to the LAMS server + * * @author Luke Foxton */ public class LamsActionRequestServlet extends HttpServlet { - /** - * - */ + private static final long serialVersionUID = 1L; /** @@ -91,7 +85,6 @@ // get the session object to obtain the current user and course object BbSessionManagerService sessionService = BbServiceManager.getSessionManagerService(); BbSession bbSession = sessionService.getSession( request ); - String username = bbSession.getUserName(); String redirect = LamsSecurityUtil.generateRequestURL(ctx, p_method); @@ -101,8 +94,6 @@ //redirect1 += '&' + Constants.PARAM_LEARNING_SESSION_ID + '=' + p_learningSessionId; } - //response.sendRedirect(redirect1); - response.sendRedirect(response.encodeRedirectURL(redirect)); Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsPluginUtil.java =================================================================== diff -u -r2d8a22624f79146eff859c52775648266d47b826 -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsPluginUtil.java (.../LamsPluginUtil.java) (revision 2d8a22624f79146eff859c52775648266d47b826) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsPluginUtil.java (.../LamsPluginUtil.java) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -29,7 +29,6 @@ import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.io.IOException; - import blackboard.platform.plugin.PlugInException; import blackboard.platform.plugin.PlugInUtil; @@ -46,7 +45,7 @@ public class LamsPluginUtil { public static final String VENDOR_ID = "lams"; - public static final String PLUGIN_HANDLE = "plglamscontent"; + public static final String PLUGIN_HANDLE = "lamscontent"; public static final String CONTENT_HANDLE = "resource/x-lams-lamscontent"; public static final String FILE_PROPERTIES = "lams.properties"; @@ -121,18 +120,34 @@ } } + /** + * + * @return the secret key from lams.properties + */ public static String getSecretKey(){ return getProperties().getProperty(PROP_LAMS_SECRET_KEY); } + /** + * + * @return the secret url from lams.properties + */ public static String getServerUrl(){ return getProperties().getProperty(PROP_LAMS_URL); } + /** + * + * @return the server id from lams.properties + */ public static String getServerId(){ return getProperties().getProperty(PROP_LAMS_SERVER_ID); } + /** + * + * @return the request source from lams.properties + */ public static String getReqSrc(){ return getProperties().getProperty(PROP_REQ_SRC); } Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java =================================================================== diff -u -ra861902df1adee65242a8c37adc1463b99aa7dcb -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision a861902df1adee65242a8c37adc1463b99aa7dcb) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -22,6 +22,8 @@ */ package org.lamsfoundation.ld.integration.blackboard; +import java.lang.IllegalStateException; +import java.net.ConnectException; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; @@ -33,40 +35,38 @@ import java.rmi.RemoteException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.Date; -import java.util.Locale; -import javax.xml.rpc.ServiceException; import blackboard.platform.context.Context; import org.apache.commons.codec.binary.Hex; -import javax.servlet.ServletException; - -//import org.lamsfoundation.lams.util.CentralConstants; import org.lamsfoundation.ld.integration.Constants; -import org.lamsfoundation.ld.webservice.LessonManager; -import org.lamsfoundation.ld.webservice.LessonManagerService; -import org.lamsfoundation.ld.webservice.LessonManagerServiceLocator; - - import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import org.apache.log4j.Logger; - - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; /** + * This class creates URLs, servlet calls and webservice calls + * for communication with LAMS + * * @author Luke Foxton */ public class LamsSecurityUtil { - //private static Connection _conn = null; static Logger logger = Logger.getLogger(LamsSecurityUtil.class); + + /** + * Generates login requests to LAMS for author, monitor and learner + * + * @param ctx the blackboard contect, contains session data + * @param method the mehtod to request of LAMS "author", "monitor", "learner" + * @return a url pointing to the LAMS lesson, monitor, author session + * @throws Exception + */ public static String generateRequestURL(Context ctx, String method) throws Exception { String serverAddr = getServerAddress(); @@ -82,17 +82,11 @@ String username = ctx.getUser().getUserName(); String hash = generateAuthenticationHash(timestamp, username, method, serverId); String courseId = ctx.getCourse().getCourseId(); - String country = "US"; - String lang = "en"; - - //ResourceLoader rl = new ResourceLoader(); - //String[] locale = ctx.getGuestSessionLocale().split("-"); + String locale = ctx.getUser().getLocale(); + String country = getCountry(locale); + String lang = getLanguage(locale); - //String siteID = getCurrentContext(); - - // TODO: Make locale settings work - String url; try { url = serverAddr + "/LoginRequest?" @@ -109,11 +103,20 @@ throw new RuntimeException(); } - System.out.println(url); + logger.info("LAMS Req: " + url); + //System.out.println(url); return url; } + /** + * Gets a list of learning designs for the current user from LAMS + * + * @param ctx the blackboard contect, contains session data + * @param mode the mode to call upon learning designes + * @return a string containing the LAMS workspace tree in tigra format + * @throws Exception + */ public static String getLearningDesigns(Context ctx, Integer mode) throws Exception { String serverAddr = getServerAddress(); @@ -129,9 +132,11 @@ String username = ctx.getUser().getUserName(); String hash = generateAuthenticationHash(timestamp, username, serverId); String courseId = ctx.getCourse().getCourseId(); - String country = "US"; - String lang = "en"; + String locale = ctx.getUser().getLocale(); + String country = getCountry(locale); + String lang = getLanguage(locale); + // TODO: Make locale settings work String learningDesigns = "[]"; // empty javascript array try { @@ -156,10 +161,13 @@ if (httpConn.getResponseCode() != HttpURLConnection.HTTP_OK) { logger.error("HTTP Response Code: " + httpConn.getResponseCode() + ", HTTP Response Message: " + httpConn.getResponseMessage()); + return "error"; } - InputStream is = url.openConnection().getInputStream(); + //InputStream is = url.openConnection().getInputStream(); + InputStream is = conn.getInputStream(); + // parse xml response DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); @@ -174,114 +182,59 @@ // TODO better error handling } catch (MalformedURLException e) { + logger.error("Unable to get LAMS learning designs, bad URL: '" + + serverAddr + + "', please check lams.properties", e); e.printStackTrace(); + return "error"; + }catch (IllegalStateException e){ + logger.error("LAMS Server timeout, did not get a response from the LAMS server. Please contact your systems administrator", e); + e.printStackTrace(); + return "error"; + }catch (ConnectException e){ + logger.error("LAMS Server timeout, did not get a response from the LAMS server. Please contact your systems administrator", e); + e.printStackTrace(); + return "error"; } catch (UnsupportedEncodingException e) { + logger.error(e); e.printStackTrace(); + return "error"; } catch (IOException e) { + logger.error(e); e.printStackTrace(); + return "error"; } catch (ParserConfigurationException e) { + logger.error(e); e.printStackTrace(); + return "error"; } catch (SAXException e) { + logger.error(e); e.printStackTrace(); + return "error"; } - return learningDesigns; - } + } - - - - - - /* Scheduling is handled by blackboard - public static Long scheduleLesson(Context ctx, long ldId, String title, String desc, String startDate) { - - - String serverID = getServerID(); - String serverAddress = getServerAddress(); - String serverKey = getServerKey(); - String courseId = ctx.getCourse().getCourseId(); - String username = ctx.getUser().getUserName(); - String siteId = getReqSrc(); - - if (serverID == null || serverAddress == null || serverKey == null ) { - logger.error("Unable to retrieve learning designs from LAMS, one or more lams configuration properties is null"); - return null; - } - - try { - - String datetime = new Date().toString(); - String hashValue = generateAuthenticationHash(serverID, serverKey, username, datetime); - - LessonManagerService service = new LessonManagerServiceLocator(); - LessonManager lessonManager = service.getLessonManagerService(new URL(serverAddress + "/services/LessonManagerService")); - Long lessonId = lessonManager.scheduleLesson(serverID, datetime, hashValue, username, ldId, siteId, title, desc, startDate, "US", "en"); - - return lessonId; - - } catch (MalformedURLException e) { - logger.error("Unable to schedule LAMS lesson, bad URL: '" - + serverAddress - + "', please check sakai.properties"); - } catch (ServiceException e) { - logger.error("Unable to schedule LAMS lesson, RPC Service Exception"); - e.printStackTrace(); - } catch (RemoteException e) { - logger.error("Unable to schedule LAMS lesson, RMI Remote Exception"); - e.printStackTrace(); - } - return null; - } - */ - - - /* - 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 courseId = request.getParameter(CentralConstants.PARAM_COURSE_ID); - String ldIdStr = request.getParameter(CentralConstants.PARAM_LEARNING_DESIGN_ID); - String lsIdStr = request.getParameter(CentralConstants.PARAM_LESSON_ID); - String country = request.getParameter(CentralConstants.PARAM_COUNTRY); - String title = request.getParameter(CentralConstants.PARAM_TITLE); - String desc = request.getParameter(CentralConstants.PARAM_DESC); - String startDate = request.getParameter(CentralConstants.PARAM_STARTDATE); - String lang = request.getParameter(CentralConstants.PARAM_LANG); - String method = request.getParameter(CentralConstants.PARAM_METHOD); - - serverId, - datetime, - hashValue, - username, - ldId, - courseId, - title, - desc, - country, - lang - - /lams//services/xml/LessonManager?serverId=lamsbb - &datetime=1186617857718 - &username=administrator - &hashValue=696e870fde732c1e14a6f79a2872f6eaff9be349 - &courseId=1 - &ldId=5 - &country=US - &lang=en - &method=start - &title=test - &desc=+%0D%0A - */ - + /** + * Starts lessons in lams through a LAMS webservice + * + * @param ctx the blackboard contect, contains session data + * @param ldId the learning design id for which you wish to start a lesson + * @param title the title of the lesson + * @param desc the description of the lesson + * @return the learning session id + */ public static Long startLesson(Context ctx, long ldId, String title, String desc) { - String serverId = getServerID(); + Long error = new Long(-1); + String serverId = getServerID(); String serverAddr = getServerAddress(); String serverKey = getServerKey(); String courseId = ctx.getCourse().getCourseId(); String username = ctx.getUser().getUserName(); + String locale = ctx.getUser().getLocale(); + String country = getCountry(locale); + String lang = getLanguage(locale); if (serverId == null || serverAddr == null || serverKey == null ) { logger.error("Unable to retrieve learning designs from LAMS, one or more lams configuration properties is null"); @@ -302,14 +255,16 @@ + "&hashValue=" + hash + "&courseId=" + URLEncoder.encode(courseId, "utf8") + "&ldId=" + new Long(ldId).toString() - + "&country=" + "US" - + "&lang=" + "en" + + "&country=" + country + + "&lang=" + lang + "&method=" + "start" + "&title=" + URLEncoder.encode(title, "utf8").trim() + "&desc=" + URLEncoder.encode(desc, "utf8").trim(); - System.out.println("START LESSON: " + serviceURL); + logger.info("LAMS START LESSON Req: " + serviceURL); + //System.out.println("START LESSON: " + serviceURL); + URL url = new URL(serviceURL); URLConnection conn = url.openConnection(); if (!(conn instanceof HttpURLConnection)) { @@ -321,10 +276,13 @@ if (httpConn.getResponseCode() != HttpURLConnection.HTTP_OK) { logger.error("HTTP Response Code: " + httpConn.getResponseCode() + ", HTTP Response Message: " + httpConn.getResponseMessage()); + return error; } - InputStream is = url.openConnection().getInputStream(); + //InputStream is = url.openConnection().getInputStream(); + InputStream is = conn.getInputStream(); + // parse xml response DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); @@ -338,121 +296,76 @@ } catch (MalformedURLException e) { logger.error("Unable to start LAMS lesson, bad URL: '" + serverAddr - + "', please check lams.properties"); + + "', please check lams.properties", e); e.printStackTrace(); + return error; + }catch (IllegalStateException e){ + logger.error("LAMS Server timeout, did not get a response from the LAMS server. Please contact your systems administrator", e); + e.printStackTrace(); + return error; } catch (RemoteException e) { - logger.error("Unable to start LAMS lesson, RMI Remote Exception"); + logger.error("Unable to start LAMS lesson, RMI Remote Exception",e); e.printStackTrace(); + return error; } catch (UnsupportedEncodingException e) { - logger.error("Unable to start LAMS lesson, Unsupported Encoding Exception"); + logger.error("Unable to start LAMS lesson, Unsupported Encoding Exception",e); e.printStackTrace(); + return error; } - catch (Exception e) + catch (ConnectException e) { - logger.error("Unable to start LAMS lesson"); + logger.error("LAMS Server timeout, did not get a response from the LAMS server. Please contact your systems administrator", e); e.printStackTrace(); + return error; } + catch (Exception e) { + logger.error("Unable to start LAMS lesson. Please contact your system administrator.",e); + e.printStackTrace(); + return error; + } - return null; } - - /* - * TODO: + /** + * @return gets server address from the lams.properties file */ - public static boolean deleteLesson(Context ctx, long lsId) { - String serverId = getServerID(); - String serverAddr = getServerAddress(); - String serverKey = getServerKey(); - String username = ctx.getUser().getUserName(); - if (serverId == null || serverAddr == null || serverKey == null ) { - logger.error("Unable to retrieve learning designs from LAMS, one or more lams configuration properties is null"); - return false; - } - - try { - - String timestamp = new Long(System.currentTimeMillis()).toString(); - String hash = generateAuthenticationHash(serverId, serverKey, username, timestamp); - - // Boolean deleted = deleteLesson(serverId, datetime, hashValue, username, lsId); - - - String serviceURL = serverAddr + "/services/xml/LessonManager?" - + "datetime=" + timestamp - + "&username=" + URLEncoder.encode(username, "utf8") - + "&serverId=" + URLEncoder.encode(serverId, "utf8") - + "&serverKey=" + URLEncoder.encode(serverKey, "utf8") - + "&hashValue=" + hash - + "&lsId=" + new Long(lsId).toString() - + "&method=" + "delete"; - - URL url = new URL(serviceURL); - URLConnection conn = url.openConnection(); - if (!(conn instanceof HttpURLConnection)) { - logger.error("Unable to open connection to: " + serviceURL); - } - - HttpURLConnection httpConn = (HttpURLConnection)conn; - - if (httpConn.getResponseCode() != HttpURLConnection.HTTP_OK) { - logger.error("HTTP Response Code: " + httpConn.getResponseCode() - + ", HTTP Response Message: " + httpConn.getResponseMessage()); - } - - InputStream is = url.openConnection().getInputStream(); - - // parse xml response - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document document = db.parse(is); - - return Boolean.parseBoolean(document.getElementById("lesson").getAttribute("deleted")); - - } catch (MalformedURLException e) { - logger.error("Unable to delete LAMS lesson, bad URL: '" - + serverAddr - + "', please check lams.properties"); - } catch (RemoteException e) { - logger.error("Unable to delete LAMS lesson, RMI Remote Exception"); - e.printStackTrace(); - } catch (UnsupportedEncodingException e) - { - logger.error("Unable to delet LAMS lesson, Unsupported Encoding Exception"); - e.printStackTrace(); - } catch (Exception e) - { - logger.error("Unable to delete LAMS lesson"); - e.printStackTrace(); - } - return false; - } - - public static String getServerAddress() { return LamsPluginUtil.getProperties().getProperty(LamsPluginUtil.PROP_LAMS_URL); } + /** + * @return gets server id from the lams.properties file + */ public static String getServerID() { return LamsPluginUtil.getProperties().getProperty(LamsPluginUtil.PROP_LAMS_SERVER_ID); } + /** + * @return gets server key from the lams.properties file + */ public static String getServerKey() { return LamsPluginUtil.getProperties().getProperty(LamsPluginUtil.PROP_LAMS_SECRET_KEY); } + /** + * @return gets request source from the lams.properties file + */ public static String getReqSrc() { return LamsPluginUtil.getProperties().getProperty(LamsPluginUtil.PROP_REQ_SRC); } - + /** + * + * @param node the node from which to do the recursive conversion + * @return the string converted to tigra format + */ public static String convertToTigraFormat(Node node) { StringBuilder sb = new StringBuilder(); @@ -500,14 +413,13 @@ serverId.toLowerCase().trim() + secretkey.toLowerCase().trim(); - System.out.println(plaintext); - String hash = sha1(plaintext); - + String hash = sha1(plaintext); return hash; } //generate authentication hash code to validate parameters + public static String generateAuthenticationHash(String datetime, String login, String serverId) { String secretkey = getServerKey(); @@ -516,7 +428,6 @@ serverId.toLowerCase().trim() + secretkey; - System.out.println(plaintext); String hash = sha1(plaintext); return hash; @@ -555,4 +466,32 @@ } } + /** + * + * @param localeStr the full balckboard locale string + * @return the language + */ + public static String getLanguage(String localeStr) + { + if (localeStr==null) + return "xx"; + String[] split = localeStr.split("_"); + return split[0]; + } + + /** + * + * @param localeStr the full balckboard locale string + * @return the country + */ + public static String getCountry(String localeStr) + { + if (localeStr==null) + return "XX"; + String[] split = localeStr.split("_"); + return split[1]; + } + + + } Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/UserDataServlet.java =================================================================== diff -u -r2d8a22624f79146eff859c52775648266d47b826 -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/UserDataServlet.java (.../UserDataServlet.java) (revision 2d8a22624f79146eff859c52775648266d47b826) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/UserDataServlet.java (.../UserDataServlet.java) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -24,35 +24,28 @@ import java.io.PrintWriter; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.Date; - import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -//import javax.servlet.ServletException; - import org.apache.commons.codec.binary.Hex; -//import org.lamsfoundation.lams.integration.security.RandomPasswordGenerator; -//import org.lamsfoundation.lams.usermanagement.AuthenticationMethod; -//import org.lamsfoundation.lams.util.HashUtil; import org.lamsfoundation.ld.util.CSVUtil; import org.lamsfoundation.ld.integration.Constants; - import blackboard.persist.BbPersistenceManager; import blackboard.persist.user.UserDbLoader; import blackboard.platform.BbServiceManager; import blackboard.data.user.User; import blackboard.platform.context.ContextManager; -import blackboard.platform.context.Context; import org.apache.log4j.Logger; +import org.lamsfoundation.ld.integration.blackboard.LamsSecurityUtil; /** * @author Anthony Xiao */ public class UserDataServlet extends HttpServlet { + private static final long serialVersionUID = 2L; static Logger logger = Logger.getLogger(UserDataServlet.class); /** @@ -69,11 +62,11 @@ throws ServletException, IOException{ ContextManager ctxMgr = null; - Context ctx = null; + //get Blackboard context try{ ctxMgr = (ContextManager) BbServiceManager.lookupService(ContextManager.class); - ctx = ctxMgr.setContext(request); + //get Parameter values @@ -120,26 +113,11 @@ PrintWriter out = response.getWriter(); - String loc_lang="en"; - String loc_cntry="US"; - - /* String locale = u.getLocale(); - String loc_lang; - String loc_cntry; - if (u.getLocale()==null) - { - loc_lang="en"; - loc_cntry="US"; - } - else - { - String [] loc = locale.split("_"); - loc_lang=loc[0]; - loc_cntry=loc[1]; - } - */ - + String loc_lang=LamsSecurityUtil.getLanguage(locale); + String loc_cntry=LamsSecurityUtil.getCountry(locale); + + // The CSV list should be the format below // ,<First name>,<Last name>,<Address>,<City>,<State>, // <Postcode>,<Country>,<Day time number>,<Mobile number>, @@ -160,24 +138,7 @@ loc_lang, loc_cntry }; - // DEBUGGING - System.out.println(valList[0]); - System.out.println(valList[1]); - System.out.println(valList[2]); - System.out.println(valList[3]); - System.out.println(valList[4]); - System.out.println(valList[5]); - System.out.println(valList[6]); - System.out.println(valList[7]); - System.out.println(valList[8]); - System.out.println(valList[9]); - System.out.println(valList[10]); - System.out.println(valList[11]); - System.out.println(valList[12]); - System.out.println(valList[13]); - System.out.println("LUKE IS AWESOME: " + CSVUtil.write(valList)); - - + out.println(CSVUtil.write(valList)); } catch (Exception e){ @@ -200,4 +161,6 @@ throw new RuntimeException(e); } } + + } Index: lams_bb_integration/src/org/lamsfoundation/ld/util/CSVUtil.java =================================================================== diff -u -r2d8a22624f79146eff859c52775648266d47b826 -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/src/org/lamsfoundation/ld/util/CSVUtil.java (.../CSVUtil.java) (revision 2d8a22624f79146eff859c52775648266d47b826) +++ lams_bb_integration/src/org/lamsfoundation/ld/util/CSVUtil.java (.../CSVUtil.java) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -1,24 +1,25 @@ -/** - * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) - * +/**************************************************************** + * Copyright (C) 2007 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 as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA - * + * * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** */ - package org.lamsfoundation.ld.util; import java.text.ParseException; @@ -30,7 +31,7 @@ * The two methods write() and parse() will perform writing to and parse from * the CSV format * - * @author <a href="mailto:anthony.xiao@lamsinternational.com">Anthony Xiao</a> + * @author <a href="mailto:lfoxton@melcoe.mq.edu.au">Luke Foxton</a> */ public class CSVUtil { Fisheye: Tag 8af1746d179f41095b074fef269722c6689b39eb refers to a dead (removed) revision in file `lams_bb_integration/src/org/lamsfoundation/ld/webservice/LessonManager.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 8af1746d179f41095b074fef269722c6689b39eb refers to a dead (removed) revision in file `lams_bb_integration/src/org/lamsfoundation/ld/webservice/LessonManagerService.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 8af1746d179f41095b074fef269722c6689b39eb refers to a dead (removed) revision in file `lams_bb_integration/src/org/lamsfoundation/ld/webservice/LessonManagerServiceLocator.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 8af1746d179f41095b074fef269722c6689b39eb refers to a dead (removed) revision in file `lams_bb_integration/src/org/lamsfoundation/ld/webservice/LessonManagerServiceSoapBindingStub.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/web/admin/config.jsp =================================================================== diff -u -r2d8a22624f79146eff859c52775648266d47b826 -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/web/admin/config.jsp (.../config.jsp) (revision 2d8a22624f79146eff859c52775648266d47b826) +++ lams_bb_integration/web/admin/config.jsp (.../config.jsp) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -23,6 +23,10 @@ String lamsServerId = p.getProperty("LAMS_SERVER_ID", ""); String SecretKey = p.getProperty("LAMS_SERVER_SKEY", ""); String ReqSrc = p.getProperty("BB_REQ_SRC"); + + // add port to the url if the port is in the blackboard url. + int bbport = request.getServerPort(); + String bbportstr = bbport != 0 ? ":" + bbport : ""; %> <bbUI:docTemplate title="Configure LAMS"> @@ -48,7 +52,7 @@ <bbUI:step title="Callback URL" number="2"> <bbUI:instructions> Copy and paste the user data callback URL into LAMS <BR> - <B>USER DATA CALLBACK URL</B>: http://<%=request.getServerName()%><%=request.getContextPath()%>/UserData?uid=%username%&ts=%timestamp%&hash=%hash% + <B>USER DATA CALLBACK URL</B>: http://<%=request.getServerName()%><%=bbportstr%><%=request.getContextPath()%>/UserData?uid=%username%&ts=%timestamp%&hash=%hash% </bbUI:instructions> </bbUI:step> <bbUI:stepSubmit title="Submit" number="3" /> Index: lams_bb_integration/web/images/favicon.ico =================================================================== diff -u -rc8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc -r8af1746d179f41095b074fef269722c6689b39eb Binary files differ Index: lams_bb_integration/web/modules/create.jsp =================================================================== diff -u -ra861902df1adee65242a8c37adc1463b99aa7dcb -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/web/modules/create.jsp (.../create.jsp) (revision a861902df1adee65242a8c37adc1463b99aa7dcb) +++ lams_bb_integration/web/modules/create.jsp (.../create.jsp) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -8,7 +8,9 @@ <bbData:context id="ctx"> <bbUI:docTemplate title = "Add new LAMS"> - +<head> + <link type="text/css" rel="stylesheet" href="css/bb.css" /> +</head> <% // SECURITY! //AccessManagerService accessManager = (AccessManagerService) BbServiceManager.lookupService(AccessManagerService.class); @@ -20,6 +22,13 @@ } String authorUrl = LamsSecurityUtil.generateRequestURL(ctx, "author"); String learningDesigns = LamsSecurityUtil.getLearningDesigns(ctx, 2); + + // Error checking + if (learningDesigns.equals("error")) + { + response.sendRedirect("lamsServerDown.jsp"); + } + %> <bbUI:breadcrumbBar handle="control_panel" isContent="true" > @@ -55,11 +64,12 @@ <br> </bbUI:dataElement> </bbUI:step> - <bbUI:step title="Open author, refresh or start the chosen lesson."> + <bbUI:step title="Open author, refresh the workspace or start the chosen lesson."> <bbUI:dataElement> - <input type="button" name="author" onClick="openAuthor();" value="Open Author"> - <input type="button" name="action" onClick="refreshSeqList();" value="Refresh Workspace"> - <input id="nextButton" type="submit" name="nextButton" onClick="openNext();" value="Next" disabled="true"> + <input type="button" class="button"name="author" onClick="openAuthor();" value="Open Author"> + <input type="button" class="button"name="action" onClick="refreshSeqList();" value="Refresh"> + <input id="disabledNextButton" class="disabled" type="button" name="disabledNextButton" value="Next" disabled="true"> + <input id="nextButton" class="button" type="hidden" name="nextButton" onClick="openNext();" value="Next"> </bbUI:dataElement> <br> </bbUI:step> @@ -96,7 +106,12 @@ function selectSequence(id) { - document.getElementById("nextButton").disabled = false; + //document.workspace_form.nextButton.class= "button"; + //document.getElementById("nextButton").disabled = false; + document.getElementById("nextButton").type = "submit"; + document.getElementById("disabledNextButton").type = "hidden"; + + //document.getElementById("nextButton").class = "button"; document.getElementById("sequence_id").value=id; } //--> Fisheye: Tag e145b2587e58d80c54fb208848e06d290c5473cd refers to a dead (removed) revision in file `lams_bb_integration/web/modules/css/bb.css'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/web/modules/css/btn.gif =================================================================== diff -u -re145b2587e58d80c54fb208848e06d290c5473cd -r8af1746d179f41095b074fef269722c6689b39eb Binary files differ Index: lams_bb_integration/web/modules/css/btnDisabled.gif =================================================================== diff -u -re145b2587e58d80c54fb208848e06d290c5473cd -r8af1746d179f41095b074fef269722c6689b39eb Binary files differ Fisheye: Tag c8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc refers to a dead (removed) revision in file `lams_bb_integration/web/modules/lamsServerDown.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/web/modules/learnermonitor.jsp =================================================================== diff -u -ra861902df1adee65242a8c37adc1463b99aa7dcb -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/web/modules/learnermonitor.jsp (.../learnermonitor.jsp) (revision a861902df1adee65242a8c37adc1463b99aa7dcb) +++ lams_bb_integration/web/modules/learnermonitor.jsp (.../learnermonitor.jsp) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -27,7 +27,6 @@ String course_idstr = request.getParameter("course_id"); - BbPersistenceManager bbPm = BbServiceManager.getPersistenceService().getDbPersistenceManager(); Id course_id = bbPm.generateId(Course.COURSE_DATA_TYPE, course_idstr); User sessionUser = ctx.getUser(); @@ -56,30 +55,25 @@ pe.printStackTrace(); } - boolean instructor=false; - boolean student=false; - + + String instructorstr="hidden"; if (courseRole.equals(CourseMembership.Role.INSTRUCTOR)||courseRole.equals(CourseMembership.Role.TEACHING_ASSISTANT)) { // instructor or assistant // can choose to redirect to monitor or learner - instructor=true; + instructorstr="button"; } - else if (courseRole.equals(CourseMembership.Role.STUDENT)) + else if (!courseRole.equals(CourseMembership.Role.STUDENT)) { - // student - // can only access learner pages - student=true; - } - else - { + response.sendRedirect("notAllowed.jsp"); } - %> <bbUI:docTemplate> - +<head> + <link type="text/css" rel="stylesheet" href="css/bb.css" /> +</head> <script language="JavaScript" type="text/javascript"> <!-- var learnerWin = null; @@ -117,91 +111,28 @@ monitorWin.focus(); } } - - - //--> </script> -<script language="JavaScript" type="text/javascript"> - <!-- - if (true) - { - openLearner(); - back(); - } - //--> -</script> + +<bbUI:breadcrumbBar handle="control_panel" isContent="true" > + <bbUI:breadcrumb>LAMS Options</bbUI:breadcrumb> +</bbUI:breadcrumbBar> + +<bbUI:titleBar iconUrl ="/images/ci/icons/bookopen_u.gif">LAMS Options</bbUI:titleBar> + + <form name="workspace_form" id="workspace_form" method="post"> - <input type="button" name="OpenMonitor" onClick="openMonitor();" value="Open Monitor"> - <input type="button" name="OpenLearner" onClick="openLearner();" value="Open Learner"> - <input type="button" name="Cancel" onClick="back();" value="Cancel"> -<form> - - - + <br> + <b>Please Choose an Option</b> + <br><br> +      + <input type="<%=instructorstr%>" class="button" name="OpenMonitor" onClick="openMonitor();" value="Open Monitor"> + <input type="button" class="button" name="OpenLearner" onClick="openLearner();" value="Open Lesson"> + <input type="button" class="button" name="Cancel" onClick="back();" value="Cancel"> +</form> + </bbUI:docTemplate> </bbData:context> - -<%! -static public String getRoleString(String type, Object role) { - // return a User Friendly String for the type Role passed in - String uRole = ""; - if ( type.equals( "COURSE" ) ) { - // get role based on coursemembershipRole (CourseMembership.Role) - if( (CourseMembership.Role)role == CourseMembership.Role.COURSE_BUILDER ) { - uRole="Course Builder"; - } else if ( (CourseMembership.Role)role == CourseMembership.Role.DEFAULT ){ - uRole="Student(Default)"; - } else if ( (CourseMembership.Role)role == CourseMembership.Role.GRADER ) { - uRole="Grader"; - } else if ( (CourseMembership.Role)role == CourseMembership.Role.GUEST ) { - uRole="Guest"; - } else if ( (CourseMembership.Role)role - == CourseMembership.Role.INSTRUCTOR ) { - uRole="Instructor"; - } else if ( (CourseMembership.Role)role == CourseMembership.Role.NONE) { - uRole="No explicit role (NONE)"; - } else if ( (CourseMembership.Role)role == CourseMembership.Role.STUDENT) { - uRole="Student"; - } else if ( (CourseMembership.Role)role - == CourseMembership.Role.TEACHING_ASSISTANT ) { - uRole="Teaching Assistant"; - } else { - uRole = "Cannot Identify Course Membership Role"; - } - } else if ( type.equals( "SYSTEM" ) ) { - // get role based on SystemRole - if( (User.SystemRole)role == User.SystemRole.ACCOUNT_ADMIN ) { - uRole="Account Administrator"; - } else if ( (User.SystemRole)role == User.SystemRole.COURSE_CREATOR ) { - uRole = "Course creator"; - } else if ( (User.SystemRole)role == User.SystemRole.COURSE_SUPPORT ) { - uRole = "Course support"; - } else if ( (User.SystemRole)role == User.SystemRole.DEFAULT ) { - uRole = "User"; - } else if ( (User.SystemRole)role == User.SystemRole.GUEST ) { - uRole = "Guest"; - } else if ( (User.SystemRole)role == User.SystemRole.NONE ) { - uRole = "No explicit role (NONE)"; - } else if ( (User.SystemRole)role == User.SystemRole.OBSERVER ) { - uRole = "Observer"; - } else if ( (User.SystemRole)role == User.SystemRole.SYSTEM_ADMIN ) { - uRole = "System Administrator"; - } else if ( (User.SystemRole)role == User.SystemRole.SYSTEM_SUPPORT ) { - uRole = "System support"; - } else if ( (User.SystemRole)role == User.SystemRole.USER ) { - uRole = "User"; - } else { - uRole = "Cannot Identify User System Role"; - } - } else { - uRole = "TYPE not qualified in method."; - } - - return uRole; -} - -%> Index: lams_bb_integration/web/modules/modify.jsp =================================================================== diff -u -ra861902df1adee65242a8c37adc1463b99aa7dcb -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/web/modules/modify.jsp (.../modify.jsp) (revision a861902df1adee65242a8c37adc1463b99aa7dcb) +++ lams_bb_integration/web/modules/modify.jsp (.../modify.jsp) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -78,9 +78,11 @@ <input type="radio" name="isTracked" value="true" <%=(courseDoc.getIsTracked())?"checked":""%>>Yes <input type="radio" name="isTracked" value="false" <%=(courseDoc.getIsTracked())?"":"checked"%>>No </bbUI:dataElement> - <bbUI:dateAvailability formName="lams_form" + <bbUI:dataElement label="Choose date restrictions"> + <bbUI:dateAvailability formName="lams_form" startDateField="startDate" endDateField="endDate" startDate="<%=startDate%>" endDate="<%=endDate%>"/> + </bbUI:dataElement> </bbUI:step> <bbUI:step title="Start lesson"> <br> Fisheye: Tag 8af1746d179f41095b074fef269722c6689b39eb refers to a dead (removed) revision in file `lams_bb_integration/web/modules/remove.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/web/modules/start_lesson.jsp =================================================================== diff -u -ra861902df1adee65242a8c37adc1463b99aa7dcb -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/web/modules/start_lesson.jsp (.../start_lesson.jsp) (revision a861902df1adee65242a8c37adc1463b99aa7dcb) +++ lams_bb_integration/web/modules/start_lesson.jsp (.../start_lesson.jsp) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -27,8 +27,17 @@ <bbData:context id="ctx"> <bbUI:docTemplate title = "Start a LAMS lesson." > + <head> + <link type="text/css" rel="stylesheet" href="css/bb.css" /> + </head> + + <bbUI:breadcrumbBar handle="control_panel" isContent="true" > + <bbUI:breadcrumb>Start LAMS Lesson</bbUI:breadcrumb> + </bbUI:breadcrumbBar> - <form name="lesson_form" id="lesson_form" action="start_lesson_proc.jsp" method="post"> + <bbUI:titleBar iconUrl ="/images/ci/icons/bookopen_u.gif">Start LAMS Lesson</bbUI:titleBar> + + <form name="lesson_form" id="lesson_form" action="start_lesson_proc.jsp" method="post" onSubmit="return confirmSubmit();"> <input type="hidden" name="sequence_id" id="sequence_id" value="<%=sequenceID%>"> <input type="hidden" name="content_id" value="<%=request.getParameter("content_id")%>"> <input type="hidden" name="course_id" value="<%=request.getParameter("course_id")%>"> @@ -60,8 +69,8 @@ <bbUI:step title="Start lesson"> <br> <bbUI:dataElement> - <input type="submit" name="start" onClick="validateStartLesson();" value="Start Lesson"> - <input type="button" name="cancel" onClick="back();" value="Cancel"> + <input class="button" type="submit" name="start" value="Start Lesson"> + <input class="button" type="button" name="cancel" onClick="back();" value="Cancel"> </bbUI:dataElement> </bbUI:step> </form> @@ -73,22 +82,21 @@ history.go(-1); } - function validateStartLesson() + function confirmSubmit() { - var title = trim(document.getElementById("title").value); - - // valdation - if (title==null||title=="") - { - alert("Lesson must have a name."); - return false; - } + var title = rettrim(document.lesson_form.title.value); + if ((title == "")||(title == null)) + { + alert("The title is empty. Please enter a title for the LAMS sequence."); + return false; + } } - - - + function rettrim(stringToTrim) { + return stringToTrim.replace(/^\s+|\s+$/g,""); + } + //--> </script> </bbUI:docTemplate> Index: lams_bb_integration/web/modules/start_lesson_proc.jsp =================================================================== diff -u -ra861902df1adee65242a8c37adc1463b99aa7dcb -r8af1746d179f41095b074fef269722c6689b39eb --- lams_bb_integration/web/modules/start_lesson_proc.jsp (.../start_lesson_proc.jsp) (revision a861902df1adee65242a8c37adc1463b99aa7dcb) +++ lams_bb_integration/web/modules/start_lesson_proc.jsp (.../start_lesson_proc.jsp) (revision 8af1746d179f41095b074fef269722c6689b39eb) @@ -6,7 +6,6 @@ <%@ page import="blackboard.data.content.ContentFile"%> <%@ page import="blackboard.data.content.ContentFolder"%> <%@ page import="blackboard.data.content.CourseDocument"%> - <%@ page import="blackboard.persist.Id"%> <%@ page import="blackboard.persist.BbPersistenceManager"%> <%@ page import="blackboard.persist.content.ContentDbPersister"%> @@ -62,24 +61,8 @@ myContent.setIsAvailable(request.getParameter("isAvailable").equals("true")?true:false); myContent.setIsTracked(request.getParameter("isTracked").equals("true")?true:false); - //get descriptions entered - //FormattedText.Type descType = FormattedText.Type.DEFAULT; //type of description (S|H|P) - //switch(p_descType.charAt(0)){ - // case 'H': - // descType = FormattedText.Type.HTML; break; - // case 'S': - // descType = FormattedText.Type.SMART_TEXT; break; - // case 'P': - // descType = FormattedText.Type.PLAIN_TEXT; break; - //} - //if(!myContent.getIsAvailable()){ - // p_descText = "<i>Item is not available.</i><br>" + p_descText; - //} - //FormattedText description = new FormattedText(p_descText,descType); FormattedText fdescription = new FormattedText(description, FormattedText.Type.HTML); - - - + // set core course data myContent.setContentHandler( LamsPluginUtil.CONTENT_HANDLE ); myContent.setCourseId( courseId ); @@ -94,37 +77,33 @@ // tell lams to create the learning session using webservices try{ long lsId = LamsSecurityUtil.startLesson(ctx, ldId, title, description); - learningSessionId = Long.toString(lsId); - } catch (Exception e){ + + //error checking + if (lsId == -1) + { + response.sendRedirect("lamsServerDown.jsp"); + System.exit(1); + } + + learningSessionId = Long.toString(lsId); + + + } catch (Exception e){ throw new ServletException(e.getMessage(), e); } + // add port to the url if the port is in the blackboard url. int bbport = request.getServerPort(); - String bbportstr; - if (new Integer(bbport).equals(null) || bbport==0) - { - bbportstr = ""; - } - else - { - bbportstr = ":" + bbport; - } + String bbportstr = bbport != 0 ? ":" + bbport : ""; //String contentUrl = LamsSecurityUtil.generateRequestURL(ctx, "learner") + "&lsid=" + learningSessionId; String contentUrl = "http://" + request.getServerName() + bbportstr + request.getContextPath() + "/modules/learnermonitor.jsp?lsid=" + learningSessionId + "&course_id=" + request.getParameter("course_id"); - - - myContent.setUrl(contentUrl); - - - //myContent.setPosition(0); - //myContent.setLaunchInNewWindow(true); - + //Parse start/end Date from the <bbUI:dateAvailability> SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar cstart = Calendar.getInstance();