Search in sources :

Example 1 with LectureParticipantSummary

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

the class LectureParticipantSummaryDAO method getLectureParticipantSummaries.

public List<ParticipantAndLectureSummary> getLectureParticipantSummaries(LectureBlock block) {
    StringBuilder sb = new StringBuilder();
    sb.append("select participant, summary from lectureblock block").append(" inner join block.groups blockGroup").append(" inner join blockGroup.group bGroup").append(" inner join bGroup.members membership on (membership.role='").append(GroupRoles.participant.name()).append("')").append(" inner join membership.identity participant").append(" inner join participant.user participantUser").append(" left join lectureparticipantsummary summary on (summary.identity.key=participant.key and summary.entry.key=block.entry.key)").append(" where block.key=:blockKey");
    List<Object[]> rawObjects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("blockKey", block.getKey()).getResultList();
    List<ParticipantAndLectureSummary> summaries = new ArrayList<>(rawObjects.size());
    for (Object[] rawObject : rawObjects) {
        Identity identity = (Identity) rawObject[0];
        LectureParticipantSummary summary = (LectureParticipantSummary) rawObject[1];
        summaries.add(new ParticipantAndLectureSummary(identity, summary));
    }
    return summaries;
}
Also used : ParticipantAndLectureSummary(org.olat.modules.lecture.model.ParticipantAndLectureSummary) LectureParticipantSummary(org.olat.modules.lecture.LectureParticipantSummary) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Example 2 with LectureParticipantSummary

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

the class LectureParticipantSummaryDAOTest method createAndGetSummary.

