use of org.olat.course.nodes.cl.model.Checkbox in project openolat by klemens.
the class CheckListRunController method doCheck.
private boolean doCheck(UserRequest ureq, CheckboxWrapper wrapper, boolean checked) {
DBCheckbox theOne;
if (wrapper.getDbCheckbox() == null) {
String uuid = wrapper.getCheckbox().getCheckboxId();
theOne = checkboxManager.loadCheckbox(courseOres, courseNode.getIdent(), uuid);
} else {
theOne = wrapper.getDbCheckbox();
}
if (theOne == null) {
// only warning because this happen in course preview
logWarn("A checkbox is missing: " + courseOres + " / " + courseNode.getIdent(), null);
} else {
Float score;
if (checked) {
score = wrapper.getCheckbox().getPoints();
} else {
score = 0f;
}
checkboxManager.check(theOne, getIdentity(), score, Boolean.valueOf(checked));
// make sure all results is on the database before calculating some scores
// manager commit already
courseNode.updateScoreEvaluation(getIdentity(), userCourseEnv, getIdentity(), Role.user);
Checkbox checkbox = wrapper.getCheckbox();
logUpdateCheck(checkbox.getCheckboxId(), checkbox.getTitle());
}
exposeUserDataToVC(ureq, flc);
return courseNode.hasScoreConfigured() || courseNode.hasPassedConfigured();
}
use of org.olat.course.nodes.cl.model.Checkbox in project openolat by klemens.
the class CheckListRunController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
boolean readOnly = isReadOnly();
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("readOnly", Boolean.valueOf(readOnly));
if (dueDate != null) {
layoutCont.contextPut("dueDate", dueDate);
layoutCont.contextPut("in-due-date", isPanelOpen(ureq, "due-date", true));
if (dueDate.compareTo(new Date()) < 0) {
layoutCont.contextPut("afterDueDate", Boolean.TRUE);
}
}
layoutCont.contextPut("withScore", new Boolean(withScore));
if (courseNode.getModuleConfiguration().getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD, false)) {
HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, courseNode, this.mainForm);
if (highScoreCtr.isViewHighscore()) {
Component highScoreComponent = highScoreCtr.getInitialComponent();
layoutCont.put("highScore", highScoreComponent);
}
}
List<DBCheck> checks = checkboxManager.loadCheck(getIdentity(), courseOres, courseNode.getIdent());
Map<String, DBCheck> uuidToCheckMap = new HashMap<>();
for (DBCheck check : checks) {
uuidToCheckMap.put(check.getCheckbox().getCheckboxId(), check);
}
List<Checkbox> list = checkboxList.getList();
List<CheckboxWrapper> wrappers = new ArrayList<>(list.size());
for (Checkbox checkbox : list) {
DBCheck check = uuidToCheckMap.get(checkbox.getCheckboxId());
CheckboxWrapper wrapper = forgeCheckboxWrapper(checkbox, check, readOnly, formLayout);
layoutCont.add(wrapper.getCheckboxEl());
wrappers.add(wrapper);
}
layoutCont.contextPut("checkboxList", wrappers);
if (withScore || withPassed) {
layoutCont.contextPut("enableScoreInfo", Boolean.TRUE);
exposeConfigToVC(ureq, layoutCont);
exposeUserDataToVC(ureq, layoutCont);
} else {
layoutCont.contextPut("enableScoreInfo", Boolean.FALSE);
}
}
}
use of org.olat.course.nodes.cl.model.Checkbox in project openolat by klemens.
the class CheckboxAssessmentController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (checkboxEl == source) {
int nextCheckboxIndex = checkboxEl.getSelected();
saveCurrentSelectCheckbox();
Checkbox box = checkboxList.getList().get(nextCheckboxIndex);
boolean hasPoints = box.getPoints() != null && box.getPoints().floatValue() > 0f;
List<CheckboxAssessmentRow> rows = model.getObjects();
for (CheckboxAssessmentRow row : rows) {
Boolean[] checkedArr = row.getChecked();
if (checkedArr[nextCheckboxIndex] != null && checkedArr[nextCheckboxIndex].booleanValue()) {
row.getCheckedEl().select(onKeys[0], true);
} else {
row.getCheckedEl().select(onKeys[0], false);
}
Float[] scores = row.getScores();
if (scores[nextCheckboxIndex] != null && scores[nextCheckboxIndex] != null) {
row.getPointEl().setValue(AssessmentHelper.getRoundedScore(scores[nextCheckboxIndex]));
} else {
row.getPointEl().setValue("");
}
row.getPointEl().setVisible(hasPoints);
}
currentCheckboxIndex = nextCheckboxIndex;
} else if (source instanceof MultipleSelectionElement) {
MultipleSelectionElement checkEl = (MultipleSelectionElement) source;
if (checkEl.getUserObject() instanceof CheckboxAssessmentRow) {
CheckboxAssessmentRow row = (CheckboxAssessmentRow) checkEl.getUserObject();
if (row.getPointEl().isVisible()) {
boolean checked = checkEl.isAtLeastSelected(1);
if (checked) {
int nextCheckboxIndex = checkboxEl.getSelected();
Checkbox box = checkboxList.getList().get(nextCheckboxIndex);
String pointVal = AssessmentHelper.getRoundedScore(box.getPoints());
row.getPointEl().setValue(pointVal);
} else {
row.getPointEl().setValue("");
}
}
}
} else if (selectAllBoxButton == source) {
doSelectAll();
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.course.nodes.cl.model.Checkbox in project openolat by klemens.
the class CheckboxManagerImpl method syncCheckbox.
@Override
public void syncCheckbox(CheckboxList checkboxList, OLATResourceable ores, String resSubPath) {
List<DBCheckbox> dbCheckboxList = loadCheckbox(ores, resSubPath);
Map<String, DBCheckbox> uuids = new HashMap<String, DBCheckbox>();
for (DBCheckbox dbCheckbox : dbCheckboxList) {
uuids.put(dbCheckbox.getCheckboxId(), dbCheckbox);
}
if (checkboxList != null && checkboxList.getList() != null) {
List<Checkbox> resCheckboxList = checkboxList.getList();
for (Checkbox resCheckbox : resCheckboxList) {
String resUuid = resCheckbox.getCheckboxId();
if (uuids.containsKey(resUuid)) {
// already synched
uuids.remove(resUuid);
} else {
createDBCheckbox(resUuid, ores, resSubPath);
}
}
}
for (DBCheckbox dbCheckbox : uuids.values()) {
System.out.println("Remove them??? " + dbCheckbox.getCheckboxId());
}
}
use of org.olat.course.nodes.cl.model.Checkbox in project openolat by klemens.
the class AssessedIdentityCheckListController method doUpdateCheck.
private void doUpdateCheck(CheckboxWrapper wrapper, boolean check) {
// nothing to do
if (wrapper.getPointEl() == null)
return;
if (check) {
if (!StringHelper.containsNonWhitespace(wrapper.getPointEl().getValue())) {
Checkbox checkbox = wrapper.getCheckbox();
Float points = checkbox.getPoints();
if (points != null) {
String val = AssessmentHelper.getRoundedScore(points);
wrapper.getPointEl().setValue(val);
}
}
} else if (wrapper.getPointEl() != null) {
wrapper.getPointEl().setValue("");
}
// hide when not yet checked
wrapper.getPointEl().setVisible(check);
}
Aggregations