Search in sources :

Example 1 with LecturesBlockSearchParameters

use of org.olat.modules.lecture.model.LecturesBlockSearchParameters in project OpenOLAT by OpenOLAT.

the class AbstractTeacherOverviewController method doSearch.

private void doSearch(SearchLecturesBlockEvent event) {
    LecturesBlockSearchParameters searchParams = new LecturesBlockSearchParameters();
    searchParams.setSearchString(event.getSearchString());
    searchParams.setStartDate(event.getStartDate());
    searchParams.setEndDate(event.getEndDate());
    loadModel(searchParams);
}
Also used : LecturesBlockSearchParameters(org.olat.modules.lecture.model.LecturesBlockSearchParameters)

Example 2 with LecturesBlockSearchParameters

use of org.olat.modules.lecture.model.LecturesBlockSearchParameters 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 3 with LecturesBlockSearchParameters

use of org.olat.modules.lecture.model.LecturesBlockSearchParameters 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)

Example 4 with LecturesBlockSearchParameters

use of org.olat.modules.lecture.model.LecturesBlockSearchParameters in project OpenOLAT by OpenOLAT.

the class LectureBlockDAOTest method loadByTeachers.

@Test
public void loadByTeachers() {
    Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-1");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = createMinimalLectureBlock(entry);
    dbInstance.commitAndCloseSession();
    lectureService.addTeacher(lectureBlock, teacher);
    dbInstance.commitAndCloseSession();
    // search all
    LecturesBlockSearchParameters searchParams = new LecturesBlockSearchParameters();
    List<LectureBlock> blocks = lectureBlockDao.loadByTeacher(teacher, searchParams);
    Assert.assertNotNull(blocks);
    Assert.assertEquals(1, blocks.size());
    Assert.assertEquals(lectureBlock, blocks.get(0));
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LecturesBlockSearchParameters(org.olat.modules.lecture.model.LecturesBlockSearchParameters) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 5 with LecturesBlockSearchParameters

use of org.olat.modules.lecture.model.LecturesBlockSearchParameters 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)

Aggregations

LecturesBlockSearchParameters (org.olat.modules.lecture.model.LecturesBlockSearchParameters)14 LectureBlock (org.olat.modules.lecture.LectureBlock)12 Test (org.junit.Test)10 Identity (org.olat.core.id.Identity)10 RepositoryEntry (org.olat.repository.RepositoryEntry)10 Calendar (java.util.Calendar)6 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 Roles (org.olat.core.id.Roles)2 LectureService (org.olat.modules.lecture.LectureService)2 RestSecurityHelper.getRoles (org.olat.restapi.security.RestSecurityHelper.getRoles)2 RestSecurityHelper.parseDate (org.olat.restapi.security.RestSecurityHelper.parseDate)2