use of org.olat.course.nodes.cl.model.AssessmentBatch 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.AssessmentBatch in project openolat by klemens.
the class CheckboxAssessmentController method formOK.
@Override
protected void formOK(UserRequest ureq) {
saveCurrentSelectCheckbox();
int numOfCheckbox = checkboxList.getNumOfCheckbox();
Map<Long, CheckListAssessmentRow> identityToInitialRow = new HashMap<>();
for (CheckListAssessmentRow initialRow : initialRows) {
identityToInitialRow.put(initialRow.getIdentityKey(), initialRow);
}
Set<Long> assessedIdentityToUpdate = new HashSet<>();
List<CheckboxAssessmentRow> rows = model.getObjects();
List<AssessmentBatch> batchElements = new ArrayList<>();
for (CheckboxAssessmentRow row : rows) {
CheckListAssessmentRow initialRow = identityToInitialRow.get(row.getIdentityKey());
Boolean[] checked = initialRow.getChecked();
Boolean[] editedChecked = row.getChecked();
Float[] scores = initialRow.getScores();
Float[] editedScores = row.getScores();
for (int i = 0; i < numOfCheckbox; i++) {
Checkbox box = checkboxList.getList().get(i);
boolean currentValue = getSecureValue(checked, i);
boolean editedValue = getSecureValue(editedChecked, i);
Float currentPoint = getSecureValue(scores, i);
;
Float editedPoint;
if (box.getPoints() != null && box.getPoints().floatValue() > 0f) {
editedPoint = getSecureValue(editedScores, i);
} else {
editedPoint = null;
}
if ((editedValue != currentValue) || ((currentPoint == null && editedPoint != null) || (currentPoint != null && editedPoint == null) || (currentPoint != null && !currentPoint.equals(editedPoint)))) {
Checkbox checkbox = checkboxList.getList().get(i);
String checkboxId = checkbox.getCheckboxId();
batchElements.add(new AssessmentBatch(row.getIdentityKey(), checkboxId, editedPoint, editedValue));
assessedIdentityToUpdate.add(row.getIdentityKey());
}
}
}
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);
}
}
fireEvent(ureq, Event.DONE_EVENT);
}
use of org.olat.course.nodes.cl.model.AssessmentBatch in project openolat by klemens.
the class AssessedIdentityCheckListController method doSave.
private void doSave() {
List<AssessmentBatch> batchElements = new ArrayList<>();
for (CheckboxWrapper wrapper : wrappers) {
Float editedPoint = null;
if (wrapper.getPointEl() != null) {
String val = wrapper.getPointEl().getValue();
if (StringHelper.containsNonWhitespace(val)) {
try {
editedPoint = new Float(val);
} catch (NumberFormatException e) {
editedPoint = null;
}
}
}
boolean editedValue = wrapper.getCheckboxEl().isAtLeastSelected(1);
Float currentPoint = null;
boolean currentValue = false;
if (wrapper.getCheck() != null) {
currentPoint = wrapper.getCheck().getScore();
Boolean checkObj = wrapper.getCheck().getChecked();
if (checkObj != null && checkObj.booleanValue()) {
currentValue = checkObj.booleanValue();
}
}
if ((editedValue != currentValue) || ((currentPoint == null && editedPoint != null) || (currentPoint != null && editedPoint == null) || (currentPoint != null && !currentPoint.equals(editedPoint)))) {
String boxId = wrapper.getCheckbox().getCheckboxId();
batchElements.add(new AssessmentBatch(assessedIdentity.getKey(), boxId, editedPoint, editedValue));
}
}
checkboxManager.check(courseOres, courseNode.getIdent(), batchElements);
courseNode.updateScoreEvaluation(getIdentity(), assessedUserCourseEnv, assessedIdentity, Role.coach);
}
Aggregations