use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class GroupsAndRightsController method fillCheckbox.
private void fillCheckbox(BGRightsRow groupRights, List<String> permissions) {
List<BGRight> selections = new ArrayList<>();
for (String permission : CourseRights.getAvailableRights()) {
BGRight permissionEl = new BGRight(permission);
boolean selected = permissions == null ? false : permissions.contains(permission);
MultipleSelectionElement selection = createSelection(selected);
permissionEl.setSelection(selection);
selection.setUserObject(permissionEl);
selections.add(permissionEl);
}
groupRights.setRightsEl(selections);
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class GroupsAndRightsController method createSelection.
private MultipleSelectionElement createSelection(boolean selected) {
String name = "cb_" + (++counter);
MultipleSelectionElement selection = uifactory.addCheckboxesHorizontal(name, null, flc, keys, values);
selection.setEnabled(!readOnly);
flc.add(name, selection);
if (selected) {
selection.select(keys[0], true);
}
return selection;
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class CheckListAssessmentController method doDisableEditingMode.
private void doDisableEditingMode() {
table.setEditMode(false);
List<CheckListAssessmentRow> rows = model.getBackedUpRows();
for (CheckListAssessmentRow row : rows) {
MultipleSelectionElement[] checkedEls = row.getCheckedEl();
if (checkedEls != null) {
for (MultipleSelectionElement checkEl : checkedEls) {
flc.remove(checkEl);
}
}
row.setCheckedEl(null);
}
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class CheckListAssessmentController method doSave.
private void doSave() {
int numOfCheckbox = checkboxList.getNumOfCheckbox();
// save all rows
List<CheckListAssessmentRow> rows = model.getBackedUpRows();
List<AssessmentBatch> batchElements = new ArrayList<>(rows.size());
Set<Long> assessedIdentityToUpdate = new HashSet<>();
for (CheckListAssessmentRow row : rows) {
Boolean[] checked = row.getChecked();
Boolean[] editedChecked = new Boolean[numOfCheckbox];
MultipleSelectionElement[] checkedEls = row.getCheckedEl();
if (checkedEls != null) {
for (int i = 0; i < numOfCheckbox; i++) {
MultipleSelectionElement checkEl = checkedEls[i];
boolean editedValue = checkEl.isAtLeastSelected(1);
editedChecked[i] = new Boolean(editedValue);
boolean currentValue;
if (checked != null && checked.length > 0 && i < checked.length && checked[i] != null) {
currentValue = checked[i].booleanValue();
} else {
currentValue = false;
}
if (editedValue != currentValue) {
Checkbox checkbox = checkboxList.getList().get(i);
String checkboxId = checkbox.getCheckboxId();
Float score = editedValue ? checkbox.getPoints() : new Float(0f);
batchElements.add(new AssessmentBatch(row.getIdentityKey(), checkboxId, score, editedValue));
assessedIdentityToUpdate.add(row.getIdentityKey());
}
flc.remove(checkEl);
}
}
row.setCheckedEl(null);
row.setChecked(editedChecked);
}
doDisableEditingMode();
checkboxManager.check(courseOres, courseNode.getIdent(), batchElements);
if (assessedIdentityToUpdate.size() > 0) {
DBFactory.getInstance().commit();
ICourse course = CourseFactory.loadCourse(courseOres);
List<Identity> assessedIdentities = securityManager.loadIdentityByKeys(assessedIdentityToUpdate);
for (Identity assessedIdentity : assessedIdentities) {
UserCourseEnvironment assessedUserCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
courseNode.updateScoreEvaluation(getIdentity(), assessedUserCourseEnv, assessedIdentity, Role.coach);
}
}
reloadTable();
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class CheckboxAssessmentController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("assessment.checkbox.description");
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
if (isAdministrativeUser) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.username.i18nKey(), Cols.username.ordinal(), true, Cols.username.name()));
}
int i = 0;
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
int colIndex = CheckListAssessmentDataModel.USER_PROPS_OFFSET + i++;
if (userPropertyHandler == null)
continue;
String propName = userPropertyHandler.getName();
boolean visible = userManager.isMandatoryUserProperty(CheckListAssessmentController.USER_PROPS_ID, userPropertyHandler);
if (visible) {
FlexiColumnModel col;
if (UserConstants.FIRSTNAME.equals(propName) || UserConstants.LASTNAME.equals(propName)) {
col = new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, userPropertyHandler.getName(), true, propName, new StaticFlexiCellRenderer(userPropertyHandler.getName(), new TextFlexiCellRenderer()));
} else {
col = new DefaultFlexiColumnModel(true, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, true, propName);
}
columnsModel.addFlexiColumnModel(col);
}
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.check.i18nKey(), Cols.check.ordinal(), true, Cols.check.name()));
if (withScore) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.points.i18nKey(), Cols.points.ordinal(), true, Cols.points.name()));
}
int numOfCheckbox = checkboxList.getList().size();
String[] keys = new String[numOfCheckbox];
String[] values = new String[numOfCheckbox];
List<Checkbox> checkbox = checkboxList.getList();
for (int j = 0; j < numOfCheckbox; j++) {
keys[j] = checkbox.get(j).getCheckboxId();
values[j] = checkbox.get(j).getTitle();
}
FormLayoutContainer selectCont = FormLayoutContainer.createDefaultFormLayout("checkbox_sel_cont", getTranslator());
formLayout.add(selectCont);
checkboxEl = uifactory.addDropdownSingleselect("checkbox", "select.checkbox", selectCont, keys, values, null);
checkboxEl.addActionListener(FormEvent.ONCHANGE);
checkboxEl.select(keys[0], true);
Checkbox box = checkboxList.getList().get(currentCheckboxIndex);
boolean hasPoints = box.getPoints() != null && box.getPoints().floatValue() > 0f;
boxRows = new ArrayList<CheckboxAssessmentRow>(initialRows.size());
for (CheckListAssessmentRow initialRow : initialRows) {
Boolean[] checked = new Boolean[numOfCheckbox];
if (initialRow.getChecked() != null) {
System.arraycopy(initialRow.getChecked(), 0, checked, 0, initialRow.getChecked().length);
}
Float[] scores = new Float[numOfCheckbox];
if (initialRow.getScores() != null) {
System.arraycopy(initialRow.getScores(), 0, scores, 0, initialRow.getScores().length);
}
CheckboxAssessmentRow row = new CheckboxAssessmentRow(initialRow, checked, scores);
String name = "box_" + boxRows.size() + "_";
String pointVal = "";
if (scores != null && scores.length > currentCheckboxIndex && scores[currentCheckboxIndex] != null) {
pointVal = AssessmentHelper.getRoundedScore(scores[currentCheckboxIndex]);
}
TextElement pointEl = uifactory.addTextElement(name + "point", null, 5, pointVal, formLayout);
pointEl.setDisplaySize(5);
MultipleSelectionElement checkEl = uifactory.addCheckboxesHorizontal(name + "check", null, formLayout, onKeys, onValues);
checkEl.setDomReplacementWrapperRequired(false);
checkEl.addActionListener(FormEvent.ONCHANGE);
checkEl.setUserObject(row);
if (checked != null && checked.length > currentCheckboxIndex && checked[currentCheckboxIndex] != null && checked[currentCheckboxIndex].booleanValue()) {
checkEl.select(onKeys[0], true);
}
pointEl.setVisible(hasPoints);
row.setCheckedEl(checkEl);
row.setPointEl(pointEl);
boxRows.add(row);
}
model = new CheckboxAssessmentDataModel(boxRows, columnsModel, getLocale());
table = uifactory.addTableElement(getWindowControl(), "checkbox-list", model, getTranslator(), formLayout);
table.setCustomizeColumns(true);
table.setEditMode(true);
table.setAndLoadPersistedPreferences(ureq, "checkbox-assessment");
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsCont);
uifactory.addFormSubmitButton("save", buttonsCont);
selectAllBoxButton = uifactory.addFormLink("selectall", buttonsCont, Link.BUTTON);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
Aggregations