Search in sources :

Example 11 with RichTextElement

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

the class EdubaseBookSectionListController method wrapBookSection.

private void wrapBookSection(BookSection bookSection) {
    String bookSectionId = "" + countBookSections++;
    // remove
    FormLink removeLink = uifactory.addFormLink(RM_PREFIX.concat(bookSectionId), RM_PREFIX, "", null, bookSectionsCont, Link.NONTRANSLATED);
    removeLink.setIconLeftCSS("o_icon o_icon-lg o_icon_delete");
    bookSectionsCont.add(removeLink);
    bookSectionsCont.add(RM_PREFIX.concat(bookSectionId), removeLink);
    // add
    FormLink addLink = uifactory.addFormLink(ADD_PREFIX.concat(bookSectionId), ADD_PREFIX, "", null, bookSectionsCont, Link.NONTRANSLATED);
    addLink.setIconLeftCSS("o_icon o_icon-lg o_icon_add");
    bookSectionsCont.add(addLink);
    bookSectionsCont.add(ADD_PREFIX.concat(bookSectionId), addLink);
    // up
    FormLink upLink = uifactory.addFormLink(UP_PREFIX.concat(bookSectionId), UP_PREFIX, "", null, bookSectionsCont, Link.NONTRANSLATED);
    upLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_up");
    bookSectionsCont.add(upLink);
    bookSectionsCont.add(UP_PREFIX.concat(bookSectionId), upLink);
    // down
    FormLink downLink = uifactory.addFormLink(DOWN_PREFIX.concat(bookSectionId), DOWN_PREFIX, "", null, bookSectionsCont, Link.NONTRANSLATED);
    downLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_down");
    bookSectionsCont.add(downLink);
    bookSectionsCont.add(DOWN_PREFIX.concat(bookSectionId), downLink);
    // Details button
    FormLink detailsLinkEl = uifactory.addFormLink(DETAILS_PREFIX.concat(bookSectionId), DETAILS_PREFIX, "edubase.book.section.details", null, bookSectionsCont, Link.BUTTON);
    detailsLinkEl.setElementCssClass("o_edubase_bs_details");
    bookSectionsCont.add(detailsLinkEl);
    bookSectionsCont.add(DETAILS_PREFIX.concat(bookSectionId), detailsLinkEl);
    // book id
    TextElement bookIdEl = uifactory.addTextElement(BOOK_ID_PREFIX.concat(bookSectionId), "edubase.book.section.id", 128, bookSection.getBookId(), bookSectionsCont);
    bookIdEl.setMandatory(true);
    bookIdEl.setHelpTextKey("edubase.book.section.id.help", null);
    // page from
    String pageFrom = bookSection.getPageFrom() != null ? Integer.toString(bookSection.getPageFrom()) : null;
    TextElement pageFromEl = uifactory.addTextElement(PAGE_FROM_PREFIX.concat(bookSectionId), "edubase.book.section.page.from", 6, pageFrom, bookSectionsCont);
    // page to
    String pageTo = bookSection.getPageTo() != null ? Integer.toString(bookSection.getPageTo()) : null;
    TextElement pageToEl = uifactory.addTextElement(PAGE_TO_PREFIX.concat(bookSectionId), "edubase.book.section.page.to", 6, pageTo, bookSectionsCont);
    // title
    TextElement titleEl = uifactory.addTextElement("title".concat(bookSectionId), "edubase.book.section.title", 128, bookSection.getTitle(), bookSectionsCont);
    // description
    RichTextElement descriptionEl = uifactory.addRichTextElementForStringDataMinimalistic(DESC_PREFIX.concat(bookSectionId), "edubase.book.section.description", bookSection.getDescription(), 4, -1, bookSectionsCont, getWindowControl());
    boolean discriptionEnabled = config.getBooleanSafe(EdubaseCourseNode.CONFIG_DESCRIPTION_ENABLED);
    descriptionEl.setVisible(discriptionEnabled);
    bookSectionWrappers.add(new BookSectionWrapper(bookSection, removeLink, addLink, upLink, downLink, detailsLinkEl, bookIdEl, pageFromEl, pageToEl, titleEl, descriptionEl));
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 12 with RichTextElement

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

the class FormUIFactory method addRichTextElementForFileData.

/**
 * Add a rich text formattable element that offers complex formatting
 * functionality and loads the data from the given file path. 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 baseContainer
 *            The VFS container where to load resources from (images etc) or
 *            NULL to not allow embedding of media files at all
 * @param relFilePath
 *            The path to the file relative to the baseContainer
 * @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
 * @return The richt text element instance
 */
public RichTextElement addRichTextElementForFileData(String name, final String i18nLabel, String initialValue, final int rows, int cols, VFSContainer baseContainer, String relFilePath, CustomLinkTreeModel customLinkTreeModel, FormItemContainer formLayout, UserSession usess, WindowControl wControl) {
    // Create richt text element with bare bone configuration
    RichTextElement rte = new RichTextElementImpl(name, initialValue, rows, cols, formLayout.getRootForm(), formLayout.getTranslator().getLocale());
    setLabelIfNotNull(i18nLabel, rte);
    // Now configure editor
    rte.getEditorConfiguration().setConfigProfileFileEditor(usess, wControl.getWindowBackOffice().getWindow().getGuiTheme(), baseContainer, relFilePath, 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)

Example 13 with RichTextElement

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

the class FormUIFactory method addRichTextElementForStringDataCompact.

public RichTextElement addRichTextElementForStringDataCompact(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().setConfigProfileFormCompactEditor(usess, theme, baseContainer);
    // 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 14 with RichTextElement

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

the class AssessmentSectionOptionsEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_assessment_section_options");
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_section");
    if (!editable) {
        setFormWarning("warning.alien.assessment.test");
    }
    String title = section.getTitle();
    titleEl = uifactory.addTextElement("title", "form.metadata.title", 255, title, formLayout);
    titleEl.setEnabled(editable);
    titleEl.setMandatory(true);
    String relativePath = rootDirectory.toPath().relativize(testFile.toPath().getParent()).toString();
    VFSContainer itemContainer = (VFSContainer) rootContainer.resolve(relativePath);
    if (section.getRubricBlocks().isEmpty()) {
        RichTextElement rubricEl = uifactory.addRichTextElementForQTI21("rubric" + counter++, "form.imd.rubric", "", 12, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
        rubricEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
        rubricEl.setEnabled(editable);
        rubricEls.add(rubricEl);
    } else {
        for (RubricBlock rubricBlock : section.getRubricBlocks()) {
            String rubric = htmlBuilder.blocksString(rubricBlock.getBlocks());
            RichTextElement rubricEl = uifactory.addRichTextElementForQTI21("rubric" + counter++, "form.imd.rubric", rubric, 12, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
            rubricEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
            rubricEl.setEnabled(editable);
            rubricEl.setUserObject(rubricBlock);
            rubricEls.add(rubricEl);
        }
    }
    // shuffle
    String[] yesnoValues = new String[] { translate("yes"), translate("no") };
    shuffleEl = uifactory.addRadiosHorizontal("shuffle", "form.section.shuffle", formLayout, yesnoKeys, yesnoValues);
    if (section.getOrdering() != null && section.getOrdering().getShuffle()) {
        shuffleEl.select("y", true);
    } else {
        shuffleEl.select("n", true);
    }
    shuffleEl.setEnabled(!restrictedEdit && editable);
    int numOfItems = getNumOfQuestions(section);
    String[] theKeys = new String[numOfItems + 1];
    String[] theValues = new String[numOfItems + 1];
    theKeys[0] = "0";
    theValues[0] = translate("form.section.selection_all");
    for (int i = 0; i < numOfItems; i++) {
        theKeys[i + 1] = Integer.toString(i + 1);
        theValues[i + 1] = Integer.toString(i + 1);
    }
    randomSelectedEl = uifactory.addDropdownSingleselect("form.section.selection_pre", formLayout, theKeys, theValues, null);
    randomSelectedEl.setHelpText(translate("form.section.selection_pre.hover"));
    randomSelectedEl.setEnabled(!restrictedEdit && editable);
    int currentNum = section.getSelection() != null ? section.getSelection().getSelect() : 0;
    if (currentNum <= numOfItems) {
        randomSelectedEl.select(theKeys[currentNum], true);
    } else if (currentNum > numOfItems) {
        randomSelectedEl.select(theKeys[numOfItems], true);
    } else {
        randomSelectedEl.select(theKeys[0], true);
    }
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("butons", getTranslator());
    formLayout.add(buttonsCont);
    FormSubmit submit = uifactory.addFormSubmitButton("save", "save", buttonsCont);
    submit.setEnabled(editable);
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)

Example 15 with RichTextElement

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

the class FeedbackFormController method initForm.

/**
 * @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
 */
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("fieldset.legend.feedback");
    setFormContextHelp("Test and Questionnaire Editor in Detail#details_testeditor_feedback");
    FormLayoutContainer switchLayout = FormLayoutContainer.createDefaultFormLayout("switchLayout", getTranslator());
    overallFeedbackLayout = FormLayoutContainer.createDefaultFormLayout("overallFeedbackLayout", getTranslator());
    responseLevelHintsLayout = FormLayoutContainer.createCustomFormLayout("responseLevelHintsLayout", getTranslator(), Util.getPackageVelocityRoot(this.getClass()) + "/response_level_feedback.html");
    // add the layouts to the custom layout
    formLayout.add(switchLayout);
    formLayout.add(overallFeedbackLayout);
    formLayout.add(responseLevelHintsLayout);
    String[] yesNoKeys, yesNoValues;
    yesNoKeys = new String[] { YES, NO };
    yesNoValues = new String[] { translate(YES), translate(NO) };
    feedbackSwitch = uifactory.addRadiosHorizontal("feedbackswitch", switchLayout, yesNoKeys, yesNoValues);
    feedbackSwitch.addActionListener(FormEvent.ONCLICK);
    if (control.isFeedback()) {
        feedbackSwitch.select(yesNoKeys[0], true);
    } else {
        // defaults to 'not showing feedback'
        feedbackSwitch.select(yesNoKeys[1], true);
    }
    responseLevelHintsLayout.contextPut("mediaBaseUrl", mediaBaseUrl);
    masteryMat = QTIEditHelper.getFeedbackMasteryMaterial(item);
    masteryMat = masteryMat == null ? new Material() : masteryMat;
    failureMat = QTIEditHelper.getFeedbackFailMaterial(item);
    failureMat = failureMat == null ? new Material() : failureMat;
    VFSContainer baseContainer = qtiPackage.getBaseDir();
    // Mastery Layout
    FormLayoutContainer masteryEditLayout = FormLayoutContainer.createCustomFormLayout("masteryEditLayout", getTranslator(), Util.getPackageVelocityRoot(this.getClass()) + "/rich_text_and_edit_link.html");
    masteryEditLayout.setLabel("item_feedback_mastery", null);
    overallFeedbackLayout.add(masteryEditLayout);
    RichTextElement masteryFeedback = uifactory.addRichTextElementForStringData("richTextElement", "item_feedback_mastery", masteryMat.renderAsHtml(mediaBaseUrl), 4, -1, true, baseContainer, null, masteryEditLayout, ureq.getUserSession(), getWindowControl());
    masteryFeedback.getEditorConfiguration().setFigCaption(false);
    FormLink editLink = uifactory.addFormLink("editLink", masteryEditLayout, Link.NONTRANSLATED + Link.LINK_CUSTOM_CSS);
    editLink.getComponent().setCustomDisplayText(" ");
    editLink.getComponent().setIconLeftCSS("o_icon o_icon_edit o_icon-lg qti_edit_link");
    registerFeedbackElement(masteryMat, masteryFeedback, editLink);
    // One Failure Layout
    FormLayoutContainer failureEditLayout = FormLayoutContainer.createCustomFormLayout("failureEditLayout", getTranslator(), Util.getPackageVelocityRoot(this.getClass()) + "/rich_text_and_edit_link.html");
    failureEditLayout.setLabel("item_feedback_fail", null);
    overallFeedbackLayout.add(failureEditLayout);
    RichTextElement failureFeedback = uifactory.addRichTextElementForStringData("richTextElement", "item_feedback_fail", failureMat.renderAsHtml(mediaBaseUrl), 4, -1, true, baseContainer, null, failureEditLayout, ureq.getUserSession(), getWindowControl());
    failureFeedback.getEditorConfiguration().setFigCaption(false);
    failureFeedback.setLabel("item_feedback_fail", null);
    FormLink failureLink = uifactory.addFormLink("editLink", failureEditLayout, Link.NONTRANSLATED + Link.LINK_CUSTOM_CSS);
    failureLink.getComponent().setCustomDisplayText("");
    failureLink.getComponent().setIconLeftCSS("o_icon o_icon_edit o_icon-lg");
    registerFeedbackElement(failureMat, failureFeedback, failureLink);
    // Feedback for each response when single or multiple choice question
    List<Material> responses = new ArrayList<Material>();
    boolean hasResponseLevelHints = false;
    if (item.getQuestion().getType() <= Question.TYPE_MC) {
        int i = 1;
        for (Object obj : item.getQuestion().getResponses()) {
            ChoiceResponse response = (ChoiceResponse) obj;
            // response-level feedback
            Material responseFeedbackMat = QTIEditHelper.getFeedbackOlatRespMaterial(item, response.getIdent());
            responseFeedbackMat = responseFeedbackMat == null ? new Material() : responseFeedbackMat;
            identities.put(responseFeedbackMat, response.getIdent());
            RichTextElement responseHintText = uifactory.addRichTextElementForStringData("feedback_" + i, null, responseFeedbackMat.renderAsHtml(mediaBaseUrl), 4, -1, true, baseContainer, null, responseLevelHintsLayout, ureq.getUserSession(), getWindowControl());
            responseHintText.getEditorConfiguration().setFigCaption(false);
            FormLink link = uifactory.addFormLink("link_" + i, responseLevelHintsLayout, Link.NONTRANSLATED + Link.LINK_CUSTOM_CSS);
            link.getComponent().setCustomDisplayText(" ");
            link.getComponent().setIconLeftCSS("o_icon o_icon_edit o_icon-lg");
            registerFeedbackElement(responseFeedbackMat, responseHintText, link);
            // get response for displaying
            Material responseMat = response.getContent();
            responses.add(responseMat);
            i++;
        }
        // If 'i' is strictly greater than the initial value, there's at least one
        // response.
        hasResponseLevelHints = i > 1;
    }
    flc.contextPut("hasResponseLevelHints", hasResponseLevelHints);
    responseLevelHintsLayout.contextPut("responses", responses);
    showHideFeedbackFields();
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Material(org.olat.ims.qti.editor.beecom.objects.Material) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) ChoiceResponse(org.olat.ims.qti.editor.beecom.objects.ChoiceResponse)

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