use of org.olat.modules.portfolio.AssessmentSection in project openolat by klemens.
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 klemens.
the class AssessmentSectionDAOTest method createAssessmentSection.
@Test
public void createAssessmentSection() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("aowner-1");
// create a binder with a section
Binder binder = portfolioService.createNewBinder("ABinder", "Assessment on binder", null, owner);
dbInstance.commit();
portfolioService.appendNewSection("Section", "Coached section", null, null, binder);
dbInstance.commit();
List<Section> sections = portfolioService.getSections(binder);
// create the assessment point
Boolean passed = Boolean.TRUE;
Section section = sections.get(0);
BigDecimal score = new BigDecimal("3.5");
AssessmentSection assessmentSection = assessmentSectionDao.createAssessmentSection(score, passed, section, owner);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(assessmentSection);
Assert.assertNotNull(assessmentSection.getKey());
Assert.assertNotNull(assessmentSection.getCreationDate());
Assert.assertNotNull(assessmentSection.getLastModified());
Assert.assertEquals(section, assessmentSection.getSection());
Assert.assertEquals(passed, assessmentSection.getPassed());
Assert.assertEquals(score, assessmentSection.getScore());
// reload the assessment point
AssessmentSection reloadedAssessmentSection = assessmentSectionDao.loadByKey(assessmentSection.getKey());
Assert.assertNotNull(reloadedAssessmentSection);
Assert.assertEquals(assessmentSection, reloadedAssessmentSection);
}
use of org.olat.modules.portfolio.AssessmentSection in project openolat by klemens.
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 PublishController method reloadData.
public void reloadData() {
binderRow.getChildren().clear();
binderRow.getAccessRights().clear();
List<AccessRights> rights = portfolioService.getAccessRights(binder);
boolean canEditBinderAccessRights = secCallback.canEditAccessRights(binder);
for (AccessRights right : rights) {
if (right.getSectionKey() == null && right.getPageKey() == null) {
if (PortfolioRoles.invitee.equals(right.getRole())) {
// only access
continue;
}
Link editLink = null;
if (canEditBinderAccessRights && !PortfolioRoles.owner.equals(right.getRole())) {
String id = "edit_" + (counter++);
editLink = LinkFactory.createLink(id, id, "edit_access", "edit", getTranslator(), mainVC, this, Link.LINK);
}
binderRow.getAccessRights().add(new AccessRightsRow(binder, right, editLink));
}
}
List<AssessmentSection> assessmentSections = portfolioService.getAssessmentSections(binder, getIdentity());
Map<Section, AssessmentSection> sectionToAssessmentSectionMap = new HashMap<>();
for (AssessmentSection assessmentSection : assessmentSections) {
sectionToAssessmentSectionMap.put(assessmentSection.getSection(), assessmentSection);
}
// sections
List<Section> sections = portfolioService.getSections(binder);
Map<Long, PortfolioElementRow> sectionMap = new HashMap<>();
for (Section section : sections) {
boolean canEditSectionAccessRights = secCallback.canEditAccessRights(section);
boolean canViewSectionAccessRights = secCallback.canViewAccessRights(section);
if (canEditSectionAccessRights || canViewSectionAccessRights) {
PortfolioElementRow sectionRow = new PortfolioElementRow(section, sectionToAssessmentSectionMap.get(section));
binderRow.getChildren().add(sectionRow);
sectionMap.put(section.getKey(), sectionRow);
for (AccessRights right : rights) {
if (section.getKey().equals(right.getSectionKey()) && right.getPageKey() == null) {
Link editLink = null;
if (canEditSectionAccessRights && !PortfolioRoles.owner.equals(right.getRole())) {
String id = "edit_" + (counter++);
editLink = LinkFactory.createLink(id, id, "edit_access", "edit", getTranslator(), mainVC, this, Link.LINK);
sectionRow.getAccessRights().add(new AccessRightsRow(section, right, editLink));
}
}
}
}
}
// pages
List<Page> pages = portfolioService.getPages(binder, null);
for (Page page : pages) {
boolean canEditPageAccessRights = secCallback.canEditAccessRights(page);
boolean canViewPageAccessRights = secCallback.canViewAccessRights(page);
if (canEditPageAccessRights || canViewPageAccessRights) {
Section section = page.getSection();
PortfolioElementRow sectionRow = sectionMap.get(section.getKey());
if (sectionRow == null) {
logError("Section not found: " + section.getKey() + " of page: " + page.getKey(), null);
continue;
}
PortfolioElementRow pageRow = new PortfolioElementRow(page, null);
sectionRow.getChildren().add(pageRow);
for (AccessRights right : rights) {
if (page.getKey().equals(right.getPageKey())) {
Link editLink = null;
if (canEditPageAccessRights && !PortfolioRoles.owner.equals(right.getRole())) {
String id = "edit_" + (counter++);
editLink = LinkFactory.createLink(id, id, "edit_access", "edit", getTranslator(), mainVC, this, Link.LINK);
pageRow.getAccessRights().add(new AccessRightsRow(page, right, editLink));
}
}
}
}
}
mainVC.setDirty(true);
}
use of org.olat.modules.portfolio.AssessmentSection in project OpenOLAT by OpenOLAT.
the class AbstractPageListController method forgeSectionRow.
protected PortfolioElementRow forgeSectionRow(Section section, AssessmentSection assessmentSection, List<Assignment> assignments, Map<OLATResourceable, List<Category>> categorizedElementMap) {
PortfolioElementRow row = new PortfolioElementRow(section, assessmentSection, config.isAssessable(), (assignments != null && assignments.size() > 0));
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.setPrimary(true);
row.setOpenFormLink(openLink);
openLink.setUserObject(row);
addCategoriesToRow(row, categorizedElementMap);
if (assignments != null && secCallback.canViewPendingAssignments(section) && secCallback.canInstantiateAssignment()) {
List<Assignment> startableAssignments = assignments.stream().filter(ass -> ass.getAssignmentStatus() == AssignmentStatus.notStarted).filter(ass -> ass.getPage() == null).collect(Collectors.toList());
if (!startableAssignments.isEmpty()) {
String[] keys = new String[startableAssignments.size() + 1];
String[] values = new String[startableAssignments.size() + 1];
keys[0] = "start.assignment.hint";
values[0] = translate("start.assignment.hint");
int count = 1;
for (Assignment assignment : startableAssignments) {
keys[count] = Long.toString(assignment.getKey());
values[count] = assignment.getTitle();
count++;
}
SingleSelection startEl = uifactory.addDropdownSingleselect("assignments_" + (++counter), "", flc, keys, values, null);
startEl.setDomReplacementWrapperRequired(false);
startEl.addActionListener(FormEvent.ONCHANGE);
row.setStartSelection(startEl);
}
}
return row;
}
Aggregations