Search in sources :

Example 36 with Assignment

use of org.olat.modules.portfolio.Assignment in project openolat by klemens.

the class AssignmentDAOTest method createBinderWithAssignment.

@Test
public void createBinderWithAssignment() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("assign-1");
    Binder binder = portfolioService.createNewBinder("Assignment binder 1", "Difficult!", null, owner);
    dbInstance.commit();
    portfolioService.appendNewSection("Section", "Assignment section", null, null, binder);
    dbInstance.commit();
    // create assignment
    List<Section> sections = portfolioService.getSections(binder);
    Assignment assignment = assignmentDao.createAssignment("Difficult", "Very difficult", "The difficult content", null, AssignmentType.essay, AssignmentStatus.template, sections.get(0), false, false, false, null);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(assignment);
    Assert.assertNotNull(assignment.getKey());
    Assert.assertNotNull(assignment.getCreationDate());
    Assert.assertNotNull(assignment.getLastModified());
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) Binder(org.olat.modules.portfolio.Binder) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 37 with Assignment

use of org.olat.modules.portfolio.Assignment in project openolat by klemens.

the class AssignmentDAOTest method loadAssignments_binder.

@Test
public void loadAssignments_binder() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("assign-2");
    Binder binder = portfolioService.createNewBinder("Assignment binder 2", "Difficult!", null, owner);
    dbInstance.commit();
    portfolioService.appendNewSection("Section", "Assignment section", null, null, binder);
    dbInstance.commit();
    // create assignment
    List<Section> sections = portfolioService.getSections(binder);
    Assignment assignment = assignmentDao.createAssignment("Load assignment", "Load by binder", "The difficult content", null, AssignmentType.essay, AssignmentStatus.template, sections.get(0), false, false, false, null);
    dbInstance.commitAndCloseSession();
    // load the assignment
    List<Assignment> assignments = assignmentDao.loadAssignments(binder, null);
    Assert.assertNotNull(assignments);
    Assert.assertEquals(1, assignments.size());
    Assert.assertEquals(assignment, assignments.get(0));
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) Binder(org.olat.modules.portfolio.Binder) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 38 with Assignment

use of org.olat.modules.portfolio.Assignment in project openolat by klemens.

the class AssignmentDAOTest method loadAssignments_section.

@Test
public void loadAssignments_section() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("assign-4");
    Binder binder = portfolioService.createNewBinder("Assignment binder 4", "Difficult!", null, owner);
    dbInstance.commit();
    portfolioService.appendNewSection("Section", "Assignment section", null, null, binder);
    dbInstance.commit();
    // create assignment
    List<Section> sections = portfolioService.getSections(binder);
    Section section = sections.get(0);
    Assignment assignment = assignmentDao.createAssignment("Load assignment", "Load by section", "The another content", null, AssignmentType.essay, AssignmentStatus.template, section, false, false, false, null);
    dbInstance.commitAndCloseSession();
    // load the assignment
    List<Assignment> assignments = assignmentDao.loadAssignments(section, null);
    Assert.assertNotNull(assignments);
    Assert.assertEquals(1, assignments.size());
    Assert.assertEquals(assignment, assignments.get(0));
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) Binder(org.olat.modules.portfolio.Binder) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 39 with Assignment

use of org.olat.modules.portfolio.Assignment in project openolat by klemens.

the class EvaluationFormHandler method getContent.

