Search in sources :

Example 16 with Renderer

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

the class GuiDebugDispatcherController method createInterceptComponentRenderer.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.olat.core.gui.render.debug.DebugHandler#createDebugComponentRenderer(org.olat.core.gui.components.ComponentRenderer)
	 */
@Override
public ComponentRenderer createInterceptComponentRenderer(final ComponentRenderer originalRenderer) {
    return new ComponentRenderer() {

        @Override
        public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
            if (debugURLBuilder != null && !DebugHelper.isProtected(source)) {
                // remember source for later debug info access
                String did = source.getDispatchID();
                String didS = String.valueOf(did);
                idToComponent.put(didS, source);
                int lev = renderResult.getNestedLevel();
                String cname = source.getClass().getName();
                String cnameShort = cname.substring(cname.lastIndexOf('.') + 1);
                // header before component
                sb.append("<div class='o_dev_w'>");
                sb.append("<div class='o_dev_h'><span id='o_guidebugst").append(did).append("' onmouseover=\"o_debu_show(this.parentNode.parentNode, jQuery('#o_guidebugtt").append(did).append("'))\">");
                sb.append(source.getComponentName()).append(" (").append(cnameShort).append(")");
                sb.append("</span></div>");
                sb.append("<div class='o_dev_c'><div id='o_guidebugtt").append(did).append("' class='o_dev_i'>");
                sb.append("Info: <b>").append(source.getComponentName()).append("</b> (" + cnameShort + ") id:");
                sb.append(String.valueOf(source.getDispatchID())).append("&nbsp; level:").append(lev);
                Controller listC = Util.getListeningControllerFor(source);
                if (listC != null) {
                    sb.append("<br /><b>controller:</b> <a  target=\"_blank\" href=\"");
                    String controllerClassName = listC.getClass().getName();
                    debugURLBuilder.buildURI(sb, new String[] { "cid", "com", "class" }, new String[] { String.valueOf(did), "ojava", controllerClassName });
                    sb.append("\">");
                    sb.append(controllerClassName);
                    sb.append("</a>");
                }
                sb.append("<br /><i>listeners</i>: ");
                if (!source.isEnabled()) {
                    sb.append(" NOT ENABLED");
                }
                String listeners = source.getListenerInfo();
                sb.append(listeners);
                if (!source.isVisible()) {
                    sb.append("<br />INVISIBLE");
                }
                sb.append("<br />");
                // we must let the original renderer do its work so that the collecting translator is callbacked.
                // we save the result in a new var since it is too early to append it to the 'stream' right now.
                StringOutput sbOrig = new StringOutput();
                try {
                    originalRenderer.render(renderer, sbOrig, source, ubu, translator, renderResult, args);
                } catch (Exception e) {
                    String emsg = "exception while rendering component '" + source.getComponentName() + "' (" + source.getClass().getName() + ") " + source.getListenerInfo() + "<br />Message of exception: " + e.getMessage();
                    sbOrig.append("<span style=\"color:red\">Exception</span><br /><pre>" + emsg + "</pre>");
                }
                sb.append("</div>");
                // add original component
                sb.append(sbOrig);
                sb.append("</div></div>");
            } else {
                // e.g. when the render process take place before the delegating
                // component of this controller here was rendered.
                // the delegating component should be placed near the <html> tag in
                // order to be rendered first.
                // the contentpane of the window and the first implementing container
                // will not be provided with debug info, which is on purpose,
                // since those are contents from the chiefcontroller which control the
                // window.
                // render original component
                originalRenderer.render(renderer, sb, source, ubu, translator, renderResult, args);
            }
        }

        @Override
        public void renderHeaderIncludes(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderingState rstate) {
            originalRenderer.renderHeaderIncludes(renderer, sb, source, ubu, translator, rstate);
        }

        @Override
        public void renderBodyOnLoadJSFunctionCall(Renderer renderer, StringOutput sb, Component source, RenderingState rstate) {
            originalRenderer.renderBodyOnLoadJSFunctionCall(renderer, sb, source, rstate);
        }
    };
}
Also used : ComponentRenderer(org.olat.core.gui.components.ComponentRenderer) Translator(org.olat.core.gui.translator.Translator) ComponentRenderer(org.olat.core.gui.components.ComponentRenderer) Renderer(org.olat.core.gui.render.Renderer) RenderResult(org.olat.core.gui.render.RenderResult) RenderingState(org.olat.core.gui.render.RenderingState) StringOutput(org.olat.core.gui.render.StringOutput) Component(org.olat.core.gui.components.Component) DelegatingComponent(org.olat.core.gui.components.delegating.DelegatingComponent) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) PlainTextEditorController(org.olat.core.commons.editor.plaintexteditor.PlainTextEditorController) SourceViewController(org.olat.core.gui.dev.controller.SourceViewController) IOException(java.io.IOException) URLBuilder(org.olat.core.gui.render.URLBuilder)

