Search in sources :

Example 11 with AssessmentModeToArea

use of org.olat.course.assessment.AssessmentModeToArea in project OpenOLAT by OpenOLAT.

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()));
}
Also used : AssessmentModeToArea(org.olat.course.assessment.AssessmentModeToArea) AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 12 with AssessmentModeToArea

use of org.olat.course.assessment.AssessmentModeToArea 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;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentModeToArea(org.olat.course.assessment.AssessmentModeToArea) Target(org.olat.course.assessment.AssessmentMode.Target) BGArea(org.olat.group.area.BGArea) HashSet(java.util.HashSet)

Example 13 with AssessmentModeToArea

use of org.olat.course.assessment.AssessmentModeToArea 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()));
}
Also used : AssessmentModeToArea(org.olat.course.assessment.AssessmentModeToArea) AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 14 with AssessmentModeToArea

use of org.olat.course.assessment.AssessmentModeToArea 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());
}
Also used : AssessmentModeToArea(org.olat.course.assessment.AssessmentModeToArea) AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 15 with AssessmentModeToArea

use of org.olat.course.assessment.AssessmentModeToArea in project openolat by klemens.

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;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentModeToArea(org.olat.course.assessment.AssessmentModeToArea) Target(org.olat.course.assessment.AssessmentMode.Target) BGArea(org.olat.group.area.BGArea) HashSet(java.util.HashSet)

Aggregations

AssessmentModeToArea (org.olat.course.assessment.AssessmentModeToArea)16 BusinessGroup (org.olat.group.BusinessGroup)16 BGArea (org.olat.group.area.BGArea)16 RepositoryEntry (org.olat.repository.RepositoryEntry)12 Test (org.junit.Test)10 Identity (org.olat.core.id.Identity)10 AssessmentMode (org.olat.course.assessment.AssessmentMode)10 AssessmentModeToGroup (org.olat.course.assessment.AssessmentModeToGroup)8 HashSet (java.util.HashSet)4 Target (org.olat.course.assessment.AssessmentMode.Target)4 ArrayList (java.util.ArrayList)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 ICourse (org.olat.course.ICourse)2 Status (org.olat.course.assessment.AssessmentMode.Status)2 CourseNode (org.olat.course.nodes.CourseNode)2 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)2