Search in sources :

Example 26 with RichTextElement

use of org.olat.core.gui.components.form.flexible.elements.RichTextElement in project openolat by klemens.

the class FormUIFactory method addRichTextElementForStringData.

/**
 * Add a rich text formattable element that offers simple formatting
 * functionality and loads the data form the given string value. Use
 * item.getEditorConfiguration() to add more editor features if you need
 * them
 *
 * @param name
 *            Name of the form item
 * @param i18nLabel
 *            The i18n key of the label or NULL when no label is used
 * @param initialValue
 *            The initial value or NULL if no initial value is available
 * @param rows
 *            The number of lines the editor should offer. Use -1 to
 *            indicate no specific height
 * @param cols
 *            The number of characters width the editor should offer. Use -1
 *            to indicate no specific width
 * @param externalToolbar
 *            true: use an external toolbar that is only visible when the
 *            user clicks into the text area; false: use the static toolbar
 * @param fullProfile
 *            false: load only the necessary plugins; true: load all plugins
 *            from the full profile
 * @param baseContainer
 *            The VFS container where to load resources from (images etc) or
 *            NULL to not allow embedding of media files at all
 * @param formLayout
 *            The form item container where to add the richt text element
 * @param customLinkTreeModel A custom link tree model or NULL not not use a
 *          custom model
 * @param formLayout The form item container where to add the rich
 *          text element
 * @param usess The user session that dispatches the images
 * @param wControl the current window controller
 * @param wControl
 *            the current window controller
 * @return The rich text element instance
 */
public RichTextElement addRichTextElementForStringData(String name, String i18nLabel, String initialHTMLValue, int rows, int cols, boolean fullProfile, VFSContainer baseContainer, CustomLinkTreeModel customLinkTreeModel, FormItemContainer formLayout, UserSession usess, WindowControl wControl) {
    // Create richt text element with bare bone configuration
    WindowBackOffice backoffice = wControl.getWindowBackOffice();
    RichTextElement rte = new RichTextElementImpl(name, initialHTMLValue, rows, cols, formLayout.getRootForm(), formLayout.getTranslator().getLocale());
    setLabelIfNotNull(i18nLabel, rte);
    // Now configure editor
    Theme theme = backoffice.getWindow().getGuiTheme();
    rte.getEditorConfiguration().setConfigProfileFormEditor(fullProfile, usess, theme, baseContainer, customLinkTreeModel);
    // Add to form and finish
    formLayout.add(rte);
    return rte;
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) RichTextElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextElementImpl) WindowBackOffice(org.olat.core.gui.control.WindowBackOffice) Theme(org.olat.core.gui.themes.Theme)

Example 27 with RichTextElement

use of org.olat.core.gui.components.form.flexible.elements.RichTextElement in project openolat by klemens.

the class FormUIFactory method addRichTextElementForQTI21Match.

public RichTextElement addRichTextElementForQTI21Match(String name, String i18nLabel, String initialHTMLValue, int rows, int cols, VFSContainer baseContainer, FormItemContainer formLayout, UserSession usess, WindowControl wControl) {
    // Create rich text element with bare bone configuration
    RichTextElement rte = new RichTextElementImpl(name, initialHTMLValue, rows, cols, formLayout.getRootForm(), formLayout.getTranslator().getLocale());
    setLabelIfNotNull(i18nLabel, rte);
    // Now configure editor
    Theme theme = wControl.getWindowBackOffice().getWindow().getGuiTheme();
    rte.getEditorConfiguration().setConfigProfileFormVeryMinimalisticConfigEditor(usess, theme, baseContainer);
    rte.getEditorConfiguration().setInvalidElements(RichTextConfiguration.INVALID_ELEMENTS_FORM_FULL_VALUE_UNSAVE_WITH_SCRIPT);
    rte.getEditorConfiguration().setExtendedValidElements("script[src|type|defer]");
    rte.getEditorConfiguration().disableTinyMedia();
    rte.getEditorConfiguration().setFilenameUriValidation(true);
    rte.getEditorConfiguration().setFigCaption(false);
    // Add to form and finish
    formLayout.add(rte);
    return rte;
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) RichTextElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextElementImpl) Theme(org.olat.core.gui.themes.Theme)

