Search in sources :

Example 16 with FormSubmit

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

the class BusinessGroupFormController 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)
 */
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // Create the business group name input text element
    if (bulkMode) {
        businessGroupName = uifactory.addTextElement("create.form.title.bgnames", "create.form.title.bgnames", 10 * BusinessGroup.MAX_GROUP_NAME_LENGTH, "", formLayout);
        businessGroupName.setExampleKey("create.form.message.example.group", null);
    } else {
        businessGroupName = uifactory.addTextElement("create.form.title.bgname", "create.form.title.bgname", BusinessGroup.MAX_GROUP_NAME_LENGTH, "", formLayout);
        businessGroupName.setNotLongerThanCheck(BusinessGroup.MAX_GROUP_NAME_LENGTH, "create.form.error.nameTooLong");
        businessGroupName.setRegexMatchCheck(BusinessGroup.VALID_GROUPNAME_REGEXP, "create.form.error.illegalName");
    }
    businessGroupName.setElementCssClass("o_sel_group_edit_title");
    businessGroupName.setMandatory(true);
    businessGroupName.setEnabled(!BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.title));
    formLayout.setElementCssClass("o_sel_group_edit_group_form");
    // Create the business group description input rich text element
    businessGroupDescription = uifactory.addRichTextElementForStringDataMinimalistic("create.form.title.description", "create.form.title.description", "", 10, -1, formLayout, getWindowControl());
    businessGroupDescription.setEnabled(!BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.description));
    if (businessGroup != null && !bulkMode) {
        // link to group direct jump in business path
        BusinessControlFactory bcf = BusinessControlFactory.getInstance();
        List<ContextEntry> entries = bcf.createCEListFromString("[BusinessGroup:" + businessGroup.getKey() + "]");
        String url = bcf.getAsURIString(entries, true);
        url = "<span class='o_copy_code o_nowrap'><input type='text' value='" + url + "' onclick='this.select()'/></span>";
        StaticTextElement urlEl = uifactory.addStaticTextElement("create.form.businesspath", url, formLayout);
        urlEl.setElementCssClass("o_sel_group_url");
        // link to group visiting card
        bcf = BusinessControlFactory.getInstance();
        entries = bcf.createCEListFromString("[GroupCard:" + businessGroup.getKey() + "]");
        url = "<span class='o_copy_code o_nowrap'><input type='text' value='" + bcf.getAsURIString(entries, true) + "' onclick='this.select()'/></span>";
        StaticTextElement cardEl = uifactory.addStaticTextElement("create.form.groupcard", url, formLayout);
        cardEl.setElementCssClass("o_sel_group_card_url");
    }
    uifactory.addSpacerElement("myspacer", formLayout, true);
    // Minimum members input
    businessGroupMinimumMembers = uifactory.addTextElement("create.form.title.min", "create.form.title.min", 5, "", formLayout);
    businessGroupMinimumMembers.setDisplaySize(6);
    // currently the minimum feature is not enabled
    businessGroupMinimumMembers.setVisible(false);
    businessGroupMinimumMembers.setElementCssClass("o_sel_group_edit_min_members");
    // Maximum members input
    businessGroupMaximumMembers = uifactory.addTextElement("create.form.title.max", "create.form.title.max", 5, "", formLayout);
    businessGroupMaximumMembers.setDisplaySize(6);
    businessGroupMaximumMembers.setElementCssClass("o_sel_group_edit_max_members");
    // Checkboxes
    enableWaitingList = uifactory.addCheckboxesHorizontal("create.form.enableWaitinglist", null, formLayout, waitingListKeys, waitingListValues);
    enableWaitingList.setElementCssClass("o_sel_group_edit_waiting_list");
    enableAutoCloseRanks = uifactory.addCheckboxesHorizontal("create.form.enableAutoCloseRanks", null, formLayout, autoCloseKeys, autoCloseValues);
    enableAutoCloseRanks.setElementCssClass("o_sel_group_edit_auto_close_ranks");
    // Enable only if specification of min and max members is possible
    // currently the minimum feature is not enabled
    businessGroupMinimumMembers.setVisible(false);
    businessGroupMaximumMembers.setVisible(true);
    enableWaitingList.setVisible(true);
    enableAutoCloseRanks.setVisible(true);
    boolean managedSettings = BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.settings);
    businessGroupMinimumMembers.setEnabled(!managedSettings);
    businessGroupMaximumMembers.setEnabled(!managedSettings);
    enableWaitingList.setEnabled(!managedSettings);
    enableAutoCloseRanks.setEnabled(!managedSettings);
    if ((businessGroup != null) && (!bulkMode)) {
        businessGroupName.setValue(businessGroup.getName());
        businessGroupDescription.setValue(businessGroup.getDescription());
        Integer minimumMembers = businessGroup.getMinParticipants();
        Integer maximumMembers = businessGroup.getMaxParticipants();
        businessGroupMinimumMembers.setValue(minimumMembers == null || minimumMembers.intValue() <= 0 ? "" : minimumMembers.toString());
        businessGroupMaximumMembers.setValue(maximumMembers == null || maximumMembers.intValue() < 0 ? "" : maximumMembers.toString());
        if (businessGroup.getWaitingListEnabled() != null) {
            enableWaitingList.select("create.form.enableWaitinglist", businessGroup.getWaitingListEnabled());
        }
        if (businessGroup.getAutoCloseRanksEnabled() != null) {
            enableAutoCloseRanks.select("create.form.enableAutoCloseRanks", businessGroup.getAutoCloseRanksEnabled());
        }
    }
    if (!embbeded) {
        // Create submit and cancel buttons
        final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
        formLayout.add(buttonLayout);
        FormSubmit submit = uifactory.addFormSubmitButton("finish", buttonLayout);
        submit.setEnabled(!BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.details));
        uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
    }
    if ((businessGroup != null) && (!bulkMode)) {
        // managed group information
        boolean managed = StringHelper.containsNonWhitespace(businessGroup.getExternalId()) || businessGroup.getManagedFlags().length > 0;
        if (managed) {
            uifactory.addSpacerElement("managedspacer", formLayout, false);
            String extId = businessGroup.getExternalId() == null ? "" : businessGroup.getExternalId();
            StaticTextElement externalIdEl = uifactory.addStaticTextElement("create.form.externalid", extId, formLayout);
            externalIdEl.setElementCssClass("o_sel_group_external_id");
            FormLayoutContainer flagsFlc = FormLayoutContainer.createHorizontalFormLayout("flc_flags", getTranslator());
            flagsFlc.setLabel("create.form.managedflags", null);
            formLayout.add(flagsFlc);
            String flags = businessGroup.getManagedFlagsString() == null ? "" : businessGroup.getManagedFlagsString().trim();
            String flagsFormatted = null;
            if (flags.length() > 0) {
                // use translator from REST admin package to import managed flags context help strings
                Translator managedTrans = Util.createPackageTranslator(RestapiAdminController.class, ureq.getLocale());
                StringBuffer flagList = new StringBuffer();
                flagList.append("<p class=\"o_important\">");
                flagList.append(translate("create.form.managedflags.intro"));
                flagList.append("</div>");
                flagList.append("<ul>");
                for (String flag : flags.split(",")) {
                    flagList.append("<li>");
                    flagList.append(managedTrans.translate("managed.flags.group." + flag));
                    flagList.append("</li>");
                }
                flagsFormatted = flagList.toString();
            } else {
                flagsFormatted = flags;
            }
            StaticTextElement flagsEl = uifactory.addStaticTextElement("create.form.managedflags", flagsFormatted, flagsFlc);
            flagsEl.showLabel(false);
            flagsEl.setElementCssClass("o_sel_group_managed_flags");
        }
    }
}
Also used : FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) Translator(org.olat.core.gui.translator.Translator) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 17 with FormSubmit

