Search in sources :

Example 16 with RenderResult

use of org.olat.core.gui.render.RenderResult in project openolat by klemens.

the class AssessmentObjectComponentRenderer method renderVelocity.

private void renderVelocity(AssessmentRenderer renderer, StringOutput sb, QtiNode interaction, Context ctx, String page, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, AssessmentObjectComponent component, URLBuilder ubu, Translator translator) {
    ctx.put("localName", interaction.getQtiClassName());
    ctx.put("assessmentItem", resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful());
    ctx.put("itemSessionState", itemSessionState);
    ctx.put("isItemSessionOpen", component.isItemSessionOpen(itemSessionState, renderer.isSolutionMode()));
    ctx.put("isItemSessionEnded", component.isItemSessionEnded(itemSessionState, renderer.isSolutionMode()));
    Renderer fr = Renderer.getInstance(component, translator, ubu, new RenderResult(), renderer.getGlobalSettings());
    AssessmentRenderer fHints = renderer.newHints(fr);
    try (AssessmentObjectVelocityRenderDecorator vrdec = new AssessmentObjectVelocityRenderDecorator(fHints, sb, component, resolvedAssessmentItem, itemSessionState, ubu, translator)) {
        ctx.put("r", vrdec);
        VelocityHelper vh = VelocityHelper.getInstance();
        vh.mergeContent(page, ctx, sb, null);
        ctx.remove("r");
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : Renderer(org.olat.core.gui.render.Renderer) DefaultComponentRenderer(org.olat.core.gui.components.DefaultComponentRenderer) RenderResult(org.olat.core.gui.render.RenderResult) VelocityHelper(org.olat.core.gui.render.velocity.VelocityHelper) IOException(java.io.IOException)

Example 17 with RenderResult

use of org.olat.core.gui.render.RenderResult in project openolat by klemens.

the class AssessmentTestComponentRenderer method renderTestItem.

private void renderTestItem(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNodeKey itemRefKey, URLBuilder ubu, Translator translator, RenderingRequest options) {
    final TestSessionController testSessionController = component.getTestSessionController();
    final TestSessionState testSessionState = testSessionController.getTestSessionState();
    String key = itemRefKey.toString();
    /* We finally do the transform on the _item_ (NB!) */
    sb.append("<div class='qtiworks o_assessmentitem o_assessmenttest'>");
    // test part feedback 'during'
    // test feedback 'during'
    TestPlanNode itemRefNode = testSessionState.getTestPlan().getNode(itemRefKey);
    final EffectiveItemSessionControl effectiveItemSessionControl = itemRefNode.getEffectiveItemSessionControl();
    final boolean allowComments = effectiveItemSessionControl.isAllowComment() && component.isPersonalNotes();
    renderer.setCandidateCommentAllowed(allowComments);
    // write section rubric
    renderSectionRubrics(renderer, sb, component, itemRefNode, ubu, translator);
    // test part -> section -> item
    renderTestItemBody(renderer, sb, component, itemRefNode, ubu, translator, options);
    // controls
    sb.append("<div class='o_button_group o_assessmentitem_controls'>");
    // submit button
    final ItemSessionState itemSessionState = component.getItemSessionState(itemRefNode.getKey());
    if (component.isItemSessionOpen(itemSessionState, options.isSolutionMode())) {
        Component submit = component.getQtiItem().getSubmitButton().getComponent();
        submit.getHTMLRendererSingleton().render(renderer.getRenderer(), sb, submit, ubu, translator, new RenderResult(), null);
    }
    // advanceTestItemAllowed /* && testSessionState.getCurrentItemKey() != null && testSessionController.mayAdvanceItemLinear() */
    if (options.isAdvanceTestItemAllowed()) {
        // TODO need to find if there is a next question
        String title = translator.translate("assessment.test.nextQuestion");
        renderControl(sb, component, title, false, "o_sel_next_question", new NameValuePair("cid", Event.finishItem.name()));
    }
    // nextItem
    if (options.isNextItemAllowed() && testSessionController.hasFollowingNonLinearItem()) {
        String title = translator.translate("assessment.test.nextQuestion");
        renderControl(sb, component, title, false, "o_sel_next_question", new NameValuePair("cid", Event.nextItem.name()));
    }
    // testPartNavigationAllowed"
    if (options.isTestPartNavigationAllowed() && component.isRenderNavigation()) {
        String title = translator.translate("assessment.test.questionMenu");
        renderControl(sb, component, title, false, "o_sel_question_menu", new NameValuePair("cid", Event.testPartNavigation.name()));
    }
    // endTestPartAllowed
    if (options.isEndTestPartAllowed()) {
        String title = component.hasMultipleTestParts() ? translator.translate("assessment.test.end.testPart") : translator.translate("assessment.test.end.test");
        renderControl(sb, component, title, false, "o_sel_end_testpart", new NameValuePair("cid", Event.endTestPart.name()));
    }
    // reviewMode
    if (options.isReviewMode()) {
        String title = translator.translate("assessment.test.backToTestFeedback");
        renderControl(sb, component, title, false, "o_sel_back_test_feedback", new NameValuePair("cid", Event.reviewTestPart.name()));
    }
    // <xsl:variable name="provideItemSolutionButton" as="xs:boolean" select="$reviewMode and $showSolution and not($solutionMode)"/>
    if (options.isReviewMode() && effectiveItemSessionControl.isShowSolution() && !options.isSolutionMode()) {
        String title = translator.translate("assessment.solution.show");
        renderControl(sb, component, title, false, "o_sel_show_solution", new NameValuePair("cid", Event.itemSolution.name()), new NameValuePair("item", key));
    }
    if (options.isReviewMode() && options.isSolutionMode()) {
        String title = translator.translate("assessment.solution.hide");
        renderControl(sb, component, title, false, "o_sel_solution_hide", new NameValuePair("cid", Event.reviewItem.name()), new NameValuePair("item", key));
    }
    // end controls
    sb.append("</div>");
    // end assessmentItem
    sb.append("</div>");
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) RenderResult(org.olat.core.gui.render.RenderResult) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) Component(org.olat.core.gui.components.Component) EffectiveItemSessionControl(uk.ac.ed.ph.jqtiplus.state.EffectiveItemSessionControl)

Example 18 with RenderResult

use of org.olat.core.gui.render.RenderResult in project openolat by klemens.

the class ExportBinderAsPDFResource method createResultHTML.

private String createResultHTML(Component content) {
    String pagePath = Util.getPackageVelocityRoot(this.getClass()) + "/export.html";
    VelocityContainer mainVC = new VelocityContainer("html", pagePath, translator, null);
    mainVC.put("cmp", content);
    mainVC.contextPut("bodyCssClass", "o_portfolio_export");
    StringOutput sb = new StringOutput(32000);
    URLBuilder ubu = new URLBuilder("auth", "1", "0");
    Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
    VelocityRenderDecorator vrdec = new VelocityRenderDecorator(renderer, mainVC, sb);
    mainVC.contextPut("r", vrdec);
    renderer.render(sb, mainVC, null);
    return sb.toString();
}
Also used : Renderer(org.olat.core.gui.render.Renderer) RenderResult(org.olat.core.gui.render.RenderResult) StringOutput(org.olat.core.gui.render.StringOutput) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) URLBuilder(org.olat.core.gui.render.URLBuilder) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator)

