Search in sources :

Example 66 with Page

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

the class SharedPagesController method doSelectedPage.

private Activateable2 doSelectedPage(UserRequest ureq, SharedPageRow row) {
    removeAsListenerAndDispose(pageCtrl);
    Page reloadedPage = portfolioService.getPageByKey(row.getPageKey());
    Binder binder = reloadedPage.getSection().getBinder();
    OLATResourceable pageOres = OresHelper.createOLATResourceableInstance("Entry", reloadedPage.getKey());
    WindowControl swControl = addToHistory(ureq, pageOres, null);
    List<AccessRights> rights = portfolioService.getAccessRights(binder, getIdentity());
    BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForCoach(binder, rights);
    pageCtrl = new PageRunController(ureq, swControl, stackPanel, secCallback, reloadedPage, false);
    listenTo(pageCtrl);
    stackPanel.pushController(reloadedPage.getTitle(), pageCtrl);
    return pageCtrl;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) Binder(org.olat.modules.portfolio.Binder) OLATResourceable(org.olat.core.id.OLATResourceable) PageRunController(org.olat.modules.portfolio.ui.PageRunController) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) WindowControl(org.olat.core.gui.control.WindowControl)

Example 67 with Page

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

the class SharedPagesController method toggleBookmark.

private void toggleBookmark(SharedPageRow row) {
    Page page = portfolioService.getPageByKey(row.getPageKey());
    PageUserInformations infos = portfolioService.getPageUserInfos(page, getIdentity(), PageUserStatus.incoming);
    infos.setMark(!infos.isMark());
    infos = portfolioService.updatePageUserInfos(infos);
    if (searchParams.isBookmarkOnly() && !infos.isMark()) {
        List<SharedPageRow> rows = model.getObjects();
        rows.remove(row);
        model.setObjects(rows);
        tableEl.reset(false, false, true);
    } else {
        row.getBookmarkLink().setIconLeftCSS(infos.isMark() ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
    }
}
Also used : PageUserInformations(org.olat.modules.portfolio.PageUserInformations) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page)

Example 68 with Page

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

the class EvaluationFormSessionDAOTest method createSessionForPortfolio.

@Test
public void createSessionForPortfolio() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("eva-1");
    BinderImpl binder = binderDao.createAndPersist("Binder evaluation 1", "A binder with an evaluation", null, null);
    Section section = binderDao.createSection("Section", "First section", null, null, binder);
    dbInstance.commit();
    Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
    Page page = pageDao.createAndPersist("Page 1", "A page with an evalutation.", null, null, true, reloadedSection, null);
    dbInstance.commit();
    RepositoryEntry formEntry = createFormEntry("Eva. form for session");
    PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    EvaluationFormSession session = evaluationFormSessionDao.createSessionForPortfolio(id, reloadedBody, formEntry);
    dbInstance.commit();
    Assert.assertNotNull(session);
    Assert.assertNotNull(session.getKey());
    Assert.assertNotNull(session.getCreationDate());
    Assert.assertNotNull(session.getLastModified());
    Assert.assertEquals(reloadedBody, session.getPageBody());
    Assert.assertEquals(id, session.getIdentity());
}
Also used : EvaluationFormSession(org.olat.modules.forms.EvaluationFormSession) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Page(org.olat.modules.portfolio.Page) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) PageBody(org.olat.modules.portfolio.PageBody) Test(org.junit.Test)

Example 69 with Page

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

the class PortfolioServiceTest method syncBinder_moveAssignmentsInSection_multiple.

