Search in sources :

Example 31 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.

the class EvaluationFormHandler method getController.

private Controller getController(UserRequest ureq, WindowControl wControl, PageBody body, EvaluationFormPart eva) {
    PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
    Controller ctrl = null;
    Page page = portfolioService.getPageByBody(body);
    List<AccessRights> accessRights = portfolioService.getAccessRights(page);
    if (hasRole(PortfolioRoles.owner, ureq.getIdentity(), accessRights)) {
        ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, eva.getContent(), false);
    } else if (hasRole(PortfolioRoles.coach, ureq.getIdentity(), accessRights)) {
        Identity owner = getOwner(accessRights);
        ctrl = new EvaluationFormController(ureq, wControl, owner, body, eva.getContent(), true);
    } else if (hasRole(PortfolioRoles.reviewer, ureq.getIdentity(), accessRights) || hasRole(PortfolioRoles.invitee, ureq.getIdentity(), accessRights)) {
        Identity owner = getOwner(accessRights);
        ctrl = new EvaluationFormController(ureq, wControl, owner, body, eva.getContent(), true);
    }
    return ctrl;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioService(org.olat.modules.portfolio.PortfolioService) Page(org.olat.modules.portfolio.Page) 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) Identity(org.olat.core.id.Identity)

Example 32 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.

the class EvaluationFormHandler method getControllerForAssignment.

private Controller getControllerForAssignment(UserRequest ureq, WindowControl wControl, PageBody body, Assignment assignment, boolean onePage) {
    PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
    // find the evaluation form
    RepositoryEntry re = assignment.getFormEntry();
    Page page = assignment.getPage();
    PageStatus pageStatus = page.getPageStatus();
    Controller ctrl = null;
    List<AccessRights> accessRights = portfolioService.getAccessRights(page);
    boolean anonym = assignment.isAnonymousExternalEvaluation();
    if (pageStatus == null || pageStatus == PageStatus.draft) {
        if (hasRole(PortfolioRoles.owner, ureq.getIdentity(), accessRights)) {
            ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, false, false);
        }
    } else if (assignment.isOnlyAutoEvaluation()) {
        // only the auto evaluation is shown
        if (hasRole(PortfolioRoles.owner, ureq.getIdentity(), accessRights)) {
            boolean readOnly = (pageStatus == PageStatus.published) || (pageStatus == PageStatus.closed) || (pageStatus == PageStatus.deleted);
            ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, readOnly, false);
        } else if (hasRole(PortfolioRoles.coach, ureq.getIdentity(), accessRights)) {
            Identity owner = getOwner(accessRights);
            ctrl = new EvaluationFormController(ureq, wControl, owner, body, re, true, false);
        } else if (hasRole(PortfolioRoles.reviewer, ureq.getIdentity(), accessRights) || hasRole(PortfolioRoles.invitee, ureq.getIdentity(), accessRights)) {
            if (assignment.isReviewerSeeAutoEvaluation()) {
                Identity owner = getOwner(accessRights);
                ctrl = new EvaluationFormController(ureq, wControl, owner, body, re, true, false);
            }
        }
    } else {
        if (hasRole(PortfolioRoles.owner, ureq.getIdentity(), accessRights)) {
            boolean readOnly = (pageStatus == PageStatus.published) || (pageStatus == PageStatus.closed) || (pageStatus == PageStatus.deleted) || onePage;
            Identity owner = getOwner(accessRights);
            List<Identity> coachesAndReviewers = getCoachesAndReviewers(accessRights);
            if (coachesAndReviewers.size() > 0) {
                ctrl = new MultiEvaluationFormController(ureq, wControl, owner, coachesAndReviewers, body, re, false, readOnly, onePage, anonym);
            } else {
                ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, readOnly, false);
            }
        } else if (hasRole(PortfolioRoles.coach, ureq.getIdentity(), accessRights)) {
            Identity owner = getOwner(accessRights);
            List<Identity> coachesAndReviewers = getCoachesAndReviewers(accessRights);
            boolean readOnly = (pageStatus == PageStatus.draft) || (pageStatus == PageStatus.closed) || (pageStatus == PageStatus.deleted) || onePage;
            ctrl = new MultiEvaluationFormController(ureq, wControl, owner, coachesAndReviewers, body, re, false, readOnly, onePage, anonym);
        } else if (hasRole(PortfolioRoles.reviewer, ureq.getIdentity(), accessRights) || hasRole(PortfolioRoles.invitee, ureq.getIdentity(), accessRights)) {
            boolean readOnly = (pageStatus == PageStatus.draft) || (pageStatus == PageStatus.closed) || (pageStatus == PageStatus.deleted) || onePage;
            if (assignment.isReviewerSeeAutoEvaluation()) {
                Identity owner = getOwner(accessRights);
                List<Identity> reviewers = Collections.singletonList(ureq.getIdentity());
                ctrl = new MultiEvaluationFormController(ureq, wControl, owner, reviewers, body, re, true, readOnly, onePage, anonym);
            } else {
                ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, readOnly, !readOnly);
            }
        }
    }
    return ctrl;
}
Also used : PageStatus(org.olat.modules.portfolio.PageStatus) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) Page(org.olat.modules.portfolio.Page) RepositoryEntry(org.olat.repository.RepositoryEntry) 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) AccessRights(org.olat.modules.portfolio.model.AccessRights) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioService(org.olat.modules.portfolio.PortfolioService) ArrayList(java.util.ArrayList) List(java.util.List) Identity(org.olat.core.id.Identity)

