Implement public cohort
This PR is based on #19284 and is part of the series of work related to the proposal #18134. This PR avoids the assignment of anonymous/unenrolled users to any cohort when course is public. Anonymous or unenrolled users will only see content that does not have a content group assigned. The "View Course" link to the course outline is shown on the course about page for a course marked public/public outline. It also makes course handouts available for public courses (not for public_outline). This PR also hides the different warnings and messages asking the user to sign-in and enroll in the course, when the course is marked public. It modifies the default public_view text to include the component display_name when unenrolled access is not available.
This commit is contained in:
@@ -391,6 +391,10 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
Anonymous user is not assigned to any cohort group.
|
||||
"""
|
||||
course = modulestore().get_course(self.toy_course_key)
|
||||
|
||||
# verify cohorts is None when course is not cohorted
|
||||
self.assertIsNone(cohorts.get_cohort(AnonymousUser(), course.id))
|
||||
|
||||
config_course_cohorts(
|
||||
course,
|
||||
is_cohorted=True,
|
||||
|
||||
@@ -313,12 +313,13 @@ class TestCourseHomePageAccess(CourseHomePageTestCase):
|
||||
self.assertContains(response, TEST_CHAPTER_NAME, count=(1 if expected_course_outline else 0))
|
||||
|
||||
# Verify that the expected message is shown to the user
|
||||
self.assertContains(
|
||||
response, 'To see course content', count=(1 if is_anonymous else 0)
|
||||
)
|
||||
self.assertContains(response, '<div class="user-messages"', count=(1 if expected_enroll_message else 0))
|
||||
if expected_enroll_message:
|
||||
self.assertContains(response, 'You must be enrolled in the course to see course content.')
|
||||
if not enable_unenrolled_access or course_visibility != COURSE_VISIBILITY_PUBLIC:
|
||||
self.assertContains(
|
||||
response, 'To see course content', count=(1 if is_anonymous else 0)
|
||||
)
|
||||
self.assertContains(response, '<div class="user-messages"', count=(1 if expected_enroll_message else 0))
|
||||
if expected_enroll_message:
|
||||
self.assertContains(response, 'You must be enrolled in the course to see course content.')
|
||||
|
||||
@override_waffle_flag(UNIFIED_COURSE_TAB_FLAG, active=False)
|
||||
@override_waffle_flag(SHOW_REVIEWS_TOOL_FLAG, active=True)
|
||||
|
||||
@@ -163,6 +163,8 @@ class CourseHomeFragmentView(EdxFragmentView):
|
||||
request, course_id=course_id, user_is_enrolled=False, **kwargs
|
||||
)
|
||||
course_sock_fragment = CourseSockFragmentView().render_to_fragment(request, course=course, **kwargs)
|
||||
if allow_public:
|
||||
handouts_html = self._get_course_handouts(request, course)
|
||||
else:
|
||||
# Redirect the user to the dashboard if they are not enrolled and
|
||||
# this is a course that does not support direct enrollment.
|
||||
|
||||
@@ -130,8 +130,8 @@ def _register_course_home_messages(request, course, user_access, course_start_da
|
||||
Text(_(
|
||||
'{open_enroll_link}Enroll now{close_enroll_link} to access the full course.'
|
||||
)).format(
|
||||
open_enroll_link='',
|
||||
close_enroll_link=''
|
||||
open_enroll_link=HTML('<button class="enroll-btn btn-link">'),
|
||||
close_enroll_link=HTML('</button>')
|
||||
),
|
||||
title=Text(_('Welcome to {course_display_name}')).format(
|
||||
course_display_name=course.display_name
|
||||
|
||||
Reference in New Issue
Block a user