From 52641c7139d9232adf2bf76da8e54ea4a2f746bc Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Mon, 16 Dec 2013 11:34:40 +0100 Subject: [PATCH] OO-910: kprim need a special "fetchPoint" as the negative and positive values are important --- .../olat/ims/qti/export/QTIWordExport.java | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/olat/ims/qti/export/QTIWordExport.java b/src/main/java/org/olat/ims/qti/export/QTIWordExport.java index e0286cfd1e1..d60379bce2f 100644 --- a/src/main/java/org/olat/ims/qti/export/QTIWordExport.java +++ b/src/main/java/org/olat/ims/qti/export/QTIWordExport.java @@ -223,22 +223,15 @@ public class QTIWordExport implements MediaResource { ChoiceQuestion choice = (ChoiceQuestion)question; if(question.getType() == Question.TYPE_SC) { questionType = translator.translate("item.type.sc"); + fetchPointsOfMultipleChoices(itemEl, choice, iinput); } else if(question.getType() == Question.TYPE_MC) { questionType = translator.translate("item.type.mc"); + fetchPointsOfMultipleChoices(itemEl, choice, iinput); } else if (question.getType() == Question.TYPE_KPRIM) { questionType = translator.translate("item.type.kprim"); + fetchPointsOfKPrim(itemEl, choice, iinput); } - Element resprocessingXML = itemEl.element("resprocessing"); - if(resprocessingXML != null) { - List<?> respconditions = resprocessingXML.elements("respcondition"); - Map<String,Float> points = QTIEditHelper.fetchPoints(respconditions, choice.getType()); - for(Map.Entry<String,Float> entryPoint:points.entrySet()) { - Float val = entryPoint.getValue(); - if(val != null && val.floatValue() > 0.0f) { - iinput.put(entryPoint.getKey(), entryPoint.getKey()); - } - } - } + } else if(question instanceof FIBQuestion) { questionType = translator.translate("item.type.sc"); for (Response response: question.getResponses()) { @@ -266,6 +259,34 @@ public class QTIWordExport implements MediaResource { foo.renderOpenXML(document, renderInstructions); } + private static void fetchPointsOfKPrim(Element itemEl, ChoiceQuestion choice, Map<String,String> iinput) { + Element resprocessingXML = itemEl.element("resprocessing"); + if(resprocessingXML != null) { + List<?> respconditions = resprocessingXML.elements("respcondition"); + Map<String,Float> points = QTIEditHelper.fetchPoints(respconditions, choice.getType()); + for(Map.Entry<String,Float> entryPoint:points.entrySet()) { + Float val = entryPoint.getValue(); + if(val != null) { + iinput.put(entryPoint.getKey(), entryPoint.getKey()); + } + } + } + } + + private static void fetchPointsOfMultipleChoices(Element itemEl, ChoiceQuestion choice, Map<String,String> iinput) { + Element resprocessingXML = itemEl.element("resprocessing"); + if(resprocessingXML != null) { + List<?> respconditions = resprocessingXML.elements("respcondition"); + Map<String,Float> points = QTIEditHelper.fetchPoints(respconditions, choice.getType()); + for(Map.Entry<String,Float> entryPoint:points.entrySet()) { + Float val = entryPoint.getValue(); + if(val != null && val.floatValue() > 0.0f) { + iinput.put(entryPoint.getKey(), entryPoint.getKey()); + } + } + } + } + public static void renderSection(Section section, OpenXMLDocument document) { String title = section.getTitle(); document.appendHeading1(title, null); -- GitLab