diff --git a/src/main/java/org/olat/modules/forms/ui/EvaluationFormController.java b/src/main/java/org/olat/modules/forms/ui/EvaluationFormController.java index 442baada4c605b188ec03ed25728b6358a612609..047f3e182aff53cf52ac02ffa046cadebe17d13f 100644 --- a/src/main/java/org/olat/modules/forms/ui/EvaluationFormController.java +++ b/src/main/java/org/olat/modules/forms/ui/EvaluationFormController.java @@ -41,6 +41,7 @@ import org.olat.core.gui.components.form.flexible.impl.FormEvent; import org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit; import org.olat.core.gui.components.link.Link; import org.olat.core.gui.control.Controller; +import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.id.Identity; import org.olat.core.util.StringHelper; @@ -327,13 +328,13 @@ public class EvaluationFormController extends FormBasicController { @Override protected void formOK(UserRequest ureq) { - doSaveAsDone(); + doSaveAsDone(ureq); } @Override protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { if(saveAsDoneButton == source) { - doSaveAsDone(); + doSaveAsDone(ureq); } else if(source instanceof SingleSelection) { SingleSelection radioEl = (SingleSelection)source; Object uobject = radioEl.getUserObject(); @@ -378,7 +379,7 @@ public class EvaluationFormController extends FormBasicController { } } - private void doSaveAsDone() { + private void doSaveAsDone(UserRequest ureq) { @SuppressWarnings("unchecked") List<EvaluationFormElementWrapper> elementWrappers = (List<EvaluationFormElementWrapper>)flc.contextGet("elements"); for(EvaluationFormElementWrapper elementWrapper:elementWrappers) { @@ -396,6 +397,9 @@ public class EvaluationFormController extends FormBasicController { loadResponses(); updateElements(); saveAsDoneButton.setVisible(false); + dbInstance.commit(); + + fireEvent(ureq, Event.DONE_EVENT); } @Override diff --git a/src/main/java/org/olat/modules/portfolio/handler/EvaluationFormHandler.java b/src/main/java/org/olat/modules/portfolio/handler/EvaluationFormHandler.java index d5f0a5a63b9b4cba9384cec3abc626d152171d97..e58dc0061848f4c9206f4771aef4a1ecb651ede8 100644 --- a/src/main/java/org/olat/modules/portfolio/handler/EvaluationFormHandler.java +++ b/src/main/java/org/olat/modules/portfolio/handler/EvaluationFormHandler.java @@ -100,7 +100,8 @@ public class EvaluationFormHandler implements PageElementHandler { } else if(hasRole(PortfolioRoles.coach, ureq.getIdentity(), accessRights)) { Identity owner = getOwner(accessRights); return new EvaluationFormController(ureq, wControl, owner, body, re, true, false).getInitialComponent(); - } else if(hasRole(PortfolioRoles.reviewer, ureq.getIdentity(), accessRights)) { + } else if(hasRole(PortfolioRoles.reviewer, ureq.getIdentity(), accessRights) + || hasRole(PortfolioRoles.invitee, ureq.getIdentity(), accessRights)) { if(assignment.isReviewerSeeAutoEvaluation()) { Identity owner = getOwner(accessRights); return new EvaluationFormController(ureq, wControl, owner, body, re, true, false).getInitialComponent(); @@ -112,21 +113,21 @@ public class EvaluationFormHandler implements PageElementHandler { Identity owner = getOwner(accessRights); List<Identity> coachesAndReviewers = getCoachesAndReviewers(accessRights); if(coachesAndReviewers.size() > 0) { - return new MultiEvaluationFormController(ureq, wControl, owner, coachesAndReviewers, body, re, readOnly, anonym).getInitialComponent(); + return new MultiEvaluationFormController(ureq, wControl, owner, coachesAndReviewers, body, re, false, readOnly, anonym).getInitialComponent(); } return new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, readOnly, false).getInitialComponent(); } 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); - return new MultiEvaluationFormController(ureq, wControl, owner, coachesAndReviewers, body, re, readOnly, anonym).getInitialComponent(); - } else if(hasRole(PortfolioRoles.reviewer, ureq.getIdentity(), accessRights)) { - boolean seeAutoEvaluation = assignment.isReviewerSeeAutoEvaluation(); + return new MultiEvaluationFormController(ureq, wControl, owner, coachesAndReviewers, body, re, false, readOnly, anonym).getInitialComponent(); + } 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); - if(seeAutoEvaluation) { + if(assignment.isReviewerSeeAutoEvaluation()) { Identity owner = getOwner(accessRights); List<Identity> reviewers = Collections.singletonList(ureq.getIdentity()); - return new MultiEvaluationFormController(ureq, wControl, owner, reviewers, body, re, readOnly, anonym).getInitialComponent(); + return new MultiEvaluationFormController(ureq, wControl, owner, reviewers, body, re, true, readOnly, anonym).getInitialComponent(); } else { return new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, readOnly, !readOnly).getInitialComponent(); } @@ -153,7 +154,7 @@ public class EvaluationFormHandler implements PageElementHandler { private List<Identity> getCoachesAndReviewers(List<AccessRights> accessRights) { List<Identity> identities = new ArrayList<>(accessRights.size()); for(AccessRights accessRight:accessRights) { - if(PortfolioRoles.coach == accessRight.getRole() || PortfolioRoles.reviewer == accessRight.getRole()) { + if(PortfolioRoles.coach == accessRight.getRole() || PortfolioRoles.reviewer == accessRight.getRole() || PortfolioRoles.invitee == accessRight.getRole()) { identities.add(accessRight.getIdentity()); } } diff --git a/src/main/java/org/olat/modules/portfolio/ui/MultiEvaluationFormController.java b/src/main/java/org/olat/modules/portfolio/ui/MultiEvaluationFormController.java index ba2c9a1a520dc766e925018735336d96c7929f5f..a0bdc12a8f6be98aded196a875fe9807d800adba 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/MultiEvaluationFormController.java +++ b/src/main/java/org/olat/modules/portfolio/ui/MultiEvaluationFormController.java @@ -30,10 +30,14 @@ import org.olat.core.gui.components.segmentedview.SegmentViewComponent; import org.olat.core.gui.components.segmentedview.SegmentViewEvent; import org.olat.core.gui.components.segmentedview.SegmentViewFactory; import org.olat.core.gui.components.velocity.VelocityContainer; +import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.controller.BasicController; import org.olat.core.id.Identity; +import org.olat.modules.forms.EvaluationFormManager; +import org.olat.modules.forms.EvaluationFormSession; +import org.olat.modules.forms.EvaluationFormSessionStatus; import org.olat.modules.forms.ui.CompareEvaluationsFormController; import org.olat.modules.forms.ui.EvaluationFormController; import org.olat.modules.forms.ui.model.Evaluator; @@ -54,6 +58,7 @@ public class MultiEvaluationFormController extends BasicController { private final PageBody anchor; private final Identity owner; private final boolean readOnly; + private final boolean doneFirst; private final RepositoryEntry formEntry; private Link ownerLink; @@ -64,34 +69,47 @@ public class MultiEvaluationFormController extends BasicController { private List<Evaluator> evaluators = new ArrayList<>(); private List<Link> otherEvaluatorLinks = new ArrayList<>(); + private EvaluationFormController currentEvalutionFormCtrl; private CompareEvaluationsFormController compareEvaluationCtrl; @Autowired private UserManager userManager; + @Autowired + private EvaluationFormManager evaluationFormManager; public MultiEvaluationFormController(UserRequest ureq, WindowControl wControl, - Identity owner, List<Identity> otherEvaluators, PageBody anchor, - RepositoryEntry formEntry, boolean readOnly, boolean anonym) { + Identity owner, List<Identity> otherEvaluators, PageBody anchor, RepositoryEntry formEntry, + boolean doneFirst, boolean readOnly, boolean anonym) { super(ureq, wControl); this.owner = owner; this.anchor = anchor; this.readOnly = readOnly; + this.doneFirst = doneFirst; this.formEntry = formEntry; mainVC = createVelocityContainer("multi_evaluation_form"); segmentView = SegmentViewFactory.createSegmentView("segments", mainVC, this); + boolean viewOthers; + if(doneFirst) { + EvaluationFormSession session = evaluationFormManager.getSessionForPortfolioEvaluation(getIdentity(), anchor); + viewOthers = session == null ? false : session.getEvaluationFormSessionStatus() == EvaluationFormSessionStatus.done; + } else { + viewOthers = true; + } + if(owner != null) { String ownerFullname = userManager.getUserDisplayName(owner); + evaluators.add(new Evaluator(owner, ownerFullname)); + String id = "eva-" + (count++); ownerLink = LinkFactory.createCustomLink(id, id, ownerFullname, Link.BUTTON | Link.NONTRANSLATED, mainVC, this); ownerLink.setUserObject(owner); - boolean selected = owner.equals(ureq.getIdentity()); - segmentView.addSegment(ownerLink, selected); - if(selected) { + boolean me = owner.equals(ureq.getIdentity()); + segmentView.addSegment(ownerLink, me); + if(me) { doOpenEvalutationForm(ureq, owner); } - evaluators.add(new Evaluator(owner, ownerFullname)); } if(otherEvaluators != null && otherEvaluators.size() > 0) { @@ -105,6 +123,7 @@ public class MultiEvaluationFormController extends BasicController { } else { evaluatorFullname = userManager.getUserDisplayName(evaluator); } + evaluators.add(new Evaluator(evaluator, evaluatorFullname)); String id = "eva-" + (count++); Link evaluatorLink = LinkFactory.createCustomLink(id, id, evaluatorFullname, Link.BUTTON | Link.NONTRANSLATED, mainVC, this); @@ -114,7 +133,6 @@ public class MultiEvaluationFormController extends BasicController { if(me) { doOpenEvalutationForm(ureq, evaluator); } - evaluators.add(new Evaluator(evaluator, evaluatorFullname)); } } @@ -124,6 +142,7 @@ public class MultiEvaluationFormController extends BasicController { segmentView.addSegment(compareLink, false); } + segmentView.setVisible(viewOthers); mainVC.put("segments", segmentView); putInitialPanel(mainVC); } @@ -133,6 +152,22 @@ public class MultiEvaluationFormController extends BasicController { // } + @Override + protected void event(UserRequest ureq, Controller source, Event event) { + if(currentEvalutionFormCtrl == source) { + if(event == Event.DONE_EVENT) { + if(doneFirst) { + // check if it's really done + EvaluationFormSession session = evaluationFormManager.getSessionForPortfolioEvaluation(getIdentity(), anchor); + if(session != null && session.getEvaluationFormSessionStatus() == EvaluationFormSessionStatus.done) { + segmentView.setVisible(true); + } + } + } + } + super.event(ureq, source, event); + } + @Override protected void event(UserRequest ureq, Component source, Event event) { if(source == segmentView) { @@ -158,9 +193,9 @@ public class MultiEvaluationFormController extends BasicController { private void doOpenEvalutationForm(UserRequest ureq, Identity evaluator) { boolean ro = readOnly || !evaluator.equals(getIdentity()); boolean doneButton = !ro && evaluator.equals(getIdentity()) && (owner == null || !owner.equals(evaluator)); - EvaluationFormController evalutionFormCtrl = new EvaluationFormController(ureq, getWindowControl(), evaluator, anchor, formEntry, ro, doneButton); - listenTo(evalutionFormCtrl); - mainVC.put("segmentCmp", evalutionFormCtrl.getInitialComponent()); + currentEvalutionFormCtrl = new EvaluationFormController(ureq, getWindowControl(), evaluator, anchor, formEntry, ro, doneButton); + listenTo(currentEvalutionFormCtrl); + mainVC.put("segmentCmp", currentEvalutionFormCtrl.getInitialComponent()); } private void doOpenOverview(UserRequest ureq) {