From c160d183e13398f139f3806d55c9af057e6d9ea4 Mon Sep 17 00:00:00 2001 From: uhensler <urs.hensler@frentix.com> Date: Fri, 19 Feb 2021 10:09:25 +0100 Subject: [PATCH] OO-5299: Hide course tools until disclaimer accepted --- .../course/run/CourseRuntimeController.java | 42 ++++++++++--------- .../olat/course/run/RunMainController.java | 20 ++++++--- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/olat/course/run/CourseRuntimeController.java b/src/main/java/org/olat/course/run/CourseRuntimeController.java index 129c7f19c7a..793339e9fc7 100644 --- a/src/main/java/org/olat/course/run/CourseRuntimeController.java +++ b/src/main/java/org/olat/course/run/CourseRuntimeController.java @@ -468,11 +468,13 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im toolbarPanel.setBreadcrumbEnabled(false); } + RunMainController rmc = getRunMainController(); + boolean disclaimerAccepted = rmc != null && rmc.isDisclaimerAccepted(); + initToolsMenu(toolsDropdown); initToolsMyCourse(course); - initGeneralTools(course); + initGeneralTools(course, disclaimerAccepted); - RunMainController rmc = getRunMainController(); if(rmc != null) { rmc.initToolbarAndProgressbar(); } @@ -852,7 +854,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im return (userCourseEnv.isParticipant() || !userCourseEnv.getParticipatingGroups().isEmpty()); } - private void initGeneralTools(ICourse course) { + private void initGeneralTools(ICourse course, boolean disclaimerAccepted) { boolean assessmentLock = isAssessmentLock(); UserCourseEnvironment userCourseEnv = getUserCourseEnvironment(); @@ -864,7 +866,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im toolbarPanel.addTool(detailsLink); } - if (!assessmentLock && !isGuestOnly + if (!assessmentLock && !isGuestOnly && disclaimerAccepted && LearningPathNodeAccessProvider.TYPE.equals(cc.getNodeAccessType().getType())) { learningPathLink = LinkFactory.createToolLink("learningPath", translate("command.learning.path"), this, CourseTool.learningpath.getIconCss()); learningPathLink.setUrl(BusinessControlFactory.getInstance() @@ -875,7 +877,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im learningPathLink.setVisible(userCourseEnv != null && userCourseEnv.isParticipant()); } - if (!assessmentLock && !isGuestOnly + if (!assessmentLock && !isGuestOnly && disclaimerAccepted && LearningPathNodeAccessProvider.TYPE.equals(cc.getNodeAccessType().getType())) { learningPathsLink = LinkFactory.createToolLink("learningPaths", translate("command.learning.paths"), this, CourseTool.learningpath.getIconCss()); learningPathsLink.setUrl(BusinessControlFactory.getInstance() @@ -886,7 +888,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im learningPathsLink.setVisible(userCourseEnv != null && (userCourseEnv.isCoach() || userCourseEnv.isAdmin())); } - boolean calendarIsEnabled = !assessmentLock && !isGuestOnly && calendarModule.isEnabled() + boolean calendarIsEnabled = !assessmentLock && !isGuestOnly && disclaimerAccepted && calendarModule.isEnabled() && calendarModule.isEnableCourseToolCalendar() && reSecurity.canLaunch(); if (calendarIsEnabled && userCourseEnv != null) { calendarLink = LinkFactory.createToolLink("calendar",translate("command.calendar"), this, "o_icon_calendar"); @@ -897,14 +899,14 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im toolbarPanel.addTool(calendarLink); } - if(!assessmentLock && isLecturesLinkEnabled()) { + if(!assessmentLock && disclaimerAccepted && isLecturesLinkEnabled()) { lecturesLink = LinkFactory.createToolLink("command.lectures", translate("command.lectures"), this, "o_icon_lecture"); lecturesLink.setUrl(BusinessControlFactory.getInstance() .getAuthenticatedURLFromBusinessPathStrings(businessPathEntry, "[Lectures:0]")); toolbarPanel.addTool(lecturesLink); } - if(!assessmentLock && !isGuestOnly && userCourseEnv != null) { + if(!assessmentLock && !isGuestOnly && disclaimerAccepted && userCourseEnv != null) { participantListLink = LinkFactory.createToolLink("participantlist", translate(CourseTool.participantlist.getI18nKey()), this, CourseTool.participantlist.getIconCss()); @@ -914,7 +916,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im toolbarPanel.addTool(participantListLink); } - if(!assessmentLock && userCourseEnv != null) { + if(!assessmentLock && disclaimerAccepted && userCourseEnv != null) { participantInfoLink = LinkFactory.createToolLink("participantinfo", translate(CourseTool.participantinfos.getI18nKey()), this, CourseTool.participantinfos.getIconCss()); @@ -924,7 +926,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im toolbarPanel.addTool(participantInfoLink); } - if(!assessmentLock && !isGuestOnly && userCourseEnv != null && !userCourseEnv.isCourseReadOnly()) { + if(!assessmentLock && !isGuestOnly && disclaimerAccepted && userCourseEnv != null && !userCourseEnv.isCourseReadOnly()) { emailLink = LinkFactory.createToolLink("email", translate(CourseTool.email.getI18nKey()), this, CourseTool.email.getIconCss()); emailLink.setUrl(BusinessControlFactory.getInstance() .getAuthenticatedURLFromBusinessPathStrings(businessPathEntry, "[email:0]")); @@ -932,7 +934,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im toolbarPanel.addTool(emailLink); } - if(!assessmentLock && userCourseEnv != null) { + if(!assessmentLock && disclaimerAccepted && userCourseEnv != null) { blogLink = LinkFactory.createToolLink("blog", translate(CourseTool.blog.getI18nKey()), this, CourseTool.blog.getIconCss()); blogLink.setUrl(BusinessControlFactory.getInstance() .getAuthenticatedURLFromBusinessPathStrings(businessPathEntry, "[blog:0]")); @@ -940,7 +942,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im toolbarPanel.addTool(blogLink); } - if(!assessmentLock && userCourseEnv != null) { + if(!assessmentLock && disclaimerAccepted && userCourseEnv != null) { wikiLink = LinkFactory.createToolLink("wiki", translate(CourseTool.wiki.getI18nKey()), this, CourseTool.wiki.getIconCss()); wikiLink.setUrl(BusinessControlFactory.getInstance() .getAuthenticatedURLFromBusinessPathStrings(businessPathEntry, "[wiki:0]")); @@ -948,7 +950,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im toolbarPanel.addTool(wikiLink); } - if(!assessmentLock && userCourseEnv != null) { + if(!assessmentLock && disclaimerAccepted && userCourseEnv != null) { forumLink = LinkFactory.createToolLink("forum", translate(CourseTool.forum.getI18nKey()), this, CourseTool.forum.getIconCss()); forumLink.setUrl(BusinessControlFactory.getInstance() .getAuthenticatedURLFromBusinessPathStrings(businessPathEntry, "[forum:0]")); @@ -956,7 +958,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im toolbarPanel.addTool(forumLink); } - if(!assessmentLock && userCourseEnv != null) { + if(!assessmentLock && disclaimerAccepted && userCourseEnv != null) { documentsLink = LinkFactory.createToolLink("documents", translate(CourseTool.documents.getI18nKey()), this, CourseTool.documents.getIconCss()); documentsLink.setUrl(BusinessControlFactory.getInstance() .getAuthenticatedURLFromBusinessPathStrings(businessPathEntry, "[documents:0]")); @@ -964,7 +966,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im toolbarPanel.addTool(documentsLink); } - if(!assessmentLock) { + if(!assessmentLock && disclaimerAccepted) { glossary = new Dropdown("glossary", "command.glossary", false, getTranslator()); glossary.setIconCSS("o_icon o_FileResource-GLOSSARY_icon"); glossary.setVisible(cc.hasGlossary() && cc.isGlossaryEnabled()); @@ -979,7 +981,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im } //add group chat to toolbox - boolean chatIsEnabled = !assessmentLock && !isGuestOnly && imModule.isEnabled() + boolean chatIsEnabled = !assessmentLock && !isGuestOnly && disclaimerAccepted && imModule.isEnabled() && imModule.isCourseEnabled() && reSecurity.canLaunch(); if(chatIsEnabled && userCourseEnv != null && !userCourseEnv.isCourseReadOnly()) { chatLink = LinkFactory.createToolLink("chat",translate("command.coursechat"), this, "o_icon_chat"); @@ -988,7 +990,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im } // add course search to toolbox - boolean isSearchEnabled = !assessmentLock && searchModule.isSearchAllowed(roles); + boolean isSearchEnabled = !assessmentLock && disclaimerAccepted && searchModule.isSearchAllowed(roles); if (isSearchEnabled) { searchLink = LinkFactory.createToolLink("coursesearch", translate("command.coursesearch"), this, "o_icon_search"); searchLink.setVisible(cc.isCourseSearchEnabled()); @@ -1164,6 +1166,8 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im } else if (event instanceof OpenCourseToolEvent) { CourseTool tool = ((OpenCourseToolEvent)event).getTool(); doOpenTool(ureq, tool); + } else if (event == RunMainController.COURSE_DISCLAIMER_ACCEPTED) { + initToolbar(); } } else if (lifeCycleChangeCtr == source) { if (event == RepositoryEntryLifeCycleChangeController.deletedEvent) { @@ -2038,7 +2042,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im currentToolCtr = participatListCtrl; } else { delayedClose = Delayed.participantList; - }; + } } private void doParticipantInfo(UserRequest ureq) { @@ -2068,7 +2072,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im currentToolCtr = participatInfoCtrl; } else { delayedClose = Delayed.participantInfo; - }; + } } private void doEmail(UserRequest ureq) { diff --git a/src/main/java/org/olat/course/run/RunMainController.java b/src/main/java/org/olat/course/run/RunMainController.java index 3ea0696c395..2a970478296 100644 --- a/src/main/java/org/olat/course/run/RunMainController.java +++ b/src/main/java/org/olat/course/run/RunMainController.java @@ -125,6 +125,7 @@ public class RunMainController extends MainLayoutBasicController implements Gene private static final Logger log = Tracing.createLoggerFor(RunMainController.class); + public static final Event COURSE_DISCLAIMER_ACCEPTED = new Event("course-disclaimer-accepted"); public static final String REBUILD = "rebuild"; public static final String ORES_TYPE_COURSE_RUN = OresHelper.calculateTypeName(RunMainController.class, CourseModule.ORES_TYPE_COURSE); private final OLATResourceable courseRunOres; //course run ores for course run channel @@ -154,6 +155,7 @@ public class RunMainController extends MainLayoutBasicController implements Gene private boolean needsRebuildAfter = false; private boolean needsRebuildAfterPublish = false; private boolean needsRebuildAfterRunDone = false; + private boolean disclaimerAccepted = true; private String courseTitle; private Link nextLink, previousLink; @@ -283,13 +285,15 @@ public class RunMainController extends MainLayoutBasicController implements Gene coursemain.contextPut("courserepokey", courseRepositoryEntry.getKey()); // if a disclaimer is enabled, show it first - if (courseModule.isDisclaimerEnabled() && course.getCourseEnvironment().getCourseConfig().isDisclaimerEnabled() && - !disclaimerManager.isAccessGranted(courseRepositoryEntry, getIdentity(), ureq.getUserSession().getRoles())) { + disclaimerAccepted = !courseModule.isDisclaimerEnabled() + || !course.getCourseEnvironment().getCourseConfig().isDisclaimerEnabled() + || disclaimerManager.isAccessGranted(courseRepositoryEntry, getIdentity(), ureq.getUserSession().getRoles()); + if (disclaimerAccepted) { + coursemain.put("coursemain", columnLayoutCtr.getInitialComponent()); + } else { disclaimerController = new CourseDisclaimerConsentController(ureq, getWindowControl(), courseRepositoryEntry); listenTo(disclaimerController); coursemain.put("coursemain", disclaimerController.getInitialComponent()); - } else { - coursemain.put("coursemain", columnLayoutCtr.getInitialComponent()); } // on initial call we have to set the data-nodeid manually. later it @@ -318,6 +322,10 @@ public class RunMainController extends MainLayoutBasicController implements Gene CoordinatorManager.getInstance().getCoordinator().getEventBus().registerFor(this, identity, courseRepositoryEntry); } + public boolean isDisclaimerAccepted() { + return disclaimerAccepted; + } + protected void setTextMarkingEnabled(boolean enabled) { if (glossaryMarkerCtr != null) { glossaryMarkerCtr.setTextMarkingEnabled(enabled); @@ -431,7 +439,7 @@ public class RunMainController extends MainLayoutBasicController implements Gene } else { List<TreeNode> flatTree = new ArrayList<>(); TreeHelper.makeTreeFlat(luTree.getTreeModel().getRootNode(), flatTree); - hasPrevious = getPreviousNonDelegatingNode(flatTree, luTree.getSelectedNode()) != null;; + hasPrevious = getPreviousNonDelegatingNode(flatTree, luTree.getSelectedNode()) != null; int index = flatTree.indexOf(luTree.getSelectedNode()); hasNext = index >= 0 && index+1 < flatTree.size(); } @@ -754,8 +762,10 @@ public class RunMainController extends MainLayoutBasicController implements Gene } } else if (source == disclaimerController) { if (event == Event.DONE_EVENT) { + disclaimerAccepted = true; coursemain.put("coursemain", columnLayoutCtr.getInitialComponent()); coursemain.setDirty(true); + fireEvent(ureq, COURSE_DISCLAIMER_ACCEPTED); } } } -- GitLab