use of org.olat.modules.portfolio.AssessmentSection in project openolat by klemens.
the class AbstractPageListController method forgePageRow.
protected PortfolioElementRow forgePageRow(UserRequest ureq, Page page, AssessmentSection assessmentSection, List<Assignment> assignments, Map<OLATResourceable, List<Category>> categorizedElementMap, Map<Long, Long> numberOfCommentsMap, boolean selectElement) {
Section section = page.getSection();
PortfolioElementRow row = new PortfolioElementRow(page, assessmentSection, config.isAssessable());
String openLinkId = "open_" + (++counter);
FormLink openLink = uifactory.addFormLink(openLinkId, "open.full", "open.full.page", null, flc, Link.BUTTON_SMALL);
openLink.setIconRightCSS("o_icon o_icon_start");
openLink.setEnabled(selectElement);
openLink.setPrimary(true);
row.setOpenFormLink(openLink);
openLink.setUserObject(row);
addCategoriesToRow(row, categorizedElementMap);
if (assignments != null) {
for (Assignment assignment : assignments) {
if (page.equals(assignment.getPage())) {
row.setAssignment(assignment);
}
}
}
decorateImage(ureq, row, page);
if (numberOfCommentsMap != null) {
Long numOfComments = numberOfCommentsMap.get(page.getKey());
if (numOfComments != null) {
row.setNumOfComments(numOfComments.longValue());
} else {
row.setNumOfComments(0);
}
} else {
row.setNumOfComments(0);
}
if (secCallback.canCloseSection(section)) {
if (SectionStatus.isClosed(section)) {
FormLink reopenLink = uifactory.addFormLink("ropens_" + (++counter), "reopen.section", "reopen.section", null, flc, Link.BUTTON_SMALL);
reopenLink.setUserObject(row);
row.setReopenSectionLink(reopenLink);
} else {
FormLink closeLink = uifactory.addFormLink("closes_" + (++counter), "close.section", "close.section", null, flc, Link.BUTTON_SMALL);
closeLink.setUserObject(row);
row.setCloseSectionLink(closeLink);
}
}
if (portfolioV2Module.isEntriesCommentsEnabled() && secCallback.canComment(page)) {
String title;
String cssClass = "o_icon o_icon-fw o_icon_comments";
if (row.getNumOfComments() == 1) {
title = translate("comment.one");
} else if (row.getNumOfComments() > 1) {
title = translate("comment.several", new String[] { Long.toString(row.getNumOfComments()) });
} else {
title = translate("comment.zero");
cssClass += "_none";
}
FormLink commentLink = uifactory.addFormLink("com_" + (++counter), "comment", title, null, flc, Link.LINK | Link.NONTRANSLATED);
commentLink.setIconLeftCSS(cssClass);
commentLink.setUserObject(row);
row.setCommentFormLink(commentLink);
}
return row;
}
use of org.olat.modules.portfolio.AssessmentSection in project openolat by klemens.
the class BinderAssessmentController method loadModel.
private void loadModel() {
List<AssessmentSection> aSections = portfolioService.getAssessmentSections(binder, null);
Map<Section, AssessmentSection> aSectionsMap = new HashMap<>();
for (AssessmentSection aSection : aSections) {
aSectionsMap.put(aSection.getSection(), aSection);
}
// binder done only is an owner is present
// and all owners have done the binder
boolean binderDone = false;
List<Identity> assessedIdentities = portfolioService.getMembers(binder, PortfolioRoles.owner.name());
int countDone = 0;
for (Identity assessedIdentity : assessedIdentities) {
AssessmentEntryStatus status = portfolioService.getAssessmentStatus(assessedIdentity, binder);
if (status == AssessmentEntryStatus.done) {
countDone++;
}
}
binderDone = (countDone > 0 && countDone == assessedIdentities.size());
boolean allClosed = true;
List<Section> sections = portfolioService.getSections(binder);
List<AssessmentSectionWrapper> rows = new ArrayList<>();
Map<Section, AssessmentSectionWrapper> sectionToRows = new HashMap<>();
for (Section section : sections) {
AssessmentSection assessmentSection = aSectionsMap.get(section);
AssessmentSectionWrapper row = new AssessmentSectionWrapper(section, assessmentSection);
sectionToRows.put(section, row);
if (secCallback.canViewAssess(section) || secCallback.canAssess(section)) {
rows.add(row);
}
allClosed &= section.getSectionStatus() == SectionStatus.closed;
}
List<Page> pages = portfolioService.getPages(binder, null);
for (Page page : pages) {
AssessmentSectionWrapper row = sectionToRows.get(page.getSection());
if (row != null) {
row.setNumOfPages(row.getNumOfPages() + 1);
}
}
boolean allowedToAssess = false;
boolean allowedToAssessBinder = secCallback.canAssess(binder);
for (AssessmentSectionWrapper row : rows) {
boolean canAssess = secCallback.canAssess(row.getSection());
if (canAssess && !binderDone) {
forgeAssessmentSection(row);
allowedToAssess = true;
}
}
reopenLink.setVisible(allowedToAssessBinder && binderDone);
saveAndDoneLink.setVisible(allowedToAssessBinder && !binderDone && allClosed);
saveButton.setVisible(allowedToAssess);
cancelButton.setVisible(allowedToAssess);
model.setObjects(rows);
tableEl.reset();
tableEl.reloadData();
}
use of org.olat.modules.portfolio.AssessmentSection in project openolat by klemens.
the class BinderAssessmentController method validateFormLogic.
@Override
protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = true;
flc.contextRemove("scoreError");
if (withScore && (maxScore != null || minScore != null)) {
double scoreTotal = 0.0d;
Set<Section> visibleSections = new HashSet<>();
List<AssessmentSectionWrapper> rows = model.getObjects();
for (AssessmentSectionWrapper row : rows) {
BigDecimal score = row.getScore();
if (row.getScoreEl() != null) {
String value = row.getScoreEl().getValue();
if (StringHelper.containsNonWhitespace(value)) {
score = new BigDecimal(value);
}
}
if (score != null) {
scoreTotal += score.doubleValue();
}
visibleSections.add(row.getSection());
}
// add score of other sections
List<AssessmentSection> assessmentSections = portfolioService.getAssessmentSections(binder, null);
for (AssessmentSection assessmentSection : assessmentSections) {
if (!visibleSections.contains(assessmentSection.getSection()) && assessmentSection.getScore() != null) {
scoreTotal += assessmentSection.getScore().doubleValue();
}
}
if (maxScore != null && (maxScore.doubleValue() < scoreTotal)) {
flc.contextPut("scoreError", translate("error.score", new String[] { "0", AssessmentHelper.getRoundedScore(maxScore), displayname }));
allOk &= false;
} else if (minScore != null && (minScore.doubleValue() > scoreTotal)) {
flc.contextPut("scoreError", translate("error.score", new String[] { "0", AssessmentHelper.getRoundedScore(maxScore), displayname }));
allOk &= false;
}
}
return allOk & super.validateFormLogic(ureq);
}
use of org.olat.modules.portfolio.AssessmentSection in project openolat by klemens.
the class BinderAssessmentController method forgeAssessmentSection.
private void forgeAssessmentSection(AssessmentSectionWrapper row) {
AssessmentSection assessmentSection = row.getAssessmentSection();
Section section = row.getSection();
if (!SectionStatus.isClosed(section)) {
// score
String pointVal = null;
if (assessmentSection != null && assessmentSection.getScore() != null) {
BigDecimal score = assessmentSection.getScore();
pointVal = AssessmentHelper.getRoundedScore(score);
}
TextElement pointEl = uifactory.addTextElement("point" + (++counter), null, 5, pointVal, flc);
pointEl.setDisplaySize(5);
row.setScoreEl(pointEl);
// passed
Boolean passed = assessmentSection == null ? null : assessmentSection.getPassed();
MultipleSelectionElement passedEl = uifactory.addCheckboxesHorizontal("check" + (++counter), null, flc, onKeys, onValues);
if (passed != null && passed.booleanValue()) {
passedEl.select(onKeys[0], passed.booleanValue());
}
row.setPassedEl(passedEl);
}
if (SectionStatus.isClosed(section)) {
FormLink reopenButton = uifactory.addFormLink("reopen" + (++counter), "reopen", "reopen", null, flc, Link.BUTTON);
reopenButton.setElementCssClass("o_sel_pf_reopen_section");
reopenButton.setUserObject(row);
row.setButton(reopenButton);
} else {
FormLink closeButton = uifactory.addFormLink("close" + (++counter), "close", "close.section", null, flc, Link.BUTTON);
closeButton.setElementCssClass("o_sel_pf_close_section");
closeButton.setUserObject(row);
row.setButton(closeButton);
}
}
use of org.olat.modules.portfolio.AssessmentSection in project openolat by klemens.
the class BinderOnePageController method loadSection.
private void loadSection(Section section) {
String id = "section_" + (++counter);
VelocityContainer rowVC = createVelocityContainer(id, "portfolio_element_row");
AssessmentSection assessmentSection = null;
PortfolioElementRow row = new PortfolioElementRow(section, assessmentSection, false, false);
rowVC.contextPut("row", row);
rowVC.contextPut("rowIndex", 0);
mainVC.put(id, rowVC);
components.add(id);
}
Aggregations