Skip to content
Snippets Groups Projects
Commit c5f7b505 authored by uhensler's avatar uhensler
Browse files

OO-4207: Make learning path work in booked courses

parent 072da62a
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
......@@ -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);
......
......@@ -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();
......
......@@ -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++) {
......
......@@ -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();
......
......@@ -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();
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment