Revert "Use content type gating in dates banner"

This commit is contained in:
Calen Pennington
2020-06-03 09:52:24 -04:00
committed by GitHub
parent 4252b14927
commit 561cdab7dd
7 changed files with 83 additions and 120 deletions

View File

@@ -72,7 +72,7 @@ class DatesTabView(RetrieveAPIView):
course = get_course_with_access(request.user, 'load', course_key, check_if_enrolled=False)
blocks = get_course_date_blocks(course, request.user, request, include_access=True, include_past_dates=True)
display_reset_dates_text = dates_banner_should_display(course_key, request)
display_reset_dates_text, _ = dates_banner_should_display(course_key, request)
learner_is_verified = False
enrollment = get_enrollment(request.user.username, course_key_string)

View File

@@ -107,8 +107,6 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_
from openedx.core.djangoapps.util.user_messages import PageLevelMessages
from openedx.core.djangoapps.zendesk_proxy.utils import create_zendesk_ticket
from openedx.core.djangolib.markup import HTML, Text
from openedx.core.lib.mobile_utils import is_request_from_mobile_app
from openedx.features.content_type_gating.models import ContentTypeGatingConfig
from openedx.features.course_duration_limits.access import generate_course_expired_fragment
from openedx.features.course_experience import (
COURSE_ENABLE_UNENROLLED_ACCESS_FLAG,
@@ -1063,7 +1061,7 @@ def dates(request, course_id):
user_timezone = user_timezone_locale['user_timezone']
user_language = user_timezone_locale['user_language']
missed_deadlines = dates_banner_should_display(course_key, request)
missed_deadlines, enrollment_mode = dates_banner_should_display(course_key, request)
context = {
'course': course,
@@ -1076,11 +1074,8 @@ def dates(request, course_id):
'can_masquerade': can_masquerade,
'masquerade': masquerade,
'on_dates_tab': True,
'content_type_gating_enabled': ContentTypeGatingConfig.enabled_for_enrollment(
user=request.user,
course_key=course_key,
),
'missed_deadlines': missed_deadlines,
'enrollment_mode': enrollment_mode,
'reset_deadlines_url': reverse(RESET_COURSE_DEADLINES_NAME),
'reset_deadlines_redirect_url_base': COURSE_DATES_NAME,
'reset_deadlines_redirect_url_id_dict': {'course_id': str(course.id)}
@@ -1627,7 +1622,7 @@ def render_xblock(request, usage_key_string, check_if_enrolled=True):
Returns an HttpResponse with HTML content for the xBlock with the given usage_key.
The returned HTML is a chromeless rendering of the xBlock (excluding content of the containing courseware).
"""
from lms.urls import COURSE_DATES_NAME, RESET_COURSE_DEADLINES_NAME
from lms.urls import RENDER_XBLOCK_NAME, RESET_COURSE_DEADLINES_NAME
from openedx.features.course_experience.urls import COURSE_HOME_VIEW_NAME
usage_key = UsageKey.from_string(usage_key_string)
@@ -1666,7 +1661,7 @@ def render_xblock(request, usage_key_string, check_if_enrolled=True):
'mark-completed-on-view-after-delay': completion_service.get_complete_on_view_delay_ms()
}
missed_deadlines = dates_banner_should_display(course_key, request)
missed_deadlines, enrollment_mode = dates_banner_should_display(course_key, request)
context = {
'fragment': block.render('student_view', context=student_view_context),
@@ -1681,18 +1676,11 @@ def render_xblock(request, usage_key_string, check_if_enrolled=True):
'staff_access': bool(request.user.has_perm(VIEW_XQA_INTERFACE, course)),
'xqa_server': settings.FEATURES.get('XQA_SERVER', 'http://your_xqa_server.com'),
'missed_deadlines': missed_deadlines,
'enrollment_mode': enrollment_mode,
'web_app_course_url': reverse(COURSE_HOME_VIEW_NAME, args=[course.id]),
'on_courseware_page': True,
'content_type_gating_enabled': ContentTypeGatingConfig.enabled_for_enrollment(
user=request.user,
course_key=course_key,
),
'verified_upgrade_link': verified_upgrade_deadline_link(request.user, course=course),
'is_learning_mfe': request.META.get('HTTP_REFERER', '').startswith(settings.LEARNING_MICROFRONTEND_URL),
'is_mobile_app': is_request_from_mobile_app(request),
'reset_deadlines_url': reverse(RESET_COURSE_DEADLINES_NAME),
'reset_deadlines_redirect_url_base': COURSE_DATES_NAME,
'reset_deadlines_redirect_url_id_dict': {'course_id': str(course.id)}
}
return render_to_response('courseware/courseware-chromeless.html', context)

View File

@@ -17,89 +17,76 @@ from course_modes.models import CourseMode
</div>
% endif
<%
additional_styling_class = 'on-mobile' if is_mobile_app else 'has-button'
has_locked_assignments = any(hasattr(block, 'contains_gated_content') and block.contains_gated_content for block in course_date_blocks if isinstance(block, CourseAssignmentDate)) if (course_date_blocks and on_dates_tab) else False
on_dates_tab_as_audit = on_dates_tab and enrollment_mode == CourseMode.AUDIT
on_dates_tab_as_verified = on_dates_tab and enrollment_mode == CourseMode.VERIFIED
on_course_outline_page_as_audit = on_course_outline_page and enrollment_mode == CourseMode.AUDIT
on_course_outline_page_as_verified = on_course_outline_page and enrollment_mode == CourseMode.VERIFIED
on_courseware_page_as_audit = on_courseware_page and enrollment_mode == CourseMode.AUDIT
on_courseware_page_as_verified = on_courseware_page and enrollment_mode == CourseMode.VERIFIED
additional_styling_class = 'on-mobile' if web_app_course_url else 'has-button'
%>
<%def name="reset_dates_banner()">
% if (missed_deadlines and (on_dates_tab_as_verified or on_courseware_page_as_audit or on_courseware_page_as_verified)) or (on_dates_tab_as_audit and has_locked_assignments) or on_course_outline_page_as_audit or on_course_outline_page_as_verified:
<div class="dates-banner ${additional_styling_class}">
<div class="dates-banner-text">
% if is_mobile_app:
${_('It looks like you missed some important deadlines based on our suggested schedule. ')}
${_('To keep yourself on track, you can update this schedule and shift the past due assignments into the future by visiting ')}
<a class="mobile-dates-link" href="${web_app_course_url}">edx.org</a>.
${_(' Dont worry—you wont lose any of the progress youve made when you shift your due dates.')}
% if web_app_course_url:
% if enrollment_mode == CourseMode.VERIFIED:
${_('It looks like you missed some important deadlines based on our suggested schedule. ')}
${_('To keep yourself on track, you can update this schedule and shift the past due assignments into the future by visiting ')}
<a class="mobile-dates-link" href="${web_app_course_url}">edx.org</a>.
${_(' Dont worry—you wont lose any of the progress youve made when you shift your due dates.')}
% else:
<strong>${_('You are auditing this course,')}</strong>
${_(' which means that you are unable to participate in graded assignments.')}
${_(' It looks like you missed some important deadlines based on our suggested schedule. To complete graded assignments as part of this course and shift the past due assignments into the future, you can upgrade today by visiting ')}
<a class="mobile-dates-link" href="${verified_upgrade_link}">edx.org</a>.
% endif
% else:
<strong>${_('It looks like you missed some important deadlines based on our suggested schedule.')}</strong>
${_('To keep yourself on track, you can update this schedule and shift the past due assignments into the future. Dont worry—you wont lose any of the progress youve made when you shift your due dates.')}
% if on_course_outline_page_as_verified or (missed_deadlines and (on_dates_tab_as_verified or on_courseware_page_as_verified)):
<strong>${_('It looks like you missed some important deadlines based on our suggested schedule.')}</strong>
${_('To keep yourself on track, you can update this schedule and shift the past due assignments into the future. Dont worry—you wont lose any of the progress youve made when you shift your due dates.')}
% endif
% if (on_dates_tab_as_audit and has_locked_assignments) or on_course_outline_page_as_audit or (on_courseware_page_as_audit and missed_deadlines):
<strong>${_('You are auditing this course,')}</strong>
${_(' which means that you are unable to participate in graded assignments.')}
% if on_dates_tab:
% if missed_deadlines:
${_(' It looks like you missed some important deadlines based on our suggested schedule. To complete graded assignments as part of this course and shift the past due assignments into the future, you can upgrade today.')}
% else:
${_(' To complete graded assignments as part of this course, you can upgrade today.')}
% endif
% else:
${_(' It looks like you missed some important deadlines based on our suggested schedule. To complete graded assignments as part of this course and shift the past due assignments into the future, you can upgrade today.')}
% endif
% endif
% endif
</div>
% if not is_mobile_app:
% if not web_app_course_url:
<div class="upgrade-button">
<form method="post" action="${reset_deadlines_url}">
<input type="hidden" id="csrf_token" name="csrfmiddlewaretoken" value="${csrf_token}">
<input type="hidden" name="reset_deadlines_redirect_url_base" value="${reset_deadlines_redirect_url_base}">
<input type="hidden" name="reset_deadlines_redirect_url_id_dict" value="${reset_deadlines_redirect_url_id_dict}">
<button class="btn reset-deadlines-button">${_("Reset my deadlines")}</button>
</form>
% if on_course_outline_page_as_verified or (missed_deadlines and (on_dates_tab_as_verified or on_courseware_page_as_verified)):
<form method="post" action="${reset_deadlines_url}">
<input type="hidden" id="csrf_token" name="csrfmiddlewaretoken" value="${csrf_token}">
<input type="hidden" name="reset_deadlines_redirect_url_base" value="${reset_deadlines_redirect_url_base}">
<input type="hidden" name="reset_deadlines_redirect_url_id_dict" value="${reset_deadlines_redirect_url_id_dict}">
<button class="btn reset-deadlines-button">${_("Reset my deadlines")}</button>
</form>
% endif:
% if (on_dates_tab_as_audit and has_locked_assignments) or on_course_outline_page_as_audit or (on_courseware_page_as_audit and missed_deadlines):
<a href="${verified_upgrade_link}">
<button type="button">
% if on_dates_tab:
% if missed_deadlines:
${_('Upgrade to shift due dates')}
% else:
${_('Upgrade now')}
% endif
% else:
${_('Upgrade to shift due dates')}
% endif
</button>
</a>
% endif
</div>
% endif
</div>
</%def>
<%def name="upgrade_to_reset_banner()">
<div class="dates-banner ${additional_styling_class}">
<div class="dates-banner-text">
% if is_mobile_app:
<strong>${_('You are auditing this course,')}</strong>
${_(' which means that you are unable to participate in graded assignments.')}
${_(' It looks like you missed some important deadlines based on our suggested schedule. Graded assignments and schedule adjustment are available to Verified Track learners.')}
% else:
<strong>${_('You are auditing this course,')}</strong>
${_(' which means that you are unable to participate in graded assignments.')}
${_(' It looks like you missed some important deadlines based on our suggested schedule. To complete graded assignments as part of this course and shift the past due assignments into the future, you can upgrade today.')}
% endif
</div>
% if not is_mobile_app:
<div class="upgrade-button">
<a href="${verified_upgrade_link}">
<button type="button">
${_('Upgrade to shift due dates')}
</button>
</a>
</div>
% endif
</div>
</%def>
<%def name="upgrade_to_complete_graded_banner()">
<div class="dates-banner ${additional_styling_class}">
<div class="dates-banner-text">
% if is_mobile_app:
<strong>${_('You are auditing this course,')}</strong>
${_(' which means that you are unable to participate in graded assignments.')}
${_('Graded assignments are available to Verified Track learners.')}
% else:
<strong>${_('You are auditing this course,')}</strong>
${_(' which means that you are unable to participate in graded assignments.')}
${_(' To complete graded assignments as part of this course, you can upgrade today.')}
% endif
</div>
% if not is_mobile_app:
<div class="upgrade-button">
<a href="${verified_upgrade_link}">
<button type="button">
${_('Upgrade now')}
</button>
</a>
</div>
% endif
</div>
</%def>
% if on_dates_tab and content_type_gating_enabled and not missed_deadlines:
${upgrade_to_complete_graded_banner()}
% elif missed_deadlines:
% if content_type_gating_enabled:
${upgrade_to_reset_banner()}
% else:
${reset_dates_banner()}
% endif
% endif