Search in sources :

Example 31 with Row

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

the class DefaultXlsTableExporter method createHeader.

private void createHeader(final Table table, final Translator translator, final int cdcnt, final OpenXMLWorksheet exportSheet, final OpenXMLWorkbook workbook) {
    Row headerRow = exportSheet.newRow();
    exportSheet.setHeaderRows(1);
    for (int c = 0; c < cdcnt; c++) {
        ColumnDescriptor cd = table.getColumnDescriptor(c);
        if (cd instanceof StaticColumnDescriptor) {
            // ignore static column descriptors - of no value in excel download!
            continue;
        }
        String headerKey = cd.getHeaderKey();
        String headerVal = cd.translateHeaderKey() ? translator.translate(headerKey) : headerKey;
        headerRow.addCell(c, headerVal, workbook.getStyles().getHeaderStyle());
    }
}
Also used : Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row)

Example 32 with Row

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

the class XlsFlexiTableExporter method createHeader.

protected void createHeader(List<FlexiColumnModel> columns, Translator translator, OpenXMLWorksheet sheet, OpenXMLWorkbook workbook) {
    sheet.setHeaderRows(1);
    Row headerRow = sheet.newRow();
    for (int c = 0; c < columns.size(); c++) {
        FlexiColumnModel cd = columns.get(c);
        String headerVal = cd.getHeaderLabel() == null ? translator.translate(cd.getHeaderKey()) : cd.getHeaderLabel();
        headerRow.addCell(c, headerVal, workbook.getStyles().getHeaderStyle());
    }
}
Also used : Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row)

Example 33 with Row

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

the class DefaultXlsTableExporter method createHeader.

private void createHeader(final Table table, final Translator translator, final int cdcnt, final OpenXMLWorksheet exportSheet, final OpenXMLWorkbook workbook) {
    Row headerRow = exportSheet.newRow();
    exportSheet.setHeaderRows(1);
    for (int c = 0; c < cdcnt; c++) {
        ColumnDescriptor cd = table.getColumnDescriptor(c);
        if (cd instanceof StaticColumnDescriptor) {
            // ignore static column descriptors - of no value in excel download!
            continue;
        }
        String headerKey = cd.getHeaderKey();
        String headerVal = cd.translateHeaderKey() ? translator.translate(headerKey) : headerKey;
        headerRow.addCell(c, headerVal, workbook.getStyles().getHeaderStyle());
    }
}
Also used : Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row)

Example 34 with Row

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

the class QTI21ArchiveFormat method writeDataRow.

private void writeDataRow(int num, SessionResponses responses, OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
    int col = 0;
    Row dataRow = exportSheet.newRow();
    // sequence number
    dataRow.addCell(col++, num, null);
    AssessmentTestSession testSession = responses.getTestSession();
    AssessmentEntry entry = testSession.getAssessmentEntry();
    Identity assessedIdentity = entry.getIdentity();
    // user properties
    if (assessedIdentity == null) {
        for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
            if (userPropertyHandler != null) {
                if (userPropertyHandlers.get(0) == userPropertyHandler) {
                    dataRow.addCell(col++, translator.translate("anonym.user"), null);
                } else {
                    col++;
                }
            }
        }
    } else if (anonymizerCallback != null) {
        String anonymizedName = anonymizerCallback.getAnonymizedUserName(assessedIdentity);
        dataRow.addCell(col++, anonymizedName, null);
    } else {
        User assessedUser = assessedIdentity.getUser();
        for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
            if (userPropertyHandler != null) {
                String property = userPropertyHandler.getUserProperty(assessedUser, translator.getLocale());
                dataRow.addCell(col++, property, null);
            }
        }
    }
    // homepage
    if (anonymizerCallback == null) {
        String homepage;
        if (entry.getIdentity() == null) {
            homepage = "";
        } else {
            ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(entry.getIdentity());
            homepage = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
        }
        dataRow.addCell(col++, homepage, null);
    }
    // course node points and passed
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasScoreConfigured()) {
            if (entry.getScore() != null) {
                dataRow.addCell(col++, entry.getScore(), null);
            } else {
                col++;
            }
        }
        if (assessableCourseNode.hasPassedConfigured()) {
            if (entry.getPassed() != null) {
                dataRow.addCell(col++, entry.getPassed().toString(), null);
            } else {
                col++;
            }
        }
    }
    // assesspoints, passed, ipaddress, date, duration
    if (testSession.getScore() != null) {
        dataRow.addCell(col++, testSession.getScore(), null);
    } else {
        col++;
    }
    if (testSession.getManualScore() != null) {
        dataRow.addCell(col++, testSession.getManualScore(), null);
    } else {
        col++;
    }
    if (testSession.getFinalScore() != null) {
        dataRow.addCell(col++, testSession.getFinalScore(), null);
    } else {
        col++;
    }
    if (testSession.getPassed() != null) {
        dataRow.addCell(col++, testSession.getPassed().toString(), null);
    } else {
        col++;
    }
    if (anonymizerCallback == null) {
        dataRow.addCell(col++, testSession.getCreationDate(), workbook.getStyles().getDateStyle());
    }
    dataRow.addCell(col++, toDurationInMilliseconds(testSession.getDuration()), null);
    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;
            AssessmentItemRef itemRef = item.getAssessmentItemRef();
            String itemRefIdentifier = itemRef.getIdentifier().toString();
            AssessmentItemSession itemSession = responses.getItemSession(itemRefIdentifier);
            if (exportConfig.isResponseCols()) {
                List<Interaction> interactions = item.getInteractions();
                for (int j = 0; j < interactions.size(); j++) {
                    Interaction interaction = interactions.get(j);
                    AssessmentResponse response = responses.getResponse(itemRefIdentifier, interaction.getResponseIdentifier());
                    col = interactionArchiveMap.get(interaction.getQtiClassName()).writeInteractionData(item.getAssessmentItem(), response, interaction, j, dataRow, col, workbook);
                }
            }
            // score, start, duration
            if (itemSession == null) {
                if (exportConfig.isPointCol()) {
                    col++;
                }
                if (exportConfig.isCommentCol()) {
                    col++;
                }
                if (exportConfig.isTimeCols()) {
                    col += anonymizerCallback != null ? 1 : 2;
                }
            } else {
                if (exportConfig.isPointCol()) {
                    if (itemSession.getManualScore() != null) {
                        dataRow.addCell(col++, itemSession.getManualScore(), null);
                    } else {
                        dataRow.addCell(col++, itemSession.getScore(), null);
                    }
                }
                if (exportConfig.isCommentCol()) {
                    dataRow.addCell(col++, itemSession.getCoachComment(), null);
                }
                if (exportConfig.isTimeCols()) {
                    if (anonymizerCallback == null) {
                        dataRow.addCell(col++, itemSession.getCreationDate(), workbook.getStyles().getTimeStyle());
                    }
                    dataRow.addCell(col++, toDurationInMilliseconds(itemSession.getDuration()), null);
                }
            }
        } else if (numOfSections > 1 && info instanceof SectionInfos) {
            SectionInfos section = (SectionInfos) info;
            if (!section.getItemInfos().isEmpty()) {
                BigDecimal score = calculateSectionScore(responses, section);
                if (score != null) {
                    dataRow.addCell(col++, score, workbook.getStyles().getLightGrayStyle());
                } else {
                    col++;
                }
            }
        }
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) User(org.olat.core.id.User) 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) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse) ContextEntry(org.olat.core.id.context.ContextEntry) BigDecimal(java.math.BigDecimal) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 35 with Row

use of org.olat.core.util.openxml.OpenXMLWorksheet.Row 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)

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