Index: lams_bb_integration/WEB-INF/bb-manifest.xml =================================================================== diff -u -r615a2ef7e23ebd72fd36a62324e12a82fe2e1ac1 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/WEB-INF/bb-manifest.xml (.../bb-manifest.xml) (revision 615a2ef7e23ebd72fd36a62324e12a82fe2e1ac1) +++ lams_bb_integration/WEB-INF/bb-manifest.xml (.../bb-manifest.xml) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -7,16 +7,16 @@ - + - - - - + + + + - + @@ -25,8 +25,8 @@ - - + + @@ -43,7 +43,7 @@ - + @@ -52,7 +52,7 @@ - + @@ -61,7 +61,7 @@ - + Index: lams_bb_integration/WEB-INF/web.xml =================================================================== diff -u -r615a2ef7e23ebd72fd36a62324e12a82fe2e1ac1 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/WEB-INF/web.xml (.../web.xml) (revision 615a2ef7e23ebd72fd36a62324e12a82fe2e1ac1) +++ lams_bb_integration/WEB-INF/web.xml (.../web.xml) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -1,6 +1,10 @@ + ConfigServlet + org.lamsfoundation.ld.integration.blackboard.ConfigServlet + + UserDataServlet org.lamsfoundation.ld.integration.blackboard.UserDataServlet @@ -17,18 +21,10 @@ org.lamsfoundation.ld.integration.blackboard.LamsLearningDesignDeleteServlet - CloneLessonsServlet - org.lamsfoundation.ld.integration.blackboard.CloneLessonsServlet + LinkToolsServlet + org.lamsfoundation.ld.integration.blackboard.LinkToolsServlet - ImportLessonsServlet - org.lamsfoundation.ld.integration.blackboard.ImportLessonsServlet - - - CorrectLineitemsServlet - org.lamsfoundation.ld.integration.blackboard.CorrectLineitemsServlet - - GradebookServlet org.lamsfoundation.ld.integration.blackboard.GradebookServlet @@ -41,6 +37,10 @@ org.lamsfoundation.ld.integration.blackboard.LessonManagerServlet + LearnerMonitorServlet + org.lamsfoundation.ld.integration.blackboard.LearnerMonitorServlet + + OpenLamsPageServlet org.lamsfoundation.ld.integration.blackboard.OpenLamsPageServlet @@ -58,6 +58,10 @@ + ConfigServlet + /configPlugin + + LamsLearningDesignServlet /LamsLearningDesign @@ -66,22 +70,14 @@ /LamsLearningDesignDelete + LinkToolsServlet + /LinkTools + + UserDataServlet /UserData - CloneLessonsServlet - /CloneLessons - - - ImportLessonsServlet - /ImportLessons - - - CorrectLineitemsServlet - /CorrectLineitems - - GroupDataServlet /GroupData @@ -98,6 +94,10 @@ /LessonManager + LearnerMonitorServlet + /LearnerMonitor + + OpenLamsPageServlet /openLamsPage Fisheye: Tag a327993967da9b51f138b3e84530a42ad3874abc refers to a dead (removed) revision in file `lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/CloneLessonsServlet.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/ConfigServlet.java =================================================================== diff -u --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/ConfigServlet.java (revision 0) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/ConfigServlet.java (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -0,0 +1,135 @@ +package org.lamsfoundation.ld.integration.blackboard; + +import java.io.IOException; +import java.text.ParseException; +import java.util.Properties; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.xml.parsers.ParserConfigurationException; + +import org.lamsfoundation.ld.integration.util.LamsPluginUtil; +import org.xml.sax.SAXException; + +import blackboard.base.InitializationException; +import blackboard.data.ValidationException; +import blackboard.persist.PersistenceException; +import blackboard.platform.BbServiceException; +import blackboard.platform.plugin.PlugInException; +import blackboard.platform.plugin.PlugInUtil; + +/** + * Handles displaying and modification of the LAMS BB plugin's config settings. + */ +@SuppressWarnings("serial") +public class ConfigServlet extends HttpServlet{ + + public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + process(request, response); + } + + public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + process(request, response); + } + + private void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + // SECURITY! + // Authorise current user for System Admin (automatic redirect) + try { + if (!PlugInUtil.authorizeForSystemAdmin(request, response)) + return; + } catch (PlugInException e) { + throw new RuntimeException(e); + } + + try { + String method = request.getParameter("method"); + if (method.equals("showConfigSettings")) { + showConfigSettings(request, response); + + } else if (method.equals("saveConfigSettings")) { + saveConfigSettings(request, response); + } + + } catch (InitializationException e) { + throw new ServletException(e); + } catch (BbServiceException e) { + throw new ServletException(e); + } catch (PersistenceException e) { + throw new ServletException(e); + } catch (ParseException e) { + throw new ServletException(e); + } catch (ValidationException e) { + throw new ServletException(e); + } catch (ParserConfigurationException e) { + throw new ServletException(e); + } catch (SAXException e) { + throw new ServletException(e); + } + } + + /** + * Show /admin/config.jsp page. + */ + private void showConfigSettings(HttpServletRequest request, HttpServletResponse response) + throws InitializationException, BbServiceException, PersistenceException, IOException, ServletException { + + // Get the LAMS2 Building Block properties from Blackboard (if set) + Properties properties = LamsPluginUtil.getProperties(); + + String lamsServerUrl = properties.getProperty(LamsPluginUtil.PROP_LAMS_URL, "http://"); + request.setAttribute("lamsServerUrl", lamsServerUrl); + + String lamsServerId = properties.getProperty(LamsPluginUtil.PROP_LAMS_SERVER_ID, ""); + request.setAttribute("lamsServerId", lamsServerId); + + String secretKey = properties.getProperty(LamsPluginUtil.PROP_LAMS_SECRET_KEY, ""); + request.setAttribute("secretKey", secretKey); + + String requestSrc = properties.getProperty(LamsPluginUtil.PROP_REQ_SRC); + request.setAttribute("requestSrc", requestSrc); + + String lamsServerTimeRefreshInterval = properties.getProperty(LamsPluginUtil.PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL); + request.setAttribute("lamsServerTimeRefreshInterval", lamsServerTimeRefreshInterval); + + String lamsAltServerUrl = properties.getProperty(LamsPluginUtil.PROP_ALT_LAMS_URL, "https://"); + request.setAttribute("lamsAltServerUrl", lamsAltServerUrl); + + request.getRequestDispatcher("/admin/config.jsp").forward(request, response); + } + + /** + * Saves modified configuration settings. + */ + private void saveConfigSettings(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException, PersistenceException, ParseException, ValidationException, + ParserConfigurationException, SAXException { + + // Get the properties object + Properties properties = LamsPluginUtil.getProperties(); + + // Get the LAMS2 Building Block properties from the request + String lamsServerUrl = request.getParameter("lamsServerUrl"); + String lamsServerId = request.getParameter("lamsServerId"); + String lamsSecretKey = request.getParameter("lamsSecretKey"); + String requestSrc = request.getParameter("requestSrc"); + String lamsServerTimeRefreshInterval = request.getParameter("lamsServerTimeRefreshInterval"); + String lamsAltServerUrl = request.getParameter("lamsAltServerUrl"); + + // Save the properties to Blackboard + properties.setProperty(LamsPluginUtil.PROP_LAMS_URL, lamsServerUrl); + properties.setProperty(LamsPluginUtil.PROP_LAMS_SECRET_KEY, lamsSecretKey); + properties.setProperty(LamsPluginUtil.PROP_LAMS_SERVER_ID, lamsServerId); + properties.setProperty(LamsPluginUtil.PROP_REQ_SRC, requestSrc); + properties.setProperty(LamsPluginUtil.PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL, lamsServerTimeRefreshInterval); + properties.setProperty(LamsPluginUtil.PROP_ALT_LAMS_URL, lamsAltServerUrl); + + // Persist the properties object + LamsPluginUtil.setProperties(properties); + + request.getRequestDispatcher("/admin/configSuccess.jsp").forward(request, response); + } +} Fisheye: Tag a327993967da9b51f138b3e84530a42ad3874abc refers to a dead (removed) revision in file `lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/CorrectLineitemsServlet.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/GradebookSyncServlet.java =================================================================== diff -u -r9bc5aee65cb0c0aa39c83f1897022d9bad910c12 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/GradebookSyncServlet.java (.../GradebookSyncServlet.java) (revision 9bc5aee65cb0c0aa39c83f1897022d9bad910c12) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/GradebookSyncServlet.java (.../GradebookSyncServlet.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -32,7 +32,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; -import java.text.DecimalFormat; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -53,13 +52,16 @@ import org.xml.sax.SAXException; import blackboard.base.BbList; +import blackboard.base.InitializationException; +import blackboard.data.ValidationException; import blackboard.data.course.CourseMembership; import blackboard.data.gradebook.Lineitem; import blackboard.data.gradebook.Score; import blackboard.persist.Id; +import blackboard.persist.PersistenceException; import blackboard.persist.course.CourseMembershipDbLoader; import blackboard.persist.gradebook.ScoreDbLoader; -import blackboard.persist.gradebook.ScoreDbPersister; +import blackboard.platform.BbServiceException; import blackboard.platform.BbServiceManager; import blackboard.platform.context.Context; import blackboard.platform.context.ContextManager; @@ -205,8 +207,14 @@ throw new ServletException(e); } catch (SAXException e) { throw new ServletException(e); - } catch (Exception e) { + } catch (PersistenceException e) { throw new ServletException(e); + } catch (ValidationException e) { + throw new ServletException(e); + } catch (InitializationException e) { + throw new ServletException(e); + } catch (BbServiceException e) { + throw new ServletException(e); } finally { // make sure context is released if (ctxMgr != null) { Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/GroupDataServlet.java =================================================================== diff -u -r90551510089141ff0f625b92c00ab97ba4e98a26 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/GroupDataServlet.java (.../GroupDataServlet.java) (revision 90551510089141ff0f625b92c00ab97ba4e98a26) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/GroupDataServlet.java (.../GroupDataServlet.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -49,7 +49,6 @@ import blackboard.persist.course.CourseDbLoader; import blackboard.persist.course.GroupDbLoader; import blackboard.persist.user.UserDbLoader; -import blackboard.platform.BbServiceManager; import blackboard.platform.persistence.PersistenceServiceFactory; /** Fisheye: Tag a327993967da9b51f138b3e84530a42ad3874abc refers to a dead (removed) revision in file `lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/ImportLessonsServlet.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsLearningDesignDeleteServlet.java =================================================================== diff -u -r90551510089141ff0f625b92c00ab97ba4e98a26 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsLearningDesignDeleteServlet.java (.../LamsLearningDesignDeleteServlet.java) (revision 90551510089141ff0f625b92c00ab97ba4e98a26) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsLearningDesignDeleteServlet.java (.../LamsLearningDesignDeleteServlet.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -29,7 +29,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.lamsfoundation.ld.integration.Constants; import org.lamsfoundation.ld.integration.util.LamsSecurityUtil; import blackboard.base.InitializationException; Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsLearningDesignServlet.java =================================================================== diff -u -r90551510089141ff0f625b92c00ab97ba4e98a26 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsLearningDesignServlet.java (.../LamsLearningDesignServlet.java) (revision 90551510089141ff0f625b92c00ab97ba4e98a26) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsLearningDesignServlet.java (.../LamsLearningDesignServlet.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -64,7 +64,6 @@ // get request parameters String folderId = request.getParameter(Constants.PARAM_FOLDER_ID); - String courseId = request.getParameter("courseId"); //paging parameters of tablesorter - used in the LAMS Template Wizard boolean usePaging = false; @@ -88,6 +87,7 @@ ctxMgr = (ContextManager) BbServiceManager.lookupService(ContextManager.class); ctx = ctxMgr.setContext(request); + String courseId = ctx.getCourse().getCourseId(); String method = usePaging ? "getPagedHomeLearningDesignsJSON" : "getLearningDesignsJSON"; String learningDesigns = LamsSecurityUtil.getLearningDesigns(ctx, username, courseId, folderId, method, type, search, page, size, sortName, sortDate); Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LearnerMonitorServlet.java =================================================================== diff -u --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LearnerMonitorServlet.java (revision 0) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LearnerMonitorServlet.java (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -0,0 +1,160 @@ +package org.lamsfoundation.ld.integration.blackboard; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.lamsfoundation.ld.integration.dto.LearnerProgressDTO; +import org.lamsfoundation.ld.integration.util.LamsSecurityUtil; + +import blackboard.base.InitializationException; +import blackboard.data.content.Content; +import blackboard.data.content.CourseDocument; +import blackboard.data.course.Course; +import blackboard.data.course.CourseMembership; +import blackboard.persist.BbPersistenceManager; +import blackboard.persist.Container; +import blackboard.persist.Id; +import blackboard.persist.KeyNotFoundException; +import blackboard.persist.PersistenceException; +import blackboard.persist.PkId; +import blackboard.persist.content.ContentDbLoader; +import blackboard.persist.course.CourseMembershipDbLoader; +import blackboard.platform.BbServiceException; +import blackboard.platform.BbServiceManager; +import blackboard.platform.context.Context; +import blackboard.platform.context.ContextManager; +import blackboard.platform.persistence.PersistenceServiceFactory; +import blackboard.platform.plugin.PlugInException; +import blackboard.platform.plugin.PlugInUtil; + +/** + * + */ +public class LearnerMonitorServlet extends HttpServlet { + + private static final long serialVersionUID = -351131323404991332L; + private static Logger logger = Logger.getLogger(LearnerMonitorServlet.class); + + public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + + // Authorise current user for Course Access (automatic redirect) + try { + if (!PlugInUtil.authorizeForCourse(request, response)) + return; + } catch (PlugInException e) { + throw new RuntimeException(e); + } + + try { + BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); + CourseMembershipDbLoader sessionCourseMembershipLoader = CourseMembershipDbLoader.Default.getInstance(); + + String strLessonId = request.getParameter("lsid").trim(); + long lessonId = Long.parseLong(strLessonId); + String courseIdParam = request.getParameter("course_id"); + + // Get Course ID and User ID + Id course_id = bbPm.generateId(Course.DATA_TYPE, courseIdParam); + + // get Blackboard context + ContextManager ctxMgr = (ContextManager) BbServiceManager.lookupService(ContextManager.class); + Context ctx = ctxMgr.getContext(); + + Id userId = ctx.getUser().getId(); + + // Get the membership data to determine the User's Role + CourseMembership courseMembership = null; + CourseMembership.Role courseRole = null; + boolean isActive = false; + + try { + courseMembership = sessionCourseMembershipLoader.loadByCourseAndUserId(course_id, userId); + 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(); + } + + // Is the User an Instructor of Teaching Assistant + boolean isInstructor = false; + if (CourseMembership.Role.INSTRUCTOR.equals(courseRole) + || CourseMembership.Role.TEACHING_ASSISTANT.equals(courseRole) + || CourseMembership.Role.COURSE_BUILDER.equals(courseRole)) { + isInstructor = true; + + } else if (!CourseMembership.Role.STUDENT.equals(courseRole)) { + // 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); + } + + //Get lessson's title and description + String title = ""; + String description = ""; + //contentId is available in versions after 1.2.3 + String contentIdParam = request.getParameter("content_id"); + if (contentIdParam != null) { + + Container bbContainer = bbPm.getContainer(); + Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, contentIdParam); + ContentDbLoader courseDocumentLoader = (ContentDbLoader) bbPm.getLoader(ContentDbLoader.TYPE); + Content courseDoc = (Content) courseDocumentLoader.loadById(contentId); + title = courseDoc.getTitle(); + description = courseDoc.getBody().getFormattedText(); + + } else { + + title = (request.getParameter("title") != null) ? request.getParameter("title") : "LAMS Options"; + description = request.getParameter("description"); + } + + //display learning design image + String strIsDisplayDesignImage = request.getParameter("isDisplayDesignImage"); + boolean isDisplayDesignImage = "true".equals(strIsDisplayDesignImage) ? true : false; + String learningDesignImageUrl = ""; + if (isDisplayDesignImage) { + String username = ctx.getUser().getUserName(); + learningDesignImageUrl = LamsSecurityUtil.generateRequestLearningDesignImage(username) + "&lsId=" + + lessonId; + } + + //prepare learnerProgressDto for displaying on jsp + LearnerProgressDTO learnerProgressDto = LamsSecurityUtil.getLearnerProgress(ctx, lessonId); + + request.setAttribute("title", title); + request.setAttribute("isInstructor", isInstructor); + request.setAttribute("description", description); + request.setAttribute("isDisplayDesignImage", isDisplayDesignImage); + request.setAttribute("learningDesignImageUrl", learningDesignImageUrl); + request.setAttribute("isLessonCompleted", learnerProgressDto.getLessonComplete()); + request.setAttribute("attemptedActivitiesCount", learnerProgressDto.getAttemptedActivities()); + request.setAttribute("activitiesCompletedCount", learnerProgressDto.getActivitiesCompleted()); + request.setAttribute("activitiesCount", learnerProgressDto.getActivityCount()); + + } catch (InitializationException e) { + throw new ServletException(e); + } catch (BbServiceException e) { + throw new ServletException(e); + } catch (PersistenceException e) { + throw new ServletException(e); + } + } + + public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + doGet(request, response); + } + +} Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LessonManagerServlet.java =================================================================== diff -u -re6a8d68204cbc85c94ba7504185f5f0581abbe88 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision e6a8d68204cbc85c94ba7504185f5f0581abbe88) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -52,7 +52,6 @@ import blackboard.persist.PkId; import blackboard.persist.content.ContentDbLoader; import blackboard.persist.content.ContentDbPersister; -import blackboard.persist.gradebook.LineitemDbPersister; import blackboard.platform.BbServiceException; import blackboard.platform.BbServiceManager; import blackboard.platform.context.Context; @@ -65,7 +64,7 @@ import blackboard.portal.servlet.PortalUtil; /** - * Launches LAMS pages: author, learner and monitor one. + * Shows startLesson page and modifyLesson pages, also handles subsequent start and modification of LAMS lessons. */ public class LessonManagerServlet extends HttpServlet { @@ -97,19 +96,21 @@ Context ctx = ctxMgr.getContext(); String method = request.getParameter("method"); - // -----------------------Assessment Author functions --------------------------- - if (method.equals("configureLessonStart")) { - configureLessonStart(request, response, ctx); + // -----------------------Start lesson functions --------------------------- + if (method.equals("showStartLessonPage")) { + showStartLessonPage(request, response, ctx); } else if (method.equals("start")) { start(request, response, ctx); - } else if (method.equals("configureLessonModification")) { - configureLessonModification(request, response, ctx); + // -----------------------Modify lesson functions --------------------------- + } else if (method.equals("showModifyLessonPage")) { + showModifyLessonPage(request, response, ctx); } else if (method.equals("modify")) { modify(request, response, ctx); + // -----------------------Delete lesson functions --------------------------- } else if (method.equals("delete")) { delete(request, response, ctx); } @@ -141,7 +142,7 @@ /** * Shows preparation page with available learning designs. Preview is available. */ - private void configureLessonStart(HttpServletRequest request, HttpServletResponse response, Context ctx) + private void showStartLessonPage(HttpServletRequest request, HttpServletResponse response, Context ctx) throws InitializationException, BbServiceException, PersistenceException, IOException, ServletException { String lamsServerUrl = LamsSecurityUtil.getServerAddress(); @@ -177,7 +178,7 @@ request.getRequestDispatcher("/modules/startLessonSuccess.jsp").forward(request, response); } - private void configureLessonModification(HttpServletRequest request, HttpServletResponse response, Context ctx) + private void showModifyLessonPage(HttpServletRequest request, HttpServletResponse response, Context ctx) throws InitializationException, BbServiceException, PersistenceException, IOException, ServletException { // retrive the LAMS lesson @@ -299,7 +300,7 @@ } private void delete(HttpServletRequest request, HttpServletResponse response, Context ctx) - throws InitializationException, BbServiceException, PersistenceException, IOException, ServletException { + throws InitializationException, BbServiceException, PersistenceException, IOException, ServletException, ParserConfigurationException, SAXException { //remove Lineitem object from Blackboard DB String bbContentId = request.getParameter("content_id"); @@ -324,5 +325,7 @@ System.out.println("Lesson (bbContentId:" + bbContentId + ") successfully deleted by userName:" + userName); } + + } Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LinkToolsServlet.java =================================================================== diff -u --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LinkToolsServlet.java (revision 0) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LinkToolsServlet.java (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -0,0 +1,605 @@ +package org.lamsfoundation.ld.integration.blackboard; +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +import java.io.IOException; +import java.io.PrintWriter; +import java.net.URLEncoder; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.log4j.Logger; +import org.lamsfoundation.ld.integration.util.BlackboardUtil; +import org.lamsfoundation.ld.integration.util.LamsSecurityUtil; +import org.lamsfoundation.ld.integration.util.LamsServerException; +import org.lamsfoundation.ld.integration.util.LineitemUtil; +import org.xml.sax.SAXException; + +import blackboard.base.BbList; +import blackboard.base.FormattedText; +import blackboard.base.InitializationException; +import blackboard.data.ValidationException; +import blackboard.data.content.Content; +import blackboard.data.course.Course; +import blackboard.data.navigation.CourseToc; +import blackboard.data.user.User; +import blackboard.persist.BbPersistenceManager; +import blackboard.persist.Container; +import blackboard.persist.Id; +import blackboard.persist.PersistenceException; +import blackboard.persist.PkId; +import blackboard.persist.content.ContentDbLoader; +import blackboard.persist.content.ContentDbPersister; +import blackboard.persist.course.CourseDbLoader; +import blackboard.persist.navigation.CourseTocDbLoader; +import blackboard.platform.BbServiceException; +import blackboard.platform.BbServiceManager; +import blackboard.platform.context.Context; +import blackboard.platform.context.ContextManager; +import blackboard.platform.persistence.PersistenceServiceFactory; +import blackboard.platform.plugin.PlugInException; +import blackboard.platform.plugin.PlugInUtil; +import blackboard.util.StringUtil; + +/** + * + */ +public class LinkToolsServlet extends HttpServlet { + + private static final long serialVersionUID = -351131323404991332L; + private static Logger logger = Logger.getLogger(LinkToolsServlet.class); + + public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + process(request, response); + } + + public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + process(request, response); + } + + private void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + // Authorise current user for Course Control Panel (automatic redirect) + try { + if (!PlugInUtil.authorizeForCourseControlPanel(request, response)) + return; + } catch (PlugInException e) { + throw new RuntimeException(e); + } + + String method = request.getParameter("method"); + if (method.equals("openAdminLinkTool")) { + openAdminLinkTool(request, response); + + } else if (method.equals("openAuthorLinkTool")) { + openAuthorLinkTool(request, response); + + } else if (method.equals("openMonitorLinkTool")) { + openMonitorLinkTool(request, response); + + //Admin on BB side calls this servlet to clone old lesson that were copied to the new course. + } else if (method.equals("cloneLessons")) { + cloneLessons(request, response); + + //Admin on BB side calls this servlet to import old lesson that were copied to the new course. + } else if (method.equals("importLessons")) { + importLessons(request, response); + + //Admin on BB side calls this servlet to correct lineitems that have been screwed up while copying/importing courses. + } else if (method.equals("correctLineitems")) { + correctLineitems(request, response); + } + } + + private void openAdminLinkTool(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + request.getRequestDispatcher("/links/admin.jsp").forward(request, response); + } + + private void openAuthorLinkTool(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + request.getRequestDispatcher("/links/author.jsp").forward(request, response); + } + + private void openMonitorLinkTool(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + + BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); + Container bbContainer = bbPm.getContainer(); + Id courseId = new PkId(bbContainer, Course.DATA_TYPE, request.getParameter("course_id")); + + ContextManager ctxMgr = null; + String strOut = "[[]]"; + try { + // get Blackboard context + ctxMgr = (ContextManager) BbServiceManager.lookupService(ContextManager.class); + Context ctx = ctxMgr.getContext(); + ContentDbLoader cLoader = (ContentDbLoader) bbPm.getLoader(ContentDbLoader.TYPE); + CourseTocDbLoader ctLoader = (CourseTocDbLoader) bbPm.getLoader(CourseTocDbLoader.TYPE); + + Course course = ctx.getCourse(); + BbList ctList = ctLoader.loadByCourseId(courseId); + CourseToc[] courseTocs = (CourseToc[]) ctList.toArray(new CourseToc[0]); + + int idx = 0; + StringBuilder strB = new StringBuilder(); + strB.append("[{type:'Text', label:'" + course.getTitle().replace("'", "\\'") + "', id:0, children:["); + for (int i = 0; i < courseTocs.length; i++) { + if (courseTocs[i].getTargetType().compareTo(CourseToc.Target.CONTENT) == 0) { + Content cont = cLoader.loadByTocId(courseTocs[i].getId()); + strB.append(getChild(cont, cLoader)); + idx = i; + break; + } + } + for (int i = idx + 1; i < courseTocs.length; i++) { + if (courseTocs[i].getTargetType().compareTo(CourseToc.Target.CONTENT) == 0) { + Content cont = cLoader.loadByTocId(courseTocs[i].getId()); + strB.append(", ").append(getChild(cont, cLoader)); + } + } + strB.append("]}]"); + strOut = strB.toString(); + } catch (InitializationException e) { + throw new ServletException(e); + } catch (BbServiceException e) { + throw new ServletException(e); + } catch (PersistenceException e) { + throw new ServletException(e); + } + + request.setAttribute("treeView", strOut); + request.getRequestDispatcher("/links/monitor.jsp").forward(request, response); + } + + private static String extractParameterValue(String url, String param) { + if (url != null && param != null) { + int quotationMarkIndex = url.indexOf("?"); + String queryPart = quotationMarkIndex > -1 ? url.substring(quotationMarkIndex + 1) : url; + String[] paramEntries = queryPart.split("&"); + for (String paramEntry : paramEntries) { + String[] paramEntrySplitted = paramEntry.split("="); + if ((paramEntrySplitted.length > 1) && param.equalsIgnoreCase(paramEntrySplitted[0])) { + return paramEntrySplitted[1]; + } + } + } + return null; + } + + private String getChild(Content f, ContentDbLoader cLoader) { + StringBuilder sb = new StringBuilder(); + try { + + if (f.getIsFolder()) { + + BbList cList = cLoader.loadChildren(f.getId()); + Content[] cArray = cList.toArray(new Content[0]); + //sort content by title + Arrays.sort(cArray, new Comparator() { + @Override + public int compare(Content o1, Content o2) { + if (o1 != null && o2 != null) { + return o1.getTitle().compareToIgnoreCase(o2.getTitle()); + } else if (o1 != null) + return 1; + else + return -1; + } + }); + + String title = f.getTitle(); + if (title.indexOf("'") != -1) { + title = title.replace("'", "\\'"); + } + sb.append("{type:'Text', label:'" + title + "', id:0"); + + if (cArray.length == 0) { + sb.append(", expanded:0, children:[{type:'HTML', html:'null', id:0}]}"); + return sb.toString(); + + } else { + sb.append(", children:["); + sb.append(getChild(cArray[0], cLoader)); + for (int i = 1; i < cArray.length; i++) { + sb.append(", ").append(getChild(cArray[i], cLoader)); + } + sb.append("]}"); + } + return sb.toString(); + + } else { + + if (f.getContentHandler().equals("resource/x-lams-lamscontent")) { + String strUrl = f.getUrl(); + String strId = extractParameterValue(strUrl, "lsid"); + String strTitle = f.getTitle().replace("'", "\\'"); + sb.append("{type:'Text', label:'" + strTitle + "', id:'" + strId + "'}"); + // return sb.toString(); + + } else if (f.getContentHandler().equals("resource/x-ntu-hdllams")) { + String strUrl = f.getUrl(); + String strId = "0"; + if (strUrl.indexOf("&seq_id=") != -1) { + int pos1 = strUrl.indexOf("&seq_id=") + 8; +// int pos2 = strUrl.indexOf("&", pos1); + strId = strUrl.substring(pos1); + } + String strTitle = f.getTitle().replace("'", "\\'"); + sb.append("{type:'Text', label:'" + strTitle + "', id:'" + strId + "'}"); + + } else { + // sb.append("{type:'HTML', html:'null', id:0}"); + } + return sb.toString(); + } + + } catch (Exception e) { + return sb.toString(); + } + } + + /** + * Admin on BB side calls this servlet to clone old lesson that were copied to the new course. + * + * @param request + * @param response + * @throws IOException + * @throws ServletException + */ + private void cloneLessons(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + String _course_id = request.getParameter("course_id"); + if (StringUtil.isEmpty(_course_id)) { + throw new RuntimeException("Required parameters are missing. courseId: " + _course_id); + } + + String newLessonIds = ""; + try { + newLessonIds = recreateLessonsAfterCourseCopy(_course_id); + } catch (IllegalStateException e) { + throw new ServletException( + "LAMS Server timeout, did not get a response from the LAMS server. Please contact your systems administrator", + e); + } catch (PersistenceException e) { + throw new ServletException(e); + } catch (ValidationException e) { + throw new ServletException(e); + } catch (ParserConfigurationException e) { + throw new ServletException(e); + } catch (SAXException e) { + throw new ServletException(e); + } + + //prepare string to write out + int newLessonsCounts = newLessonIds.length() - newLessonIds.replace(",", "").length(); + String resultStr = "Complete! " + newLessonsCounts + " lessons have been cloned."; + //add all lessonIds (without the last comma) + if (newLessonsCounts > 0) { + resultStr += " Their updated lessonIds: " + newLessonIds.substring(0, newLessonIds.length() - 2); + } + + response.setContentType("text/html"); + PrintWriter out = response.getWriter(); + out.write(resultStr); + out.flush(); + out.close(); + } + + /** + * Recreates lessons after course has been copied. I.e. asks LAMS server to clone old lesson and then updates BB + * link with the newly created lesson Id. + * + * @param courseIdParam + * id of the course that has been copied + * @return + * @throws PersistenceException + * @throws ValidationException + * @throws IOException + * @throws ServletException + * @throws SAXException + * @throws ParserConfigurationException + */ + private static String recreateLessonsAfterCourseCopy(String _course_id) + throws PersistenceException, ValidationException, ServletException, IOException, ParserConfigurationException, SAXException { + String newLessonIds = ""; + + BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); + ContentDbPersister persister = ContentDbPersister.Default.getInstance(); + CourseDbLoader courseLoader = CourseDbLoader.Default.getInstance(); + + PkId courseId = (PkId) bbPm.generateId(Course.DATA_TYPE, _course_id); + Course course = courseLoader.loadById(courseId); + String courseIdStr = course.getCourseId(); + + logger.debug("Starting clonning course lessons (courseId=" + courseId + ")."); + + // find a teacher that will be assigned as lesson's author on LAMS side + User teacher = BlackboardUtil.getCourseTeacher(courseId); + + //find all lessons that should be updated + List lamsContents = BlackboardUtil.getLamsLessonsByCourse(courseId); + for (Content content : lamsContents) { + + PkId contentId = (PkId) content.getId(); + String _content_id = "_" + contentId.getPk1() + "_" + contentId.getPk2(); + + String url = content.getUrl(); + String urlLessonId = getParameterValue(url, "lsid"); + String urlCourseId = getParameterValue(url, "course_id"); + String urlContentId = getParameterValue(url, "content_id"); + + //in case when both courseId and contentId don't coincide with the ones from URL - means lesson needs to be cloned + if (!urlCourseId.equals(_course_id) && !urlContentId.equals(_content_id)) { + + final Long newLessonId = LamsSecurityUtil.cloneLesson(teacher, courseIdStr, urlLessonId); + + // update lesson id + content.setLinkRef(Long.toString(newLessonId)); + + // update URL + url = replaceParameterValue(url, "lsid", Long.toString(newLessonId)); + url = replaceParameterValue(url, "course_id", _course_id); + url = replaceParameterValue(url, "content_id", _content_id); + content.setUrl(url); + + // persist updated content + persister.persist(content); + + //update lineitem details + LineitemUtil.updateLineitemLessonId(content, _course_id, newLessonId, teacher.getUserName()); + + logger.debug("Lesson (lessonId=" + urlLessonId + ") was successfully cloned to the one (lessonId=" + + newLessonId + ")."); + + newLessonIds += newLessonId + ", "; + } + + } + + return newLessonIds; + } + + /** + * Admin on BB side calls this servlet to import old lesson that were copied to the new course. + */ + private void importLessons(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String _course_id = request.getParameter("course_id"); + if (StringUtil.isEmpty(_course_id)) { + throw new RuntimeException("Required parameters are missing. courseId: " + _course_id); + } + + String newLessonIds = ""; + try { + BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); + ContentDbPersister persister = ContentDbPersister.Default.getInstance(); + CourseDbLoader courseLoader = CourseDbLoader.Default.getInstance(); + + PkId courseId = (PkId) bbPm.generateId(Course.DATA_TYPE, _course_id); + Course course = courseLoader.loadById(courseId); + String courseIdStr = course.getCourseId(); + + logger.debug("Starting importing course lessons (courseId=" + courseId + ")."); + + // find a teacher that will be assigned as lesson's author on LAMS side + User teacher = BlackboardUtil.getCourseTeacher(courseId); + + //find all lessons that should be updated + List lamsContents = BlackboardUtil.getLamsLessonsByCourse(courseId); + for (Content content : lamsContents) { + + PkId contentId = (PkId) content.getId(); + String _content_id = "_" + contentId.getPk1() + "_" + contentId.getPk2(); + + String url = content.getUrl(); + String urlLessonId = getParameterValue(url, "lsid"); + String urlCourseId = getParameterValue(url, "course_id"); + String urlContentId = getParameterValue(url, "content_id"); + String urlLdId = getParameterValue(url, "ldid"); + + //in case when both courseId and contentId don't coincide with the ones from URL - means lesson needs to be imported + if (!urlCourseId.equals(_course_id) && !urlContentId.equals(_content_id)) { + + final Long newLdId = LamsSecurityUtil.importLearningDesign(teacher, courseIdStr, urlLessonId, + urlLdId); + + logger.debug("Lesson (lessonId=" + urlLessonId + + ") was successfully imported to the one (learningDesignId=" + newLdId + ")."); + + // Start the Lesson in LAMS (via Webservices) and get back the lesson ID + String title = content.getTitle(); + FormattedText descriptionFormatted = content.getBody(); + String description = URLEncoder.encode(descriptionFormatted.getText(), "UTF-8"); + final long newLessonId = LamsSecurityUtil.startLesson(teacher, courseIdStr, newLdId, title, + description, false); + + // update lesson id + content.setLinkRef(Long.toString(newLessonId)); + + // update URL + url = replaceParameterValue(url, "ldid", Long.toString(newLdId)); + url = replaceParameterValue(url, "lsid", Long.toString(newLessonId)); + url = replaceParameterValue(url, "course_id", _course_id); + url = replaceParameterValue(url, "content_id", _content_id); + content.setUrl(url); + + // persist updated content + persister.persist(content); + + //update lineitem details + LineitemUtil.updateLineitemLessonId(content, _course_id, newLessonId, teacher.getUserName()); + + logger.debug("Lesson (lessonId=" + urlLessonId + ") was successfully imported to the one (lessonId=" + + newLessonId + ")."); + + newLessonIds += newLessonId + ", "; + } + } + + } catch (LamsServerException e) { + //printing out error cause + response.setContentType("text/html"); + PrintWriter out = response.getWriter(); + out.write("Failed! " + e.getMessage()); + out.flush(); + out.close(); + return; + } catch (IllegalStateException e) { + throw new ServletException( + "LAMS Server timeout, did not get a response from the LAMS server. Please contact your systems administrator", + e); + } catch (PersistenceException e) { + throw new ServletException(e); + } catch (ValidationException e) { + throw new ServletException(e); + } catch (ParserConfigurationException e) { + throw new ServletException(e); + } catch (SAXException e) { + throw new ServletException(e); + } + + //prepare string to write out + int newLessonsCounts = newLessonIds.length() - newLessonIds.replace(",", "").length(); + String resultStr = "Complete! " + newLessonsCounts + " lessons have been imported."; + //add all lessonIds (without the last comma) + if (newLessonsCounts > 0) { + resultStr += " Their updated lessonIds: " + newLessonIds.substring(0, newLessonIds.length()-2); + } + logger.debug(resultStr); + + response.setContentType("text/html"); + PrintWriter out = response.getWriter(); + out.write(resultStr); + out.flush(); + out.close(); + } + + /** + * Admin on BB side calls this servlet to correct lineitems that have been screwed up while copying/importing courses. + * + * @param request + * @param response + * @throws ServletException + * @throws IOException + */ + private void correctLineitems(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String _course_id = request.getParameter("course_id"); + if (StringUtil.isEmpty(_course_id)) { + throw new RuntimeException("Required parameters are missing. courseId: " + _course_id); + } + + try { + BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); + PkId courseId = (PkId) bbPm.generateId(Course.DATA_TYPE, _course_id); + + logger.debug("Starting clonning course lessons (courseId=" + courseId + ")."); + + // find a teacher that will be assigned as lesson's author on LAMS side + User teacher = BlackboardUtil.getCourseTeacher(courseId); + + //find all lessons that should be updated + List lamsContents = BlackboardUtil.getLamsLessonsByCourse(courseId); + for (Content content : lamsContents) { + + // update lesson id + String lessonId = content.getLinkRef(); + + //update lineitem details + LineitemUtil.updateLineitemLessonId(content, _course_id, Long.parseLong(lessonId), + teacher.getUserName()); + } + + } catch (IllegalStateException e) { + throw new ServletException( + "LAMS Server timeout, did not get a response from the LAMS server. Please contact your systems administrator", + e); + } catch (NumberFormatException e) { + throw new ServletException(e); + } catch (PersistenceException e) { + throw new ServletException(e); + } catch (ValidationException e) { + throw new ServletException(e); + } catch (ParserConfigurationException e) { + throw new ServletException(e); + } catch (SAXException e) { + throw new ServletException(e); + } + + //prepare string to write out + String resultStr = "Complete! All lineiems have been corrected."; + logger.debug(resultStr); + + response.setContentType("text/html"); + PrintWriter out = response.getWriter(); + out.write(resultStr); + out.flush(); + out.close(); + } + + /* + * Returns param value, and empty string in case of there is no such param available + * + * @param url + * @param paramName + * @return + */ + private static String getParameterValue(String url, String paramName) { + String paramValue = ""; + + int quotationMarkIndex = url.indexOf("?"); + String queryPart = quotationMarkIndex > -1 ? url.substring(quotationMarkIndex + 1) : url; + String[] paramEntries = queryPart.split("&"); + for (String paramEntry : paramEntries) { + String[] paramEntrySplitted = paramEntry.split("="); + if ((paramEntrySplitted.length > 1) && paramName.equalsIgnoreCase(paramEntrySplitted[0])) { + paramValue = paramEntrySplitted[1]; + break; + } + } + + return paramValue; + } + + private static String replaceParameterValue(String url, String paramName, String newParamValue) { + String oldParamValue = ""; + + int quotationMarkIndex = url.indexOf("?"); + String queryPart = quotationMarkIndex > -1 ? url.substring(quotationMarkIndex + 1) : url; + String[] paramEntries = queryPart.split("&"); + for (String paramEntry : paramEntries) { + String[] paramEntrySplitted = paramEntry.split("="); + if ((paramEntrySplitted.length > 1) && paramName.equalsIgnoreCase(paramEntrySplitted[0])) { + oldParamValue = paramEntrySplitted[1]; + + return url.replaceFirst(paramName + "=" + oldParamValue, paramName + "=" + newParamValue); + } + } + + return url; + } + +} Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/OpenLamsPageServlet.java =================================================================== diff -u -rdcd309de058219ef41f76000936b9136eedb0d70 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/OpenLamsPageServlet.java (.../OpenLamsPageServlet.java) (revision dcd309de058219ef41f76000936b9136eedb0d70) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/OpenLamsPageServlet.java (.../OpenLamsPageServlet.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -212,8 +212,8 @@ // Get Course ID and Session User ID BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); CourseMembershipDbLoader sessionCourseMembershipLoader = CourseMembershipDbLoader.Default.getInstance(); - String course_idstr = request.getParameter("course_id"); - Id course_id = bbPm.generateId(Course.DATA_TYPE, course_idstr); + String _course_id = request.getParameter("course_id"); + Id course_id = bbPm.generateId(Course.DATA_TYPE, _course_id); User sessionUser = ctx.getUser(); Id sessionUserId = sessionUser.getId(); // Get the membership data to determine the User's Role Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/RenderDesignImageServlet.java =================================================================== diff -u -r4c05d1662c30b2f4263441487eb55fd67c1c2cbd -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/RenderDesignImageServlet.java (.../RenderDesignImageServlet.java) (revision 4c05d1662c30b2f4263441487eb55fd67c1c2cbd) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/RenderDesignImageServlet.java (.../RenderDesignImageServlet.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -29,7 +29,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.lamsfoundation.ld.integration.Constants; import org.lamsfoundation.ld.integration.util.LamsSecurityUtil; import blackboard.base.InitializationException; Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/StartLessonAjaxServlet.java =================================================================== diff -u -rdcd309de058219ef41f76000936b9136eedb0d70 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/StartLessonAjaxServlet.java (.../StartLessonAjaxServlet.java) (revision dcd309de058219ef41f76000936b9136eedb0d70) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/StartLessonAjaxServlet.java (.../StartLessonAjaxServlet.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -22,15 +22,22 @@ */ import java.io.IOException; +import java.text.ParseException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.xml.parsers.ParserConfigurationException; import org.apache.log4j.Logger; import org.lamsfoundation.ld.integration.util.BlackboardUtil; +import org.xml.sax.SAXException; +import blackboard.base.InitializationException; +import blackboard.data.ValidationException; import blackboard.data.user.User; +import blackboard.persist.PersistenceException; +import blackboard.platform.BbServiceException; import blackboard.platform.BbServiceManager; import blackboard.platform.context.ContextManager; @@ -78,9 +85,20 @@ response.getWriter().print("{\"content_id\":" + bbContentId + "}"); } - } catch (Exception e) { - logger.error("Unable to start lesson "+e.getMessage(), e); + } catch (PersistenceException e) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to start lesson "+e.getMessage()); + } catch (ParseException e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to start lesson "+e.getMessage()); + } catch (ValidationException e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to start lesson "+e.getMessage()); + } catch (ParserConfigurationException e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to start lesson "+e.getMessage()); + } catch (SAXException e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to start lesson "+e.getMessage()); + } catch (InitializationException e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to start lesson "+e.getMessage()); + } catch (BbServiceException e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to start lesson "+e.getMessage()); } finally { // make sure context is released if (ctxMgr != null) { Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/UpdateServerUrlServlet.java =================================================================== diff -u -r6c816ed5cfaacf7a92c46e7ddb649148b73fbfb3 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/UpdateServerUrlServlet.java (.../UpdateServerUrlServlet.java) (revision 6c816ed5cfaacf7a92c46e7ddb649148b73fbfb3) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/UpdateServerUrlServlet.java (.../UpdateServerUrlServlet.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -35,15 +35,20 @@ import org.lamsfoundation.ld.integration.Constants; import org.lamsfoundation.ld.integration.util.BlackboardUtil; +import blackboard.base.InitializationException; +import blackboard.data.ValidationException; import blackboard.data.content.Content; import blackboard.data.course.Course; import blackboard.persist.BbPersistenceManager; import blackboard.persist.Container; +import blackboard.persist.PersistenceException; import blackboard.persist.PkId; import blackboard.persist.content.ContentDbPersister; +import blackboard.platform.BbServiceException; import blackboard.platform.BbServiceManager; import blackboard.platform.context.ContextManager; import blackboard.platform.persistence.PersistenceServiceFactory; +import blackboard.platform.plugin.PlugInException; import blackboard.platform.plugin.PlugInUtil; /** @@ -95,8 +100,16 @@ out.write("Old Url" + oldUrl + ". New url:" + newUrl + "\n\r"); } - } catch (Exception e) { + } catch (PersistenceException e) { throw new ServletException(e); + } catch (ValidationException e) { + throw new ServletException(e); + } catch (InitializationException e) { + throw new ServletException(e); + } catch (BbServiceException e) { + throw new ServletException(e); + } catch (PlugInException e) { + throw new ServletException(e); } finally { // make sure context is released if (ctxMgr != null) { Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/UserDataServlet.java =================================================================== diff -u -r90551510089141ff0f625b92c00ab97ba4e98a26 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/UserDataServlet.java (.../UserDataServlet.java) (revision 90551510089141ff0f625b92c00ab97ba4e98a26) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/UserDataServlet.java (.../UserDataServlet.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -22,33 +22,29 @@ import java.io.IOException; import java.io.PrintWriter; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; + import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.codec.binary.Hex; -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.persistence.PersistenceServiceFactory; import org.apache.log4j.Logger; +import org.lamsfoundation.ld.integration.Constants; import org.lamsfoundation.ld.integration.util.CSVUtil; import org.lamsfoundation.ld.integration.util.LamsPluginUtil; import org.lamsfoundation.ld.integration.util.LamsSecurityUtil; +import blackboard.data.user.User; +import blackboard.persist.PersistenceException; +import blackboard.persist.user.UserDbLoader; + /** * @author Anthony Xiao */ public class UserDataServlet extends HttpServlet { private static final long serialVersionUID = 2L; - static Logger logger = Logger.getLogger(UserDataServlet.class); + private static Logger logger = Logger.getLogger(UserDataServlet.class); /** * The doGet method of the servlet.
@@ -64,77 +60,66 @@ * @throws IOException * if an error occurred */ - public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException { + public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - ContextManager ctxMgr = null; + // get Parameter values + String usernameParam = request.getParameter(Constants.PARAM_USER_ID); + String tsParam = request.getParameter(Constants.PARAM_TIMESTAMP); + String hashParam = request.getParameter(Constants.PARAM_HASH); - // get Blackboard context - try { - ctxMgr = (ContextManager) BbServiceManager.lookupService(ContextManager.class); + // check paramaeters + if (usernameParam == null || tsParam == null || hashParam == null) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "missing expected parameters"); + return; + } - // get Parameter values - String usernameParam = request.getParameter(Constants.PARAM_USER_ID); - String tsParam = request.getParameter(Constants.PARAM_TIMESTAMP); - String hashParam = request.getParameter(Constants.PARAM_HASH); + String secretKey = LamsPluginUtil.getSecretKey(); + String serverId = LamsPluginUtil.getServerId(); - // check paramaeters - if (usernameParam == null || tsParam == null || hashParam == null) { - response.sendError(HttpServletResponse.SC_BAD_REQUEST, "missing expected parameters"); - return; - } + if (!LamsSecurityUtil.sha1( + tsParam.toLowerCase() + usernameParam.toLowerCase() + serverId.toLowerCase() + secretKey.toLowerCase()) + .equals(hashParam)) { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "authentication failed"); + return; + } - String secretKey = LamsPluginUtil.getSecretKey(); - String serverId = LamsPluginUtil.getServerId(); + // get user list, but no role info since there are no course info + User user; + try { + UserDbLoader userLoader = UserDbLoader.Default.getInstance(); + user = userLoader.loadByUserName(usernameParam); + } catch (PersistenceException e) { + throw new ServletException(e); + } - if (!LamsSecurityUtil.sha1( - tsParam.toLowerCase() + usernameParam.toLowerCase() + serverId.toLowerCase() - + secretKey.toLowerCase()).equals(hashParam)) { - response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "authentication failed"); - return; - } + if (user == null) { + throw new ServletException("user not found"); + } - // get the persistence manager - BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); + // construct the address + String address = user.getStreet1() + (user.getStreet1().length() == 0 ? "" : " "); + address += user.getStreet2() + (address.length() == 0 ? "" : " "); + address += user.getState() + (address.length() == 0 ? "" : " "); + address += user.getCountry() + (address.length() == 0 ? "" : " "); + address += user.getZipCode(); + // String username = u.getUserName().replaceAll(); - // get user list, but no role info since there are no course info - UserDbLoader userLoader = (UserDbLoader) bbPm.getLoader(UserDbLoader.TYPE); - User u = userLoader.loadByUserName(usernameParam); + PrintWriter out = response.getWriter(); - if (u == null) { - throw new ServletException("user not found"); - } + String locale = user.getLocale(); + String loc_lang = LamsSecurityUtil.getLanguage(locale); + String loc_cntry = LamsSecurityUtil.getCountry(locale); - // construct the address - String address = u.getStreet1() + (u.getStreet1().length() == 0 ? "" : " "); - address += u.getStreet2() + (address.length() == 0 ? "" : " "); - address += u.getState() + (address.length() == 0 ? "" : " "); - address += u.getCountry() + (address.length() == 0 ? "" : " "); - address += u.getZipCode(); - // String username = u.getUserName().replaceAll(); + // The CSV list should be the format below + // ,<First name>,<Last name>,<Address>,<City>,<State>, + // <Postcode>,<Country>,<Day time number>,<Mobile number>, + // <Fax number>,<Email>,<Locale language>,<Locale country> + String[] valList = { user.getTitle(), user.getGivenName(), user.getFamilyName(), + user.getStreet1() + user.getStreet2(), user.getCity(), user.getState(), user.getZipCode(), + user.getCountry(), user.getHomePhone1(), user.getMobilePhone(), user.getBusinessFax(), + user.getEmailAddress(), loc_lang, loc_cntry }; - PrintWriter out = response.getWriter(); - - String locale = u.getLocale(); - String loc_lang = LamsSecurityUtil.getLanguage(locale); - String loc_cntry = LamsSecurityUtil.getCountry(locale); - - // The CSV list should be the format below - // <Title>,<First name>,<Last name>,<Address>,<City>,<State>, - // <Postcode>,<Country>,<Day time number>,<Mobile number>, - // <Fax number>,<Email>,<Locale language>,<Locale country> - String[] valList = { u.getTitle(), u.getGivenName(), u.getFamilyName(), u.getStreet1() + u.getStreet2(), - u.getCity(), u.getState(), u.getZipCode(), u.getCountry(), u.getHomePhone1(), u.getMobilePhone(), - u.getBusinessFax(), u.getEmailAddress(), loc_lang, loc_cntry }; - - out.println(CSVUtil.write(valList)); - - } catch (Exception e) { - throw new ServletException("Failed to fetch user", e); - } finally { - // make sure context is released - if (ctxMgr != null) - ctxMgr.releaseContext(); - } + out.println(CSVUtil.write(valList)); } } Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/util/BlackboardUtil.java =================================================================== diff -u -r5d8a735e86e4b2c0d216560e6fc7750dcafd81ed -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/util/BlackboardUtil.java (.../BlackboardUtil.java) (revision 5d8a735e86e4b2c0d216560e6fc7750dcafd81ed) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/util/BlackboardUtil.java (.../BlackboardUtil.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -7,12 +7,10 @@ import java.util.Calendar; import java.util.List; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.parsers.ParserConfigurationException; -import org.apache.log4j.Logger; import org.xml.sax.SAXException; import blackboard.base.BbList; Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/util/CSVUtil.java =================================================================== diff -u -r90551510089141ff0f625b92c00ab97ba4e98a26 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/util/CSVUtil.java (.../CSVUtil.java) (revision 90551510089141ff0f625b92c00ab97ba4e98a26) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/util/CSVUtil.java (.../CSVUtil.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -24,7 +24,7 @@ import java.text.ParseException; import java.util.ArrayList; -import java.util.regex.*; +import java.util.regex.Pattern; /** * CSVUtil Provides "Comma Seperated Value" writing and parsing. Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/util/LamsPluginUtil.java =================================================================== diff -u -r90551510089141ff0f625b92c00ab97ba4e98a26 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/util/LamsPluginUtil.java (.../LamsPluginUtil.java) (revision 90551510089141ff0f625b92c00ab97ba4e98a26) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/util/LamsPluginUtil.java (.../LamsPluginUtil.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -22,12 +22,13 @@ */ package org.lamsfoundation.ld.integration.util; -import java.util.Properties; import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; +import java.util.Properties; + import blackboard.platform.plugin.PlugInException; import blackboard.platform.plugin.PlugInUtil; Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/util/LamsSecurityUtil.java =================================================================== diff -u -re6a8d68204cbc85c94ba7504185f5f0581abbe88 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/src/org/lamsfoundation/ld/integration/util/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision e6a8d68204cbc85c94ba7504185f5f0581abbe88) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/util/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -60,7 +60,6 @@ import blackboard.persist.KeyNotFoundException; import blackboard.persist.PersistenceException; import blackboard.persist.course.CourseMembershipDbLoader; -import blackboard.persist.user.UserDbLoader; import blackboard.platform.context.Context; import blackboard.platform.persistence.PersistenceServiceFactory; import blackboard.portal.data.ExtraInfo; @@ -487,8 +486,10 @@ } catch (IOException e) { throw new RuntimeException("Unable to start LAMS lesson. " + e.getMessage() + " Please contact your system administrator.", e); - } catch (Exception e) { + } catch (ParserConfigurationException e) { throw new RuntimeException("Unable to start LAMS lesson. Please contact your system administrator.", e); + } catch (SAXException e) { + throw new RuntimeException("Unable to start LAMS lesson. Please contact your system administrator.", e); } } @@ -504,8 +505,11 @@ * the lesson id to be deleted * * @return boolean whether lesson was successfully deleted + * @throws IOException + * @throws ParserConfigurationException + * @throws SAXException */ - public static Boolean deleteLesson(String userName, String lsId) { + public static Boolean deleteLesson(String userName, String lsId) throws IOException, ParserConfigurationException, SAXException { String serverId = getServerID(); String serverAddr = getServerAddress(); @@ -515,47 +519,22 @@ throw new RuntimeException("Unable to delete lesson. One or more LAMS configuration properties are null"); } - try { - String timestamp = new Long(System.currentTimeMillis()).toString(); - String hash = generateAuthenticationHash(timestamp, userName, serverId); + String timestamp = new Long(System.currentTimeMillis()).toString(); + String hash = generateAuthenticationHash(timestamp, userName, serverId); - String serviceURL = serverAddr + "/services/xml/LessonManager?" + "serverId=" - + URLEncoder.encode(serverId, "utf8") + "&datetime=" + timestamp + "&username=" - + URLEncoder.encode(userName, "utf8") + "&hashValue=" + hash + "&method=removeLesson" + "&lsId=" - + lsId; + String serviceURL = serverAddr + "/services/xml/LessonManager?" + "serverId=" + + URLEncoder.encode(serverId, "utf8") + "&datetime=" + timestamp + "&username=" + + URLEncoder.encode(userName, "utf8") + "&hashValue=" + hash + "&method=removeLesson" + "&lsId=" + lsId; - logger.info("LAMS DELETE LESSON Req: " + serviceURL); + logger.info("LAMS DELETE LESSON Req: " + serviceURL); - // parse xml response and get the lesson id - InputStream is = LamsSecurityUtil.callLamsServerPost(serviceURL); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document document = db.parse(is); - return Boolean.parseBoolean(document.getElementsByTagName("Lesson").item(0).getAttributes() - .getNamedItem("deleted").getNodeValue()); - - } catch (MalformedURLException e) { - throw new RuntimeException("Unable to start LAMS lesson, bad URL: '" + serverAddr - + "', please check lams.properties", e); - } catch (IllegalStateException e) { - throw new RuntimeException( - "LAMS Server timeout, did not get a response from the LAMS server. Please contact your systems administrator", - e); - } catch (RemoteException e) { - throw new RuntimeException("Unable to start LAMS lesson, RMI Remote Exception", e); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException("Unable to start LAMS lesson, Unsupported Encoding Exception", e); - } catch (ConnectException e) { - throw new RuntimeException( - "LAMS Server timeout, did not get a response from the LAMS server. Please contact your systems administrator", - e); - } catch (IOException e) { - throw new RuntimeException("Unable to start LAMS lesson. " + e.getMessage() - + " Please contact your system administrator.", e); - } catch (Exception e) { - throw new RuntimeException("Unable to start LAMS lesson. Please contact your system administrator.", e); - } - + // parse xml response and get the lesson id + InputStream is = LamsSecurityUtil.callLamsServerPost(serviceURL); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document document = db.parse(is); + return Boolean.parseBoolean( + document.getElementsByTagName("Lesson").item(0).getAttributes().getNamedItem("deleted").getNodeValue()); } /** @@ -627,8 +606,6 @@ } catch (SAXException e) { throw new RuntimeException( "Unable to clone LAMS lesson. " + e.getMessage() + " Can't parse LAMS results.", e); - } catch (Exception e) { - throw new RuntimeException("Unable to clone LAMS lesson. Please contact your system administrator.", e); } } @@ -711,11 +688,6 @@ } catch (SAXException e) { throw new LamsServerException("Unable to import LAMS lesson. " + e.getMessage() + " Can't parse LAMS results. Tried to import file " + filePath, e); - } catch (Exception e) { - throw new LamsServerException( - "Unable to import LAMS lesson. Please contact your system administrator. Tried to import file " - + filePath, - e); } } @@ -847,9 +819,12 @@ } catch (IOException e) { throw new RuntimeException("Unable to preadd users to the lesson. " + e.getMessage() + " Please contact your system administrator.", e); - } catch (Exception e) { - throw new RuntimeException( - "Unable to preadd users to the lesson. Please contact your system administrator.", e); + } catch (KeyNotFoundException e) { + throw new RuntimeException("Unable to preadd users to the lesson. " + e.getMessage() + + " Please contact your system administrator.", e); + } catch (PersistenceException e) { + throw new RuntimeException("Unable to preadd users to the lesson. " + e.getMessage() + + " Please contact your system administrator.", e); } } @@ -952,8 +927,14 @@ } catch (IOException e) { throw new RuntimeException("Unable to get LearnerProgress. " + e.getMessage() + " Please contact your system administrator.", e); - } catch (Exception e) { - throw new RuntimeException("Unable to get LearnerProgress. Please contact your system administrator.", e); + } catch (ParserConfigurationException e) { + throw new RuntimeException( + "Unable to get LearnerProgress. " + e.getMessage() + " Please contact your system administrator.", + e); + } catch (SAXException e) { + throw new RuntimeException( + "Unable to get LearnerProgress. " + e.getMessage() + " Please contact your system administrator.", + e); } } Index: lams_bb_integration/web/admin/config.jsp =================================================================== diff -u -r3ee2f5e23a3e6ac011601577ac73c85146c94e0d -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/web/admin/config.jsp (.../config.jsp) (revision 3ee2f5e23a3e6ac011601577ac73c85146c94e0d) +++ lams_bb_integration/web/admin/config.jsp (.../config.jsp) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -1,45 +1,16 @@ +<%@ page contentType="text/html; charset=utf-8" language="java"%> +<%@ page isELIgnored="false" %> + +<!DOCTYPE HTML> <%-- - 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.util.LamsPluginUtil"%> <%@ page errorPage="/error.jsp"%> <%@ taglib uri="/bbNG" prefix="bbNG"%> +<%@ taglib uri="/tags-core" prefix="c"%> <bbNG:genericPage title="LAMS Configuration" ctxId="ctx"> -<% - // SECURITY! - // 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 lamsServerTimeRefreshInterval = p.getProperty("LAMS_SERVER_TIME_REFRESH_INTERVAL"); - String lamsAltServerUrl = p.getProperty("LAMS_ALT_SERVER_URL", "https://"); - //Add port to the url if the port is in the blackboard url - int bbport = request.getServerPort(); - String bbportstr = bbport != 0 ? ":" + bbport : ""; -%> - <%-- Breadcrumbs It seems we need to build the full trail manually --%> <bbNG:breadcrumbBar environment="SYS_ADMIN"> <bbNG:breadcrumb href="/webapps/portal/execute/tabs/tabAction?tabType=admin" title="Administrator Panel" /> @@ -54,26 +25,26 @@ </bbNG:pageHeader> <%-- Properties Form --%> - <form action="config_proc.jsp"> + <form action="../configPlugin?method=saveConfigSettings" method="post"> <bbNG:dataCollection> <bbNG:step title="Select Plug-in"> - <bbNG:dataElement label="LAMS SERVER URL" isRequired="true" labelFor="lams_server_url"> - <input type="text" name="lams_server_url" size="70" value="<%=lamsServerUrl%>"> + <bbNG:dataElement label="LAMS SERVER URL" isRequired="true" labelFor="lamsServerUrl"> + <input type="text" name="lamsServerUrl" size="70" value="${lamsServerUrl}"> </bbNG:dataElement> - <bbNG:dataElement label="LAMS SERVER ID" isRequired="true" labelFor="lams_server_id"> - <input type="text" name="lams_server_id" size="70" value="<%=lamsServerId%>"> + <bbNG:dataElement label="LAMS SERVER ID" isRequired="true" labelFor="lamsServerId"> + <input type="text" name="lamsServerId" size="70" value="${lamsServerId}"> </bbNG:dataElement> - <bbNG:dataElement label="LAMS SERVER SECRET KEY" isRequired="true" labelFor="lams_server_skey"> - <input type="text" name="lams_server_skey" size="70" value="<%=SecretKey%>"> + <bbNG:dataElement label="LAMS SERVER SECRET KEY" isRequired="true" labelFor="lamsSecretKey"> + <input type="text" name="lamsSecretKey" size="70" value="${secretKey}"> </bbNG:dataElement> - <bbNG:dataElement label="BLACKBOARD REQUEST SRC" isRequired="true" labelFor="bb_req_src"> - <input type="text" name="bb_req_src" size="70" value="<%=ReqSrc%>"> + <bbNG:dataElement label="BLACKBOARD REQUEST SRC" isRequired="true" labelFor="requestSrc"> + <input type="text" name="requestSrc" size="70" value="${requestSrc}"> </bbNG:dataElement> - <bbNG:dataElement label="LAMS SERVER TIME REFRESH INTERVAL (HOURS)" isRequired="true" labelFor="lams_server_time_refresh_interval"> - <input type="text" name="lams_server_time_refresh_interval" size="20" value="<%=lamsServerTimeRefreshInterval%>"> + <bbNG:dataElement label="LAMS SERVER TIME REFRESH INTERVAL (HOURS)" isRequired="true" labelFor="lamsServerTimeRefreshInterval"> + <input type="text" name="lamsServerTimeRefreshInterval" size="20" value="${lamsServerTimeRefreshInterval}"> </bbNG:dataElement> - <bbNG:dataElement label="LAMS ALTERNATIVE SERVER URL" isRequired="false" labelFor="lams_alt_server_url"> - <input type="text" name="lams_alt_server_url" size="70" value="<%=lamsAltServerUrl%>"> + <bbNG:dataElement label="LAMS ALTERNATIVE SERVER URL" isRequired="false" labelFor="lamsAltServerUrl"> + <input type="text" name="lamsAltServerUrl" size="70" value="${lamsAltServerUrl}"> </bbNG:dataElement> <p>For further information on how to configure these settings, see <a target="_blank" href="http://wiki.lamsfoundation.org/display/lamsdocs/Blackboard+9">this tutorial</a>.</p> </bbNG:step> Index: lams_bb_integration/web/admin/configSuccess.jsp =================================================================== diff -u --- lams_bb_integration/web/admin/configSuccess.jsp (revision 0) +++ lams_bb_integration/web/admin/configSuccess.jsp (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -0,0 +1,41 @@ +<%@ page contentType="text/html; charset=utf-8" language="java"%> +<%@ page isELIgnored="false" %> + +<!DOCTYPE HTML> +<%-- + Process the Configuration Form for the Building Block System Administration + Save the configuration items and display a success receipt +--%> +<%@ page errorPage="/error.jsp"%> +<%@ taglib uri="/bbNG" prefix="bbNG"%> +<%@ taglib uri="/tags-core" prefix="c"%> +<bbNG:genericPage title="LAMS Configuration" ctxId="ctx"> + + <%-- Breadcrumbs It seems we need to build the full trail manually --%> + <bbNG:breadcrumbBar environment="SYS_ADMIN"> + <bbNG:breadcrumb href="/webapps/portal/execute/tabs/tabAction?tabType=admin" title="Administrator Panel" /> + <bbNG:breadcrumb href="/webapps/portal/admin/pa_ext_caret.jsp" title="Building Blocks" /> + <bbNG:breadcrumb href="/webapps/blackboard/admin/manage_plugins.jsp" title="Installed Tools" /> + <bbNG:breadcrumb title="LAMS Configuration" /> + </bbNG:breadcrumbBar> + + <%-- Page Header --%> + <bbNG:pageHeader> + <bbNG:pageTitleBar title="LAMS Configuration"/> + </bbNG:pageHeader> + + <%-- Receipt --%> + <bbNG:receipt type="SUCCESS" + iconUrl="/includes/images/ci/icons/receiptsuccess_u.gif" + title="LAMS Configuration" + recallUrl="/webapps/blackboard/admin/manage_plugins.jsp"> + <h4>Sample plugin configured</h4><p> + LAMS_SERVER_URL: ${param.lamsServerUrl}<br> + LAMS_SERVER_SKEY: ${param.lamsSecretKey}<br> + LAMS_SERVER_ID: ${param.lamsServerId}<br> + BB_REQ_SRC: ${param.requestSrc}<br> + LAMS_SERVER_TIME_REFRESH_INTERVAL: ${param.lamsServerTimeRefreshInterval}<br> + LAMS_ALT_SERVER_URL: ${param.lamsAltServerUrl} + </bbNG:receipt> + +</bbNG:genericPage> \ No newline at end of file Fisheye: Tag a327993967da9b51f138b3e84530a42ad3874abc refers to a dead (removed) revision in file `lams_bb_integration/web/admin/config_proc.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/web/includes/javascript/openLamsPage.js =================================================================== diff -u --- lams_bb_integration/web/includes/javascript/openLamsPage.js (revision 0) +++ lams_bb_integration/web/includes/javascript/openLamsPage.js (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -0,0 +1,47 @@ +// Open the LAMS Seuence Author Window +function openAuthor() { + var authorUrl = '../openLamsPage?method=openAuthor'; + + if(authorWin && !authorWin.closed) { + try { + authorWin.focus(); + }catch(e){ + // popups blocked by a 3rd party + alert("Pop-up windows have been blocked by your browser. Please allow pop-ups for this site and try again"); + } + } else { + try { + authorWin = window.open(authorUrl,'aWindow','width=1280,height=720,resizable,scrollbars=yes'); + authorWin.focus(); + }catch(e){ + // popups blocked by a 3rd party + alert("Pop-up windows have been blocked by your browser. Please allow pop-ups for this site and try again"); + } + } + + return false; +} + +// Open the LAMS Seuence Monitor Window +function openMonitor(courseId, lsid) { + var monitorUrl = '../openLamsPage?method=openMonitor&course_id=' + courseId + '&lsid=' + lsid; + if(monitorWin && !monitorWin.closed) { + try { + monitorWin.focus(); + } catch(e) { + // popups blocked by a 3rd party + alert("Pop-up windows have been blocked by your browser. Please allow pop-ups for this site and try again"); + } + } else { + try { + monitorWin = window.open(monitorUrl,'aWin','width=1280,height=720,resizable=1,scrollbars=yes'); + monitorWin.opener = self; + monitorWin.focus(); + } catch(e) { + // popups blocked by a 3rd party + alert("Pop-up windows have been blocked by your browser. Please allow pop-ups for this site and try again"); + } + } + + return false; +} \ No newline at end of file Index: lams_bb_integration/web/links/admin.jsp =================================================================== diff -u -r2df41e4250f5329a8be4e9e2642d17b091a11f64 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/web/links/admin.jsp (.../admin.jsp) (revision 2df41e4250f5329a8be4e9e2642d17b091a11f64) +++ lams_bb_integration/web/links/admin.jsp (.../admin.jsp) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -1,24 +1,13 @@ -<%@ page import="java.util.*, java.net.*, - java.text.SimpleDateFormat, - blackboard.data.*, - blackboard.persist.*, - blackboard.data.course.*, - blackboard.data.user.*, - blackboard.data.navigation.*, - blackboard.persist.course.*, - blackboard.persist.navigation.*, - blackboard.data.content.*, - blackboard.persist.content.*, - blackboard.db.*, - blackboard.base.*, - blackboard.platform.*, - blackboard.platform.plugin.*, - org.lamsfoundation.ld.integration.*, - org.lamsfoundation.ld.integration.blackboard.*" errorPage="error.jsp" %> +<%@ page contentType="text/html; charset=utf-8" language="java"%> +<%@ page isELIgnored="false" %> + +<!DOCTYPE HTML> +<%@ page errorPage="error.jsp"%> +<%@ page import="blackboard.platform.plugin.*"%> <%@ taglib uri="/bbNG" prefix="bbNG"%> <%@ taglib uri="/bbData" prefix="bbData"%> +<%@ taglib uri="/tags-core" prefix="c"%> <bbData:context id="ctx"> - <% //check permission if (!PlugInUtil.authorizeForCourseControlPanel(request, response)) { @@ -27,11 +16,11 @@ %> <bbNG:learningSystemPage contextOverride="CTRL_PANEL"> <bbNG:cssBlock> - <style type="text/css"> - #buttons { - float:right; - } - </style> + <style type="text/css"> + #buttons { + float:right; + } + </style> </bbNG:cssBlock> <bbNG:jsFile href="includes/javascript/jquery.js" /> @@ -75,8 +64,8 @@ $j.ajax({ async: true, - url: '../CloneLessons', - data : 'courseId=<%=ctx.getCourse().getCourseId()%>', + url: '../LinkTools?method=cloneLessons', + data : 'course_id=${param.course_id}', type: 'post', success: function (response) { $j("#buttons").unblock(); @@ -99,8 +88,8 @@ $j.ajax({ async: true, - url: '../ImportLessons', - data : 'courseId=<%=ctx.getCourse().getCourseId()%>', + url: '../LinkTools?method=importLessons', + data : 'course_id=${param.course_id}', type: 'post', success: function (response) { $j("#buttons").unblock(); @@ -121,8 +110,8 @@ $j.ajax({ async: true, - url: '../CorrectLineitems', - data : 'courseId=<%=ctx.getCourse().getCourseId()%>', + url: '../LinkTools?method=correctLineitems', + data : 'course_id=${param.course_id}', type: 'post', success: function (response) { $j("#buttons").unblock(); Index: lams_bb_integration/web/links/author.jsp =================================================================== diff -u -r92f0489cd46a28a50c81548f165c4d2b4ad10252 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/web/links/author.jsp (.../author.jsp) (revision 92f0489cd46a28a50c81548f165c4d2b4ad10252) +++ lams_bb_integration/web/links/author.jsp (.../author.jsp) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -1,21 +1,23 @@ -<%@ page import="java.util.*, java.net.*, - org.lamsfoundation.ld.integration.util.*" errorPage="error.jsp" %> <%@ taglib uri="/bbData" prefix="bbData"%> <%@ taglib uri="/bbNG" prefix="bbNG"%> +<%@ taglib uri="/tags-core" prefix="c"%> <bbData:context id="ctx"> -<% - String authorURL = LamsSecurityUtil.generateRequestURL(ctx, "author", null); - authorURL = authorURL + "&isPostMessageToParent=true"; -%> -<bbNG:learningSystemPage> - <bbNG:breadcrumbBar environment="CTRL_PANEL" isContent="false"> - <bbNG:breadcrumb>LAMS Author</bbNG:breadcrumb> - </bbNG:breadcrumbBar> + <bbNG:learningSystemPage> + <bbNG:jsFile href="includes/javascript/openLamsPage.js" /> + <bbNG:jsBlock> + <script type="text/javascript"> + var authorWin = null; + </script> + </bbNG:jsBlock> - <bbNG:pageHeader> - <bbNG:pageTitleBar title="LAMS Author" /> - </bbNG:pageHeader> - - To launch LAMS Author, please, click <a href="<%= authorURL %>" target="_blank">here</a>. -</bbNG:learningSystemPage> + <bbNG:breadcrumbBar environment="CTRL_PANEL" isContent="false"> + <bbNG:breadcrumb>LAMS Author</bbNG:breadcrumb> + </bbNG:breadcrumbBar> + + <bbNG:pageHeader> + <bbNG:pageTitleBar title="LAMS Author" /> + </bbNG:pageHeader> + + To launch LAMS Author, please, click <a href="#" onclick="openAuthor(); return false;">here</a>. + </bbNG:learningSystemPage> </bbData:context> Index: lams_bb_integration/web/links/monitor.jsp =================================================================== diff -u -r5f248b5997c5cab966ecf8920a89e22745758859 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/web/links/monitor.jsp (.../monitor.jsp) (revision 5f248b5997c5cab966ecf8920a89e22745758859) +++ lams_bb_integration/web/links/monitor.jsp (.../monitor.jsp) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -1,152 +1,13 @@ -<%@ page import="java.util.*, java.net.*, - java.text.SimpleDateFormat, - blackboard.data.*, - blackboard.persist.*, - blackboard.data.course.*, - blackboard.data.user.*, - blackboard.data.navigation.*, - blackboard.persist.course.*, - blackboard.persist.navigation.*, - blackboard.data.content.*, - blackboard.persist.content.*, - blackboard.db.*, - blackboard.base.*, - blackboard.platform.*, - blackboard.platform.plugin.*, - blackboard.platform.persistence.*, - org.lamsfoundation.ld.integration.*, - org.lamsfoundation.ld.integration.blackboard.*" errorPage="error.jsp" %> +<%@ page contentType="text/html; charset=utf-8" language="java"%> +<%@ page isELIgnored="false" %> + +<!DOCTYPE HTML> +<%@ page errorPage="error.jsp"%> <%@ taglib uri="/bbNG" prefix="bbNG"%> <%@ taglib uri="/bbData" prefix="bbData"%> +<%@ taglib uri="/tags-core" prefix="c"%> <bbData:context id="ctx"> -<%! -public static String extractParameterValue(String url, String param) { - if (url != null && param != null) { - int quotationMarkIndex = url.indexOf("?"); - String queryPart = quotationMarkIndex > -1 ? url.substring(quotationMarkIndex + 1) : url; - String[] paramEntries = queryPart.split("&"); - for (String paramEntry : paramEntries) { - String[] paramEntrySplitted = paramEntry.split("="); - if ((paramEntrySplitted.length > 1) && param.equalsIgnoreCase(paramEntrySplitted[0])) { - return paramEntrySplitted[1]; - } - } - } - return null; -} -public String getChild(Content f, ContentDbLoader cLoader) { - StringBuilder sb = new StringBuilder(); - try { - - if (f.getIsFolder()) { - - BbList<Content> cList = cLoader.loadChildren(f.getId()); - Content[] cArray = cList.toArray(new Content[0]); - //sort content by title - Arrays.sort(cArray, new Comparator<Content>() { - @Override - public int compare(Content o1, Content o2) { - if (o1 != null && o2 != null) { - return o1.getTitle().compareToIgnoreCase(o2.getTitle()); - } else if (o1 != null) - return 1; - else - return -1; - } - }); - - String title = f.getTitle(); - if (title.indexOf("'") != -1) { - title = title.replace("'", "\\'"); - } - sb.append("{type:'Text', label:'" + title + "', id:0"); - - if (cArray.length == 0) { - sb.append(", expanded:0, children:[{type:'HTML', html:'<i>null</i>', id:0}]}"); - return sb.toString(); - - } else { - sb.append(", children:["); - sb.append(getChild(cArray[0], cLoader)); - for (int i = 1; i < cArray.length; i++) { - sb.append(", ").append(getChild(cArray[i], cLoader)); - } - sb.append("]}"); - } - return sb.toString(); - - } else { - - if (f.getContentHandler().equals("resource/x-lams-lamscontent")) { - String strUrl = f.getUrl(); - String strId = extractParameterValue(strUrl, "lsid"); - String strTitle = f.getTitle().replace("'", "\\'"); - sb.append("{type:'Text', label:'" + strTitle + "', id:'" + strId + "'}"); - // return sb.toString(); - - } else if (f.getContentHandler().equals("resource/x-ntu-hdllams")) { - String strUrl = f.getUrl(); - String strId = "0"; - if (strUrl.indexOf("&seq_id=") != -1) { - int pos1 = strUrl.indexOf("&seq_id=") + 8; -// int pos2 = strUrl.indexOf("&", pos1); - strId = strUrl.substring(pos1); - } - String strTitle = f.getTitle().replace("'", "\\'"); - sb.append("{type:'Text', label:'" + strTitle + "', id:'" + strId + "'}"); - - } else { - // sb.append("{type:'HTML', html:'<i>null</i>', id:0}"); - } - return sb.toString(); - } - - } catch (Exception e) { - return sb.toString(); - } -} -%> - -<% - //check permission - if (!PlugInUtil.authorizeForCourseControlPanel(request, response)) { - return; - } - - BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); - Container bbContainer = bbPm.getContainer(); - - ContentDbLoader cLoader = (ContentDbLoader) bbPm.getLoader( ContentDbLoader.TYPE ); - - CourseTocDbLoader ctLoader = (CourseTocDbLoader) bbPm.getLoader(CourseTocDbLoader.TYPE); - Id courseId = new PkId(bbContainer, Course.DATA_TYPE, request.getParameter("course_id")); - Course course = ctx.getCourse(); - BbList ctList = ctLoader.loadByCourseId(courseId); - CourseToc[] courseTocs = (CourseToc[]) ctList.toArray(new CourseToc[0]); - String strOut = "[[]]"; - int idx = 0; - StringBuilder strB = new StringBuilder(); - strB.append("[{type:'Text', label:'" + course.getTitle().replace("'", "\\'") + "', id:0, children:["); - for (int i = 0; i < courseTocs.length; i++) { - if (courseTocs[i].getTargetType().compareTo(CourseToc.Target.CONTENT) == 0) { - Content cont = cLoader.loadByTocId(courseTocs[i].getId()); - strB.append(getChild(cont, cLoader)); - idx = i; - break; - } - } - for (int i = idx + 1; i < courseTocs.length; i++) { - if (courseTocs[i].getTargetType().compareTo(CourseToc.Target.CONTENT) == 0) { - Content cont = cLoader.loadByTocId(courseTocs[i].getId()); - strB.append(", ").append(getChild(cont, cLoader)); - } - } - strB.append("]}]"); - strOut = strB.toString(); - - String monitorURL = "monitoring.jsp?course_id=" + course.getId().toExternalString(); -%> <bbNG:learningSystemPage contextOverride="CTRL_PANEL"> <bbNG:cssFile href="../includes/css/treeview.css" /> <bbNG:cssFile href="../includes/css/folders.css" /> @@ -164,6 +25,7 @@ <bbNG:jsFile href="includes/javascript/yahoo-dom-event.js" /> <bbNG:jsFile href="includes/javascript/treeview-min.js" /> <bbNG:jsFile href="includes/javascript/jquery.js" /> + <bbNG:jsFile href="includes/javascript/openLamsPage.js" /> <bbNG:breadcrumbBar environment="CTRL_PANEL" isContent="false"> <bbNG:breadcrumb>LAMS Monitor</bbNG:breadcrumb> @@ -175,7 +37,7 @@ <%-- Monitor Button --%> <div id="buttons"> <span id="monitor-button" class="yui-button yui-link-button"> - <button onclick="openMonitor(); return false;"> + <button onclick="openMonitor('${param.course_id}', sequenceId); return false;"> Monitor this lesson </button> </span> @@ -189,7 +51,7 @@ <div id="treeDiv"></div> <bbNG:jsBlock> - <script language="JavaScript" type="text/javascript"> + <script type="text/javascript"> var $j = jQuery.noConflict(); @@ -227,34 +89,8 @@ document.getElementById('monitor-button').style.visibility=visibility; document.getElementById('sync-button').style.visibility=visibility; } - - // Open the LAMS Seuence Monitor Window - function openMonitor() { - - var monitorURL = "<%= monitorURL %>&lsid=" + sequenceId; - - if (monitorWin && !monitorWin.closed) { - try { - monitorWin.focus(); - } catch(e) { - // popups blocked by a 3rd party - alert("Pop-up windows have been blocked by your browser. Please allow pop-ups for this site and try again"); - } - - } else { - try { - monitorWin = window.open(monitorURL,'mWindow','width=1280,height=720,resizable,scrollbars=yes'); - monitorWin.focus(); - } catch(e) { - // popups blocked by a 3rd party - alert("Pop-up windows have been blocked by your browser. Please allow pop-ups for this site and try again"); - } - } - - return false; - } - var tree = new YAHOO.widget.TreeView("treeDiv", <%= strOut %>); + var tree = new YAHOO.widget.TreeView("treeDiv", ${treeView}); tree.getNodeByIndex(1).expand(true); tree.render(); tree.subscribe('clickEvent',function(oArgs) { Fisheye: Tag a327993967da9b51f138b3e84530a42ad3874abc refers to a dead (removed) revision in file `lams_bb_integration/web/links/monitoring.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/web/modules/create.jsp =================================================================== diff -u -r615a2ef7e23ebd72fd36a62324e12a82fe2e1ac1 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/web/modules/create.jsp (.../create.jsp) (revision 615a2ef7e23ebd72fd36a62324e12a82fe2e1ac1) +++ lams_bb_integration/web/modules/create.jsp (.../create.jsp) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -10,21 +10,18 @@ Step 1 - create.jsp Step 2 - /LessonManager?method=start --%> -<%@ 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.util.LamsSecurityUtil"%> <%@ page errorPage="/error.jsp"%> <%@ taglib uri="/bbNG" prefix="bbNG"%> +<%@ taglib uri="/tags-core" prefix="c"%> <bbNG:genericPage title="Add New LAMS" ctxId="ctx"> -<bbNG:jsFile href="includes/javascript/yahoo-dom-event.js" /> -<bbNG:jsFile href="includes/javascript/treeview-min.js" /> -<bbNG:jsFile href="includes/javascript/jquery.js" /> - <bbNG:cssFile href="../includes/css/treeview.css" /> <bbNG:cssFile href="../includes/css/folders.css" /> +<bbNG:jsFile href="includes/javascript/yahoo-dom-event.js" /> +<bbNG:jsFile href="includes/javascript/treeview-min.js" /> +<bbNG:jsFile href="includes/javascript/jquery.js" /> +<bbNG:jsFile href="includes/javascript/openLamsPage.js" /> <bbNG:jsBlock> <script type="text/javascript"> var $j = jQuery.noConflict(); @@ -42,7 +39,7 @@ // load subfolder contents $j.ajax({ url : '../LamsLearningDesign', - data : 'courseId=<%=ctx.getCourse().getCourseId()%>&folderId=' + folderId, + data : 'course_id=${param.course_id}&folderId=' + folderId, cache : false, async: false, dataType : 'json', @@ -114,8 +111,8 @@ <%-- Form to Collect ID of Selected LAMS Sequence --%> <form name="lesson_form" id="lesson_form" action="../LessonManager?method=start" method="post" onSubmit="return confirmSubmit();"> - <input type="hidden" name="content_id" value="<%=request.getParameter("content_id")%>"> - <input type="hidden" name="course_id" value="<%=request.getParameter("course_id")%>"> + <input type="hidden" name="content_id" value="${param.content_id}"> + <input type="hidden" name="course_id" value="${param.course_id}"> <input type="hidden" name="sequence_id" id="sequence_id" value="0"> <bbNG:dataCollection> @@ -198,39 +195,11 @@ var authorWin = null; var previewWin = null; var isSelected = false; - - // Open the LAMS Seuence Author Window - function openAuthor() { - var authorUrl = '../openLamsPage?method=openAuthor&course_id=<%=request.getParameter("course_id")%>&content_id=<%=request.getParameter("content_id")%>'; - - if(authorWin && !authorWin.closed){ - try { - authorWin.focus(); - }catch(e){ - // popups blocked by a 3rd party - alert("Pop-up windows have been blocked by your browser. Please allow pop-ups for this site and try again"); - } - } - else{ - try { - authorWin = window.open(authorUrl,'aWindow','width=1280,height=720,resizable,scrollbars=yes'); - authorWin.focus(); - }catch(e){ - // popups blocked by a 3rd party - alert("Pop-up windows have been blocked by your browser. Please allow pop-ups for this site and try again"); - } - } - return false; - } - function unloadHandler(m){ - - } - // Open the LAMS Seuence Preview Window function openPreview() { - var previewUrl = "../openLamsPage?method=openPreview&course_id=<%=request.getParameter("course_id")%>&ldId=" + document.getElementsByName("sequence_id")[0].value + "&title=" + document.lesson_form.title.value; + var previewUrl = "../openLamsPage?method=openPreview&ldId=" + document.getElementsByName("sequence_id")[0].value + "&title=" + document.lesson_form.title.value; if (previewWin && !previewWin.closed) { try { Index: lams_bb_integration/web/modules/lamsServerDown.jsp =================================================================== diff -u -rdcd309de058219ef41f76000936b9136eedb0d70 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/web/modules/lamsServerDown.jsp (.../lamsServerDown.jsp) (revision dcd309de058219ef41f76000936b9136eedb0d70) +++ lams_bb_integration/web/modules/lamsServerDown.jsp (.../lamsServerDown.jsp) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -11,6 +11,7 @@ <%@ page import="java.io.PrintWriter"%> <%@ page isErrorPage = "true" %> <%@ taglib uri="/bbNG" prefix="bbNG"%> +<%@ taglib uri="/tags-core" prefix="c"%> <bbNG:genericPage title="LAMS Server Timeout"> <bbNG:receipt type="FAIL" iconUrl="/images/ci/icons/receiptfail_u.gif" Index: lams_bb_integration/web/modules/learnermonitor.jsp =================================================================== diff -u -rdcd309de058219ef41f76000936b9136eedb0d70 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/web/modules/learnermonitor.jsp (.../learnermonitor.jsp) (revision dcd309de058219ef41f76000936b9136eedb0d70) +++ lams_bb_integration/web/modules/learnermonitor.jsp (.../learnermonitor.jsp) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -1,3 +1,7 @@ +<%@ page contentType="text/html; charset=utf-8" language="java"%> +<%@ page isELIgnored="false" %> +<jsp:include page="/LearnerMonitor" /> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <%-- Original Version: 2007 LAMS Foundation @@ -10,30 +14,10 @@ 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.persist.gradebook.*"%> -<%@ page import="blackboard.data.gradebook.*"%> -<%@ page import="blackboard.db.*"%> -<%@ page import="blackboard.base.*"%> -<%@ page import="blackboard.platform.*"%> <%@ page import="blackboard.platform.plugin.*"%> -<%@ page import="blackboard.platform.persistence.*"%> -<%@ page import="blackboard.portal.servlet.*"%> -<%@ page import="blackboard.portal.data.*"%> -<%@ page import="org.lamsfoundation.ld.integration.util.*"%> -<%@ page import="org.lamsfoundation.ld.integration.dto.LearnerProgressDTO"%> <%@ page errorPage="/error.jsp"%> <%@ taglib uri="/bbNG" prefix="bbNG"%> +<%@ taglib uri="/tags-core" prefix="c"%> <bbNG:genericPage title="LAMS Options" ctxId="ctx"> @@ -66,185 +50,77 @@ } </style> </bbNG:cssBlock> - + + <bbNG:jsFile href="includes/javascript/openLamsPage.js" /> + <% - BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); - CourseMembershipDbLoader sessionCourseMembershipLoader = CourseMembershipDbLoader.Default.getInstance(); - // Authorise current user for Course Access (automatic redirect) try{ if (!PlugInUtil.authorizeForCourse(request, response)) return; } catch(PlugInException e) { throw new RuntimeException(e); } - - String strLessonId = request.getParameter("lsid").trim(); - long lessonId = Long.parseLong(strLessonId); - String courseIdParam = request.getParameter("course_id"); - - // Get Course ID and User ID - Id course_id = bbPm.generateId(Course.DATA_TYPE, courseIdParam); - Id userId = ctx.getUser().getId(); - - // Get the membership data to determine the User's Role - CourseMembership courseMembership = null; - CourseMembership.Role courseRole = null; - boolean isActive = false; - - try { - courseMembership = sessionCourseMembershipLoader.loadByCourseAndUserId(course_id, userId); - 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(); - } - - // Is the User an Instructor of Teaching Assistant - boolean instructorstr=false; - if (CourseMembership.Role.INSTRUCTOR.equals(courseRole) || CourseMembership.Role.TEACHING_ASSISTANT.equals(courseRole) - || CourseMembership.Role.COURSE_BUILDER.equals(courseRole)) { - instructorstr=true; - - } else if (!CourseMembership.Role.STUDENT.equals(courseRole)) { - // 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); - } - - //Get lessson's title and description - String title = ""; - String description = ""; - String strLineitemId = null; - String position = "unknown"; - //contentId is available in versions after 1.2.3 - String contentIdParam = request.getParameter("content_id"); - if (contentIdParam != null) { - - Container bbContainer = bbPm.getContainer(); - Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, contentIdParam); - ContentDbLoader courseDocumentLoader = (ContentDbLoader) bbPm.getLoader(ContentDbLoader.TYPE); - Content courseDoc = (Content) courseDocumentLoader.loadById(contentId); - title = courseDoc.getTitle(); - description = courseDoc.getBody().getFormattedText(); - position = String.valueOf(courseDoc.getPosition()); - - //get lineitemid from the storage - Lineitem lineitem = LineitemUtil.getLineitem(contentIdParam, userId, strLessonId); - - } else { - - title = (request.getParameter("title") != null) ? request.getParameter("title") : "LAMS Options"; - description = request.getParameter("description"); - strLineitemId = request.getParameter("lineitemid"); - } - - //display learning design image - String strIsDisplayDesignImage = request.getParameter("isDisplayDesignImage"); - boolean isDisplayDesignImage = "true".equals(strIsDisplayDesignImage) ? true : false; - String learningDesignImageUrl = ""; - if (isDisplayDesignImage) { - String username = ctx.getUser().getUserName(); - learningDesignImageUrl = LamsSecurityUtil.generateRequestLearningDesignImage(username) + "&lsId=" + lessonId; - } - - //check whether user has score for this lesson - Score current_score = null; - if (strLineitemId != null) { // there won't be "lineitemid" parameter in case lesson had been created in LAMS building block version prior to 1.2 - - //check if it was created in old versions (e.g. 1.2.1) where lineitemId parameter had the following format "PkId(key=_XXXX_1, %20dataType=blackboard.data.gradebook.impl.OutcomeDefinition, %20container=blackboard.persist.DatabaseContainer@xxxx)" - //in which case transform it to the more regular one - if (strLineitemId.contains("key=")) { - int pos1 = strLineitemId.indexOf("key=") + 4; - int pos2 = strLineitemId.indexOf(",", pos1); - - if (pos1 != -1 && pos2 != -1 && pos1 <= pos2 && pos2 <= strLineitemId.length()) { - strLineitemId = strLineitemId.substring(pos1, pos2); - } - } - - Id lineitemId = bbPm.generateId(Lineitem.LINEITEM_DATA_TYPE, strLineitemId.trim()); - ScoreDbLoader scoreLoader = (ScoreDbLoader) bbPm.getLoader(ScoreDbLoader.TYPE); - try { - current_score = scoreLoader.loadByCourseMembershipIdAndLineitemId(courseMembership.getId(), - lineitemId); - } catch (KeyNotFoundException c) { - //no score availalbe - } - } - boolean isScoreAvailable = (current_score != null); - - //prepare learnerProgressDto for displaying on jsp - LearnerProgressDTO learnerProgressDto = LamsSecurityUtil.getLearnerProgress(ctx, lessonId); %> - <%-- Page Header --%> <bbNG:pageHeader> - <bbNG:pageTitleBar title="<%=title%>"/> + <bbNG:pageTitleBar title="${title}"/> </bbNG:pageHeader> <%-- Action Control Bar --%> <bbNG:actionControlBar> <bbNG:actionButton id="open_learner" url="javascript:openLearner();" title="Open Lesson" primary="true"/> <%-- Access the Lesson as a Learner --%> - <% if(instructorstr) { %> - <bbNG:actionButton id="open_monitor" url="javascript:openMonitor();" title="Open Monitor" primary="true"/> <%-- Access the Monitor --%> - <% } %> + <c:if test="${isInstructor}"> + <bbNG:actionButton id="open_monitor" url="javascript:openMonitor('${param.course_id}', '${param.lsid}');" title="Open Monitor" primary="true"/> <%-- Access the Monitor --%> + </c:if> <bbNG:actionButton id="cancel" url="javascript:back();" title="Cancel" primary="false"/> <%-- Cancel (Go Back) --%> </bbNG:actionControlBar> - - <!-- Position <%=position%> --> - <% if((description != "") && (description != null)) { %> + <c:if test='${description != null && description != ""}'> <div class="vtbegenerated"> - <%=description%> + ${description} </div> - <% } %> + </c:if> - <% if(isDisplayDesignImage) { %> + <c:if test="${isDisplayDesignImage}"> <div style="text-align: center; margin-top: 10px;"> - <img src="<%=learningDesignImageUrl%>"> + <img src="${learningDesignImageUrl}"> </div> - <% } %> + </c:if> - <% if(learnerProgressDto.getAttemptedActivities() > 0 || learnerProgressDto.getLessonComplete()) { %> + <c:if test="${attemptedActivitiesCount > 0 || isLessonCompleted}"> <div id="progress-area"> <div class="progress-header"> Your Lesson Progress </div> - <% if(!learnerProgressDto.getLessonComplete()) { %> + <c:choose> + <c:when test="${!isLessonCompleted}"> <p class="left-text-align"> Lesson is not yet completed. </p> <p class="left-text-align"> - You have completed: <%=learnerProgressDto.getActivitiesCompleted()%> out of approximately <%=learnerProgressDto.getActivityCount()%> activities + You have completed: ${activitiesCompletedCount} out of approximately ${activitiesCount} activities <span class="super">[*]</span> </p> <div class="smalltext"> <span class="super">*</span> Total activities depend on your learning path. </div> - - <% } else { %> + </c:when> + <c:otherwise> <p> You have completed this lesson. </p> - <% } %> + </c:otherwise> + </c:choose> </div> - <% } %> + </c:if> <bbNG:jsBlock> - <script language="JavaScript" type="text/javascript"> + <script type="text/javascript"> var learnerWin = null; var monitorWin = null; @@ -255,7 +131,7 @@ // Open the Lesson as a Learner function openLearner() { - var learnerUrl = '../openLamsPage?method=openLearner&course_id=<%=request.getParameter("course_id")%>&content_id=<%=request.getParameter("content_id")%>&lsid=<%=request.getParameter("lsid")%>'; + var learnerUrl = '../openLamsPage?method=openLearner&course_id=${param.course_id}&content_id=${param.content_id}&lsid=${param.lsid}'; if (learnerWin && !learnerWin.closed) { try { learnerWin.focus(); @@ -273,28 +149,6 @@ } } } - - // Open the Lesson Monitor - function openMonitor() { - var monitorUrl = '../openLamsPage?method=openMonitor&course_id=<%=request.getParameter("course_id")%>&content_id=<%=request.getParameter("content_id")%>&lsid=<%=request.getParameter("lsid")%>'; - if(monitorWin && !monitorWin.closed) { - try { - monitorWin.focus(); - } catch(e) { - // popups blocked by a 3rd party - alert("Pop-up windows have been blocked by your browser. Please allow pop-ups for this site and try again"); - } - } else { - try { - monitorWin = window.open(monitorUrl,'aWin','width=1280,height=720,resizable=1,scrollbars=yes'); - monitorWin.opener = self; - monitorWin.focus(); - } catch(e) { - // popups blocked by a 3rd party - alert("Pop-up windows have been blocked by your browser. Please allow pop-ups for this site and try again"); - } - } - } </script> </bbNG:jsBlock> Index: lams_bb_integration/web/modules/modify.jsp =================================================================== diff -u -r615a2ef7e23ebd72fd36a62324e12a82fe2e1ac1 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/web/modules/modify.jsp (.../modify.jsp) (revision 615a2ef7e23ebd72fd36a62324e12a82fe2e1ac1) +++ lams_bb_integration/web/modules/modify.jsp (.../modify.jsp) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -26,8 +26,8 @@ <%-- Form for the LAMS Lesson Attributes --%> <form name="lams_form" id="lams_form" action="../LessonManager?method=modify" method="post" onSubmit="return validateModify();"> - <input type="hidden" name="content_id" value="<%=request.getParameter("content_id")%>"> - <input type="hidden" name="course_id" value="<%=request.getParameter("course_id")%>"> + <input type="hidden" name="content_id" value="${param.content_id}"> + <input type="hidden" name="course_id" value="${param.course_id}"> <bbNG:dataCollection> @@ -95,7 +95,7 @@ </form> <bbNG:jsBlock> - <script language="JavaScript" type="text/javascript"> + <script type="text/javascript"> // Go back one page if the user clicks the Cancel Button function back() { Index: lams_bb_integration/web/modules/modifyLessonSuccess.jsp =================================================================== diff -u -r615a2ef7e23ebd72fd36a62324e12a82fe2e1ac1 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/web/modules/modifyLessonSuccess.jsp (.../modifyLessonSuccess.jsp) (revision 615a2ef7e23ebd72fd36a62324e12a82fe2e1ac1) +++ lams_bb_integration/web/modules/modifyLessonSuccess.jsp (.../modifyLessonSuccess.jsp) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -11,6 +11,7 @@ --%> <%@ page errorPage="/error.jsp"%> <%@ taglib uri="/bbNG" prefix="bbNG"%> +<%@ taglib uri="/tags-core" prefix="c"%> <bbNG:genericPage title="Modify A LAMS Lesson" ctxId="ctx"> <%-- Breadcrumbs --%> Index: lams_bb_integration/web/modules/notAllowed.jsp =================================================================== diff -u -rdcd309de058219ef41f76000936b9136eedb0d70 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/web/modules/notAllowed.jsp (.../notAllowed.jsp) (revision dcd309de058219ef41f76000936b9136eedb0d70) +++ lams_bb_integration/web/modules/notAllowed.jsp (.../notAllowed.jsp) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -11,6 +11,7 @@ <%@ page import="java.io.PrintWriter"%> <%@ page isErrorPage = "true" %> <%@ taglib uri="/bbNG" prefix="bbNG"%> +<%@ taglib uri="/tags-core" prefix="c"%> <bbNG:genericPage title="Access Denied"> <bbNG:receipt type="FAIL" iconUrl="/images/ci/icons/receiptfail_u.gif" Index: lams_bb_integration/web/modules/startLessonSuccess.jsp =================================================================== diff -u -rdcd309de058219ef41f76000936b9136eedb0d70 -ra327993967da9b51f138b3e84530a42ad3874abc --- lams_bb_integration/web/modules/startLessonSuccess.jsp (.../startLessonSuccess.jsp) (revision dcd309de058219ef41f76000936b9136eedb0d70) +++ lams_bb_integration/web/modules/startLessonSuccess.jsp (.../startLessonSuccess.jsp) (revision a327993967da9b51f138b3e84530a42ad3874abc) @@ -10,6 +10,7 @@ --%> <%@ page errorPage="/error.jsp"%> <%@ taglib uri="/bbNG" prefix="bbNG"%> +<%@ taglib uri="/tags-core" prefix="c"%> <bbNG:genericPage title="LAMS Learning Activity Management System" ctxId="ctx"> <%-- Breadcrumbs --%>