use of org.olat.group.area.BGArea in project openolat by klemens.
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);
}
use of org.olat.group.area.BGArea in project openolat by klemens.
the class KeyAndNameConverterTest method convertAreaKeyToKey.
@Test
public void convertAreaKeyToKey() {
CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
BGArea newArea = new MockArea(567l, "Area 1");
BGAreaReference areaRef = new BGAreaReference(newArea, 345l, "Area 1");
envMapper.getAreas().add(areaRef);
String convertedExp = convertExpressionKeyToKey("inLearningArea(\"345\")", envMapper);
Assert.assertEquals("inLearningArea(\"567\")", convertedExp);
}
use of org.olat.group.area.BGArea in project openolat by klemens.
the class KeyAndNameConverterTest method convertAreaNameToKey.
@Test
public void convertAreaNameToKey() {
CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
BGArea newArea = new MockArea(567l, "Area 1");
BGAreaReference areaRef = new BGAreaReference(newArea, 345l, "Area 1");
envMapper.getAreas().add(areaRef);
String convertedExp = convertExpressionNameToKey("inLearningArea(\"Area 1\")", envMapper);
Assert.assertEquals("inLearningArea(\"567\")", convertedExp);
}
use of org.olat.group.area.BGArea in project openolat by klemens.
the class EnrollmentManagerSerialTest method getEnrollmentRows_withAreas.
@Test
public void getEnrollmentRows_withAreas() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("en-area-1");
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("en-part-1");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("en-part-2");
Identity participant3 = JunitTestHelper.createAndPersistIdentityAsRndUser("en-part-3");
Identity participant4 = JunitTestHelper.createAndPersistIdentityAsRndUser("en-part-4");
Identity participant5 = JunitTestHelper.createAndPersistIdentityAsRndUser("en-part-5");
Identity waiter1 = JunitTestHelper.createAndPersistIdentityAsRndUser("en-wait-3");
Identity waiter2 = JunitTestHelper.createAndPersistIdentityAsRndUser("en-wait-4");
Identity waiter3 = JunitTestHelper.createAndPersistIdentityAsRndUser("en-wait-5");
// create a resource, an area, a group
RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
String areaName = UUID.randomUUID().toString();
BGArea area = areaManager.createAndPersistBGArea("en-area-" + areaName, "description:" + areaName, resource.getOlatResource());
BusinessGroup group1 = businessGroupService.createBusinessGroup(null, "en-area-group", "area-group-desc", 0, 10, false, false, resource);
BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "en-group-2", "area-group-desc", 0, 10, true, false, resource);
BusinessGroup group3 = businessGroupService.createBusinessGroup(null, "en-group-3", "area-group-desc", 0, 10, true, false, resource);
businessGroupRelationDao.addRole(participant1, group1, GroupRoles.participant.name());
businessGroupRelationDao.addRole(participant2, group2, GroupRoles.participant.name());
businessGroupRelationDao.addRole(participant3, group2, GroupRoles.participant.name());
businessGroupRelationDao.addRole(participant4, group2, GroupRoles.participant.name());
businessGroupRelationDao.addRole(participant5, group2, GroupRoles.participant.name());
businessGroupRelationDao.addRole(waiter1, group2, GroupRoles.waiting.name());
businessGroupRelationDao.addRole(waiter2, group2, GroupRoles.waiting.name());
businessGroupRelationDao.addRole(waiter3, group2, GroupRoles.waiting.name());
areaManager.addBGToBGArea(group1, area);
areaManager.addBGToBGArea(group2, area);
dbInstance.commitAndCloseSession();
List<Long> groupKeys = new ArrayList<>();
groupKeys.add(group2.getKey());
groupKeys.add(group3.getKey());
List<Long> areaKeys = new ArrayList<>();
areaKeys.add(area.getKey());
// check id enrollments
List<EnrollmentRow> idEnrollments = enrollmentManager.getEnrollments(id, groupKeys, areaKeys, 128);
Assert.assertNotNull(idEnrollments);
Assert.assertEquals(3, idEnrollments.size());
// check enrollment group 1
EnrollmentRow enrollment1 = getEnrollmentRowFor(group1, idEnrollments);
Assert.assertEquals(group1.getKey(), enrollment1.getKey());
Assert.assertEquals(group1.getName(), enrollment1.getName());
Assert.assertEquals(1, enrollment1.getNumOfParticipants());
Assert.assertEquals(0, enrollment1.getNumInWaitingList());
Assert.assertFalse(enrollment1.isParticipant());
Assert.assertFalse(enrollment1.isWaiting());
// check enrollment group 2
EnrollmentRow enrollment2 = getEnrollmentRowFor(group2, idEnrollments);
Assert.assertEquals(group2.getKey(), enrollment2.getKey());
Assert.assertEquals(group2.getName(), enrollment2.getName());
Assert.assertEquals(4, enrollment2.getNumOfParticipants());
Assert.assertEquals(3, enrollment2.getNumInWaitingList());
Assert.assertFalse(enrollment2.isParticipant());
Assert.assertFalse(enrollment2.isWaiting());
// check enrollment group 3
EnrollmentRow enrollment3 = getEnrollmentRowFor(group3, idEnrollments);
Assert.assertEquals(group3.getKey(), enrollment3.getKey());
Assert.assertEquals(group3.getName(), enrollment3.getName());
Assert.assertEquals(0, enrollment3.getNumOfParticipants());
Assert.assertEquals(0, enrollment3.getNumInWaitingList());
Assert.assertFalse(enrollment3.isParticipant());
Assert.assertFalse(enrollment3.isWaiting());
// check enrollments of participant5
List<EnrollmentRow> part5Enrollments = enrollmentManager.getEnrollments(participant5, groupKeys, areaKeys, 128);
Assert.assertNotNull(part5Enrollments);
Assert.assertEquals(3, part5Enrollments.size());
EnrollmentRow enrollment2_w5 = getEnrollmentRowFor(group2, part5Enrollments);
Assert.assertEquals(group2.getKey(), enrollment2_w5.getKey());
Assert.assertEquals(group2.getName(), enrollment2_w5.getName());
Assert.assertEquals(4, enrollment2_w5.getNumOfParticipants());
Assert.assertEquals(3, enrollment2_w5.getNumInWaitingList());
Assert.assertTrue(enrollment2_w5.isParticipant());
Assert.assertFalse(enrollment2_w5.isWaiting());
// check enrollments of waiter 3
List<EnrollmentRow> wait3Enrollments = enrollmentManager.getEnrollments(waiter3, groupKeys, areaKeys, 128);
Assert.assertNotNull(wait3Enrollments);
Assert.assertEquals(3, wait3Enrollments.size());
EnrollmentRow enrollment2_p3 = getEnrollmentRowFor(group2, wait3Enrollments);
Assert.assertEquals(group2.getKey(), enrollment2_p3.getKey());
Assert.assertEquals(group2.getName(), enrollment2_p3.getName());
Assert.assertEquals(4, enrollment2_p3.getNumOfParticipants());
Assert.assertEquals(3, enrollment2_p3.getNumInWaitingList());
Assert.assertFalse(enrollment2_p3.isParticipant());
Assert.assertTrue(enrollment2_p3.isWaiting());
}
use of org.olat.group.area.BGArea in project openolat by klemens.
the class PreviewSettingsForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
sdate = uifactory.addDateChooser("sdate", "form.sdate", null, formLayout);
sdate.setExampleKey("form.easy.example.bdate", null);
sdate.setDateChooserTimeEnabled(true);
sdate.setMandatory(true);
sdate.setValidDateCheck("form.sdate.invalid");
// setDate must be called after the DataChooser was configured
sdate.setDate(new Date());
List<BusinessGroup> groups = courseGroupManager.getAllBusinessGroups();
String[] groupNames = new String[groups.size()];
String[] groupKeys = new String[groups.size()];
for (int i = groups.size(); i-- > 0; ) {
groupNames[i] = groups.get(i).getName();
groupKeys[i] = groups.get(i).getKey().toString();
}
groupSelector = uifactory.addCheckboxesVertical("details.groups", formLayout, groupKeys, groupNames, 1);
groupSelector.setVisible(groups.size() > 0);
List<BGArea> areas = courseGroupManager.getAllAreas();
String[] areaNames = new String[areas.size()];
String[] areaKeys = new String[areas.size()];
for (int i = areas.size(); i-- > 0; ) {
areaNames[i] = areas.get(i).getName();
areaKeys[i] = areas.get(i).getKey().toString();
}
areaSelector = uifactory.addCheckboxesVertical("details.areas", formLayout, areaKeys, areaNames, 1);
areaSelector.setVisible(areas.size() > 0);
String[] keys = { ROLE_STUDENT, ROLE_GUEST, ROLE_COURSECOACH, ROLE_COURSEADMIN, ROLE_GLOBALAUTHOR };
String[] values = new String[keys.length];
for (int i = 0; i < keys.length; i++) {
values[i] = translate(keys[i]);
}
roles = uifactory.addRadiosVertical("roles", "form.roles", formLayout, keys, values);
roles.select(ROLE_STUDENT, true);
String page = velocity_root + "/attributes.html";
FormLayoutContainer attrlayout = FormLayoutContainer.createCustomFormLayout("attributes", getTranslator(), page);
formLayout.add(attrlayout);
attrlayout.setLabel("form.attributes", null);
for (int i = 0; i < NUMATTR; i++) {
TextElement name = uifactory.addTextElement("attrname" + i, null, 255, "", attrlayout);
((AbstractComponent) name.getComponent()).setDomReplacementWrapperRequired(false);
name.setDisplaySize(12);
TextElement value = uifactory.addTextElement("attrvalue" + i, "form.equals", 255, "", attrlayout);
((AbstractComponent) value.getComponent()).setDomReplacementWrapperRequired(false);
value.setDisplaySize(12);
attrNames.add(name);
attrValues.add(value);
}
uifactory.addFormSubmitButton("submit", "command.preview", formLayout);
}
Aggregations