Search in sources :

Example 41 with Row

use of org.olat.core.util.openxml.OpenXMLWorksheet.Row in project OpenOLAT by OpenOLAT.

the class CheckListExcelExport method writeDataRow.

private void writeDataRow(AssessmentData data, AssessmentEntry entry, int num, OpenXMLWorksheet exportSheet) {
    int col = 0;
    Identity assessedIdentity = data.getIdentity();
    User assessedUser = assessedIdentity.getUser();
    Row dataRow = exportSheet.newRow();
    // sequence number
    dataRow.addCell(col++, num, null);
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler != null) {
            String property = userPropertyHandler.getUserProperty(assessedUser, translator.getLocale());
            dataRow.addCell(col++, property, null);
        }
    }
    // homepage
    ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(assessedIdentity);
    String homepage = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
    dataRow.addCell(col++, homepage, null);
    // course node points and passed
    if (courseNode.hasScoreConfigured()) {
        if (entry != null && entry.getScore() != null) {
            dataRow.addCell(col++, entry.getScore(), null);
        } else {
            col++;
        }
    }
    if (courseNode.hasPassedConfigured()) {
        if (entry != null && entry.getPassed() != null) {
            dataRow.addCell(col++, entry.getPassed().toString(), null);
        } else {
            col++;
        }
    }
    ModuleConfiguration config = courseNode.getModuleConfiguration();
    CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
    if (list != null && list.getList() != null && data.getChecks() != null) {
        Map<String, DBCheck> checkMap = data.getChecks().stream().collect(Collectors.toMap(c -> c.getCheckbox().getCheckboxId(), c -> c));
        List<Checkbox> checkboxList = list.getList();
        for (Checkbox checkbox : checkboxList) {
            String boxId = checkbox.getCheckboxId();
            DBCheck check = checkMap.get(boxId);
            if (check != null && check.getChecked() != null && check.getChecked().booleanValue()) {
                dataRow.addCell(col++, "x", null);
            } else {
                col++;
            }
            if (courseNode.hasScoreConfigured() && checkbox.getPoints() != null) {
                if (check != null && check.getScore() != null) {
                    dataRow.addCell(col++, check.getScore(), null);
                } else {
                    col++;
                }
            }
        }
    }
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) Util(org.olat.core.util.Util) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet) CoreSpringFactory(org.olat.core.CoreSpringFactory) HashMap(java.util.HashMap) DBCheck(org.olat.course.nodes.cl.model.DBCheck) OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) ModuleConfiguration(org.olat.modules.ModuleConfiguration) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) ContextEntry(org.olat.core.id.context.ContextEntry) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) Locale(java.util.Locale) Map(java.util.Map) AssessmentData(org.olat.course.nodes.cl.model.AssessmentData) ZipEntry(java.util.zip.ZipEntry) OLog(org.olat.core.logging.OLog) ICourse(org.olat.course.ICourse) OutputStream(java.io.OutputStream) Translator(org.olat.core.gui.translator.Translator) CellStyle(org.olat.core.util.openxml.workbookstyle.CellStyle) CheckListCourseNode(org.olat.course.nodes.CheckListCourseNode) Checkbox(org.olat.course.nodes.cl.model.Checkbox) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) UserManager(org.olat.user.UserManager) List(java.util.List) User(org.olat.core.id.User) Identity(org.olat.core.id.Identity) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Collections(java.util.Collections) Tracing(org.olat.core.logging.Tracing) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) DBCheck(org.olat.course.nodes.cl.model.DBCheck) User(org.olat.core.id.User) ModuleConfiguration(org.olat.modules.ModuleConfiguration) ContextEntry(org.olat.core.id.context.ContextEntry) Checkbox(org.olat.course.nodes.cl.model.Checkbox) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 42 with Row

use of org.olat.core.util.openxml.OpenXMLWorksheet.Row in project OpenOLAT by OpenOLAT.

the class CheckListExcelExport method writeHeaders.

private void writeHeaders(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
    CellStyle headerStyle = workbook.getStyles().getHeaderStyle();
    // second header
    // reset column counter
    int col = 0;
    Row header2Row = exportSheet.newRow();
    String sequentialNumber = translator.translate("column.header.seqnum");
    header2Row.addCell(col++, sequentialNumber, headerStyle);
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null) {
            continue;
        }
        String header = translator.translate(userPropertyHandler.i18nFormElementLabelKey());
        header2Row.addCell(col++, header, headerStyle);
    }
    // add other user and session information
    header2Row.addCell(col++, translator.translate("column.header.homepage"), headerStyle);
    // course node points and passed
    if (courseNode.hasScoreConfigured()) {
        header2Row.addCell(col++, translator.translate("column.header.node.points"), headerStyle);
    }
    if (courseNode.hasPassedConfigured()) {
        header2Row.addCell(col++, translator.translate("column.header.node.passed"), headerStyle);
    }
    ModuleConfiguration config = courseNode.getModuleConfiguration();
    CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
    if (list != null && list.getList() != null) {
        List<Checkbox> checkboxList = list.getList();
        for (Checkbox checkbox : checkboxList) {
            String boxTitle = checkbox.getTitle();
            header2Row.addCell(col++, boxTitle, headerStyle);
            if (courseNode.hasScoreConfigured() && checkbox.getPoints() != null) {
                header2Row.addCell(col++, translator.translate("column.header.points"), headerStyle);
            }
        }
    }
}
Also used : CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) ModuleConfiguration(org.olat.modules.ModuleConfiguration) Checkbox(org.olat.course.nodes.cl.model.Checkbox) CellStyle(org.olat.core.util.openxml.workbookstyle.CellStyle) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 43 with Row

