Search in sources :

Example 1 with Membership

use of org.olat.course.nodes.gta.model.Membership in project OpenOLAT by OpenOLAT.

the class GTAManagerImpl method getMembership.

@Override
public Membership getMembership(IdentityRef identity, RepositoryEntryRef entry, GTACourseNode cNode) {
    List<String> roles;
    ModuleConfiguration config = cNode.getModuleConfiguration();
    if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
        List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
        List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
        List<Long> consolidatedGroupKeys = new ArrayList<>();
        if (groupKeys != null && groupKeys.size() > 0) {
            consolidatedGroupKeys.addAll(groupKeys);
        }
        consolidatedGroupKeys.addAll(areaManager.findBusinessGroupKeysOfAreaKeys(areaKeys));
        List<BusinessGroupRef> businessGroups = BusinessGroupRefImpl.toRefs(consolidatedGroupKeys);
        roles = businessGroupRelationDao.getRoles(identity, businessGroups);
    } else {
        roles = repositoryEntryRelationDao.getRoles(identity, entry);
    }
    boolean coach = roles.contains(GroupRoles.coach.name()) || roles.contains(GroupRoles.owner.name());
    boolean participant = roles.contains(GroupRoles.participant.name());
    return new Membership(coach, participant);
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) ModuleConfiguration(org.olat.modules.ModuleConfiguration) ArrayList(java.util.ArrayList) Membership(org.olat.course.nodes.gta.model.Membership)

Example 2 with Membership

use of org.olat.course.nodes.gta.model.Membership in project openolat by klemens.

the class GTANotifications method createBusinessGroupsSubscriptionInfo.

private void createBusinessGroupsSubscriptionInfo(Identity subscriberIdentity) {
    RepositoryEntry entry = courseEnv.getCourseGroupManager().getCourseEntry();
    Membership membership = gtaManager.getMembership(subscriberIdentity, entry, gtaNode);
    boolean owner = repositoryService.hasRole(subscriberIdentity, entry, GroupRoles.owner.name());
    if (owner) {
        List<BusinessGroup> groups = gtaManager.getBusinessGroups(gtaNode);
        for (BusinessGroup group : groups) {
            createBusinessGroupsSubscriptionItems(group, true);
        }
        createCoachSolutionItems();
    } else if (membership.isCoach()) {
        List<BusinessGroup> groups = gtaManager.getCoachedBusinessGroups(subscriberIdentity, gtaNode);
        for (BusinessGroup group : groups) {
            createBusinessGroupsSubscriptionItems(group, true);
        }
        createCoachSolutionItems();
    }
    if (membership.isParticipant()) {
        List<BusinessGroup> groups = gtaManager.getParticipatingBusinessGroups(subscriberIdentity, gtaNode);
        if (groups.size() == 1 && !owner && !membership.isCoach()) {
            Task task = gtaManager.getTask(groups.get(0), taskList);
            if (task != null) {
                header = translator.translate("notifications.group.header.task", new String[] { getTaskName(task), displayName });
            }
        }
        for (BusinessGroup group : groups) {
            createBusinessGroupsSubscriptionItems(group, false);
            Task task = gtaManager.getTask(group, taskList);
            if (createParticipantSolutionItems(task, null, group)) {
                break;
            }
        }
    }
}
Also used : Task(org.olat.course.nodes.gta.Task) BusinessGroup(org.olat.group.BusinessGroup) Membership(org.olat.course.nodes.gta.model.Membership) List(java.util.List) ArrayList(java.util.ArrayList) TaskList(org.olat.course.nodes.gta.TaskList) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 3 with Membership

use of org.olat.course.nodes.gta.model.Membership in project OpenOLAT by OpenOLAT.

the class GTANotifications method createBusinessGroupsSubscriptionInfo.

private void createBusinessGroupsSubscriptionInfo(Identity subscriberIdentity) {
    RepositoryEntry entry = courseEnv.getCourseGroupManager().getCourseEntry();
    Membership membership = gtaManager.getMembership(subscriberIdentity, entry, gtaNode);
    boolean owner = repositoryService.hasRole(subscriberIdentity, entry, GroupRoles.owner.name());
    if (owner) {
        List<BusinessGroup> groups = gtaManager.getBusinessGroups(gtaNode);
        for (BusinessGroup group : groups) {
            createBusinessGroupsSubscriptionItems(group, true);
        }
        createCoachSolutionItems();
    } else if (membership.isCoach()) {
        List<BusinessGroup> groups = gtaManager.getCoachedBusinessGroups(subscriberIdentity, gtaNode);
        for (BusinessGroup group : groups) {
            createBusinessGroupsSubscriptionItems(group, true);
        }
        createCoachSolutionItems();
    }
    if (membership.isParticipant()) {
        List<BusinessGroup> groups = gtaManager.getParticipatingBusinessGroups(subscriberIdentity, gtaNode);
        if (groups.size() == 1 && !owner && !membership.isCoach()) {
            Task task = gtaManager.getTask(groups.get(0), taskList);
            if (task != null) {
                header = translator.translate("notifications.group.header.task", new String[] { getTaskName(task), displayName });
            }
        }
        for (BusinessGroup group : groups) {
            createBusinessGroupsSubscriptionItems(group, false);
            Task task = gtaManager.getTask(group, taskList);
            if (createParticipantSolutionItems(task, null, group)) {
                break;
            }
        }
    }
}
Also used : Task(org.olat.course.nodes.gta.Task) BusinessGroup(org.olat.group.BusinessGroup) Membership(org.olat.course.nodes.gta.model.Membership) List(java.util.List) ArrayList(java.util.ArrayList) TaskList(org.olat.course.nodes.gta.TaskList) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 4 with Membership

use of org.olat.course.nodes.gta.model.Membership in project openolat by klemens.

the class GTAManagerImpl method getMembership.

@Override
public Membership getMembership(IdentityRef identity, RepositoryEntryRef entry, GTACourseNode cNode) {
    List<String> roles;
    ModuleConfiguration config = cNode.getModuleConfiguration();
    if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
        List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
        List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
        List<Long> consolidatedGroupKeys = new ArrayList<>();
        if (groupKeys != null && groupKeys.size() > 0) {
            consolidatedGroupKeys.addAll(groupKeys);
        }
        consolidatedGroupKeys.addAll(areaManager.findBusinessGroupKeysOfAreaKeys(areaKeys));
        List<BusinessGroupRef> businessGroups = BusinessGroupRefImpl.toRefs(consolidatedGroupKeys);
        roles = businessGroupRelationDao.getRoles(identity, businessGroups);
    } else {
        roles = repositoryEntryRelationDao.getRoles(identity, entry);
    }
    boolean coach = roles.contains(GroupRoles.coach.name()) || roles.contains(GroupRoles.owner.name());
    boolean participant = roles.contains(GroupRoles.participant.name());
    return new Membership(coach, participant);
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) ModuleConfiguration(org.olat.modules.ModuleConfiguration) ArrayList(java.util.ArrayList) Membership(org.olat.course.nodes.gta.model.Membership)

Aggregations

ArrayList (java.util.ArrayList)4 Membership (org.olat.course.nodes.gta.model.Membership)4 List (java.util.List)2 Task (org.olat.course.nodes.gta.Task)2 TaskList (org.olat.course.nodes.gta.TaskList)2 BusinessGroup (org.olat.group.BusinessGroup)2 BusinessGroupRef (org.olat.group.BusinessGroupRef)2 ModuleConfiguration (org.olat.modules.ModuleConfiguration)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2