use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
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());
}
use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
the class LectureBlockDAOTest method getTeachers.
@Test
public void getTeachers() {
Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-7");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = createMinimalLectureBlock(entry);
dbInstance.commit();
Group defGroup = repositoryEntryRelationDao.getDefaultGroup(entry);
lectureBlockDao.addGroupToLectureBlock(lectureBlock, defGroup);
lectureService.addTeacher(lectureBlock, teacher);
dbInstance.commitAndCloseSession();
// get teachers
List<Identity> teachers = lectureBlockDao.getTeachers(entry);
Assert.assertNotNull(teachers);
Assert.assertEquals(1, teachers.size());
Assert.assertTrue(teachers.contains(teacher));
}
use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
the class LectureBlockDAOTest method getParticipants_lectureBlock.
@Test
public void getParticipants_lectureBlock() {
Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-3");
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-3");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-4");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = createMinimalLectureBlock(entry);
dbInstance.commit();
// add teacher
lectureService.addTeacher(lectureBlock, teacher);
dbInstance.commit();
// add participants
repositoryEntryRelationDao.addRole(participant1, entry, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(participant2, entry, GroupRoles.participant.name());
// add the course to the lectures
Group defGroup = repositoryService.getDefaultGroup(entry);
lectureBlock = lectureService.save(lectureBlock, Collections.singletonList(defGroup));
dbInstance.commitAndCloseSession();
List<Identity> participants = lectureBlockDao.getParticipants(lectureBlock);
Assert.assertNotNull(participants);
Assert.assertEquals(2, participants.size());
Assert.assertTrue(participants.contains(participant1));
Assert.assertTrue(participants.contains(participant2));
}
use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
the class LectureBlockDAOTest method getParticipants_repositoryEntryTeacher_paranoiaCheck.
@Test
public void getParticipants_repositoryEntryTeacher_paranoiaCheck() {
Identity teacher1 = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-7");
Identity teacher2 = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-8");
Identity coach1 = JunitTestHelper.createAndPersistIdentityAsRndUser("coach-2");
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-8");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-9");
Identity participant3 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-10");
Identity participant4 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-11");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock1 = createMinimalLectureBlock(entry);
LectureBlock lectureBlock2 = createMinimalLectureBlock(entry);
dbInstance.commit();
// add teachers
lectureService.addTeacher(lectureBlock1, teacher1);
lectureService.addTeacher(lectureBlock2, teacher2);
// add a participant to the course itself as noise
repositoryEntryRelationDao.addRole(coach1, entry, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(participant1, entry, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(participant2, entry, GroupRoles.participant.name());
// add the course to the lectures
Group defGroup = repositoryService.getDefaultGroup(entry);
lectureBlock1 = lectureService.save(lectureBlock1, Collections.singletonList(defGroup));
dbInstance.commit();
// add 2 participants to a business group linked to the repository entry
BusinessGroup group = businessGroupService.createBusinessGroup(null, "lectures 2", "tg", null, null, false, false, entry);
businessGroupRelationDao.addRole(coach1, group, GroupRoles.coach.name());
businessGroupRelationDao.addRole(participant3, group, GroupRoles.participant.name());
businessGroupRelationDao.addRole(participant4, group, GroupRoles.participant.name());
// add the group to the lectures
lectureBlock2 = lectureService.save(lectureBlock2, Collections.singletonList(group.getBaseGroup()));
dbInstance.commitAndCloseSession();
// teacher1 see participant 1 and 2
List<Identity> participantsBlocks1 = lectureBlockDao.getParticipants(entry, teacher1);
Assert.assertNotNull(participantsBlocks1);
Assert.assertEquals(2, participantsBlocks1.size());
Assert.assertTrue(participantsBlocks1.contains(participant1));
Assert.assertTrue(participantsBlocks1.contains(participant2));
// teacher 2 see participants 3 and 4
List<Identity> participantsBlock2 = lectureBlockDao.getParticipants(entry, teacher2);
Assert.assertNotNull(participantsBlock2);
Assert.assertEquals(2, participantsBlock2.size());
Assert.assertTrue(participantsBlock2.contains(participant3));
Assert.assertTrue(participantsBlock2.contains(participant4));
}
use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
the class LectureBlockDAOTest method getParticipants_repositoryEntryTeacher.
@Test
public void getParticipants_repositoryEntryTeacher() {
Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-6");
Identity coach1 = JunitTestHelper.createAndPersistIdentityAsRndUser("coach-2");
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-7");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-8");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = createMinimalLectureBlock(entry);
dbInstance.commit();
// add teacher
lectureService.addTeacher(lectureBlock, teacher);
// add a participant to the course itself as noise
repositoryEntryRelationDao.addRole(coach1, entry, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(participant1, entry, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(participant2, entry, GroupRoles.participant.name());
// add the course to the lectures
Group defGroup = repositoryService.getDefaultGroup(entry);
lectureBlock = lectureService.save(lectureBlock, Collections.singletonList(defGroup));
dbInstance.commitAndCloseSession();
List<Identity> participants = lectureBlockDao.getParticipants(entry, teacher);
Assert.assertNotNull(participants);
Assert.assertEquals(2, participants.size());
Assert.assertTrue(participants.contains(participant1));
Assert.assertTrue(participants.contains(participant2));
Assert.assertFalse(participants.contains(coach1));
}
Aggregations