@Override
public PageRunElement getContent(UserRequest ureq, WindowControl wControl, PageElement element, PageElementRenderingHints hints) {
    Controller ctrl = null;
    if (element instanceof EvaluationFormPart) {
        PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
        // find assignment
        EvaluationFormPart eva = (EvaluationFormPart) element;
        PageBody body = eva.getBody();
        Assignment assignment = portfolioService.getAssignment(body);
        if (assignment == null) {
            ctrl = getController(ureq, wControl, body, eva);
        } else {
            ctrl = getControllerForAssignment(ureq, wControl, body, assignment, hints.isOnePage());
        }
    }
    if (ctrl == null) {
        Translator translator = Util.createPackageTranslator(PortfolioHomeController.class, ureq.getLocale());
        String title = translator.translate("warning.evaluation.not.visible.title");
        String text = translator.translate("warning.evaluation.not.visible.text");
        ctrl = MessageUIFactory.createWarnMessage(ureq, wControl, title, text);
    }
    return new PageRunControllerElement(ctrl);
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) PageRunControllerElement(org.olat.modules.portfolio.ui.editor.PageRunControllerElement) EvaluationFormPart(org.olat.modules.portfolio.model.EvaluationFormPart) PortfolioService(org.olat.modules.portfolio.PortfolioService) Translator(org.olat.core.gui.translator.Translator) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) Controller(org.olat.core.gui.control.Controller) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioHomeController(org.olat.modules.portfolio.ui.PortfolioHomeController) PageBody(org.olat.modules.portfolio.PageBody)

Example 40 with Assignment

use of org.olat.modules.portfolio.Assignment in project openolat by klemens.

the class MyPageListController method loadModel.

@Override
protected void loadModel(UserRequest ureq, String searchString) {
    Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfCommentsOnOwnedPage(getIdentity());
    List<CategoryToElement> categorizedElements = portfolioService.getCategorizedOwnedPages(getIdentity());
    Map<OLATResourceable, List<Category>> categorizedElementMap = new HashMap<>();
    for (CategoryToElement categorizedElement : categorizedElements) {
        List<Category> categories = categorizedElementMap.get(categorizedElement.getCategorizedResource());
        if (categories == null) {
            categories = new ArrayList<>();
            categorizedElementMap.put(categorizedElement.getCategorizedResource(), categories);
        }
        categories.add(categorizedElement.getCategory());
    }
    List<Assignment> assignments = portfolioService.searchOwnedAssignments(getIdentity());
    Map<Page, List<Assignment>> pageToAssignments = new HashMap<>();
    for (Assignment assignment : assignments) {
        Page page = assignment.getPage();
        List<Assignment> assignmentList;
        if (pageToAssignments.containsKey(page)) {
            assignmentList = pageToAssignments.get(page);
        } else {
            assignmentList = new ArrayList<>();
            pageToAssignments.put(page, assignmentList);
        }
        assignmentList.add(assignment);
    }
    FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
    newEntryButton.setCustomEnabledLinkCSS("btn btn-primary");
    List<Page> pages = portfolioService.searchOwnedPages(getIdentity(), searchString);
    List<PortfolioElementRow> rows = new ArrayList<>(pages.size());
    List<TimelinePoint> points = new ArrayList<>(pages.size());
    for (Page page : pages) {
        if (page.getPageStatus() == PageStatus.deleted) {
            continue;
        }
        List<Assignment> assignmentList = pageToAssignments.get(page);
        PortfolioElementRow row = forgePageRow(ureq, page, null, assignmentList, categorizedElementMap, numberOfCommentsMap, true);
        rows.add(row);
        if (page.getSection() != null) {
            Section section = page.getSection();
            row.setMetaSectionTitle(section.getTitle());
            if (section.getBinder() != null) {
                row.setMetaBinderTitle(section.getBinder().getTitle());
            }
        }
        row.setNewFloatingEntryLink(newEntryButton);
        String s = page.getPageStatus() == null ? "draft" : page.getPageStatus().name();
        points.add(new TimelinePoint(page.getKey().toString(), page.getTitle(), page.getCreationDate(), s));
    }
    timelineEl.setPoints(points);
    // clean up the posters
    disposeRows();
    model.setObjects(rows);
    tableEl.reset();
    tableEl.reloadData();
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) Category(org.olat.modules.portfolio.Category) OLATResourceable(org.olat.core.id.OLATResourceable) HashMap(java.util.HashMap) CategoryToElement(org.olat.modules.portfolio.CategoryToElement) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Section(org.olat.modules.portfolio.Section) Assignment(org.olat.modules.portfolio.Assignment) ArrayList(java.util.ArrayList) List(java.util.List) TimelinePoint(org.olat.modules.portfolio.ui.component.TimelinePoint)

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