Search in sources :

Example 41 with Group

use of org.olat.basesecurity.Group in project openolat by klemens.

the class LectureServiceTest method getParticipantLecturesStatistics.

@Test
public void getParticipantLecturesStatistics() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-6-1");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-6-2");
    // a closed lecture block in the past
    LectureBlock lectureBlock1 = createClosedLectureBlockInPast(entry);
    LectureBlock lectureBlock2 = createClosedLectureBlockInPast(entry);
    LectureBlock lectureBlock3 = createClosedLectureBlockInPast(entry);
    // create summary in the past
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -4);
    lectureParticipantSummaryDao.createSummary(entry, participant1, cal.getTime());
    lectureParticipantSummaryDao.createSummary(entry, participant2, cal.getTime());
    // add participants to the "course"
    repositoryEntryRelationDAO.addRole(participant1, entry, GroupRole.participant.name());
    repositoryEntryRelationDAO.addRole(participant2, entry, GroupRole.participant.name());
    dbInstance.commitAndCloseSession();
    RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
    config.setLectureEnabled(true);
    lectureService.updateRepositoryEntryLectureConfiguration(config);
    // add the course to the lectures
    Group defGroup = repositoryService.getDefaultGroup(entry);
    lectureBlock1 = lectureService.save(lectureBlock1, Collections.singletonList(defGroup));
    lectureBlock2 = lectureService.save(lectureBlock2, Collections.singletonList(defGroup));
    lectureBlock3 = lectureService.save(lectureBlock3, Collections.singletonList(defGroup));
    dbInstance.commitAndCloseSession();
    lectureService.addRollCall(participant1, lectureBlock1, null, toList(1, 2));
    lectureService.addRollCall(participant1, lectureBlock2, null, toList(1, 2, 3, 4));
    lectureService.addRollCall(participant2, lectureBlock1, null, toList(1, 2, 3, 4));
    lectureService.addRollCall(participant2, lectureBlock3, null, toList(2, 3, 4));
    dbInstance.commitAndCloseSession();
    // check first participant
    List<LectureBlockStatistics> statistics_1 = lectureService.getParticipantLecturesStatistics(participant1);
    Assert.assertNotNull(statistics_1);
    Assert.assertEquals(1, statistics_1.size());
    LectureBlockStatistics statistic_1 = statistics_1.get(0);
    Assert.assertEquals(12, statistic_1.getTotalPersonalPlannedLectures());
    Assert.assertEquals(2, statistic_1.getTotalAttendedLectures());
    Assert.assertEquals(6, statistic_1.getTotalAbsentLectures());
    // check second participant
    List<LectureBlockStatistics> statistics_2 = lectureService.getParticipantLecturesStatistics(participant2);
    Assert.assertNotNull(statistics_2);
    Assert.assertEquals(1, statistics_2.size());
    LectureBlockStatistics statistic_2 = statistics_2.get(0);
    Assert.assertEquals(12, statistic_2.getTotalPersonalPlannedLectures());
    Assert.assertEquals(1, statistic_2.getTotalAttendedLectures());
    Assert.assertEquals(7, statistic_2.getTotalAbsentLectures());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Group(org.olat.basesecurity.Group) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) BusinessGroup(org.olat.group.BusinessGroup) Calendar(java.util.Calendar) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) LectureBlockStatistics(org.olat.modules.lecture.model.LectureBlockStatistics) Test(org.junit.Test)

Example 42 with Group

use of org.olat.basesecurity.Group in project openolat by klemens.

the class LectureServiceTest method getLectureStatistics_checkQuerySyntax.

@Test
public void getLectureStatistics_checkQuerySyntax() {
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-5-1");
    // a lecture block
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = createMinimalLectureBlock(entry);
    // add participant to the "course"
    repositoryEntryRelationDAO.addRole(participant, entry, GroupRole.participant.name());
    dbInstance.commitAndCloseSession();
    // enable lectures
    RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
    config.setLectureEnabled(true);
    lectureService.updateRepositoryEntryLectureConfiguration(config);
    // add the course to the lecture
    Group defGroup = repositoryService.getDefaultGroup(entry);
    lectureBlock = lectureService.save(lectureBlock, Collections.singletonList(defGroup));
    dbInstance.commitAndCloseSession();
    lectureService.addRollCall(participant, lectureBlock, null, Collections.singletonList(3));
    dbInstance.commitAndCloseSession();
    // add
    List<LectureBlockStatistics> statistics = lectureService.getParticipantLecturesStatistics(participant);
    Assert.assertNotNull(statistics);
    Assert.assertEquals(1, statistics.size());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Group(org.olat.basesecurity.Group) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) LectureBlockStatistics(org.olat.modules.lecture.model.LectureBlockStatistics) Test(org.junit.Test)

