Index: lams_bb_integration/RELEASE_NOTES.TXT =================================================================== diff -u -r60c470dd6832f76d6a7b05bf54a763532af113c9 -rceb0cd59c019481da796281a115e4d2e61034b25 --- lams_bb_integration/RELEASE_NOTES.TXT (.../RELEASE_NOTES.TXT) (revision 60c470dd6832f76d6a7b05bf54a763532af113c9) +++ lams_bb_integration/RELEASE_NOTES.TXT (.../RELEASE_NOTES.TXT) (revision ceb0cd59c019481da796281a115e4d2e61034b25) @@ -51,5 +51,5 @@ =================== * LDEV-3176 Fix wrong URL format for starting LAMS lesson * LDEV-2790 Use html editor for lesson description +* LDEV-3180 Load LAMS sequences on demand - Index: lams_bb_integration/WEB-INF/web.xml =================================================================== diff -u -r7313b5c073ae563d642a7ef9a2acec81caa2a8ea -rceb0cd59c019481da796281a115e4d2e61034b25 --- lams_bb_integration/WEB-INF/web.xml (.../web.xml) (revision 7313b5c073ae563d642a7ef9a2acec81caa2a8ea) +++ lams_bb_integration/WEB-INF/web.xml (.../web.xml) (revision ceb0cd59c019481da796281a115e4d2e61034b25) @@ -10,17 +10,17 @@ org.lamsfoundation.ld.integration.blackboard.UserDataServlet - LamsActionRequestServlet - org.lamsfoundation.ld.integration.blackboard.LamsActionRequestServlet + LamsLearningDesignServlet + org.lamsfoundation.ld.integration.blackboard.LamsLearningDesignServlet GradebookServlet org.lamsfoundation.ld.integration.blackboard.GradebookServlet - LamsActionRequestServlet - /LamsActionRequest + LamsLearningDesignServlet + /LamsLearningDesign UserDataServlet Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/Constants.java =================================================================== diff -u -r7313b5c073ae563d642a7ef9a2acec81caa2a8ea -rceb0cd59c019481da796281a115e4d2e61034b25 --- lams_bb_integration/src/org/lamsfoundation/ld/integration/Constants.java (.../Constants.java) (revision 7313b5c073ae563d642a7ef9a2acec81caa2a8ea) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/Constants.java (.../Constants.java) (revision ceb0cd59c019481da796281a115e4d2e61034b25) @@ -38,6 +38,7 @@ public static final String PARAM_LESSON_ID = "lsId"; public static final String PARAM_LEARNING_DESIGN_ID = "ldid"; public static final String PARAM_COURSE_ID = "course_id"; + public static final String PARAM_FOLDER_ID = "folderId"; public static final String SERVLET_LOGIN_REQUEST = "/lams/LoginRequest"; public static final String SERVLET_ACTION_REQUEST = "/LamsActionRequest"; Fisheye: Tag ceb0cd59c019481da796281a115e4d2e61034b25 refers to a dead (removed) revision in file `lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsActionRequestServlet.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag c8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc refers to a dead (removed) revision in file `lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsLearningDesignServlet.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java =================================================================== diff -u -r1568156ccc545849b14864558e2c3c360a3364d2 -rceb0cd59c019481da796281a115e4d2e61034b25 --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision 1568156ccc545849b14864558e2c3c360a3364d2) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision ceb0cd59c019481da796281a115e4d2e61034b25) @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.InputStream; +import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.net.ConnectException; import java.net.HttpURLConnection; @@ -35,19 +36,13 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import javax.servlet.ServletException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; import org.apache.commons.codec.binary.Hex; import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; -import org.lamsfoundation.ld.integration.Constants; import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; import blackboard.platform.context.Context; @@ -162,43 +157,52 @@ * 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 + * the blackboard context, contains session data + * @param courseId + * blackboard courseid. We pass it as a parameter as ctx.getCourse().getCourseId() is null when called + * from LamsLearningDesignServlet. + * @param folderId folderId. It can be null and then LAMS returns default workspace folders. + * * @return a string containing the LAMS workspace tree in tigra format */ - public static String getLearningDesigns(Context ctx, Integer mode) { + public static String getLearningDesigns(Context ctx, String courseId, String folderId) { String serverAddr = getServerAddress(); String serverId = getServerID(); - String serverKey = getServerKey(); // If lams.properties could not be read, throw exception - if (serverAddr == null || serverId == null || serverKey == null) { + if (serverAddr == null || serverId == null) { throw new RuntimeException("lams.properties file could not be read. serverAddr:" + serverAddr + ", serverId:" + serverId); } String timestamp = new Long(System.currentTimeMillis()).toString(); String username = ctx.getUser().getUserName(); String firstName = ctx.getUser().getGivenName(); - String lastName = ctx.getUser().getFamilyName(); + String lastName = ctx.getUser().getFamilyName(); String email = ctx.getUser().getEmailAddress(); String hash = generateAuthenticationHash(timestamp, username, serverId); - String courseId = ctx.getCourse().getCourseId(); String locale = ctx.getUser().getLocale(); String country = getCountry(locale); String lang = getLanguage(locale); + // LamsSecurityUtil.getLearningDesigns(null, userDTO.getUserID(), false); + // the mode to call upon learning designs + final Integer MODE = 2; + // TODO: Make locale settings work - String learningDesigns = "[]"; // empty javascript array + String learningDesigns = ""; // empty try { - String serviceURL = serverAddr + "/services/xml/LearningDesignRepository?" + "datetime=" + timestamp - + "&username=" + URLEncoder.encode(username, "utf8") + "&serverId=" + + String serviceURL = 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=" + email; + + URLEncoder.encode(courseId, "UTF8") + "&country=" + country + "&lang=" + lang + "&mode=" + MODE + + "&firstName=" + URLEncoder.encode(firstName, "UTF-8") + "&lastName=" + + URLEncoder.encode(lastName, "UTF-8") + "&email=" + email; + if (folderId != null) { + serviceURL += "&folderID=" + folderId; + } URL url = new URL(serviceURL); URLConnection conn = url.openConnection(); @@ -215,21 +219,13 @@ + httpConn.getResponseMessage()); } - // InputStream is = url.openConnection().getInputStream(); InputStream is = conn.getInputStream(); - // parse xml response - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document document = db.parse(is); + // Read/convert response to a String + StringWriter writer = new StringWriter(); + IOUtils.copy(is, writer, "UTF-8"); + learningDesigns = writer.toString(); - learningDesigns = "[" + convertToTigraFormat(document.getDocumentElement()) + "]"; - - // replace sequence id with javascript method - //String pattern = "'(\\d+)'"; - //String replacement = "'javascript:selectSequence($1)'"; - //learningDesigns = learningDesigns.replaceAll(pattern, replacement); - } catch (MalformedURLException e) { throw new RuntimeException("Unable to get LAMS learning designs, bad URL: '" + serverAddr + "', please check lams.properties", e); @@ -245,10 +241,6 @@ throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (SAXException e) { - throw new RuntimeException(e); } return learningDesigns; @@ -379,59 +371,59 @@ 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) { +// /** +// * +// * @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(); +// +// if (node.getNodeName().equals(Constants.ELEM_FOLDER)) { +// +// StringBuilder attribute = new StringBuilder(node.getAttributes().getNamedItem(Constants.ATTR_NAME) +// .getNodeValue().replace("'", "\\'")); +// +// sb.append("{type:'Text', label:'" + attribute + "',id:0"); +// +// NodeList children = node.getChildNodes(); +// if (children.getLength() == 0) { +// sb.append(",expanded:0,children:[{type:'HTML',html:'-empty-', id:0}]}"); +// return sb.toString(); +// } else { +// sb.append(",children:["); +// +// +// sb.append(convertToTigraFormat(children.item(0))); +// for (int i = 1; i < children.getLength(); i++) { +// sb.append(',').append(convertToTigraFormat(children.item(i))); +// } +// +// sb.append("]}"); +// } +// +// } else if (node.getNodeName().equals(Constants.ELEM_LEARNING_DESIGN)) { +// +// +//// $ld_name = preg_replace("/'/", "$1\'", $xml_node['@']['name']); +//// $output .= "{type:'Text',label:'" . $ld_name . "',id:'" . $xml_node['@']['resourceId'] . "'}"; +// +// StringBuilder attrName = new StringBuilder(node.getAttributes().getNamedItem(Constants.ATTR_NAME) +// .getNodeValue().replace("'", "\\'")); +// StringBuilder attrResId = new StringBuilder(node.getAttributes().getNamedItem(Constants.ATTR_RESOURCE_ID) +// .getNodeValue().replace("'", "\\'")); +// +// sb.append("{type:'Text',label:'"); +// sb.append(attrName); +// sb.append("',id:'"); +// sb.append(attrResId); +// sb.append("'}"); +// } +// return sb.toString(); +// } - StringBuilder sb = new StringBuilder(); - - if (node.getNodeName().equals(Constants.ELEM_FOLDER)) { - - StringBuilder attribute = new StringBuilder(node.getAttributes().getNamedItem(Constants.ATTR_NAME) - .getNodeValue().replace("'", "\\'")); - - sb.append("{type:'Text', label:'" + attribute + "',id:0"); - - NodeList children = node.getChildNodes(); - if (children.getLength() == 0) { - sb.append(",expanded:0,children:[{type:'HTML',html:'-empty-', id:0}]}"); - return sb.toString(); - } else { - sb.append(",children:["); - - - sb.append(convertToTigraFormat(children.item(0))); - for (int i = 1; i < children.getLength(); i++) { - sb.append(',').append(convertToTigraFormat(children.item(i))); - } - - sb.append("]}"); - } - - } else if (node.getNodeName().equals(Constants.ELEM_LEARNING_DESIGN)) { - - -// $ld_name = preg_replace("/'/", "$1\'", $xml_node['@']['name']); -// $output .= "{type:'Text',label:'" . $ld_name . "',id:'" . $xml_node['@']['resourceId'] . "'}"; - - StringBuilder attrName = new StringBuilder(node.getAttributes().getNamedItem(Constants.ATTR_NAME) - .getNodeValue().replace("'", "\\'")); - StringBuilder attrResId = new StringBuilder(node.getAttributes().getNamedItem(Constants.ATTR_RESOURCE_ID) - .getNodeValue().replace("'", "\\'")); - - sb.append("{type:'Text',label:'"); - sb.append(attrName); - sb.append("',id:'"); - sb.append(attrResId); - sb.append("'}"); - } - return sb.toString(); - } - // generate authentication hash code to validate parameters public static String generateAuthenticationHash(String datetime, String login, String method, String serverId) { String secretkey = LamsPluginUtil.getSecretKey(); Fisheye: Tag c8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc refers to a dead (removed) revision in file `lams_bb_integration/web/includes/css/bb.css'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/web/includes/css/btn.gif =================================================================== diff -u -rc8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc -rceb0cd59c019481da796281a115e4d2e61034b25 Binary files differ Index: lams_bb_integration/web/includes/css/btnDisabled.gif =================================================================== diff -u -rc8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc -rceb0cd59c019481da796281a115e4d2e61034b25 Binary files differ Fisheye: Tag c8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc refers to a dead (removed) revision in file `lams_bb_integration/web/includes/css/folders.css'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag c8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc refers to a dead (removed) revision in file `lams_bb_integration/web/includes/css/treeview.css'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag c8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc refers to a dead (removed) revision in file `lams_bb_integration/web/includes/javascript/jquery.js'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag c8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc refers to a dead (removed) revision in file `lams_bb_integration/web/includes/javascript/treeview-min.js'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag c8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc refers to a dead (removed) revision in file `lams_bb_integration/web/includes/javascript/yahoo-dom-event.js'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ceb0cd59c019481da796281a115e4d2e61034b25 refers to a dead (removed) revision in file `lams_bb_integration/web/lib/tree/treeview-min.js'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ceb0cd59c019481da796281a115e4d2e61034b25 refers to a dead (removed) revision in file `lams_bb_integration/web/lib/tree/yahoo-dom-event.js'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/web/modules/create.jsp =================================================================== diff -u -r0b039f5d3b81dd56af9fdf497c1ebe921e8e9b1d -rceb0cd59c019481da796281a115e4d2e61034b25 --- lams_bb_integration/web/modules/create.jsp (.../create.jsp) (revision 0b039f5d3b81dd56af9fdf497c1ebe921e8e9b1d) +++ lams_bb_integration/web/modules/create.jsp (.../create.jsp) (revision ceb0cd59c019481da796281a115e4d2e61034b25) @@ -21,11 +21,12 @@ <%@ taglib uri="/bbNG" prefix="bbNG"%> - - + + + - - + + <% // Authorise current user for Course Control Panel (automatic redirect) try{ @@ -39,10 +40,91 @@ String authorUrl = LamsSecurityUtil.generateRequestURL(ctx, "author"); // Get the list of Learning Designs - String learningDesigns = LamsSecurityUtil.getLearningDesigns(ctx, 2); + //String learningDesigns = LamsSecurityUtil.getLearningDesigns(ctx, 2); String lamsServerUrl = LamsSecurityUtil.getServerAddress(); + + // get all user accessible folders and LD descriptions as JSON + String learningDesigns = LamsSecurityUtil.getLearningDesigns(ctx, ctx.getCourse().getCourseId(), null); %> + + + + + <%-- Breadcrumbs --%> @@ -101,25 +183,11 @@ -
+
Display image design?
- - <%-- Display LAMS Sequence tree (Using tigra) --%> - @@ -187,7 +255,7 @@ // Open the LAMS Seuence Preview Window function openPreview() { - var previewUrl = "preview.jsp?course_id=<%=request.getParameter("course_id")%>&ldId=" + document.getElementsByName("sequence_id")[0].value + "&title=" + document.lesson_form.title.value + "&description=" + document.lesson_form.description.value; + var previewUrl = "preview.jsp?course_id=<%=request.getParameter("course_id")%>&ldId=" + document.getElementsByName("sequence_id")[0].value + "&title=" + document.lesson_form.title.value; //lams_central //if (parentURL != "") { @@ -216,10 +284,10 @@ } // Refresh the LAMS sequence list (tigra tree) - function refreshSeqList() { + function refreshSeqList() { document.getElementById("sequence_id").value="0"; document.location.reload(); - } + } function selectSequence(obj, name){ // if the selected object is a sequence (id!=0) then we assign the id to the hidden sequence_id Fisheye: Tag ceb0cd59c019481da796281a115e4d2e61034b25 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 -r6fe54e5afc8aeab9db6e51472e4abf1c8077000e -rceb0cd59c019481da796281a115e4d2e61034b25 Binary files differ Index: lams_bb_integration/web/modules/css/btnDisabled.gif =================================================================== diff -u -r6fe54e5afc8aeab9db6e51472e4abf1c8077000e -rceb0cd59c019481da796281a115e4d2e61034b25 Binary files differ Fisheye: Tag ceb0cd59c019481da796281a115e4d2e61034b25 refers to a dead (removed) revision in file `lams_bb_integration/web/modules/css/folders.css'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ceb0cd59c019481da796281a115e4d2e61034b25 refers to a dead (removed) revision in file `lams_bb_integration/web/modules/css/treeview.css'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ceb0cd59c019481da796281a115e4d2e61034b25 refers to a dead (removed) revision in file `lams_bb_integration/web/modules/js/DynamicOptionList.js'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ceb0cd59c019481da796281a115e4d2e61034b25 refers to a dead (removed) revision in file `lams_bb_integration/web/modules/js/seqList.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/web/modules/preview.jsp =================================================================== diff -u -re27f01d34eea709e255d542039faac9c4e46ac4d -rceb0cd59c019481da796281a115e4d2e61034b25 --- lams_bb_integration/web/modules/preview.jsp (.../preview.jsp) (revision e27f01d34eea709e255d542039faac9c4e46ac4d) +++ lams_bb_integration/web/modules/preview.jsp (.../preview.jsp) (revision ceb0cd59c019481da796281a115e4d2e61034b25) @@ -51,15 +51,13 @@ // Get the form parameters and convert into correct data types String strTitle = request.getParameter("title").trim(); - String strDescription = request.getParameter("description").trim(); - FormattedText description = new FormattedText(strDescription, FormattedText.Type.HTML); String strLdId = request.getParameter("ldId").trim(); long ldId = Long.parseLong(strLdId); // Start the Lesson for preview in LAMS (via Webservices) // Capture the lesson ID - Long lsId = LamsSecurityUtil.startLesson(ctx, ldId, strTitle, strDescription, true); + Long lsId = LamsSecurityUtil.startLesson(ctx, ldId, strTitle, "", true); //error checking if (lsId == -1) { response.sendRedirect("lamsServerDown.jsp");