From 637b639e782bfff28febba7360af1c5f17ab7179 Mon Sep 17 00:00:00 2001 From: Nicholas D'Alfonso Date: Tue, 12 May 2020 09:20:36 -0400 Subject: [PATCH] AA-157 dates page missed deadlines - add banner to dates page when deadlines are missed --- lms/djangoapps/courseware/views/views.py | 10 +++++++ lms/static/sass/course/_dates.scss | 3 +- lms/templates/courseware/dates.html | 32 ++++++++++++++++++--- lms/urls.py | 3 +- openedx/features/course_experience/utils.py | 9 ++++-- 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/lms/djangoapps/courseware/views/views.py b/lms/djangoapps/courseware/views/views.py index 6118beceae..56dc868c0d 100644 --- a/lms/djangoapps/courseware/views/views.py +++ b/lms/djangoapps/courseware/views/views.py @@ -1061,6 +1061,8 @@ def dates(request, course_id): Display the course's dates.html, or 404 if there is no such course. Assumes the course_id is in a valid format. """ + from lms.urls import COURSE_DATES_NAME, RESET_COURSE_DEADLINES_NAME + course_key = CourseKey.from_string(course_id) # Enable NR tracing for this view based on course @@ -1094,6 +1096,10 @@ def dates(request, course_id): user_timezone = user_timezone_locale['user_timezone'] user_language = user_timezone_locale['user_language'] + display_reset_dates_text = False + if RELATIVE_DATES_FLAG.is_enabled(course.id): + display_reset_dates_text = reset_deadlines_banner_should_display(course_key, request) + context = { 'course': course, 'course_date_blocks': course_date_blocks, @@ -1104,6 +1110,10 @@ def dates(request, course_id): 'supports_preview_menu': True, 'can_masquerade': can_masquerade, 'masquerade': masquerade, + 'display_reset_dates_text': display_reset_dates_text, + '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/dates.html', context) diff --git a/lms/static/sass/course/_dates.scss b/lms/static/sass/course/_dates.scss index 653384c18e..743bcd18ac 100644 --- a/lms/static/sass/course/_dates.scss +++ b/lms/static/sass/course/_dates.scss @@ -18,7 +18,7 @@ padding: 24px; display: flex; flex-wrap: wrap; - gap: 24px; + justify-content: space-between; max-width: $text-width-readability-max; .upgrade-banner-text { @@ -26,6 +26,7 @@ line-height: 24px; color: #414141; flex: 1 1 20em; + max-width: 70%; } .upgrade-button { diff --git a/lms/templates/courseware/dates.html b/lms/templates/courseware/dates.html index 8c7e9f5856..127e2a147d 100644 --- a/lms/templates/courseware/dates.html +++ b/lms/templates/courseware/dates.html @@ -30,19 +30,43 @@ from openedx.core.djangolib.markup import HTML, Text % if has_locked_assignments and verified_upgrade_link:
- ${_('You are auditing this course.')} - ${_('This means that you are unable to participate in graded assignments.')} - ${_('To complete graded assignments as part of this course, you can upgrade today.')} + ${_('You are auditing this course,')} + ${_(' which means that you are unable to participate in graded assignments.')} + % if display_reset_dates_text: + ${_(' 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
% endif + % if display_reset_dates_text and learner_is_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. Don’t worry—you won’t lose any of the progress you’ve made when you shift your due dates. ')} +
+
+
+ + + + +
+
+
+ % endif <% due_next_set = False %> % for block in course_date_blocks: diff --git a/lms/urls.py b/lms/urls.py index 29e961942e..6e6c1943a7 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -57,6 +57,7 @@ from util import views as util_views RESET_COURSE_DEADLINES_NAME = 'reset_course_deadlines' RENDER_XBLOCK_NAME = 'render_xblock' +COURSE_DATES_NAME = 'dates' if settings.DEBUG or settings.FEATURES.get('ENABLE_DJANGO_ADMIN_SITE'): django_autodiscover() @@ -486,7 +487,7 @@ urlpatterns += [ settings.COURSE_ID_PATTERN, ), courseware_views.dates, - name='dates', + name=COURSE_DATES_NAME, ), # Takes optional student_id for instructor use--shows profile as that student sees it. diff --git a/openedx/features/course_experience/utils.py b/openedx/features/course_experience/utils.py index 46ae05fbf2..a7ab4f386e 100644 --- a/openedx/features/course_experience/utils.py +++ b/openedx/features/course_experience/utils.py @@ -6,6 +6,7 @@ Common utilities for the course experience, including course outline. from datetime import timedelta from completion.models import BlockCompletion +from django.db.models import Q from django.utils import timezone from opaque_keys.edx.keys import CourseKey from six.moves import range @@ -266,9 +267,11 @@ def reset_deadlines_banner_should_display(course_key, request): request.user and course_overview and has_access(request.user, 'staff', course_overview, course_overview.id) ) if is_self_paced and (not is_course_staff) and (not course_end_date or timezone.now() < course_end_date): - if (CourseEnrollment.objects.filter( - course=course_overview, user=request.user, mode=CourseMode.VERIFIED - ).exists()): + if CourseEnrollment.objects.filter( + course=course_overview, user=request.user, + ).filter( + Q(mode=CourseMode.AUDIT) | Q(mode=CourseMode.VERIFIED) + ).exists(): course_block_tree = get_course_outline_block_tree( request, str(course_key), request.user )