Search in sources :

Example 26 with BusinessGroup

use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method loadAssessmentMode_identityInArea.

/**
 * Check an assessment linked to an area with one participant
 */
@Test
public void loadAssessmentMode_identityInArea() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-12");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-13");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-14");
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(author, "as-mode-3", "", null, null, null, null, false, false, entry);
    businessGroupRelationDao.addRole(participant, businessGroup, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(coach, businessGroup, GroupRoles.coach.name());
    BGArea area = areaMgr.createAndPersistBGArea("area for people", "", entry.getOlatResource());
    areaMgr.addBGToBGArea(businessGroup, area);
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setTargetAudience(AssessmentMode.Target.courseAndGroups);
    mode.setApplySettingsForCoach(false);
    mode = assessmentModeMgr.persist(mode);
    AssessmentModeToGroup modeToGroup = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup);
    mode.getGroups().add(modeToGroup);
    mode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    // check participant
    List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModeFor(participant);
    Assert.assertNotNull(currentModes);
    Assert.assertEquals(1, currentModes.size());
    Assert.assertTrue(currentModes.contains(mode));
    // check coach
    List<AssessmentMode> currentCoachModes = assessmentModeMgr.getAssessmentModeFor(coach);
    Assert.assertNotNull(currentCoachModes);
    Assert.assertTrue(currentCoachModes.isEmpty());
    // check author
    List<AssessmentMode> currentAuthorModes = assessmentModeMgr.getAssessmentModeFor(author);
    Assert.assertNotNull(currentAuthorModes);
    Assert.assertTrue(currentAuthorModes.isEmpty());
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 27 with BusinessGroup

use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.

the class GTAReminderRuleTest method assignTask_businessGroup.

@Test
public void assignTask_businessGroup() {
    // prepare
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-2");
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-3");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-4");
    Identity participant3 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-5");
    Identity participant4 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-6");
    BusinessGroup businessGroup1 = businessGroupDao.createAndPersist(coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
    BusinessGroup businessGroup2 = businessGroupDao.createAndPersist(coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
    businessGroupRelationDao.addRole(participant1, businessGroup1, GroupRole.participant.name());
    businessGroupRelationDao.addRole(participant2, businessGroup1, GroupRole.participant.name());
    businessGroupRelationDao.addRole(participant3, businessGroup2, GroupRole.participant.name());
    businessGroupRelationDao.addRole(participant4, businessGroup2, GroupRole.participant.name());
    dbInstance.commit();
    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry("", false);
    businessGroupRelationDao.addRelationToResource(businessGroup1, re);
    businessGroupRelationDao.addRelationToResource(businessGroup2, re);
    GTACourseNode node = new GTACourseNode();
    node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.group.name());
    List<Long> groupKeys = new ArrayList<>(2);
    groupKeys.add(businessGroup1.getKey());
    groupKeys.add(businessGroup2.getKey());
    node.getModuleConfiguration().setList(GTACourseNode.GTASK_GROUPS, groupKeys);
    TaskList tasks = gtaManager.createIfNotExists(re, node);
    File taskFile = new File("bg.txt");
    Assert.assertNotNull(tasks);
    dbInstance.commit();
    // group 1 select a task
    AssignmentResponse response = gtaManager.selectTask(businessGroup1, tasks, node, taskFile);
    dbInstance.commitAndCloseSession();
    Assert.assertEquals(AssignmentResponse.Status.ok, response.getStatus());
    // only remind group 2
    List<Identity> toRemind = assignTaskRuleSPI.getPeopleToRemind(re, node);
    Assert.assertEquals(2, toRemind.size());
    Assert.assertTrue(toRemind.contains(participant3));
    Assert.assertTrue(toRemind.contains(participant4));
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) TaskList(org.olat.course.nodes.gta.TaskList) ArrayList(java.util.ArrayList) GTACourseNode(org.olat.course.nodes.GTACourseNode) AssignmentResponse(org.olat.course.nodes.gta.AssignmentResponse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) File(java.io.File) Test(org.junit.Test)

