use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.
the class CheckboxPDFExport method create.
public void create(CheckboxList checkboxList, List<CheckListAssessmentRow> rows) throws IOException, COSVisitorException, TransformerException {
addPage();
addMetadata(courseNodeTitle, courseTitle, author);
if (StringHelper.containsNonWhitespace(courseTitle)) {
addParagraph(courseTitle, 16, true, width);
}
if (StringHelper.containsNonWhitespace(courseNodeTitle)) {
addParagraph(courseNodeTitle, 14, true, width);
}
if (StringHelper.containsNonWhitespace(groupName)) {
String prefix = translator.translate("participants");
addParagraph(prefix + ": " + groupName, 14, true, width);
}
float cellMargin = 5.0f;
float headerMaxSize = 0.0f;
float fontSize = 10.0f;
for (Checkbox box : checkboxList.getList()) {
headerMaxSize = Math.max(headerMaxSize, getStringWidth(box.getTitle(), fontSize));
}
String[] headers = getHeaders(checkboxList);
String[][] content = getRows(checkboxList, rows);
float nameMaxSize = 0.0f;
for (String[] row : content) {
float nameWidth = getStringWidth(row[0], fontSize);
nameMaxSize = Math.max(nameMaxSize, nameWidth);
}
nameMaxSize = Math.min(nameMaxSize, 150f);
int numOfRows = content.length;
for (int offset = 0; offset < numOfRows; ) {
offset += drawTable(headers, content, offset, headerMaxSize, nameMaxSize, fontSize, cellMargin);
closePage();
if (offset < numOfRows) {
addPage();
}
}
addPageNumbers();
}
use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.
the class CheckListAssessmentController method loadDatas.
private List<CheckListAssessmentRow> loadDatas() {
if (!(coachCourseEnv instanceof UserCourseEnvironmentImpl)) {
return Collections.emptyList();
}
UserCourseEnvironmentImpl env = (UserCourseEnvironmentImpl) coachCourseEnv;
List<Checkbox> checkboxColl = checkboxList.getList();
int numOfCheckbox = checkboxList.getNumOfCheckbox();
boolean courseAdmin = env.isAdmin();
RepositoryEntry re = env.getCourseRepositoryEntry();
boolean courseTutor = repositoryService.hasRole(getIdentity(), re, GroupRoles.coach.name());
Set<Long> missingIdentityKeys = new HashSet<>();
if (courseTutor || courseAdmin) {
List<RepositoryEntryMembership> repoMemberships = repositoryManager.getRepositoryEntryMembership(re);
for (RepositoryEntryMembership repoMembership : repoMemberships) {
if (repoMembership.isParticipant()) {
missingIdentityKeys.add(repoMembership.getIdentityKey());
}
}
}
List<BusinessGroup> coachedGroups = courseAdmin ? coachCourseEnv.getCourseEnvironment().getCourseGroupManager().getAllBusinessGroups() : env.getCoachedGroups();
List<AssessmentData> dataList = checkboxManager.getAssessmentDatas(courseOres, courseNode.getIdent(), courseTutor || courseAdmin ? re : null, coachedGroups);
List<CheckListAssessmentRow> boxList = getAssessmentDataViews(dataList, checkboxColl);
Map<Long, CheckListAssessmentRow> identityToView = new HashMap<>();
for (CheckListAssessmentRow box : boxList) {
identityToView.put(box.getIdentityKey(), box);
missingIdentityKeys.remove(box.getIdentityKey());
}
List<BusinessGroupMembership> memberships = businessGroupService.getBusinessGroupsMembership(coachedGroups);
for (BusinessGroupMembership membership : memberships) {
if (!membership.isParticipant())
continue;
Long identityKey = membership.getIdentityKey();
if (!identityToView.containsKey(identityKey)) {
missingIdentityKeys.add(identityKey);
}
}
List<Identity> missingIdentities = securityManager.loadIdentityByKeys(missingIdentityKeys);
for (Identity missingIdentity : missingIdentities) {
Boolean[] checked = new Boolean[numOfCheckbox];
Float[] scores = new Float[numOfCheckbox];
CheckListAssessmentRow view = new CheckListAssessmentRow(missingIdentity, checked, scores, null, userPropertyHandlers, getLocale());
identityToView.put(missingIdentity.getKey(), view);
}
for (BusinessGroupMembership membership : memberships) {
if (!membership.isParticipant())
continue;
CheckListAssessmentRow view = identityToView.get(membership.getIdentityKey());
if (view != null) {
view.addGroupKey(membership.getGroupKey());
}
}
List<CheckListAssessmentRow> views = new ArrayList<>();
views.addAll(identityToView.values());
return views;
}
use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.
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++;
}
}
}
}
}
use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class CheckboxListStepController method updateModel.
private void updateModel() {
List<Checkbox> boxList = data.getCheckboxList();
List<CheckboxConfigRow> rows = new ArrayList<>();
for (Checkbox box : boxList) {
rows.add(new CheckboxConfigRow(box, null));
}
model.setObjects(rows);
boxTable.reset();
}
Aggregations