use of org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit 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 18 with FormSubmit

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

the class AssessmentTestOptionsEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_test");
    String title = assessmentTest.getTitle();
    titleEl = uifactory.addTextElement("title", "form.metadata.title", 255, title, formLayout);
    titleEl.setMandatory(true);
    titleEl.setEnabled(testBuilder.isEditable());
    // score
    String maxScore = testBuilder.getMaxScore() == null ? "" : AssessmentHelper.getRoundedScore(testBuilder.getMaxScore());
    maxScoreEl = uifactory.addTextElement("max.score", "max.score", 8, maxScore, formLayout);
    maxScoreEl.setEnabled(false);
    Double cutValue = testBuilder.getCutValue();
    String cutValueStr = cutValue == null ? "" : cutValue.toString();
    cutValueEl = uifactory.addTextElement("cut.value", "cut.value", 8, cutValueStr, formLayout);
    cutValueEl.setEnabled(!restrictedEdit && testBuilder.isEditable());
    TimeLimits timeLimits = assessmentTest.getTimeLimits();
    long maxInSeconds = -1;
    String timeMaxHour = "";
    String timeMaxMinute = "";
    if (timeLimits != null && timeLimits.getMaximum() != null && timeLimits.getMaximum().longValue() > 0) {
        maxInSeconds = timeLimits.getMaximum().longValue();
        timeMaxHour = Long.toString(maxInSeconds / 3600);
        timeMaxMinute = Long.toString((maxInSeconds % 3600) / 60);
    }
    maxTimeEl = uifactory.addCheckboxesVertical("time.limit.enable", "time.limit.max", formLayout, onKeys, onValues, 1);
    maxTimeEl.addActionListener(FormEvent.ONCHANGE);
    if (maxInSeconds > 0) {
        maxTimeEl.select(onKeys[0], true);
    }
    String page = velocity_root + "/max_time_limit.html";
    maxTimeCont = FormLayoutContainer.createCustomFormLayout("time.limit.cont", getTranslator(), page);
    maxTimeCont.setVisible(maxTimeEl.isAtLeastSelected(1));
    formLayout.add(maxTimeCont);
    timeMaxHour = timeMaxHour.equals("0") ? "" : timeMaxHour;
    maxTimeHourEl = uifactory.addTextElement("time.limit.hour", "time.limit.max", 4, timeMaxHour, maxTimeCont);
    maxTimeHourEl.setDomReplacementWrapperRequired(false);
    maxTimeHourEl.setDisplaySize(4);
    maxTimeHourEl.setEnabled(!restrictedEdit);
    maxTimeMinuteEl = uifactory.addTextElement("time.limit.minute", "time.limit.max", 4, timeMaxMinute, maxTimeCont);
    maxTimeMinuteEl.setDomReplacementWrapperRequired(false);
    maxTimeMinuteEl.setDisplaySize(4);
    maxTimeMinuteEl.setEnabled(!restrictedEdit);
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("butons", getTranslator());
    formLayout.add(buttonsCont);
    FormSubmit submit = uifactory.addFormSubmitButton("save", "save", buttonsCont);
    submit.setEnabled(testBuilder.isEditable());
}
Also used : FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) TimeLimits(uk.ac.ed.ph.jqtiplus.node.test.TimeLimits)