use of org.olat.core.util.openxml.OpenXMLWorksheet.Row in project OpenOLAT by OpenOLAT.

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)

Example 44 with Row

use of org.olat.core.util.openxml.OpenXMLWorksheet.Row in project OpenOLAT by OpenOLAT.

the class AbstractLectureBlockAuditLogExport method addHeader.

private void addHeader(OpenXMLWorksheet exportSheet) {
    exportSheet.setHeaderRows(2);
    Row headerRow = exportSheet.newRow();
    int pos = 0;
    // creationDate
    headerRow.addCell(pos++, translator.translate("table.header.date"));
    // action
    headerRow.addCell(pos++, translator.translate("table.header.log.action"));
    // repository entry title
    headerRow.addCell(pos++, translator.translate("table.header.entry"));
    // lecture block title
    headerRow.addCell(pos++, translator.translate("table.header.lecture.block"));
    // audit block
    // lecture block status
    headerRow.addCell(pos++, translator.translate("table.header.status"));
    // lecture block planned lectures
    headerRow.addCell(pos++, translator.translate("table.header.log.planned.lectures"));
    // lecture block effective lectures
    headerRow.addCell(pos++, translator.translate("table.header.log.effective.lectures"));
    // lecture block effective end date
    headerRow.addCell(pos++, translator.translate("table.header.log.effective.end.date"));
    // audit roll call
    // roll call user
    headerRow.addCell(pos++, translator.translate("table.header.log.user"));
    // roll call attended
    headerRow.addCell(pos++, translator.translate("table.header.attended.lectures"));
    // roll call absent
    headerRow.addCell(pos++, translator.translate("table.header.absent.lectures"));
    if (authorizedAbsenceEnabled) {
        // roll call authorized
        headerRow.addCell(pos++, translator.translate("table.header.authorized.absence"));
        // roll call reason
        headerRow.addCell(pos++, translator.translate("authorized.absence.reason"));
    }
    // roll call comment
    headerRow.addCell(pos++, translator.translate("rollcall.comment"));
    // author
    // author
    headerRow.addCell(pos++, translator.translate("table.header.log.author"));
}
Also used : Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row)

Example 45 with Row

use of org.olat.core.util.openxml.OpenXMLWorksheet.Row in project OpenOLAT by OpenOLAT.

the class LectureBlockExport method addContent.

private void addContent(OpenXMLWorksheet exportSheet) {
    List<Identity> participants = lectureService.getParticipants(lectureBlock);
    List<LectureBlockRollCall> rollCalls = lectureService.getRollCalls(lectureBlock);
    Map<Identity, LectureBlockRollCall> participantToRollCallMap = rollCalls.stream().collect(Collectors.toMap(r -> r.getIdentity(), r -> r));
    for (Identity participant : participants) {
        Row row = exportSheet.newRow();
        int pos = 0;
        if (isAdministrativeUser) {
            row.addCell(pos++, participant.getName());
        }
        for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
            if (userPropertyHandler == null)
                continue;
            String val = userPropertyHandler.getUserProperty(participant.getUser(), translator.getLocale());
            row.addCell(pos++, val);
        }
        LectureBlockRollCall rollCall = participantToRollCallMap.get(participant);
        if (rollCall != null) {
            List<Integer> absentList = rollCall.getLecturesAbsentList();
            for (int i = 0; i < lectureBlock.getPlannedLecturesNumber(); i++) {
                String val = absentList.contains(i) ? "x" : null;
                row.addCell(pos++, val);
            }
            if (authorizedAbsenceEnabled && rollCall.getAbsenceAuthorized() != null && rollCall.getAbsenceAuthorized().booleanValue()) {
                row.addCell(pos++, "x");
                row.addCell(pos++, rollCall.getAbsenceReason());
            }
        }
    }
}
Also used : OutputStream(java.io.OutputStream) Formatter(org.olat.core.util.Formatter) Translator(org.olat.core.gui.translator.Translator) OpenXMLWorkbookResource(org.olat.core.util.openxml.OpenXMLWorkbookResource) LectureBlock(org.olat.modules.lecture.LectureBlock) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet) Date(java.util.Date) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) CoreSpringFactory(org.olat.core.CoreSpringFactory) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) UserManager(org.olat.user.UserManager) LectureService(org.olat.modules.lecture.LectureService) List(java.util.List) ParticipantListRepositoryController(org.olat.modules.lecture.ui.ParticipantListRepositoryController) Identity(org.olat.core.id.Identity) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Map(java.util.Map) StringHelper(org.olat.core.util.StringHelper) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) OLog(org.olat.core.logging.OLog) Tracing(org.olat.core.logging.Tracing) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Aggregations

Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)66 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)24 Date (java.util.Date)12 Identity (org.olat.core.id.Identity)12 IOException (java.io.IOException)10 Translator (org.olat.core.gui.translator.Translator)10 OpenXMLWorkbook (org.olat.core.util.openxml.OpenXMLWorkbook)10 OpenXMLWorksheet (org.olat.core.util.openxml.OpenXMLWorksheet)10 OutputStream (java.io.OutputStream)8 CellStyle (org.olat.core.util.openxml.workbookstyle.CellStyle)8 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)8 User (org.olat.core.id.User)6 Formatter (org.olat.core.util.Formatter)6 OpenXMLWorkbookResource (org.olat.core.util.openxml.OpenXMLWorkbookResource)6 AssociateInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction)6 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)6 CustomInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction)6 DrawingInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction)6 EndAttemptInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction)6 ExtendedTextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction)6