Search in sources :

Example 1 with RenderInstructions

use of org.olat.ims.qti.container.qtielements.RenderInstructions in project OpenOLAT by OpenOLAT.

the class QTIWordExport method renderItem.

public static void renderItem(Item item, OpenXMLDocument document, boolean withResponses, Translator translator) {
    Element el = DocumentFactory.getInstance().createElement("dummy");
    item.addToElement(el);
    Element itemEl = (Element) el.elements().get(0);
    org.olat.ims.qti.container.qtielements.Item foo = new org.olat.ims.qti.container.qtielements.Item(itemEl);
    RenderInstructions renderInstructions = new RenderInstructions();
    renderInstructions.put(RenderInstructions.KEY_STATICS_PATH, "/");
    renderInstructions.put(RenderInstructions.KEY_LOCALE, translator.getLocale());
    renderInstructions.put(RenderInstructions.KEY_RENDER_TITLE, Boolean.TRUE);
    if (item.getQuestion() != null) {
        Map<String, String> iinput = new HashMap<String, String>();
        String questionType = null;
        String questionScore = null;
        Question question = item.getQuestion();
        if (question instanceof ChoiceQuestion) {
            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);
            }
        } else if (question instanceof FIBQuestion) {
            questionType = translator.translate("item.type.sc");
            for (Response response : question.getResponses()) {
                FIBResponse fibResponse = (FIBResponse) response;
                if ("BLANK".equals(fibResponse.getType())) {
                    iinput.put(fibResponse.getIdent(), fibResponse.getCorrectBlank());
                }
            }
        } else if (question instanceof EssayQuestion) {
            questionType = translator.translate("item.type.essay");
        }
        if (question != null && question.getMaxValue() > 0.0f) {
            questionScore = AssessmentHelper.getRoundedScore(question.getMaxValue());
            questionScore = translator.translate("item.score.long", new String[] { questionScore });
        }
        renderInstructions.put(RenderInstructions.KEY_RENDER_CORRECT_RESPONSES, new Boolean(withResponses));
        renderInstructions.put(RenderInstructions.KEY_CORRECT_RESPONSES_MAP, iinput);
        renderInstructions.put(RenderInstructions.KEY_QUESTION_TYPE, questionType);
        renderInstructions.put(RenderInstructions.KEY_QUESTION_SCORE, questionScore);
        renderInstructions.put(RenderInstructions.KEY_QUESTION_OO_TYPE, new Integer(question.getType()));
    }
    foo.renderOpenXML(document, renderInstructions);
}
Also used : EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) HashMap(java.util.HashMap) Element(org.dom4j.Element) RenderInstructions(org.olat.ims.qti.container.qtielements.RenderInstructions) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Item(org.olat.ims.qti.editor.beecom.objects.Item) EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) FIBQuestion(org.olat.ims.qti.editor.beecom.objects.FIBQuestion) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) FIBQuestion(org.olat.ims.qti.editor.beecom.objects.FIBQuestion)

Example 2 with RenderInstructions

use of org.olat.ims.qti.container.qtielements.RenderInstructions in project OpenOLAT by OpenOLAT.

the class IQComponentRenderer method displayItem.

private void displayItem(StringOutput sb, Renderer renderer, URLBuilder ubu, ItemContext itc, AssessmentInstance ai) {
    StringBuilder buffer = new StringBuilder(1000);
    Resolver resolver = ai.getResolver();
    RenderInstructions ri = new RenderInstructions();
    ri.put(RenderInstructions.KEY_STATICS_PATH, resolver.getStaticsBaseURI() + "/");
    ri.put(RenderInstructions.KEY_LOCALE, renderer.getTranslator().getLocale());
    StringOutput soCommandURI = new StringOutput(50);
    ubu.buildURI(soCommandURI, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "sflash" });
    ri.put(RenderInstructions.KEY_APPLET_SUBMIT_URI, soCommandURI.toString());
    if (itc.getItemInput() != null)
        ri.put(RenderInstructions.KEY_ITEM_INPUT, itc.getItemInput());
    ri.put(RenderInstructions.KEY_RENDER_TITLE, Boolean.valueOf(ai.isDisplayTitles()));
    if (ai.isAutoEnum()) {
        String k = renderer.getTranslator().translate("choices.autoenum.keys");
        if (k != null) {
            ri.put(RenderInstructions.KEY_RENDER_AUTOENUM_LIST, k);
        }
    }
    itc.getQtiItem().render(buffer, ri);
    sb.append(buffer);
}
Also used : RenderInstructions(org.olat.ims.qti.container.qtielements.RenderInstructions) Resolver(org.olat.ims.qti.process.Resolver) StringOutput(org.olat.core.gui.render.StringOutput)

Example 3 with RenderInstructions

use of org.olat.ims.qti.container.qtielements.RenderInstructions in project openolat by klemens.

the class IQComponentRenderer method displayFeedback.

