Search in sources :

Example 91 with BGArea

use of org.olat.group.area.BGArea in project openolat by klemens.

the class KeyAndNameConverterTest method convertGroupAndAreaNameToKey_sameName.

/**
 * Test with same name for area and group
 */
@Test
public void convertGroupAndAreaNameToKey_sameName() {
    CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
    BGArea newArea = new MockArea(567l, "Test 1");
    BGAreaReference areaRef = new BGAreaReference(newArea, 345l, "Test 1");
    envMapper.getAreas().add(areaRef);
    MockBusinessGroup newGroup = new MockBusinessGroup(568l, "Test 1");
    BusinessGroupReference bgRef = new BusinessGroupReference(newGroup, 346l, "Test 1");
    envMapper.getGroups().add(bgRef);
    String convertedExp = convertExpressionNameToKey("inLearningArea(\"Test 1\") & inLearningGroup(\"Test 1\")", envMapper);
    Assert.assertEquals("inLearningArea(\"567\") & inLearningGroup(\"568\")", convertedExp);
}
Also used : BGArea(org.olat.group.area.BGArea) BusinessGroupReference(org.olat.group.model.BusinessGroupReference) BGAreaReference(org.olat.group.model.BGAreaReference) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper) Test(org.junit.Test)

Example 92 with BGArea

use of org.olat.group.area.BGArea in project openolat by klemens.

the class KeyAndNameConverterTest method convertGroupAndAreaKeyToName_sameKey.

@Test
public void convertGroupAndAreaKeyToName_sameKey() {
    CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
    BGArea newArea = new MockArea(567l, "Area 1");
    BGAreaReference areaRef = new BGAreaReference(newArea, null, null);
    envMapper.getAreas().add(areaRef);
    MockBusinessGroup newGroup = new MockBusinessGroup(567l, "Group 1");
    BusinessGroupReference bgRef = new BusinessGroupReference(newGroup, null, null);
    envMapper.getGroups().add(bgRef);
    String convertedExp = convertExpressionKeyToName("inLearningArea(\"567\") & isLearningGroupFull(\"567\")", envMapper);
    Assert.assertEquals("inLearningArea(\"Area 1\") & isLearningGroupFull(\"Group 1\")", convertedExp);
}
Also used : BGArea(org.olat.group.area.BGArea) BusinessGroupReference(org.olat.group.model.BusinessGroupReference) BGAreaReference(org.olat.group.model.BGAreaReference) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper) Test(org.junit.Test)

Example 93 with BGArea

use of org.olat.group.area.BGArea in project openolat by klemens.

the class KeyAndNameConverterTest method convertAreaKeyToName.

@Test
public void convertAreaKeyToName() {
    CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
    BGArea newArea = new MockArea(567l, "Area 1");
    BGAreaReference areaRef = new BGAreaReference(newArea, null, null);
    envMapper.getAreas().add(areaRef);
    String convertedExp = convertExpressionKeyToName("inLearningArea(\"567\")", envMapper);
    Assert.assertEquals("inLearningArea(\"Area 1\")", convertedExp);
}
Also used : BGArea(org.olat.group.area.BGArea) BGAreaReference(org.olat.group.model.BGAreaReference) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper) Test(org.junit.Test)

Example 94 with BGArea

use of org.olat.group.area.BGArea in project openolat by klemens.

the class KeyAndNameConverterTest method convertGroupAndAreaKeyToKey_sameKey.