Example 19 with RenderResult

use of org.olat.core.gui.render.RenderResult in project openolat by klemens.

the class MailFromCellRenderer method render.

@Override
public void render(StringOutput sb, Renderer renderer, Object val, Locale locale, int alignment, String action) {
    if (val instanceof Identity) {
        Identity identity = (Identity) val;
        String fullName = userManager.getUserDisplayName(identity);
        if (renderer == null) {
            sb.appendHtmlEscaped(fullName);
        } else {
            Link link = LinkFactory.createLink("bp_" + counter.incrementAndGet(), container, listeningController);
            link.setCustomDisplayText(StringHelper.escapeHtml(fullName));
            link.setUserObject("[Identity:" + identity.getKey() + "]");
            URLBuilder ubu = renderer.getUrlBuilder().createCopyFor(link);
            RenderResult renderResult = new RenderResult();
            link.getHTMLRendererSingleton().render(renderer, sb, link, ubu, translator, renderResult, null);
        }
    } else if (val instanceof String) {
        sb.append("<span>").appendHtmlEscaped((String) val).append("</span>");
    }
}
Also used : RenderResult(org.olat.core.gui.render.RenderResult) Identity(org.olat.core.id.Identity) Link(org.olat.core.gui.components.link.Link) URLBuilder(org.olat.core.gui.render.URLBuilder)