Example 28 with RichTextElement

use of org.olat.core.gui.components.form.flexible.elements.RichTextElement in project openolat by klemens.

the class MatchEditorController method wrapAnswer.

private void wrapAnswer(UserRequest ureq, SimpleAssociableChoice choice, List<MatchWrapper> wrappers) {
    List<FlowStatic> choiceFlow = choice.getFlowStatics();
    String choiceContent = itemBuilder.getHtmlHelper().flowStaticString(choiceFlow);
    String choiceId = "answer" + count++;
    RichTextElement choiceEl = uifactory.addRichTextElementForQTI21Match(choiceId, "form.imd.answer", choiceContent, 4, -1, itemContainer, answersCont, ureq.getUserSession(), getWindowControl());
    choiceEl.setUserObject(choice);
    choiceEl.setEnabled(!readOnly);
    choiceEl.setVisible(!readOnly);
    answersCont.add("choiceId", choiceEl);
    String choiceRoId = "answerro" + count++;
    FlowFormItem choiceReadOnlyEl = new FlowFormItem(choiceRoId, itemFile);
    choiceReadOnlyEl.setFlowStatics(choiceFlow);
    choiceReadOnlyEl.setMapperUri(mapperUri);
    answersCont.add(choiceRoId, choiceReadOnlyEl);
    FormLink deleteButton = uifactory.addFormLink("del_" + (count++), "delete", "delete", null, answersCont, Link.NONTRANSLATED);
    deleteButton.setIconLeftCSS("o_icon o_icon_delete_item");
    deleteButton.setVisible(!restrictedEdit && !readOnly);
    deleteButton.setI18nKey("");
    MatchWrapper wrapper = new MatchWrapper(choice, choiceEl, choiceReadOnlyEl, deleteButton);
    deleteButton.setUserObject(wrapper);
    wrappers.add(wrapper);
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 29 with RichTextElement

use of org.olat.core.gui.components.form.flexible.elements.RichTextElement in project openolat by klemens.

the class MultipleChoiceEditorController method wrapAnswer.

private void wrapAnswer(UserRequest ureq, SimpleChoice choice) {
    List<FlowStatic> choiceFlow = choice.getFlowStatics();
    String choiceContent = itemBuilder.getHtmlHelper().flowStaticString(choice.getFlowStatics());
    String choiceId = "answer" + count++;
    RichTextElement choiceEl = uifactory.addRichTextElementForQTI21(choiceId, "form.imd.answer", choiceContent, 8, -1, itemContainer, answersCont, ureq.getUserSession(), getWindowControl());
    choiceEl.setEnabled(!readOnly);
    choiceEl.setVisible(!readOnly);
    choiceEl.getEditorConfiguration().setSimplestTextModeAllowed(TextMode.oneLine);
    choiceEl.setUserObject(choice);
    answersCont.add("choiceId", choiceEl);
    String choiceRoId = "answerro" + count++;
    FlowFormItem choiceReadOnlyEl = new FlowFormItem(choiceRoId, itemFile);
    choiceReadOnlyEl.setFlowStatics(choiceFlow);
    choiceReadOnlyEl.setMapperUri(mapperUri);
    answersCont.add(choiceRoId, choiceReadOnlyEl);
    FormLink removeLink = uifactory.addFormLink("rm-".concat(choiceId), "rm", "", null, answersCont, Link.NONTRANSLATED);
    removeLink.setIconLeftCSS("o_icon o_icon-lg o_icon_delete");
    removeLink.setEnabled(!restrictedEdit && !readOnly);
    answersCont.add(removeLink);
    answersCont.add("rm-".concat(choiceId), removeLink);
    FormLink addLink = uifactory.addFormLink("add-".concat(choiceId), "add", "", null, answersCont, Link.NONTRANSLATED);
    addLink.setIconLeftCSS("o_icon o_icon-lg o_icon_add");
    addLink.setEnabled(!restrictedEdit && !readOnly);
    answersCont.add(addLink);
    answersCont.add("add-".concat(choiceId), addLink);
    FormLink upLink = uifactory.addFormLink("up-".concat(choiceId), "up", "", null, answersCont, Link.NONTRANSLATED);
    upLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_up");
    upLink.setEnabled(!restrictedEdit && !readOnly);
    answersCont.add(upLink);
    answersCont.add("up-".concat(choiceId), upLink);
    FormLink downLink = uifactory.addFormLink("down-".concat(choiceId), "down", "", null, answersCont, Link.NONTRANSLATED);
    downLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_down");
    downLink.setEnabled(!restrictedEdit && !readOnly);
    answersCont.add(downLink);
    answersCont.add("down-".concat(choiceId), downLink);
    choiceWrappers.add(new SimpleChoiceWrapper(choice, choiceEl, choiceReadOnlyEl, removeLink, addLink, upLink, downLink));
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 30 with RichTextElement

use of org.olat.core.gui.components.form.flexible.elements.RichTextElement in project openolat by klemens.

the class AssessmentSectionOptionsEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    section.setTitle(titleEl.getValue());
    // rubrics
    List<RubricBlock> rubricBlocks = new ArrayList<>();
    for (RichTextElement rubricEl : rubricEls) {
        String rubric = rubricEl.getRawValue();
        if (htmlBuilder.containsSomething(rubric)) {
            RubricBlock rubricBlock = (RubricBlock) rubricEl.getUserObject();
            if (rubricBlock == null) {
                rubricBlock = new RubricBlock(section);
                rubricBlock.setViews(Collections.singletonList(View.CANDIDATE));
            }
            rubricBlock.getBlocks().clear();
            htmlBuilder.appendHtml(rubricBlock, rubric);
            rubricBlocks.add(rubricBlock);
        }
    }
    section.getRubricBlocks().clear();
    section.getRubricBlocks().addAll(rubricBlocks);
    // shuffle
    boolean shuffle = (shuffleEl.isOneSelected() && shuffleEl.isSelected(0));
    if (shuffle) {
        if (section.getOrdering() == null) {
            section.setOrdering(new Ordering(section));
        }
        section.getOrdering().setShuffle(shuffle);
    } else {
        section.setOrdering(null);
    }
    // number of selected questions
    Integer randomSelection = null;
    if (StringHelper.containsNonWhitespace(randomSelectedEl.getSelectedKey())) {
        randomSelection = new Integer(randomSelectedEl.getSelectedKey());
    }
    if (randomSelection == null || randomSelection.intValue() < 1) {
        section.setSelection(null);
    } else {
        if (section.getSelection() == null) {
            section.setSelection(new Selection(section));
        }
        section.getSelection().setSelect(randomSelection);
    }
    fireEvent(ureq, new AssessmentSectionEvent(AssessmentSectionEvent.ASSESSMENT_SECTION_CHANGED, section));
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) Selection(uk.ac.ed.ph.jqtiplus.node.test.Selection) ArrayList(java.util.ArrayList) Ordering(uk.ac.ed.ph.jqtiplus.node.test.Ordering) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) AssessmentSectionEvent(org.olat.ims.qti21.ui.editor.events.AssessmentSectionEvent)

Aggregations

RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)30 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)14 RichTextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextElementImpl)12 FlowFormItem (org.olat.ims.qti21.ui.components.FlowFormItem)10 FlowStatic (uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic)10 Theme (org.olat.core.gui.themes.Theme)8 ArrayList (java.util.ArrayList)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)4 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)2 FormSubmit (org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit)2 WindowBackOffice (org.olat.core.gui.control.WindowBackOffice)2 ChoiceResponse (org.olat.ims.qti.editor.beecom.objects.ChoiceResponse)2 Material (org.olat.ims.qti.editor.beecom.objects.Material)2 AssessmentSectionEvent (org.olat.ims.qti21.ui.editor.events.AssessmentSectionEvent)2 Ordering (uk.ac.ed.ph.jqtiplus.node.test.Ordering)2 Selection (uk.ac.ed.ph.jqtiplus.node.test.Selection)2