Search in sources :

Example 1 with AssessmentSection

use of org.olat.modules.portfolio.AssessmentSection in project OpenOLAT by OpenOLAT.

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 2 with AssessmentSection

use of org.olat.modules.portfolio.AssessmentSection in project OpenOLAT by OpenOLAT.

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 3 with AssessmentSection

use of org.olat.modules.portfolio.AssessmentSection in project OpenOLAT by OpenOLAT.

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 4 with AssessmentSection

use of org.olat.modules.portfolio.AssessmentSection in project OpenOLAT by OpenOLAT.

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);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) Assignment(org.olat.modules.portfolio.Assignment) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) List(java.util.List) ArrayList(java.util.ArrayList)

Example 5 with AssessmentSection

use of org.olat.modules.portfolio.AssessmentSection in project OpenOLAT by OpenOLAT.

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)

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