Search in sources :

Example 1 with CellStyle

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

the class QTI21ArchiveFormat method writeHeaders_2.

private void writeHeaders_2(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);
    if (anonymizerCallback != null) {
        col++;
    } else {
        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 instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasScoreConfigured()) {
            header2Row.addCell(col++, translator.translate("archive.table.header.node.points"), headerStyle);
        }
        if (assessableCourseNode.hasPassedConfigured()) {
            header2Row.addCell(col++, translator.translate("archive.table.header.node.passed"), headerStyle);
        }
    }
    header2Row.addCell(col++, translator.translate("archive.table.header.points"), headerStyle);
    header2Row.addCell(col++, translator.translate("archive.table.header.manual.points"), headerStyle);
    header2Row.addCell(col++, translator.translate("archive.table.header.final.points"), headerStyle);
    header2Row.addCell(col++, translator.translate("column.header.passed"), headerStyle);
    if (anonymizerCallback == null) {
        header2Row.addCell(col++, translator.translate("column.header.date"), headerStyle);
    }
    header2Row.addCell(col++, translator.translate("column.header.duration"), headerStyle);
    List<AbstractInfos> infos = getItemInfos();
    for (int i = 0; i < infos.size(); i++) {
        AbstractInfos info = infos.get(i);
        if (info instanceof ItemInfos) {
            ItemInfos item = (ItemInfos) info;
            if (exportConfig.isResponseCols()) {
                List<Interaction> interactions = item.getInteractions();
                for (int j = 0; j < interactions.size(); j++) {
                    Interaction interaction = interactions.get(j);
                    col = interactionArchiveMap.get(interaction.getQtiClassName()).writeHeader2(item.getAssessmentItem(), interaction, i, j, header2Row, col, workbook);
                }
            }
            if (exportConfig.isPointCol()) {
                header2Row.addCell(col++, translator.translate("item.score"), headerStyle);
            }
            if (exportConfig.isCommentCol()) {
                header2Row.addCell(col++, translator.translate("item.comment"), headerStyle);
            }
            if (exportConfig.isTimeCols()) {
                if (anonymizerCallback == null) {
                    header2Row.addCell(col++, translator.translate("item.start"), headerStyle);
                }
                header2Row.addCell(col++, translator.translate("item.duration"), headerStyle);
            }
        } else if (numOfSections > 1 && info instanceof SectionInfos) {
            SectionInfos section = (SectionInfos) info;
            if (!section.getItemInfos().isEmpty()) {
                header2Row.addCell(col++, translator.translate("archive.table.header.points"), 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 2 with CellStyle

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

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)

Example 3 with CellStyle

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

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

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

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

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

the class QTI21ArchiveFormat method writeHeaders_2.

private void writeHeaders_2(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);
    if (anonymizerCallback != null) {
        col++;
    } else {
        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 instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasScoreConfigured()) {
            header2Row.addCell(col++, translator.translate("archive.table.header.node.points"), headerStyle);
        }
        if (assessableCourseNode.hasPassedConfigured()) {
            header2Row.addCell(col++, translator.translate("archive.table.header.node.passed"), headerStyle);
        }
    }
    header2Row.addCell(col++, translator.translate("archive.table.header.points"), headerStyle);
    header2Row.addCell(col++, translator.translate("archive.table.header.manual.points"), headerStyle);
    header2Row.addCell(col++, translator.translate("archive.table.header.final.points"), headerStyle);
    header2Row.addCell(col++, translator.translate("column.header.passed"), headerStyle);
    if (anonymizerCallback == null) {
        header2Row.addCell(col++, translator.translate("column.header.date"), headerStyle);
    }
    header2Row.addCell(col++, translator.translate("column.header.duration"), headerStyle);
    List<AbstractInfos> infos = getItemInfos();
    for (int i = 0; i < infos.size(); i++) {
        AbstractInfos info = infos.get(i);
        if (info instanceof ItemInfos) {
            ItemInfos item = (ItemInfos) info;
            if (exportConfig.isResponseCols()) {
                List<Interaction> interactions = item.getInteractions();
                for (int j = 0; j < interactions.size(); j++) {
                    Interaction interaction = interactions.get(j);
                    col = interactionArchiveMap.get(interaction.getQtiClassName()).writeHeader2(item.getAssessmentItem(), interaction, i, j, header2Row, col, workbook);
                }
            }
            if (exportConfig.isPointCol()) {
                header2Row.addCell(col++, translator.translate("item.score"), headerStyle);
            }
            if (exportConfig.isCommentCol()) {
                header2Row.addCell(col++, translator.translate("item.comment"), headerStyle);
            }
            if (exportConfig.isTimeCols()) {
                if (anonymizerCallback == null) {
                    header2Row.addCell(col++, translator.translate("item.start"), headerStyle);
                }
                header2Row.addCell(col++, translator.translate("item.duration"), headerStyle);
            }
        } else if (numOfSections > 1 && info instanceof SectionInfos) {
            SectionInfos section = (SectionInfos) info;
            if (!section.getItemInfos().isEmpty()) {
                header2Row.addCell(col++, translator.translate("archive.table.header.points"), 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)

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