Search in sources :

Example 6 with TextElement

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

the class BinderAssessmentController method forgeAssessmentSection.

private void forgeAssessmentSection(AssessmentSectionWrapper row) {
    AssessmentSection assessmentSection = row.getAssessmentSection();
    Section section = row.getSection();
    if (!SectionStatus.isClosed(section)) {
        // score
        String pointVal = null;
        if (assessmentSection != null && assessmentSection.getScore() != null) {
            BigDecimal score = assessmentSection.getScore();
            pointVal = AssessmentHelper.getRoundedScore(score);
        }
        TextElement pointEl = uifactory.addTextElement("point" + (++counter), null, 5, pointVal, flc);
        pointEl.setDisplaySize(5);
        row.setScoreEl(pointEl);
        // passed
        Boolean passed = assessmentSection == null ? null : assessmentSection.getPassed();
        MultipleSelectionElement passedEl = uifactory.addCheckboxesHorizontal("check" + (++counter), null, flc, onKeys, onValues);
        if (passed != null && passed.booleanValue()) {
            passedEl.select(onKeys[0], passed.booleanValue());
        }
        row.setPassedEl(passedEl);
    }
    if (SectionStatus.isClosed(section)) {
        FormLink reopenButton = uifactory.addFormLink("reopen" + (++counter), "reopen", "reopen", null, flc, Link.BUTTON);
        reopenButton.setElementCssClass("o_sel_pf_reopen_section");
        reopenButton.setUserObject(row);
        row.setButton(reopenButton);
    } else {
        FormLink closeButton = uifactory.addFormLink("close" + (++counter), "close", "close.section", null, flc, Link.BUTTON);
        closeButton.setElementCssClass("o_sel_pf_close_section");
        closeButton.setUserObject(row);
        row.setButton(closeButton);
    }
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) BigDecimal(java.math.BigDecimal)

Example 7 with TextElement

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

the class ShibbolethRegistrationUserPropertiesFrom method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // Add all available user fields to this form
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler != null) {
            FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, USERPROPERTIES_FORM_IDENTIFIER, false, formLayout);
            propFormItems.put(userPropertyHandler.getName(), fi);
            if (fi instanceof TextElement) {
                String value = shibbolethAttributes.getValueForUserPropertyName(userPropertyHandler.getName());
                if (StringHelper.containsNonWhitespace(value)) {
                    TextElement formElement = (TextElement) fi;
                    formElement.setValue(value);
                    formElement.setEnabled(false);
                }
            }
        }
    }
    FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
    formLayout.add(buttonLayout);
    uifactory.addFormSubmitButton("save", buttonLayout);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormItem(org.olat.core.gui.components.form.flexible.FormItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 8 with TextElement

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

the class GroupAssessmentController method loadModel.

/**
 * @return True if all results are the same
 */
private ModelInfos loadModel() {
    // load participants, load datas
    ICourse course = CourseFactory.loadCourse(courseEntry);
    List<Identity> identities = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());
    Map<Identity, AssessmentEntry> identityToEntryMap = new HashMap<>();
    List<AssessmentEntry> entries = course.getCourseEnvironment().getAssessmentManager().getAssessmentEntries(assessedGroup, gtaNode);
    for (AssessmentEntry entry : entries) {
        identityToEntryMap.put(entry.getIdentity(), entry);
    }
    int count = 0;
    boolean same = true;
    StringBuilder duplicateWarning = new StringBuilder();
    Float scoreRef = null;
    Boolean passedRef = null;
    String commentRef = null;
    Boolean userVisibleRef = null;
    List<AssessmentRow> rows = new ArrayList<>(identities.size());
    for (Identity identity : identities) {
        AssessmentEntry entry = identityToEntryMap.get(identity);
        ScoreEvaluation scoreEval = null;
        if (withScore || withPassed) {
            scoreEval = gtaNode.getUserScoreEvaluation(entry);
            if (scoreEval == null) {
                scoreEval = ScoreEvaluation.EMPTY_EVALUATION;
            }
        }
        String comment = null;
        if (withComment && entry != null) {
            comment = entry.getComment();
        }
        boolean duplicate = duplicateMemberKeys.contains(identity.getKey());
        if (duplicate) {
            if (duplicateWarning.length() > 0)
                duplicateWarning.append(", ");
            duplicateWarning.append(StringHelper.escapeHtml(userManager.getUserDisplayName(identity)));
        }
        AssessmentRow row = new AssessmentRow(identity, duplicate);
        rows.add(row);
        if (withScore) {
            Float score = scoreEval.getScore();
            String pointVal = AssessmentHelper.getRoundedScore(score);
            TextElement pointEl = uifactory.addTextElement("point" + count, null, 5, pointVal, flc);
            pointEl.setDisplaySize(5);
            row.setScoreEl(pointEl);
            if (count == 0) {
                scoreRef = score;
            } else if (!same(scoreRef, score)) {
                same = false;
            }
        }
        if (withPassed && cutValue == null) {
            Boolean passed = scoreEval.getPassed();
            MultipleSelectionElement passedEl = uifactory.addCheckboxesHorizontal("check" + count, null, flc, onKeys, onValues);
            if (passed != null && passed.booleanValue()) {
                passedEl.select(onKeys[0], passed.booleanValue());
            }
            row.setPassedEl(passedEl);
            if (count == 0) {
                passedRef = passed;
            } else if (!same(passedRef, passed)) {
                same = false;
            }
        }
        if (withComment) {
            FormLink commentLink = uifactory.addFormLink("comment-" + CodeHelper.getRAMUniqueID(), "comment", "comment", null, flc, Link.LINK);
            if (StringHelper.containsNonWhitespace(comment)) {
                commentLink.setIconLeftCSS("o_icon o_icon_comments");
            } else {
                commentLink.setIconLeftCSS("o_icon o_icon_comments_none");
            }
            commentLink.setUserObject(row);
            row.setComment(comment);
            row.setCommentEditLink(commentLink);
            if (count == 0) {
                commentRef = comment;
            } else if (!same(commentRef, comment)) {
                same = false;
            }
        }
        if (withScore || withPassed || withPassed) {
            Boolean userVisible = scoreEval.getUserVisible();
            if (userVisible == null) {
                userVisible = Boolean.TRUE;
            }
            if (count == 0) {
                userVisibleRef = userVisible;
            } else if (!same(userVisibleRef, userVisible)) {
                same = false;
            }
        }
        count++;
    }
    model.setObjects(rows);
    table.reset();
    return new ModelInfos(same, scoreRef, passedRef, commentRef, userVisibleRef, duplicateWarning.toString());
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) Identity(org.olat.core.id.Identity)

