Search in sources :

Example 6 with FormSubmit

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

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 7 with FormSubmit

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

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

the class AssessedIdentityCheckListController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        List<DBCheck> checks = checkboxManager.loadCheck(assessedIdentity, courseOres, courseNode.getIdent());
        Map<String, DBCheck> uuidToCheckMap = new HashMap<>();
        for (DBCheck check : checks) {
            uuidToCheckMap.put(check.getCheckbox().getCheckboxId(), check);
        }
        List<Checkbox> list = checkboxList.getList();
        wrappers = new ArrayList<>(list.size());
        for (Checkbox checkbox : list) {
            DBCheck check = uuidToCheckMap.get(checkbox.getCheckboxId());
            boolean readOnly = false;
            CheckboxWrapper wrapper = forgeCheckboxWrapper(checkbox, check, readOnly, formLayout);
            wrappers.add(wrapper);
        }
        layoutCont.contextPut("checkboxList", wrappers);
    }
    FormLayoutContainer buttonCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonCont);
    FormSubmit saveButton = uifactory.addFormSubmitButton("save", "save", buttonCont);
    saveButton.setEnabled(checkboxList.getNumOfCheckbox() > 0);
    saveButton.setVisible(!coachCourseEnv.isCourseReadOnly());
    saveAndCloseLink = uifactory.addFormLink("save.close", buttonCont, Link.BUTTON);
    saveAndCloseLink.setEnabled(checkboxList.getNumOfCheckbox() > 0);
    saveAndCloseLink.setVisible(saveAndClose && !coachCourseEnv.isCourseReadOnly());
    if (cancel) {
        uifactory.addFormCancelButton("cancel", buttonCont, ureq, getWindowControl());
    }
}
Also used : DBCheck(org.olat.course.nodes.cl.model.DBCheck) FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) HashMap(java.util.HashMap) Checkbox(org.olat.course.nodes.cl.model.Checkbox) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 9 with FormSubmit

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

the class CreateRepositoryEntryController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String typeName;
    if (handler != null) {
        typeName = NewControllerFactory.translateResourceableTypeName(handler.getSupportedType(), getLocale());
    } else {
        typeName = translate("cif.type.na");
    }
    StaticTextElement typeEl = uifactory.addStaticTextElement("cif.type", typeName, formLayout);
    typeEl.setElementCssClass("o_sel_author_type");
    displaynameEl = uifactory.addTextElement("cif.displayname", "cif.displayname", 100, "", formLayout);
    displaynameEl.setElementCssClass("o_sel_author_displayname");
    displaynameEl.setFocus(true);
    displaynameEl.setDisplaySize(30);
    displaynameEl.setMandatory(true);
    String page = velocity_root + "/example_help.html";
    exampleHelpEl = FormLayoutContainer.createCustomFormLayout("example.help", "example.help", getTranslator(), page);
    formLayout.add(exampleHelpEl);
    exampleHelpEl.setVisible(false);
    FormLayoutContainer buttonContainer = FormLayoutContainer.createButtonLayout("buttonContainer", getTranslator());
    formLayout.add("buttonContainer", buttonContainer);
    buttonContainer.setElementCssClass("o_sel_repo_save_details");
    FormSubmit submit = uifactory.addFormSubmitButton("cmd.create.ressource", buttonContainer);
    submit.setElementCssClass("o_sel_author_create_submit");
    if (handler.isPostCreateWizardAvailable()) {
        wizardButton = uifactory.addFormLink("csc.startwizard", buttonContainer, Link.BUTTON);
        wizardButton.setElementCssClass("o_sel_author_create_wizard");
    }
    uifactory.addFormCancelButton("cancel", buttonContainer, ureq, getWindowControl());
}
Also used : FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement)

Example 10 with FormSubmit

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

the class GuiDemoFlexiForm 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 a form with a title and 4 input fields to enter some persons data
		 */
    setFormTitle("guidemo_flexi_form_simpleform");
    final int defaultDisplaySize = 32;
    final boolean inputMode = !personData.isReadOnly();
    firstName = uifactory.addTextElement("firstname", "guidemo.flexi.form.firstname", 256, personData.getFirstName(), formLayout);
    firstName.setDisplaySize(defaultDisplaySize);
    firstName.setNotEmptyCheck("guidemo.flexi.form.mustbefilled");
    firstName.setMandatory(true);
    firstName.setEnabled(inputMode);
    firstName.setPlaceholderText("Hans");
    firstName.setHelpText("If you have a middle name, add it to the first name input field");
    firstName.setHelpUrlForManualPage("Configuration#Profile");
    lastName = uifactory.addTextElement("lastname", "guidemo.flexi.form.lastname", 256, personData.getLastName(), formLayout);
    lastName.setDisplaySize(defaultDisplaySize);
    lastName.setNotEmptyCheck("guidemo.flexi.form.mustbefilled");
    lastName.setEnabled(inputMode);
    lastName.setPlaceholderText("Muster");
    lastName.setHelpUrl("https://en.wikipedia.org/wiki/Family_name");
    fileElement = uifactory.addFileElement(getWindowControl(), "file", formLayout);
    fileElement.setLabel("guidemo.flexi.form.file", null);
    fileElement.setMaxUploadSizeKB(500, "guidemo.flexi.form.filetobig", null);
    Set<String> mimeTypes = new HashSet<String>();
    mimeTypes.add("image/*");
    fileElement.limitToMimeType(mimeTypes, "guidemo.flexi.form.wrongfiletype", null);
    fileElement.setMandatory(true, "guidemo.flexi.form.mustbefilled");
    fileElement.setEnabled(inputMode);
    institution = uifactory.addTextElement("institution", "guidemo.flexi.form.institution", 256, personData.getInstitution(), formLayout);
    institution.setDisplaySize(defaultDisplaySize);
    institution.setNotEmptyCheck("guidemo.flexi.form.mustbefilled");
    institution.setMandatory(true);
    institution.setEnabled(inputMode);
    institution.setHelpTextKey("guidemo.flexi.form.institution.help", null);
    if (inputMode) {
        // submit only if in input mode
        submit = new FormSubmit("submit", "submit");
        formLayout.add(submit);
    }
}
Also used : FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) HashSet(java.util.HashSet)

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