Example 28 with BusinessGroup

use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.

the class BGAreaManagerTest method findBusinessGroupsOfAreaAttendedBy.

@Test
public void findBusinessGroupsOfAreaAttendedBy() {
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("attendee-1-" + UUID.randomUUID().toString());
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("attendee-2-" + UUID.randomUUID().toString());
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser("attendee-3-" + UUID.randomUUID().toString());
    // create a resource, an area, a group
    RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
    String areaName = UUID.randomUUID().toString();
    BGArea area1 = areaManager.createAndPersistBGArea("area-1-" + areaName, "description:" + areaName, resource.getOlatResource());
    BGArea area2 = areaManager.createAndPersistBGArea("area-2-" + areaName, "description:" + areaName, resource.getOlatResource());
    // create 2 groups
    BusinessGroup group1 = businessGroupService.createBusinessGroup(null, "area-1-group", "area-group-desc", 0, -1, false, false, resource);
    BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "area-2-group", "area-group-desc", 0, -1, false, false, resource);
    BusinessGroup group3 = businessGroupService.createBusinessGroup(null, "area-3-group", "area-group-desc", 0, -1, false, false, resource);
    dbInstance.commitAndCloseSession();
    // add the relations
    areaManager.addBGToBGArea(group1, area1);
    areaManager.addBGToBGArea(group2, area1);
    areaManager.addBGToBGArea(group2, area2);
    areaManager.addBGToBGArea(group3, area1);
    dbInstance.commitAndCloseSession();
    // add attendee
    businessGroupRelationDao.addRole(id1, group1, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(id2, group2, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(id2, group3, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(id3, group3, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // find with resource
    List<BusinessGroup> groupId1 = areaManager.findBusinessGroupsOfAreaAttendedBy(id1, null, resource.getOlatResource());
    Assert.assertNotNull(groupId1);
    Assert.assertEquals(1, groupId1.size());
    Assert.assertTrue(groupId1.contains(group1));
    // find nothing with name and resource
    List<Long> area2Keys = Collections.singletonList(area2.getKey());
    List<BusinessGroup> groupId1Area2 = areaManager.findBusinessGroupsOfAreaAttendedBy(id1, area2Keys, resource.getOlatResource());
    Assert.assertNotNull(groupId1Area2);
    Assert.assertEquals(0, groupId1Area2.size());
    // find groups id 2 with name and resource
    List<Long> area1Keys = Collections.singletonList(area1.getKey());
    List<BusinessGroup> groupId2Area1 = areaManager.findBusinessGroupsOfAreaAttendedBy(id2, area1Keys, resource.getOlatResource());
    Assert.assertNotNull(groupId2Area1);
    Assert.assertEquals(2, groupId2Area1.size());
    Assert.assertTrue(groupId2Area1.contains(group2));
    Assert.assertTrue(groupId2Area1.contains(group3));
}
Also used : BGArea(org.olat.group.area.BGArea) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 29 with BusinessGroup

use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.

the class BGAreaManagerTest method addFindAndDeleteRelation.

@Test
public void addFindAndDeleteRelation() {
    // create a resource, an area, a group
    RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
    String areaName = UUID.randomUUID().toString();
    BGArea area1 = areaManager.createAndPersistBGArea("area-1-" + areaName, "description:" + areaName, resource.getOlatResource());
    // create 2 groups
    BusinessGroup group1 = businessGroupService.createBusinessGroup(null, "area-1-group", "area-group-desc", 0, -1, false, false, resource);
    BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "area-2-group", "area-group-desc", 0, -1, false, false, resource);
    dbInstance.commitAndCloseSession();
    // add the relations
    areaManager.addBGToBGArea(group1, area1);
    areaManager.addBGToBGArea(group2, area1);
    dbInstance.commitAndCloseSession();
    // check find groups
    List<BusinessGroup> groups = areaManager.findBusinessGroupsOfArea(area1);
    Assert.assertNotNull(groups);
    Assert.assertEquals(2, groups.size());
    Assert.assertTrue(groups.contains(group1));
    Assert.assertTrue(groups.contains(group2));
    dbInstance.commitAndCloseSession();
    // remove relation to group1
    areaManager.removeBGFromArea(group2, area1);
    dbInstance.commitAndCloseSession();
    // check find groups
    List<BusinessGroup> diminushedGroups = areaManager.findBusinessGroupsOfArea(area1);
    Assert.assertNotNull(diminushedGroups);
    Assert.assertEquals(1, diminushedGroups.size());
    Assert.assertTrue(diminushedGroups.contains(group1));
}
Also used : BGArea(org.olat.group.area.BGArea) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 30 with BusinessGroup

use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.

the class BGAreaManagerTest method countBGAreasOfBusinessGroups.

@Test
public void countBGAreasOfBusinessGroups() {
    // create a resource, 3 area and 2 group
    RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
    String areaName = UUID.randomUUID().toString();
    BGArea area1 = areaManager.createAndPersistBGArea("count-1-" + areaName, "description:" + areaName, resource.getOlatResource());
    BGArea area2 = areaManager.createAndPersistBGArea("count-2-" + areaName, "description:" + areaName, resource.getOlatResource());
    BGArea area3 = areaManager.createAndPersistBGArea("count-3-" + areaName, "description:" + areaName, resource.getOlatResource());
    // create 2 groups
    BusinessGroup group1 = businessGroupService.createBusinessGroup(null, "count-1-group", "count-group-desc", 0, -1, false, false, resource);
    BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "count-2-group", "count-group-desc", 0, -1, false, false, resource);
    dbInstance.commitAndCloseSession();
    // add the relations
    areaManager.addBGToBGArea(group1, area1);
    areaManager.addBGToBGArea(group1, area2);
    areaManager.addBGToBGArea(group1, area3);
    areaManager.addBGToBGArea(group2, area1);
    dbInstance.commitAndCloseSession();
    // check with empty list
    int numOfAreas1 = areaManager.countBGAreasOfBusinessGroups(Collections.<BusinessGroup>emptyList());
    Assert.assertEquals(0, numOfAreas1);
    // num of areas of group2 -> only area1
    int numOfAreas2 = areaManager.countBGAreasOfBusinessGroups(Collections.singletonList(group2));
    Assert.assertEquals(1, numOfAreas2);
    // num of areas of group 1 and 2
    List<BusinessGroup> groups = new ArrayList<BusinessGroup>(2);
    groups.add(group1);
    groups.add(group2);
    int numOfAreas3 = areaManager.countBGAreasOfBusinessGroups(groups);
    Assert.assertEquals(3, numOfAreas3);
}
Also used : BGArea(org.olat.group.area.BGArea) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Aggregations

BusinessGroup (org.olat.group.BusinessGroup)1034 Test (org.junit.Test)536 Identity (org.olat.core.id.Identity)536 RepositoryEntry (org.olat.repository.RepositoryEntry)324 ArrayList (java.util.ArrayList)224 BusinessGroupService (org.olat.group.BusinessGroupService)116 SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)84 BGArea (org.olat.group.area.BGArea)70 CollaborationTools (org.olat.collaboration.CollaborationTools)58 OLATResource (org.olat.resource.OLATResource)56 Date (java.util.Date)54 HashSet (java.util.HashSet)50 File (java.io.File)46 Path (javax.ws.rs.Path)42 Group (org.olat.basesecurity.Group)42 HashMap (java.util.HashMap)38 Roles (org.olat.core.id.Roles)38 BusinessGroupQueryParams (org.olat.group.model.BusinessGroupQueryParams)38 BusinessGroupRow (org.olat.group.model.BusinessGroupRow)38 StatisticsBusinessGroupRow (org.olat.group.model.StatisticsBusinessGroupRow)38