use of org.olat.group.model.LeaveOption in project OpenOLAT by OpenOLAT.
the class BusinessGroupServiceTest method allowToLeavingBusinessGroup_overrideForbidden_notAllowForAuthorsGroups_butForLearnersGroup.
/**
* Override of allow is forbidden system-wide. If a group have the settings not "not allowed to leave",
* the setting must be ignored for learners group but not for authors group.
*/
@Test
public void allowToLeavingBusinessGroup_overrideForbidden_notAllowForAuthorsGroups_butForLearnersGroup() {
businessGroupModule.setAllowLeavingGroupOverride(false);
businessGroupModule.setAllowLeavingGroupCreatedByAuthors(false);
businessGroupModule.setAllowLeavingGroupCreatedByLearners(true);
// authors group
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("leave-auth-4-" + UUID.randomUUID().toString());
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-4-");
BusinessGroup authorsGroup = businessGroupService.createBusinessGroup(author, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, null);
businessGroupRelationDao.addRole(participant, authorsGroup, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// set to not allowed to leave
authorsGroup = businessGroupService.updateAllowToLeaveBusinessGroup(authorsGroup, false);
dbInstance.commitAndCloseSession();
// check the authors group leaving option
LeaveOption optionToLeaveAuthorsGroup = businessGroupService.isAllowToLeaveBusinessGroup(participant, authorsGroup);
Assert.assertNotNull(optionToLeaveAuthorsGroup);
Assert.assertFalse(optionToLeaveAuthorsGroup.isAllowToLeave());
// learners group
Identity learner = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-learn-4-" + UUID.randomUUID().toString());
BusinessGroup learnersGroup = businessGroupService.createBusinessGroup(learner, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, null);
businessGroupRelationDao.addRole(participant, learnersGroup, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// set to not allowed to leave
learnersGroup = businessGroupService.updateAllowToLeaveBusinessGroup(learnersGroup, false);
dbInstance.commitAndCloseSession();
// check the learners group leaving option
LeaveOption optionToLeaveLearnersGroup = businessGroupService.isAllowToLeaveBusinessGroup(participant, learnersGroup);
Assert.assertNotNull(optionToLeaveLearnersGroup);
Assert.assertTrue(optionToLeaveLearnersGroup.isAllowToLeave());
}
use of org.olat.group.model.LeaveOption in project OpenOLAT by OpenOLAT.
the class BusinessGroupServiceImpl method isAllowToLeaveBusinessGroup.
@Override
public LeaveOption isAllowToLeaveBusinessGroup(Identity identity, BusinessGroup group) {
LeaveOption opt;
if (groupModule.isAllowLeavingGroupOverride()) {
if (group.isAllowToLeave()) {
opt = new LeaveOption();
} else {
ContactList list = getAdminContactList(group);
opt = new LeaveOption(false, list);
}
} else if (groupModule.isAllowLeavingGroupCreatedByAuthors() && groupModule.isAllowLeavingGroupCreatedByLearners()) {
opt = new LeaveOption();
} else if (!groupModule.isAllowLeavingGroupCreatedByAuthors() && !groupModule.isAllowLeavingGroupCreatedByLearners()) {
ContactList list = getAdminContactList(group);
opt = new LeaveOption(false, list);
} else {
int numOfCoaches = countMembers(group, GroupRoles.coach.name());
if (numOfCoaches == 0) {
int numOfResources = businessGroupRelationDAO.countResources(group);
if (numOfResources > 0) {
// author group
if (groupModule.isAllowLeavingGroupCreatedByAuthors()) {
opt = new LeaveOption();
} else {
ContactList list = getAdminContactList(group);
opt = new LeaveOption(false, list);
}
// learner group
} else if (groupModule.isAllowLeavingGroupCreatedByLearners()) {
opt = new LeaveOption();
} else {
ContactList list = getAdminContactList(group);
opt = new LeaveOption(false, list);
}
} else {
int numOfAuthors = businessGroupRelationDAO.countAuthors(group);
if (numOfAuthors > 0) {
if (groupModule.isAllowLeavingGroupCreatedByAuthors()) {
opt = new LeaveOption();
} else {
ContactList list = getAdminContactList(group);
opt = new LeaveOption(false, list);
}
} else if (groupModule.isAllowLeavingGroupCreatedByLearners()) {
opt = new LeaveOption();
} else {
ContactList list = getAdminContactList(group);
opt = new LeaveOption(false, list);
}
}
}
return opt;
}
use of org.olat.group.model.LeaveOption in project openolat by klemens.
the class BusinessGroupServiceTest method allowToLeavingBusinessGroup_defaultSettings.
/**
* Test the default settings. Participants are allowed to leave business groups.
*/
@Test
public void allowToLeavingBusinessGroup_defaultSettings() {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("leave-auth-1-" + UUID.randomUUID().toString());
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-1-");
BusinessGroup group = businessGroupService.createBusinessGroup(author, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, null);
businessGroupRelationDao.addRole(participant, group, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
LeaveOption optionToLeave = businessGroupService.isAllowToLeaveBusinessGroup(participant, group);
Assert.assertNotNull(optionToLeave);
Assert.assertTrue(optionToLeave.isAllowToLeave());
}
use of org.olat.group.model.LeaveOption in project openolat by klemens.
the class BusinessGroupServiceTest method allowToLeavingBusinessGroup_overrideForbidden_notAllowForAuthorsAndLearnersGroups.
/**
* Override of allow is forbidden system-wide. If a group have the settings not "not allowed to leave",
* the setting must be ignored for learners group but not for authors group.
*/
@Test
public void allowToLeavingBusinessGroup_overrideForbidden_notAllowForAuthorsAndLearnersGroups() {
businessGroupModule.setAllowLeavingGroupOverride(false);
businessGroupModule.setAllowLeavingGroupCreatedByAuthors(false);
businessGroupModule.setAllowLeavingGroupCreatedByLearners(false);
// authors group
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("leave-auth-5-" + UUID.randomUUID().toString());
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-5-");
BusinessGroup authorsGroup = businessGroupService.createBusinessGroup(author, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, null);
businessGroupRelationDao.addRole(participant, authorsGroup, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// set to not allowed to leave
authorsGroup = businessGroupService.updateAllowToLeaveBusinessGroup(authorsGroup, false);
dbInstance.commitAndCloseSession();
// check the authors group leaving option
LeaveOption optionToLeaveAuthorsGroup = businessGroupService.isAllowToLeaveBusinessGroup(participant, authorsGroup);
Assert.assertNotNull(optionToLeaveAuthorsGroup);
Assert.assertFalse(optionToLeaveAuthorsGroup.isAllowToLeave());
// learners group
Identity learner = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-learn-5-" + UUID.randomUUID().toString());
BusinessGroup learnersGroup = businessGroupService.createBusinessGroup(learner, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, null);
businessGroupRelationDao.addRole(participant, learnersGroup, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// set to not allowed to leave
learnersGroup = businessGroupService.updateAllowToLeaveBusinessGroup(learnersGroup, false);
dbInstance.commitAndCloseSession();
// check the learners group leaving option
LeaveOption optionToLeaveLearnersGroup = businessGroupService.isAllowToLeaveBusinessGroup(participant, learnersGroup);
Assert.assertNotNull(optionToLeaveLearnersGroup);
Assert.assertFalse(optionToLeaveLearnersGroup.isAllowToLeave());
}
use of org.olat.group.model.LeaveOption in project openolat by klemens.
the class BusinessGroupServiceTest method allowToLeavingBusinessGroup_overrideForbidden_notAllowForAuthorsGroups_butForLearnersGroup.
/**
* Override of allow is forbidden system-wide. If a group have the settings not "not allowed to leave",
* the setting must be ignored for learners group but not for authors group.
*/
@Test
public void allowToLeavingBusinessGroup_overrideForbidden_notAllowForAuthorsGroups_butForLearnersGroup() {
businessGroupModule.setAllowLeavingGroupOverride(false);
businessGroupModule.setAllowLeavingGroupCreatedByAuthors(false);
businessGroupModule.setAllowLeavingGroupCreatedByLearners(true);
// authors group
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("leave-auth-4-" + UUID.randomUUID().toString());
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-4-");
BusinessGroup authorsGroup = businessGroupService.createBusinessGroup(author, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, null);
businessGroupRelationDao.addRole(participant, authorsGroup, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// set to not allowed to leave
authorsGroup = businessGroupService.updateAllowToLeaveBusinessGroup(authorsGroup, false);
dbInstance.commitAndCloseSession();
// check the authors group leaving option
LeaveOption optionToLeaveAuthorsGroup = businessGroupService.isAllowToLeaveBusinessGroup(participant, authorsGroup);
Assert.assertNotNull(optionToLeaveAuthorsGroup);
Assert.assertFalse(optionToLeaveAuthorsGroup.isAllowToLeave());
// learners group
Identity learner = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-learn-4-" + UUID.randomUUID().toString());
BusinessGroup learnersGroup = businessGroupService.createBusinessGroup(learner, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, null);
businessGroupRelationDao.addRole(participant, learnersGroup, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// set to not allowed to leave
learnersGroup = businessGroupService.updateAllowToLeaveBusinessGroup(learnersGroup, false);
dbInstance.commitAndCloseSession();
// check the learners group leaving option
LeaveOption optionToLeaveLearnersGroup = businessGroupService.isAllowToLeaveBusinessGroup(participant, learnersGroup);
Assert.assertNotNull(optionToLeaveLearnersGroup);
Assert.assertTrue(optionToLeaveLearnersGroup.isAllowToLeave());
}
Aggregations