Search in sources :

Example 16 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project OpenOLAT by OpenOLAT.

the class SmsPhoneElement method evalFormRequest.

@Override
public void evalFormRequest(UserRequest ureq) {
    Form form = getRootForm();
    String dispatchuri = form.getRequestParameter("dispatchuri");
    if (editLink != null && editLink.getFormDispatchId().equals(dispatchuri)) {
        doEdit(ureq);
    } else if (removeLink != null && removeLink.getFormDispatchId().equals(dispatchuri)) {
        doRemove();
    }
}
Also used : Form(org.olat.core.gui.components.form.flexible.impl.Form)

Example 17 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project OpenOLAT by OpenOLAT.

the class AssessmentTestComponentRenderer method renderSectionRubrics.

private void renderSectionRubrics(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNode itemRefNode, URLBuilder ubu, Translator translator) {
    boolean writeRubrics = false;
    boolean writeTitles = false;
    List<AssessmentSection> sectionParentLine = new ArrayList<>();
    for (TestPlanNode parentNode = itemRefNode.getParent(); parentNode.getParent() != null; parentNode = parentNode.getParent()) {
        AssessmentSection selectedSection = component.getAssessmentSection(parentNode.getIdentifier());
        if (selectedSection != null && selectedSection.getVisible()) {
            sectionParentLine.add(selectedSection);
            if (selectedSection.getRubricBlocks().size() > 0) {
                for (RubricBlock rubric : selectedSection.getRubricBlocks()) {
                    if (rubric.getBlocks().size() > 0) {
                        writeRubrics = true;
                    }
                }
            }
            if (StringHelper.containsNonWhitespace(selectedSection.getTitle())) {
                writeTitles = true;
            }
        }
    }
    if (writeRubrics) {
        boolean show = true;
        for (int i = sectionParentLine.size(); i-- > 0; ) {
            AssessmentSection selectedSection = sectionParentLine.get(i);
            if (component.getCandidateSessionContext().isRubricHidden(selectedSection.getIdentifier())) {
                show = false;
            }
        }
        String key = sectionParentLine.get(0).getIdentifier().toString();
        Form form = component.getQtiItem().getRootForm();
        String dispatchId = component.getQtiItem().getFormDispatchId();
        sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRNFFnCallFor(form, dispatchId, 1, new NameValuePair("cid", Event.rubric.name()), new NameValuePair("section", key))).append("; return false;\" class='o_toogle_rubrics translated'><i class='o_icon o_icon-fw ");
        if (show) {
            sb.append("o_icon_close_togglebox'> </i> <span>").append(translator.translate("hide.rubric"));
        } else {
            sb.append("o_icon_open_togglebox'> </i> <span>").append(translator.translate("show.rubric"));
        }
        sb.append("</span></a>");
        sb.append("<div class='o_info o_assessmentsection_rubrics clearfix");
        if (show) {
            sb.append(" o_show");
        } else {
            sb.append(" o_hide");
        }
        sb.append("'>");
        // write the titles first
        if (writeTitles) {
            sb.append("<h4>");
            for (int i = 0; i < sectionParentLine.size(); i++) {
                if (i == 1) {
                    sb.append("<small>");
                } else if (i > 1) {
                    sb.append(" / ");
                }
                sb.append(sectionParentLine.get(i).getTitle());
            }
            if (sectionParentLine.size() > 1) {
                sb.append("</small>");
            }
            sb.append("</h4>");
        }
        for (int i = sectionParentLine.size(); i-- > 0; ) {
            AssessmentSection selectedSection = sectionParentLine.get(i);
            for (RubricBlock rubricBlock : selectedSection.getRubricBlocks()) {
                // @view (candidate)
                sb.append("<div class='rubric'>");
                rubricBlock.getBlocks().forEach(block -> renderBlock(renderer, sb, component, null, null, block, ubu, translator));
                sb.append("</div>");
            }
        }
        sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRNFFnCallFor(form, dispatchId, 1, new NameValuePair("cid", Event.rubric.name()), new NameValuePair("section", key))).append("; return false;\" class='o_toogle_rubrics o_hide'><span>").append(translator.translate("hide.rubric.short")).append("</span></a>");
        // script to show/hide the rubrics with the translated linked
        sb.append("<script type=\"text/javascript\">\n").append("/* <![CDATA[ */ \n").append("jQuery(function() {\n").append(" jQuery('.o_toogle_rubrics').on('click', function() {\n").append("   jQuery('.o_assessmentsection_rubrics').each(function(index, el) {\n").append("     var current = jQuery(el).attr('class');\n").append("     if(current.indexOf('o_hide') >= 0) {\n").append("       jQuery(el).removeClass('o_hide').addClass('o_show');\n").append("       jQuery('a.o_toogle_rubrics.translated i').removeClass('o_icon_open_togglebox').addClass('o_icon_close_togglebox');\n").append("       jQuery('a.o_toogle_rubrics.translated span').html('").append(translator.translate("hide.rubric")).append("');").append("     } else {\n").append("   	  jQuery(el).removeClass('o_show').addClass('o_hide');\n").append("       jQuery('a.o_toogle_rubrics.translated i').removeClass('o_icon_close_togglebox').addClass('o_icon_open_togglebox');\n").append("       jQuery('a.o_toogle_rubrics.translated span').html('").append(translator.translate("show.rubric")).append("');").append("     }\n").append("   });").append(" });").append("});\n /* ]]> */").append("</script>").append("</div>");
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) ArrayList(java.util.ArrayList) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)

Example 18 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project openolat by klemens.

the class SmsPhoneElement method evalFormRequest.

