Search in sources :

Example 6 with Assignment

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

the class PortfolioServiceImpl method deleteAssignment.

@Override
public boolean deleteAssignment(Assignment assignment) {
    Assignment reloadedAssignment = assignmentDao.loadAssignmentByKey(assignment.getKey());
    Section reloadedSection = reloadedAssignment.getSection();
    boolean removed = false;
    if (reloadedSection != null) {
        removed = ((SectionImpl) reloadedSection).getAssignments().remove(reloadedAssignment);
    }
    assignmentDao.deleteAssignment(reloadedAssignment);
    if (removed) {
        binderDao.updateSection(reloadedSection);
    }
    return true;
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) SectionImpl(org.olat.modules.portfolio.model.SectionImpl) AssessmentSectionImpl(org.olat.modules.portfolio.model.AssessmentSectionImpl)

Example 7 with Assignment

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

the class PortfolioServiceImpl method startAssignment.

@Override
public Assignment startAssignment(Long assignmentKey, Identity author) {
    Assignment reloadedAssignment = assignmentDao.loadAssignmentByKey(assignmentKey);
    if (reloadedAssignment.getPage() == null) {
        Section section = reloadedAssignment.getSection();
        if (reloadedAssignment.getAssignmentType() == AssignmentType.essay || reloadedAssignment.getAssignmentType() == AssignmentType.document) {
            Page page = appendNewPage(author, reloadedAssignment.getTitle(), reloadedAssignment.getSummary(), null, null, section);
            reloadedAssignment = assignmentDao.startEssayAssignment(reloadedAssignment, page, author);
        } else if (reloadedAssignment.getAssignmentType() == AssignmentType.form) {
            RepositoryEntry formEntry = reloadedAssignment.getFormEntry();
            Page page = appendNewPage(author, reloadedAssignment.getTitle(), reloadedAssignment.getSummary(), null, false, null, section);
            reloadedAssignment = assignmentDao.startFormAssignment(reloadedAssignment, page, author);
            // create the session for the assignee
            evaluationFormSessionDao.createSessionForPortfolio(author, page.getBody(), formEntry);
        }
    }
    dbInstance.commit();
    ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_ASSIGNMENT_STARTED, getClass(), LoggingResourceable.wrap(reloadedAssignment.getSection()), LoggingResourceable.wrap(reloadedAssignment));
    return reloadedAssignment;
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

Example 8 with Assignment

use of org.olat.modules.portfolio.Assignment 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 9 with Assignment

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

the class AssignmentDAO method moveDownAssignment.

public Section moveDownAssignment(SectionImpl section, Assignment assignment) {
    section.getAssignments().size();
    int index = section.getAssignments().indexOf(assignment);
    if (index >= 0 && index + 1 < section.getAssignments().size()) {
        Assignment reloadedAssignment = section.getAssignments().remove(index);
        section.getAssignments().add(index + 1, reloadedAssignment);
        section = dbInstance.getCurrentEntityManager().merge(section);
    }
    return section;
}
Also used : Assignment(org.olat.modules.portfolio.Assignment)

Example 10 with Assignment

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

the class AssignmentDAO method moveUpAssignment.

public Section moveUpAssignment(SectionImpl section, Assignment assignment) {
    section.getAssignments().size();
    int index = section.getAssignments().indexOf(assignment);
    if (index > 0) {
        Assignment reloadedAssigment = section.getAssignments().remove(index);
        section.getAssignments().add(index - 1, reloadedAssigment);
    } else if (index < 0) {
        section.getAssignments().add(0, assignment);
    }
    section = dbInstance.getCurrentEntityManager().merge(section);
    return section;
}
Also used : Assignment(org.olat.modules.portfolio.Assignment)

Aggregations

Assignment (org.olat.modules.portfolio.Assignment)78 Section (org.olat.modules.portfolio.Section)48 Binder (org.olat.modules.portfolio.Binder)30 Identity (org.olat.core.id.Identity)28 Test (org.junit.Test)26 Page (org.olat.modules.portfolio.Page)26 ArrayList (java.util.ArrayList)24 RepositoryEntry (org.olat.repository.RepositoryEntry)20 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)18 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)18 SectionRef (org.olat.modules.portfolio.SectionRef)16 File (java.io.File)8 HashMap (java.util.HashMap)8 List (java.util.List)8 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 SectionImpl (org.olat.modules.portfolio.model.SectionImpl)8 PortfolioElementRow (org.olat.modules.portfolio.ui.model.PortfolioElementRow)8 Link (org.olat.core.gui.components.link.Link)6