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