Search in sources :

Example 21 with LectureBlockRollCall

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

the class LectureServiceImpl method adaptAll.

@Override
public void adaptAll(Identity author) {
    List<LectureBlock> lectureBlocks = lectureBlockDao.getLectureBlocks();
    for (LectureBlock lectureBlock : lectureBlocks) {
        List<LectureBlockRollCall> rollCallList = lectureBlockRollCallDao.getRollCalls(lectureBlock);
        for (LectureBlockRollCall rollCall : rollCallList) {
            int numOfLectures = lectureBlock.getEffectiveLecturesNumber();
            if (numOfLectures <= 0 && lectureBlock.getStatus() != LectureBlockStatus.cancelled) {
                numOfLectures = lectureBlock.getPlannedLecturesNumber();
            }
            lectureBlockRollCallDao.adaptLecture(lectureBlock, rollCall, numOfLectures, author);
        }
        dbInstance.commitAndCloseSession();
    }
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall)

Example 22 with LectureBlockRollCall

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

the class LectureServiceImpl method autoClose.

private void autoClose(LectureBlockImpl lectureBlock) {
    String blockBefore = auditLogDao.toXml(lectureBlock);
    lectureBlock.setStatus(LectureBlockStatus.done);
    lectureBlock.setRollCallStatus(LectureRollCallStatus.autoclosed);
    if (lectureBlock.getEffectiveLecturesNumber() <= 0 && lectureBlock.getStatus() != LectureBlockStatus.cancelled) {
        lectureBlock.setEffectiveLecturesNumber(lectureBlock.getPlannedLecturesNumber());
    }
    lectureBlock.setAutoClosedDate(new Date());
    lectureBlock = (LectureBlockImpl) lectureBlockDao.update(lectureBlock);
    dbInstance.commit();
    List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(lectureBlock);
    Map<Identity, LectureBlockRollCall> rollCallMap = rollCalls.stream().collect(Collectors.toMap(r -> r.getIdentity(), r -> r));
    List<ParticipantAndLectureSummary> participantsAndSummaries = lectureParticipantSummaryDao.getLectureParticipantSummaries(lectureBlock);
    Set<Identity> participants = new HashSet<>();
    for (ParticipantAndLectureSummary participantAndSummary : participantsAndSummaries) {
        if (participants.contains(participantAndSummary.getIdentity())) {
            continue;
        }
        if (participantAndSummary.getSummary() != null) {
            LectureBlockRollCall rollCall = rollCallMap.get(participantAndSummary.getIdentity());
            String before = auditLogDao.toXml(rollCall);
            if (rollCall == null) {
                rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, participantAndSummary.getIdentity(), null, null, null, new ArrayList<>());
            } else if (rollCall.getLecturesAbsentList().isEmpty() && rollCall.getLecturesAttendedList().isEmpty()) {
                rollCall = lectureBlockRollCallDao.addLecture(lectureBlock, rollCall, new ArrayList<>());
            }
            String after = auditLogDao.toXml(rollCall);
            auditLogDao.auditLog(LectureBlockAuditLog.Action.autoclose, before, after, null, lectureBlock, rollCall, lectureBlock.getEntry(), participantAndSummary.getIdentity(), null);
        }
    }
    String blockAfter = auditLogDao.toXml(lectureBlock);
    auditLogDao.auditLog(LectureBlockAuditLog.Action.autoclose, blockBefore, blockAfter, null, lectureBlock, null, lectureBlock.getEntry(), null, null);
    dbInstance.commit();
    recalculateSummary(lectureBlock.getEntry());
}
Also used : Util(org.olat.core.util.Util) LectureParticipantSummary(org.olat.modules.lecture.LectureParticipantSummary) LectureBlockRollCallSearchParameters(org.olat.modules.lecture.LectureBlockRollCallSearchParameters) Date(java.util.Date) I18nManager(org.olat.core.util.i18n.I18nManager) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef) LectureBlockAuditLog(org.olat.modules.lecture.LectureBlockAuditLog) Autowired(org.springframework.beans.factory.annotation.Autowired) IdentityRef(org.olat.basesecurity.IdentityRef) MailContextImpl(org.olat.core.util.mail.MailContextImpl) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Locale(java.util.Locale) GroupDAO(org.olat.basesecurity.manager.GroupDAO) Map(java.util.Map) Group(org.olat.basesecurity.Group) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) LectureBlockStatistics(org.olat.modules.lecture.model.LectureBlockStatistics) MailTemplate(org.olat.core.util.mail.MailTemplate) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) OLog(org.olat.core.logging.OLog) Translator(org.olat.core.gui.translator.Translator) LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockWithTeachers(org.olat.modules.lecture.model.LectureBlockWithTeachers) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) Set(java.util.Set) LectureBlockImpl(org.olat.modules.lecture.model.LectureBlockImpl) UUID(java.util.UUID) AggregatedLectureBlocksStatistics(org.olat.modules.lecture.model.AggregatedLectureBlocksStatistics) Collectors(java.util.stream.Collectors) VelocityContext(org.apache.velocity.VelocityContext) MailManager(org.olat.core.util.mail.MailManager) LectureService(org.olat.modules.lecture.LectureService) List(java.util.List) Identity(org.olat.core.id.Identity) ParticipantAndLectureSummary(org.olat.modules.lecture.model.ParticipantAndLectureSummary) IdentityImpl(org.olat.basesecurity.IdentityImpl) MailContext(org.olat.core.util.mail.MailContext) LectureBlockIdentityStatistics(org.olat.modules.lecture.model.LectureBlockIdentityStatistics) Settings(org.olat.core.helpers.Settings) MailBundle(org.olat.core.util.mail.MailBundle) LectureBlockAndRollCall(org.olat.modules.lecture.model.LectureBlockAndRollCall) Action(org.olat.modules.lecture.LectureBlockAuditLog.Action) HashMap(java.util.HashMap) CalendarManagedFlag(org.olat.commons.calendar.CalendarManagedFlag) Reason(org.olat.modules.lecture.Reason) RepositoryEntry(org.olat.repository.RepositoryEntry) LecturesBlockSearchParameters(org.olat.modules.lecture.model.LecturesBlockSearchParameters) ArrayList(java.util.ArrayList) Kalendar(org.olat.commons.calendar.model.Kalendar) HashSet(java.util.HashSet) Calendar(java.util.Calendar) Service(org.springframework.stereotype.Service) StringHelper(org.olat.core.util.StringHelper) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) RepositoryEntryDAO(org.olat.repository.manager.RepositoryEntryDAO) LectureBlockToTeacher(org.olat.modules.lecture.model.LectureBlockToTeacher) CalendarManager(org.olat.commons.calendar.CalendarManager) LectureBlockRef(org.olat.modules.lecture.LectureBlockRef) LectureBlockStatus(org.olat.modules.lecture.LectureBlockStatus) LectureStatisticsSearchParameters(org.olat.modules.lecture.model.LectureStatisticsSearchParameters) Formatter(org.olat.core.util.Formatter) MailerResult(org.olat.core.util.mail.MailerResult) LectureAdminController(org.olat.modules.lecture.ui.LectureAdminController) LectureModule(org.olat.modules.lecture.LectureModule) Iterator(java.util.Iterator) LectureBlockRollCallRef(org.olat.modules.lecture.LectureBlockRollCallRef) File(java.io.File) UserManager(org.olat.user.UserManager) DB(org.olat.core.commons.persistence.DB) BusinessGroup(org.olat.group.BusinessGroup) DeletableGroupData(org.olat.group.DeletableGroupData) LectureRollCallStatus(org.olat.modules.lecture.LectureRollCallStatus) Tracing(org.olat.core.logging.Tracing) ConfigurationHelper(org.olat.modules.lecture.ui.ConfigurationHelper) UserDataDeletable(org.olat.user.UserDataDeletable) ParticipantAndLectureSummary(org.olat.modules.lecture.model.ParticipantAndLectureSummary) ArrayList(java.util.ArrayList) Date(java.util.Date) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 23 with LectureBlockRollCall

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

