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