diff --git a/src/main/java/org/olat/core/util/openxml/HTMLToOpenXMLHandler.java b/src/main/java/org/olat/core/util/openxml/HTMLToOpenXMLHandler.java index 8030481566553b2e0bf67dde99674da2e2677a3d..663daf84ae44158abfdfbfb948d66cc79aabce2c 100644 --- a/src/main/java/org/olat/core/util/openxml/HTMLToOpenXMLHandler.java +++ b/src/main/java/org/olat/core/util/openxml/HTMLToOpenXMLHandler.java @@ -28,6 +28,7 @@ import java.util.List; import org.olat.core.util.StringHelper; import org.olat.core.util.openxml.OpenXMLDocument.Border; +import org.olat.core.util.openxml.OpenXMLDocument.Columns; import org.olat.core.util.openxml.OpenXMLDocument.Indent; import org.olat.core.util.openxml.OpenXMLDocument.ListParagraph; import org.olat.core.util.openxml.OpenXMLDocument.PredefinedStyle; @@ -61,7 +62,7 @@ public class HTMLToOpenXMLHandler extends DefaultHandler { protected List<Node> content = new ArrayList<>(); protected Deque<StyleStatus> styleStack = new ArrayDeque<>(); - protected Table currentTable; + protected Deque<Table> tableStack = new ArrayDeque<>(); protected Element currentParagraph; protected ListParagraph currentListParagraph; protected boolean pNeedNewParagraph = true; @@ -163,6 +164,7 @@ public class HTMLToOpenXMLHandler extends DefaultHandler { protected Element addContent(Node element) { if(element == null) return null; + Table currentTable = getCurrentTable(); if(currentTable != null) { currentTable.getCurrentCell().appendChild(element); } else { @@ -376,29 +378,39 @@ public class HTMLToOpenXMLHandler extends DefaultHandler { closeParagraph(); } - public void startTable() { + public Table getCurrentTable() { + if(tableStack.isEmpty()) { + return null; + } + return tableStack.getLast(); + } + + public Table startTable() { closeParagraph(); - currentTable = new Table(); + tableStack.add(new Table(OpenXMLConstants.TABLE_FULL_FULL_WIDTH_PCT)); + return tableStack.getLast(); } - public void startTable(Integer... width) { + public Table startTable(Columns columns) { closeParagraph(); - currentTable = new Table(width); + tableStack.add(new Table(OpenXMLConstants.TABLE_FULL_FULL_WIDTH_PCT, columns)); + return tableStack.getLast(); } public void startCurrentTableRow() { - currentTable.addRowEl(); + getCurrentTable().addRowEl(); } public Node addCell(int colSpan, int rowSpan) { - return currentTable.addCellEl(colSpan, rowSpan); + return getCurrentTable().addCellEl(colSpan, rowSpan); } public Node addCell(Element cellEl) { - return currentTable.addCellEl(cellEl, 1); + return getCurrentTable().addCellEl(cellEl, 1); } public void closeCurrentTableRow() { + Table currentTable = getCurrentTable(); if(currentTable != null) { currentTable.closeRow(); } @@ -408,10 +420,14 @@ public class HTMLToOpenXMLHandler extends DefaultHandler { } public void endTable() { - if(currentTable != null) { - content.add(currentTable.getTableEl()); + if(!tableStack.isEmpty()) { + Table currentTable = tableStack.removeLast(); + addContent(currentTable.getTableEl()); + if(!tableStack.isEmpty()) { + Element emptyParagraph = factory.createParagraphEl(); + addContent(emptyParagraph); + } } - currentTable = null; currentParagraph = null; } @@ -452,7 +468,7 @@ public class HTMLToOpenXMLHandler extends DefaultHandler { } else if("td".equals(tag) || "th".equals(tag)) { int colspan = OpenXMLUtils.getSpanAttribute("colspan", attributes); int rowspan = OpenXMLUtils.getSpanAttribute("rowspan", attributes); - currentTable.addCellEl(colspan, rowspan); + getCurrentTable().addCellEl(colspan, rowspan); } else if("ul".equals(tag) || "ol".equals(tag)) { currentListParagraph = factory.createListParagraph(); } else if("li".equals(tag)) { @@ -578,20 +594,26 @@ public class HTMLToOpenXMLHandler extends DefaultHandler { private Node currentRowEl; private Element currentCellEl; + private Columns columns; private Span[] rowSpans = new Span[128]; - public Table() { - tableEl = factory.createTable(); + public Table(int tableWidth) { + tableEl = factory.createTable(tableWidth); } - public Table(Integer... width) { - tableEl = factory.createTable(width); + public Table(int tableWidth, Columns columns) { + this.columns = columns; + tableEl = factory.createTable(tableWidth, columns); } public Element getTableEl() { return tableEl; } + public Columns getColumns() { + return columns; + } + public Node addRowEl() { for(int i=rowSpans.length; i-->0; ) { if(rowSpans[i] != null) { @@ -600,8 +622,8 @@ public class HTMLToOpenXMLHandler extends DefaultHandler { } nextCol = 0; - currentRowEl = tableEl.getOwnerDocument().createElement("w:tr"); - return tableEl.appendChild(currentRowEl); + currentRowEl = factory.createTableRow(); + return tableEl.appendChild(currentRowEl); } public void closeRow() { @@ -619,15 +641,22 @@ public class HTMLToOpenXMLHandler extends DefaultHandler { currentCellEl = currentRowEl.getOwnerDocument().createElement("w:tc"); - Node prefs = null; + Node prefs = currentCellEl.appendChild(currentCellEl.getOwnerDocument().createElement("w:tcPr")); if(colSpan > 1) { - prefs = currentCellEl.appendChild(currentCellEl.getOwnerDocument().createElement("w:tcPr")); Element gridSpan = (Element)prefs.appendChild(prefs.getOwnerDocument().createElement("w:gridSpan")); gridSpan.setAttribute("w:val", Integer.toString(colSpan)); + } else { + /* + <w:tcPr> + <w:tcW w:w="0" w:type="auto" /> + </w:tcPr> + */ + Element wCPrefs = (Element)prefs.appendChild(prefs.getOwnerDocument().createElement("w:tcW")); + wCPrefs.setAttribute("w:w", "0"); + wCPrefs.setAttribute("w:type", "auto"); } if(rowSpan > 1) { - prefs = prefs != null ? prefs : currentCellEl.appendChild(currentCellEl.getOwnerDocument().createElement("w:tcPr")); Element vMerge = (Element)prefs.appendChild(prefs.getOwnerDocument().createElement("w:vMerge")); vMerge.setAttribute("w:val", "restart"); } diff --git a/src/main/java/org/olat/core/util/openxml/OpenXMLConstants.java b/src/main/java/org/olat/core/util/openxml/OpenXMLConstants.java index 28beaa0d653f979d4caf713cee26f8045b9c4d61..2fa582b9055d6921838fcf3d9a1d2a5b7556559c 100644 --- a/src/main/java/org/olat/core/util/openxml/OpenXMLConstants.java +++ b/src/main/java/org/olat/core/util/openxml/OpenXMLConstants.java @@ -31,6 +31,16 @@ public class OpenXMLConstants { public static final int TABLE_FULL_WIDTH_DXA = 11294; + /** + * This is a standard full width with some margins + */ public static final int TABLE_FULL_WIDTH_PCT = 4858; + + /** + * This is 100% width, really full width. + */ + public static final int TABLE_FULL_FULL_WIDTH_PCT = 5000; + + } diff --git a/src/main/java/org/olat/core/util/openxml/OpenXMLDocument.java b/src/main/java/org/olat/core/util/openxml/OpenXMLDocument.java index dfaabdda7ff9adcd8cfc3fb8f84e0a962ce8af91..57f25cca3defd6482b6d1072f1832cb7adb2928f 100644 --- a/src/main/java/org/olat/core/util/openxml/OpenXMLDocument.java +++ b/src/main/java/org/olat/core/util/openxml/OpenXMLDocument.java @@ -470,8 +470,14 @@ public class OpenXMLDocument { return html.replace("<p/>", "<p></p>"); } - public Node appendTable(Integer... width) { - Element tableEl = createTable(width); + /** + * + * @param tableWidth The table width in pct. + * @param columns Width of the columns + * @return + */ + public Node appendTable(int tableWidth, Columns columns) { + Element tableEl = createTable(tableWidth, columns); return getCursor().appendChild(tableEl); } @@ -707,12 +713,17 @@ public class OpenXMLDocument { return paragraphEl; } - public Element createTable() { + /** + * + * @param widthPct The width of the table in pct (percent of the width (100% = 5000pct)) + * @return The table element (w:tbl) + */ + public Element createTable(int widthPct) { Element tableEl = document.createElement("w:tbl"); //preferences table Element tablePrEl = (Element)tableEl.appendChild(document.createElement("w:tblPr")); - createWidthEl("w:tblW", 5000, Unit.pct, tablePrEl); + createWidthEl("w:tblW", widthPct, Unit.pct, tablePrEl); createWidthEl("w:tblCellSpacing", 22, Unit.dxa, tablePrEl); Node tableCellMarEl = tablePrEl.appendChild(document.createElement("w:tblCellMar")); createWidthEl("w:top", 45, Unit.dxa, tableCellMarEl); @@ -751,19 +762,22 @@ public class OpenXMLDocument { <w:gridCol w:w="10178" /><w:gridCol w:w="1116" /> </w:tblGrid> */ - public Element createTable(Integer... width) { - Element tableEl = createTable(); + public Element createTable(int tableWidth, Columns columns) { + Element tableEl = createTable(tableWidth); NodeList gridPrefs = tableEl.getElementsByTagName("w:tblGrid"); Element tableGridEl = (Element)gridPrefs.item(0); //table grid - for(Integer w:width) { - createGridCol(w, tableGridEl); + if(columns != null && columns.getWidth() != null && columns.getWidth().length > 0) { + for(Integer w:columns.getWidth()) { + createGridCol(w, tableGridEl); + } } return tableEl; } /* + * For the moment, only w:tr <w:tr> <w:trPr> <w:tblCellSpacing w:w="22" w:type="dxa" /> @@ -1795,6 +1809,40 @@ public class OpenXMLDocument { } } + /** + * These are width in twentieths of a point. + */ + public static class Columns { + + private Integer[] width; + + private Columns(Integer[] width) { + this.width = width; + } + + public Integer[] getWidth() { + return width; + } + + /** + * Return the width in twentieths of a point. + * + * @param col The column + * @return An integer or null + */ + public Integer getColumnWidth(int col) { + if(width == null || width.length <= col) return null; + return width[col]; + } + + public static Columns valueOf(Integer... width) { + if(width == null || width.length == 0 || width[0] == null) { + return new Columns(new Integer[0]); + } + return new Columns(width); + } + } + public static class HeaderReference { private final String id; diff --git a/src/main/java/org/olat/course/nodes/co/CORunController.java b/src/main/java/org/olat/course/nodes/co/CORunController.java index 812ef4f4d404b88b2d1ab780e64a79f4c1ad5ba9..1e15a482fd01f8e456c95fcec30557ef162aeadb 100755 --- a/src/main/java/org/olat/course/nodes/co/CORunController.java +++ b/src/main/java/org/olat/course/nodes/co/CORunController.java @@ -100,8 +100,9 @@ public class CORunController extends BasicController { // Adding learning objectives using a consumable panel. Will only be // displayed on the first page - Boolean partipsCourseConfigured = moduleConfiguration.getBooleanEntry(COEditController.CONFIG_KEY_EMAILTOPARTICIPANTS_COURSE); - Boolean partipsAllConfigured = moduleConfiguration.getBooleanEntry(COEditController.CONFIG_KEY_EMAILTOPARTICIPANTS_ALL); + Boolean participantsCourseConfigured = moduleConfiguration.getBooleanEntry(COEditController.CONFIG_KEY_EMAILTOPARTICIPANTS_COURSE); + Boolean participantsAllConfigured = moduleConfiguration.getBooleanEntry(COEditController.CONFIG_KEY_EMAILTOPARTICIPANTS_ALL); + Boolean coachesCourseConfigured = moduleConfiguration.getBooleanEntry(COEditController.CONFIG_KEY_EMAILTOCOACHES_COURSE); Boolean coachesAllConfigured = moduleConfiguration.getBooleanEntry(COEditController.CONFIG_KEY_EMAILTOCOACHES_ALL); Boolean ownersConfigured = moduleConfiguration.getBooleanEntry(COEditController.CONFIG_KEY_EMAILTOOWNERS); @@ -147,6 +148,7 @@ public class CORunController extends BasicController { ContactList cl = retrieveParticipantsFromAreas(participantAreaKeys); contactLists.push(cl); } + if (coachesAllConfigured != null && coachesAllConfigured.booleanValue()) { ContactList cl = retrieveCoachesFromCourse(); contactLists.push(cl); @@ -159,8 +161,12 @@ public class CORunController extends BasicController { contactLists.push(cl); cl = retrieveCoachesFromAreas(grp_keys); contactLists.push(cl); + } else if (coachesCourseConfigured != null && coachesCourseConfigured.booleanValue()){ + ContactList cl = retrieveCoachesFromCourse(); + contactLists.push(cl); } - if (partipsAllConfigured != null && partipsAllConfigured.booleanValue()) { + + if (participantsAllConfigured != null && participantsAllConfigured.booleanValue()) { ContactList cl = retrieveParticipantsFromCourse(); contactLists.push(cl); List<BusinessGroup> groups = cgm.getAllBusinessGroups(); @@ -172,11 +178,11 @@ public class CORunController extends BasicController { contactLists.push(cl); cl = retrieveParticipantsFromAreas(grp_keys); contactLists.push(cl); - } - if (partipsCourseConfigured != null && partipsCourseConfigured.booleanValue()){ + } else if (participantsCourseConfigured != null && participantsCourseConfigured.booleanValue()){ ContactList cl = retrieveParticipantsFromCourse(); contactLists.push(cl); } + if (ownersConfigured != null && ownersConfigured){ ContactList cl = retrieveOwnersFromCourse(); contactLists.push(cl); @@ -192,7 +198,7 @@ public class CORunController extends BasicController { ContactList cl = retrieveCoachesFromAreas(areaKeys); contactLists.push(cl); } - if (partipsAllConfigured != null && partipsAllConfigured.booleanValue()) { + if (participantsAllConfigured != null && participantsAllConfigured.booleanValue()) { ContactList cl = retrieveParticipantsFromAreas(areaKeys); contactLists.push(cl); } diff --git a/src/main/java/org/olat/ims/qti/container/qtielements/Render_choice.java b/src/main/java/org/olat/ims/qti/container/qtielements/Render_choice.java index ede0a5e7c31f0ecd6c7ed3d2b22cd4c9b8bc2370..f3c82191f628031ab94e286af7e41c1f1d22b772 100644 --- a/src/main/java/org/olat/ims/qti/container/qtielements/Render_choice.java +++ b/src/main/java/org/olat/ims/qti/container/qtielements/Render_choice.java @@ -31,6 +31,7 @@ import org.dom4j.Element; import org.dom4j.tree.AbstractAttribute; import org.olat.core.logging.AssertException; import org.olat.core.util.openxml.OpenXMLDocument; +import org.olat.core.util.openxml.OpenXMLDocument.Columns; import org.olat.core.util.openxml.OpenXMLDocument.Unit; import org.olat.ims.qti.editor.beecom.parser.ItemParser; import org.w3c.dom.Node; @@ -152,7 +153,7 @@ public class Render_choice extends GenericQTIElement { if (kprim) { ri.put(RenderInstructions.KEY_RENDER_CLASS, "kprim"); //open a table with 3 columns - table = document.appendTable(new Integer[]{9062, 1116, 1116}); + table = document.appendTable(5000, Columns.valueOf(9062, 1116, 1116)); //draw header with +/- Node row = document.createTableRow(); Node emptyCell = row.appendChild(document.createTableCell(null, 9062, Unit.dxa)); @@ -169,7 +170,7 @@ public class Render_choice extends GenericQTIElement { ri.put(RenderInstructions.KEY_RENDER_CLASS, "choice"); //open a table with 2 columns //{10178, 1116} - table = document.appendTable(new Integer[]{8468, 745}); + table = document.appendTable(5000, Columns.valueOf(8468, 745)); } document.pushCursor(table); super.renderOpenXML(document, ri); diff --git a/src/main/java/org/olat/ims/qti21/manager/openxml/QTI21WordExport.java b/src/main/java/org/olat/ims/qti21/manager/openxml/QTI21WordExport.java index 8e473f2b7cc7eaf7aee8839bbb892a5b7515276f..7ce330be6c302143baea920e88843521e456e2f5 100644 --- a/src/main/java/org/olat/ims/qti21/manager/openxml/QTI21WordExport.java +++ b/src/main/java/org/olat/ims/qti21/manager/openxml/QTI21WordExport.java @@ -51,6 +51,7 @@ import org.olat.core.util.openxml.HTMLToOpenXMLHandler; import org.olat.core.util.openxml.OpenXMLConstants; import org.olat.core.util.openxml.OpenXMLDocument; import org.olat.core.util.openxml.OpenXMLDocument.Border; +import org.olat.core.util.openxml.OpenXMLDocument.Columns; import org.olat.core.util.openxml.OpenXMLDocument.Indent; import org.olat.core.util.openxml.OpenXMLDocument.Spacing; import org.olat.core.util.openxml.OpenXMLDocument.Style; @@ -410,8 +411,9 @@ public class QTI21WordExport implements MediaResource { responseIdentifier = attributes.getValue("responseidentifier"); break; case "simplechoice": + Table currentTable = getCurrentTable(); if(currentTable == null) { - startTable(); + currentTable = startTable(); } currentTable.addRowEl(); currentTable.addCellEl(factory.createTableCell("E9EAF2", 4560, Unit.pct), 1); @@ -542,7 +544,7 @@ public class QTI21WordExport implements MediaResource { private void endSimpleChoice() { Element checkboxCell = factory.createTableCell(null, 369, Unit.pct); - Node checkboxNode = currentTable.addCellEl(checkboxCell, 1); + Node checkboxNode = getCurrentTable().addCellEl(checkboxCell, 1); boolean checked = false; if(withResponses) { @@ -720,15 +722,15 @@ public class QTI21WordExport implements MediaResource { String backgroundColor = "FFFFFF"; Border sourceBorder = new Border(0, 6, "E9EAF2"); - startTable(OpenXMLConstants.TABLE_FULL_WIDTH_DXA); - currentTable.addRowEl(); + startTable(Columns.valueOf(OpenXMLConstants.TABLE_FULL_WIDTH_DXA)); + getCurrentTable().addRowEl(); createCellHeader(translator.translate("form.imd.layout.match.sources"), OpenXMLConstants.TABLE_FULL_WIDTH_DXA, 10); - currentTable.closeRow(); + getCurrentTable().closeRow(); for(SimpleAssociableChoice choice:choices) { - currentTable.addRowEl(); + getCurrentTable().addRowEl(); Element cell = factory.createTableCell(backgroundColor, sourceBorder, OpenXMLConstants.TABLE_FULL_WIDTH_PCT - 10, Unit.pct); - Node contentCell = currentTable.addCellEl(cell, 1); + Node contentCell = getCurrentTable().addCellEl(cell, 1); String html = htmlBuilder.flowStaticString(choice.getFlowStatics()); List<Node> nodes = appendHtmlText(html, factory.createParagraphEl(), 7.5); @@ -740,7 +742,7 @@ public class QTI21WordExport implements MediaResource { } contentCell.appendChild(factory.createParagraphEl()); } - currentTable.closeRow(); + getCurrentTable().closeRow(); } endTable(); } @@ -754,14 +756,14 @@ public class QTI21WordExport implements MediaResource { Border dropBorder = new Border(0, 6, "EEEEEE"); int columnWidthPct = OpenXMLConstants.TABLE_FULL_WIDTH_PCT; - startTable(OpenXMLConstants.TABLE_FULL_WIDTH_DXA); - currentTable.addRowEl(); + startTable(Columns.valueOf(OpenXMLConstants.TABLE_FULL_WIDTH_DXA)); + getCurrentTable().addRowEl(); createCellHeader(translator.translate("form.imd.layout.match.targets.short"), OpenXMLConstants.TABLE_FULL_WIDTH_DXA, 10); - currentTable.closeRow(); + getCurrentTable().closeRow(); for(SimpleAssociableChoice choice:targetChoices) { - currentTable.addRowEl(); - Node contentCell = currentTable.addCellEl(factory.createTableCell(backgroundColor, targetBorder, columnWidthPct - 10, Unit.pct), 1); + getCurrentTable().addRowEl(); + Node contentCell = getCurrentTable().addCellEl(factory.createTableCell(backgroundColor, targetBorder, columnWidthPct - 10, Unit.pct), 1); String html = htmlBuilder.flowStaticString(choice.getFlowStatics()); List<Node> nodes = appendHtmlText(html, factory.createParagraphEl(), 7.5); @@ -773,7 +775,7 @@ public class QTI21WordExport implements MediaResource { Element wrapEl = factory.createParagraphEl(); HTMLToOpenXMLHandler dropTable = new HTMLToOpenXMLHandler(factory, wrapEl, false); dropTable.setMaxWidthCm(7); - dropTable.startTable(columnWidthPct - 50); + dropTable.startTable(Columns.valueOf(columnWidthPct - 50)); if(withResponses) { for(SimpleAssociableChoice sourceChoice:sourceChoices) { boolean correct = isCorrectMatchResponse(sourceChoice.getIdentifier(), choice.getIdentifier(), matchInteraction); @@ -807,7 +809,7 @@ public class QTI21WordExport implements MediaResource { contentCell.appendChild(dropNode); } contentCell.appendChild(factory.createParagraphEl()); - currentTable.closeRow(); + getCurrentTable().closeRow(); } endTable(); } @@ -833,32 +835,32 @@ public class QTI21WordExport implements MediaResource { columnsWidth[i] = columnWidthDxa; } columnsWidth[numOfColumns] = halfTableWidthDxa; - startTable(columnsWidth); + startTable(Columns.valueOf(columnsWidth)); - currentTable.addRowEl(); + getCurrentTable().addRowEl(); // horizontal headers for(SimpleAssociableChoice choice:horizontalAssociableChoices) { - Element answerCell = currentTable.addCellEl(factory.createTableCell("E9EAF2", columnWidthPct, Unit.pct), 1); + Element answerCell = getCurrentTable().addCellEl(factory.createTableCell("E9EAF2", columnWidthPct, Unit.pct), 1); appendSimpleAssociableChoice(choice, answerCell); } // white corner - Node emptyCell = currentTable.addCellEl(factory.createTableCell(null, halfTableWidthDxa, Unit.dxa), 1); + Node emptyCell = getCurrentTable().addCellEl(factory.createTableCell(null, halfTableWidthDxa, Unit.dxa), 1); emptyCell.appendChild(factory.createParagraphEl("")); - currentTable.closeRow(); + getCurrentTable().closeRow(); for(SimpleAssociableChoice choice:verticalAssociableChoices) { - currentTable.addRowEl(); + getCurrentTable().addRowEl(); //checkbox for(SimpleAssociableChoice horizontalChoice:horizontalAssociableChoices) { boolean correct = isCorrectMatchResponse(choice.getIdentifier(), horizontalChoice.getIdentifier(), matchInteraction); appendMatchCheckBox(correct, columnWidthPct, factory); } //answer - Element answerCell = currentTable.addCellEl(factory.createTableCell("E9EAF2", halfTableWidthPct, Unit.pct), 1); + Element answerCell = getCurrentTable().addCellEl(factory.createTableCell("E9EAF2", halfTableWidthPct, Unit.pct), 1); appendSimpleAssociableChoice(choice, answerCell) ; - currentTable.closeRow(); + getCurrentTable().closeRow(); } endTable(); @@ -885,39 +887,39 @@ public class QTI21WordExport implements MediaResource { for(int i=numOfColumns; i-->0; ) { columnsWidth[i] = columnWidthDxa; } - startTable(columnsWidth); + startTable(Columns.valueOf(columnsWidth)); if(hasClass(matchInteraction, QTI21Constants.CSS_MATCH_SOURCE_RIGHT)) { - currentTable.addRowEl(); + getCurrentTable().addRowEl(); createCellHeader(translator.translate("form.imd.layout.match.targets.short"), columnWidthPct, 50); createCellHeader(translator.translate("form.imd.layout.match.sources"), columnWidthPct, 50); - currentTable.closeRow(); + getCurrentTable().closeRow(); - currentTable.addRowEl(); - Element targetsCell = currentTable.addCellEl(factory.createTableCell(null, columnWidthPct, Unit.pct), 1); + getCurrentTable().addRowEl(); + Element targetsCell = getCurrentTable().addCellEl(factory.createTableCell(null, columnWidthPct, Unit.pct), 1); appendMatchTargetsVertical(targetsAssociableChoices, sourcesAssociableChoices, matchInteraction, columnWidthPct, targetsCell); - Element sourcesCell = currentTable.addCellEl(factory.createTableCell(null, columnWidthPct, Unit.pct), 1); + Element sourcesCell = getCurrentTable().addCellEl(factory.createTableCell(null, columnWidthPct, Unit.pct), 1); appendMatchSourcesVertical(sourcesAssociableChoices, columnWidthPct, sourcesCell); - currentTable.closeRow(); + getCurrentTable().closeRow(); } else { - currentTable.addRowEl(); + getCurrentTable().addRowEl(); createCellHeader(translator.translate("form.imd.layout.match.sources"), columnWidthPct, 50); createCellHeader(translator.translate("form.imd.layout.match.targets.short"), columnWidthPct, 50); - currentTable.closeRow(); + getCurrentTable().closeRow(); - currentTable.addRowEl(); - Element sourcesCell = currentTable.addCellEl(factory.createTableCell(null, columnWidthPct, Unit.pct), 1); + getCurrentTable().addRowEl(); + Element sourcesCell = getCurrentTable().addCellEl(factory.createTableCell(null, columnWidthPct, Unit.pct), 1); appendMatchSourcesVertical(sourcesAssociableChoices, columnWidthPct, sourcesCell); - Element targetsCell = currentTable.addCellEl(factory.createTableCell(null, columnWidthPct, Unit.pct), 1); + Element targetsCell = getCurrentTable().addCellEl(factory.createTableCell(null, columnWidthPct, Unit.pct), 1); appendMatchTargetsVertical(targetsAssociableChoices, sourcesAssociableChoices, matchInteraction, columnWidthPct, targetsCell); - currentTable.closeRow(); + getCurrentTable().closeRow(); } endTable(); } private void createCellHeader(String header, int columnWidthPct, int indent) { - Element sourcesHeaderCell = currentTable.addCellEl(factory.createTableCell(null, columnWidthPct, Unit.pct), 1); + Element sourcesHeaderCell = getCurrentTable().addCellEl(factory.createTableCell(null, columnWidthPct, Unit.pct), 1); Element paragraphEl = factory.createParagraphEl(new Indent(indent), null, null, null); Element runEl = factory.createRunEl(); @@ -941,7 +943,7 @@ public class QTI21WordExport implements MediaResource { HTMLToOpenXMLHandler innerTable = new HTMLToOpenXMLHandler(factory, wrapEl, false); innerTable.setMaxWidthCm(7.5); - innerTable.startTable(columnWidthPct); + innerTable.startTable(Columns.valueOf(columnWidthPct)); for(SimpleAssociableChoice choice:choices) { innerTable.startCurrentTableRow(); Node contentCell = innerTable.addCell(factory.createTableCell(backgroundColor, sourceBorder, columnWidthPct - 10, Unit.pct)); @@ -978,7 +980,7 @@ public class QTI21WordExport implements MediaResource { HTMLToOpenXMLHandler innerTable = new HTMLToOpenXMLHandler(factory, wrapEl, false); innerTable.setMaxWidthCm(7.5); - innerTable.startTable(columnWidthPct); + innerTable.startTable(Columns.valueOf(columnWidthPct)); for(SimpleAssociableChoice choice:targetChoices) { innerTable.startCurrentTableRow(); Node contentCell = innerTable.addCell(factory.createTableCell(backgroundColor, targetBorder, columnWidthPct - 10, Unit.pct)); @@ -992,7 +994,7 @@ public class QTI21WordExport implements MediaResource { // add the drop panels HTMLToOpenXMLHandler dropTable = new HTMLToOpenXMLHandler(factory, wrapEl, false); dropTable.setMaxWidthCm(7); - dropTable.startTable(columnWidthPct - 50); + dropTable.startTable(Columns.valueOf(columnWidthPct - 50)); if(withResponses) { for(SimpleAssociableChoice sourceChoice:sourceChoices) { boolean correct = isCorrectMatchResponse(sourceChoice.getIdentifier(), choice.getIdentifier(), matchInteraction); @@ -1061,25 +1063,25 @@ public class QTI21WordExport implements MediaResource { for(int i=numOfColumns; i-->0; ) { columnsWidth[i] = columnWidthDxa; } - startTable(columnsWidth); + startTable(Columns.valueOf(columnsWidth)); - currentTable.addRowEl(); + getCurrentTable().addRowEl(); // white corner - Node emptyCell = currentTable.addCellEl(factory.createTableCell(null, columnWidthDxa, Unit.dxa), 1); + Node emptyCell = getCurrentTable().addCellEl(factory.createTableCell(null, columnWidthDxa, Unit.dxa), 1); emptyCell.appendChild(factory.createParagraphEl("")); // horizontal headers for(SimpleAssociableChoice choice:horizontalAssociableChoices) { - Element answerCell = currentTable.addCellEl(factory.createTableCell("E9EAF2", columnWidthPct, Unit.pct), 1); + Element answerCell = getCurrentTable().addCellEl(factory.createTableCell("E9EAF2", columnWidthPct, Unit.pct), 1); appendSimpleAssociableChoice(choice, answerCell); } - currentTable.closeRow(); + getCurrentTable().closeRow(); for(SimpleAssociableChoice choice:verticalAssociableChoices) { - currentTable.addRowEl(); + getCurrentTable().addRowEl(); //answer - Element answerCell = currentTable.addCellEl(factory.createTableCell("E9EAF2", columnWidthPct, Unit.pct), 1); + Element answerCell = getCurrentTable().addCellEl(factory.createTableCell("E9EAF2", columnWidthPct, Unit.pct), 1); appendSimpleAssociableChoice(choice, answerCell) ; //checkbox for(SimpleAssociableChoice horizontalChoice:horizontalAssociableChoices) { @@ -1087,7 +1089,7 @@ public class QTI21WordExport implements MediaResource { appendMatchCheckBox(correct, columnWidthPct, factory); } - currentTable.closeRow(); + getCurrentTable().closeRow(); } endTable(); @@ -1128,25 +1130,25 @@ public class QTI21WordExport implements MediaResource { SimpleMatchSet questionMatchSet = matchInteraction.getSimpleMatchSets().get(0); //open a table with 3 columns - startTable(new Integer[]{9062, 1116, 1116}); + startTable(Columns.valueOf(9062, 1116, 1116)); - currentTable.addRowEl(); + getCurrentTable().addRowEl(); //draw header with +/- - Node emptyCell = currentTable.addCellEl(factory.createTableCell(null, 9062, Unit.dxa), 1); + Node emptyCell = getCurrentTable().addCellEl(factory.createTableCell(null, 9062, Unit.dxa), 1); emptyCell.appendChild(factory.createParagraphEl("")); - Node plusCell = currentTable.addCellEl(factory.createTableCell(null, 1116, Unit.dxa), 1); + Node plusCell = getCurrentTable().addCellEl(factory.createTableCell(null, 1116, Unit.dxa), 1); plusCell.appendChild(factory.createParagraphEl(translator.translate("kprim.plus"))); - Node minusCell = currentTable.addCellEl(factory.createTableCell(null, 1116, Unit.dxa), 1); + Node minusCell = getCurrentTable().addCellEl(factory.createTableCell(null, 1116, Unit.dxa), 1); minusCell.appendChild(factory.createParagraphEl(translator.translate("kprim.minus"))); - currentTable.closeRow(); + getCurrentTable().closeRow(); for(SimpleAssociableChoice choice:questionMatchSet.getSimpleAssociableChoices()) { - currentTable.addRowEl(); + getCurrentTable().addRowEl(); //answer - Element answerCell = currentTable.addCellEl(factory.createTableCell("E9EAF2", 4120, Unit.pct), 1); + Element answerCell = getCurrentTable().addCellEl(factory.createTableCell("E9EAF2", 4120, Unit.pct), 1); appendSimpleAssociableChoice(choice, answerCell); //checkbox boolean correct = isCorrectKPrimResponse(choice.getIdentifier(), QTI21Constants.CORRECT_IDENTIFIER, matchInteraction); @@ -1154,7 +1156,7 @@ public class QTI21WordExport implements MediaResource { boolean wrong = isCorrectKPrimResponse(choice.getIdentifier(), QTI21Constants.WRONG_IDENTIFIER, matchInteraction); appendMatchCheckBox(wrong, 369, factory); - currentTable.closeRow(); + getCurrentTable().closeRow(); } endTable(); @@ -1215,7 +1217,7 @@ public class QTI21WordExport implements MediaResource { } private void appendMatchCheckBox(boolean checked, int width, OpenXMLDocument document) { - Node checkboxCell = currentTable.addCellEl(document.createTableCell(null, width, Unit.pct), 1); + Node checkboxCell = getCurrentTable().addCellEl(document.createTableCell(null, width, Unit.pct), 1); Node responseEl = document.createCheckbox(checked); Node wrapEl = document.wrapInParagraph(responseEl); checkboxCell.appendChild(wrapEl);