the class LectureBlockRollCallWebService method updateLectureBlockRollCall.

private Response updateLectureBlockRollCall(LectureBlockRollCallVO rollCallVo, HttpServletRequest httpRequest) {
    Roles roles = getRoles(httpRequest);
    if (!roles.isOLATAdmin()) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    if (rollCallVo.getKey() == null) {
        return Response.serverError().status(Status.BAD_REQUEST).build();
    }
    LectureService lectureService = CoreSpringFactory.getImpl(LectureService.class);
    LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
    searchParams.setRollCallKey(rollCallVo.getKey());
    List<LectureBlockRollCall> rollCalls = lectureService.getRollCalls(searchParams);
    if (rollCalls.size() == 1) {
        LectureBlockRollCall rollCall = rollCalls.get(0);
        rollCall.setAbsenceSupervisorNotificationDate(rollCallVo.getAbsenceSupervisorNotificationDate());
        if (rollCallVo.getAbsenceReason() != null) {
            rollCall.setAbsenceReason(rollCallVo.getAbsenceReason());
        }
        if (rollCallVo.getComment() != null) {
            rollCall.setComment(rollCallVo.getComment());
        }
        rollCall = lectureService.updateRollCall(rollCall);
        LectureBlockRollCallVO vo = new LectureBlockRollCallVO(rollCall);
        return Response.ok(vo).build();
    }
    return Response.serverError().status(Status.NOT_FOUND).build();
}
Also used : LectureBlockRollCallSearchParameters(org.olat.modules.lecture.LectureBlockRollCallSearchParameters) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) LectureService(org.olat.modules.lecture.LectureService)

