Search in sources :

Example 16 with AssessmentModeToGroup

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

the class AssessmentModeManagerTest method deleteAssessmentMode.

@Test
public void deleteAssessmentMode() {
    // prepare the setup
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-1");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(author, "as_mode_1", "", null, null, null, null, false, false, null);
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    AssessmentModeToGroup modeToGroup = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup);
    mode.getGroups().add(modeToGroup);
    AssessmentMode savedMode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    BusinessGroup businessGroupForArea = businessGroupService.createBusinessGroup(author, "as_mode_1", "", null, null, null, null, false, false, null);
    BGArea area = areaMgr.createAndPersistBGArea("little area", "My little secret area", entry.getOlatResource());
    areaMgr.addBGToBGArea(businessGroupForArea, area);
    dbInstance.commitAndCloseSession();
    AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(savedMode, area);
    savedMode.getAreas().add(modeToArea);
    savedMode = assessmentModeMgr.merge(savedMode, true);
    dbInstance.commitAndCloseSession();
    // delete
    assessmentModeMgr.delete(savedMode);
    dbInstance.commit();
    // check
    AssessmentMode deletedMode = assessmentModeMgr.getAssessmentModeById(mode.getKey());
    Assert.assertNull(deletedMode);
}
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) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 17 with AssessmentModeToGroup

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

the class AssessmentModeManagerTest method loadAssessmentMode_identityInBusinessGroup_coach.

/**
 * Check an assessment linked to a group with one participant
 */
@Test
public void loadAssessmentMode_identityInBusinessGroup_coach() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-4");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-5");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-6");
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(null, "as-mode-3", "", null, null, null, null, false, false, entry);
    businessGroupRelationDao.addRole(participant, businessGroup, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(coach, businessGroup, GroupRoles.coach.name());
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setTargetAudience(AssessmentMode.Target.courseAndGroups);
    mode.setApplySettingsForCoach(true);
    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.assertEquals(1, currentCoachModes.size());
    Assert.assertTrue(currentCoachModes.contains(mode));
    // 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) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 18 with AssessmentModeToGroup

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

the class AssessmentModeManagerTest method removeBusinessGroupFromRepositoryEntry.

@Test
public void removeBusinessGroupFromRepositoryEntry() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-4");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-5");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-6");
    BusinessGroup businessGroup1 = businessGroupService.createBusinessGroup(author, "as-mode-7", "", null, null, null, null, false, false, entry);
    BusinessGroup businessGroup2 = businessGroupService.createBusinessGroup(author, "as-mode-8", "", null, null, null, null, false, false, entry);
    businessGroupRelationDao.addRole(participant1, businessGroup1, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(participant2, businessGroup2, GroupRoles.participant.name());
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setTargetAudience(AssessmentMode.Target.groups);
    mode.setApplySettingsForCoach(false);
    mode = assessmentModeMgr.persist(mode);
    AssessmentModeToGroup modeToGroup1 = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup1);
    AssessmentModeToGroup modeToGroup2 = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup2);
    mode.getGroups().add(modeToGroup1);
    mode.getGroups().add(modeToGroup2);
    mode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    // check participant 1
    List<AssessmentMode> currentModes1 = assessmentModeMgr.getAssessmentModeFor(participant1);
    Assert.assertNotNull(currentModes1);
    Assert.assertEquals(1, currentModes1.size());
    Assert.assertTrue(currentModes1.contains(mode));
    // check participant 2
    List<AssessmentMode> currentModes2 = assessmentModeMgr.getAssessmentModeFor(participant2);
    Assert.assertNotNull(currentModes2);
    Assert.assertEquals(1, currentModes2.size());
    Assert.assertTrue(currentModes2.contains(mode));
    // remove business group 1
    businessGroupRelationDao.deleteRelation(businessGroup1, entry);
    dbInstance.commitAndCloseSession();
    // check participant 1
    List<AssessmentMode> afterDeleteModes1 = assessmentModeMgr.getAssessmentModeFor(participant1);
    Assert.assertNotNull(afterDeleteModes1);
    Assert.assertEquals(0, afterDeleteModes1.size());
    // check participant 2
    List<AssessmentMode> afterDeleteModes2 = assessmentModeMgr.getAssessmentModeFor(participant2);
    Assert.assertNotNull(afterDeleteModes2);
    Assert.assertEquals(1, afterDeleteModes2.size());
    Assert.assertTrue(afterDeleteModes2.contains(mode));
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 19 with AssessmentModeToGroup

use of org.olat.course.assessment.AssessmentModeToGroup 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 20 with AssessmentModeToGroup

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

the class AssessmentModeManagerTest method loadAssessmentMode_identityInBusinessGroup.

/**
 * Check an assessment linked to a group with one participant
 */
@Test
public void loadAssessmentMode_identityInBusinessGroup() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-2");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-3");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-3");
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(author, "as-mode-2", "", null, null, null, null, false, false, entry);
    businessGroupRelationDao.addRole(participant, businessGroup, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(coach, businessGroup, GroupRoles.coach.name());
    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) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

AssessmentModeToGroup (org.olat.course.assessment.AssessmentModeToGroup)22 BusinessGroup (org.olat.group.BusinessGroup)22 RepositoryEntry (org.olat.repository.RepositoryEntry)18 Test (org.junit.Test)16 Identity (org.olat.core.id.Identity)16 AssessmentMode (org.olat.course.assessment.AssessmentMode)16 BGArea (org.olat.group.area.BGArea)10 AssessmentModeToArea (org.olat.course.assessment.AssessmentModeToArea)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