Example 43 with Group

use of org.olat.basesecurity.Group in project openolat by klemens.

the class LectureServiceTest method getParticipants.

@Test
public void getParticipants() {
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-4-1");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-4-2");
    // a lecture block
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = createMinimalLectureBlock(entry);
    // add 2 participants to the "course"
    repositoryEntryRelationDAO.addRole(participant1, entry, GroupRole.participant.name());
    repositoryEntryRelationDAO.addRole(participant2, entry, GroupRole.participant.name());
    dbInstance.commitAndCloseSession();
    // add the course to the lecture
    Group defGroup = repositoryService.getDefaultGroup(entry);
    lectureBlock = lectureService.save(lectureBlock, Collections.singletonList(defGroup));
    dbInstance.commitAndCloseSession();
    List<Identity> participants = lectureService.getParticipants(lectureBlock);
    Assert.assertNotNull(participants);
    Assert.assertEquals(2, participants.size());
    Assert.assertTrue(participants.contains(participant1));
    Assert.assertTrue(participants.contains(participant2));
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Group(org.olat.basesecurity.Group) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 44 with Group

use of org.olat.basesecurity.Group in project openolat by klemens.

the class LecturesBlocksTest method addRepositoryEntryDefaultGroupToLectureBlock.

@Test
public void addRepositoryEntryDefaultGroupToLectureBlock() throws IOException, URISyntaxException {
    Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-1");
    ICourse course = CoursesWebService.createEmptyCourse(author, "Course with absence config", "Course with absence configuration", new CourseConfigVO());
    RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    LectureBlock block = createLectureBlock(entry);
    dbInstance.commit();
    RestConnection conn = new RestConnection();
    Assert.assertTrue(conn.login("administrator", "openolat"));
    URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("entries").path(entry.getKey().toString()).path("lectureblocks").path(block.getKey().toString()).path("participants").path("repositoryentry").build();
    HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    // check the response
    Assert.assertEquals(200, response.getStatusLine().getStatusCode());
    EntityUtils.consume(response.getEntity());
    // check the database
    List<Group> groups = lectureService.getLectureBlockToGroups(block);
    Assert.assertNotNull(groups);
    Assert.assertEquals(1, groups.size());
    Group defGroup = repositoryService.getDefaultGroup(entry);
    Assert.assertEquals(defGroup, groups.get(0));
}
Also used : CourseConfigVO(org.olat.restapi.support.vo.CourseConfigVO) LectureBlock(org.olat.modules.lecture.LectureBlock) Group(org.olat.basesecurity.Group) HttpResponse(org.apache.http.HttpResponse) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) URI(java.net.URI) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Example 45 with Group

use of org.olat.basesecurity.Group in project openolat by klemens.

the class EPPolicyManager method applyPolicyToInvitation.

private EPStructureElementToGroupRelation applyPolicyToInvitation(Invitation invitation, EPMapPolicy policy, PortfolioStructureMap map) {
    invitation = dbInstance.getCurrentEntityManager().merge(invitation);
    Group secGroup = invitation.getBaseGroup();
    Collection<EPStructureElementToGroupRelation> currentRelations = map.getGroups();
    for (EPStructureElementToGroupRelation currentRelation : currentRelations) {
        if (secGroup.equals(currentRelation.getGroup())) {
            updatePolicy(currentRelation, policy.getFrom(), policy.getTo());
            return currentRelation;
        }
    }
    return createBaseRelation(map, secGroup, EPMapPolicy.Type.invitation.name(), policy.getFrom(), policy.getTo());
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) Group(org.olat.basesecurity.Group) EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation)

Aggregations

Group (org.olat.basesecurity.Group)170 Test (org.junit.Test)92 Identity (org.olat.core.id.Identity)80 BusinessGroup (org.olat.group.BusinessGroup)72 RepositoryEntry (org.olat.repository.RepositoryEntry)46 ArrayList (java.util.ArrayList)28 GroupMembership (org.olat.basesecurity.GroupMembership)26 LectureBlock (org.olat.modules.lecture.LectureBlock)26 OLATResource (org.olat.resource.OLATResource)26 LectureBlockToGroup (org.olat.modules.lecture.LectureBlockToGroup)20 Date (java.util.Date)16 SecurityGroup (org.olat.basesecurity.SecurityGroup)16 EPStructureElementToGroupRelation (org.olat.portfolio.model.structel.EPStructureElementToGroupRelation)14 HashSet (java.util.HashSet)12 RepositoryEntryToGroupRelation (org.olat.repository.model.RepositoryEntryToGroupRelation)11 HashMap (java.util.HashMap)8 Grant (org.olat.basesecurity.Grant)8 Calendar (java.util.Calendar)6 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)6 BGRights (org.olat.group.right.BGRights)5