private void displayFeedback(StringOutput sb, GenericQTIElement feedback, AssessmentInstance ai, Locale locale) {
    StringBuilder sbTmp = new StringBuilder();
    Resolver resolver = ai.getResolver();
    RenderInstructions ri = new RenderInstructions();
    ri.put(RenderInstructions.KEY_STATICS_PATH, resolver.getStaticsBaseURI() + "/");
    ri.put(RenderInstructions.KEY_LOCALE, locale);
    feedback.render(sbTmp, ri);
    sb.append(sbTmp);
}
Also used : RenderInstructions(org.olat.ims.qti.container.qtielements.RenderInstructions) Resolver(org.olat.ims.qti.process.Resolver)

Example 4 with RenderInstructions

use of org.olat.ims.qti.container.qtielements.RenderInstructions in project openolat by klemens.

the class IQComponentRenderer method displayItem.

private void displayItem(StringOutput sb, Renderer renderer, URLBuilder ubu, ItemContext itc, AssessmentInstance ai) {
    StringBuilder buffer = new StringBuilder(1000);
    Resolver resolver = ai.getResolver();
    RenderInstructions ri = new RenderInstructions();
    ri.put(RenderInstructions.KEY_STATICS_PATH, resolver.getStaticsBaseURI() + "/");
    ri.put(RenderInstructions.KEY_LOCALE, renderer.getTranslator().getLocale());
    StringOutput soCommandURI = new StringOutput(50);
    ubu.buildURI(soCommandURI, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "sflash" });
    ri.put(RenderInstructions.KEY_APPLET_SUBMIT_URI, soCommandURI.toString());
    if (itc.getItemInput() != null)
        ri.put(RenderInstructions.KEY_ITEM_INPUT, itc.getItemInput());
    ri.put(RenderInstructions.KEY_RENDER_TITLE, Boolean.valueOf(ai.isDisplayTitles()));
    if (ai.isAutoEnum()) {
        String k = renderer.getTranslator().translate("choices.autoenum.keys");
        if (k != null) {
            ri.put(RenderInstructions.KEY_RENDER_AUTOENUM_LIST, k);
        }
    }
    itc.getQtiItem().render(buffer, ri);
    sb.append(buffer);
}
Also used : RenderInstructions(org.olat.ims.qti.container.qtielements.RenderInstructions) Resolver(org.olat.ims.qti.process.Resolver) StringOutput(org.olat.core.gui.render.StringOutput)

Example 5 with RenderInstructions

use of org.olat.ims.qti.container.qtielements.RenderInstructions in project OpenOLAT by OpenOLAT.

the class IQComponentRenderer method displayAssessmentInfo.

private void displayAssessmentInfo(StringOutput sb, AssessmentContext ac, AssessmentInstance ai, IQComponent comp, URLBuilder ubu, Translator translator) {
    Objectives objectives = ac.getObjectives();
    if (objectives != null) {
        StringBuilder sbTmp = new StringBuilder();
        Resolver resolver = ai.getResolver();
        RenderInstructions ri = new RenderInstructions();
        ri.put(RenderInstructions.KEY_STATICS_PATH, resolver.getStaticsBaseURI() + "/");
        objectives.render(sbTmp, ri);
        sb.append(sbTmp);
    }
    // if Menu not visible, or if visible but not selectable show button to navigate to the first section panel
    IQMenuDisplayConf menuDisplayConfig = comp.getMenuDisplayConf();
    if (!menuDisplayConfig.isEnabledMenu()) {
        sb.append("<a class=\"btn btn-default\" onclick=\"return o2cl()\" href=\"");
        ubu.buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "gse" });
        sb.append("?seid=" + 0);
        String title = translator.translate("next");
        sb.append("\" title=\"" + StringEscapeUtils.escapeHtml(title) + "\">");
        sb.append("<span>").append(title).append("</span>");
        sb.append("</a>");
    }
}
Also used : RenderInstructions(org.olat.ims.qti.container.qtielements.RenderInstructions) Resolver(org.olat.ims.qti.process.Resolver) Objectives(org.olat.ims.qti.container.qtielements.Objectives)

Aggregations

RenderInstructions (org.olat.ims.qti.container.qtielements.RenderInstructions)10 Resolver (org.olat.ims.qti.process.Resolver)8 Objectives (org.olat.ims.qti.container.qtielements.Objectives)4 HashMap (java.util.HashMap)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Element (org.dom4j.Element)2 StringOutput (org.olat.core.gui.render.StringOutput)2 AssessmentContext (org.olat.ims.qti.container.AssessmentContext)2 Hint (org.olat.ims.qti.container.qtielements.Hint)2 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)2 EssayQuestion (org.olat.ims.qti.editor.beecom.objects.EssayQuestion)2 FIBQuestion (org.olat.ims.qti.editor.beecom.objects.FIBQuestion)2 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)2 Item (org.olat.ims.qti.editor.beecom.objects.Item)2 Question (org.olat.ims.qti.editor.beecom.objects.Question)2 Response (org.olat.ims.qti.editor.beecom.objects.Response)2