use of org.olat.group.area.BGArea in project OpenOLAT by OpenOLAT.
the class AssessmentModeManagerImpl method getAssessedIdentityKeys.
@Override
public Set<Long> getAssessedIdentityKeys(AssessmentMode assessmentMode) {
Target targetAudience = assessmentMode.getTargetAudience();
RepositoryEntry re = assessmentMode.getRepositoryEntry();
Set<Long> assessedKeys = new HashSet<>();
if (targetAudience == Target.course || targetAudience == Target.courseAndGroups) {
List<Long> courseMemberKeys = assessmentMode.isApplySettingsForCoach() ? repositoryEntryRelationDao.getMemberKeys(re, RepositoryEntryRelationType.defaultGroup, GroupRoles.coach.name(), GroupRoles.participant.name()) : repositoryEntryRelationDao.getMemberKeys(re, RepositoryEntryRelationType.defaultGroup, GroupRoles.participant.name());
assessedKeys.addAll(courseMemberKeys);
}
if (targetAudience == Target.groups || targetAudience == Target.courseAndGroups) {
List<BusinessGroup> groups = new ArrayList<>();
Set<AssessmentModeToArea> modeToAreas = assessmentMode.getAreas();
if (modeToAreas.size() > 0) {
List<BGArea> areas = new ArrayList<>(modeToAreas.size());
for (AssessmentModeToArea modeToArea : modeToAreas) {
areas.add(modeToArea.getArea());
}
List<BusinessGroup> groupsInAreas = areaMgr.findBusinessGroupsOfAreas(areas);
groups.addAll(groupsInAreas);
}
Set<AssessmentModeToGroup> modeToGroups = assessmentMode.getGroups();
if (modeToGroups.size() > 0) {
for (AssessmentModeToGroup modeToGroup : modeToGroups) {
groups.add(modeToGroup.getBusinessGroup());
}
}
List<Long> groupMemberKeys = assessmentMode.isApplySettingsForCoach() ? businessGroupRelationDao.getMemberKeys(groups, GroupRoles.coach.name(), GroupRoles.participant.name()) : businessGroupRelationDao.getMemberKeys(groups, GroupRoles.participant.name());
assessedKeys.addAll(groupMemberKeys);
}
return assessedKeys;
}
use of org.olat.group.area.BGArea in project OpenOLAT by OpenOLAT.
the class COCourseNode method isConfigValid.
/**
* @see org.olat.course.nodes.CourseNode#isConfigValid(org.olat.course.run.userview.UserCourseEnvironment)
*/
public StatusDescription[] isConfigValid(CourseEditorEnv cev) {
oneClickStatusCache = null;
// only here we know which translator to take for translating condition
// error messages
String translatorStr = Util.getPackageName(ConditionEditController.class);
List<StatusDescription> condErrs = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions());
List<StatusDescription> missingNames = new ArrayList<StatusDescription>();
/*
* check group and area names for existence
*/
String nodeId = getIdent();
ModuleConfiguration mc = getModuleConfiguration();
@SuppressWarnings("unchecked") List<Long> areaKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA_IDS);
if (areaKeys != null) {
BGAreaManager areaManager = CoreSpringFactory.getImpl(BGAreaManager.class);
List<BGArea> areas = areaManager.loadAreas(areaKeys);
a_a: for (Long areaKey : areaKeys) {
for (BGArea area : areas) {
if (area.getKey().equals(areaKey)) {
continue a_a;
}
}
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", areaKey.toString() }, translatorStr);
sd.setDescriptionForUnit(nodeId);
missingNames.add(sd);
}
} else {
String areaStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA);
if (areaStr != null) {
String[] areas = areaStr.split(",");
for (int i = 0; i < areas.length; i++) {
String trimmed = areas[i] != null ? areas[i].trim() : areas[i];
if (!trimmed.equals("") && !cev.existsArea(trimmed)) {
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", trimmed }, translatorStr);
sd.setDescriptionForUnit(nodeId);
missingNames.add(sd);
}
}
}
}
@SuppressWarnings("unchecked") List<Long> groupKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_GROUP_ID);
if (groupKeys != null) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
List<BusinessGroupShort> groups = bgs.loadShortBusinessGroups(groupKeys);
a_a: for (Long activeGroupKey : groupKeys) {
for (BusinessGroupShort group : groups) {
if (group.getKey().equals(activeGroupKey)) {
continue a_a;
}
}
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", activeGroupKey.toString() }, translatorStr);
sd.setDescriptionForUnit(nodeId);
missingNames.add(sd);
}
} else {
String groupStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_GROUP);
if (groupStr != null) {
String[] groups = groupStr.split(",");
for (int i = 0; i < groups.length; i++) {
String trimmed = groups[i] != null ? groups[i].trim() : groups[i];
if (!trimmed.equals("") && !cev.existsGroup(trimmed)) {
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", trimmed }, translatorStr);
sd.setDescriptionForUnit(nodeId);
missingNames.add(sd);
}
}
}
}
missingNames.addAll(condErrs);
oneClickStatusCache = StatusDescriptionHelper.sort(missingNames);
return oneClickStatusCache;
}
use of org.olat.group.area.BGArea in project openolat by klemens.
the class OLATUpgrade_8_2_0 method getCourseEnvironmentMapper.
private CourseEnvironmentMapper getCourseEnvironmentMapper(RepositoryEntry courseResource) {
CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
List<BusinessGroup> groups = businessGroupService.findBusinessGroups(null, courseResource, 0, -1);
for (BusinessGroup group : groups) {
envMapper.getGroups().add(new BusinessGroupReference(group));
}
List<BGArea> areas = areaManager.findBGAreasInContext(courseResource.getOlatResource());
for (BGArea area : areas) {
envMapper.getAreas().add(new BGAreaReference(area));
}
return envMapper;
}
use of org.olat.group.area.BGArea in project openolat by klemens.
the class AssessmentModeManagerTest method getAssessedIdentities_course_areas.
@Test
public void getAssessedIdentities_course_areas() {
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-20");
RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-21");
Identity coach1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-22");
BusinessGroup businessGroup = businessGroupService.createBusinessGroup(null, "as-mode-5", "", null, null, null, null, false, false, entry);
businessGroupRelationDao.addRole(participant1, businessGroup, GroupRoles.participant.name());
businessGroupRelationDao.addRole(coach1, businessGroup, GroupRoles.coach.name());
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-23");
Identity coach2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-24");
repositoryEntryRelationDao.addRole(participant2, entry, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(coach2, entry, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(author, entry, GroupRoles.owner.name());
AssessmentMode mode = createMinimalAssessmentmode(entry);
mode.setTargetAudience(AssessmentMode.Target.courseAndGroups);
mode.setApplySettingsForCoach(true);
mode = assessmentModeMgr.persist(mode);
BGArea area = areaMgr.createAndPersistBGArea("area for people", "", entry.getOlatResource());
areaMgr.addBGToBGArea(businessGroup, area);
AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(mode, area);
mode.getAreas().add(modeToArea);
mode = assessmentModeMgr.merge(mode, true);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(mode);
Set<Long> assessedIdentityKeys = assessmentModeMgr.getAssessedIdentityKeys(mode);
Assert.assertNotNull(assessedIdentityKeys);
Assert.assertEquals(4, assessedIdentityKeys.size());
Assert.assertFalse(assessedIdentityKeys.contains(author.getKey()));
Assert.assertTrue(assessedIdentityKeys.contains(coach1.getKey()));
Assert.assertTrue(assessedIdentityKeys.contains(participant1.getKey()));
Assert.assertTrue(assessedIdentityKeys.contains(coach2.getKey()));
Assert.assertTrue(assessedIdentityKeys.contains(participant2.getKey()));
}
use of org.olat.group.area.BGArea in project openolat by klemens.
the class AssessmentModeManagerTest method deleteAreaFromRepositoryEntry.
@Test
public void deleteAreaFromRepositoryEntry() {
// prepare the setup
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-14");
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-15");
RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
AssessmentMode mode = createMinimalAssessmentmode(entry);
mode.setTargetAudience(AssessmentMode.Target.groups);
mode = assessmentModeMgr.persist(mode);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(mode);
BusinessGroup businessGroupForArea = businessGroupService.createBusinessGroup(author, "as_mode_1", "", null, null, null, null, false, false, null);
businessGroupRelationDao.addRole(participant, businessGroupForArea, GroupRoles.participant.name());
BGArea area = areaMgr.createAndPersistBGArea("little area", "My little secret area", entry.getOlatResource());
areaMgr.addBGToBGArea(businessGroupForArea, area);
dbInstance.commitAndCloseSession();
AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(mode, area);
mode.getAreas().add(modeToArea);
mode = assessmentModeMgr.merge(mode, true);
dbInstance.commitAndCloseSession();
// check the participant modes
List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModeFor(participant);
Assert.assertNotNull(currentModes);
Assert.assertEquals(1, currentModes.size());
Assert.assertTrue(currentModes.contains(mode));
// delete
areaMgr.deleteBGArea(area);
dbInstance.commitAndCloseSession();
// check the participant modes after deleting the area
List<AssessmentMode> afterDeleteModes = assessmentModeMgr.getAssessmentModeFor(participant);
Assert.assertNotNull(afterDeleteModes);
Assert.assertEquals(0, afterDeleteModes.size());
}
Aggregations