Search in sources :

Example 36 with StringOutput

use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.

the class IQComponentRenderer method addSectionLink.

// menu stuff
private StringOutput addSectionLink(Renderer r, URLBuilder ubu, Formatter formatter, SectionContext sc, int sectionPos, boolean clickable, boolean active, boolean pagewise) {
    StringOutput sb = new StringOutput();
    // section link
    sb.append("<td>");
    String title = StringHelper.escapeHtml(Formatter.truncate(sc.getTitle(), 30));
    long maxdur = sc.getDurationLimit();
    long start = sc.getTimeOfStart();
    long due = start + maxdur;
    boolean started = (start != -1);
    boolean timelimit = (maxdur != -1);
    String fdue = (started && timelimit ? formatter.formatTimeShort(new Date(due)) : null);
    if (!sc.isOpen())
        clickable = false;
    if (active) {
        if (pagewise) {
            sb.append("<div class=\"o_qti_menu_section_active\">");
        } else {
            sb.append("<div class=\"o_qti_menu_section\">");
        }
    } else {
        if (pagewise) {
            sb.append("<div class=\"o_qti_menu_section_clickable\">");
        } else {
            sb.append("<div class=\"o_qti_menu_section\">");
        }
    }
    if (clickable) {
        sb.append("<a onclick=\"return o2cl()\" href=\"");
        ubu.buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "gse" });
        sb.append("?seid=" + sectionPos);
        sb.append("\" title=\"" + StringEscapeUtils.escapeHtml(sc.getTitle()) + "\">");
    }
    sb.append("<b>" + (sectionPos + 1) + ".</b>&nbsp;");
    sb.append(title);
    if (clickable) {
        sb.append("</a>");
    }
    sb.append("</div>");
    sb.append("</td>");
    sb.append("<td>");
    if (!sc.isOpen()) {
        sb.append("<div class='o_qti_closed_icon' title=\"");
        sb.append(StringEscapeUtils.escapeHtml(r.getTranslator().translate("itemclosed")));
        sb.append("\"><i class='o_icon o_icon_locked'> </i></div>");
    } else {
        // max duration info
        if (maxdur != -1) {
            sb.append("<div class='o_qti_timelimit_icon' title=\"");
            if (!sc.isStarted()) {
                sb.append(StringEscapeUtils.escapeHtml(r.getTranslator().translate("timelimit.initial", new String[] { getFormattedLimit(maxdur) })));
            } else {
                sb.append(StringEscapeUtils.escapeHtml(r.getTranslator().translate("timelimit.running", new String[] { fdue })));
            }
            sb.append("\" ><i class='o_icon o_icon_timelimit'> </i></div>");
        }
    }
    sb.append("</td>");
    sb.append("<td colspan=\"2\"></td>");
    return sb;
}
Also used : StringOutput(org.olat.core.gui.render.StringOutput) Date(java.util.Date)

Example 37 with StringOutput

use of org.olat.core.gui.render.StringOutput 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 38 with StringOutput

use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.

the class HotspotAssessmentItemBuilder method extractHotspotInteraction.

private void extractHotspotInteraction() {
    try (StringOutput sb = new StringOutput()) {
        List<Block> blocks = assessmentItem.getItemBody().getBlocks();
        for (Block block : blocks) {
            if (block instanceof HotspotInteraction) {
                hotspotInteraction = (HotspotInteraction) block;
                responseIdentifier = hotspotInteraction.getResponseIdentifier();
                break;
            } else {
                serializeJqtiObject(block, sb);
            }
        }
        question = sb.toString();
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) AssessmentItemFactory.appendHotspotInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendHotspotInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) StringOutput(org.olat.core.gui.render.StringOutput) IOException(java.io.IOException)

Example 39 with StringOutput

use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.

the class MatchAssessmentItemBuilder method extractMatchInteraction.

private void extractMatchInteraction() {
    try (StringOutput sb = new StringOutput()) {
        List<Block> blocks = assessmentItem.getItemBody().getBlocks();
        for (Block block : blocks) {
            if (block instanceof MatchInteraction) {
                matchInteraction = (MatchInteraction) block;
                responseIdentifier = matchInteraction.getResponseIdentifier();
                shuffle = matchInteraction.getShuffle();
                break;
            } else {
                serializeJqtiObject(block, sb);
            }
        }
        question = sb.toString();
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : AssessmentItemFactory.appendMatchInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendMatchInteraction) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) StringOutput(org.olat.core.gui.render.StringOutput) IOException(java.io.IOException)

Example 40 with StringOutput

use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.

the class EssayAssessmentItemBuilder method extractExtendedTextInteraction.

private void extractExtendedTextInteraction() {
    try (StringOutput sb = new StringOutput()) {
        List<Block> blocks = assessmentItem.getItemBody().getBlocks();
        for (Block block : blocks) {
            if (block instanceof ExtendedTextInteraction) {
                extendedTextInteraction = (ExtendedTextInteraction) block;
                responseIdentifier = extendedTextInteraction.getResponseIdentifier();
                break;
            } else {
                serializeJqtiObject(block, sb);
            }
        }
        question = sb.toString();
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) StringOutput(org.olat.core.gui.render.StringOutput) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) AssessmentItemFactory.appendExtendedTextInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendExtendedTextInteraction) IOException(java.io.IOException)

Aggregations

StringOutput (org.olat.core.gui.render.StringOutput)188 IOException (java.io.IOException)48 URLBuilder (org.olat.core.gui.render.URLBuilder)30 Renderer (org.olat.core.gui.render.Renderer)26 Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)24 RenderResult (org.olat.core.gui.render.RenderResult)22 Component (org.olat.core.gui.components.Component)10 Translator (org.olat.core.gui.translator.Translator)10 Locale (java.util.Locale)8 Window (org.olat.core.gui.components.Window)8 Form (org.olat.core.gui.components.form.flexible.impl.Form)8 VelocityRenderDecorator (org.olat.core.gui.render.velocity.VelocityRenderDecorator)8 ArrayList (java.util.ArrayList)6 StreamResult (javax.xml.transform.stream.StreamResult)6 Test (org.junit.Test)6 GlobalSettings (org.olat.core.gui.GlobalSettings)6 ComponentRenderer (org.olat.core.gui.components.ComponentRenderer)6 DefaultColumnDescriptor (org.olat.core.gui.components.table.DefaultColumnDescriptor)6 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)6 Matcher (java.util.regex.Matcher)5