Search in sources :

Example 71 with LectureBlock

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

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

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

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

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

the class LectureBlockDAOTest method getRollCallAsTeacher.

@Test
public void getRollCallAsTeacher() {
    Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-1");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = createMinimalLectureBlock(entry);
    dbInstance.commitAndCloseSession();
    // enable lecture on this entry
    RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
    config.setLectureEnabled(true);
    config = lectureService.updateRepositoryEntryLectureConfiguration(config);
    lectureService.addTeacher(lectureBlock, teacher);
    dbInstance.commitAndCloseSession();
    List<LectureBlock> rollcalls = lectureBlockDao.getRollCallAsTeacher(teacher);
    Assert.assertNotNull(rollcalls);
    Assert.assertEquals(1, rollcalls.size());
    Assert.assertEquals(lectureBlock, rollcalls.get(0));
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Test(org.junit.Test)

Example 74 with LectureBlock

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

the class LectureBlockReminderDAOTest method deleteReminder.

@Test
public void deleteReminder() {
    // create a reminder
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("reminder-to-delete-1");
    LectureBlock lectureBlock = createMinimalLectureBlock(2);
    LectureBlockReminderImpl reminder = lectureBlockReminderDao.createReminder(lectureBlock, id, "Delete it");
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(reminder);
    // delete the reminders
    int deletedRows = lectureBlockReminderDao.deleteReminders(id);
    Assert.assertEquals(1, deletedRows);
    dbInstance.commitAndCloseSession();
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -3);
    List<LectureBlockToTeacher> toRemind = lectureBlockReminderDao.getLectureBlockTeachersToReminder(cal.getTime());
    boolean hasId = false;
    for (LectureBlockToTeacher remind : toRemind) {
        if (remind.getLectureBlock().equals(lectureBlock)) {
            if (remind.getTeacher().equals(id)) {
                hasId = true;
            }
        }
    }
    Assert.assertFalse(hasId);
}
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)

Example 75 with LectureBlock

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

the class LectureBlockReminderDAOTest method loadLectureBlockToRemind_status.

@Test
public void loadLectureBlockToRemind_status() {
    Identity teacher1 = JunitTestHelper.createAndPersistIdentityAsRndUser("reminder-8");
    Identity teacher2 = JunitTestHelper.createAndPersistIdentityAsRndUser("reminder-9");
    LectureBlock lectureBlockAutoClosed = createMinimalLectureBlock(5);
    LectureBlock lectureBlockClosed = createMinimalLectureBlock(5);
    LectureBlock lectureBlockCancelled = createMinimalLectureBlock(5);
    LectureBlock lectureBlockReopen = createMinimalLectureBlock(5);
    LectureBlock lectureBlockOpen = createMinimalLectureBlock(5);
    LectureBlock lectureBlock = createMinimalLectureBlock(5);
    dbInstance.commit();
    // add the teachers
    lectureService.addTeacher(lectureBlockAutoClosed, teacher1);
    lectureService.addTeacher(lectureBlockClosed, teacher1);
    lectureService.addTeacher(lectureBlockCancelled, teacher2);
    lectureService.addTeacher(lectureBlockReopen, teacher1);
    lectureService.addTeacher(lectureBlockReopen, teacher2);
    lectureService.addTeacher(lectureBlockOpen, teacher1);
    lectureService.addTeacher(lectureBlockOpen, teacher2);
    lectureService.addTeacher(lectureBlock, teacher2);
    dbInstance.commit();
    lectureBlockAutoClosed.setRollCallStatus(LectureRollCallStatus.autoclosed);
    lectureBlockAutoClosed = lectureService.save(lectureBlockAutoClosed, null);
    lectureBlockClosed.setRollCallStatus(LectureRollCallStatus.closed);
    lectureBlockClosed = lectureService.save(lectureBlockClosed, null);
    lectureBlockCancelled.setStatus(LectureBlockStatus.cancelled);
    lectureBlockCancelled = lectureService.save(lectureBlockCancelled, null);
    lectureBlockReopen.setRollCallStatus(LectureRollCallStatus.reopen);
    lectureBlockReopen = lectureService.save(lectureBlockReopen, null);
    lectureBlockOpen.setRollCallStatus(LectureRollCallStatus.open);
    lectureBlockOpen = lectureService.save(lectureBlockOpen, null);
    dbInstance.commitAndCloseSession();
    ;
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -3);
    List<LectureBlockToTeacher> toRemind = lectureBlockReminderDao.getLectureBlockTeachersToReminder(cal.getTime());
    boolean hasBlock = false;
    boolean hasBlockOpen = false;
    boolean hasOtherBlock = false;
    for (LectureBlockToTeacher remind : toRemind) {
        if (remind.getLectureBlock().equals(lectureBlock)) {
            hasBlock = true;
        } else if (remind.getLectureBlock().equals(lectureBlockOpen)) {
            hasBlockOpen = true;
        } else if (remind.getLectureBlock().equals(lectureBlockAutoClosed) || remind.getLectureBlock().equals(lectureBlockClosed) || remind.getLectureBlock().equals(lectureBlockCancelled)) {
            hasOtherBlock = true;
        }
    }
    Assert.assertTrue(hasBlock);
    Assert.assertTrue(hasBlockOpen);
    Assert.assertFalse(hasOtherBlock);
}
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) 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