Search in sources :

Example 6 with RenderResult

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

the class MailContextCellRenderer method render.

@Override
public void render(StringOutput sb, Renderer renderer, Object val, Locale locale, int alignment, String action) {
    if (val instanceof ContextPair) {
        ContextPair context = (ContextPair) val;
        if (renderer == null) {
            StringHelper.escapeHtml(sb, context.getName());
        } else {
            String contextName = StringHelper.escapeHtml(context.getName());
            Link link = LinkFactory.createLink("bp_" + UUID.randomUUID().toString(), container, listeningController);
            link.setCustomDisplayText(contextName);
            link.setUserObject(context.getBusinessPath());
            URLBuilder ubu = renderer.getUrlBuilder().createCopyFor(link);
            RenderResult renderResult = new RenderResult();
            link.getHTMLRendererSingleton().render(renderer, sb, link, ubu, translator, renderResult, null);
        }
    }
}
Also used : RenderResult(org.olat.core.gui.render.RenderResult) Link(org.olat.core.gui.components.link.Link) ContextPair(org.olat.core.util.mail.ui.MailDataModel.ContextPair) URLBuilder(org.olat.core.gui.render.URLBuilder)

Example 7 with RenderResult

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

the class ExportBinderAsCPResource method renderVelocityContainer.

private String renderVelocityContainer(VelocityContainer mainVC) {
    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) URLBuilder(org.olat.core.gui.render.URLBuilder) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator)

Example 8 with RenderResult

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

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 9 with RenderResult

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

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 10 with RenderResult

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

the class QTI21ResultsExportMediaResource method createResultHTML.

private String createResultHTML(Component results) {
    String pagePath = Util.getPackageVelocityRoot(this.getClass()) + "/qti21results.html";
    URLBuilder ubu = new URLBuilder("auth", "1", "0");
    // generate VelocityContainer and put Component
    VelocityContainer mainVC = new VelocityContainer("html", pagePath, translator, null);
    mainVC.contextPut("rootTitle", translator.translate("table.grading"));
    mainVC.put("results", results);
    // render VelocityContainer to StringOutPut
    Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
    try (StringOutput sb = new StringOutput(32000);
        VelocityRenderDecorator vrdec = new VelocityRenderDecorator(renderer, mainVC, sb)) {
        mainVC.contextPut("r", vrdec);
        renderer.render(sb, mainVC, null);
        vrdec.close();
        return sb.toString();
    } catch (Exception e) {
        log.error("", e);
        return "";
    }
}
Also used : Renderer(org.olat.core.gui.render.Renderer) RenderResult(org.olat.core.gui.render.RenderResult) StringOutput(org.olat.core.gui.render.StringOutput) IOException(java.io.IOException) URLBuilder(org.olat.core.gui.render.URLBuilder) 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