Example 17 with Renderer

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

the class AssessmentObjectComponentRenderer method renderBlock.

public void renderBlock(AssessmentRenderer renderer, StringOutput sb, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, Block block, URLBuilder ubu, Translator translator) {
    switch(block.getQtiClassName()) {
        case AssociateInteraction.QTI_CLASS_NAME:
        case ChoiceInteraction.QTI_CLASS_NAME:
        case DrawingInteraction.QTI_CLASS_NAME:
        case ExtendedTextInteraction.QTI_CLASS_NAME:
        case GapMatchInteraction.QTI_CLASS_NAME:
        case GraphicAssociateInteraction.QTI_CLASS_NAME:
        case GraphicGapMatchInteraction.QTI_CLASS_NAME:
        case GraphicOrderInteraction.QTI_CLASS_NAME:
        case HotspotInteraction.QTI_CLASS_NAME:
        case SelectPointInteraction.QTI_CLASS_NAME:
        case HottextInteraction.QTI_CLASS_NAME:
        case MatchInteraction.QTI_CLASS_NAME:
        case MediaInteraction.QTI_CLASS_NAME:
        case OrderInteraction.QTI_CLASS_NAME:
        case PositionObjectInteraction.QTI_CLASS_NAME:
        case SliderInteraction.QTI_CLASS_NAME:
        case UploadInteraction.QTI_CLASS_NAME:
            {
                renderInteraction(renderer, sb, (FlowInteraction) block, resolvedAssessmentItem, itemSessionState, component, ubu, translator);
                break;
            }
        case CustomInteraction.QTI_CLASS_NAME:
            {
                renderCustomInteraction(renderer, sb, (CustomInteraction<?>) block, resolvedAssessmentItem, itemSessionState, component, ubu, translator);
                break;
            }
        case PositionObjectStage.QTI_CLASS_NAME:
            {
                renderPositionObjectStage(renderer, sb, (PositionObjectStage) block, resolvedAssessmentItem, itemSessionState, component, ubu, translator);
                break;
            }
        // never rendered
        case TemplateBlock.QTI_CLASS_NAME:
            break;
        case InfoControl.QTI_CLASS_NAME:
            {
                renderInfoControl(renderer, sb, component, resolvedAssessmentItem, itemSessionState, (InfoControl) block, ubu, translator);
                break;
            }
        case FeedbackBlock.QTI_CLASS_NAME:
            {
                FeedbackBlock feedbackBlock = (FeedbackBlock) block;
                if (component.isFeedback(feedbackBlock, itemSessionState)) {
                    sb.append("<div class='o_info feedbackBlock '").append(getAtClass(feedbackBlock)).append(">");
                    feedbackBlock.getBlocks().forEach((child) -> renderBlock(renderer, sb, component, resolvedAssessmentItem, itemSessionState, child, ubu, translator));
                    sb.append("</div>");
                }
                break;
            }
        // never rendered automatically
        case RubricBlock.QTI_CLASS_NAME:
            break;
        case Math.QTI_CLASS_NAME:
            {
                renderMath(renderer, sb, component, resolvedAssessmentItem, itemSessionState, (Math) block);
                break;
            }
        case Div.QTI_CLASS_NAME:
            renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
            ((Div) block).getFlows().forEach((flow) -> renderFlow(renderer, sb, component, resolvedAssessmentItem, itemSessionState, flow, ubu, translator));
            renderEndTag(sb, block);
            break;
        case Ul.QTI_CLASS_NAME:
            renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
            ((Ul) block).getLis().forEach((li) -> renderLi(renderer, sb, component, resolvedAssessmentItem, itemSessionState, li, ubu, translator));
            renderEndTag(sb, block);
            break;
        case Ol.QTI_CLASS_NAME:
            renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
            ((Ol) block).getLis().forEach((li) -> renderLi(renderer, sb, component, resolvedAssessmentItem, itemSessionState, li, ubu, translator));
            renderEndTag(sb, block);
            break;
        case Dl.QTI_CLASS_NAME:
            renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
            ((Dl) block).getDlElements().forEach((dlElement) -> renderDlElement(renderer, sb, component, resolvedAssessmentItem, itemSessionState, dlElement, ubu, translator));
            renderEndTag(sb, block);
            break;
        case Table.QTI_CLASS_NAME:
            renderTable(renderer, sb, component, resolvedAssessmentItem, itemSessionState, (Table) block, ubu, translator);
            break;
        case Object.QTI_CLASS_NAME:
            System.out.println("1");
            break;
        default:
            {
                renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
                if (block instanceof AtomicBlock) {
                    AtomicBlock atomicBlock = (AtomicBlock) block;
                    atomicBlock.getInlines().forEach((child) -> renderInline(renderer, sb, component, resolvedAssessmentItem, itemSessionState, child, ubu, translator));
                } else if (block instanceof SimpleBlock) {
                    SimpleBlock simpleBlock = (SimpleBlock) block;
                    simpleBlock.getBlocks().forEach((child) -> renderBlock(renderer, sb, component, resolvedAssessmentItem, itemSessionState, child, ubu, translator));
                }
                renderEndTag(sb, block);
            }
    }
}
Also used : Util(org.olat.core.util.Util) AtomicBlock(uk.ac.ed.ph.jqtiplus.node.content.basic.AtomicBlock) AssessmentRenderFunctions.extractMathsContentPmathml(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractMathsContentPmathml) Colgroup(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Colgroup) AssessmentRenderFunctions.getAtClass(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getAtClass) AssessmentRenderFunctions.getOutcomeValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getOutcomeValue) StreamResult(javax.xml.transform.stream.StreamResult) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) CoreSpringFactory(org.olat.core.CoreSpringFactory) IntegerAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.IntegerAttribute) Context(org.apache.velocity.context.Context) Flow(uk.ac.ed.ph.jqtiplus.node.content.basic.Flow) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) AssessmentRenderFunctions.isInvalidResponse(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isInvalidResponse) QTI21Module(org.olat.ims.qti21.QTI21Module) InfoControl(uk.ac.ed.ph.jqtiplus.node.content.InfoControl) TableCell(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.TableCell) OLog(org.olat.core.logging.OLog) AssessmentRenderFunctions.extractRecordFieldValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractRecordFieldValue) Translator(org.olat.core.gui.translator.Translator) FormJSHelper(org.olat.core.gui.components.form.flexible.impl.FormJSHelper) Tfoot(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Tfoot) AssessmentRenderFunctions.getCardinalitySize(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getCardinalitySize) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun) Reader(java.io.Reader) Value(uk.ac.ed.ph.jqtiplus.value.Value) VelocityContext(org.apache.velocity.VelocityContext) QTI21Service(org.olat.ims.qti21.QTI21Service) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) AssessmentRenderFunctions.getHtmlAttributeValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getHtmlAttributeValue) StringOutputPool(org.olat.core.gui.render.StringOutputPool) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) TemplateBlock(uk.ac.ed.ph.jqtiplus.node.content.template.TemplateBlock) XsltStylesheetManager(uk.ac.ed.ph.jqtiplus.xmlutils.xslt.XsltStylesheetManager) ForeignAttribute(uk.ac.ed.ph.jqtiplus.attribute.ForeignAttribute) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) Hottext(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext) VariableDeclaration(uk.ac.ed.ph.jqtiplus.node.shared.VariableDeclaration) AssessmentRenderFunctions.checkJavaScript(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.checkJavaScript) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) QueryUtils(uk.ac.ed.ph.jqtiplus.utils.QueryUtils) AssessmentRenderFunctions.isTemplateDeclarationAMathVariable(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isTemplateDeclarationAMathVariable) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) QTI21Constants(org.olat.ims.qti21.QTI21Constants) StringMultipleAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.StringMultipleAttribute) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) FlowInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.FlowInteraction) MathEntryInteraction(uk.ac.ed.ph.qtiworks.mathassess.MathEntryInteraction) Attribute(uk.ac.ed.ph.jqtiplus.attribute.Attribute) Table(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Table) ArrayList(java.util.ArrayList) XMLReader(org.xml.sax.XMLReader) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) Cardinality(uk.ac.ed.ph.jqtiplus.value.Cardinality) AssessmentRenderFunctions.renderOrderedCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderOrderedCardinalityValue) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) StringHelper(org.olat.core.util.StringHelper) RenderResult(org.olat.core.gui.render.RenderResult) Img(uk.ac.ed.ph.jqtiplus.node.content.xhtml.image.Img) AssessmentRenderFunctions.isMultipleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMultipleCardinalityValue) PrintedVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.PrintedVariable) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentRenderFunctions.isVisible(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isVisible) AssessmentRenderFunctions.renderSingleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderSingleCardinalityValue) Inline(uk.ac.ed.ph.jqtiplus.node.content.basic.Inline) Br(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.Br) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) IOException(java.io.IOException) ForeignElement(uk.ac.ed.ph.jqtiplus.node.ForeignElement) CodeHelper(org.olat.core.util.CodeHelper) AssessmentRenderFunctions.renderMultipleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderMultipleCardinalityValue) StringReader(java.io.StringReader) SimpleBlock(uk.ac.ed.ph.jqtiplus.node.content.basic.SimpleBlock) AssessmentRenderFunctions.isBadResponse(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isBadResponse) NavigationMode(uk.ac.ed.ph.jqtiplus.node.test.NavigationMode) TransformerHandler(javax.xml.transform.sax.TransformerHandler) AssessmentRenderFunctions.exists(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.exists) AssessmentRenderFunctions.valueContains(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.valueContains) AssessmentRenderFunctions.extractSingleCardinalityResponseInput(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractSingleCardinalityResponseInput) URLBuilder(org.olat.core.gui.render.URLBuilder) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) Form(org.olat.core.gui.components.form.flexible.impl.Form) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) AssessmentRenderFunctions.extractResponseInputAt(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractResponseInputAt) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) XmlUtilities(org.olat.ims.qti21.XmlUtilities) A(uk.ac.ed.ph.jqtiplus.node.content.xhtml.hypertext.A) CustomInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction) Object(uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) AssessmentRenderFunctions.getTemplateValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getTemplateValue) FormUIFactory(org.olat.core.gui.components.form.flexible.FormUIFactory) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) StringOutput(org.olat.core.gui.render.StringOutput) AssessmentRenderFunctions.extractIterableElement(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractIterableElement) Renderer(org.olat.core.gui.render.Renderer) SimpleInline(uk.ac.ed.ph.jqtiplus.node.content.basic.SimpleInline) URI(java.net.URI) AssessmentRenderFunctions.renderRecordCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderRecordCardinalityValue) AssessmentItemFactory(org.olat.ims.qti21.model.xml.AssessmentItemFactory) Col(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Col) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) AssessmentRenderFunctions.getResponseValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseValue) AssessmentRenderFunctions.isNullValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isNullValue) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssessmentRenderFunctions.isSingleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isSingleCardinalityValue) FeedbackInline(uk.ac.ed.ph.jqtiplus.node.content.variable.FeedbackInline) Thead(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Thead) List(java.util.List) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) TextOrVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.TextOrVariable) PositionObjectStage(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.PositionObjectStage) BaseType(uk.ac.ed.ph.jqtiplus.value.BaseType) DefaultComponentRenderer(org.olat.core.gui.components.DefaultComponentRenderer) Ol(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Ol) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback) Settings(org.olat.core.helpers.Settings) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode) TemplateInline(uk.ac.ed.ph.jqtiplus.node.content.template.TemplateInline) AssessmentRenderFunctions.isRecordCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isRecordCardinalityValue) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) FormItem(org.olat.core.gui.components.form.flexible.FormItem) Math(uk.ac.ed.ph.jqtiplus.node.content.mathml.Math) SelectPointInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SelectPointInteraction) Span(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.Span) AssessmentRenderFunctions.isOrderedCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isOrderedCardinalityValue) AssessmentRenderFunctions.isMathsContentValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMathsContentValue) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) DlElement(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.DlElement) VelocityHelper(org.olat.core.gui.render.velocity.VelocityHelper) Li(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Li) Tr(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Tr) AssessmentRenderFunctions.getResponseDeclaration(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseDeclaration) InputSource(org.xml.sax.InputSource) Dd(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Dd) Link(org.olat.core.gui.components.link.Link) PositionObjectInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.PositionObjectInteraction) Dl(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Dl) FeedbackBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.FeedbackBlock) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) AttributeList(uk.ac.ed.ph.jqtiplus.attribute.AttributeList) Div(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.Div) Dt(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Dt) Tbody(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Tbody) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) MediaInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MediaInteraction) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) AssessmentRenderFunctions.getResponseInput(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseInput) Tracing(org.olat.core.logging.Tracing) Ul(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Ul) StringEscapeUtils(org.apache.commons.lang.StringEscapeUtils) SimpleBlock(uk.ac.ed.ph.jqtiplus.node.content.basic.SimpleBlock) InfoControl(uk.ac.ed.ph.jqtiplus.node.content.InfoControl) FeedbackBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.FeedbackBlock) AtomicBlock(uk.ac.ed.ph.jqtiplus.node.content.basic.AtomicBlock) CustomInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction) FlowInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.FlowInteraction) Math(uk.ac.ed.ph.jqtiplus.node.content.mathml.Math) PositionObjectStage(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.PositionObjectStage)

