use of org.olat.modules.portfolio.AssessmentSection in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method updateAssessmentSections.
@Override
public void updateAssessmentSections(BinderRef binderRef, List<AssessmentSectionChange> changes, Identity coachingIdentity) {
Binder binder = binderDao.loadByKey(binderRef.getKey());
Map<Identity, List<AssessmentSectionChange>> assessedIdentitiesToChangesMap = new HashMap<>();
for (AssessmentSectionChange change : changes) {
List<AssessmentSectionChange> identityChanges;
if (assessedIdentitiesToChangesMap.containsKey(change.getIdentity())) {
identityChanges = assessedIdentitiesToChangesMap.get(change.getIdentity());
} else {
identityChanges = new ArrayList<>();
assessedIdentitiesToChangesMap.put(change.getIdentity(), identityChanges);
}
identityChanges.add(change);
}
for (Map.Entry<Identity, List<AssessmentSectionChange>> changesEntry : assessedIdentitiesToChangesMap.entrySet()) {
Identity assessedIdentity = changesEntry.getKey();
List<AssessmentSection> currentAssessmentSections = assessmentSectionDao.loadAssessmentSections(binder, assessedIdentity);
Set<AssessmentSection> updatedAssessmentSections = new HashSet<>(currentAssessmentSections);
List<AssessmentSectionChange> identityChanges = changesEntry.getValue();
for (AssessmentSectionChange change : identityChanges) {
AssessmentSection assessmentSection = change.getAssessmentSection();
for (AssessmentSection currentAssessmentSection : currentAssessmentSections) {
if (assessmentSection != null && assessmentSection.equals(currentAssessmentSection)) {
assessmentSection = currentAssessmentSection;
} else if (change.getSection().equals(currentAssessmentSection.getSection())) {
assessmentSection = currentAssessmentSection;
}
}
if (assessmentSection == null) {
assessmentSection = assessmentSectionDao.createAssessmentSection(change.getScore(), change.getPassed(), change.getSection(), assessedIdentity);
} else {
((AssessmentSectionImpl) assessmentSection).setScore(change.getScore());
((AssessmentSectionImpl) assessmentSection).setPassed(change.getPassed());
assessmentSection = assessmentSectionDao.update(assessmentSection);
}
updatedAssessmentSections.add(assessmentSection);
}
updateAssessmentEntry(assessedIdentity, binder, updatedAssessmentSections, coachingIdentity);
}
}
use of org.olat.modules.portfolio.AssessmentSection in project OpenOLAT by OpenOLAT.
the class ExportBinderAsCPResource method exportSection.
private void exportSection(Section section, ZipOutputStream zout) throws IOException {
String pagePath = Util.getPackageVelocityRoot(AbstractPageListController.class) + "/portfolio_element_row.html";
VelocityContainer rowVC = new VelocityContainer("html", pagePath, translator, null);
AssessmentSection assessmentSection = null;
PortfolioElementRow row = new PortfolioElementRow(section, assessmentSection, false, false);
rowVC.contextPut("row", row);
rowVC.contextPut("rowIndex", 0);
String html = createResultHTML(null, rowVC, null, "o_section_export");
convertToZipEntry(zout, sectionFilename(section), html);
}
use of org.olat.modules.portfolio.AssessmentSection in project openolat by klemens.
the class BinderPageListController method loadModel.
@Override
protected void loadModel(UserRequest ureq, String searchString) {
if (StringHelper.containsNonWhitespace(binder.getSummary())) {
summaryComp.setText(binder.getSummary());
flc.getFormItemComponent().put("summary", summaryCtrl.getInitialComponent());
} else {
flc.getFormItemComponent().remove("summary");
}
List<Section> sections = portfolioService.getSections(binder);
List<CategoryToElement> categorizedElements = portfolioService.getCategorizedSectionsAndPages(binder);
Map<OLATResourceable, List<Category>> categorizedElementMap = new HashMap<>();
Map<Section, Set<String>> sectionAggregatedCategoriesMap = new HashMap<>();
for (CategoryToElement categorizedElement : categorizedElements) {
List<Category> categories = categorizedElementMap.get(categorizedElement.getCategorizedResource());
if (categories == null) {
categories = new ArrayList<>();
categorizedElementMap.put(categorizedElement.getCategorizedResource(), categories);
}
categories.add(categorizedElement.getCategory());
}
// comments
Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfComments(binder);
// assessment sections
List<AssessmentSection> assessmentSections = portfolioService.getAssessmentSections(binder, getIdentity());
Map<Section, AssessmentSection> sectionToAssessmentSectionMap = assessmentSections.stream().collect(Collectors.toMap(as -> as.getSection(), as -> as));
List<PortfolioElementRow> rows = new ArrayList<>();
// assignments
List<Assignment> assignments = portfolioService.getAssignments(binder, searchString);
Map<Section, List<Assignment>> sectionToAssignmentMap = new HashMap<>();
for (Assignment assignment : assignments) {
List<Assignment> assignmentList;
Section section = assignment.getSection();
if (sectionToAssignmentMap.containsKey(section)) {
assignmentList = sectionToAssignmentMap.get(section);
} else {
assignmentList = new ArrayList<>();
sectionToAssignmentMap.put(section, assignmentList);
}
assignmentList.add(assignment);
}
for (Assignment assignment : assignments) {
Section section = assignment.getSection();
if (assignment.getPage() == null && secCallback.canViewPendingAssignments(section)) {
List<Assignment> sectionAssignments = sectionToAssignmentMap.get(section);
PortfolioElementRow row = forgePendingAssignmentRow(assignment, section, sectionAssignments);
rows.add(row);
if (secCallback.canAddPage(section)) {
FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
newEntryButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_entry");
newEntryButton.setUserObject(row);
row.setNewEntryLink(newEntryButton);
}
}
}
boolean userInfos = secCallback.canPageUserInfosStatus();
Map<Long, PageUserInformations> userInfosToPage = new HashMap<>();
rowVC.contextPut("userInfos", Boolean.valueOf(userInfos));
if (userInfos) {
rowVC.contextPut("userInfosRenderer", new SharedPageStatusCellRenderer(getTranslator()));
List<PageUserInformations> userInfoList = portfolioService.getPageUserInfos(binder, getIdentity());
for (PageUserInformations userInfo : userInfoList) {
userInfosToPage.put(userInfo.getPage().getKey(), userInfo);
}
}
List<Page> pages = portfolioService.getPages(binder, searchString);
for (Page page : pages) {
boolean viewElement = secCallback.canViewElement(page);
boolean viewTitleElement = viewElement || secCallback.canViewTitleOfElement(page);
if (!viewTitleElement) {
continue;
}
Section section = page.getSection();
PortfolioElementRow pageRow = forgePageRow(ureq, page, sectionToAssessmentSectionMap.get(section), sectionToAssignmentMap.get(section), categorizedElementMap, numberOfCommentsMap, viewElement);
rows.add(pageRow);
if (secCallback.canAddPage(section)) {
FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
newEntryButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_entry");
newEntryButton.setUserObject(pageRow);
pageRow.setNewEntryLink(newEntryButton);
}
if (secCallback.canNewAssignment() && section != null) {
FormLink newAssignmentButton = uifactory.addFormLink("new.assignment." + (++counter), "new.assignment", "create.new.assignment", null, flc, Link.BUTTON);
newAssignmentButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_assignment");
newAssignmentButton.setUserObject(pageRow);
pageRow.setNewAssignmentLink(newAssignmentButton);
}
if (userInfos) {
PageUserInformations infos = userInfosToPage.get(page.getKey());
if (infos != null) {
pageRow.setUserInfosStatus(infos.getStatus());
}
}
if (section != null) {
Set<String> categories = sectionAggregatedCategoriesMap.get(section);
if (categories == null) {
categories = new HashSet<>();
sectionAggregatedCategoriesMap.put(section, categories);
}
if (pageRow.getPageCategories() != null && pageRow.getPageCategories().size() > 0) {
categories.addAll(pageRow.getPageCategories());
}
pageRow.setSectionCategories(categories);
}
}
// sections without pages
if (!StringHelper.containsNonWhitespace(searchString)) {
for (Section section : sections) {
if (!secCallback.canViewElement(section)) {
continue;
}
PortfolioElementRow sectionRow = forgeSectionRow(section, sectionToAssessmentSectionMap.get(section), sectionToAssignmentMap.get(section), categorizedElementMap);
rows.add(sectionRow);
if (secCallback.canAddPage(section)) {
FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
newEntryButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_entry");
newEntryButton.setUserObject(sectionRow);
sectionRow.setNewEntryLink(newEntryButton);
}
if (secCallback.canNewAssignment() && section != null) {
FormLink newAssignmentButton = uifactory.addFormLink("new.assignment." + (++counter), "new.assignment", "create.new.assignment", null, flc, Link.BUTTON);
newAssignmentButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_assignment");
newAssignmentButton.setUserObject(sectionRow);
sectionRow.setNewAssignmentLink(newAssignmentButton);
}
}
}
if (newSectionButton != null && rows.isEmpty()) {
flc.add("create.new.section", newSectionButton);
} else if (newSectionButton != null) {
flc.remove(newSectionButton);
}
if (newEntryLink != null && !newEntryLink.isVisible()) {
newEntryLink.setVisible(rows.size() > 0);
stackPanel.setDirty(true);
}
if (newAssignmentLink != null && !newAssignmentLink.isVisible()) {
newAssignmentLink.setVisible(rows.size() > 0);
stackPanel.setDirty(true);
}
// clean up the posters
disposeRows();
model.setObjects(rows);
if (filteringSection != null) {
doFilterSection(filteringSection);
} else {
tableEl.reloadData();
updateTimeline();
}
}
use of org.olat.modules.portfolio.AssessmentSection in project openolat by klemens.
the class PortfolioServiceImpl method updateAssessmentEntry.
private void updateAssessmentEntry(Identity assessedIdentity, Binder binder, Set<AssessmentSection> assessmentSections, Identity coachingIdentity) {
boolean allPassed = true;
int totalSectionPassed = 0;
int totalSectionClosed = 0;
BigDecimal totalScore = new BigDecimal("0.0");
AssessmentEntryStatus binderStatus = null;
for (AssessmentSection assessmentSection : assessmentSections) {
if (assessmentSection.getScore() != null) {
totalScore = totalScore.add(assessmentSection.getScore());
}
if (assessmentSection.getPassed() != null && assessmentSection.getPassed().booleanValue()) {
allPassed &= true;
totalSectionPassed++;
}
Section section = assessmentSection.getSection();
if (section.getSectionStatus() == SectionStatus.closed) {
totalSectionClosed++;
}
}
Boolean totalPassed = null;
if (totalSectionClosed == assessmentSections.size()) {
totalPassed = new Boolean(allPassed);
} else {
if (assessmentSections.size() == totalSectionPassed) {
totalPassed = Boolean.TRUE;
}
binderStatus = AssessmentEntryStatus.inProgress;
}
// order status from the entry / section
RepositoryEntry entry = binder.getEntry();
if ("CourseModule".equals(entry.getOlatResource().getResourceableTypeName())) {
ICourse course = CourseFactory.loadCourse(entry);
CourseNode courseNode = course.getRunStructure().getNode(binder.getSubIdent());
if (courseNode instanceof PortfolioCourseNode) {
PortfolioCourseNode pfNode = (PortfolioCourseNode) courseNode;
ScoreEvaluation scoreEval = new ScoreEvaluation(totalScore.floatValue(), totalPassed, binderStatus, true, true, null, null, binder.getKey());
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
pfNode.updateUserScoreEvaluation(scoreEval, userCourseEnv, coachingIdentity, false, Role.coach);
}
} else {
OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
assessmentEntry.setScore(totalScore);
assessmentEntry.setPassed(totalPassed);
assessmentEntry.setAssessmentStatus(binderStatus);
assessmentService.updateAssessmentEntry(assessmentEntry);
}
}
use of org.olat.modules.portfolio.AssessmentSection in project openolat by klemens.
the class TableOfContentController method loadModel.
protected void loadModel() {
mainVC.contextPut("binderTitle", StringHelper.escapeHtml(binder.getTitle()));
if (StringHelper.containsNonWhitespace(binder.getSummary())) {
summaryComp.setText(binder.getSummary());
mainVC.put("summary", summaryCtrl.getInitialComponent());
} else {
mainVC.remove("summary");
}
List<SectionRow> sectionRows = new ArrayList<>();
Map<Long, SectionRow> sectionMap = new HashMap<>();
List<AssessmentSection> assessmentSections = portfolioService.getAssessmentSections(binder, getIdentity());
Map<Section, AssessmentSection> sectionToAssessmentSectionMap = new HashMap<>();
for (AssessmentSection assessmentSection : assessmentSections) {
sectionToAssessmentSectionMap.put(assessmentSection.getSection(), assessmentSection);
}
// assignments
List<Assignment> assignments = portfolioService.getAssignments(binder, null);
Map<Section, List<Assignment>> sectionToAssignmentMap = new HashMap<>();
for (Assignment assignment : assignments) {
List<Assignment> assignmentList;
if (sectionToAssignmentMap.containsKey(assignment.getSection())) {
assignmentList = sectionToAssignmentMap.get(assignment.getSection());
} else {
assignmentList = new ArrayList<>();
sectionToAssignmentMap.put(assignment.getSection(), assignmentList);
}
assignmentList.add(assignment);
}
List<Section> sections = portfolioService.getSections(binder);
int count = 0;
for (Section section : sections) {
boolean first = count == 0;
boolean last = count == sections.size() - 1;
count++;
if (secCallback.canViewElement(section)) {
SectionRow sectionRow = forgeSectionRow(section, sectionToAssessmentSectionMap.get(section), sectionToAssignmentMap.get(section), first, last);
sectionRows.add(sectionRow);
sectionMap.put(section.getKey(), sectionRow);
}
}
loadPagesModel(sectionMap);
mainVC.contextPut("sections", sectionRows);
sectionList = sectionRows;
if (secCallback.canAddSection()) {
if (newSectionButton == null) {
newSectionButton = LinkFactory.createButton("create.new.section", mainVC, this);
newSectionButton.setCustomEnabledLinkCSS("btn btn-primary");
}
mainVC.put("create.new.section", newSectionButton);
}
boolean hasSection = (sectionList != null && sectionList.size() > 0);
if (newEntryLink != null && newEntryLink.isVisible() != hasSection) {
newEntryLink.setVisible(hasSection);
stackPanel.setDirty(true);
}
if (newAssignmentLink != null && newAssignmentLink.isVisible() != hasSection) {
newAssignmentLink.setVisible(hasSection);
stackPanel.setDirty(true);
}
}
Aggregations