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);
}
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());
}
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());
}
}
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());
}
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);
}
}
Aggregations