Search in sources :

Example 6 with AssessmentSection

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;
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) Assignment(org.olat.modules.portfolio.Assignment) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

Example 7 with AssessmentSection

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();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Identity(org.olat.core.id.Identity)

Example 8 with AssessmentSection

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);
}
Also used : AssessmentSection(org.olat.modules.portfolio.AssessmentSection) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) BigDecimal(java.math.BigDecimal) HashSet(java.util.HashSet)

Example 9 with AssessmentSection

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);
    }
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) BigDecimal(java.math.BigDecimal)

Example 10 with AssessmentSection

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

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