Search in sources :

Example 96 with FormItem

use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.

the class AssessmentObjectComponentRenderer method renderEndAttemptInteraction.

private void renderEndAttemptInteraction(AssessmentRenderer renderer, StringOutput sb, EndAttemptInteraction interaction, ItemSessionState itemSessionState, AssessmentObjectComponent component, URLBuilder ubu, Translator translator) {
    if (QTI21Constants.HINT_REQUEST_IDENTIFIER.equals(interaction.getResponseIdentifier()) && component.isHideFeedbacks()) {
        // don't show our hint's, they trigger feedbacks
        return;
    }
    boolean ended = component.isItemSessionEnded(itemSessionState, renderer.isSolutionMode());
    AssessmentObjectFormItem item = component.getQtiItem();
    String responseUniqueId = component.getResponseUniqueIdentifier(itemSessionState, interaction);
    String id = "qtiworks_response_".concat(responseUniqueId);
    if (!ended) {
        sb.append("<input name=\"qtiworks_presented_").append(responseUniqueId).append("\" type=\"hidden\" value=\"1\"/>");
    }
    FormItem endAttemptButton = item.getFormComponent(id);
    if (endAttemptButton == null) {
        String title = StringHelper.escapeHtml(interaction.getTitle());
        FormLink button = FormUIFactory.getInstance().addFormLink(id, id, title, null, null, Link.BUTTON | Link.NONTRANSLATED);
        // use specific icon for known types
        if (interaction.getResponseIdentifier().equals(QTI21Constants.HINT_REQUEST_IDENTIFIER)) {
            button.setIconLeftCSS("o_icon o_icon-fw o_icon_qti_hint");
            button.setElementCssClass("o_sel_assessment_item_hint");
        }
        endAttemptButton = button;
        endAttemptButton.setTranslator(translator);
        endAttemptButton.setUserObject(interaction);
        if (item.getRootForm() != endAttemptButton.getRootForm()) {
            endAttemptButton.setRootForm(item.getRootForm());
        }
        item.addFormItem(endAttemptButton);
    }
    endAttemptButton.setEnabled(!ended);
    endAttemptButton.getComponent().getHTMLRendererSingleton().render(renderer.getRenderer(), sb, endAttemptButton.getComponent(), ubu, translator, new RenderResult(), null);
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) RenderResult(org.olat.core.gui.render.RenderResult) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 97 with FormItem

use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.

the class StepsMainRunController method initForm.