Example 33 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.

the class BinderInvitationContextEntryControllerCreator method createController.

@Override
public Controller createController(List<ContextEntry> ces, UserRequest ureq, WindowControl wControl) {
    if (!ureq.getUserSession().getRoles().isInvitee()) {
        return null;
    }
    Binder binder = getBinderFromContext(ces.get(0));
    BinderConfiguration config = BinderConfiguration.createInvitationConfig();
    List<AccessRights> rights = CoreSpringFactory.getImpl(PortfolioService.class).getAccessRights(binder, ureq.getIdentity());
    BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForInvitation(rights);
    Controller binderCtrl = new PortfolioInvitationController(ureq, wControl, secCallback, binder, config);
    LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(ureq, wControl, binderCtrl);
    layoutCtr.addDisposableChildController(binderCtrl);
    return layoutCtr;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) PortfolioInvitationController(org.olat.modules.portfolio.ui.PortfolioInvitationController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) PortfolioInvitationController(org.olat.modules.portfolio.ui.PortfolioInvitationController) Controller(org.olat.core.gui.control.Controller) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController)

Example 34 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.

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 35 with AccessRights

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

the class PortfolioServiceTest method binderAccessRights.

@Test
public void binderAccessRights() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-2");
    String title = "My private binder";
    String summary = "My live";
    Binder binder = portfolioService.createNewBinder(title, summary, null, owner);
    dbInstance.commitAndCloseSession();
    // load right
    List<AccessRights> rights = portfolioService.getAccessRights(binder);
    Assert.assertNotNull(rights);
    Assert.assertEquals(1, rights.size());
    AccessRights ownerRight = rights.get(0);
    Assert.assertEquals(binder.getKey(), ownerRight.getBinderKey());
    Assert.assertEquals(owner, ownerRight.getIdentity());
    Assert.assertEquals(PortfolioRoles.owner, ownerRight.getRole());
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

AccessRights (org.olat.modules.portfolio.model.AccessRights)38 Identity (org.olat.core.id.Identity)24 ArrayList (java.util.ArrayList)16 Invitation (org.olat.basesecurity.Invitation)14 Binder (org.olat.modules.portfolio.Binder)12 Page (org.olat.modules.portfolio.Page)12 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)10 Test (org.junit.Test)6 Controller (org.olat.core.gui.control.Controller)6 BinderConfiguration (org.olat.modules.portfolio.BinderConfiguration)6 Section (org.olat.modules.portfolio.Section)6 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)6 WindowControl (org.olat.core.gui.control.WindowControl)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 EvaluationFormController (org.olat.modules.forms.ui.EvaluationFormController)4 PortfolioService (org.olat.modules.portfolio.PortfolioService)4 BinderController (org.olat.modules.portfolio.ui.BinderController)4 MultiEvaluationFormController (org.olat.modules.portfolio.ui.MultiEvaluationFormController)4 PortfolioHomeController (org.olat.modules.portfolio.ui.PortfolioHomeController)4 Date (java.util.Date)2