Index: lams_admin/.classpath =================================================================== diff -u -r9e2dc03fe28e3c80540446ea36654baeb862a888 -rff01a6c237cefc4a5186889bf46041152cfc37ae --- lams_admin/.classpath (.../.classpath) (revision 9e2dc03fe28e3c80540446ea36654baeb862a888) +++ lams_admin/.classpath (.../.classpath) (revision ff01a6c237cefc4a5186889bf46041152cfc37ae) @@ -17,5 +17,10 @@ + + + + + Index: lams_admin/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -rfef07b985628ec48d8ec6948f4c75b640308e450 -rff01a6c237cefc4a5186889bf46041152cfc37ae --- lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision fef07b985628ec48d8ec6948f4c75b640308e450) +++ lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision ff01a6c237cefc4a5186889bf46041152cfc37ae) @@ -507,5 +507,15 @@ config.user.validation.emails =Enforce properly formatted emails config.cache.refresh =Configuration cache refresh interval (minutes) +tool.groups.open.button =Manage tool groups +tool.groups.open.button.tooltip =Assign tools to groups for later use in Authoring +tool.groups.dialog.title =Tool groups management +tool.groups.dialog.instructions =Manage groups by dragging and dropping tools +tool.groups.add.group.button =Add group +tool.groups.remove.group.button.tooltip =Remove group +tool.groups.group.default.name =Untitled +tool.groups.remove.confirm =Are you sure you want to remove this group? +tool.groups.group.name.error =A group name can not be blank +tool.groups.save.error =Error while saving groups #======= End labels: Exported 500 labels for en AU ===== Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ToolContentListAction.java =================================================================== diff -u -rd5655905b56e2063bc3854df756ef16572d2c745 -rff01a6c237cefc4a5186889bf46041152cfc37ae --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ToolContentListAction.java (.../ToolContentListAction.java) (revision d5655905b56e2063bc3854df756ef16572d2c745) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ToolContentListAction.java (.../ToolContentListAction.java) (revision ff01a6c237cefc4a5186889bf46041152cfc37ae) @@ -23,11 +23,13 @@ /* $Id$ */ package org.lamsfoundation.lams.admin.web; +import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -40,7 +42,12 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.apache.tomcat.util.json.JSONArray; +import org.apache.tomcat.util.json.JSONException; +import org.apache.tomcat.util.json.JSONObject; import org.lamsfoundation.lams.admin.service.AdminServiceProxy; +import org.lamsfoundation.lams.learningdesign.LearningLibrary; +import org.lamsfoundation.lams.learningdesign.LearningLibraryGroup; import org.lamsfoundation.lams.learningdesign.dto.LearningLibraryDTO; import org.lamsfoundation.lams.learningdesign.dto.LibraryActivityDTO; import org.lamsfoundation.lams.learningdesign.service.ILearningDesignService; @@ -60,6 +67,7 @@ * @struts:action path="/toolcontentlist" scope="request" validate="false" * * @struts:action-forward name="toolcontentlist" path=".toolcontentlist" + * @struts:action-forward name="groups" path="/toolcontent/learningLibraryGroup.jsp" * @struts.action-forward name="error" path=".error" */ public class ToolContentListAction extends Action { @@ -75,21 +83,24 @@ private static final String ATTRIBUTE_DATABASE_VERSIONS = "dbVersions"; private static final String FORWARD_SUCCESS = "toolcontentlist"; + private static final String FORWARD_GROUPS = "groups"; private static final String FORWARD_ERROR = "error"; private static final String ACTION_ENABLE = "enable"; private static final String ACTION_DISABLE = "disable"; + private static final String ACTION_OPEN_GROUPS = "openLearningLibraryGroups"; + private static final String ACTION_SAVE_GROUPS = "saveLearningLibraryGroups"; private static final String QUERY_DATABASE_VERSIONS = "select system_name, patch_level from patches"; private static ILearningDesignService learningDesignService; private static IUserManagementService userManagementService; private static DataSource dataSource; + @SuppressWarnings("unchecked") @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { - // check permission if (!(request.isUserInRole(Role.SYSADMIN) || request.isUserInRole(Role.AUTHOR_ADMIN))) { request.setAttribute(ToolContentListAction.ATTRIBUTE_ERROR_NAME, "ToolContentListAction"); @@ -99,7 +110,7 @@ "error.authorisation")); return mapping.findForward(ToolContentListAction.FORWARD_ERROR); } - + // not just display, but enable/disable a learning library String param = request.getParameter(ToolContentListAction.PARAM_ACTION); if (StringUtils.equals(param, ToolContentListAction.ACTION_ENABLE)) { @@ -108,14 +119,17 @@ } else { return mapping.findForward(ToolContentListAction.FORWARD_ERROR); } - } else { - if (StringUtils.equals(param, ToolContentListAction.ACTION_DISABLE)) { - if (checkPriviledge(request)) { - disableLibrary(mapping, form, request, response); - } else { - return mapping.findForward(ToolContentListAction.FORWARD_ERROR); - } + } else if (StringUtils.equals(param, ToolContentListAction.ACTION_DISABLE)) { + if (checkPriviledge(request)) { + disableLibrary(mapping, form, request, response); + } else { + return mapping.findForward(ToolContentListAction.FORWARD_ERROR); } + } else if (StringUtils.equals(param, ToolContentListAction.ACTION_OPEN_GROUPS)) { + return openLearningLibraryGroups(mapping, form, request, response); + } else if (StringUtils.equals(param, ToolContentListAction.ACTION_SAVE_GROUPS)) { + saveLearningLibraryGroups(mapping, form, request, response); + return null; } // get learning library dtos and their validity @@ -150,6 +164,7 @@ } // returns full list of learning libraries, valid or not + @SuppressWarnings("unchecked") private ArrayList filterMultipleToolEntries(List learningLibraryDTOs, HashMap learningLibraryValidity) { ArrayList activeTools = new ArrayList(); @@ -220,6 +235,73 @@ } + /** + * Loads groups and libraries and displays the management dialog. + */ + private ActionForward openLearningLibraryGroups(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws JSONException, IOException { + // build full list of available learning libraries + List learningLibraries = getLearningDesignService().getAllLearningLibraryDetails( + getUserLanguage()); + JSONArray learningLibrariesJSON = new JSONArray(); + for (LearningLibraryDTO learningLibrary : learningLibraries) { + JSONObject learningLibraryJSON = new JSONObject(); + learningLibraryJSON.put("learningLibraryId", learningLibrary.getLearningLibraryID()); + learningLibraryJSON.put("title", learningLibrary.getTitle()); + learningLibrariesJSON.put(learningLibraryJSON); + } + request.setAttribute("learningLibraries", learningLibrariesJSON.toString()); + + // build list of existing groups + List groups = getLearningDesignService().getLearningLibraryGroups(); + JSONArray groupsJSON = new JSONArray(); + for (LearningLibraryGroup group : groups) { + JSONObject groupJSON = new JSONObject(); + groupJSON.put("groupId", group.getGroupId()); + groupJSON.put("name", group.getName()); + for (LearningLibrary learningLibrary : group.getLearningLibraries()) { + JSONObject learningLibraryJSON = new JSONObject(); + learningLibraryJSON.put("learningLibraryId", learningLibrary.getLearningLibraryId()); + learningLibraryJSON.put("title", learningLibrary.getTitle()); + groupJSON.append("learningLibraries", learningLibraryJSON); + } + groupsJSON.put(groupJSON); + } + request.setAttribute("groups", groupsJSON.toString()); + + return mapping.findForward(ToolContentListAction.FORWARD_GROUPS); + } + + + private void saveLearningLibraryGroups(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws JSONException, IOException { + // extract groups from JSON and persist them + JSONArray groupsJSON = new JSONArray(request.getParameter("groups")); + List groups = new ArrayList(groupsJSON.length()); + + for (int groupIndex = 0; groupIndex < groupsJSON.length(); groupIndex++) { + LearningLibraryGroup group = new LearningLibraryGroup(); + groups.add(group); + + JSONObject groupJSON = groupsJSON.getJSONObject(groupIndex); + long groupId = groupJSON.optLong("groupId"); + if (groupId > 0) { + group.setGroupId(groupId); + } + group.setName(groupJSON.getString("name")); + + group.setLearningLibraries(new HashSet()); + JSONArray learningLibrariesJSON = groupJSON.getJSONArray("learningLibraries"); + for (int learningLibraryIndex = 0; learningLibraryIndex < learningLibrariesJSON.length(); learningLibraryIndex++) { + long learningLibraryId = learningLibrariesJSON.getLong(learningLibraryIndex); + LearningLibrary learningLibrary = getLearningDesignService().getLearningLibrary(learningLibraryId); + group.getLearningLibraries().add(learningLibrary); + } + } + + getLearningDesignService().saveLearningLibraryGroups(groups); + } + private ILearningDesignService getLearningDesignService() { if (ToolContentListAction.learningDesignService == null) { WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() Index: lams_admin/web/css/learningLibraryGroup.css =================================================================== diff -u --- lams_admin/web/css/learningLibraryGroup.css (revision 0) +++ lams_admin/web/css/learningLibraryGroup.css (revision ff01a6c237cefc4a5186889bf46041152cfc37ae) @@ -0,0 +1,93 @@ +html, body { + height: 100%; +} + +div#titleDiv { + padding: 3px 5px; + font-size: small; + font-weight: bold; + border-bottom: thin dotted #2E6E9E; +} + +table#groupsTable { + height: 375px; +} + +table#groupsTable td { + vertical-align: top; +} + +td#learningLibraryCell { + width: 200px; + padding: 5px; + border-right: thin dotted #2E6E9E; +} + +#groupTemplate { + display: none; +} + +#newGroupPlaceholder { + border: thin dashed #2E6E9E; + cursor: pointer; +} + +#newGroupPlaceholder > div { + text-align: center; + margin: 60px 5px 0 5px; +} + +.groupContainer { + float: left; + width: 180px; + height: 150px; + margin: 0 10px 10px 0; + padding: 5px; + border: thin solid #2E6E9E; +} + +.learningLibraryContainerTitle { + font-weight: bold; + text-align: center; +} + +.removeGroupButton { + float: left; + cursor: pointer; + width: 16px; + height: 16px; +} + +.learningLibraryContainer { + overflow: auto; + height: 123px; + margin-top: 5px; +} + +td#learningLibraryCell .learningLibraryContainer { + height: 100%; +} + +.groupContainer input { + width: 135px; + margin-right: 5px; +} + +.groupContainer .removeGroupButton { + padding-top: 3px; +} + +.draggableLearningLibrary { + padding: 3px 0px 3px 0px; + cursor: default; +} + +.droppableHighlight { + padding : 1px !important; + border: 5px solid #5c9ccc !important; +} + +.draggableLearningLibrarySelected { + background-color: #5c9ccc !important; + color: white !important; +} \ No newline at end of file Index: lams_admin/web/file/lams_groups_template.xls =================================================================== diff -u -rb7008b95e3f3054ee6f3696a0579e34a197201ca -rff01a6c237cefc4a5186889bf46041152cfc37ae Binary files differ Index: lams_admin/web/file/lams_roles_template.xls =================================================================== diff -u -r35da7c79459d1e4ecc8a599e72abef1f5f8a69bf -rff01a6c237cefc4a5186889bf46041152cfc37ae Binary files differ Index: lams_admin/web/file/lams_users_template.xls =================================================================== diff -u -r35da7c79459d1e4ecc8a599e72abef1f5f8a69bf -rff01a6c237cefc4a5186889bf46041152cfc37ae Binary files differ Index: lams_admin/web/includes/javascript/learningLibraryGroup.js =================================================================== diff -u --- lams_admin/web/includes/javascript/learningLibraryGroup.js (revision 0) +++ lams_admin/web/includes/javascript/learningLibraryGroup.js (revision ff01a6c237cefc4a5186889bf46041152cfc37ae) @@ -0,0 +1,248 @@ +var lastSelected = {}; + +$(document).ready(function(){ + // show all learning libraries on the left + fillGroup(learningLibraries, $('#learningLibraryCell')); + // add existing groups + $.each(groups, function(){ + var group = addGroup(this); + }); + + $('#newGroupPlaceholder').click(function(){ + addGroup(); + }); +}); + + +/** + * Add a group and fills it with given learning libraries; + */ +function addGroup(groupData) { + var group = $('#groupTemplate').clone() + .attr({ + // remove template's HTML ID + 'id' : null, + 'groupId' : groupData ? groupData.groupId : null + }) + .css('display', null) + .insertBefore('#newGroupPlaceholder'); + + group.find('input').val(groupData ? groupData.name : LABELS.GROUP_DEFAULT_NAME); + fillGroup(groupData ? groupData.learningLibraries : null, group); + + return group; +} + + +/** + * Makes a list of learning libraries and adds drag&drop functionality to them. + */ +function fillGroup(learningLibraries, container) { + if (learningLibraries) { + // create learning library DIVs + $.each(learningLibraries, function(index, learningLibraryJSON) { + var learningLibraryDiv = createLearningLibraryDiv(learningLibraryJSON.learningLibraryId, learningLibraryJSON.title); + $('.learningLibraryContainer', container).append(learningLibraryDiv); + }); + + colorDraggableLearningLibraries(container); + } + + $(container).droppable({ + 'activeClass' : 'droppableHighlight', + 'tolerance' : 'pointer', + 'drop' : function (event, ui) { + var draggableLearningLibraryContainer = $(ui.draggable).parent(), + thisLearningLibraryContainer = $('.learningLibraryContainer', this); + // do not do anything if it is the same container + // using "accept" feature breaks the layout + if (draggableLearningLibraryContainer[0] != thisLearningLibraryContainer[0]) { + transferLearningLibraries(draggableLearningLibraryContainer, thisLearningLibraryContainer); + } + } + }); + + $('.removeGroupButton', container).click(function(){ + removeGroup(container); + }); +} + + +/** + * Constructs a single learning library label with events. + */ +function createLearningLibraryDiv(learningLibraryId, title) { + return $('
').attr('learningLibraryId', learningLibraryId) + .addClass('draggableLearningLibrary') + .text(title) + .draggable({ + 'appendTo' : 'body', + 'containment' : '#groupsTable', + 'revert' : 'invalid', + 'distance' : 20, + 'cursor' : 'move', + 'helper' : function(event){ + // include the learning library from which dragging started + $(this).addClass('draggableLearningLibrarySelected'); + + // copy selected learning libraries + var helperContainer = $('
'); + $(this).siblings('.draggableLearningLibrarySelected').andSelf().each(function(){ + $(this).clone().appendTo(helperContainer); + }); + return helperContainer; + } + }) + + .click(function(event){ + var wasSelected = $(this).hasClass('draggableLearningLibrarySelected'), + parentId = $(this).parent().parent().attr('id'), + // this is needed for shift+click + lastSelectedLearningLibrary = lastSelected[parentId]; + + if (event.shiftKey && lastSelectedLearningLibrary && lastSelectedLearningLibrary != this) { + // clear current selection + $(this).siblings().andSelf().removeClass('draggableLearningLibrarySelected'); + + // find range of learning libraries to select + var lastSelectedIndex = $(lastSelectedLearningLibrary).index(), + index = $(this).index(). + startingElem = lastSelectedIndex > index ? this : lastSelectedLearningLibrary, + endingElem = lastSelectedIndex > index ? lastSelectedLearningLibrary : this; + + $(startingElem).nextUntil(endingElem).andSelf().add(endingElem) + .addClass('draggableLearningLibrarySelected'); + } else { + if (!event.ctrlKey) { + // clear current sleection + $(this).siblings().andSelf().removeClass('draggableLearningLibrarySelected'); + } + + if (wasSelected && !event.shiftKey){ + $(this).removeClass('draggableLearningLibrarySelected'); + lastSelected[parentId] = null; + } else { + $(this).addClass('draggableLearningLibrarySelected'); + lastSelected[parentId] = this; + } + } + }); +} + + +/** + * Move learning library DIVs from one group to another + */ +function transferLearningLibraries(fromContainer, toContainer) { + var selectedLearningLibraries = $('.draggableLearningLibrarySelected', fromContainer); + if (selectedLearningLibraries.length > 0){ + if (toContainer.parent().attr('id') == 'learningLibraryCell'){ + // just remove the selected items as they already exist in the full learning library list + selectedLearningLibraries.remove(); + } else { + // find out which learning libraries are already there and do not move them + var filteredLearningLibraries = [], + existingLearningLibraries = $('.draggableLearningLibrary', toContainer), + isAdd = fromContainer.parent().attr('id') == 'learningLibraryCell'; + $.each(selectedLearningLibraries, function(){ + var selectedLearningLibrary = $(this); + $.each(existingLearningLibraries, function(){ + if ($(this).attr('learningLibraryId') == selectedLearningLibrary.attr('learningLibraryId')){ + selectedLearningLibrary = null; + return false; + } + }); + if (selectedLearningLibrary) { + if (isAdd) { + // the selected items were pulled out from the full library list, + // so do not remove them from the source container + selectedLearningLibrary = createLearningLibraryDiv(selectedLearningLibrary.attr('learningLibraryId'), + selectedLearningLibrary.text()); + } + filteredLearningLibraries.push(selectedLearningLibrary); + } + }); + + // move the selected learning libraries + $.each(filteredLearningLibraries, function(){ + $(this).css({'top' : '0px', + 'left' : '0px', + }).removeClass('draggableLearningLibrarySelected') + .appendTo(toContainer); + }); + } + // recolour both containers + colorDraggableLearningLibraries(toContainer); + colorDraggableLearningLibraries(fromContainer); + } +} + + +function colorDraggableLearningLibraries(container) { + // every second line is different + $(container).find('div.draggableLearningLibrary').each(function(index, learningLibraryDiv){ + // exact colour should be defined in CSS, but it's easier this way... + $(this).css('background-color', index % 2 ? '#dfeffc' : 'inherit'); + }); +} + + +/** + * Remove a group from the page. + */ +function removeGroup(container) { + if (confirm(LABELS.GROUP_REMOVE_CONFIRM)){ + container.remove(); + } +} + + +/** + * Save groups and let parent window that it can close the dialog + */ +function saveGroups(){ + var groups = [], + result = false; + + $('#groupsTable .groupContainer').not('#newGroupPlaceholder').each(function(){ + var learningLibraries = $('div.draggableLearningLibrary', this), + learningLibraryIds = [], + name = $('input', this).val(); + if (!name || name.trim() == '') { + alert(LABELS.GROUP_NAME_VALIDATION_ERROR); + groups = null; + return false; + } + $.each(learningLibraries, function(){ + learningLibraryIds.push($(this).attr('learningLibraryId')); + }); + + // add the group JSON + groups.push({ + 'groupId' : $(this).attr('groupId'), + 'name' : name, + 'learningLibraries' : learningLibraryIds + }); + }); + + if (groups){ + $.ajax({ + 'async' : false, + 'cache' : false, + 'url' : 'toolcontentlist.do', + 'data' : { + 'action' : 'saveLearningLibraryGroups', + 'groups' : JSON.stringify(groups) + }, + 'type' : 'POST', + 'success' : function(){ + result = true; + }, + 'error' : function(){ + alert(LABELS.SAVE_ERROR); + } + }); + } + + return result; +} \ No newline at end of file Index: lams_admin/web/template.jsp =================================================================== diff -u -r64938df458cbab9999f9a826ef2902d061648d7d -rff01a6c237cefc4a5186889bf46041152cfc37ae --- lams_admin/web/template.jsp (.../template.jsp) (revision 64938df458cbab9999f9a826ef2902d061648d7d) +++ lams_admin/web/template.jsp (.../template.jsp) (revision ff01a6c237cefc4a5186889bf46041152cfc37ae) @@ -7,6 +7,7 @@ <fmt:message key="${title}"/> + Index: lams_admin/web/toolcontent/learningLibraryGroup.jsp =================================================================== diff -u --- lams_admin/web/toolcontent/learningLibraryGroup.jsp (revision 0) +++ lams_admin/web/toolcontent/learningLibraryGroup.jsp (revision ff01a6c237cefc4a5186889bf46041152cfc37ae) @@ -0,0 +1,57 @@ +<%@ page contentType="text/html; charset=utf-8" language="java"%> +<%@ taglib uri="tags-lams" prefix="lams"%> +<%@ taglib uri="tags-fmt" prefix="fmt"%> + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+
+
+
+
+
+
+ + +
+
+ + +
+
+
+ +
\ No newline at end of file Index: lams_admin/web/toolcontent/toolcontentlist.jsp =================================================================== diff -u -rd5655905b56e2063bc3854df756ef16572d2c745 -rff01a6c237cefc4a5186889bf46041152cfc37ae --- lams_admin/web/toolcontent/toolcontentlist.jsp (.../toolcontentlist.jsp) (revision d5655905b56e2063bc3854df756ef16572d2c745) +++ lams_admin/web/toolcontent/toolcontentlist.jsp (.../toolcontentlist.jsp) (revision ff01a6c237cefc4a5186889bf46041152cfc37ae) @@ -1,5 +1,40 @@ <%@ include file="/taglibs.jsp"%> + + + + +

@@ -12,6 +47,16 @@

+ + + + Index: lams_build/lib/lams/lams-central.jar =================================================================== diff -u -r10c87fd05c34bda4f1695bb872296803ab77faa0 -rff01a6c237cefc4a5186889bf46041152cfc37ae Binary files differ Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -rac48fd0f080c920174cce3d8b957ea1c63d965f4 -rff01a6c237cefc4a5186889bf46041152cfc37ae Binary files differ Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -re837b7b90d6cbae5ecf051b9c9ba61b3097e0c51 -rff01a6c237cefc4a5186889bf46041152cfc37ae --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision e837b7b90d6cbae5ecf051b9c9ba61b3097e0c51) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision ff01a6c237cefc4a5186889bf46041152cfc37ae) @@ -635,4 +635,5 @@ authoring.fla.page.download.wait =Please wait for the download. authoring.fla.page.download.close =Close the dialog when the download is finished. authoring.fla.page.svg.generator.title =SVG Generator +authoring.fla.tool.groups.all =All #======= End labels: Exported 436 labels for en AU ===== Index: lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java =================================================================== diff -u -r7676f06ab1c200a434600195e4380a30a7b8264b -rff01a6c237cefc4a5186889bf46041152cfc37ae --- lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java (.../AuthoringAction.java) (revision 7676f06ab1c200a434600195e4380a30a7b8264b) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java (.../AuthoringAction.java) (revision ff01a6c237cefc4a5186889bf46041152cfc37ae) @@ -52,6 +52,8 @@ import org.lamsfoundation.lams.authoring.service.IAuthoringService; import org.lamsfoundation.lams.learningdesign.LearningDesign; import org.lamsfoundation.lams.learningdesign.LearningDesignAccess; +import org.lamsfoundation.lams.learningdesign.LearningLibrary; +import org.lamsfoundation.lams.learningdesign.LearningLibraryGroup; import org.lamsfoundation.lams.learningdesign.dto.LearningDesignDTO; import org.lamsfoundation.lams.learningdesign.dto.LicenseDTO; import org.lamsfoundation.lams.learningdesign.dto.ValidationErrorDTO; @@ -71,8 +73,6 @@ import org.lamsfoundation.lams.usermanagement.exception.WorkspaceFolderException; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.CentralConstants; -import org.lamsfoundation.lams.util.Configuration; -import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.FileUtil; import org.lamsfoundation.lams.util.FileUtilException; import org.lamsfoundation.lams.util.WebUtil; @@ -120,18 +120,31 @@ } public ActionForward openAuthoring(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException { - request.setAttribute("tools", getLearningDesignService().getToolDTOs(true, request.getRemoteUser())); + HttpServletResponse response) throws IOException, JSONException { request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, FileUtil.generateUniqueContentFolderID()); + + request.setAttribute("tools", getLearningDesignService().getToolDTOs(true, request.getRemoteUser())); + // build list of existing learning library groups + List groups = getLearningDesignService().getLearningLibraryGroups(); + JSONArray groupsJSON = new JSONArray(); + for (LearningLibraryGroup group : groups) { + JSONObject groupJSON = new JSONObject(); + groupJSON.put("name", group.getName()); + for (LearningLibrary learningLibrary : group.getLearningLibraries()) { + groupJSON.append("learningLibraries", learningLibrary.getLearningLibraryId()); + } + groupsJSON.put(groupJSON); + } + request.setAttribute("learningLibraryGroups", groupsJSON.toString()); List accessList = getAuthoringService().getLearningDesignAccessByUser(getUserId()); accessList = accessList.subList(0, Math.min(accessList.size(), AuthoringAction.LEARNING_DESIGN_ACCESS_ENTRIES_LIMIT - 1)); Gson gson = new GsonBuilder().create(); request.setAttribute("access", gson.toJson(accessList)); - + request.setAttribute("licenses", getAuthoringService().getAvailableLicenses()); - + return mapping.findForward("openAutoring"); } Index: lams_central/web/authoring/authoring.jsp =================================================================== diff -u -re837b7b90d6cbae5ecf051b9c9ba61b3097e0c51 -rff01a6c237cefc4a5186889bf46041152cfc37ae --- lams_central/web/authoring/authoring.jsp (.../authoring.jsp) (revision e837b7b90d6cbae5ecf051b9c9ba61b3097e0c51) +++ lams_central/web/authoring/authoring.jsp (.../authoring.jsp) (revision ff01a6c237cefc4a5186889bf46041152cfc37ae) @@ -154,6 +154,7 @@ activitiesOnlySelectable = false, initContentFolderID = '${contentFolderID}', initLearningDesignID = '${param.learningDesignID}', + learningLibraryGroups = ${learningLibraryGroups}, initAccess = ${access}; @@ -261,7 +262,10 @@
-
+ +
12){ toolName.css('padding-top', '8px'); } + } + }); + + if (!isReadOnlyMode){ + // create list of learning libraries for each group + var templateContainerCell = $('#templateContainerCell'), + learningLibraryGroupSelect = $('select', templateContainerCell), + allGroup = $('option', learningLibraryGroupSelect), + allTemplates = $('#templateContainerCell .templateContainer').show(); + + learningLibraryGroupSelect.change(function(){ + $('.templateContainer').hide(); + // show DIV with the selected learning libraries group + $('option:selected', this).data('templates').show(); + }); + allGroup.data('templates', allTemplates); + + $.each(learningLibraryGroups, function(){ + var templates = allTemplates.clone().appendTo(templateContainerCell), + learningLibraries = this.learningLibraries; + // cloned everything, now remove ones that are not in the list + $('.template', templates).each(function(){ + var learningLibraryId = $(this).attr('learningLibraryId'), + found = false; + $.each(learningLibraries, function(){ + if (learningLibraryId == this) { + found = true; + return false; + } + }); + + if (!found) { + $(this).remove(); + } + }); + $('