Search in sources :

Example 66 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.

the class LectureBlockDAOTest method createLectureBlock.

@Test
public void createLectureBlock() {
    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();
    Assert.assertNotNull(lectureBlock);
    Assert.assertNotNull(lectureBlock.getKey());
    Assert.assertNotNull(lectureBlock.getCreationDate());
    Assert.assertNotNull(lectureBlock.getLastModified());
    Assert.assertNotNull(lectureBlock.getStartDate());
    Assert.assertNotNull(lectureBlock.getEndDate());
    Assert.assertEquals("Hello lecturers", lectureBlock.getTitle());
    Assert.assertEquals(LectureBlockStatus.active, lectureBlock.getStatus());
    Assert.assertEquals(LectureRollCallStatus.open, lectureBlock.getRollCallStatus());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) Test(org.junit.Test)

Example 67 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.

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 68 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.

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)

Example 69 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.

the class LectureBlockDAOTest method loadByTeachers_startEndDates.

@Test
public void loadByTeachers_startEndDates() {
    Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-1");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = createMinimalLectureBlock(entry);
    dbInstance.commitAndCloseSession();
    lectureService.addTeacher(lectureBlock, teacher);
    dbInstance.commitAndCloseSession();
    // search lectures with the string
    LecturesBlockSearchParameters searchNowParams = new LecturesBlockSearchParameters();
    Calendar now = Calendar.getInstance();
    now.add(Calendar.DATE, -1);
    searchNowParams.setStartDate(now.getTime());
    now.add(Calendar.DATE, 2);
    searchNowParams.setEndDate(now.getTime());
    List<LectureBlock> blocks = lectureBlockDao.loadByTeacher(teacher, searchNowParams);
    Assert.assertNotNull(blocks);
    Assert.assertEquals(1, blocks.size());
    Assert.assertEquals(lectureBlock, blocks.get(0));
    // search in future
    LecturesBlockSearchParameters searchFutureParams = new LecturesBlockSearchParameters();
    now.add(Calendar.DATE, 2);
    searchFutureParams.setStartDate(now.getTime());
    now.add(Calendar.DATE, 2);
    searchFutureParams.setEndDate(now.getTime());
    List<LectureBlock> futureBlocks = lectureBlockDao.loadByTeacher(teacher, searchFutureParams);
    Assert.assertNotNull(futureBlocks);
    Assert.assertEquals(0, futureBlocks.size());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LecturesBlockSearchParameters(org.olat.modules.lecture.model.LecturesBlockSearchParameters) Calendar(java.util.Calendar) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 70 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.

the class LectureBlockDAOTest method loadByTeachers_startDate.

@Test
public void loadByTeachers_startDate() {
    Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-3");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = createMinimalLectureBlock(entry);
    dbInstance.commitAndCloseSession();
    lectureService.addTeacher(lectureBlock, teacher);
    dbInstance.commitAndCloseSession();
    // search lectures with the string
    LecturesBlockSearchParameters searchNowParams = new LecturesBlockSearchParameters();
    Calendar now = Calendar.getInstance();
    now.add(Calendar.DATE, -1);
    searchNowParams.setStartDate(now.getTime());
    List<LectureBlock> blocks = lectureBlockDao.loadByTeacher(teacher, searchNowParams);
    Assert.assertNotNull(blocks);
    Assert.assertEquals(1, blocks.size());
    Assert.assertEquals(lectureBlock, blocks.get(0));
    // search in future
    LecturesBlockSearchParameters searchFutureParams = new LecturesBlockSearchParameters();
    now.add(Calendar.DATE, 2);
    searchFutureParams.setStartDate(now.getTime());
    List<LectureBlock> futureBlocks = lectureBlockDao.loadByTeacher(teacher, searchFutureParams);
    Assert.assertNotNull(futureBlocks);
    Assert.assertEquals(0, futureBlocks.size());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LecturesBlockSearchParameters(org.olat.modules.lecture.model.LecturesBlockSearchParameters) Calendar(java.util.Calendar) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) 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