@Override
public void evalFormRequest(UserRequest ureq) {
    Form form = getRootForm();
    String dispatchuri = form.getRequestParameter("dispatchuri");
    if (editLink != null && editLink.getFormDispatchId().equals(dispatchuri)) {
        doEdit(ureq);
    } else if (removeLink != null && removeLink.getFormDispatchId().equals(dispatchuri)) {
        doRemove();
    }
}
Also used : Form(org.olat.core.gui.components.form.flexible.impl.Form)

Example 19 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project openolat by klemens.

the class RichTextElementRenderer method renderTinyMCE_4.

private void renderTinyMCE_4(StringOutput sb, String domID, RichTextElementComponent teC, URLBuilder ubu, Translator translator) {
    RichTextElementImpl te = teC.getRichTextElementImpl();
    te.setRenderingMode(TextMode.formatted);
    RichTextConfiguration config = te.getEditorConfiguration();
    List<String> onInit = config.getOnInit();
    StringOutput configurations = new StringOutput();
    config.appendConfigToTinyJSArray_4(configurations, translator);
    if (config.getAdditionalConfiguration() != null) {
        config.getAdditionalConfiguration().appendConfigToTinyJSArray_4(configurations, translator);
    }
    StringOutput baseUrl = new StringOutput();
    StaticMediaDispatcher.renderStaticURI(baseUrl, "js/tinymce4/tinymce/tinymce.min.js", true);
    // Read write view
    renderTinyMCETextarea(sb, domID, teC);
    Form form = te.getRootForm();
    configurations.append("ffxhrevent: { formNam:\"").append(form.getFormName()).append("\", dispIdField:\"").append(form.getDispatchFieldId()).append("\",").append(" dispId:\"").append(teC.getFormDispatchId()).append("\", eventIdField:\"").append(form.getEventFieldId()).append("\"},\n");
    if (te.getMaxLength() > 0) {
        configurations.append("maxSize:").append(te.getMaxLength()).append("\n");
    }
    sb.append("<script type='text/javascript'>/* <![CDATA[ */\n");
    // file browser url
    sb.append("  BTinyHelper.editorMediaUris.put('").append(domID).append("','");
    ubu.buildURI(sb, null, null);
    sb.append("');\n");
    sb.append("  jQuery('#").append(domID).append("').tinymce({\n").append("    selector: '#").append(domID).append("',\n").append("    script_url: '").append(baseUrl.toString()).append("',\n").append("    setup: function(ed){\n").append("      ed.on('init', function(e) {\n").append("        ").append(onInit.get(0).replace(".curry(", "(")).append(";\n").append("      });\n").append("      ed.on('change', function(e) {\n").append("        BTinyHelper.triggerOnChange('").append(domID).append("');\n").append("      });\n");
    if (config.isSendOnBlur()) {
        sb.append("      ed.on('blur', function(e) {\n").append("        o_ffXHREvent('").append(form.getFormName()).append("','").append(form.getDispatchFieldId()).append("','").append(teC.getFormDispatchId()).append("','").append(form.getEventFieldId()).append("', 2, false, false, false, 'cmd','saveinlinedtiny','").append(domID).append("',ed.getContent());\n").append("      });\n");
    }
    sb.append("    },\n").append(configurations).append("  });\n").append("/* ]]> */</script>\n");
}
Also used : Form(org.olat.core.gui.components.form.flexible.impl.Form) StringOutput(org.olat.core.gui.render.StringOutput)

Example 20 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project openolat by klemens.

the class MultipleSelectionElementImpl method evalFormRequest.

@Override
public void evalFormRequest(UserRequest ureq) {
    Form form = getRootForm();
    if (isAjaxOnly()) {
        String dispatchuri = form.getRequestParameter("dispatchuri");
        if (dispatchuri != null && dispatchuri.equals(component.getFormDispatchId())) {
            String key = form.getRequestParameter("achkbox");
            String checked = form.getRequestParameter("checked");
            if ("true".equals(checked)) {
                selected.add(key);
            } else if ("false".equals(checked)) {
                selected.remove(key);
            }
        }
    } else if (isEnabled()) {
        // which one was selected?
        // selection change?
        // mark corresponding comps as dirty
        String[] reqVals = form.getRequestParameterValues(getName());
        if (reqVals == null) {
            // selection box?
            reqVals = form.getRequestParameterValues(getName() + "_SELBOX");
        }
        // 
        selected = new HashSet<>();
        if (reqVals != null) {
            for (int i = 0; i < reqVals.length; i++) {
                selected.add(reqVals[i]);
            }
        }
    }
    String dispatchuri = form.getRequestParameter("dispatchuri");
    if (dispatchuri != null && dispatchuri.equals(component.getFormDispatchId())) {
        formRequestEval = new ConsumableBoolean(true);
    }
}
Also used : ConsumableBoolean(org.olat.core.util.ConsumableBoolean) Form(org.olat.core.gui.components.form.flexible.impl.Form) HashSet(java.util.HashSet)

Aggregations

Form (org.olat.core.gui.components.form.flexible.impl.Form)64 NameValuePair (org.olat.core.gui.components.form.flexible.impl.NameValuePair)42 AssessmentRenderFunctions.contentAsString (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)10 Component (org.olat.core.gui.components.Component)4 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)4 FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)4 StringOutput (org.olat.core.gui.render.StringOutput)4 TestSessionController (uk.ac.ed.ph.jqtiplus.running.TestSessionController)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 HashSet (java.util.HashSet)2 Matcher (java.util.regex.Matcher)2 SortKey (org.olat.core.commons.persistence.SortKey)2 TextBoxListElementComponent (org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementComponent)2 TextBoxListElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementImpl)2 TextModeState (org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextElementImpl.TextModeState)2 FlexiTableElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableElementImpl)2 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)2 AJAXFlags (org.olat.core.gui.control.winmgr.AJAXFlags)2