Search in sources :

Example 46 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.

the class LectureServiceTest method createClosedLectureBlockInPast.

private LectureBlock createClosedLectureBlockInPast(RepositoryEntry entry) {
    LectureBlock lectureBlock = lectureService.createLectureBlock(entry);
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -2);
    lectureBlock.setStartDate(cal.getTime());
    lectureBlock.setEndDate(cal.getTime());
    lectureBlock.setStatus(LectureBlockStatus.done);
    lectureBlock.setRollCallStatus(LectureRollCallStatus.closed);
    lectureBlock.setTitle("Hello lecturers");
    lectureBlock.setPlannedLecturesNumber(4);
    lectureBlock.setEffectiveLecturesNumber(4);
    return lectureService.save(lectureBlock, null);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Calendar(java.util.Calendar)

Example 47 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.

the class RepositoryEntryLectureConfigurationDAOTest method getRepositoryEntryLectureConfiguration_lectureBlock.

@Test
public void getRepositoryEntryLectureConfiguration_lectureBlock() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntryLectureConfiguration config = lectureConfigurationDao.createConfiguration(entry);
    dbInstance.commit();
    LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
    lectureBlock.setStartDate(new Date());
    lectureBlock.setEndDate(new Date());
    lectureBlock.setTitle("Hello lecturers");
    lectureBlock = lectureBlockDao.update(lectureBlock);
    dbInstance.commitAndCloseSession();
    // get the configuration
    RepositoryEntryLectureConfiguration reloadedConfig = lectureConfigurationDao.getConfiguration(lectureBlock);
    Assert.assertEquals(config, reloadedConfig);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 48 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.

the class LectureBlockDAOTest method loadByTeachers_endDate.

@Test
public void loadByTeachers_endDate() {
    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.setEndDate(now.getTime());
    List<LectureBlock> blocks = lectureBlockDao.loadByTeacher(teacher, searchNowParams);
    Assert.assertNotNull(blocks);
    Assert.assertEquals(0, blocks.size());
    // search in future
    LecturesBlockSearchParameters searchFutureParams = new LecturesBlockSearchParameters();
    now.add(Calendar.DATE, 2);
    searchFutureParams.setEndDate(now.getTime());
    List<LectureBlock> futureBlocks = lectureBlockDao.loadByTeacher(teacher, searchFutureParams);
    Assert.assertNotNull(futureBlocks);
    Assert.assertEquals(1, futureBlocks.size());
    Assert.assertEquals(lectureBlock, futureBlocks.get(0));
}
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 49 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.

the class LectureBlockDAOTest method getLectureBlocks_all.

@Test
public void getLectureBlocks_all() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
    lectureBlock.setStartDate(new Date());
    lectureBlock.setEndDate(new Date());
    lectureBlock.setTitle("Get them all");
    lectureBlock = lectureBlockDao.update(lectureBlock);
    dbInstance.commitAndCloseSession();
    List<LectureBlock> blocks = lectureBlockDao.getLectureBlocks();
    Assert.assertNotNull(blocks);
    Assert.assertTrue(blocks.size() >= 1);
    Assert.assertTrue(blocks.contains(lectureBlock));
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) Test(org.junit.Test)

Example 50 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.

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)

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