Example 9 with TextElement

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

the class HotspotChoiceScoreController method createHotspotChoiceWrapper.

private HotspotChoiceWrapper createHotspotChoiceWrapper(HotspotChoice choice) {
    String points = "";
    Double score = itemBuilder.getMapping(choice.getIdentifier());
    if (score != null) {
        points = score.toString();
    } else if (itemBuilder.isCorrect(choice)) {
        points = "1";
    } else {
        points = "0";
    }
    String pointElId = "points_" + counter++;
    TextElement pointEl = uifactory.addTextElement(pointElId, null, 5, points, scoreCont);
    pointEl.setDisplaySize(5);
    pointEl.setEnabled(!restrictedEdit && !readOnly);
    scoreCont.add(pointElId, pointEl);
    return new HotspotChoiceWrapper(choice, pointEl);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement)

Example 10 with TextElement

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

the class MatchScoreController method forgeScoreElement.

private void forgeScoreElement(MatchWrapper sourceWrapper, MatchWrapper targetWrapper) {
    Identifier sourceIdentifier = sourceWrapper.getChoiceIdentifier();
    Identifier targetIdentifier = targetWrapper.getChoiceIdentifier();
    DirectedPairValue dKey = new DirectedPairValue(sourceIdentifier, targetIdentifier);
    if (!scoreWrappers.containsKey(dKey)) {
        String key = sourceIdentifier.toString() + "-" + targetIdentifier.toString();
        TextElement textEl = uifactory.addTextElement(key, null, 8, "", scoreCont);
        MatchScoreWrapper scoreWrapper = new MatchScoreWrapper(sourceIdentifier, targetIdentifier, textEl);
        textEl.setDomReplacementWrapperRequired(false);
        textEl.setDisplaySize(5);
        textEl.setUserObject(scoreWrapper);
        textEl.setEnabled(!restrictedEdit && !readOnly);
        Double score = itemBuilder.getScore(sourceIdentifier, targetIdentifier);
        if (score == null) {
            textEl.setValue("0.0");
        } else {
            textEl.setValue(AssessmentHelper.getRoundedScore(score));
        }
        scoreWrappers.put(dKey, scoreWrapper);
        scoreCont.contextPut(key, scoreWrapper);
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)

Aggregations

TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)146 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)40 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)36 FormItem (org.olat.core.gui.components.form.flexible.FormItem)34 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)30 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)26 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)24 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)18 ArrayList (java.util.ArrayList)16 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)16 Identity (org.olat.core.id.Identity)12 HashMap (java.util.HashMap)8 FormLinkImpl (org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)8 EmailProperty (org.olat.user.propertyhandlers.EmailProperty)8 Date (java.util.Date)6 DateChooser (org.olat.core.gui.components.form.flexible.elements.DateChooser)6 StaticTextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.StaticTextElementImpl)6 TextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.TextElementImpl)6 RichTextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextElementImpl)6 File (java.io.File)4