Search in sources :

Example 6 with CellStyle

use of org.olat.core.util.openxml.workbookstyle.CellStyle in project OpenOLAT by OpenOLAT.

the class QTI21ArchiveFormat method writeHeaders_1.

private void writeHeaders_1(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
    CellStyle headerStyle = workbook.getStyles().getHeaderStyle();
    // first header
    Row header1Row = exportSheet.newRow();
    int col = 1;
    if (anonymizerCallback != null) {
        // anonymized name -> test duration
        col += 0;
    } else {
        for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
            if (userPropertyHandler != null) {
                col++;
            }
        }
        // homepage -> test duration
        col += 1;
    }
    // course node points and passed
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasScoreConfigured()) {
            header1Row.addCell(col++, translator.translate("archive.table.header.node"), headerStyle);
        }
        if (assessableCourseNode.hasPassedConfigured()) {
            if (assessableCourseNode.hasScoreConfigured()) {
                col++;
            } else {
                header1Row.addCell(col++, translator.translate("archive.table.header.node"), headerStyle);
            }
        }
    }
    // test points, passed and dates
    header1Row.addCell(col++, translator.translate("archive.table.header.test"), headerStyle);
    col += 5;
    List<AbstractInfos> infos = getItemInfos();
    for (int i = 0; i < infos.size(); i++) {
        int delta = col;
        AbstractInfos info = infos.get(i);
        if (info instanceof ItemInfos) {
            ItemInfos item = (ItemInfos) info;
            if (exportConfig.isResponseCols() || exportConfig.isPointCol() || exportConfig.isTimeCols() || exportConfig.isCommentCol()) {
                List<Interaction> interactions = item.getInteractions();
                for (int j = 0; j < interactions.size(); j++) {
                    Interaction interaction = interactions.get(j);
                    col = interactionArchiveMap.get(interaction.getQtiClassName()).writeHeader1(item.getAssessmentItem(), interaction, i, j, header1Row, col, workbook);
                }
            }
            if (!exportConfig.isResponseCols()) {
                col -= col - delta;
            }
            if (exportConfig.isPointCol()) {
                col++;
            }
            if (exportConfig.isCommentCol()) {
                col++;
            }
            if (exportConfig.isTimeCols()) {
                col += anonymizerCallback != null ? 1 : 2;
            }
        } else if (numOfSections > 1 && info instanceof SectionInfos) {
            SectionInfos section = (SectionInfos) info;
            if (!section.getItemInfos().isEmpty()) {
                String sectionTitle = translator.translate("archive.table.header.section", new String[] { section.getAssessmentSection().getTitle() });
                header1Row.addCell(col++, sectionTitle, headerStyle);
            }
        }
    }
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) CustomInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) SelectPointInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SelectPointInteraction) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) PositionObjectInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.PositionObjectInteraction) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) MediaInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MediaInteraction) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) CellStyle(org.olat.core.util.openxml.workbookstyle.CellStyle) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 7 with CellStyle

use of org.olat.core.util.openxml.workbookstyle.CellStyle in project OpenOLAT by OpenOLAT.

the class OpenXMLWorksheet method appendRow.

private void appendRow() {
    if (row == null || row.isEmpty())
        return;
    try {
        String rowId = Integer.toString(rowPosition);
        writer.writeStartElement("row");
        writer.writeAttribute("r", rowId);
        int numOfCols = row.size();
        for (int j = 0; j < numOfCols; j++) {
            Cell cell = row.getCell(j);
            if (cell != null && cell.getValue() != null) {
                writer.writeStartElement("c");
                writer.writeAttribute("r", getColumn(j).concat(rowId));
                CellStyle style = cell.getStyle();
                if (style != null && style.getIndex() > 0) {
                    writer.writeAttribute("s", Integer.toString(style.getIndex()));
                }
                if (cell.getType() == OpenXMLCellType.sharedString) {
                    writer.writeAttribute("t", "s");
                }
                writer.writeStartElement("v");
                if (cell.getType() == OpenXMLCellType.date) {
                    cal.setTime((Date) cell.getValue());
                    double val = internalGetExcelDate(cal, false);
                    writer.writeCharacters(Double.toString(val));
                } else {
                    writer.writeCharacters(cell.getValue().toString());
                }
                // end v
                writer.writeEndElement();
                // end c
                writer.writeEndElement();
            }
        }
        // end row
        writer.writeEndElement();
    } catch (XMLStreamException e) {
        log.error("", e);
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) CellStyle(org.olat.core.util.openxml.workbookstyle.CellStyle)

Example 8 with CellStyle

use of org.olat.core.util.openxml.workbookstyle.CellStyle 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 9 with CellStyle

use of org.olat.core.util.openxml.workbookstyle.CellStyle in project openolat by klemens.

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 10 with CellStyle

use of org.olat.core.util.openxml.workbookstyle.CellStyle in project openolat by klemens.

the class OpenXMLWorkbook method appendCellXfs.

/*
<cellXfs count="5">
	<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" />
	<xf numFmtId="0" fontId="0" fillId="2" borderId="0" xfId="0" applyFill="1" />
	<xf numFmtId="0" fontId="0" fillId="3" borderId="0" xfId="0" applyFill="1" />
	<xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1" />
	<xf numFmtId="0" fontId="0" fillId="0" borderId="1" xfId="0" applyBorder="1" />
</cellXfs>
*/
private void appendCellXfs(List<CellStyle> cellXfs, XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("cellXfs");
    writer.writeAttribute("count", Integer.toString(cellXfs.size()));
    for (CellStyle style : cellXfs) {
        appendCellXfs(style, writer);
    }
    writer.writeEndElement();
}
Also used : CellStyle(org.olat.core.util.openxml.workbookstyle.CellStyle)

Aggregations

CellStyle (org.olat.core.util.openxml.workbookstyle.CellStyle)10 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)6 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)6 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)4 AssociateInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction)4 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)4 CustomInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction)4 DrawingInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction)4 EndAttemptInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction)4 ExtendedTextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction)4 GapMatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction)4 GraphicAssociateInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction)4 GraphicGapMatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction)4 GraphicOrderInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction)4 HotspotInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction)4 HottextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction)4 InlineChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction)4 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)4 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)4 MediaInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MediaInteraction)4