diff --git a/src/main/java/org/olat/course/editor/EditorUserCourseEnvironmentImpl.java b/src/main/java/org/olat/course/editor/EditorUserCourseEnvironmentImpl.java index c5ea43f42c5ef51adb35e4c6873800620119808f..783342d80f8fb110f9e04131ac48b453f79ad242 100644 --- a/src/main/java/org/olat/course/editor/EditorUserCourseEnvironmentImpl.java +++ b/src/main/java/org/olat/course/editor/EditorUserCourseEnvironmentImpl.java @@ -119,6 +119,16 @@ public class EditorUserCourseEnvironmentImpl implements UserCourseEnvironment { return false; } + @Override + public List<BusinessGroup> getParticipatingGroups() { + return Collections.emptyList(); + } + + @Override + public List<BusinessGroup> getWaitingLists() { + return Collections.emptyList(); + } + @Override public List<BusinessGroup> getCoachedGroups() { return Collections.emptyList(); diff --git a/src/main/java/org/olat/course/run/CourseRuntimeController.java b/src/main/java/org/olat/course/run/CourseRuntimeController.java index 4f231bf1d94bb3c2b78970314f3c95875c75f1d2..b2c55b27f6eb3e3895815952de9bab39ba716afb 100644 --- a/src/main/java/org/olat/course/run/CourseRuntimeController.java +++ b/src/main/java/org/olat/course/run/CourseRuntimeController.java @@ -429,7 +429,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im cc.removeCurrentCustomCSSFromView(); } setCustomCSS(null); - setCourseClosedMessage(getUserCourseEnvironment()); + setCourseClosedMessage(); } @Override @@ -438,8 +438,6 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im if(corrupted) return; ICourse course = CourseFactory.loadCourse(getRepositoryEntry()); - UserCourseEnvironmentImpl uce = getUserCourseEnvironment(); - if(!course.getCourseConfig().isToolbarEnabled() && !reSecurity.isEntryAdmin() && !reSecurity.isCoach() && !hasCourseRight(CourseRights.RIGHT_COURSEEDITOR) && !hasCourseRight(CourseRights.RIGHT_MEMBERMANAGEMENT) && !hasCourseRight(CourseRights.RIGHT_GROUPMANAGEMENT) && !hasCourseRight(CourseRights.RIGHT_ARCHIVING) @@ -456,18 +454,19 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im } initToolsMenu(toolsDropdown); - initToolsMyCourse(course, uce); + initToolsMyCourse(course); initGeneralTools(course); RunMainController rmc = getRunMainController(); if(rmc != null) { rmc.initToolbar(); } - setCourseClosedMessage(uce); + setCourseClosedMessage(); } - private void setCourseClosedMessage(UserCourseEnvironment uce) { - if(uce != null && getRepositoryEntry().getEntryStatus() == RepositoryEntryStatusEnum.closed) { + private void setCourseClosedMessage() { + UserCourseEnvironment userCourseEnv = getUserCourseEnvironment(); + if(userCourseEnv != null && getRepositoryEntry().getEntryStatus() == RepositoryEntryStatusEnum.closed) { toolbarPanel.setMessage(translate("course.closed")); toolbarPanel.setMessageCssClass("o_warning"); } else { @@ -676,8 +675,9 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im } } - private void initToolsMyCourse(ICourse course, UserCourseEnvironmentImpl uce) { + private void initToolsMyCourse(ICourse course) { boolean assessmentLock = isAssessmentLock(); + UserCourseEnvironment userCourseEnv = getUserCourseEnvironment(); myCourse = new Dropdown("myCourse", "header.tools.mycourse", false, getTranslator()); myCourse.setElementCssClass("dropdown-menu-right"); @@ -685,7 +685,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im // Personal tools on right side CourseConfig cc = course.getCourseConfig(); - if ((course.hasAssessableNodes() || cc.isCertificateEnabled()) && !isGuestOnly && !assessmentLock) { + if ((course.hasAssessableNodes() || cc.isCertificateEnabled()) && !isGuestOnly && !assessmentLock && userCourseEnv != null) { // link to efficiency statements should // - not appear when not configured in course configuration // - not appear when configured in course configuration but no assessable @@ -698,11 +698,11 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im efficiencyStatementsLink.setVisible(cc.isEfficencyStatementEnabled() || cc.isCertificateEnabled()); myCourse.addComponent(efficiencyStatementsLink); if(cc.isEfficencyStatementEnabled() || cc.isCertificateEnabled()) { - boolean certification = uce.hasEfficiencyStatementOrCertificate(false); + boolean certification = userCourseEnv.hasEfficiencyStatementOrCertificate(false); efficiencyStatementsLink.setVisible(certification); } } - if (efficiencyStatementsLink != null && !uce.isParticipant()) { + if (efficiencyStatementsLink != null && userCourseEnv != null && !userCourseEnv.isParticipant()) { efficiencyStatementsLink.setVisible(false); } @@ -720,53 +720,55 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im myCourse.addComponent(bookmarkLink); } - if(myCourse.size() > 0 && (!uce.getCoachedGroups().isEmpty() || !uce.getParticipatingGroups().isEmpty() || !uce.getWaitingLists().isEmpty())) { - myCourse.addComponent(new Spacer("")); - } - - // 2) add coached groups - if (!uce.getCoachedGroups().isEmpty()) { - for (BusinessGroup group:uce.getCoachedGroups()) { - Link link = LinkFactory.createToolLink(CMD_START_GROUP_PREFIX + group.getKey(), "group", StringHelper.escapeHtml(group.getName()), this); - link.setIconLeftCSS("o_icon o_icon-fw o_icon_group"); - link.setUserObject(group); - link.setEnabled(!assessmentLock); - myCourse.addComponent(link); - + if (userCourseEnv != null) { + if(myCourse.size() > 0 && (!userCourseEnv.getCoachedGroups().isEmpty() || !userCourseEnv.getParticipatingGroups().isEmpty() || !userCourseEnv.getWaitingLists().isEmpty())) { + myCourse.addComponent(new Spacer("")); + } + + // 2) add coached groups + if (!userCourseEnv.getCoachedGroups().isEmpty()) { + for (BusinessGroup group: userCourseEnv.getCoachedGroups()) { + Link link = LinkFactory.createToolLink(CMD_START_GROUP_PREFIX + group.getKey(), "group", StringHelper.escapeHtml(group.getName()), this); + link.setIconLeftCSS("o_icon o_icon-fw o_icon_group"); + link.setUserObject(group); + link.setEnabled(!assessmentLock); + myCourse.addComponent(link); + + } } - } - // 3) add participating groups - if (!uce.getParticipatingGroups().isEmpty()) { - for (BusinessGroup group: uce.getParticipatingGroups()) { - Link link = LinkFactory.createToolLink(CMD_START_GROUP_PREFIX + group.getKey(), "group", StringHelper.escapeHtml(group.getName()), this); - link.setIconLeftCSS("o_icon o_icon-fw o_icon_group"); - link.setUserObject(group); - link.setEnabled(!assessmentLock); - myCourse.addComponent(link); + // 3) add participating groups + if (!userCourseEnv.getParticipatingGroups().isEmpty()) { + for (BusinessGroup group: userCourseEnv.getParticipatingGroups()) { + Link link = LinkFactory.createToolLink(CMD_START_GROUP_PREFIX + group.getKey(), "group", StringHelper.escapeHtml(group.getName()), this); + link.setIconLeftCSS("o_icon o_icon-fw o_icon_group"); + link.setUserObject(group); + link.setEnabled(!assessmentLock); + myCourse.addComponent(link); + } } - } - // 5) add waiting-list groups - if (!uce.getWaitingLists().isEmpty()) { - for (BusinessGroup group:uce.getWaitingLists()) { - int pos = businessGroupService.getPositionInWaitingListFor(getIdentity(), group); - String name = StringHelper.escapeHtml(group.getName()) + " (" + pos + ")"; - Link link = LinkFactory.createToolLink(CMD_START_GROUP_PREFIX + group.getKey(), "group", name, this); - link.setIconLeftCSS("o_icon o_icon-fw o_icon_group"); - link.setUserObject(group); - link.setEnabled(false); - myCourse.addComponent(link); + // 5) add waiting-list groups + if (!userCourseEnv.getWaitingLists().isEmpty()) { + for (BusinessGroup group: userCourseEnv.getWaitingLists()) { + int pos = businessGroupService.getPositionInWaitingListFor(getIdentity(), group); + String name = StringHelper.escapeHtml(group.getName()) + " (" + pos + ")"; + Link link = LinkFactory.createToolLink(CMD_START_GROUP_PREFIX + group.getKey(), "group", name, this); + link.setIconLeftCSS("o_icon o_icon-fw o_icon_group"); + link.setUserObject(group); + link.setEnabled(false); + myCourse.addComponent(link); + } + } + + if(repositoryService.isParticipantAllowedToLeave(getRepositoryEntry()) + && !assessmentLock && !roles.isGuestOnly() && !userCourseEnv.isCourseReadOnly() + && isAllowedToLeave(userCourseEnv)) { + leaveLink = LinkFactory.createToolLink("sign.out", "leave", translate("sign.out"), this); + leaveLink.setIconLeftCSS("o_icon o_icon-fw o_icon_sign_out"); + myCourse.addComponent(new Spacer("leaving-space")); + myCourse.addComponent(leaveLink); } - } - - if(repositoryService.isParticipantAllowedToLeave(getRepositoryEntry()) - && !assessmentLock && !roles.isGuestOnly() && !uce.isCourseReadOnly() - && isAllowedToLeave(uce)) { - leaveLink = LinkFactory.createToolLink("sign.out", "leave", translate("sign.out"), this); - leaveLink.setIconLeftCSS("o_icon o_icon-fw o_icon_sign_out"); - myCourse.addComponent(new Spacer("leaving-space")); - myCourse.addComponent(leaveLink); } if(myCourse.size() > 0) { @@ -774,10 +776,10 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im } } - private boolean isAllowedToLeave(UserCourseEnvironmentImpl uce) { - if(!uce.getParticipatingGroups().isEmpty()) { - CourseNode rootNode = uce.getCourseEnvironment().getRunStructure().getRootNode(); - OLATResource courseResource = uce.getCourseEnvironment().getCourseGroupManager().getCourseResource(); + private boolean isAllowedToLeave(UserCourseEnvironment userCourseEnv) { + if(!userCourseEnv.getParticipatingGroups().isEmpty()) { + CourseNode rootNode = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode(); + OLATResource courseResource = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseResource(); AtomicBoolean bool = new AtomicBoolean(false); new TreeVisitor(node -> { @@ -785,7 +787,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im try { ENCourseNode enNode = (ENCourseNode)node; boolean cancelEnrollEnabled = enNode.getModuleConfiguration().getBooleanSafe(ENCourseNode.CONF_CANCEL_ENROLL_ENABLED); - if(!cancelEnrollEnabled && enNode.isUsedForEnrollment(uce.getParticipatingGroups(), courseResource)) { + if(!cancelEnrollEnabled && enNode.isUsedForEnrollment(userCourseEnv.getParticipatingGroups(), courseResource)) { bool.set(true); } } catch (Exception e) { @@ -798,7 +800,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im return false;// is in a enrollment group } } - return (uce.isParticipant() || !uce.getParticipatingGroups().isEmpty()); + return (userCourseEnv.isParticipant() || !userCourseEnv.getParticipatingGroups().isEmpty()); } private void initGeneralTools(ICourse course) { @@ -1049,7 +1051,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im super.processPopEvent(ureq, pop); if(pop.getController() == assessmentToolCtr) { - setCourseClosedMessage(getUserCourseEnvironment()); + setCourseClosedMessage(); } if(pop.getController() != getRunMainController()) { toolControllerDone(ureq); diff --git a/src/main/java/org/olat/course/run/RunMainController.java b/src/main/java/org/olat/course/run/RunMainController.java index 53487dcb653ac22c43b64be010f5b0bd5adac45a..4e2688a721e4e2c619c4a411fac61cc150f690df 100644 --- a/src/main/java/org/olat/course/run/RunMainController.java +++ b/src/main/java/org/olat/course/run/RunMainController.java @@ -197,7 +197,7 @@ public class RunMainController extends MainLayoutBasicController implements Gene uce = loadUserCourseEnvironment(ureq, reSecurity); // build score now - uce.getScoreAccounting().evaluateAll(); + uce.getScoreAccounting().evaluateAll(true); if(assessmentMode != null && assessmentMode.isRestrictAccessElements()) { Status assessmentStatus = assessmentMode.getStatus(); diff --git a/src/main/java/org/olat/course/run/scoring/AssessmentAccounting.java b/src/main/java/org/olat/course/run/scoring/AssessmentAccounting.java index 4da1e7a378c3b8868845da37022d074990df7b11..a739fb83e99a23c24584054ff170281353c9d359 100644 --- a/src/main/java/org/olat/course/run/scoring/AssessmentAccounting.java +++ b/src/main/java/org/olat/course/run/scoring/AssessmentAccounting.java @@ -58,7 +58,6 @@ public class AssessmentAccounting implements ScoreAccounting { private final CourseConfig courseConfig; private Map<String, AssessmentEntry> identToEntry = new HashMap<>(); private final Map<CourseNode, AssessmentEvaluation> courseNodeToEval = new HashMap<>(); - private AssessmentEvaluation previousEvaluation; private Blocker blocker; @Autowired @@ -92,7 +91,6 @@ public class AssessmentAccounting implements ScoreAccounting { @Override public boolean evaluateAll(boolean update) { - previousEvaluation = null; blocker = new Blocker(); courseNodeToEval.clear(); @@ -181,7 +179,6 @@ public class AssessmentAccounting implements ScoreAccounting { result.setStatus(status); - previousEvaluation = result; int childCount = courseNode.getChildCount(); List<AssessmentEvaluation> children = new ArrayList<>(childCount); for (int i = 0; i < childCount; i++) { diff --git a/src/main/java/org/olat/course/run/userview/UserCourseEnvironment.java b/src/main/java/org/olat/course/run/userview/UserCourseEnvironment.java index 4d05f0d429e26580cc86fca9d375e1d5a74478d8..3b7bfdadd88257f6f3e877fc1da6dd1289ebedde 100644 --- a/src/main/java/org/olat/course/run/userview/UserCourseEnvironment.java +++ b/src/main/java/org/olat/course/run/userview/UserCourseEnvironment.java @@ -90,6 +90,9 @@ public interface UserCourseEnvironment { public boolean isInOrganisation(String organisationIdentifier, OrganisationRoles... roles); + public List<BusinessGroup> getParticipatingGroups(); + + public List<BusinessGroup> getWaitingLists(); public List<BusinessGroup> getCoachedGroups(); diff --git a/src/main/java/org/olat/course/run/userview/UserCourseEnvironmentImpl.java b/src/main/java/org/olat/course/run/userview/UserCourseEnvironmentImpl.java index c3903ef1c55d82e9a8d917e1657f73e672603d37..1eff5d2676f40d435718d5953c1c7a8057f84e77 100644 --- a/src/main/java/org/olat/course/run/userview/UserCourseEnvironmentImpl.java +++ b/src/main/java/org/olat/course/run/userview/UserCourseEnvironmentImpl.java @@ -286,6 +286,7 @@ public class UserCourseEnvironmentImpl implements UserCourseEnvironment { return coachedGroups; } + @Override public List<BusinessGroup> getParticipatingGroups() { if(participatingGroups == null) { return Collections.emptyList(); @@ -293,6 +294,7 @@ public class UserCourseEnvironmentImpl implements UserCourseEnvironment { return participatingGroups; } + @Override public List<BusinessGroup> getWaitingLists() { if(waitingLists == null) { return Collections.emptyList(); diff --git a/src/main/java/org/olat/repository/ui/RepositoryEntryRuntimeController.java b/src/main/java/org/olat/repository/ui/RepositoryEntryRuntimeController.java index f3f3b4433a1018ef84319d37e89f8ef365e7a7ce..2bdbbb4c140725a1fd5e6b981415e97c64a54829 100644 --- a/src/main/java/org/olat/repository/ui/RepositoryEntryRuntimeController.java +++ b/src/main/java/org/olat/repository/ui/RepositoryEntryRuntimeController.java @@ -256,8 +256,8 @@ public class RepositoryEntryRuntimeController extends MainLayoutBasicController toolbarPanel.setShowCloseLink(!assessmentLock, !assessmentLock); toolbarPanel.getBackLink().setEnabled(!assessmentLock); putInitialPanel(toolbarPanel); - doRun(ureq, this.reSecurity); onSecurityReloaded(ureq); + doRun(ureq, this.reSecurity); initToolbar(); eventBus = ureq.getUserSession().getSingleUserEventCenter(); @@ -944,8 +944,9 @@ public class RepositoryEntryRuntimeController extends MainLayoutBasicController setActiveTool(ordersLink); } - private void doRun(UserRequest ureq, RepositoryEntrySecurity security) { - if(security.isEntryAdmin() || security.isPrincipal() || reSecurity.isMasterCoach()) { + private void doRun(UserRequest ureq, SingleRoleRepositoryEntrySecurity srSecurity) { + RepositoryEntrySecurity security = srSecurity.getWrappedSecurity(); + if(security .isEntryAdmin() || security.isPrincipal() || reSecurity.isMasterCoach()) { launchContent(ureq); } else { // guest are allowed to see resource with BARG