Example 19 with FormSubmit

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

the class DENEditForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    Boolean initialCancelEnrollEnabled = (Boolean) moduleConfig.get(ENCourseNode.CONF_CANCEL_ENROLL_ENABLED);
    enableCancelEnroll = uifactory.addCheckboxesHorizontal("enableCancelEnroll", "form.enableCancelEnroll", formLayout, new String[] { "ison" }, new String[] { "" });
    enableCancelEnroll.select("ison", initialCancelEnrollEnabled);
    subm = new FormSubmit("subm", "submit");
    formLayout.add(subm);
}
Also used : FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit)

Example 20 with FormSubmit

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

the class VCEditForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    editVC = FormLayoutContainer.createCustomFormLayout("titleLayout", getTranslator(), velocity_root + "/editForm.html");
    formLayout.add(editVC);
    // template chooser
    String[] keys = new String[templates.size() + 1];
    keys[0] = DefaultVCConfiguration.DEFAULT_TEMPLATE;
    String[] values = new String[templates.size() + 1];
    values[0] = "";
    int index = 1;
    for (String key : templates.keySet()) {
        keys[index] = key;
        values[index] = templates.get(key);
        index++;
    }
    boolean hasTemplates = templates.size() > 0;
    if (hasTemplates) {
        vcTemplate = uifactory.addDropdownSingleselect("vc.template.choose", "vc.template.choose.label", editVC, keys, values, null);
        String templateKey = config.getTemplateKey();
        vcTemplate.select(templateKey == null ? DefaultVCConfiguration.DEFAULT_TEMPLATE : templateKey, true);
    }
    editVC.contextPut("hasTemplates", hasTemplates);
    // meeting options
    boolean useDates = !dateList.isEmpty() | config.isUseMeetingDates();
    String[] accessKeys = new String[] { OPTION_DATES };
    String[] accessVals = new String[] { translate(OPTION_DATES) };
    multiSelectOptions = uifactory.addCheckboxesVertical("vc.options", "vc.options.label", editVC, accessKeys, accessVals, 1);
    multiSelectOptions.select(OPTION_DATES, useDates);
    multiSelectOptions.addActionListener(FormEvent.ONCHANGE);
    // create gui elements for all meetings
    editVC.contextPut("useDates", useDates);
    if (useDates)
        addDates();
    editVC.contextPut("dateList", dateList);
    editVC.contextPut("vcTitleInputList", vcTitleInputList);
    editVC.contextPut("vcDescriptionInputList", vcDescriptionInputList);
    editVC.contextPut("vcCalenderbeginInputList", vcCalenderbeginInputList);
    editVC.contextPut("vcDurationInputList", vcDurationInputList);
    editVC.contextPut("vcAddButtonList", vcAddButtonList);
    editVC.contextPut("vcDelButtonList", vcDelButtonList);
    submit = new FormSubmit("subm", "submit");
    formLayout.add(submit);
}
Also used : FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit)

Aggregations

FormSubmit (org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit)42 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)16 HashSet (java.util.HashSet)4 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)4 Submit (org.olat.core.gui.components.form.flexible.elements.Submit)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 Date (java.util.Date)2 HashMap (java.util.HashMap)2 FormItem (org.olat.core.gui.components.form.flexible.FormItem)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)2 Translator (org.olat.core.gui.translator.Translator)2 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)2 ContextEntry (org.olat.core.id.context.ContextEntry)2 Checkbox (org.olat.course.nodes.cl.model.Checkbox)2 DBCheck (org.olat.course.nodes.cl.model.DBCheck)2 DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)2 RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)2 TimeLimits (uk.ac.ed.ph.jqtiplus.node.test.TimeLimits)2