/*
	 * (non-Javadoc)
	 * 
	 * @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) {
    formLayout.add("stepLinks", stepTitleLinks);
    // steps/wizard navigation .. as start most of buttons are disabled
    // they must be enabled by the first step according to its rules
    // cancel button is not possible to disable
    prevButton = new FormLinkImpl("back");
    prevButton.setCustomEnabledLinkCSS("btn btn-default o_wizard_button_prev");
    prevButton.setCustomDisabledLinkCSS("btn btn-default o_wizard_button_prev");
    prevButton.setIconLeftCSS("o_icon o_icon_previous_step o_icon-fw");
    nextButton = new FormLinkImpl("next");
    nextButton.setCustomEnabledLinkCSS("btn btn-default o_wizard_button_next");
    nextButton.setCustomDisabledLinkCSS("btn btn-default o_wizard_button_next");
    nextButton.setIconRightCSS("o_icon o_icon_next_step o_icon-fw");
    finishButton = new FormLinkImpl("finish");
    finishButton.setCustomEnabledLinkCSS("btn btn-default o_wizard_button_finish");
    finishButton.setCustomDisabledLinkCSS("btn btn-default o_wizard_button_finish");
    cancelButton = new FormLinkImpl("cancel");
    cancelButton.setCustomEnabledLinkCSS("btn btn-default o_wizard_button_cancel");
    cancelButton.setCustomDisabledLinkCSS("btn btn-default o_wizard_button_cancel");
    closeLink = new FormLinkImpl("closeIcon", "close", "", Link.NONTRANSLATED);
    closeLink.setIconLeftCSS("o_icon o_icon_close");
    formLayout.add(prevButton);
    formLayout.add(nextButton);
    formLayout.add(finishButton);
    formLayout.add(cancelButton);
    formLayout.add(closeLink);
    // add all step titles, but disabled.
    Step tmp = startStep;
    do {
        FormItem title = tmp.getStepTitle();
        title.setEnabled(false);
        stepTitleLinks.add(title);
        tmp = tmp.nextStep();
    } while (tmp != Step.NOSTEP);
    // init buttons and the like
    // start with -1 to be on zero after calling
    currentStepIndex = -1;
    // update current step index to velocity
    flc.contextPut("currentStep", currentStepIndex + 1);
    // next step the first time
    addNextStep(startStep.getStepController(ureq, getWindowControl(), this.stepsContext, this.mainForm), startStep);
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)

Example 98 with FormItem

use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.

the class SubmitDocumentsController method updateModel.

private void updateModel() {
    File[] documents = documentsDir.listFiles(new SystemFileFilter(true, false));
    List<SubmittedSolution> docList = new ArrayList<>(documents.length);
    for (File document : documents) {
        String filename = document.getName();
        String uploadedBy = null;
        VFSItem item = documentsContainer.resolve(filename);
        if (item instanceof MetaTagged) {
            MetaInfo metaInfo = ((MetaTagged) item).getMetaInfo();
            if (metaInfo != null && metaInfo.getAuthorIdentityKey() != null) {
                uploadedBy = userManager.getUserDisplayName(metaInfo.getAuthorIdentityKey());
            }
        }
        FormItem download;
        if (filename.endsWith(".html")) {
            download = uifactory.addFormLink("view-" + CodeHelper.getRAMUniqueID(), "view", filename, null, flc, Link.LINK | Link.NONTRANSLATED);
            download.setUserObject(filename);
        } else {
            download = uifactory.addDownloadLink("view-" + CodeHelper.getRAMUniqueID(), filename, null, document, tableEl);
        }
        docList.add(new SubmittedSolution(document, uploadedBy, download));
    }
    model.setObjects(docList);
    tableEl.reset();
    if (maxDocs > 0 && docList.size() >= maxDocs) {
        if (uploadDocButton != null) {
            uploadDocButton.setEnabled(false);
        }
        if (createDocButton != null) {
            createDocButton.setEnabled(false);
        }
        String msg = translate("error.max.documents", new String[] { Integer.toString(maxDocs) });
        flc.contextPut("maxDocsWarning", msg);
    } else {
        if (uploadDocButton != null) {
            uploadDocButton.setEnabled(true);
        }
        if (createDocButton != null) {
            createDocButton.setEnabled(true);
        }
        flc.contextPut("maxDocsWarning", Boolean.FALSE);
    }
    flc.contextPut("hasDocuments", Boolean.valueOf(hasUploadDocuments()));
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem) SystemFileFilter(org.olat.core.util.io.SystemFileFilter) File(java.io.File)

Example 99 with FormItem

use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.

the class FlexiTableClassicRenderer method renderCell.

private void renderCell(Renderer renderer, StringOutput target, FlexiTableComponent ftC, FlexiColumnModel fcm, int row, URLBuilder ubu, Translator translator, RenderResult renderResult) {
    FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
    FlexiTableDataModel<?> dataModel = ftE.getTableDataModel();
    int alignment = fcm.getAlignment();
    String cssClass = (alignment == FlexiColumnModel.ALIGNMENT_LEFT ? "text-left" : (alignment == FlexiColumnModel.ALIGNMENT_RIGHT ? "text-right" : "text-center"));
    target.append("<td class=\"").append(cssClass).append(" ").append("o_dnd_label", ftE.getColumnIndexForDragAndDropLabel() == fcm.getColumnIndex()).append("\">");
    int columnIndex = fcm.getColumnIndex();
    Object cellValue = columnIndex >= 0 ? dataModel.getValueAt(row, columnIndex) : null;
    if (cellValue instanceof FormItem) {
        FormItem formItem = (FormItem) cellValue;
        formItem.setTranslator(translator);
        if (ftE.getRootForm() != formItem.getRootForm()) {
            formItem.setRootForm(ftE.getRootForm());
        }
        ftE.addFormItem(formItem);
        if (formItem.isVisible()) {
            formItem.getComponent().getHTMLRendererSingleton().render(renderer, target, formItem.getComponent(), ubu, translator, renderResult, null);
        }
    } else if (cellValue instanceof Component) {
        Component cmp = (Component) cellValue;
        cmp.setTranslator(translator);
        if (cmp.isVisible()) {
            cmp.getHTMLRendererSingleton().render(renderer, target, cmp, ubu, translator, renderResult, null);
        }
    } else {
        fcm.getCellRenderer().render(renderer, target, cellValue, row, ftC, ubu, translator);
    }
    target.append("</td>");
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) Component(org.olat.core.gui.components.Component)

Example 100 with FormItem

use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.

the class FlexiTableComponent method getComponents.

@Override
public Iterable<Component> getComponents() {
    List<Component> cmp = new ArrayList<Component>();
    for (FormItem item : element.getFormItems()) {
        cmp.add(item.getComponent());
    }
    cmp.addAll(components.values());
    return cmp;
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) Component(org.olat.core.gui.components.Component)

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