Search in sources :

Example 91 with FormLayoutContainer

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

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 92 with FormLayoutContainer

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

the class UnkownItemConversionConfirmationController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("warnings", report.getWarnings());
        layoutCont.contextPut("questionType", translate("new." + report.getType().name()));
    }
    if (report.getAlternatives().size() > 0) {
        String[] theKeys = new String[report.getAlternatives().size()];
        String[] theValues = new String[theKeys.length];
        for (int i = 0; i < report.getAlternatives().size(); i++) {
            QTI21QuestionType alternative = report.getAlternatives().get(i);
            theKeys[i] = alternative.name();
            theValues[i] = translate("new." + alternative.name());
        }
        alternativeEl = uifactory.addDropdownSingleselect("questions.alternative", formLayout, theKeys, theValues, null);
        alternativeEl.setDomReplacementWrapperRequired(false);
    }
    uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
    uifactory.addFormSubmitButton("convert", formLayout);
}
Also used : FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType)

Example 93 with FormLayoutContainer

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

the class FIBEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    titleEl = uifactory.addTextElement("title", "form.imd.title", -1, itemBuilder.getTitle(), formLayout);
    titleEl.setElementCssClass("o_sel_assessment_item_title");
    titleEl.setMandatory(true);
    titleEl.setEnabled(!readOnly);
    String relativePath = rootDirectory.toPath().relativize(itemFile.toPath().getParent()).toString();
    VFSContainer itemContainer = (VFSContainer) rootContainer.resolve(relativePath);
    String question = itemBuilder.getQuestion();
    textEl = uifactory.addRichTextElementForQTI21("desc", "form.imd.descr", question, 16, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
    textEl.addActionListener(FormEvent.ONCLICK);
    textEl.setElementCssClass("o_sel_assessment_item_fib_text");
    RichTextConfiguration richTextConfig = textEl.getEditorConfiguration();
    richTextConfig.setReadOnly(restrictedEdit || readOnly);
    boolean hasNumericals = itemBuilder.hasNumericalInputs();
    boolean hasTexts = itemBuilder.hasTextEntry();
    if (!hasNumericals && !hasTexts) {
        if (preferredType == QTI21QuestionType.numerical) {
            hasNumericals = true;
            hasTexts = false;
        } else if (preferredType == QTI21QuestionType.fib) {
            hasNumericals = false;
            hasTexts = true;
        } else {
            hasNumericals = true;
            hasTexts = true;
        }
    }
    if (hasNumericals) {
        setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_ni");
    } else {
        setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_fib");
    }
    richTextConfig.enableQTITools(hasTexts, hasNumericals, false);
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setElementCssClass("o_sel_fib_save");
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : RichTextConfiguration(org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextConfiguration) VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 94 with FormLayoutContainer

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

the class UserPropertyEditor method initForm.

@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String page = Util.getPackageVelocityRoot(this.getClass()) + "/user_prop.html";
    String id = Long.toString(CodeHelper.getRAMUniqueID());
    FormLayoutContainer userPropCont = FormLayoutContainer.createCustomFormLayout("user.prop.".concat(id), formLayout.getTranslator(), page);
    userPropCont.setRootForm(formLayout.getRootForm());
    formLayout.add(userPropCont);
    userPropCont.getFormItemComponent().contextPut("id", id);
    Translator trans = Util.createPackageTranslator(UserPropertyHandler.class, ureq.getLocale(), formLayout.getTranslator());
    int numOfProperties = userPropertyHandlers.size();
    String[] propKeys = new String[numOfProperties];
    String[] propValues = new String[numOfProperties];
    for (int i = 0; i < numOfProperties; i++) {
        UserPropertyHandler handler = userPropertyHandlers.get(i);
        propKeys[i] = handler.getName();
        propValues[i] = trans.translate(handler.i18nFormElementLabelKey());
    }
    String currentPropertyName = null;
    String currentPropertyValue = null;
    if (rule instanceof ReminderRuleImpl) {
        ReminderRuleImpl r = (ReminderRuleImpl) rule;
        currentPropertyName = r.getLeftOperand();
        currentPropertyValue = r.getRightOperand();
    }
    propEl = uifactory.addDropdownSingleselect("user.prop.".concat(id), null, userPropCont, propKeys, propValues, null);
    propEl.setDomReplacementWrapperRequired(false);
    if (currentPropertyName != null) {
        for (String propKey : propKeys) {
            if (currentPropertyName.equals(propKey)) {
                propEl.select(propKey, true);
            }
        }
    }
    valueEl = uifactory.addTextElement("user.value.".concat(id), null, 128, currentPropertyValue, userPropCont);
    valueEl.setDomReplacementWrapperRequired(false);
    return userPropCont;
}
Also used : Translator(org.olat.core.gui.translator.Translator) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 95 with FormLayoutContainer

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

the class EditTaxonomyCompetenceController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String fullName = userManager.getUserDisplayName(competence.getIdentity());
    uifactory.addStaticTextElement("taxonomy.competence.fullName", fullName, formLayout);
    TaxonomyCompetenceTypes competenceType = competence.getCompetenceType();
    String type = translate(competenceType.name());
    uifactory.addStaticTextElement("taxonomy.competence.type", type, formLayout);
    TaxonomyLevelManagedFlag marker = TaxonomyLevelManagedFlag.getCorrespondingFlag(competenceType);
    expirationEl = uifactory.addDateChooser("taxonomy.competence.expiration", competence.getExpiration(), formLayout);
    expirationEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(taxonomyLevel, marker));
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
    if (expirationEl.isEnabled()) {
        // save only if there is something to update
        uifactory.addFormSubmitButton("save", buttonsCont);
    }
}
Also used : FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) TaxonomyLevelManagedFlag(org.olat.modules.taxonomy.TaxonomyLevelManagedFlag)

Aggregations

FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)844 ArrayList (java.util.ArrayList)96 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)76 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)76 Date (java.util.Date)56 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)56 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)42 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)40 FormItem (org.olat.core.gui.components.form.flexible.FormItem)38 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)32 Translator (org.olat.core.gui.translator.Translator)30 Identity (org.olat.core.id.Identity)30 VFSContainer (org.olat.core.util.vfs.VFSContainer)28 File (java.io.File)26 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)26 BusinessGroup (org.olat.group.BusinessGroup)26 HashMap (java.util.HashMap)22 HashSet (java.util.HashSet)22 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)22 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)20