Example 18 with Renderer

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

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

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

the class RepositoryTableModel method addColumnDescriptors.

/**
 * @param tableCtr
 * @param selectButtonLabel Label of action row or null if no action row should be used
 * @param enableDirectLaunch
 * @return the position of the display name column
 */
public ColumnDescriptor addColumnDescriptors(TableController tableCtr, boolean selectTitle, boolean selectIcon, boolean remove, boolean infos) {
    Locale loc = translator.getLocale();
    CustomCellRenderer acRenderer = new RepositoryEntryACColumnDescriptor();
    tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.ac", RepoCols.ac.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT, acRenderer) {

        @Override
        public int compareTo(int rowa, int rowb) {
            Object o1 = table.getTableDataModel().getObject(rowa);
            Object o2 = table.getTableDataModel().getObject(rowb);
            if (o1 == null || !(o1 instanceof RepositoryEntry))
                return -1;
            if (o2 == null || !(o2 instanceof RepositoryEntry))
                return 1;
            RepositoryEntry re1 = (RepositoryEntry) o1;
            RepositoryEntry re2 = (RepositoryEntry) o2;
            if (re1.isMembersOnly()) {
                if (!re2.isMembersOnly()) {
                    return 1;
                }
            } else if (re2.isMembersOnly()) {
                return -1;
            }
            OLATResourceAccess ac1 = repoEntriesWithOffer.get(re1.getOlatResource().getKey());
            OLATResourceAccess ac2 = repoEntriesWithOffer.get(re2.getOlatResource().getKey());
            if (ac1 == null && ac2 != null)
                return -1;
            if (ac1 != null && ac2 == null)
                return 1;
            if (ac1 != null && ac2 != null)
                return compareAccess(re1, ac1, re2, ac2);
            return super.compareString(re1.getDisplayname(), re2.getDisplayname());
        }

        private int compareAccess(RepositoryEntry re1, OLATResourceAccess ac1, RepositoryEntry re2, OLATResourceAccess ac2) {
            int s1 = ac1.getMethods().size();
            int s2 = ac2.getMethods().size();
            int compare = s1 - s2;
            if (compare != 0)
                return compare;
            if (s1 > 0 && s2 > 0) {
                String t1 = ac1.getMethods().get(0).getMethod().getType();
                String t2 = ac2.getMethods().get(0).getMethod().getType();
                int compareType = super.compareString(t1, t2);
                if (compareType != 0)
                    return compareType;
            }
            return super.compareString(re1.getDisplayname(), re2.getDisplayname());
        }
    });
    tableCtr.addColumnDescriptor(new RepositoryEntryTypeColumnDescriptor("table.header.typeimg", RepoCols.repoEntry.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT));
    String selectAction = selectTitle ? TABLE_ACTION_SELECT_LINK : null;
    if (repositoryModule.isManagedRepositoryEntries()) {
        tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.externalid", RepoCols.externalId.ordinal(), selectAction, loc));
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.externalref", RepoCols.externalRef.ordinal(), selectAction, loc));
    }
    boolean lfVisible = lifecycleDao.countPublicLifecycle() > 0;
    tableCtr.addColumnDescriptor(lfVisible, new DefaultColumnDescriptor("table.header.lifecycle.label", RepoCols.lifecycleLabel.ordinal(), null, loc));
    tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.lifecycle.softkey", RepoCols.lifecycleSoftKey.ordinal(), null, loc));
    ColumnDescriptor nameColDesc = new DefaultColumnDescriptor("table.header.displayname", RepoCols.displayname.ordinal(), selectAction, loc) {

        @Override
        public int compareTo(int rowa, int rowb) {
            Object o1 = table.getTableDataModel().getValueAt(rowa, 1);
            Object o2 = table.getTableDataModel().getValueAt(rowb, 1);
            if (o1 == null || !(o1 instanceof RepositoryEntry))
                return -1;
            if (o2 == null || !(o2 instanceof RepositoryEntry))
                return 1;
            RepositoryEntry re1 = (RepositoryEntry) o1;
            RepositoryEntry re2 = (RepositoryEntry) o2;
            boolean c1 = RepositoryManager.getInstance().createRepositoryEntryStatus(re1.getStatusCode()).isClosed();
            boolean c2 = RepositoryManager.getInstance().createRepositoryEntryStatus(re2.getStatusCode()).isClosed();
            // same as Boolean compare
            int result = (c2 == c1 ? 0 : (c1 ? 1 : -1));
            if (result == 0) {
                Object a = table.getTableDataModel().getValueAt(rowa, dataColumn);
                Object b = table.getTableDataModel().getValueAt(rowb, dataColumn);
                if (a == null || !(a instanceof String))
                    return -1;
                if (b == null || !(b instanceof String))
                    return 1;
                String s1 = (String) a;
                String s2 = (String) b;
                result = compareString(s1, s2);
            }
            return result;
        }
    };
    tableCtr.addColumnDescriptor(nameColDesc);
    CustomCellRenderer dateRenderer = new DateCellRenderer(loc);
    tableCtr.addColumnDescriptor(false, new CustomRenderColumnDescriptor("table.header.lifecycle.start", RepoCols.lifecycleStart.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT, dateRenderer));
    tableCtr.addColumnDescriptor(false, new CustomRenderColumnDescriptor("table.header.lifecycle.end", RepoCols.lifecycleEnd.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT, dateRenderer));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.author", RepoCols.author.ordinal(), null, loc));
    CustomCellRenderer accessRenderer = new RepositoryEntryAccessColumnDescriptor(translator);
    ColumnDescriptor accessColDesc = new CustomRenderColumnDescriptor("table.header.access", RepoCols.repoEntry.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT, accessRenderer) {

        @Override
        public int compareTo(int rowa, int rowb) {
            Object o1 = table.getTableDataModel().getValueAt(rowa, 1);
            Object o2 = table.getTableDataModel().getValueAt(rowb, 1);
            if (o1 == null || !(o1 instanceof RepositoryEntry))
                return -1;
            if (o2 == null || !(o2 instanceof RepositoryEntry))
                return 1;
            RepositoryEntry re1 = (RepositoryEntry) o1;
            RepositoryEntry re2 = (RepositoryEntry) o2;
            int ar1 = re1.getAccess();
            if (re1.isMembersOnly()) {
                ar1 = 99;
            }
            int ar2 = re2.getAccess();
            if (re2.isMembersOnly()) {
                ar2 = 99;
            }
            if (ar1 < ar2)
                return -1;
            if (ar1 > ar2)
                return 1;
            return super.compareString(re1.getDisplayname(), re2.getDisplayname());
        }
    };
    tableCtr.addColumnDescriptor(accessColDesc);
    tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.date", RepoCols.creationDate.ordinal(), null, loc));
    tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.lastusage", RepoCols.lastUsage.ordinal(), null, loc));
    if (infos) {
        tableCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_INFOS, "info.header", translator.translate("info.header")) {

            @Override
            public void renderValue(StringOutput so, int row, Renderer renderer) {
                so.append("<i id='o_core").append(row).append("ref' class='o_icon o_icon-lg o_icon_info_resource'> </i>");
            }
        });
    }
    if (selectIcon) {
        tableCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_SELECT_LINK, "select", translator.translate("table.select")));
    }
    if (remove) {
        tableCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_REMOVE_LINK, "remove", translator.translate("remove")));
    }
    return nameColDesc;
}
Also used : Locale(java.util.Locale) CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) ColumnDescriptor(org.olat.core.gui.components.table.ColumnDescriptor) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) StringOutput(org.olat.core.gui.render.StringOutput) RepositoryEntry(org.olat.repository.RepositoryEntry) OLATResourceAccess(org.olat.resource.accesscontrol.model.OLATResourceAccess) CustomCellRenderer(org.olat.core.gui.components.table.CustomCellRenderer) DateCellRenderer(org.olat.core.gui.components.table.DateCellRenderer) CustomCellRenderer(org.olat.core.gui.components.table.CustomCellRenderer) Renderer(org.olat.core.gui.render.Renderer) DateCellRenderer(org.olat.core.gui.components.table.DateCellRenderer) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Aggregations