Example 20 with RenderResult

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

the class CourseCreationConfiguration method getSinglePageText.

/**
 * @param translator
 * @return single page content
 */
public String getSinglePageText(Translator translator) {
    VelocityContainer vc = new VelocityContainer("singlePageTemplate", CourseCreationHelper.class, "singlePageTemplate", translator, null);
    vc.contextPut("coursetitle", courseTitle);
    // prepare rendering of velocity page for the content of the single page node
    GlobalSettings globalSettings = new GlobalSettings() {

        public int getFontSize() {
            return 100;
        }

        public AJAXFlags getAjaxFlags() {
            return new EmptyAJAXFlags();
        }

        public boolean isIdDivsForced() {
            return false;
        }
    };
    Context context = vc.getContext();
    Renderer fr = Renderer.getInstance(vc, translator, null, new RenderResult(), globalSettings);
    StringOutput wOut = new StringOutput(10000);
    VelocityRenderDecorator vrdec = new VelocityRenderDecorator(fr, vc, wOut);
    context.put("r", vrdec);
    VelocityHelper.getInstance().mergeContent(vc.getPage(), context, wOut, null);
    // free the decorator
    context.remove("r");
    IOUtils.closeQuietly(vrdec);
    return WysiwygFactory.createXHtmlFileContent(wOut.toString(), courseTitle);
}
Also used : Context(org.apache.velocity.context.Context) Renderer(org.olat.core.gui.render.Renderer) RenderResult(org.olat.core.gui.render.RenderResult) GlobalSettings(org.olat.core.gui.GlobalSettings) StringOutput(org.olat.core.gui.render.StringOutput) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator)

Aggregations

RenderResult (org.olat.core.gui.render.RenderResult)32 Renderer (org.olat.core.gui.render.Renderer)22 URLBuilder (org.olat.core.gui.render.URLBuilder)22 StringOutput (org.olat.core.gui.render.StringOutput)20 IOException (java.io.IOException)10 Component (org.olat.core.gui.components.Component)10 VelocityRenderDecorator (org.olat.core.gui.render.velocity.VelocityRenderDecorator)8 GlobalSettings (org.olat.core.gui.GlobalSettings)6 ComponentRenderer (org.olat.core.gui.components.ComponentRenderer)6 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)6 RenderingState (org.olat.core.gui.render.RenderingState)6 Translator (org.olat.core.gui.translator.Translator)6 ArrayList (java.util.ArrayList)4 DelegatingComponent (org.olat.core.gui.components.delegating.DelegatingComponent)4 InvalidRequestParameterException (org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException)4 Link (org.olat.core.gui.components.link.Link)4 Command (org.olat.core.gui.control.winmgr.Command)4 JSCommand (org.olat.core.gui.control.winmgr.JSCommand)4 AsyncMediaResponsible (org.olat.core.gui.media.AsyncMediaResponsible)4 InterceptHandler (org.olat.core.gui.render.intercept.InterceptHandler)4