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());
}
}
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());
}
}
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());
}
}
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++;
}
}
}
}
}
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);
}
}
}
}
Aggregations