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