use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class GroupBulkDownloadResource method prepare.
@Override
public void prepare(HttpServletResponse hres) {
try {
hres.setCharacterEncoding(encoding);
} catch (Exception e) {
log.error("", e);
}
String label = StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeWithMinutes(new Date()) + ".zip";
String urlEncodedLabel = StringHelper.urlEncodeUTF8(label);
hres.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + urlEncodedLabel);
hres.setHeader("Content-Description", urlEncodedLabel);
try (ZipOutputStream zout = new ZipOutputStream(hres.getOutputStream())) {
zout.setLevel(9);
ICourse course = CourseFactory.loadCourse(courseOres);
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
if (courseNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_GRADING)) {
List<Identity> assessableIdentities = CoreSpringFactory.getImpl(BusinessGroupService.class).getMembers(groups, GroupRoles.participant.name());
String courseTitle = course.getCourseTitle();
String fileName = ExportUtil.createFileNameWithTimeStamp(courseTitle, "xlsx");
List<AssessableCourseNode> nodes = Collections.<AssessableCourseNode>singletonList(courseNode);
try (OutputStream out = new ShieldOutputStream(zout)) {
zout.putNextEntry(new ZipEntry(fileName));
ScoreAccountingHelper.createCourseResultsOverviewXMLTable(assessableIdentities, nodes, course, locale, out);
zout.closeEntry();
} catch (Exception e) {
log.error("", e);
}
}
TaskList taskList = gtaManager.getTaskList(course.getCourseEnvironment().getCourseGroupManager().getCourseEntry(), courseNode);
for (BusinessGroup businessGroup : groups) {
courseNode.archiveNodeData(course, businessGroup, taskList, "", zout);
}
} catch (Exception e) {
log.error("", e);
}
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class GTAManagerImpl method filterBusinessGroups.
@Override
public List<BusinessGroup> filterBusinessGroups(List<BusinessGroup> groups, GTACourseNode cNode) {
if (groups == null || groups.isEmpty())
return new ArrayList<>(1);
List<BusinessGroup> filteredGroups = new ArrayList<>();
ModuleConfiguration config = cNode.getModuleConfiguration();
List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
for (BusinessGroup group : groups) {
if (groupKeys.contains(group.getKey())) {
filteredGroups.add(group);
}
}
if (filteredGroups.size() < groups.size()) {
List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
List<Long> groupKeysOfAreas = areaManager.findBusinessGroupKeysOfAreaKeys(areaKeys);
for (BusinessGroup group : groups) {
// don't add 2x
if (!groupKeys.contains(group.getKey()) && groupKeysOfAreas.contains(group.getKey())) {
filteredGroups.add(group);
}
}
}
return filteredGroups;
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class ACFrontendManager method reserveAccessToResource.
@Override
public boolean reserveAccessToResource(final Identity identity, final OfferAccess offer) {
final OLATResource resource = offer.getOffer().getResource();
String resourceType = resource.getResourceableTypeName();
if ("BusinessGroup".equals(resourceType)) {
boolean reserved = false;
final BusinessGroup group = businessGroupDao.loadForUpdate(resource.getResourceableId());
if (group.getMaxParticipants() == null && group.getMaxParticipants() <= 0) {
// don't need reservation
reserved = true;
} else {
BusinessGroup reloadedGroup = businessGroupService.loadBusinessGroup(resource);
ResourceReservation reservation = reservationDao.loadReservation(identity, resource);
if (reservation != null) {
reserved = true;
}
int currentCount = businessGroupService.countMembers(reloadedGroup, GroupRoles.participant.name());
int reservations = reservationDao.countReservations(resource);
if (currentCount + reservations < reloadedGroup.getMaxParticipants().intValue()) {
reservationDao.createReservation(identity, offer.getMethod().getType(), null, resource);
reserved = true;
}
}
return reserved;
}
return true;
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class RepositoryManagerTest method getParticipantRepositoryEntryWithGroups.
@Test
public void getParticipantRepositoryEntryWithGroups() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("re-stud-ld-" + UUID.randomUUID().toString());
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group = businessGroupService.createBusinessGroup(null, "studh", "th", null, null, false, false, re);
businessGroupRelationDao.addRole(id, group, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
List<RepositoryEntryLight> entries = repositoryManager.getParticipantRepositoryEntry(id, -1);
Assert.assertNotNull(entries);
Assert.assertFalse(entries.isEmpty());
boolean found = false;
Set<Long> duplicates = new HashSet<Long>();
for (RepositoryEntryLight entry : entries) {
Assert.assertTrue(duplicates.add(entry.getKey()));
if (entry.getKey().equals(re.getKey())) {
found = true;
}
}
Assert.assertTrue(found);
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class RepositoryManagerTest method getTutorRepositoryEntryWithGroups.
@Test
public void getTutorRepositoryEntryWithGroups() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("re-stud-lf-" + UUID.randomUUID().toString());
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group = businessGroupService.createBusinessGroup(null, "studi", "ti", null, null, false, false, re);
businessGroupRelationDao.addRole(id, group, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
List<RepositoryEntryLight> entries = repositoryManager.getTutorRepositoryEntry(id, -1);
Assert.assertNotNull(entries);
Assert.assertFalse(entries.isEmpty());
boolean found = false;
Set<Long> duplicates = new HashSet<Long>();
for (RepositoryEntryLight entry : entries) {
Assert.assertTrue(duplicates.add(entry.getKey()));
if (entry.getKey().equals(re.getKey())) {
found = true;
}
}
Assert.assertTrue(found);
}
Aggregations