@Test
public void createAndGetSummary() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("summary-2");
    // null must be accepted
    lectureParticipantSummaryDao.createSummary(entry, id, new Date());
    dbInstance.commitAndCloseSession();
    LectureParticipantSummary summary = lectureParticipantSummaryDao.getSummary(entry, id);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(summary);
    Assert.assertNotNull(summary.getKey());
    Assert.assertNotNull(summary.getCreationDate());
    Assert.assertNotNull(summary.getLastModified());
    Assert.assertNotNull(summary.getFirstAdmissionDate());
    LectureParticipantSummaryImpl summaryImpl = (LectureParticipantSummaryImpl) summary;
    Assert.assertEquals(entry, summaryImpl.getEntry());
    Assert.assertEquals(id, summaryImpl.getIdentity());
}
Also used : LectureParticipantSummary(org.olat.modules.lecture.LectureParticipantSummary) LectureParticipantSummaryImpl(org.olat.modules.lecture.model.LectureParticipantSummaryImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 3 with LectureParticipantSummary

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

the class LectureParticipantSummaryDAOTest method createAndGetSummary.

@Test
public void createAndGetSummary() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("summary-2");
    // null must be accepted
    lectureParticipantSummaryDao.createSummary(entry, id, new Date());
    dbInstance.commitAndCloseSession();
    LectureParticipantSummary summary = lectureParticipantSummaryDao.getSummary(entry, id);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(summary);
    Assert.assertNotNull(summary.getKey());
    Assert.assertNotNull(summary.getCreationDate());
    Assert.assertNotNull(summary.getLastModified());
    Assert.assertNotNull(summary.getFirstAdmissionDate());
    LectureParticipantSummaryImpl summaryImpl = (LectureParticipantSummaryImpl) summary;
    Assert.assertEquals(entry, summaryImpl.getEntry());
    Assert.assertEquals(id, summaryImpl.getIdentity());
}
Also used : LectureParticipantSummary(org.olat.modules.lecture.LectureParticipantSummary) LectureParticipantSummaryImpl(org.olat.modules.lecture.model.LectureParticipantSummaryImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 4 with LectureParticipantSummary

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

the class LectureParticipantSummaryDAO method getLectureParticipantSummaries.

public List<ParticipantAndLectureSummary> getLectureParticipantSummaries(LectureBlock block) {
    StringBuilder sb = new StringBuilder();
    sb.append("select participant, summary from lectureblock block").append(" inner join block.groups blockGroup").append(" inner join blockGroup.group bGroup").append(" inner join bGroup.members membership on (membership.role='").append(GroupRoles.participant.name()).append("')").append(" inner join membership.identity participant").append(" inner join participant.user participantUser").append(" left join lectureparticipantsummary summary on (summary.identity.key=participant.key and summary.entry.key=block.entry.key)").append(" where block.key=:blockKey");
    List<Object[]> rawObjects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("blockKey", block.getKey()).getResultList();
    List<ParticipantAndLectureSummary> summaries = new ArrayList<>(rawObjects.size());
    for (Object[] rawObject : rawObjects) {
        Identity identity = (Identity) rawObject[0];
        LectureParticipantSummary summary = (LectureParticipantSummary) rawObject[1];
        summaries.add(new ParticipantAndLectureSummary(identity, summary));
    }
    return summaries;
}
Also used : ParticipantAndLectureSummary(org.olat.modules.lecture.model.ParticipantAndLectureSummary) LectureParticipantSummary(org.olat.modules.lecture.LectureParticipantSummary) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Example 5 with LectureParticipantSummary

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

the class AbstractLectureBlockAuditLogExport method addContent.

private void addContent(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
    for (LectureBlockAuditLog logEntry : auditLog) {
        int pos = 0;
        Row row = exportSheet.newRow();
        Date creationDate = logEntry.getCreationDate();
        row.addCell(pos++, creationDate, workbook.getStyles().getDateTimeStyle());
        row.addCell(pos++, logEntry.getAction());
        // repo entry title
        row.addCell(pos++, getRepositoryEntryDisplayName(logEntry.getEntryKey()), null);
        // lecture block
        row.addCell(pos++, getLectureBlockTitle(logEntry.getLectureBlockKey()), null);
        // date start / end
        // planned / effective
        LectureBlock auditBlock = null;
        LectureBlockRollCall auditRollCall = null;
        LectureParticipantSummary auditSummary = null;
        if (logEntry.getRollCallKey() != null) {
            auditRollCall = getAuditRollCall(logEntry.getAfter());
        }
        if (auditRollCall == null) {
            if (logEntry.getLectureBlockKey() != null) {
                auditBlock = getAuditLectureBlock(logEntry.getAfter());
            } else {
                auditSummary = getAuditLectureParticipantSummary(logEntry.getAfter());
            }
        }
        if (auditBlock != null) {
            if (auditBlock.getStatus() == null) {
                pos++;
            } else {
                row.addCell(pos++, auditBlock.getStatus().name(), null);
            }
            row.addCell(pos++, auditBlock.getPlannedLecturesNumber(), null);
            row.addCell(pos++, auditBlock.getEffectiveLecturesNumber(), null);
            row.addCell(pos++, auditBlock.getEffectiveEndDate(), workbook.getStyles().getDateTimeStyle());
        } else {
            pos += 4;
        }
        if (auditRollCall != null) {
            Long assessedIdentityKey = logEntry.getIdentityKey();
            String fullname = userManager.getUserDisplayName(assessedIdentityKey);
            row.addCell(pos++, fullname);
            row.addCell(pos++, auditRollCall.getLecturesAttendedNumber(), null);
            row.addCell(pos++, auditRollCall.getLecturesAbsentNumber(), null);
            if (authorizedAbsenceEnabled) {
                if (auditRollCall.getAbsenceAuthorized() != null && auditRollCall.getAbsenceAuthorized().booleanValue()) {
                    row.addCell(pos++, "x");
                } else {
                    pos++;
                }
                row.addCell(pos++, auditRollCall.getAbsenceReason(), null);
            }
            row.addCell(pos++, auditRollCall.getComment(), null);
        } else if (auditSummary != null) {
            Long assessedIdentityKey = logEntry.getIdentityKey();
            String fullname = userManager.getUserDisplayName(assessedIdentityKey);
            row.addCell(pos++, fullname);
            pos += 2;
            if (authorizedAbsenceEnabled) {
                pos += 2;
            }
            String summaryComment = getSummaryComment(getAuditLectureParticipantSummary(logEntry.getBefore()), auditSummary);
            row.addCell(pos++, summaryComment, null);
        } else {
            pos += 4;
            if (authorizedAbsenceEnabled) {
                pos += 2;
            }
        }
        Long authorKey = logEntry.getAuthorKey();
        if (authorKey != null) {
            String fullname = userManager.getUserDisplayName(authorKey);
            row.addCell(pos++, fullname);
        }
    }
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureParticipantSummary(org.olat.modules.lecture.LectureParticipantSummary) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) LectureBlockAuditLog(org.olat.modules.lecture.LectureBlockAuditLog) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Date(java.util.Date)

Aggregations

LectureParticipantSummary (org.olat.modules.lecture.LectureParticipantSummary)6 Date (java.util.Date)4 Identity (org.olat.core.id.Identity)4 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)2 LectureBlock (org.olat.modules.lecture.LectureBlock)2 LectureBlockAuditLog (org.olat.modules.lecture.LectureBlockAuditLog)2 LectureBlockRollCall (org.olat.modules.lecture.LectureBlockRollCall)2 LectureParticipantSummaryImpl (org.olat.modules.lecture.model.LectureParticipantSummaryImpl)2 ParticipantAndLectureSummary (org.olat.modules.lecture.model.ParticipantAndLectureSummary)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2