@Test
public void convertGroupAndAreaKeyToKey_sameKey() {
    CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
    BGArea newArea = new MockArea(567l, "Area 1");
    BGAreaReference areaRef = new BGAreaReference(newArea, 345l, "Area 1");
    envMapper.getAreas().add(areaRef);
    MockBusinessGroup newGroup = new MockBusinessGroup(568l, "Group 1");
    BusinessGroupReference bgRef = new BusinessGroupReference(newGroup, 345l, "Group 1");
    envMapper.getGroups().add(bgRef);
    String convertedExp = convertExpressionKeyToKey("inLearningArea(\"345\") & inRightGroup(\"345\")", envMapper);
    Assert.assertEquals("inLearningArea(\"567\") & inRightGroup(\"568\")", convertedExp);
}
Also used : BGArea(org.olat.group.area.BGArea) BusinessGroupReference(org.olat.group.model.BusinessGroupReference) BGAreaReference(org.olat.group.model.BGAreaReference) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper) Test(org.junit.Test)

Example 95 with BGArea

use of org.olat.group.area.BGArea in project openolat by klemens.

the class BusinessGroupImportExportTest method importLearningGroupsAndAreasWithResource.

@Test
public void importLearningGroupsAndAreasWithResource() throws URISyntaxException {
    RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
    URL input = BusinessGroupImportExportTest.class.getResource("learninggroupexport_3.xml");
    File importXml = new File(input.toURI());
    businessGroupService.importGroups(resource, importXml);
    dbInstance.commitAndCloseSession();
    // check if all three groups are imported
    List<BusinessGroup> groups = businessGroupService.findBusinessGroups(null, resource, 0, -1);
    Assert.assertNotNull(groups);
    Assert.assertEquals(3, groups.size());
    // check if all three areas are imported
    List<BGArea> areas = areaManager.findBGAreasInContext(resource.getOlatResource());
    Assert.assertNotNull(areas);
    Assert.assertEquals(3, areas.size());
    // check first area
    BGArea area1 = areaManager.findBGArea("Area 1", resource.getOlatResource());
    Assert.assertNotNull(area1);
    Assert.assertEquals("Area 1", area1.getName());
    Assert.assertEquals("<p>Area 1 description</p>", area1.getDescription());
    // check relation to groups
    List<BusinessGroup> groupArea1 = areaManager.findBusinessGroupsOfArea(area1);
    Assert.assertNotNull(groupArea1);
    Assert.assertEquals(2, groupArea1.size());
    Assert.assertTrue(groupArea1.get(0).getName().equals("Export group 1") || groupArea1.get(1).getName().equals("Export group 1"));
    Assert.assertTrue(groupArea1.get(0).getName().equals("Export group 2") || groupArea1.get(1).getName().equals("Export group 2"));
    // check empty area
    BGArea area3 = areaManager.findBGArea("Area 3", resource.getOlatResource());
    Assert.assertNotNull(area1);
    Assert.assertEquals("Area 3", area3.getName());
    // check relation to groups
    List<BusinessGroup> groupArea3 = areaManager.findBusinessGroupsOfArea(area3);
    Assert.assertNotNull(groupArea3);
    Assert.assertEquals(0, groupArea3.size());
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Aggregations

BGArea (org.olat.group.area.BGArea)124 BusinessGroup (org.olat.group.BusinessGroup)70 Test (org.junit.Test)68 RepositoryEntry (org.olat.repository.RepositoryEntry)52 ArrayList (java.util.ArrayList)22 Identity (org.olat.core.id.Identity)22 BGAreaReference (org.olat.group.model.BGAreaReference)18 AssessmentModeToArea (org.olat.course.assessment.AssessmentModeToArea)16 CourseEnvironmentMapper (org.olat.course.export.CourseEnvironmentMapper)16 HashSet (java.util.HashSet)14 AssessmentMode (org.olat.course.assessment.AssessmentMode)12 BusinessGroupReference (org.olat.group.model.BusinessGroupReference)12 OLATResource (org.olat.resource.OLATResource)12 AssessmentModeToGroup (org.olat.course.assessment.AssessmentModeToGroup)10 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)8 CollaborationTools (org.olat.collaboration.CollaborationTools)6 BusinessGroupShort (org.olat.group.BusinessGroupShort)6 File (java.io.File)4 IOException (java.io.IOException)4 Field (java.lang.reflect.Field)4