Index: lams_bb_integration/RELEASE_NOTES.TXT =================================================================== diff -u -ra930db13eb2e9bd50802f65516c169da454e9030 -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/RELEASE_NOTES.TXT (.../RELEASE_NOTES.TXT) (revision a930db13eb2e9bd50802f65516c169da454e9030) +++ lams_bb_integration/RELEASE_NOTES.TXT (.../RELEASE_NOTES.TXT) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -18,6 +18,17 @@ * LDEV-1353 All uppercase characters in secret key causes an illegal state exception +1.1.0 Fixes / Changes for Blackboard 9.1 (SP6) +* Removed references to the AccessManagerService class (deprecated) +* Replaced references to deprecated COURSE_DOCUMENT_DATA_TYPE and COURSE_DATA_TYPE to DATA_TYPE +* PlugInUtil.getEditableContentReturnURL() now requires two mandatory parameters (previously only required one), code now supplies both +* Consistent security checking across all jsp pages +* Prevent students who are still enrolled but have a status of inactive accessing the LAMS lesson URL directly +* Changed code workflow to NOT set start date automatically on creation and modification of lessons. You can now set and unset both start and end dates. +* Updated all jsp pages to use the new Blackboard presentation tags (Using bbNG instead of bbData and bbUI) +* Updated and increased level of code comments in jsp pages for future maintenance +* Deleted all unused jsp pages. + Index: lams_bb_integration/WEB-INF/bb-manifest.xml =================================================================== diff -u -ra930db13eb2e9bd50802f65516c169da454e9030 -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/WEB-INF/bb-manifest.xml (.../bb-manifest.xml) (revision a930db13eb2e9bd50802f65516c169da454e9030) +++ lams_bb_integration/WEB-INF/bb-manifest.xml (.../bb-manifest.xml) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -5,9 +5,9 @@ - + - + @@ -17,10 +17,6 @@ - @@ -31,38 +27,31 @@ - - - - - - + - - - - - + + + + + - + - + Index: lams_bb_integration/WEB-INF/web.xml =================================================================== diff -u -r8ea6dac2e1f9e39a41030dd5907592bc2aa04d17 -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/WEB-INF/web.xml (.../web.xml) (revision 8ea6dac2e1f9e39a41030dd5907592bc2aa04d17) +++ lams_bb_integration/WEB-INF/web.xml (.../web.xml) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -22,15 +22,6 @@ UserDataServlet /UserData - - - - /bbUI - /WEB-INF/config/taglibs/bbUI.tld - - - /bbData - /WEB-INF/config/taglibs/bbData.tld - + Index: lams_bb_integration/build.xml =================================================================== diff -u -r01bff541ab9e8724006329eb69455e7e232111cd -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/build.xml (.../build.xml) (revision 01bff541ab9e8724006329eb69455e7e232111cd) +++ lams_bb_integration/build.xml (.../build.xml) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -2,7 +2,7 @@ - + Index: lams_bb_integration/readme.txt =================================================================== diff -u -r8ea6dac2e1f9e39a41030dd5907592bc2aa04d17 -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/readme.txt (.../readme.txt) (revision 8ea6dac2e1f9e39a41030dd5907592bc2aa04d17) +++ lams_bb_integration/readme.txt (.../readme.txt) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -4,6 +4,11 @@ By Luke Foxton LAMS Foundation Copyright (C) 2007 (http://lamsfoundation.org) +Updated for the Blackboard 9.1 SP6 Building block by +Richard Stals (www.stals.com.au) +Edith Cowan University +2011 + Contents ================================================================================ 1. Requirements @@ -17,7 +22,7 @@ 1. Requirements ================================================================================ 1.1 Minimum requirement to install the module - - Blackboard Learning System 7 + - Blackboard Learning System 9.1 1.2 Minimum requirement to build the module from source - Java 2 Platform, Standard Edition, v 1.5 @@ -56,7 +61,7 @@ 4. Configuring the LAMS Server for Blackboard Integration ================================================================================ 1. Login to LAMS as sysadmin - 2. Open the Sys Admin window, thne navigate to the "Maintain Integrated + 2. Open the Sys Admin window, the navigate to the "Maintain Integrated Servers page. 3. Click "Add New Server" 4. Put in the same ID and key as blackboard @@ -67,7 +72,7 @@ 7. Enter the "User Information URL", this points to the servlet that provides LAMS with Blackboard user information. (See step 7 of "Configuring the module in Blackboard") - 8. You can optionally put a timout URL and choose an organisation to add + 8. You can optionally put a timeout URL and choose an organisation to add the integrated server to. Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java =================================================================== diff -u -r01bff541ab9e8724006329eb69455e7e232111cd -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision 01bff541ab9e8724006329eb69455e7e232111cd) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -331,7 +331,8 @@ } } - + + /** * @return gets server address from the lams.properties file */ Index: lams_bb_integration/web/admin/config.jsp =================================================================== diff -u -r8ea6dac2e1f9e39a41030dd5907592bc2aa04d17 -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/web/admin/config.jsp (.../config.jsp) (revision 8ea6dac2e1f9e39a41030dd5907592bc2aa04d17) +++ lams_bb_integration/web/admin/config.jsp (.../config.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -1,63 +1,78 @@ -<%@page import="java.util.Properties, - blackboard.platform.BbServiceManager, - blackboard.platform.plugin.PlugInUtil, - blackboard.platform.security.AccessManagerService, - org.lamsfoundation.ld.integration.blackboard.LamsPluginUtil" - errorPage="/error.jsp" -%> - -<%@ taglib uri="/bbUI" prefix="bbUI"%> -<%@ taglib uri="/bbData" prefix="bbData"%> - - +<%-- + Original Version: 2007 LAMS Foundation + Updated for Blackboard 9.1 SP6 (including new bbNG tag library) 2011 + Richard Stals (www.stals.com.au) + Edith Cowan University, Western Australia +--%> +<%-- + Configuration Form for the Building Block System Administration + View and set the configuration items +--%> +<%@ page import="java.util.Properties"%> +<%@ page import="blackboard.platform.BbServiceManager"%> +<%@ page import="blackboard.platform.plugin.PlugInUtil"%> +<%@ page import="blackboard.platform.plugin.PlugInException"%> +<%@ page import="org.lamsfoundation.ld.integration.blackboard.LamsPluginUtil"%> +<%@ page errorPage="/error.jsp"%> +<%@ taglib uri="/bbNG" prefix="bbNG"%> + <% // SECURITY! - AccessManagerService accessManager = (AccessManagerService) BbServiceManager.lookupService(AccessManagerService.class); - if (!PlugInUtil.authorizeForSystemAdmin(request,response)){ - accessManager.sendAccessDeniedRedirect(request,response); - return; + // Authorise current user for System Admin (automatic redirect) + try{ + if (!PlugInUtil.authorizeForSystemAdmin(request, response)) + return; + } catch(PlugInException e) { + throw new RuntimeException(e); } - + + // Get the LAMS2 Building Block properties from Blackboard (if set) Properties p = LamsPluginUtil.getProperties(); - String lamsServerUrl = p.getProperty("LAMS_SERVER_URL", "http://"); - String lamsServerId = p.getProperty("LAMS_SERVER_ID", ""); - String SecretKey = p.getProperty("LAMS_SERVER_SKEY", ""); - String ReqSrc = p.getProperty("BB_REQ_SRC"); + String lamsServerUrl = p.getProperty("LAMS_SERVER_URL", "http://"); + 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 : ""; + //Add port to the url if the port is in the blackboard url + int bbport = request.getServerPort(); + String bbportstr = bbport != 0 ? ":" + bbport : ""; %> - - - LAMS Configuration - -Configure Sample Plugin. -
- - - - - - - - - - - - - - - - - Copy and paste the user data callback URL into LAMS
- USER DATA CALLBACK URL: http://<%=request.getServerName()%><%=bbportstr%><%=request.getContextPath()%>/UserData?uid=%username%&ts=%timestamp%&hash=%hash% -
-
- - - - -
-
\ No newline at end of file + <%-- Breadcrumbs It seems we need to build the full trail manually --%> + + + + + + + + <%-- Page Header --%> + + + + + <%-- Properties Form --%> +
+ + + + + + + + + + + + + + + + + USER DATA CALLBACK URL: http://<%=request.getServerName()%><%=bbportstr%><%=request.getContextPath()%>/UserData?uid=%username%&ts=%timestamp%&hash=%hash% + + + +
+ + \ No newline at end of file Index: lams_bb_integration/web/admin/config_proc.jsp =================================================================== diff -u -ra225f60e82f4197c7a2bf6dbb7200709d1e852d7 -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/web/admin/config_proc.jsp (.../config_proc.jsp) (revision a225f60e82f4197c7a2bf6dbb7200709d1e852d7) +++ lams_bb_integration/web/admin/config_proc.jsp (.../config_proc.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -1,50 +1,75 @@ -<%@page import="java.util.Properties, - blackboard.platform.BbServiceManager, - blackboard.platform.plugin.PlugInUtil, - blackboard.platform.security.AccessManagerService, - org.lamsfoundation.ld.integration.blackboard.LamsPluginUtil" - - errorPage="/error.jsp" -%> - -<%@ taglib uri="/bbUI" prefix="bbUI"%> -<%@ taglib uri="/bbData" prefix="bbData"%> - +<%-- + Original Version: 2007 LAMS Foundation + Updated for Blackboard 9.1 SP6 (including new bbNG tag library) 2011 + Richard Stals (www.stals.com.au) + Edith Cowan University, Western Australia +--%> +<%-- + Process the Configuration Form for the Building Block System Administration + Save the configuration items and display a success receipt +--%> +<%@ page import="java.util.Properties"%> +<%@ page import="blackboard.platform.BbServiceManager"%> +<%@ page import="blackboard.platform.plugin.PlugInUtil"%> +<%@ page import="blackboard.platform.plugin.PlugInException"%> +<%@ page import="org.lamsfoundation.ld.integration.blackboard.LamsPluginUtil"%> +<%@ page errorPage="/error.jsp"%> +<%@ taglib uri="/bbNG" prefix="bbNG"%> + <% // SECURITY! - AccessManagerService accessManager = (AccessManagerService) BbServiceManager.lookupService(AccessManagerService.class); - if (!PlugInUtil.authorizeForSystemAdmin(request,response)){ - accessManager.sendAccessDeniedRedirect(request,response); - return; + // Authorise current user for System Admin (automatic redirect) + try{ + if (!PlugInUtil.authorizeForSystemAdmin(request, response)) + return; + } catch(PlugInException e) { + throw new RuntimeException(e); } + + // Save the Properties + + // Getthe properties object Properties p = LamsPluginUtil.getProperties(); + + // Get the LAMS2 Building Block properties from the request String lamsServerUrl = request.getParameter("lams_server_url"); String lamsServerSkey = request.getParameter("lams_server_skey"); String lamsServerId = request.getParameter("lams_server_id"); String bbReqSrc = request.getParameter("bb_req_src"); + // Save the properties to Blackboard p.setProperty(LamsPluginUtil.PROP_LAMS_URL, lamsServerUrl); p.setProperty(LamsPluginUtil.PROP_LAMS_SECRET_KEY, lamsServerSkey); p.setProperty(LamsPluginUtil.PROP_LAMS_SERVER_ID, lamsServerId); p.setProperty("BB_REQ_SRC", bbReqSrc); - - LamsPluginUtil.setProperties(p); //persist the properties file + + // Persist the properties object + LamsPluginUtil.setProperties(p); %> - - - LAMS Configuration - - -

Sample plugin configured

- LAMS_SERVER_URL: <%= lamsServerUrl %>
- LAMS_SERVER_SKEY: <%= lamsServerSkey %>
- LAMS_SERVER_ID: <%= lamsServerId %>
- BB_REQ_SRC: <%= bbReqSrc %> - -
- - \ No newline at end of file + <%-- Breadcrumbs It seems we need to build the full trail manually --%> + + + + + + + + <%-- Page Header --%> + + + + + <%-- Receipt --%> + +

Sample plugin configured

+ LAMS_SERVER_URL: <%= lamsServerUrl %>
+ LAMS_SERVER_SKEY: <%= lamsServerSkey %>
+ LAMS_SERVER_ID: <%= lamsServerId %>
+ BB_REQ_SRC: <%= bbReqSrc %> + + + \ No newline at end of file Index: lams_bb_integration/web/error.jsp =================================================================== diff -u -ra225f60e82f4197c7a2bf6dbb7200709d1e852d7 -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/web/error.jsp (.../error.jsp) (revision a225f60e82f4197c7a2bf6dbb7200709d1e852d7) +++ lams_bb_integration/web/error.jsp (.../error.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -1,19 +1,34 @@ -<%@ taglib uri="/bbUI" prefix="bbUI"%> +<%-- + Original Version: 2007 LAMS Foundation + Updated for Blackboard 9.1 SP6 (including new bbNG tag library) 2011 + Richard Stals (www.stals.com.au) + Edith Cowan University, Western Australia +--%> +<%-- + General Error Page + Print out the Exception Messsage and full stack trace +--%> <%@ page import="java.io.PrintWriter"%> <%@ page isErrorPage = "true" %> +<%@ taglib uri="/bbNG" prefix="bbNG"%> <% String strException = exception.getMessage(); response.setStatus(response.SC_INTERNAL_SERVER_ERROR); %> - -<%=strException%> -

-

-<%
-	// now display a stack trace of the exception
-  PrintWriter pw = new PrintWriter( out );
-  exception.printStackTrace( pw );
-%>
-
-

+ + + <%=strException%> +

+

+                    <%  // Display a stack trace of the exception
+                        PrintWriter pw = new PrintWriter( out );
+                        exception.printStackTrace( pw );
+                    %>
+                
+

+
+ +
\ No newline at end of file Index: lams_bb_integration/web/modules/create.jsp =================================================================== diff -u -r1e15d13033d975a99f5361181aa8a7eb3b14f82d -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/web/modules/create.jsp (.../create.jsp) (revision 1e15d13033d975a99f5361181aa8a7eb3b14f82d) +++ lams_bb_integration/web/modules/create.jsp (.../create.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -1,138 +1,138 @@ +<%-- + Original Version: 2007 LAMS Foundation + Updated for Blackboard 9.1 SP6 (including new bbNG tag library) 2011 + Richard Stals (www.stals.com.au) + Edith Cowan University, Western Australia +--%> +<%-- + Step 1 For Creating a New LAMS Lesson + Allows the user to (optionally) author a new LAMS lesson + Then the user must select a LAMS lesson before proceeding to Step 2. + + Step 1 - create.jsp + Step 2 - start_lesson.jsp + Step 3 - start_lesson_proc.jsp +--%> <%@ page import="blackboard.platform.plugin.PlugInUtil"%> +<%@ page import="blackboard.platform.plugin.PlugInException"%> <%@ page import="org.lamsfoundation.ld.integration.Constants"%> <%@ page import="org.lamsfoundation.ld.integration.blackboard.LamsSecurityUtil"%> <%@ page errorPage="/error.jsp"%> +<%@ taglib uri="/bbNG" prefix="bbNG"%> -<%@ taglib uri="/bbData" prefix="bbData"%> -<%@ taglib uri="/bbUI" prefix="bbUI"%> - - - - - - + + + <% - // SECURITY! - //AccessManagerService accessManager = (AccessManagerService) BbServiceManager.lookupService(AccessManagerService.class); - if (!PlugInUtil.authorizeForCourseControlPanel(request,response)){ - //accessManager.sendAccessDeniedRedirect(request,response); - //TODO: redirect user to login page, since sendAccessDeniedRedirect is deprecated another way is needed - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - return; - } - String authorUrl = LamsSecurityUtil.generateRequestURL(ctx, "author"); - String learningDesigns = LamsSecurityUtil.getLearningDesigns(ctx, 2); - - // Error checking - if (learningDesigns.equals("error")) - { - response.sendRedirect("lamsServerDown.jsp"); - } + // SECURITY! + // Authorise current user for Course Control Panel (automatic redirect) + try{ + if (!PlugInUtil.authorizeForCourseControlPanel(request, response)) + return; + } catch(PlugInException e) { + throw new RuntimeException(e); + } -%> - - - Add new LAMS - - -Add new LAMS - - - - - -
+ // Get the Login Request URL for authoring LAMS Lessons + String authorUrl = LamsSecurityUtil.generateRequestURL(ctx, "author"); - - "> - "> - - - - - -
- - - -
-
-
- - - - - - - -
-
- -
+ // Get the list of Learning Designs + String learningDesigns = LamsSecurityUtil.getLearningDesigns(ctx, 2); + // Error checking + if (learningDesigns.equals("error")) { + response.sendRedirect("lamsServerDown.jsp"); + return; + } +%> + <%-- Breadcrumbs --%> + + + - + - document.getElementById("nextButton").style.visibility = "visible"; - - - //document.getElementById("nextButton").class = "button"; - document.getElementById("sequence_id").value=id; - } -//--> - + + + + +
\ No newline at end of file Index: lams_bb_integration/web/modules/js/seqList.jsp =================================================================== diff -u -ra225f60e82f4197c7a2bf6dbb7200709d1e852d7 -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/web/modules/js/seqList.jsp (.../seqList.jsp) (revision a225f60e82f4197c7a2bf6dbb7200709d1e852d7) +++ lams_bb_integration/web/modules/js/seqList.jsp (.../seqList.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -4,9 +4,8 @@ <%@ page import="org.lamsfoundation.ld.integration.blackboard.LamsServiceUtil"%> <%@ page import="lamsws.SimpleLearningDesignVO"%> <%@ page errorPage="/error.jsp"%> -<%@ taglib uri="/bbData" prefix="bbData"%> -<%@ taglib uri="/bbUI" prefix="bbUI"%> - +<%@ taglib uri="/bbNG" prefix="bbNG"%> + <% /*** * this JSP page simply generate a list of all Learning Design from the LearningDesign web service @@ -50,4 +49,5 @@ //close designs XML tag %><% %> - \ No newline at end of file + +
\ No newline at end of file Index: lams_bb_integration/web/modules/lamsServerDown.jsp =================================================================== diff -u -r8ea6dac2e1f9e39a41030dd5907592bc2aa04d17 -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/web/modules/lamsServerDown.jsp (.../lamsServerDown.jsp) (revision 8ea6dac2e1f9e39a41030dd5907592bc2aa04d17) +++ lams_bb_integration/web/modules/lamsServerDown.jsp (.../lamsServerDown.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -1,10 +1,19 @@ -<%@ taglib uri="/bbUI" prefix="bbUI"%> +<%-- + Original Version: 2007 LAMS Foundation + Updated for Blackboard 9.1 SP6 (including new bbNG tag library) 2011 + Richard Stals (www.stals.com.au) + Edith Cowan University, Western Australia +--%> +<%-- + Error Page for LAMS Integration Errors (Communication timeouts etc.) +--%> <%@ page import="java.io.PrintWriter"%> <%@ page isErrorPage = "true" %> - - - - -

Did not get a response from the LAMS server. Please contact your systems administrator.

- -

\ No newline at end of file +<%@ taglib uri="/bbNG" prefix="bbNG"%> + + +

Did not get a response from the LAMS server. Please contact your systems administrator.

+
+
\ No newline at end of file Index: lams_bb_integration/web/modules/learnermonitor.jsp =================================================================== diff -u -ra930db13eb2e9bd50802f65516c169da454e9030 -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/web/modules/learnermonitor.jsp (.../learnermonitor.jsp) (revision a930db13eb2e9bd50802f65516c169da454e9030) +++ lams_bb_integration/web/modules/learnermonitor.jsp (.../learnermonitor.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -1,196 +1,168 @@ -<%@ page import="java.util.*, - java.util.Date, - java.text.SimpleDateFormat, - blackboard.data.*, - blackboard.persist.*, - blackboard.data.course.*, - blackboard.data.user.*, - blackboard.persist.course.*, - blackboard.data.content.*, - blackboard.persist.content.*, - blackboard.persist.navigation.CourseTocDbLoader, - blackboard.db.*, - blackboard.base.*, - org.lamsfoundation.ld.integration.blackboard.LamsSecurityUtil, - blackboard.platform.*, - blackboard.platform.plugin.*" - errorPage="/error.jsp" -%> -<%@ taglib uri="/bbUI" prefix="bbUI"%> -<%@ taglib uri="/bbData" prefix="bbData"%> - +<%-- + Original Version: 2007 LAMS Foundation + Updated for Blackboard 9.1 SP6 (including new bbNG tag library) 2011 + Richard Stals (www.stals.com.au) + Edith Cowan University, Western Australia +--%> +<%-- + Handle LAMS Lesson Access + Students - access lesson only + Staff - additionally access the Lesson Monitor +--%> +<%@ page import="java.util.*"%> +<%@ page import="java.util.Date"%> +<%@ page import="java.text.SimpleDateFormat"%> +<%@ page import="blackboard.data.*"%> +<%@ page import="blackboard.persist.*"%> +<%@ page import="blackboard.data.course.*"%> +<%@ page import="blackboard.data.user.*"%> +<%@ page import="blackboard.persist.course.*"%> +<%@ page import="blackboard.data.content.*"%> +<%@ page import="blackboard.persist.content.*"%> +<%@ page import="blackboard.persist.navigation.CourseTocDbLoader"%> +<%@ page import="blackboard.db.*"%> +<%@ page import="blackboard.base.*"%> +<%@ page import="blackboard.platform.*"%> +<%@ page import="blackboard.platform.plugin.*"%> +<%@ page import="org.lamsfoundation.ld.integration.blackboard.LamsSecurityUtil"%> +<%@ page errorPage="/error.jsp"%> +<%@ taglib uri="/bbNG" prefix="bbNG"%> + <% - String lsid = request.getParameter("lsid"); - String learnerUrl = LamsSecurityUtil.generateRequestURL(ctx, "learner") + "&lsid=" + lsid; - String monitorUrl = LamsSecurityUtil.generateRequestURL(ctx, "monitor") + "&lsid=" + lsid; - String liveEditUrl = LamsSecurityUtil.generateRequestURL(ctx, "author"); + // SECURITY! + // Authorise current user for Course Access (automatic redirect) + try{ + if (!PlugInUtil.authorizeForCourse(request, response)) + return; + } catch(PlugInException e) { + throw new RuntimeException(e); + } + + // Get the LAMS access URLs + String lsid = request.getParameter("lsid"); + String learnerUrl = LamsSecurityUtil.generateRequestURL(ctx, "learner") + "&lsid=" + lsid; + String monitorUrl = LamsSecurityUtil.generateRequestURL(ctx, "monitor") + "&lsid=" + lsid; + String liveEditUrl = LamsSecurityUtil.generateRequestURL(ctx, "author"); -// add port to the url if the port is in the blackboard url. - int bbport = request.getServerPort(); - String bbportstr = bbport != 0 ? ":" + bbport : ""; - - //String contentUrl = LamsSecurityUtil.generateRequestURL(ctx, "learner") + "&lsid=" + learningSessionId; - String updateGradesUrl = "\"" + request.getScheme() - + "://" + - request.getServerName() + - bbportstr + - request.getContextPath() + - "/modules/updateGrades.jsp?lsid=" + lsid + - "&course_id=" + request.getParameter("course_id") + - "&lineitem_id=" + request.getParameter("lineitem_id") - + "\""; - + // Get Course ID and Session User ID + BbPersistenceManager bbPm = BbServiceManager.getPersistenceService().getDbPersistenceManager(); + String course_idstr = request.getParameter("course_id"); + Id course_id = bbPm.generateId(Course.DATA_TYPE, course_idstr); + User sessionUser = ctx.getUser(); + Id sessionUserId = sessionUser.getId(); - String course_idstr = request.getParameter("course_id"); + // Get the membership data to determine the User's Role + CourseMembership courseMembership = null; + CourseMembership.Role courseRole = null; + boolean isActive = false; + + CourseMembershipDbLoader sessionCourseMembershipLoader = (CourseMembershipDbLoader) bbPm.getLoader(CourseMembershipDbLoader.TYPE); + try { + courseMembership = sessionCourseMembershipLoader.loadByCourseAndUserId(course_id, sessionUserId); + courseRole = courseMembership.getRole(); + isActive = courseMembership.getIsAvailable(); + } catch (KeyNotFoundException e) { + // There is no membership record. + e.printStackTrace(); + } catch (PersistenceException pe) { + // There is no membership record. + pe.printStackTrace(); + } - BbPersistenceManager bbPm = BbServiceManager.getPersistenceService().getDbPersistenceManager(); - Id course_id = bbPm.generateId(Course.COURSE_DATA_TYPE, course_idstr); - User sessionUser = ctx.getUser(); - Id sessionUserId = sessionUser.getId(); - - - //get the membership data to determine the User's Role - CourseMembership courseMembership = null; - CourseMembership.Role courseRole = null; - CourseMembershipDbLoader sessionCourseMembershipLoader = - (CourseMembershipDbLoader) bbPm.getLoader(CourseMembershipDbLoader.TYPE); - try - { - courseMembership = sessionCourseMembershipLoader.loadByCourseAndUserId(course_id, sessionUserId); - courseRole = courseMembership.getRole(); - } - catch (KeyNotFoundException e) - { - // There is no membership record. - e.printStackTrace(); - - } - catch (PersistenceException pe) - { - // There is no membership record. - pe.printStackTrace(); - } - - - 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 - instructorstr="button"; - } - else if (!courseRole.equals(CourseMembership.Role.STUDENT)) - { - - response.sendRedirect("notAllowed.jsp"); - } + // Is the User an Instructor of Teaching Assistant + boolean instructorstr=false; + if (courseRole.equals(CourseMembership.Role.INSTRUCTOR)||courseRole.equals(CourseMembership.Role.TEACHING_ASSISTANT)) { + instructorstr=true; + } else if (!courseRole.equals(CourseMembership.Role.STUDENT)) { + // The user is not an Instructor, Teaching Assistant or Student - Access Denied + response.sendRedirect("notAllowed.jsp"); + } + + // Are they active in the course? If not let Blackboard handle the redirect + if (!isActive) { + PlugInUtil.sendAccessDeniedRedirect(request, response); + } %> - - - - - + <%-- Breadcrumbs --%> + + + + <%-- Page Header --%> + + + + <%-- Action Control Bar --%> + + <%-- Access the Lesson as a Learner --%> + <% if(instructorstr) { %> + <%-- Access the Monitor --%> + <% } %> + <%-- Cancel (Go Back) --%> + - - - LAMS Options - - -LAMS Options - - -
-
- Please Choose an Option -

-      - - - - - -
- -
-
+ + + + + \ No newline at end of file Index: lams_bb_integration/web/modules/modify.jsp =================================================================== diff -u -r8ea6dac2e1f9e39a41030dd5907592bc2aa04d17 -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/web/modules/modify.jsp (.../modify.jsp) (revision 8ea6dac2e1f9e39a41030dd5907592bc2aa04d17) +++ lams_bb_integration/web/modules/modify.jsp (.../modify.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -1,120 +1,158 @@ -<%@ page import="java.util.*, - java.util.Date, - java.text.SimpleDateFormat, - blackboard.data.*, - blackboard.persist.*, - blackboard.data.course.*, - blackboard.data.user.*, - blackboard.persist.course.*, - blackboard.data.content.*, - blackboard.persist.content.*, - blackboard.db.*, - blackboard.base.*, - blackboard.platform.*, - blackboard.platform.plugin.*" - errorPage="/error.jsp" -%> -<%@ taglib uri="/bbUI" prefix="bbUI"%> -<%@ taglib uri="/bbData" prefix="bbData"%> - +<%-- + Original Version: 2007 LAMS Foundation + Updated for Blackboard 9.1 SP6 (including new bbNG tag library) 2011 + Richard Stals (www.stals.com.au) + Edith Cowan University, Western Australia +--%> +<%-- + Step 1 For Modifing an existing LAMS Lesson + Set the various attributes for the LAMS lesson in Blackboard + Step 1 - modify.jsp + Step 2 - modify_proc.jsp +--%> +<%@ page import="java.util.*"%> +<%@ page import="java.util.Date"%> +<%@ page import="java.util.Calendar"%> +<%@ page import="java.text.SimpleDateFormat"%> +<%@ page import="blackboard.data.*"%> +<%@ page import="blackboard.persist.*"%> +<%@ page import="blackboard.data.course.*"%> +<%@ page import="blackboard.data.user.*"%> +<%@ page import="blackboard.persist.course.*"%> +<%@ page import="blackboard.data.content.*"%> +<%@ page import="blackboard.persist.content.*"%> +<%@ page import="blackboard.db.*"%> +<%@ page import="blackboard.base.*"%> +<%@ page import="blackboard.platform.*"%> +<%@ page import="blackboard.platform.plugin.*"%> +<%@ page errorPage="/error.jsp"%> +<%@ taglib uri="/bbNG" prefix="bbNG"%> + + <% String NOT_AVAILABLE = "Item is not available.
"; - //check permission - if (!PlugInUtil.authorizeForCourseControlPanel(request, response)) - return; + // SECURITY! + // Authorise current user for Course Control Panel (automatic redirect) + try{ + if (!PlugInUtil.authorizeForCourseControlPanel(request, response)) + return; + } catch(PlugInException e) { + throw new RuntimeException(e); + } - BbPersistenceManager bbPm = BbServiceManager.getPersistenceService().getDbPersistenceManager(); + // Retrieve the Db persistence manager from the persistence service + BbPersistenceManager bbPm = BbServiceManager.getPersistenceService().getDbPersistenceManager(); + + // Get the content ID for this item Container bbContainer = bbPm.getContainer(); + Id contentId = new PkId( bbContainer, CourseDocument.DATA_TYPE, request.getParameter("content_id") ); - Id contentId = new PkId( bbContainer, CourseDocument.COURSE_DOCUMENT_DATA_TYPE, request.getParameter("content_id") ); - + // Load the Course Document (Lams Lesson) ContentDbLoader courseDocumentLoader = (ContentDbLoader) bbPm.getLoader( ContentDbLoader.TYPE ); Content courseDoc = (Content)courseDocumentLoader.loadById( contentId ); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date startDate = null; - Date endDate = null; - - if(courseDoc.getStartDate() != null) - startDate = courseDoc.getStartDate().getTime(); - if(courseDoc.getEndDate() != null) - endDate = courseDoc.getStartDate().getTime(); - + // Get the Item Attributes + Calendar startDate = courseDoc.getStartDate(); + Calendar endDate = courseDoc.getEndDate(); FormattedText desc = courseDoc.getBody(); String description = desc.getText().replaceFirst(NOT_AVAILABLE, ""); //remove the NOT_AVAILABLE substring %> - - - - - Modify HTML Block - -Modify LAMS -
- "> - "> + <%-- Breadcrumbs --%> + + + + + <%-- Page Header --%> + + + + + <%-- Form for the LAMS Lesson Attributes --%> + + "> + "> + - - - - - - - - - + + + + + - - - >Yes - >No - - - >Yes - >No - - - - - - -
- - - - -
- -
+ + + + + + + + + + >Yes + >No + + + + >Yes + >No + + + + <%-- + Show start and end dates if they have been set + If non ehave been set, leave the tags out so that Blackboard puts the default dates in + --%> + <% if(startDate==null && endDate==null) { %> + + <% } else if(endDate==null) { %> + + <% } else if(startDate==null) { %> + + <% } else { %> + + <% } %> + + + + + - -
-
+ + + + + + Index: lams_bb_integration/web/modules/modify_proc.jsp =================================================================== diff -u -rd77a5e0e31a43d80a8f8418e6525de0500624fed -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/web/modules/modify_proc.jsp (.../modify_proc.jsp) (revision d77a5e0e31a43d80a8f8418e6525de0500624fed) +++ lams_bb_integration/web/modules/modify_proc.jsp (.../modify_proc.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -1,85 +1,130 @@ -<%@ page import="java.util.*, - java.text.*, - java.io.*, - blackboard.data.*, - blackboard.persist.*, - blackboard.data.course.*, - blackboard.data.user.*, - blackboard.persist.course.*, - blackboard.data.content.*, - blackboard.persist.content.*, - blackboard.base.*, - blackboard.platform.*, - blackboard.platform.persistence.*, - blackboard.platform.plugin.*" - errorPage="/error.jsp" -%> -<%@ taglib uri="/bbUI" prefix="bbUI"%> -<%@ taglib uri="/bbData" prefix="bbData"%> - +<%-- + Original Version: 2007 LAMS Foundation + Updated for Blackboard 9.1 SP6 (including new bbNG tag library) 2011 + Richard Stals (www.stals.com.au) + Edith Cowan University, Western Australia +--%> +<%-- + Step 2 For Modifing an existing LAMS Lesson + Process the data and persist to Blackboard + + Step 1 - modify.jsp + Step 2 - modify_proc.jsp +--%> +<%@ page import="java.util.*"%> +<%@ page import="java.text.*"%> +<%@ page import="java.io.*"%> +<%@ page import="blackboard.data.*"%> +<%@ page import="blackboard.persist.*"%> +<%@ page import="blackboard.data.course.*"%> +<%@ page import="blackboard.data.user.*"%> +<%@ page import="blackboard.persist.course.*"%> +<%@ page import="blackboard.data.content.*"%> +<%@ page import="blackboard.persist.content.*"%> +<%@ page import="blackboard.base.*"%> +<%@ page import="blackboard.platform.*"%> +<%@ page import="blackboard.platform.persistence.*"%> +<%@ page import="blackboard.platform.plugin.*"%> +<%@ page errorPage="/error.jsp"%> +<%@ taglib uri="/bbNG" prefix="bbNG"%> + -<% - //check permission - - if (!PlugInUtil.authorizeForCourseControlPanel(request, response)) - return; + <% + // SECURITY! + // Authorise current user for Course Control Panel (automatic redirect) + try{ + if (!PlugInUtil.authorizeForCourseControlPanel(request, response)) + return; + } catch(PlugInException e) { + throw new RuntimeException(e); + } - BbPersistenceManager bbPm = BbServiceManager.getPersistenceService().getDbPersistenceManager(); - Container bbContainer = bbPm.getContainer(); + // Retrieve the Db persistence manager from the persistence service + BbPersistenceManager bbPm = BbServiceManager.getPersistenceService().getDbPersistenceManager(); + Container bbContainer = bbPm.getContainer(); - Id contentId = new PkId( bbContainer, CourseDocument.COURSE_DOCUMENT_DATA_TYPE, request.getParameter("content_id") ); + // Internal Blackboard IDs for the course and parent content item + Id courseId = bbPm.generateId(Course.DATA_TYPE,request.getParameter("course_id")); + Id contentId = new PkId( bbContainer, CourseDocument.DATA_TYPE, request.getParameter("content_id") ); - ContentDbLoader courseDocumentLoader = (ContentDbLoader) bbPm.getLoader( ContentDbLoader.TYPE ); - Content myContent = (Content)courseDocumentLoader.loadById( contentId ); - - //set LAMS content data - myContent.setTitle(request.getParameter("title")); - myContent.setIsAvailable(request.getParameter("isAvailable").equals("true")?true:false); - myContent.setIsTracked(request.getParameter("isTracked").equals("true")?true:false); - - FormattedText description = new FormattedText(request.getParameter("description"),FormattedText.Type.HTML); - myContent.setBody(description); + // Load the content item + ContentDbLoader courseDocumentLoader = (ContentDbLoader) bbPm.getLoader( ContentDbLoader.TYPE ); + Content modifiedLesson = (Content)courseDocumentLoader.loadById( contentId ); - //Parse start/end Date from the - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Calendar cstart = Calendar.getInstance(); - Calendar cend = Calendar.getInstance(); - cstart.setTime(formatter.parse(request.getParameter("startDate"))); - cend.setTime(formatter.parse(request.getParameter("endDate"))); - + // Get the form parameters and convert into correct data types + // TODO: Use bb text area instead + String strTitle = request.getParameter("title").trim(); + String strDescription = request.getParameter("description").trim(); + FormattedText description = new FormattedText(strDescription, FormattedText.Type.HTML); + + String strIsAvailable = request.getParameter("isAvailable"); + String strIsTracked = request.getParameter("isTracked"); + boolean isAvailable = strIsAvailable.equals("true")?true:false; + boolean isTracked = strIsTracked.equals("true")?true:false; + + String strStartDate = request.getParameter("lessonAvailability_start_datetime"); + String strEndDate = request.getParameter("lessonAvailability_end_datetime"); + 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 LAMS content data in Blackboard + modifiedLesson.setTitle(strTitle); + modifiedLesson.setIsAvailable(isAvailable); + modifiedLesson.setIsTracked(isTracked); + modifiedLesson.setBody(description); - // Set Availability Dates - myContent.setStartDate(cstart); - if (request.getParameter("restrict_end") != null){ - if (request.getParameter("restrict_end").equals("1")){ - myContent.setEndDate(cend); + // Set Availability Dates + // Clear the date (set to null) if the checkbox is unchecked + // Start Date + if (strStartDateCheckbox != null){ + if (strStartDateCheckbox.equals("1")){ + modifiedLesson.setStartDate(startDate); + } else { + modifiedLesson.setStartDate(null); + } + } else { + modifiedLesson.setStartDate(null); } - } + // End Date + if (strEndDateCheckbox != null){ + if (strEndDateCheckbox.equals("1")){ + modifiedLesson.setEndDate(endDate); + } else { + modifiedLesson.setEndDate(null); + } + } else { + modifiedLesson.setEndDate(null); + } + + //Persist the Modified Lesson Object in Blackboard + ContentDbPersister persister= (ContentDbPersister) bbPm.getPersister( ContentDbPersister.TYPE ); + persister.persist( modifiedLesson ); - ContentDbPersister persister= (ContentDbPersister) bbPm.getPersister( ContentDbPersister.TYPE ); - persister.persist( myContent ); + String strReturnUrl = PlugInUtil.getEditableContentReturnURL(modifiedLesson.getParentId(), courseId); + %> + + <%-- Breadcrumbs --%> + + + - String strReturnUrl = PlugInUtil.getEditableContentReturnURL(myContent.getParentId()); - - + <%-- Page Header --%> + + + -%> + <%-- Receipt --%> + + Content successfully modified. + - - - - - - Modify LAMS - - - Content successfully modified.
-
-
-
-
+ \ No newline at end of file Index: lams_bb_integration/web/modules/notAllowed.jsp =================================================================== diff -u -rd77a5e0e31a43d80a8f8418e6525de0500624fed -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/web/modules/notAllowed.jsp (.../notAllowed.jsp) (revision d77a5e0e31a43d80a8f8418e6525de0500624fed) +++ lams_bb_integration/web/modules/notAllowed.jsp (.../notAllowed.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -1,10 +1,19 @@ -<%@ taglib uri="/bbUI" prefix="bbUI"%> +<%-- + Original Version: 2007 LAMS Foundation + Updated for Blackboard 9.1 SP6 (including new bbNG tag library) 2011 + Richard Stals (www.stals.com.au) + Edith Cowan University, Western Australia +--%> +<%-- + Error Page for access denied errors +--%> <%@ page import="java.io.PrintWriter"%> <%@ page isErrorPage = "true" %> - - - - -

Your current user privileges do not allow you to access this content.

- -

\ No newline at end of file +<%@ taglib uri="/bbNG" prefix="bbNG"%> + + +

Your current user privileges do not allow you to access this content.

+
+
\ No newline at end of file Index: lams_bb_integration/web/modules/start_lesson.jsp =================================================================== diff -u -r0c7a8cba1ded8f132d5d5d1cc816023179ede9ca -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/web/modules/start_lesson.jsp (.../start_lesson.jsp) (revision 0c7a8cba1ded8f132d5d5d1cc816023179ede9ca) +++ lams_bb_integration/web/modules/start_lesson.jsp (.../start_lesson.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -1,3 +1,17 @@ +<%-- + Original Version: 2007 LAMS Foundation + Updated for Blackboard 9.1 SP6 (including new bbNG tag library) 2011 + Richard Stals (www.stals.com.au) + Edith Cowan University, Western Australia +--%> +<%-- + Step 2 For Creating a New LAMS Lesson + Set the various attributes for the LAMS lesson in Blackboard + + Step 1 - create.jsp + Step 2 - start_lesson.jsp + Step 3 - start_lesson_proc.jsp +--%> <%@ page import="java.util.Calendar"%> <%@ page import="java.text.SimpleDateFormat"%> <%@ page import="blackboard.base.FormattedText"%> @@ -13,91 +27,100 @@ <%@ page import="blackboard.platform.session.BbSession"%> <%@ page import="blackboard.platform.*"%> <%@ page import="blackboard.platform.plugin.PlugInUtil"%> +<%@ page import="blackboard.platform.plugin.PlugInException"%> <%@ page import="org.lamsfoundation.ld.integration.blackboard.LamsPluginUtil"%> -<%@ page import="org.lamsfoundation.ld.integration.Constants"%> - -<%@ page errorPage="/error.jsp"%><%@ page import="org.lamsfoundation.ld.integration.Constants" %> - -<%@ taglib uri="/bbUI" prefix="bbUI"%> -<%@ taglib uri="/bbData" prefix="bbData"%> - +<%@ page import="org.lamsfoundation.ld.integration.Constants"%> +<%@ page errorPage="/error.jsp"%> +<%@ taglib uri="/bbNG" prefix="bbNG"%> <% - String sequenceID = request.getParameter("sequence_id"); + // SECURITY! + // Authorise current user for Course Control Panel (automatic redirect) + try{ + if (!PlugInUtil.authorizeForCourseControlPanel(request, response)) + return; + } catch(PlugInException e) { + throw new RuntimeException(e); + } + + // Get the sequence ID from the form request parameter + String sequenceID = request.getParameter("sequence_id"); %> - - - - - - - - Start LAMS Lesson - + - Start LAMS Lesson - -
- - "> + <%-- Breadcrumbs --%> + + + + + <%-- Page Header --%> + + + + + <%-- Form to Collect LAMS Lesson Attributes --%> + + + "> "> + - - - - - - - - - - - - - Yes - No - - - Yes - No - - - - - - -
- - - - -
- + + + + + + + + + + + + + Yes + No + + + Yes + No + + + + + + + + +
+ - -
-
\ No newline at end of file + //--> + + + + \ No newline at end of file Index: lams_bb_integration/web/modules/start_lesson_proc.jsp =================================================================== diff -u -ra930db13eb2e9bd50802f65516c169da454e9030 -re90547eeb5330fd68c424212233b1689f25c71ce --- lams_bb_integration/web/modules/start_lesson_proc.jsp (.../start_lesson_proc.jsp) (revision a930db13eb2e9bd50802f65516c169da454e9030) +++ lams_bb_integration/web/modules/start_lesson_proc.jsp (.../start_lesson_proc.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce) @@ -1,3 +1,17 @@ +<%-- + Original Version: 2007 LAMS Foundation + Updated for Blackboard 9.1 SP6 (including new bbNG tag library) 2011 + Richard Stals (www.stals.com.au) + Edith Cowan University, Western Australia +--%> +<%-- + Step 3 For Creating a New LAMS Lesson + Process the Lesson Information and add it to the Blackboard site + + Step 1 - create.jsp + Step 2 - start_lesson.jsp + Step 3 - start_lesson_proc.jsp +--%> <%@ page import="java.util.Calendar"%> <%@ page import="java.text.SimpleDateFormat"%> <%@ page import="blackboard.base.FormattedText"%> @@ -14,162 +28,156 @@ <%@ page import="blackboard.platform.session.BbSession"%> <%@ page import="blackboard.platform.*"%> <%@ page import="blackboard.platform.plugin.PlugInUtil"%> +<%@ page import="blackboard.platform.plugin.PlugInException"%> <%@ page import="blackboard.data.gradebook.Lineitem" %> <%@ page import="blackboard.persist.gradebook.LineitemDbPersister" %> <%@ page import="org.lamsfoundation.ld.integration.blackboard.LamsSecurityUtil"%> <%@ page import="org.lamsfoundation.ld.integration.blackboard.LamsPluginUtil"%> - -<%@ page errorPage="/error.jsp"%><%@ page import="org.lamsfoundation.ld.integration.Constants" %> +<%@ page import="org.lamsfoundation.ld.integration.Constants" %> +<%@ page errorPage="/error.jsp"%> +<%@ taglib uri="/bbNG" prefix="bbNG"%> -<%@ taglib uri="/bbUI" prefix="bbUI"%> -<%@ taglib uri="/bbData" prefix="bbData"%> + - - + <%-- Set the new LAMS Lesson Content Object --%> + + + + - - - - - - <% - String title = request.getParameter("title").trim(); - String description = request.getParameter("description").trim(); - - // TODO: Use bb text area instead - //String p_descText = request.getParameter("descriptiontext"); - //String p_descType = request.getParameter("descriptiontype"); - long ldId = Long.parseLong(request.getParameter("sequence_id").trim()); - //TODO: Get and validate dates and options - - //public static Long scheduleLesson(Context ctx, long ldId, String title, String desc, String startDate) //public static Long startLesson(Context ctx, long ldId, String title, String desc) - - // retrieve the Db persistence manager from the persistence service - BbPersistenceManager bbPm = BbServiceManager.getPersistenceService().getDbPersistenceManager(); - ContentDbPersister contentPersister = (ContentDbPersister) bbPm.getPersister( ContentDbPersister.TYPE ); + <% + // SECURITY! + // Authorise current user for Course Control Panel (automatic redirect) + try{ + if (!PlugInUtil.authorizeForCourseControlPanel(request, response)) + return; + } catch(PlugInException e) { + throw new RuntimeException(e); + } + + + // Retrieve the Db persistence manager from the persistence service + BbPersistenceManager bbPm = BbServiceManager.getPersistenceService().getDbPersistenceManager(); + ContentDbPersister contentPersister = (ContentDbPersister) bbPm.getPersister( ContentDbPersister.TYPE ); - // internal IDs for the course and parent content item - Id courseId = bbPm.generateId(Course.DATA_TYPE,request.getParameter("course_id")); - Id folderId = bbPm.generateId(CourseDocument.DATA_TYPE,request.getParameter("content_id")); + // Internal Blackboard IDs for the course and parent content item + Id courseId = bbPm.generateId(Course.DATA_TYPE,request.getParameter("course_id")); + Id folderId = bbPm.generateId(CourseDocument.DATA_TYPE,request.getParameter("content_id")); - // load parent content item - ContentDbLoader courseDocumentLoader = (ContentDbLoader) bbPm.getLoader( ContentDbLoader.TYPE ); - ContentFolder courseDocParent = (ContentFolder)courseDocumentLoader.loadById( folderId ); + // Load parent content item + ContentDbLoader courseDocumentLoader = (ContentDbLoader) bbPm.getLoader( ContentDbLoader.TYPE ); + ContentFolder courseDocParent = (ContentFolder)courseDocumentLoader.loadById( folderId ); - // get the session object to obtain the user and course object - BbSessionManagerService sessionService = BbServiceManager.getSessionManagerService(); - BbSession bbSession = sessionService.getSession( request ); + // Get the session object to obtain the user and course object + BbSessionManagerService sessionService = BbServiceManager.getSessionManagerService(); + BbSession bbSession = sessionService.getSession( request ); + + // Get the form parameters and convert into correct data types + // TODO: Use bb text area instead + String strTitle = request.getParameter("title").trim(); + String strDescription = request.getParameter("description").trim(); + FormattedText description = new FormattedText(strDescription, FormattedText.Type.HTML); + + String strSequenceID = request.getParameter("sequence_id").trim(); + long ldId = Long.parseLong(strSequenceID); + + String strIsAvailable = request.getParameter("isAvailable"); + String strIsTracked = request.getParameter("isTracked"); + boolean isAvailable = strIsAvailable.equals("true")?true:false; + boolean isTracked = strIsTracked.equals("true")?true:false; + + String strStartDate = request.getParameter("lessonAvailability_start_datetime"); + String strEndDate = request.getParameter("lessonAvailability_end_datetime"); + 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 LAMS content data - myContent.setTitle(title); - myContent.setIsAvailable(request.getParameter("isAvailable").equals("true")?true:false); - myContent.setIsTracked(request.getParameter("isTracked").equals("true")?true:false); + // Set the New LAMS Lesson content data (in Blackboard) + newLesson.setTitle(strTitle); + newLesson.setIsAvailable(isAvailable); + newLesson.setIsTracked(isTracked); - FormattedText fdescription = new FormattedText(description, FormattedText.Type.HTML); - - // set core course data - myContent.setContentHandler( LamsPluginUtil.CONTENT_HANDLE ); - myContent.setCourseId( courseId ); - myContent.setParentId( folderId ); + newLesson.setContentHandler(LamsPluginUtil.CONTENT_HANDLE); + newLesson.setCourseId(courseId); + newLesson.setParentId(folderId); - // set LAMS content data - myContent.setRenderType(Content.RenderType.URL); - //myContent.setRenderType(Content.RenderType.LINK); - myContent.setBody(fdescription); - String learningSessionId = null; - - // tell lams to create the learning session using webservices - try{ - long lsId = LamsSecurityUtil.startLesson(ctx, ldId, title, description); - - //error checking - if (lsId == -1) - { - response.sendRedirect("lamsServerDown.jsp"); - System.exit(1); - } + newLesson.setRenderType(Content.RenderType.URL); + newLesson.setBody(description); + + + // Start the Lesson in LAMS (via Webservices) + // Capture the session ID + String learningSessionId = null; + try{ + long lsId = LamsSecurityUtil.startLesson(ctx, ldId, strTitle, strDescription); + //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); - } - - - // Creating the gradebook row for this lesson - Id lineitemId = bbPm.generateId(Lineitem.LINEITEM_DATA_TYPE,learningSessionId); - - Lineitem lineitem = new Lineitem(); - lineitem.setCourseId(courseId); - lineitem.setName("LAMS Lesson: " + title); - lineitem.setId(lineitemId); - lineitem.setAssessmentId(learningSessionId,Lineitem.AssessmentLocation.EXTERNAL); - lineitem.setAssessmentLocation( Lineitem.AssessmentLocation.EXTERNAL ); - lineitem.setDateAdded(); - lineitem.setIsAvailable(true); - lineitem.setType("LAMS"); - lineitem.setColumnOrder(3000); - lineitem.validate(); - lineitem.setPointsPossible(1); - - - - // add port to the url if the port is in the blackboard url. - int bbport = request.getServerPort(); - String bbportstr = bbport != 0 ? ":" + bbport : ""; - - //String contentUrl = LamsSecurityUtil.generateRequestURL(ctx, "learner") + "&lsid=" + learningSessionId; - String contentUrl = request.getScheme() - + "://" + - request.getServerName() + - bbportstr + - request.getContextPath() + - "/modules/learnermonitor.jsp?lsid=" + learningSessionId + - "&course_id=" + request.getParameter("course_id") + - "&lineitem_id=" + lineitemId.getExternalString(); - myContent.setUrl(contentUrl); + learningSessionId = Long.toString(lsId); + } catch (Exception e){ + throw new ServletException(e.getMessage(), e); + } - //Parse start/end Date from the - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Calendar cstart = Calendar.getInstance(); - Calendar cend = Calendar.getInstance(); - cstart.setTime(formatter.parse(request.getParameter("startDate"))); - cend.setTime(formatter.parse(request.getParameter("endDate"))); + // Add port to the url if the port is in the blackboard url. + int bbport = request.getServerPort(); + String bbportstr = bbport != 0 ? ":" + bbport : ""; + + //Build and set the content URL + String contentUrl = request.getScheme() + + "://" + + request.getServerName() + + bbportstr + + request.getContextPath() + + "/modules/learnermonitor.jsp?lsid=" + learningSessionId + + "&course_id=" + request.getParameter("course_id"); + + newLesson.setUrl(contentUrl); - // Set Availability Dates - myContent.setStartDate(cstart); - if (request.getParameter("restrict_end") != null){ - if (request.getParameter("restrict_end").equals("1")){ - myContent.setEndDate(cend); - } - } + // Set Availability Dates + // Start Date + if (strStartDateCheckbox != null){ + if (strStartDateCheckbox.equals("1")){ + newLesson.setStartDate(startDate); + } + } + // End Date + if (strEndDateCheckbox != null){ + if (strEndDateCheckbox.equals("1")){ + newLesson.setEndDate(endDate); + } + } + + //Persist the New Lesson Object in Blackboard + ContentDbPersister persister= (ContentDbPersister) bbPm.getPersister( ContentDbPersister.TYPE ); + persister.persist( newLesson ); - - - - //LineitemDbLoader liLoader = (LineitemDbLoader) bbPm.getLoader(LineitemDbLoader.TYPE); - LineitemDbPersister lineItempersist = (LineitemDbPersister) bbPm.getPersister(LineitemDbPersister.TYPE); - lineItempersist.persist(lineitem); - - - ContentDbPersister persister= (ContentDbPersister) bbPm.getPersister( ContentDbPersister.TYPE ); - persister.persist( myContent ); - - String strReturnUrl = PlugInUtil.getEditableContentReturnURL(myContent.getParentId()); + String strReturnUrl = PlugInUtil.getEditableContentReturnURL(newLesson.getParentId(), courseId); %> - - - - - LAMS - - - Content successfully added.
-
-
- - -
-
-
\ No newline at end of file + + <%-- Breadcrumbs --%> + + + + + <%-- Page Header --%> + + + + + <%-- Receipt --%> + + Content successfully added. + + +
\ No newline at end of file