Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -re10cc5cece2f9f7a5044b274914c0517a064699a -r24961a0e4692ce893e1903a9ab498f34aaf012b8 --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision e10cc5cece2f9f7a5044b274914c0517a064699a) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 24961a0e4692ce893e1903a9ab498f34aaf012b8) @@ -854,7 +854,6 @@ outcome.manage.add.description =Description outcome.manage.add.global =Global outcome.manage.add.scale =Scale -outcome.manage.add.scale.none =Choose a scale outcome.manage.add.save =Save outcome.manage.scope =Scope outcome.manage.scope.global =global Index: lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeAction.java =================================================================== diff -u -r73e57b8ca1a3ddd6cd15b00240d90b79c5de063a -r24961a0e4692ce893e1903a9ab498f34aaf012b8 --- lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeAction.java (.../OutcomeAction.java) (revision 73e57b8ca1a3ddd6cd15b00240d90b79c5de063a) +++ lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeAction.java (.../OutcomeAction.java) (revision 24961a0e4692ce893e1903a9ab498f34aaf012b8) @@ -122,7 +122,9 @@ OutcomeForm outcomeForm = (OutcomeForm) form; outcomeForm.setOrganisationId(organisationId); outcomeForm.setContentFolderId(getOutcomeService().getContentFolderId(organisationId)); - if (outcome != null) { + if (outcome == null) { + outcomeForm.setScaleId(IOutcomeService.DEFAULT_SCALE_ID); + } else { outcomeForm.setOutcomeId(outcome.getOutcomeId()); outcomeForm.setName(outcome.getName()); outcomeForm.setCode(outcome.getCode()); @@ -540,6 +542,7 @@ } request.setAttribute("canManageGlobal", getUserManagementService().isUserSysAdmin()); + request.setAttribute("isDefaultScale", getOutcomeService().isDefaultScale(scaleForm.getScaleId())); return mapping.findForward("scaleEdit"); } @@ -554,6 +557,10 @@ organisationId = scaleForm.getOrganisationId(); } else { scale = (OutcomeScale) getUserManagementService().findById(OutcomeScale.class, scaleId); + if (getOutcomeService().isDefaultScale(scale.getScaleId())) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "The default scale can not be altered"); + return null; + } if (scale.getOrganisation() != null) { // get organisation ID from the outcome - the safest way organisationId = scale.getOrganisation().getOrganisationId(); Index: lams_central/web/outcome/outcomeEdit.jsp =================================================================== diff -u -r846f7b4c76f01650ce4a2df946772bafc4228dcf -r24961a0e4692ce893e1903a9ab498f34aaf012b8 --- lams_central/web/outcome/outcomeEdit.jsp (.../outcomeEdit.jsp) (revision 846f7b4c76f01650ce4a2df946772bafc4228dcf) +++ lams_central/web/outcome/outcomeEdit.jsp (.../outcomeEdit.jsp) (revision 24961a0e4692ce893e1903a9ab498f34aaf012b8) @@ -97,9 +97,6 @@
- + @@ -81,7 +81,7 @@
- + Index: lams_common/src/java/org/lamsfoundation/lams/commonContext.xml =================================================================== diff -u -r313e29d4010a35282a7c56dd24971e40b442dfb0 -r24961a0e4692ce893e1903a9ab498f34aaf012b8 --- lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision 313e29d4010a35282a7c56dd24971e40b442dfb0) +++ lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision 24961a0e4692ce893e1903a9ab498f34aaf012b8) @@ -510,7 +510,7 @@ - PROPAGATION_REQUIRED + PROPAGATION_REQUIRED Index: lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20180802.sql =================================================================== diff -u -ra1bfe9d7972867fa2a0bcacc2bf263a9e34c856b -r24961a0e4692ce893e1903a9ab498f34aaf012b8 --- lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20180802.sql (.../patch20180802.sql) (revision a1bfe9d7972867fa2a0bcacc2bf263a9e34c856b) +++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20180802.sql (.../patch20180802.sql) (revision 24961a0e4692ce893e1903a9ab498f34aaf012b8) @@ -73,6 +73,10 @@ CONSTRAINT FK_lams_outcome_result_2 FOREIGN KEY (user_id) REFERENCES lams_user (user_id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT FK_lams_outcome_result_3 FOREIGN KEY (create_by) REFERENCES lams_user (user_id) ON DELETE SET NULL ON UPDATE CASCADE ); + +-- create default scale +INSERT INTO lams_outcome_scale VALUES (1, NULL, 'Default attainment scale', 'default', 'Default global scale', NULL, 1, NOW()); +INSERT INTO lams_outcome_scale_item VALUES (1, 1, 0, 'Not yet attained'), (2, 1, 1, 'Attained'); ----------------------Put all sql statements above here------------------------- Index: lams_common/src/java/org/lamsfoundation/lams/outcome/service/IOutcomeService.java =================================================================== diff -u -r73e57b8ca1a3ddd6cd15b00240d90b79c5de063a -r24961a0e4692ce893e1903a9ab498f34aaf012b8 --- lams_common/src/java/org/lamsfoundation/lams/outcome/service/IOutcomeService.java (.../IOutcomeService.java) (revision 73e57b8ca1a3ddd6cd15b00240d90b79c5de063a) +++ lams_common/src/java/org/lamsfoundation/lams/outcome/service/IOutcomeService.java (.../IOutcomeService.java) (revision 24961a0e4692ce893e1903a9ab498f34aaf012b8) @@ -9,6 +9,8 @@ import org.lamsfoundation.lams.outcome.OutcomeScale; public interface IOutcomeService { + static final long DEFAULT_SCALE_ID = 1; + String getContentFolderId(Integer organisationId); List getOutcomes(Integer organisationId); @@ -23,6 +25,10 @@ OutcomeResult getOutcomeResult(Integer userId, Long mappingId); + OutcomeScale getDefaultScale(); + + boolean isDefaultScale(Long scaleId); + void copyOutcomeMappings(Long sourceLessonId, Long sourceToolContentId, Long sourceItemId, Long targetLessonId, Long targetToolContentId, Long targetItemId); } Index: lams_common/src/java/org/lamsfoundation/lams/outcome/service/OutcomeService.java =================================================================== diff -u -r73e57b8ca1a3ddd6cd15b00240d90b79c5de063a -r24961a0e4692ce893e1903a9ab498f34aaf012b8 --- lams_common/src/java/org/lamsfoundation/lams/outcome/service/OutcomeService.java (.../OutcomeService.java) (revision 73e57b8ca1a3ddd6cd15b00240d90b79c5de063a) +++ lams_common/src/java/org/lamsfoundation/lams/outcome/service/OutcomeService.java (.../OutcomeService.java) (revision 24961a0e4692ce893e1903a9ab498f34aaf012b8) @@ -52,6 +52,14 @@ return outcomeDAO.getOutcomeResult(userId, mappingId); } + public OutcomeScale getDefaultScale() { + return (OutcomeScale) outcomeDAO.find(OutcomeScale.class, DEFAULT_SCALE_ID); + } + + public boolean isDefaultScale(Long scaleId) { + return scaleId != null && DEFAULT_SCALE_ID == scaleId; + } + public void copyOutcomeMappings(Long sourceLessonId, Long sourceToolContentId, Long sourceItemId, Long targetLessonId, Long targetToolContentId, Long targetItemId) { List sourceMappings = getOutcomeMappings(sourceLessonId, sourceToolContentId, sourceItemId);