Search in sources :

Example 11 with URLBuilder

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

the class RESTDispatcher method getRedirectToURL.

private String getRedirectToURL(UserSession usess) {
    ChiefController cc = Windows.getWindows(usess).getChiefController();
    Window w = cc.getWindow();
    URLBuilder ubu = new URLBuilder(WebappHelper.getServletContextPath() + DispatcherModule.PATH_AUTHENTICATED, w.getInstanceId(), String.valueOf(w.getTimestamp()));
    StringOutput sout = new StringOutput(30);
    ubu.buildURI(sout, null, null);
    return sout.toString();
}
Also used : Window(org.olat.core.gui.components.Window) StringOutput(org.olat.core.gui.render.StringOutput) ChiefController(org.olat.core.gui.control.ChiefController) URLBuilder(org.olat.core.gui.render.URLBuilder)

Example 12 with URLBuilder

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

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 13 with URLBuilder

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

the class I18nTest method testInlineTranslationReplaceLocalizationMarkupWithHTML.

/**
 * Test methods i18nManager inline translation tool and InlineTranslationInterceptHandlerController
 */
@Test
public void testInlineTranslationReplaceLocalizationMarkupWithHTML() {
    // enable inline translation markup
    i18nMgr.setMarkLocalizedStringsEnabled(null, true);
    Translator inlineTrans = Util.createPackageTranslator(InlineTranslationInterceptHandlerController.class, i18nMgr.getLocaleOrNull("de"));
    URLBuilder inlineTranslationURLBuilder = new jUnitURLBuilder();
    String testBundle = "org.olat.core.util.i18n.junittestdata";
    String testKey = "no.need.to.translate.this";
    String rawtext1 = "Lorem impsum<b>nice stuff</b>";
    String rawtext2 = "Holderadio <ul>lsdfsdf<y  asdf blblb";
    String combinedKey = testBundle + ":" + testKey;
    // test method that adds identifyers around the translation items
    String plainVanillaWrapped = i18nMgr.getLocalizedString(testBundle, testKey, null, i18nMgr.getLocaleOrNull("de"), false, false);
    String plainVanillaPlain = "just a test";
    Pattern plainVanillaWrappedPattern = Pattern.compile(I18nManager.IDENT_PREFIX + combinedKey + ":([0-9]*?)" + I18nManager.IDENT_START_POSTFIX + plainVanillaPlain + I18nManager.IDENT_PREFIX + combinedKey + ":\\1" + I18nManager.IDENT_END_POSTFIX);
    Matcher m = plainVanillaWrappedPattern.matcher(plainVanillaWrapped);
    assertTrue(m.find());
    // test find-replace translator identifyers with HTML markup
    StringOutput inlineTransLink = new StringOutput();
    String[] args = (combinedKey + ":1000000001").split(":");
    InlineTranslationInterceptHandlerController.buildInlineTranslationLink(args, inlineTransLink, inlineTrans, inlineTranslationURLBuilder);
    // Plain vanilla text
    String convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(plainVanillaWrapped, inlineTranslationURLBuilder, inlineTrans);
    assertEquals("<span class=\"o_translation_i18nitem\">" + inlineTransLink.toString() + plainVanillaPlain + "</span>", convertedToHTMLMarkup);
    // Simple link
    String linkOPEN = "<a href=\"http://www.olat.org/bla/blu:bli#bla\" title='funny title' class=\"o_css O_anothercss\">";
    String linkCLOSE = "</a>";
    String inlineSpanOPEN = "<span class=\"o_translation_i18nitem\">";
    String inlineSpanCLOSE = "</span>";
    String translatedWithinLink = linkOPEN + plainVanillaWrapped + linkCLOSE + rawtext1;
    convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(translatedWithinLink, inlineTranslationURLBuilder, inlineTrans);
    String convertedWithinLinkExpected = inlineSpanOPEN + inlineTransLink.toString() + linkOPEN + plainVanillaPlain + linkCLOSE + inlineSpanCLOSE + rawtext1;
    assertEquals(convertedWithinLinkExpected, convertedToHTMLMarkup);
    // Simple link with span
    String linkSpanOPEN = "<span class=\"bluber\">";
    String linkSpanCLOSE = "</span>";
    String translatedWithinLinkAndSpan = rawtext2 + linkOPEN + linkSpanOPEN + plainVanillaWrapped + linkSpanCLOSE + linkCLOSE;
    convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(translatedWithinLinkAndSpan, inlineTranslationURLBuilder, inlineTrans);
    String convertedWithinLinkAndSpanExpected = rawtext2 + inlineSpanOPEN + inlineTransLink.toString() + linkOPEN + linkSpanOPEN + plainVanillaPlain + linkSpanCLOSE + linkCLOSE + inlineSpanCLOSE;
    assertEquals(convertedWithinLinkAndSpanExpected, convertedToHTMLMarkup);
    // Muliple links
    String translatedWithinMultipleLinks = translatedWithinLink + translatedWithinLinkAndSpan + translatedWithinLinkAndSpan;
    convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(translatedWithinMultipleLinks, inlineTranslationURLBuilder, inlineTrans);
    String convertedWithinMultipleLinksExpected = convertedWithinLinkExpected + convertedWithinLinkAndSpanExpected + convertedWithinLinkAndSpanExpected;
    assertEquals(convertedWithinMultipleLinksExpected, convertedToHTMLMarkup);
    // Input elements
    String inputOPEN = "<input type='submit' class=\"bluber\" value=\"";
    String inputCLOSE = "\" />";
    String translatedWithinInput = inputOPEN + plainVanillaWrapped + inputCLOSE + rawtext1;
    convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(translatedWithinInput, inlineTranslationURLBuilder, inlineTrans);
    String convertedWithinInputExpected = inlineSpanOPEN + inlineTransLink.toString() + inputOPEN + plainVanillaPlain + inputCLOSE + inlineSpanCLOSE + rawtext1;
    assertEquals(convertedWithinInputExpected, convertedToHTMLMarkup);
    // checkbox elements
    String checkboxOPEN = "<input type='submit' class=\"bluber\" type=\"checkbox\" value=\"";
    String checkboxCLOSE = "\" />";
    String translatedWithinCheckbox = checkboxOPEN + plainVanillaWrapped + checkboxCLOSE + rawtext1;
    convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(translatedWithinCheckbox, inlineTranslationURLBuilder, inlineTrans);
    String convertedWithinCheckboxExpected = checkboxOPEN + plainVanillaPlain + checkboxCLOSE + rawtext1;
    assertEquals(convertedWithinCheckboxExpected, convertedToHTMLMarkup);
    // Input and links mixed
    String translatedWithinMultipleLinksAndInput = translatedWithinLink + rawtext1 + translatedWithinInput + translatedWithinLinkAndSpan + rawtext2 + translatedWithinInput + translatedWithinLinkAndSpan;
    convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(translatedWithinMultipleLinksAndInput, inlineTranslationURLBuilder, inlineTrans);
    String convertedWithinMultipleLinksAndInputExpected = convertedWithinLinkExpected + rawtext1 + convertedWithinInputExpected + convertedWithinLinkAndSpanExpected + rawtext2 + convertedWithinInputExpected + convertedWithinLinkAndSpanExpected;
    assertEquals(convertedWithinMultipleLinksAndInputExpected, convertedToHTMLMarkup);
    // Within element attribute
    String attributeOPEN = "<a href='sdfsdf' title=\"";
    String attributeCLOSE = "\" class=\"o_bluber\">hello world</a>";
    String translatedWithinAttribute = attributeOPEN + plainVanillaWrapped + attributeCLOSE + rawtext1;
    convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(translatedWithinAttribute, inlineTranslationURLBuilder, inlineTrans);
    String convertedWithinAttributeExpected = attributeOPEN + plainVanillaPlain + attributeCLOSE + rawtext1;
    assertEquals(convertedWithinAttributeExpected, convertedToHTMLMarkup);
    // Ultimate test
    String translatedUltimate = translatedWithinMultipleLinksAndInput + rawtext1 + translatedWithinAttribute + translatedWithinMultipleLinksAndInput + rawtext2 + translatedWithinInput + translatedWithinLinkAndSpan;
    convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(translatedUltimate, inlineTranslationURLBuilder, inlineTrans);
    String convertedUltimateExpected = convertedWithinMultipleLinksAndInputExpected + rawtext1 + convertedWithinAttributeExpected + convertedWithinMultipleLinksAndInputExpected + rawtext2 + convertedWithinInputExpected + convertedWithinLinkAndSpanExpected;
    assertEquals(convertedUltimateExpected, convertedToHTMLMarkup);
    // don't do inline translation markup
    i18nMgr.setMarkLocalizedStringsEnabled(null, false);
}
Also used : Pattern(java.util.regex.Pattern) Translator(org.olat.core.gui.translator.Translator) Matcher(java.util.regex.Matcher) StringOutput(org.olat.core.gui.render.StringOutput) URLBuilder(org.olat.core.gui.render.URLBuilder) Test(org.junit.Test)

