Search in sources :

Example 51 with LectureBlock

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));
}
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 52 with LectureBlock

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));
}
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 53 with LectureBlock

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));
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Group(org.olat.basesecurity.Group) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) BusinessGroup(org.olat.group.BusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 54 with LectureBlock

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));
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Test(org.junit.Test)

Example 55 with LectureBlock

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);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) Test(org.junit.Test)

Aggregations

LectureBlock (org.olat.modules.lecture.LectureBlock)232 Identity (org.olat.core.id.Identity)132 Test (org.junit.Test)116 RepositoryEntry (org.olat.repository.RepositoryEntry)98 Date (java.util.Date)64 LectureBlockRollCall (org.olat.modules.lecture.LectureBlockRollCall)42 URI (java.net.URI)30 ArrayList (java.util.ArrayList)30 HttpResponse (org.apache.http.HttpResponse)30 Group (org.olat.basesecurity.Group)30 Calendar (java.util.Calendar)26 ICourse (org.olat.course.ICourse)24 BusinessGroup (org.olat.group.BusinessGroup)24 CourseConfigVO (org.olat.restapi.support.vo.CourseConfigVO)24 LectureBlockToGroup (org.olat.modules.lecture.LectureBlockToGroup)22 RepositoryEntryLectureConfiguration (org.olat.modules.lecture.RepositoryEntryLectureConfiguration)20 LecturesBlockSearchParameters (org.olat.modules.lecture.model.LecturesBlockSearchParameters)16 List (java.util.List)14 HttpGet (org.apache.http.client.methods.HttpGet)14 LectureBlockToTeacher (org.olat.modules.lecture.model.LectureBlockToTeacher)14