Search in sources :

Example 31 with FormItem

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);
}
Also used : ItemBodyResultFormItem(org.olat.ims.qti21.ui.components.ItemBodyResultFormItem) FeedbackResultFormItem(org.olat.ims.qti21.ui.components.FeedbackResultFormItem) ItemBodyResultFormItem(org.olat.ims.qti21.ui.components.ItemBodyResultFormItem) FormItem(org.olat.core.gui.components.form.flexible.FormItem)

Example 32 with FormItem

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);
}
Also used : FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement) Util(org.olat.core.util.Util) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) ItemSessionKey(org.olat.ims.qti21.ui.assessment.model.ItemSessionKey) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) Autowired(org.springframework.beans.factory.annotation.Autowired) AssessmentItemCorrection(org.olat.ims.qti21.ui.assessment.model.AssessmentItemCorrection) OLATResourceable(org.olat.core.id.OLATResourceable) BigDecimal(java.math.BigDecimal) OresHelper(org.olat.core.util.resource.OresHelper) Map(java.util.Map) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) QuestionTypeFlexiCellRenderer(org.olat.ims.qti21.ui.assessment.components.QuestionTypeFlexiCellRenderer) QTI21Module(org.olat.ims.qti21.QTI21Module) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder) Translator(org.olat.core.gui.translator.Translator) Predicate(java.util.function.Predicate) WindowControl(org.olat.core.gui.control.WindowControl) PopEvent(org.olat.core.gui.components.stack.PopEvent) Component(org.olat.core.gui.components.Component) LinkFactory(org.olat.core.gui.components.link.LinkFactory) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus) QTI21Service(org.olat.ims.qti21.QTI21Service) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) BasicController(org.olat.core.gui.control.controller.BasicController) CorrectionAssessmentItemRow(org.olat.ims.qti21.ui.assessment.model.CorrectionAssessmentItemRow) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) CorrectedFlexiCellRenderer(org.olat.ims.qti21.ui.assessment.components.CorrectedFlexiCellRenderer) Identity(org.olat.core.id.Identity) AssessmentTestComposerController(org.olat.ims.qti21.ui.editor.AssessmentTestComposerController) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) SelectAssessmentItemEvent(org.olat.ims.qti21.ui.assessment.event.SelectAssessmentItemEvent) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) ToReviewFlexiCellRenderer(org.olat.ims.qti21.ui.assessment.components.ToReviewFlexiCellRenderer) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) HashMap(java.util.HashMap) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) ArrayList(java.util.ArrayList) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) FlexiTableDataModelFactory(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) CorrectionWorkflow(org.olat.ims.qti21.QTI21Module.CorrectionWorkflow) AssessmentItemListEntry(org.olat.ims.qti21.ui.assessment.model.AssessmentItemListEntry) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) Link(org.olat.core.gui.components.link.Link) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey) CompleteAssessmentTestSessionEvent(org.olat.modules.assessment.ui.event.CompleteAssessmentTestSessionEvent) ItemCols(org.olat.ims.qti21.ui.assessment.CorrectionAssessmentItemTableModel.ItemCols) AutoCorrectedFlexiCellRenderer(org.olat.ims.qti21.ui.assessment.components.AutoCorrectedFlexiCellRenderer) Controller(org.olat.core.gui.control.Controller) UserManager(org.olat.user.UserManager) NotCorrectedFlexiCellRenderer(org.olat.ims.qti21.ui.assessment.components.NotCorrectedFlexiCellRenderer) LockResult(org.olat.core.util.coordinate.LockResult) UserRequest(org.olat.core.gui.UserRequest) CoordinatorManager(org.olat.core.util.coordinate.CoordinatorManager) CorrectionAssessmentItemRow(org.olat.ims.qti21.ui.assessment.model.CorrectionAssessmentItemRow) AssessmentItemListEntry(org.olat.ims.qti21.ui.assessment.model.AssessmentItemListEntry) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 33 with FormItem

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;
    }
}
Also used : User(org.olat.core.id.User) UserManager(org.olat.user.UserManager) FormItem(org.olat.core.gui.components.form.flexible.FormItem) Preferences(org.olat.core.id.Preferences) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) UserPropertiesConfig(org.olat.user.UserPropertiesConfig)

Example 34 with FormItem

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, "&nbsp;&nbsp;&nbsp;&nbsp;", 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, "&nbsp;&nbsp;&nbsp;&nbsp;", 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, "&nbsp;&nbsp;&nbsp;&nbsp;", 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, "&nbsp;&nbsp;&nbsp;&nbsp;", 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);
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) FormToggle(org.olat.core.gui.components.form.flexible.elements.FormToggle) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 35 with FormItem

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;
}
Also used : AssertException(org.olat.core.logging.AssertException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) SpecialAttributeFormItemHandler(org.olat.course.config.ui.courselayout.attribs.SpecialAttributeFormItemHandler) Entry(java.util.Map.Entry) RepositoryEntry(org.olat.repository.RepositoryEntry) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

FormItem (org.olat.core.gui.components.form.flexible.FormItem)142 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)62 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)34 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)30 ArrayList (java.util.ArrayList)24 HashMap (java.util.HashMap)22 Identity (org.olat.core.id.Identity)20 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)16 User (org.olat.core.id.User)16 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)14 UserManager (org.olat.user.UserManager)12 EmailProperty (org.olat.user.propertyhandlers.EmailProperty)12 HashSet (java.util.HashSet)10 Translator (org.olat.core.gui.translator.Translator)10 File (java.io.File)8 Map (java.util.Map)8 Component (org.olat.core.gui.components.Component)8 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)8 Date (java.util.Date)6 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)6