Example 24 with LectureBlockRollCall

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

the class TeacherRollCallController method doCheckRow.

private void doCheckRow(TeacherRollCallRow row, MultipleSelectionElement check) {
    int index = row.getIndexOfCheck(check);
    List<Integer> indexList = Collections.singletonList(index);
    LectureBlockRollCall rollCall;
    String before = lectureService.toAuditXml(row.getRollCall());
    if (check.isAtLeastSelected(1)) {
        rollCall = lectureService.addRollCall(row.getIdentity(), lectureBlock, row.getRollCall(), indexList);
        lectureService.auditLog(LectureBlockAuditLog.Action.addToRollCall, before, lectureService.toAuditXml(rollCall), Integer.toString(index), lectureBlock, rollCall, lectureBlock.getEntry(), row.getIdentity(), getIdentity());
    } else {
        rollCall = lectureService.removeRollCall(row.getIdentity(), lectureBlock, row.getRollCall(), indexList);
        lectureService.auditLog(LectureBlockAuditLog.Action.removeFromRollCall, before, lectureService.toAuditXml(rollCall), Integer.toString(index), lectureBlock, rollCall, lectureBlock.getEntry(), row.getIdentity(), getIdentity());
    }
    row.setRollCall(rollCall);
    if (authorizedAbsenceEnabled && row.getAuthorizedAbsence() != null) {
        if (rollCall.getAbsenceAuthorized() != null && rollCall.getAbsenceAuthorized().booleanValue()) {
            row.getAuthorizedAbsence().select(onKeys[0], true);
        } else {
            row.getAuthorizedAbsence().uncheckAll();
        }
        row.getAuthorizedAbsenceCont().setDirty(true);
    }
    row.getRollCallStatusEl().getComponent().setDirty(true);
}
Also used : LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall)

Example 25 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall 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

LectureBlockRollCall (org.olat.modules.lecture.LectureBlockRollCall)64 LectureBlock (org.olat.modules.lecture.LectureBlock)40 Identity (org.olat.core.id.Identity)36 Test (org.junit.Test)26 LectureBlockRollCallSearchParameters (org.olat.modules.lecture.LectureBlockRollCallSearchParameters)16 Date (java.util.Date)14 ArrayList (java.util.ArrayList)12 List (java.util.List)10 LectureService (org.olat.modules.lecture.LectureService)10 HashMap (java.util.HashMap)8 IOException (java.io.IOException)6 URI (java.net.URI)6 Collectors (java.util.stream.Collectors)6 HttpResponse (org.apache.http.HttpResponse)6 LectureBlockRollCallVO (org.olat.modules.lecture.restapi.LectureBlockRollCallVO)6 LectureBlockStatus (org.olat.modules.lecture.LectureBlockStatus)5 LectureRollCallStatus (org.olat.modules.lecture.LectureRollCallStatus)5 Map (java.util.Map)4 Roles (org.olat.core.id.Roles)4 LectureBlockAndRollCall (org.olat.modules.lecture.model.LectureBlockAndRollCall)4