Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r313e29d4010a35282a7c56dd24971e40b442dfb0 -r846f7b4c76f01650ce4a2df946772bafc4228dcf Binary files differ Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r7d7e4420720fa2caa466d0faa33f8a810c72af45 -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 7d7e4420720fa2caa466d0faa33f8a810c72af45) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -858,7 +858,6 @@ outcome.manage.add.global =Global outcome.manage.add.scale =Scale outcome.manage.add.scale.none =Choose a scale -outcome.manage.add.scale.button =Manage scales outcome.manage.add.save =Save outcome.manage.scope =Scope outcome.manage.scope.global =global @@ -867,7 +866,18 @@ outcome.manage.add.error.name.blank =Name can not be blank outcome.manage.add.error.code.blank =Code can not be blank outcome.manage.add.error.scale.choose =You have to choose a scale -scale.manage.button =Manage scales +scale.title =Scales +scale.manage =Manage scales +scale.manage.add =Add scale +scale.manage.edit =Edit scale +scale.manage.view =View scale +scale.manage.title =Course scales +scale.manage.remove =Remove scale +scale.manage.remove.confirm =Are you sure you want to remove this scale? +scale.manage.add.value =Values +scale.manage.add.value.info =Enter comma separated values in increasing order of value. For example, an A,B,C,D scale must be entered as D,C,B,A. +scale.manage.add.value.error.blank =A value must not be blank +scale.manage.add.error =Error while saving an outcome scale #=================== Specific to Team Based Learning (TBL) =========================# authoring.tbl.template.title=Team Based Learning Index: lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeAction.java =================================================================== diff -u -rf0a07161503850e9dcdb4b69b4a37be03744743b -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeAction.java (.../OutcomeAction.java) (revision f0a07161503850e9dcdb4b69b4a37be03744743b) +++ lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeAction.java (.../OutcomeAction.java) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -23,7 +23,9 @@ package org.lamsfoundation.lams.web.outcome; import java.util.Date; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -38,11 +40,9 @@ import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.apache.struts.actions.DispatchAction; -import org.lamsfoundation.lams.integration.service.IIntegrationService; -import org.lamsfoundation.lams.learning.service.ICoreLearnerService; -import org.lamsfoundation.lams.lesson.service.ILessonService; import org.lamsfoundation.lams.outcome.Outcome; import org.lamsfoundation.lams.outcome.OutcomeScale; +import org.lamsfoundation.lams.outcome.OutcomeScaleItem; import org.lamsfoundation.lams.outcome.service.IOutcomeService; import org.lamsfoundation.lams.security.ISecurityService; import org.lamsfoundation.lams.usermanagement.Organisation; @@ -61,10 +61,7 @@ private static Logger log = Logger.getLogger(OutcomeAction.class); private static IUserManagementService userManagementService; - private static ICoreLearnerService learnerService; - private static ILessonService lessonService; private static ISecurityService securityService; - private static IIntegrationService integrationService; private static IOutcomeService outcomeService; public ActionForward outcomeManage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @@ -93,7 +90,6 @@ return mapping.findForward("outcomeManage"); } - @SuppressWarnings("unchecked") public ActionForward outcomeEdit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Integer userId = getUserDTO().getUserID(); @@ -127,7 +123,7 @@ outcomeForm.setScaleId(outcome.getScale().getScaleId()); } - List scales = getUserManagementService().findAll(OutcomeScale.class); + List scales = getOutcomeService().getScalesForManagement(organisationId); request.setAttribute("scales", scales); request.setAttribute("canManageGlobal", getUserManagementService().isUserSysAdmin()); @@ -230,6 +226,193 @@ return outcomeManage(mapping, form, request, response); } + public ActionForward scaleManage(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + Integer userId = getUserDTO().getUserID(); + Integer organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true); + + if (organisationId == null) { + // check if user is allowed to view and edit global outcomes + if (!getSecurityService().isSysadmin(userId, "manage global scales", false)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a sysadmin"); + return null; + } + } else { + // check if user is allowed to view and edit course outcomes + if (!getSecurityService().hasOrgRole(organisationId, userId, new String[] { Role.AUTHOR }, + "manage course scales", false)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not an author in the organisation"); + return null; + } + } + List scales = getOutcomeService().getScalesForManagement(organisationId); + request.setAttribute("scales", scales); + + request.setAttribute("canManageGlobal", getUserManagementService().isUserSysAdmin()); + return mapping.findForward("scaleManage"); + } + + public ActionForward scaleRemove(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + Long scaleId = WebUtil.readLongParam(request, "scaleId", false); + OutcomeScale scale = (OutcomeScale) getUserManagementService().findById(OutcomeScale.class, scaleId); + if (scale == null) { + throw new IllegalArgumentException("Can not find an outcome scale with ID " + scaleId); + } + Integer organisationId = scale.getOrganisation() == null ? null : scale.getOrganisation().getOrganisationId(); + Integer userId = getUserDTO().getUserID(); + + if (organisationId == null) { + if (!getSecurityService().isSysadmin(userId, "remove global scale", false)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a sysadmin"); + return null; + } + } else { + if (!getSecurityService().hasOrgRole(organisationId, userId, new String[] { Role.AUTHOR }, + "remove course scale", false)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not an author in the organisation"); + return null; + } + } + getUserManagementService().delete(scale); + return scaleManage(mapping, form, request, response); + } + + public ActionForward scaleEdit(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + Integer userId = getUserDTO().getUserID(); + Long scaleId = WebUtil.readLongParam(request, "scaleId", true); + OutcomeScale scale = null; + Integer organisationId = null; + if (scaleId == null) { + organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true); + } else { + scale = (OutcomeScale) getUserManagementService().findById(OutcomeScale.class, scaleId); + if (scale.getOrganisation() != null) { + // get organisation ID from the outcome - the safest way + organisationId = scale.getOrganisation().getOrganisationId(); + } + } + + if (organisationId != null && !getSecurityService().hasOrgRole(organisationId, userId, + new String[] { Role.AUTHOR }, "add/edit course outcome", false)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not an author in the organisation"); + return null; + } + + OutcomeScaleForm scaleForm = (OutcomeScaleForm) form; + scaleForm.setOrganisationId(organisationId); + scaleForm.setContentFolderId(getOutcomeService().getContentFolderId(organisationId)); + if (scale != null) { + scaleForm.setScaleId(scale.getScaleId()); + scaleForm.setName(scale.getName()); + scaleForm.setCode(scale.getCode()); + scaleForm.setDescription(scale.getDescription()); + scaleForm.setItems(scale.getItemString()); + } + + request.setAttribute("canManageGlobal", getUserManagementService().isUserSysAdmin()); + return mapping.findForward("scaleEdit"); + } + + public ActionForward scaleSave(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + OutcomeScaleForm scaleForm = (OutcomeScaleForm) form; + Integer userId = getUserDTO().getUserID(); + Long scaleId = scaleForm.getScaleId(); + OutcomeScale scale = null; + Integer organisationId = null; + if (scaleId == null) { + organisationId = scaleForm.getOrganisationId(); + } else { + scale = (OutcomeScale) getUserManagementService().findById(OutcomeScale.class, scaleId); + if (scale.getOrganisation() != null) { + // get organisation ID from the outcome - the safest way + organisationId = scale.getOrganisation().getOrganisationId(); + } + } + + if (organisationId == null) { + if (!getSecurityService().isSysadmin(userId, "persist global scale", false)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a sysadmin"); + return null; + } + } else { + if (!getSecurityService().hasOrgRole(organisationId, userId, new String[] { Role.AUTHOR }, + "persist course scale", false)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not an author in the organisation"); + return null; + } + } + + ActionErrors errors = validateScaleForm(scaleForm); + List items = OutcomeScale.parseItems(scaleForm.getItems()); + if (items == null) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("scale.manage.add.value.error.blank")); + } + if (errors.isEmpty()) { + try { + Organisation organisation = (Organisation) (organisationId == null ? null + : getUserManagementService().findById(Organisation.class, organisationId)); + if (scale == null) { + scale = new OutcomeScale(); + scale.setOrganisation(organisation); + User user = (User) getUserManagementService().findById(User.class, userId); + scale.setCreateBy(user); + scale.setCreateDateTime(new Date()); + } + + scale.setName(scaleForm.getName()); + scale.setCode(scaleForm.getCode()); + scale.setDescription(scaleForm.getDescription()); + scale.setContentFolderId(scaleForm.getContentFolderId()); + getUserManagementService().save(scale); + + // find existing scales and add new ones + Set newItems = new LinkedHashSet<>(); + int value = 0; + for (String itemString : items) { + itemString = itemString.trim(); + if (StringUtils.isBlank(itemString)) { + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage("scale.manage.add.value.error.blank")); + break; + } + OutcomeScaleItem item = null; + for (OutcomeScaleItem exisitngItem : scale.getItems()) { + if (itemString.equals(exisitngItem.getName())) { + item = exisitngItem; + break; + } + } + if (item == null) { + item = new OutcomeScaleItem(); + item.setScale(scale); + item.setName(itemString); + } + item.setValue(value++); + newItems.add(item); + } + if (errors.isEmpty()) { + scale.getItems().clear(); + scale.getItems().addAll(newItems); + getUserManagementService().save(scale); + + request.setAttribute("saved", true); + } + } catch (Exception e) { + log.error("Exception while saving an outcome", e); + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("scale.manage.add.error")); + this.addErrors(request, errors); + } + } + if (!errors.isEmpty()) { + this.addErrors(request, errors); + } + + return mapping.findForward("scaleEdit"); + } + private UserDTO getUserDTO() { HttpSession ss = SessionManager.getSession(); return (UserDTO) ss.getAttribute(AttributeNames.USER); @@ -249,6 +432,17 @@ return errors; } + private ActionErrors validateScaleForm(OutcomeScaleForm scaleForm) { + ActionErrors errors = new ActionErrors(); + if (StringUtils.isBlank(scaleForm.getName())) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("outcome.manage.add.error.name.blank")); + } + if (StringUtils.isBlank(scaleForm.getCode())) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("outcome.manage.add.error.code.blank")); + } + return errors; + } + private IUserManagementService getUserManagementService() { if (OutcomeAction.userManagementService == null) { WebApplicationContext ctx = WebApplicationContextUtils @@ -258,24 +452,6 @@ return OutcomeAction.userManagementService; } - private ICoreLearnerService getLearnerService() { - if (OutcomeAction.learnerService == null) { - WebApplicationContext ctx = WebApplicationContextUtils - .getRequiredWebApplicationContext(getServlet().getServletContext()); - OutcomeAction.learnerService = (ICoreLearnerService) ctx.getBean("learnerService"); - } - return OutcomeAction.learnerService; - } - - private ILessonService getLessonService() { - if (OutcomeAction.lessonService == null) { - WebApplicationContext ctx = WebApplicationContextUtils - .getRequiredWebApplicationContext(getServlet().getServletContext()); - OutcomeAction.lessonService = (ILessonService) ctx.getBean("lessonService"); - } - return OutcomeAction.lessonService; - } - private ISecurityService getSecurityService() { if (OutcomeAction.securityService == null) { WebApplicationContext ctx = WebApplicationContextUtils @@ -293,13 +469,4 @@ } return OutcomeAction.outcomeService; } - - private IIntegrationService getIntegrationService() { - if (OutcomeAction.integrationService == null) { - WebApplicationContext ctx = WebApplicationContextUtils - .getRequiredWebApplicationContext(getServlet().getServletContext()); - OutcomeAction.integrationService = (IIntegrationService) ctx.getBean("integrationService"); - } - return OutcomeAction.integrationService; - } } \ No newline at end of file Index: lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeScaleForm.java =================================================================== diff -u --- lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeScaleForm.java (revision 0) +++ lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeScaleForm.java (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -0,0 +1,93 @@ +/**************************************************************** + * 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 + * **************************************************************** + */ + +package org.lamsfoundation.lams.web.outcome; + +import org.apache.struts.action.ActionForm; + +public class OutcomeScaleForm extends ActionForm { + private static final long serialVersionUID = -2985243667102883631L; + + private Long scaleId; + private Integer organisationId; + private String name; + private String code; + private String description; + private String contentFolderId; + private String items; + + public Long getScaleId() { + return scaleId; + } + + public void setScaleId(Long scaleId) { + this.scaleId = scaleId != null && scaleId < 1 ? null : scaleId; + } + + public Integer getOrganisationId() { + return organisationId; + } + + public void setOrganisationId(Integer organisationId) { + this.organisationId = organisationId != null && organisationId < 1 ? null : organisationId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getContentFolderId() { + return contentFolderId; + } + + public void setContentFolderId(String contentFolderId) { + this.contentFolderId = contentFolderId; + } + + public String getItems() { + return items; + } + + public void setItems(String itemString) { + this.items = itemString; + } +} \ No newline at end of file Index: lams_central/web/WEB-INF/struts-config.xml =================================================================== diff -u -r7d7e4420720fa2caa466d0faa33f8a810c72af45 -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_central/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 7d7e4420720fa2caa466d0faa33f8a810c72af45) +++ lams_central/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -42,9 +42,13 @@ type="org.lamsfoundation.lams.web.planner.PedagogicalPlannerSequenceNodeForm" /> + @@ -874,16 +878,26 @@ - - + + - + + + + Index: lams_central/web/css/outcome.scss =================================================================== diff -u -r7d7e4420720fa2caa466d0faa33f8a810c72af45 -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_central/web/css/outcome.scss (.../outcome.scss) (revision 7d7e4420720fa2caa466d0faa33f8a810c72af45) +++ lams_central/web/css/outcome.scss (.../outcome.scss) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -8,13 +8,13 @@ border-bottom: $border-thin-dotted; } -.manageOutcomeButton { +.manageButton { cursor: pointer; width: 16px; height: 16px; } -#addOutcomeButton { +#addButton { float: right; margin: 20px 10px 10px 0; } @@ -29,4 +29,8 @@ .outcomeContainer .row:first-child { border-bottom: $border-thin-solid; -} \ No newline at end of file +} + +textarea { + width: 100%; +} Index: lams_central/web/includes/javascript/main.js =================================================================== diff -u -r7d7e4420720fa2caa466d0faa33f8a810c72af45 -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_central/web/includes/javascript/main.js (.../main.js) (revision 7d7e4420720fa2caa466d0faa33f8a810c72af45) +++ lams_central/web/includes/javascript/main.js (.../main.js) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -585,7 +585,6 @@ }); } - function closeAddSingleActivityLessonDialog(action) { var id = 'dialogAddSingleActivityLesson', dialog = $('#' + id), Index: lams_central/web/includes/javascript/outcome.js =================================================================== diff -u -r313e29d4010a35282a7c56dd24971e40b442dfb0 -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_central/web/includes/javascript/outcome.js (.../outcome.js) (revision 313e29d4010a35282a7c56dd24971e40b442dfb0) +++ lams_central/web/includes/javascript/outcome.js (.../outcome.js) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -1,22 +1,69 @@ function removeOutcome(outcomeId) { if (confirm(LABELS.REMOVE_OUTCOME_CONFIRM_LABEL)) { - document.location.href = "outcome.do?method=outcomeRemove&outcomeId=" + outcomeId - + '&organisationID=' + organisationId; + document.location.href = 'outcome.do?method=outcomeRemove&organisationID=' + organisationId + '&outcomeId=' + outcomeId; } } +function removeScale(scaleId) { + if (confirm(LABELS.REMOVE_SCALE_CONFIRM_LABEL)) { + document.location.href = 'outcomeScale.do?method=scaleRemove&organisationID=' + organisationId + '&scaleId=' + scaleId; + } +} + function openEditOutcomeDialog(outcomeId) { window.parent.showDialog("dialogOutcomeEdit", { - 'height': Math.max(380, Math.min(700, $(window).height() - 30)), - 'width' : Math.max(380, Math.min(850, $(window).width() - 60)), + 'height': Math.max(380, Math.min(700, $(window.parent).height() - 30)), + 'width' : Math.max(380, Math.min(850, $(window.parent).width() - 60)), 'title' : outcomeId ? LABELS.EDIT_OUTCOME_TITLE : LABELS.ADD_OUTCOME_TITLE, - 'open' : function() { + 'open' : function() { var dialog = $(this); // load contents after opening the dialog $('iframe', dialog) .attr('src', LAMS_URL - + 'outcome.do?method=outcomeEdit&' - + (outcomeId ? "outcomeId=" + outcomeId : "organisationID=" + organisationId)); + + 'outcome.do?method=outcomeEdit&organisationID=' + organisationId + + (outcomeId ? "&outcomeId=" + outcomeId : "")); } }); -} \ No newline at end of file +} + +function openEditScaleDialog(scaleId) { + window.parent.showDialog("dialogOutcomeScaleEdit", { + 'height': Math.max(380, Math.min(700, $(window.parent).height() - 30)), + 'width' : Math.max(380, Math.min(850, $(window.parent).width() - 60)), + 'title' : scaleId ? LABELS.EDIT_SCALE_TITLE : LABELS.ADD_SCALE_TITLE, + 'open' : function() { + var dialog = $(this); + // load contents after opening the dialog + $('iframe', dialog) + .attr('src', LAMS_URL + + 'outcomeScale.do?method=scaleEdit&organisationID=' + organisationId + + (scaleId ? "&scaleId=" + scaleId : "")); + } + }); +} + +function openOutcomeScaleDialog() { + window.parent.showDialog("dialogOutcomeScale", { + 'height': Math.max(380, Math.min(700, $(window.parent).height() - 30)), + 'width' : Math.max(380, Math.min(850, $(window.parent).width() - 60)), + 'title' : organisationId ? LABELS.OUTCOME_SCALE_COURSE_MANAGE_TITLE : LABELS.OUTCOME_SCALE_MANAGE_TITLE, + 'open' : function() { + var dialog = $(this); + // load contents after opening the dialog + $('iframe', dialog) + .attr('src', LAMS_URL + + 'outcomeScale.do?method=scaleManage&organisationID=' + + organisationId); + } + }); +} + +function submitOutcome(){ + CKEDITOR.instances.description.updateElement(); + document.getElementById("outcomeForm"); +} + +function submitScale(){ + CKEDITOR.instances.description.updateElement(); + document.getElementById("scaleForm"); +} \ No newline at end of file Index: lams_central/web/outcome/outcomeEdit.jsp =================================================================== diff -u -rf0a07161503850e9dcdb4b69b4a37be03744743b -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_central/web/outcome/outcomeEdit.jsp (.../outcomeEdit.jsp) (revision f0a07161503850e9dcdb4b69b4a37be03744743b) +++ lams_central/web/outcome/outcomeEdit.jsp (.../outcomeEdit.jsp) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -26,23 +26,25 @@ 'outcome.do?method=outcomeManage${empty param.organisationID ? "" : "&organisationID=param.organisationID"}'; } else { outcomesFrame.attr('src', outcomesFrame.attr('src')); - window.parent.closeDialog('dialogOutcomeEdit'); + $('#dialogOutcomeEdit', window.parent.document).remove(); } var organisationId = '${param.organisationID}', - outcomeId = '${param.outcomeId}', LAMS_URL = '', - decoderDiv = $('
'), LABELS = { - + + ADD_OUTCOME_TITLE : '', + + EDIT_OUTCOME_TITLE : '', + + REMOVE_OUTCOME_CONFIRM_LABEL : decoderDiv.html('').text(), + + OUTCOME_SCALE_MANAGE_TITLE : '', + + OUTCOME_SCALE_COURSE_MANAGE_TITLE : '' }; - - function submitOutcome(){ - CKEDITOR.instances.description.updateElement(); - document.getElementById("outcomeForm"); - } @@ -64,7 +66,7 @@
<%-- Error Messages --%> - +
@@ -105,6 +107,9 @@ +
: @@ -123,7 +128,7 @@
- Index: lams_central/web/outcome/outcomeManage.jsp =================================================================== diff -u -rf0a07161503850e9dcdb4b69b4a37be03744743b -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_central/web/outcome/outcomeManage.jsp (.../outcomeManage.jsp) (revision f0a07161503850e9dcdb4b69b4a37be03744743b) +++ lams_central/web/outcome/outcomeManage.jsp (.../outcomeManage.jsp) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -6,6 +6,7 @@ + <fmt:message key="index.outcome.manage" /> @@ -26,70 +27,74 @@ EDIT_OUTCOME_TITLE : '', - REMOVE_OUTCOME_CONFIRM_LABEL : decoderDiv.html('').text(), + REMOVE_OUTCOME_CONFIRM_LABEL : decoderDiv.html('').text() }; - -
-
-
- -
-
- -
-
- -
-
-
-
-
-
- + + +
- +
- +
- - - - - - - - +
- - - - - - - - - -
- -
- -
- - + +
+
+ +
+
+ +
+
+ + + + + + + + +
+
+ + + + + + + + + + +
+
+ + + + +
+
+
+
+ + +
-
+
\ No newline at end of file Index: lams_central/web/outcome/scaleEdit.jsp =================================================================== diff -u --- lams_central/web/outcome/scaleEdit.jsp (revision 0) +++ lams_central/web/outcome/scaleEdit.jsp (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -0,0 +1,115 @@ +<%@ page contentType="text/html; charset=utf-8" language="java"%> +<%@ taglib uri="tags-lams" prefix="lams"%> +<%@ taglib uri="tags-fmt" prefix="fmt"%> +<%@ taglib uri="tags-core" prefix="c"%> +<%@ taglib uri="tags-html" prefix="html"%> +<%@ taglib uri="tags-logic" prefix="logic" %> +<%@ taglib uri="tags-function" prefix="fn" %> + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ <%-- Error Messages --%> + + + +
+
+
+
+ +
+ +
+
+ +
+
+ : + + + + + + + + +
+
+ +
+
+ : + + +
+ +
+ + + +
+
+
+
+
+
+ + + +
+
+ +
\ No newline at end of file Index: lams_central/web/outcome/scaleManage.jsp =================================================================== diff -u --- lams_central/web/outcome/scaleManage.jsp (revision 0) +++ lams_central/web/outcome/scaleManage.jsp (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -0,0 +1,99 @@ +<%@ page contentType="text/html; charset=utf-8" language="java"%> +<%@ taglib uri="tags-lams" prefix="lams"%> +<%@ taglib uri="tags-fmt" prefix="fmt"%> +<%@ taglib uri="tags-core" prefix="c"%> + + + + + + + + + + + + + + + + + +
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ + + + + + + + +
+
+ + + + + + + + + + +
+
+ + + + +
+
+
+
+ + +
+
+
+ +
\ No newline at end of file Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/outcome/OutcomeScale.hbm.xml =================================================================== diff -u -r313e29d4010a35282a7c56dd24971e40b442dfb0 -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/outcome/OutcomeScale.hbm.xml (.../OutcomeScale.hbm.xml) (revision 313e29d4010a35282a7c56dd24971e40b442dfb0) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/outcome/OutcomeScale.hbm.xml (.../OutcomeScale.hbm.xml) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -17,6 +17,9 @@ + + @@ -35,7 +38,7 @@ - + Index: lams_common/src/java/org/lamsfoundation/lams/outcome/OutcomeScale.java =================================================================== diff -u -r313e29d4010a35282a7c56dd24971e40b442dfb0 -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_common/src/java/org/lamsfoundation/lams/outcome/OutcomeScale.java (.../OutcomeScale.java) (revision 313e29d4010a35282a7c56dd24971e40b442dfb0) +++ lams_common/src/java/org/lamsfoundation/lams/outcome/OutcomeScale.java (.../OutcomeScale.java) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -1,9 +1,12 @@ package org.lamsfoundation.lams.outcome; +import java.util.Arrays; import java.util.Date; -import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; import java.util.Set; +import org.apache.commons.lang.StringUtils; import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.User; @@ -17,8 +20,26 @@ private User createBy; private Date createDateTime; - private Set items = new HashSet(); + private Set items = new LinkedHashSet(); + /** + * Split comma separated values into a list + */ + public static List parseItems(String itemString) { + return StringUtils.isBlank(itemString) ? null : Arrays.asList(itemString.split(",")); + } + + /** + * Build a string of comma separated values + */ + public String getItemString() { + StringBuilder itemString = new StringBuilder(); + for (OutcomeScaleItem item : items) { + itemString.append(item.getName()).append(","); + } + return itemString.length() == 0 ? null : itemString.substring(0, itemString.length() - 1); + } + public Long getScaleId() { return scaleId; } @@ -84,10 +105,10 @@ } public String getContentFolderId() { - return contentFolderId; + return contentFolderId; } public void setContentFolderId(String contentFolderId) { - this.contentFolderId = contentFolderId; + this.contentFolderId = contentFolderId; } } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/outcome/dao/IOutcomeDAO.java =================================================================== diff -u -r313e29d4010a35282a7c56dd24971e40b442dfb0 -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_common/src/java/org/lamsfoundation/lams/outcome/dao/IOutcomeDAO.java (.../IOutcomeDAO.java) (revision 313e29d4010a35282a7c56dd24971e40b442dfb0) +++ lams_common/src/java/org/lamsfoundation/lams/outcome/dao/IOutcomeDAO.java (.../IOutcomeDAO.java) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -26,9 +26,12 @@ import org.lamsfoundation.lams.dao.IBaseDAO; import org.lamsfoundation.lams.outcome.Outcome; +import org.lamsfoundation.lams.outcome.OutcomeScale; public interface IOutcomeDAO extends IBaseDAO { String getContentFolderID(Integer organisationId); List getOutcomesSortedByName(Integer organisationId); + + List getScalesSortedByName(Integer organisationId); } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/outcome/dao/hibernate/OutcomeDAO.java =================================================================== diff -u -r313e29d4010a35282a7c56dd24971e40b442dfb0 -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_common/src/java/org/lamsfoundation/lams/outcome/dao/hibernate/OutcomeDAO.java (.../OutcomeDAO.java) (revision 313e29d4010a35282a7c56dd24971e40b442dfb0) +++ lams_common/src/java/org/lamsfoundation/lams/outcome/dao/hibernate/OutcomeDAO.java (.../OutcomeDAO.java) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -27,6 +27,7 @@ import org.hibernate.Query; import org.lamsfoundation.lams.dao.hibernate.LAMSBaseDAO; import org.lamsfoundation.lams.outcome.Outcome; +import org.lamsfoundation.lams.outcome.OutcomeScale; import org.lamsfoundation.lams.outcome.dao.IOutcomeDAO; import org.springframework.stereotype.Repository; @@ -38,6 +39,8 @@ private static final String FIND_OUTCOMES_SORTED_BY_NAME = "FROM Outcome o WHERE o.organisation IS NULL ? ORDER BY o.name, o.code"; + private static final String FIND_SCALES_SORTED_BY_NAME = "FROM OutcomeScale o WHERE o.organisation IS NULL ? ORDER BY o.name, o.code"; + /** * Finds an existing content folder ID for the given organisation outcomes or scales, or for global ones */ @@ -57,4 +60,14 @@ organisationId == null ? "" : "OR o.organisation.organisationId = " + organisationId); return find(queryString); } + + /** + * Finds all global scales and ones for the given organisation + */ + @SuppressWarnings("unchecked") + public List getScalesSortedByName(Integer organisationId) { + String queryString = FIND_SCALES_SORTED_BY_NAME.replaceAll("\\?", + organisationId == null ? "" : "OR o.organisation.organisationId = " + organisationId); + return find(queryString); + } } Index: lams_common/src/java/org/lamsfoundation/lams/outcome/service/IOutcomeService.java =================================================================== diff -u -r313e29d4010a35282a7c56dd24971e40b442dfb0 -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_common/src/java/org/lamsfoundation/lams/outcome/service/IOutcomeService.java (.../IOutcomeService.java) (revision 313e29d4010a35282a7c56dd24971e40b442dfb0) +++ lams_common/src/java/org/lamsfoundation/lams/outcome/service/IOutcomeService.java (.../IOutcomeService.java) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -3,9 +3,12 @@ import java.util.List; import org.lamsfoundation.lams.outcome.Outcome; +import org.lamsfoundation.lams.outcome.OutcomeScale; public interface IOutcomeService { String getContentFolderId(Integer organisationId); List getOutcomesForManagement(Integer organisationId); + + List getScalesForManagement(Integer organisationId); } Index: lams_common/src/java/org/lamsfoundation/lams/outcome/service/OutcomeService.java =================================================================== diff -u -r313e29d4010a35282a7c56dd24971e40b442dfb0 -r846f7b4c76f01650ce4a2df946772bafc4228dcf --- lams_common/src/java/org/lamsfoundation/lams/outcome/service/OutcomeService.java (.../OutcomeService.java) (revision 313e29d4010a35282a7c56dd24971e40b442dfb0) +++ lams_common/src/java/org/lamsfoundation/lams/outcome/service/OutcomeService.java (.../OutcomeService.java) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) @@ -3,6 +3,7 @@ import java.util.List; import org.lamsfoundation.lams.outcome.Outcome; +import org.lamsfoundation.lams.outcome.OutcomeScale; import org.lamsfoundation.lams.outcome.dao.IOutcomeDAO; import org.lamsfoundation.lams.util.FileUtil; @@ -18,6 +19,10 @@ return outcomeDAO.getOutcomesSortedByName(organisationId); } + public List getScalesForManagement(Integer organisationId) { + return outcomeDAO.getScalesSortedByName(organisationId); + } + public void setOutcomeDAO(IOutcomeDAO outcomeDAO) { this.outcomeDAO = outcomeDAO; }