use of org.olat.modules.lecture.LectureBlock 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.modules.lecture.LectureBlock 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.modules.lecture.LectureBlock 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.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureBlockDAOTest method getRollCallAsTeacher.
@Test
public void getRollCallAsTeacher() {
Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-1");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = createMinimalLectureBlock(entry);
dbInstance.commitAndCloseSession();
// enable lecture on this entry
RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
config.setLectureEnabled(true);
config = lectureService.updateRepositoryEntryLectureConfiguration(config);
lectureService.addTeacher(lectureBlock, teacher);
dbInstance.commitAndCloseSession();
List<LectureBlock> rollcalls = lectureBlockDao.getRollCallAsTeacher(teacher);
Assert.assertNotNull(rollcalls);
Assert.assertEquals(1, rollcalls.size());
Assert.assertEquals(lectureBlock, rollcalls.get(0));
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureBlockDAOTest method getLectureBlocks_entry.
@Test
public void getLectureBlocks_entry() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
lectureBlock.setStartDate(new Date());
lectureBlock.setEndDate(new Date());
lectureBlock.setTitle("Hello lecturers");
lectureBlock = lectureBlockDao.update(lectureBlock);
dbInstance.commitAndCloseSession();
List<LectureBlock> blocks = lectureBlockDao.getLectureBlocks(entry);
Assert.assertNotNull(blocks);
Assert.assertEquals(1, blocks.size());
LectureBlock loadedBlock = blocks.get(0);
Assert.assertEquals(lectureBlock, loadedBlock);
}
Aggregations