use of org.olat.course.nodes.cl.model.Checkbox in project openolat by klemens.
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.course.nodes.cl.model.Checkbox in project openolat by klemens.
the class CheckListBoxListEditController method doDown.
private void doDown(UserRequest ureq, int checkboxIndex) {
CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
if (checkboxIndex >= 0 && checkboxIndex < list.getList().size() - 1) {
Checkbox box = list.getList().remove(checkboxIndex);
list.getList().add(checkboxIndex + 1, box);
}
fireEvent(ureq, Event.DONE_EVENT);
updateModel();
}
use of org.olat.course.nodes.cl.model.Checkbox in project openolat by klemens.
the class CheckListBoxListEditController method doUp.
private void doUp(UserRequest ureq, int checkboxIndex) {
CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
if (checkboxIndex > 0 && checkboxIndex < list.getList().size()) {
Checkbox box = list.getList().remove(checkboxIndex);
list.getList().add(checkboxIndex - 1, box);
}
fireEvent(ureq, Event.DONE_EVENT);
updateModel();
}
use of org.olat.course.nodes.cl.model.Checkbox in project openolat by klemens.
the class CheckListExcelExport method writeHeaders.
private void writeHeaders(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
CellStyle headerStyle = workbook.getStyles().getHeaderStyle();
// second header
// reset column counter
int col = 0;
Row header2Row = exportSheet.newRow();
String sequentialNumber = translator.translate("column.header.seqnum");
header2Row.addCell(col++, sequentialNumber, headerStyle);
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null) {
continue;
}
String header = translator.translate(userPropertyHandler.i18nFormElementLabelKey());
header2Row.addCell(col++, header, headerStyle);
}
// add other user and session information
header2Row.addCell(col++, translator.translate("column.header.homepage"), headerStyle);
// course node points and passed
if (courseNode.hasScoreConfigured()) {
header2Row.addCell(col++, translator.translate("column.header.node.points"), headerStyle);
}
if (courseNode.hasPassedConfigured()) {
header2Row.addCell(col++, translator.translate("column.header.node.passed"), headerStyle);
}
ModuleConfiguration config = courseNode.getModuleConfiguration();
CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
if (list != null && list.getList() != null) {
List<Checkbox> checkboxList = list.getList();
for (Checkbox checkbox : checkboxList) {
String boxTitle = checkbox.getTitle();
header2Row.addCell(col++, boxTitle, headerStyle);
if (courseNode.hasScoreConfigured() && checkbox.getPoints() != null) {
header2Row.addCell(col++, translator.translate("column.header.points"), headerStyle);
}
}
}
}
use of org.olat.course.nodes.cl.model.Checkbox in project openolat by klemens.
the class CheckListExcelExport method writeDataRow.
private void writeDataRow(AssessmentData data, AssessmentEntry entry, int num, OpenXMLWorksheet exportSheet) {
int col = 0;
Identity assessedIdentity = data.getIdentity();
User assessedUser = assessedIdentity.getUser();
Row dataRow = exportSheet.newRow();
// sequence number
dataRow.addCell(col++, num, null);
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
String property = userPropertyHandler.getUserProperty(assessedUser, translator.getLocale());
dataRow.addCell(col++, property, null);
}
}
// homepage
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(assessedIdentity);
String homepage = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
dataRow.addCell(col++, homepage, null);
// course node points and passed
if (courseNode.hasScoreConfigured()) {
if (entry != null && entry.getScore() != null) {
dataRow.addCell(col++, entry.getScore(), null);
} else {
col++;
}
}
if (courseNode.hasPassedConfigured()) {
if (entry != null && entry.getPassed() != null) {
dataRow.addCell(col++, entry.getPassed().toString(), null);
} else {
col++;
}
}
ModuleConfiguration config = courseNode.getModuleConfiguration();
CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
if (list != null && list.getList() != null && data.getChecks() != null) {
Map<String, DBCheck> checkMap = data.getChecks().stream().collect(Collectors.toMap(c -> c.getCheckbox().getCheckboxId(), c -> c));
List<Checkbox> checkboxList = list.getList();
for (Checkbox checkbox : checkboxList) {
String boxId = checkbox.getCheckboxId();
DBCheck check = checkMap.get(boxId);
if (check != null && check.getChecked() != null && check.getChecked().booleanValue()) {
dataRow.addCell(col++, "x", null);
} else {
col++;
}
if (courseNode.hasScoreConfigured() && checkbox.getPoints() != null) {
if (check != null && check.getScore() != null) {
dataRow.addCell(col++, check.getScore(), null);
} else {
col++;
}
}
}
}
}
Aggregations