Search in sources :

Example 56 with LectureBlock

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

the class LectureBlockDAOTest method deleteLectureBlock.

@Test
public void deleteLectureBlock() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock block = createMinimalLectureBlock(entry);
    dbInstance.commitAndCloseSession();
    Long blockKey = block.getKey();
    // delete the block
    lectureBlockDao.delete(block);
    dbInstance.commitAndCloseSession();
    // try to relaod the block
    LectureBlock deletedBlock = lectureBlockDao.loadByKey(blockKey);
    Assert.assertNull(deletedBlock);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 57 with LectureBlock

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

the class LectureBlockDAOTest method getParticipants_repositoryEntryTeacher.

@Test
public void getParticipants_repositoryEntryTeacher() {
    Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-6");
    Identity coach1 = JunitTestHelper.createAndPersistIdentityAsRndUser("coach-2");
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-7");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-8");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = createMinimalLectureBlock(entry);
    dbInstance.commit();
    // add teacher
    lectureService.addTeacher(lectureBlock, teacher);
    // 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);
    lectureBlock = lectureService.save(lectureBlock, Collections.singletonList(defGroup));
    dbInstance.commitAndCloseSession();
    List<Identity> participants = lectureBlockDao.getParticipants(entry, teacher);
    Assert.assertNotNull(participants);
    Assert.assertEquals(2, participants.size());
    Assert.assertTrue(participants.contains(participant1));
    Assert.assertTrue(participants.contains(participant2));
    Assert.assertFalse(participants.contains(coach1));
}
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 58 with LectureBlock

use of org.olat.modules.lecture.LectureBlock 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 59 with LectureBlock

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

the class LectureBlockDAOTest method createMinimalLectureBlock.

private LectureBlock createMinimalLectureBlock(RepositoryEntry entry) {
    LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.MINUTE, -15);
    lectureBlock.setStartDate(cal.getTime());
    cal.add(Calendar.MINUTE, 30);
    lectureBlock.setEndDate(cal.getTime());
    lectureBlock.setTitle("Hello lecturers");
    lectureBlock.setPlannedLecturesNumber(4);
    return lectureBlockDao.update(lectureBlock);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Calendar(java.util.Calendar)

Example 60 with LectureBlock

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

the class LectureBlockReminderDAOTest method loadLectureBlockToRemind.

@Test
public void loadLectureBlockToRemind() {
    Identity teacher1 = JunitTestHelper.createAndPersistIdentityAsRndUser("reminder-2");
    Identity teacher2 = JunitTestHelper.createAndPersistIdentityAsRndUser("reminder-3");
    LectureBlock lectureBlock = createMinimalLectureBlock(5);
    dbInstance.commit();
    // add the teachers
    lectureService.addTeacher(lectureBlock, teacher1);
    lectureService.addTeacher(lectureBlock, teacher2);
    LectureBlockReminderImpl reminder = lectureBlockReminderDao.createReminder(lectureBlock, teacher1, "ok");
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(reminder);
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -3);
    List<LectureBlockToTeacher> toRemind = lectureBlockReminderDao.getLectureBlockTeachersToReminder(cal.getTime());
    boolean hasTeacher1 = false;
    boolean hasTeacher2 = false;
    for (LectureBlockToTeacher remind : toRemind) {
        if (remind.getLectureBlock().equals(lectureBlock)) {
            if (remind.getTeacher().equals(teacher1)) {
                hasTeacher1 = true;
            } else if (remind.getTeacher().equals(teacher2)) {
                hasTeacher2 = true;
            }
        }
    }
    Assert.assertTrue(hasTeacher2);
    Assert.assertFalse(hasTeacher1);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockToTeacher(org.olat.modules.lecture.model.LectureBlockToTeacher) Calendar(java.util.Calendar) Identity(org.olat.core.id.Identity) LectureBlockReminderImpl(org.olat.modules.lecture.model.LectureBlockReminderImpl) 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