use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class AssessmentResultController method initFormItemInteractions.
private InteractionResults initFormItemInteractions(FormLayoutContainer layoutCont, ItemSessionState sessionState, ResolvedAssessmentItem resolvedAssessmentItem) {
FormItem responseFormItem = null;
if (options.isUserSolutions()) {
// response
String responseId = "responseItem" + count++;
ItemBodyResultFormItem formItem = new ItemBodyResultFormItem(responseId, resolvedAssessmentItem);
initInteractionResultFormItem(formItem, sessionState);
layoutCont.add(responseId, formItem);
responseFormItem = formItem;
}
// solution
FormItem solutionFormItem = null;
if (options.isCorrectSolutions()) {
String solutionId = "solutionItem" + count++;
ItemBodyResultFormItem formItem = new ItemBodyResultFormItem(solutionId, resolvedAssessmentItem);
formItem.setShowSolution(true);
initInteractionResultFormItem(formItem, sessionState);
layoutCont.add(solutionId, formItem);
solutionFormItem = formItem;
}
return new InteractionResults(responseFormItem, solutionFormItem);
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class CorrectionAssessmentItemListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (tableEl == source) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
CorrectionAssessmentItemRow row = tableModel.getObject(se.getIndex());
if ("select".equals(cmd)) {
// accept all
doSelect(ureq, row, r -> true);
} else if ("answered".equals(cmd)) {
// accept all
doSelect(ureq, row, new ResponsedPredicate(row, true));
} else if ("notAnswered".equals(cmd)) {
// accept all
doSelect(ureq, row, new ResponsedPredicate(row, false));
} else if ("autoCorrected".equals(cmd)) {
doSelect(ureq, row, entry -> !row.isManualCorrection() && entry.getManualScore() == null);
} else if ("corrected".equals(cmd)) {
doSelect(ureq, row, entry -> entry.getManualScore() != null);
} else if ("notCorrected".equals(cmd)) {
doSelect(ureq, row, entry -> row.isManualCorrection() && entry.getManualScore() == null);
} else if ("toReview".equals(cmd)) {
doSelect(ureq, row, AssessmentItemListEntry::isToReview);
}
}
} else if (saveTestsButton == source) {
doConfirmSaveTests(ureq);
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
if ("tools".equals(link.getCmd())) {
doOpenTools(ureq, (CorrectionAssessmentItemRow) link.getUserObject(), link);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class RegistrationController method createNewUserAfterRegistration.
/**
* OO-92
* this will finally create the user, set all it's userproperties
*
* @return User the newly created, persisted User Object
*/
private Identity createNewUserAfterRegistration() {
// create user with mandatory fields from registration-form
UserManager um = UserManager.getInstance();
User volatileUser = um.createUser(registrationForm.getFirstName(), registrationForm.getLastName(), tempKey.getEmailAddress());
// set user configured language
Preferences preferences = volatileUser.getPreferences();
preferences.setLanguage(registrationForm.getLangKey());
volatileUser.setPreferences(preferences);
// create an identity with the given username / pwd and the user object
String login = registrationForm.getLogin();
String pwd = registrationForm.getPassword();
Identity persistedIdentity = registrationManager.createNewUserAndIdentityFromTemporaryKey(login, pwd, volatileUser, tempKey);
if (persistedIdentity == null) {
showError("user.notregistered");
return null;
} else {
// update other user properties from form
List<UserPropertyHandler> userPropertyHandlers = um.getUserPropertyHandlersFor(RegistrationForm2.USERPROPERTIES_FORM_IDENTIFIER, false);
User persistedUser = persistedIdentity.getUser();
// add eventually static value
UserPropertiesConfig userPropertiesConfig = CoreSpringFactory.getImpl(UserPropertiesConfig.class);
if (registrationModule.isStaticPropertyMappingEnabled()) {
String propertyName = registrationModule.getStaticPropertyMappingName();
String propertyValue = registrationModule.getStaticPropertyMappingValue();
if (StringHelper.containsNonWhitespace(propertyName) && StringHelper.containsNonWhitespace(propertyValue) && userPropertiesConfig.getPropertyHandler(propertyName) != null) {
try {
persistedUser.setProperty(propertyName, propertyValue);
} catch (Exception e) {
logError("Cannot set the static property value", e);
}
}
}
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
FormItem fi = registrationForm.getPropFormItem(userPropertyHandler.getName());
userPropertyHandler.updateUserFromFormItem(persistedUser, fi);
}
// persist changes in db
um.updateUserFromIdentity(persistedIdentity);
// send notification mail to sys admin
String notiEmail = CoreSpringFactory.getImpl(RegistrationModule.class).getRegistrationNotificationEmail();
if (notiEmail != null) {
registrationManager.sendNewUserNotificationMessage(notiEmail, persistedIdentity);
}
// tell system that this user did accept the disclaimer
registrationManager.setHasConfirmedDislaimer(persistedIdentity);
return persistedIdentity;
}
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class UsrPropContextEditController method addTableRowComponents.
/**
* adds tableRow-Components (Toggles and Links) for the given Handler
*
* @param handler The handler to create Components for
* @param moveable if true, additional "up"/"down" Links will be rendered
*/
private void addTableRowComponents(UserPropertyHandler handler, boolean moveable) {
List<FormItem> rowFormItemComponents = new ArrayList<FormItem>();
final String handlername = handler.getName();
final boolean isIncluded = context.contains(handler);
final boolean isMandatory = context.isMandatoryUserProperty(handler);
final boolean isAdminOnly = context.isForAdministrativeUserOnly(handler);
final boolean isUserReadOnly = context.isUserViewReadOnly(handler);
// put the translation (in the current language) for the property
String translatedName = I18nManager.getInstance().getLocalizedString(UserPropertyHandler.class.getPackage().getName(), handler.i18nFormElementLabelKey(), null, getLocale(), true, true);
uifactory.addStaticTextElement(FT_NAME_PREFIX_TRANS + handlername, (translatedName == null ? "-" : translatedName), contTableFlc);
FormToggle ftMandatory = uifactory.addToggleButton(FT_NAME_PREFIX_MAND + handlername, " ", contTableFlc, null, null);
ftMandatory.setUserObject(handler);
if (isMandatory)
ftMandatory.toggleOn();
else
ftMandatory.toggleOff();
if (!isIncluded) {
ftMandatory.setEnabled(false);
ftMandatory.setVisible(false);
}
FormToggle ftAdminonly = uifactory.addToggleButton(FT_NAME_PREFIX_ADMN + handlername, " ", contTableFlc, null, null);
ftAdminonly.setUserObject(handler);
if (isAdminOnly)
ftAdminonly.toggleOn();
else
ftAdminonly.toggleOff();
if (!isIncluded) {
ftAdminonly.setEnabled(false);
ftAdminonly.setVisible(false);
}
FormToggle ftUserreadonly = uifactory.addToggleButton(FT_NAME_PREFIX_USR + handlername, " ", contTableFlc, null, null);
ftUserreadonly.setUserObject(handler);
if (isUserReadOnly)
ftUserreadonly.toggleOn();
else
ftUserreadonly.toggleOff();
if (!isIncluded) {
ftUserreadonly.setEnabled(false);
ftUserreadonly.setVisible(false);
}
FormToggle ftInclude = uifactory.addToggleButton(FT_NAME_PREFIX_INCL + handlername, " ", contTableFlc, null, null);
ftInclude.setUserObject(handler);
if (isIncluded) {
ftInclude.toggleOn();
includedPropertiesCount++;
} else
ftInclude.toggleOff();
// up/down links
FormLink fl_up = uifactory.addFormLink(FT_NAME_PREFIX_MUP + handlername, " ", null, contTableFlc, Link.NONTRANSLATED);
fl_up.setIconLeftCSS("o_icon o_icon_move_up o_icon-lg");
fl_up.setUserObject(handler);
FormLink fl_down = uifactory.addFormLink(FT_NAME_PREFIX_MDN + handlername, " ", null, contTableFlc, Link.NONTRANSLATED);
fl_down.setIconRightCSS("o_icon o_icon_move_down o_icon-lg");
fl_down.setUserObject(handler);
if (!moveable) {
fl_up.setEnabled(false);
fl_up.setVisible(false);
fl_down.setEnabled(false);
fl_down.setVisible(false);
}
rowFormItemComponents.add(ftMandatory);
rowFormItemComponents.add(ftAdminonly);
rowFormItemComponents.add(ftUserreadonly);
rowFormItemComponents.add(fl_up);
rowFormItemComponents.add(fl_down);
rowToggleButtonsMap.put(handlername, rowFormItemComponents);
}
use of org.olat.core.gui.components.form.flexible.FormItem in project openolat by klemens.
the class CourseLayoutGeneratorController method compileCustomConfigFromGuiWrapper.
private Map<String, Map<String, Object>> compileCustomConfigFromGuiWrapper() {
// get config from wrapper-object
elWithErrorExists = false;
Map<String, Map<String, Object>> customConfig = new HashMap<String, Map<String, Object>>();
for (Iterator<Entry<String, Map<String, FormItem>>> iterator = guiWrapper.entrySet().iterator(); iterator.hasNext(); ) {
Entry<String, Map<String, FormItem>> type = iterator.next();
String cIdent = type.getKey();
Map<String, Object> elementConfig = new HashMap<String, Object>();
Map<String, FormItem> element = type.getValue();
for (Entry<String, FormItem> entry : element.entrySet()) {
String attribName = entry.getKey();
if (!attribName.equals(PreviewLA.IDENTIFIER)) {
// exclude preview
FormItem foItem = entry.getValue();
String value = "";
if (foItem instanceof SingleSelection) {
value = ((SingleSelection) foItem).isOneSelected() ? ((SingleSelection) foItem).getSelectedKey() : "";
} else if (foItem.getUserObject() != null && foItem.getUserObject() instanceof SpecialAttributeFormItemHandler) {
// enclosed item
SpecialAttributeFormItemHandler specHandler = (SpecialAttributeFormItemHandler) foItem.getUserObject();
value = specHandler.getValue();
if (specHandler.hasError()) {
elWithErrorExists = true;
}
} else {
throw new AssertException("implement a getValue for this FormItem to get back a processable value.");
}
elementConfig.put(attribName, value);
}
}
customConfig.put(cIdent, elementConfig);
}
return customConfig;
}
Aggregations