@Test
public void syncBinder_moveAssignmentsInSection_multiple() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-10");
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-11");
    RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
    dbInstance.commitAndCloseSession();
    // make 2 sections
    Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
    SectionRef sectionRef1 = portfolioService.getSections(templateBinder).get(0);
    dbInstance.commit();
    // make 4 assignments
    Section templateSection1 = portfolioService.getSection(sectionRef1);
    Assignment assignment_1_1 = portfolioService.addAssignment("1.1 Assignment", "", "", AssignmentType.essay, templateSection1, false, false, false, null);
    Assignment assignment_1_2 = portfolioService.addAssignment("1.2 Assignment", "", "", AssignmentType.essay, templateSection1, false, false, false, null);
    Assignment assignment_1_3 = portfolioService.addAssignment("1.3 Assignment", "", "", AssignmentType.essay, templateSection1, false, false, false, null);
    Assignment assignment_1_4 = portfolioService.addAssignment("1.4 Assignment", "", "", AssignmentType.essay, templateSection1, false, false, false, null);
    Assignment assignment_1_5 = portfolioService.addAssignment("1.5 Assignment", "", "", AssignmentType.essay, templateSection1, false, false, false, null);
    Assignment assignment_1_6 = portfolioService.addAssignment("1.6 Assignment", "", "", AssignmentType.essay, templateSection1, false, false, false, null);
    dbInstance.commit();
    List<Assignment> templateAssignments = portfolioService.getAssignments(templateBinder, null);
    Assert.assertEquals(6, templateAssignments.size());
    // a user take the binder and synched it a first time
    Binder binder = portfolioService.assignBinder(id, templateBinder, templateEntry, "74", null);
    dbInstance.commit();
    SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(binder);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(synchedBinder);
    Assert.assertEquals(binder, synchedBinder.getBinder());
    // start all assignments
    List<Assignment> assignments = portfolioService.getAssignments(binder, null);
    Assert.assertEquals(6, assignments.size());
    for (Assignment assignment : assignments) {
        portfolioService.startAssignment(assignment.getKey(), id);
        dbInstance.commit();
    }
    dbInstance.commit();
    // check that the student has it's 8 pages
    List<Page> pages = portfolioService.getPages(binder, null);
    Assert.assertEquals(6, pages.size());
    dbInstance.commit();
    // synched and check the sections order
    SynchedBinder synchedBinder2 = portfolioService.loadAndSyncBinder(binder);
    Binder freshBinder = synchedBinder2.getBinder();
    dbInstance.commitAndCloseSession();
    // ooops, someone deleted the assignment (simulate jump in the numbering of the list)
    List<Section> sections = portfolioService.getSections(freshBinder);
    List<Assignment> firstSectionAssignments = portfolioService.getAssignments(sections.get(0), null);
    dbInstance.getCurrentEntityManager().remove(firstSectionAssignments.get(1));
    dbInstance.getCurrentEntityManager().remove(firstSectionAssignments.get(2));
    dbInstance.getCurrentEntityManager().remove(firstSectionAssignments.get(3));
    dbInstance.getCurrentEntityManager().remove(firstSectionAssignments.get(5));
    dbInstance.commit();
    List<Assignment> firstSectionDeletedAssignments = portfolioService.getAssignments(sections.get(0), null);
    Assert.assertEquals(2, firstSectionDeletedAssignments.size());
    // synched and check the sections order
    SynchedBinder synchedBinder3 = portfolioService.loadAndSyncBinder(binder);
    Binder freshBinder3 = synchedBinder3.getBinder();
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(freshBinder3);
    List<Assignment> firstSectionAssignmentResynched = portfolioService.getAssignments(sections.get(0), null);
    List<Assignment> templateAssignmentsSynched = new ArrayList<>();
    Assert.assertEquals(6, firstSectionAssignmentResynched.size());
    for (Assignment firstSectionAssignment : firstSectionAssignmentResynched) {
        Assert.assertEquals(firstSectionAssignment.getTitle(), firstSectionAssignment.getTemplateReference().getTitle());
        templateAssignmentsSynched.add(firstSectionAssignment.getTemplateReference());
    }
    Assert.assertTrue(templateAssignmentsSynched.contains(assignment_1_1));
    Assert.assertTrue(templateAssignmentsSynched.contains(assignment_1_2));
    Assert.assertTrue(templateAssignmentsSynched.contains(assignment_1_3));
    Assert.assertTrue(templateAssignmentsSynched.contains(assignment_1_4));
    Assert.assertTrue(templateAssignmentsSynched.contains(assignment_1_5));
    Assert.assertTrue(templateAssignmentsSynched.contains(assignment_1_6));
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) SectionRef(org.olat.modules.portfolio.SectionRef) Section(org.olat.modules.portfolio.Section) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Test(org.junit.Test)

Example 70 with Page

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

the class PortfolioServiceTest method deleteBinder.

@Test
public void deleteBinder() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("del-binder-");
    Binder binder = portfolioService.createNewBinder("Binder to delete", "Deletion", "", owner);
    SectionRef sectionRef1 = portfolioService.appendNewSection("1. section ", "Section 1", null, null, binder);
    dbInstance.commit();
    SectionRef sectionRef2 = portfolioService.appendNewSection("2. section ", "Section 2", null, null, binder);
    dbInstance.commit();
    portfolioService.updateBinderUserInformations(binder, owner);
    dbInstance.commit();
    Section reloadedSection1 = portfolioService.getSection(sectionRef1);
    Page page1 = portfolioService.appendNewPage(owner, "New page", "A brand new page.", null, null, reloadedSection1);
    Section reloadedSection2 = portfolioService.getSection(sectionRef2);
    Page page2 = portfolioService.appendNewPage(owner, "New page", "A brand new page.", null, null, reloadedSection2);
    Assert.assertNotNull(page1);
    Assert.assertNotNull(page2);
    dbInstance.commitAndCloseSession();
    // delete
    boolean deleted = portfolioService.deleteBinder(binder);
    dbInstance.commit();
    Assert.assertTrue(deleted);
}
Also used : SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) SectionRef(org.olat.modules.portfolio.SectionRef) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Aggregations

Page (org.olat.modules.portfolio.Page)136 Section (org.olat.modules.portfolio.Section)98 Test (org.junit.Test)70 Identity (org.olat.core.id.Identity)64 Binder (org.olat.modules.portfolio.Binder)44 ArrayList (java.util.ArrayList)32 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)32 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)26 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)26 Assignment (org.olat.modules.portfolio.Assignment)24 RepositoryEntry (org.olat.repository.RepositoryEntry)22 HashMap (java.util.HashMap)20 SectionRef (org.olat.modules.portfolio.SectionRef)20 PageUserInformations (org.olat.modules.portfolio.PageUserInformations)18 AssessedPage (org.olat.modules.portfolio.model.AssessedPage)16 PageBody (org.olat.modules.portfolio.PageBody)14 OLATResourceable (org.olat.core.id.OLATResourceable)12 AccessRights (org.olat.modules.portfolio.model.AccessRights)12 CategoryToElement (org.olat.modules.portfolio.CategoryToElement)10 Date (java.util.Date)8