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());
}
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));
}
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);
}
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());
}
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());
}
Aggregations