Example 14 with URLBuilder

use of org.olat.core.gui.render.URLBuilder 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)

Example 15 with URLBuilder

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

the class FolderPage method assertOnDirectory.

public FolderPage assertOnDirectory(String name) {
    // encode name same was as in UI
    URLBuilder urlBuilder = new URLBuilder("", "", "");
    String escapedName = urlBuilder.encodeUrl(name);
    By directoryBy = By.xpath("//table[contains(@class,'o_bc_table')]//a[contains(@onclick,'" + escapedName + "')]");
    List<WebElement> directoryEls = browser.findElements(directoryBy);
    Assert.assertFalse(directoryEls.isEmpty());
    return this;
}
Also used : By(org.openqa.selenium.By) WebElement(org.openqa.selenium.WebElement) URLBuilder(org.olat.core.gui.render.URLBuilder)

Aggregations

URLBuilder (org.olat.core.gui.render.URLBuilder)36 StringOutput (org.olat.core.gui.render.StringOutput)30 RenderResult (org.olat.core.gui.render.RenderResult)24 Renderer (org.olat.core.gui.render.Renderer)20 IOException (java.io.IOException)10 Translator (org.olat.core.gui.translator.Translator)10 ArrayList (java.util.ArrayList)6 Component (org.olat.core.gui.components.Component)6 ComponentRenderer (org.olat.core.gui.components.ComponentRenderer)6 Window (org.olat.core.gui.components.Window)6 Link (org.olat.core.gui.components.link.Link)6 ChiefController (org.olat.core.gui.control.ChiefController)6 RenderingState (org.olat.core.gui.render.RenderingState)6 VelocityRenderDecorator (org.olat.core.gui.render.velocity.VelocityRenderDecorator)6 GlobalSettings (org.olat.core.gui.GlobalSettings)4 DelegatingComponent (org.olat.core.gui.components.delegating.DelegatingComponent)4 InvalidRequestParameterException (org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException)4 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)4 Command (org.olat.core.gui.control.winmgr.Command)4 JSCommand (org.olat.core.gui.control.winmgr.JSCommand)4