Renderer (org.olat.core.gui.render.Renderer)30 StringOutput (org.olat.core.gui.render.StringOutput)26 RenderResult (org.olat.core.gui.render.RenderResult)24 URLBuilder (org.olat.core.gui.render.URLBuilder)20 IOException (java.io.IOException)12 VelocityRenderDecorator (org.olat.core.gui.render.velocity.VelocityRenderDecorator)10 Component (org.olat.core.gui.components.Component)8 ComponentRenderer (org.olat.core.gui.components.ComponentRenderer)8 Translator (org.olat.core.gui.translator.Translator)8 ArrayList (java.util.ArrayList)6 Context (org.apache.velocity.context.Context)6 GlobalSettings (org.olat.core.gui.GlobalSettings)6 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)6 RenderingState (org.olat.core.gui.render.RenderingState)6 VelocityHelper (org.olat.core.gui.render.velocity.VelocityHelper)6 DefaultComponentRenderer (org.olat.core.gui.components.DefaultComponentRenderer)4 DelegatingComponent (org.olat.core.gui.components.delegating.DelegatingComponent)4 InvalidRequestParameterException (org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException)4 Command (org.olat.core.gui.control.winmgr.Command)4 JSCommand (org.olat.core.gui.control.winmgr.JSCommand)4