Index: lams_build/lib/lams/lams.jar =================================================================== RCS file: /usr/local/cvsroot/lams_build/lib/lams/lams.jar,v diff -u -r1.492 -r1.493 Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/web/OrganisationGroupAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/OrganisationGroupAction.java,v diff -u -r1.15 -r1.16 --- lams_central/src/java/org/lamsfoundation/lams/web/OrganisationGroupAction.java 11 May 2016 07:30:15 -0000 1.15 +++ lams_central/src/java/org/lamsfoundation/lams/web/OrganisationGroupAction.java 23 May 2016 08:04:31 -0000 1.16 @@ -52,6 +52,8 @@ import org.lamsfoundation.lams.contentrepository.InvalidParameterException; import org.lamsfoundation.lams.integration.dto.ExtGroupDTO; import org.lamsfoundation.lams.integration.service.IIntegrationService; +import org.lamsfoundation.lams.learning.service.ICoreLearnerService; +import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.Group; import org.lamsfoundation.lams.learningdesign.GroupComparator; import org.lamsfoundation.lams.learningdesign.Grouping; @@ -64,6 +66,7 @@ import org.lamsfoundation.lams.usermanagement.OrganisationGrouping; import org.lamsfoundation.lams.usermanagement.Role; import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.dto.OrganisationGroupingDTO; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.AlphanumComparator; @@ -80,70 +83,11 @@ * @struts.action-forward name = "viewExtGroups" path = "/extGroups.jsp" */ public class OrganisationGroupAction extends DispatchAction { - /** - * Class for displaying data on groupings page. - */ - public class OrganisationGroupingDTO implements Comparable { - private Long groupingId; - private String name; - private Integer groupCount; - public OrganisationGroupingDTO(OrganisationGrouping grouping) { - this.groupingId = grouping.getGroupingId(); - this.name = grouping.getName(); - this.groupCount = grouping.getGroups().size(); - } - - public Long getGroupingId() { - return groupingId; - } - - public void setGroupingId(Long groupingId) { - this.groupingId = groupingId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getGroupCount() { - return groupCount; - } - - public void setGroupCount(Integer groupCount) { - this.groupCount = groupCount; - } - - @Override - public int compareTo(OrganisationGroupingDTO o) { - if (o == null) { - return 1; - } - if (this.name == null) { - return o.name == null ? 0 : 1; - } - return this.name.compareTo(o.name); - } - } - - private static final Comparator ORG_GROUP_COMPARATOR = new Comparator() { - @Override - public int compare(OrganisationGroup o1, OrganisationGroup o2) { - String grp1Name = o1 != null ? o1.getName() : ""; - String grp2Name = o2 != null ? o2.getName() : ""; - - AlphanumComparator comparator = new AlphanumComparator(); - return comparator.compare(grp1Name, grp2Name); - } - }; - private static Logger log = Logger.getLogger(OrganisationGroupAction.class); private static IUserManagementService userManagementService; + private static ICoreLearnerService learnerService; private static ILessonService lessonService; private static ISecurityService securityService; private static IIntegrationService integrationService; @@ -191,7 +135,15 @@ request.setAttribute(AttributeNames.PARAM_ORGANISATION_ID, organisationId); // if this is a chosen group and lesson is created using integrations - show groups received from LMS instead of actual LAMS ones - if (lessonId != null && getIntegrationService().isIntegratedServerGroupFetchingAvailable(lessonId)) { + if (getIntegrationService().isIntegratedServerGroupFetchingAvailable(lessonId)) { + + if (lessonId == null) { + //it's when a learner clicks back button on groups page + Activity activity = getLearnerService().getActivity(activityID); + lessonId = getLearnerService().getLessonByActivity(activity).getLessonId(); + request.setAttribute("lessonID", lessonId); + } + List extGroups = getIntegrationService().getExtGroups(lessonId, null); request.setAttribute("extGroups", extGroups); // TODO ? show only with user number >0 @@ -535,12 +487,24 @@ */ private JSONArray getOrgGroupsDetails(Set groups, Collection learners) throws JSONException { + + final Comparator ORG_GROUP_COMPARATOR = new Comparator() { + @Override + public int compare(OrganisationGroup o1, OrganisationGroup o2) { + String grp1Name = o1 != null ? o1.getName() : ""; + String grp2Name = o2 != null ? o2.getName() : ""; + + AlphanumComparator comparator = new AlphanumComparator(); + return comparator.compare(grp1Name, grp2Name); + } + }; + // serialize database group objects into JSON JSONArray groupsJSON = new JSONArray(); if (groups != null) { // sort groups by their name List groupList = new LinkedList(groups); - Collections.sort(groupList, OrganisationGroupAction.ORG_GROUP_COMPARATOR); + Collections.sort(groupList, ORG_GROUP_COMPARATOR); for (OrganisationGroup group : groupList) { JSONObject groupJSON = new JSONObject(); @@ -619,6 +583,16 @@ } return OrganisationGroupAction.userManagementService; } + + private ICoreLearnerService getLearnerService() { + if (OrganisationGroupAction.learnerService == null) { + WebApplicationContext ctx = WebApplicationContextUtils + .getRequiredWebApplicationContext(getServlet().getServletContext()); + OrganisationGroupAction.learnerService = (ICoreLearnerService) ctx + .getBean("learnerService"); + } + return OrganisationGroupAction.learnerService; + } private ILessonService getLessonService() { if (OrganisationGroupAction.lessonService == null) { Index: lams_central/web/extGroups.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/extGroups.jsp,v diff -u -r1.1 -r1.2 --- lams_central/web/extGroups.jsp 1 Dec 2015 22:27:57 -0000 1.1 +++ lams_central/web/extGroups.jsp 23 May 2016 08:04:31 -0000 1.2 @@ -2,6 +2,10 @@ <%@ taglib uri="tags-lams" prefix="lams"%> <%@ taglib uri="tags-fmt" prefix="fmt"%> <%@ taglib uri="tags-core" prefix="c"%> + + + + @@ -19,8 +23,9 @@ -
- + + +
Index: lams_central/web/orgGroup.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/orgGroup.jsp,v diff -u -r1.9 -r1.10 --- lams_central/web/orgGroup.jsp 25 Apr 2016 08:19:34 -0000 1.9 +++ lams_central/web/orgGroup.jsp 23 May 2016 08:04:31 -0000 1.10 @@ -14,6 +14,8 @@ + +