Search in sources :

Example 11 with AssessmentSection

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);
    }
}
Also used : HashMap(java.util.HashMap) AssessmentSectionChange(org.olat.modules.portfolio.model.AssessmentSectionChange) Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) AssessmentSectionImpl(org.olat.modules.portfolio.model.AssessmentSectionImpl) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) ArrayList(java.util.ArrayList) List(java.util.List) Identity(org.olat.core.id.Identity) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 12 with AssessmentSection

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);
}
Also used : Binder(org.olat.modules.portfolio.Binder) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Identity(org.olat.core.id.Identity) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 13 with AssessmentSection

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);
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) AbstractPageListController(org.olat.modules.portfolio.ui.AbstractPageListController) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 14 with AssessmentSection

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);
}
Also used : HashMap(java.util.HashMap) Page(org.olat.modules.portfolio.Page) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) AccessRights(org.olat.modules.portfolio.model.AccessRights) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Link(org.olat.core.gui.components.link.Link)

Example 15 with AssessmentSection

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;
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) Assignment(org.olat.modules.portfolio.Assignment) FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) PortfolioV2Module(org.olat.modules.portfolio.PortfolioV2Module) TimelineElement(org.olat.modules.portfolio.ui.component.TimelineElement) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) Autowired(org.springframework.beans.factory.annotation.Autowired) ThreadLocalUserActivityLogger(org.olat.core.logging.activity.ThreadLocalUserActivityLogger) PageRemovedEvent(org.olat.modules.portfolio.ui.event.PageRemovedEvent) MediaResource(org.olat.core.gui.media.MediaResource) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) OLATResourceable(org.olat.core.id.OLATResourceable) StatusCellRenderer(org.olat.modules.portfolio.ui.renderer.StatusCellRenderer) BinderConfiguration(org.olat.modules.portfolio.BinderConfiguration) Category(org.olat.modules.portfolio.Category) OresHelper(org.olat.core.util.resource.OresHelper) Assignment(org.olat.modules.portfolio.Assignment) Map(java.util.Map) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) SectionStatus(org.olat.modules.portfolio.SectionStatus) AssignmentStatus(org.olat.modules.portfolio.AssignmentStatus) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) Page(org.olat.modules.portfolio.Page) CommentAndRatingDefaultSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) PortfolioLoggingAction(org.olat.modules.portfolio.PortfolioLoggingAction) WindowControl(org.olat.core.gui.control.WindowControl) FlexiTableRendererType(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableRendererType) Set(java.util.Set) AssignmentType(org.olat.modules.portfolio.AssignmentType) Component(org.olat.core.gui.components.Component) Collectors(java.util.stream.Collectors) Mapper(org.olat.core.dispatcher.mapper.Mapper) DefaultFlexiTableCssDelegate(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiTableCssDelegate) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) PortfolioElementCellRenderer(org.olat.modules.portfolio.ui.renderer.PortfolioElementCellRenderer) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) UserCommentsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsController) TooledController(org.olat.core.gui.components.stack.TooledController) LoggingResourceable(org.olat.util.logging.activity.LoggingResourceable) ImageComponent(org.olat.core.gui.components.image.ImageComponent) SharedPageStatusCellRenderer(org.olat.modules.portfolio.ui.renderer.SharedPageStatusCellRenderer) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) FileMediaResource(org.olat.core.gui.media.FileMediaResource) Section(org.olat.modules.portfolio.Section) CategoriesCellRenderer(org.olat.modules.portfolio.ui.component.CategoriesCellRenderer) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) PageDeletedEvent(org.olat.modules.portfolio.ui.event.PageDeletedEvent) ReadOnlyCommentsSecurityCallback(org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback) HttpServletRequest(javax.servlet.http.HttpServletRequest) Calendar(java.util.Calendar) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) ContextEntry(org.olat.core.id.context.ContextEntry) StringHelper(org.olat.core.util.StringHelper) StateEntry(org.olat.core.id.context.StateEntry) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) FlexiTableDataModelFactory(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory) PageCols(org.olat.modules.portfolio.ui.PageListDataModel.PageCols) PortfolioService(org.olat.modules.portfolio.PortfolioService) Link(org.olat.core.gui.components.link.Link) FlexiTableComponentDelegate(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableComponentDelegate) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent) Controller(org.olat.core.gui.control.Controller) File(java.io.File) NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) PageImageAlign(org.olat.modules.portfolio.PageImageAlign) DialogBoxUIFactory(org.olat.core.gui.control.generic.modal.DialogBoxUIFactory) UserRequest(org.olat.core.gui.UserRequest) PageStatus(org.olat.modules.portfolio.PageStatus) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Aggregations

AssessmentSection (org.olat.modules.portfolio.AssessmentSection)26 Section (org.olat.modules.portfolio.Section)20 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 PortfolioElementRow (org.olat.modules.portfolio.ui.model.PortfolioElementRow)10 BigDecimal (java.math.BigDecimal)8 List (java.util.List)8 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)8 Identity (org.olat.core.id.Identity)8 Assignment (org.olat.modules.portfolio.Assignment)8 Page (org.olat.modules.portfolio.Page)8 HashSet (java.util.HashSet)6 Map (java.util.Map)6 Link (org.olat.core.gui.components.link.Link)6 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)6 Binder (org.olat.modules.portfolio.Binder)6 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 UserRequest (org.olat.core.gui.UserRequest)4 Component (org.olat.core.gui.components.Component)4