feat: warn when relative dates are past due and can't be shifted
This commit is contained in:
committed by
Piotr Surowiec
parent
a3bafb2ccd
commit
b98cbd4c2c
@@ -13,6 +13,7 @@ from django.utils.translation import gettext as _, ngettext
|
||||
from xmodule.util.misc import is_xblock_an_assignment
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.core.lib.mobile_utils import is_request_from_mobile_app
|
||||
from openedx.features.course_experience import RELATIVE_DATES_DISABLE_RESET_FLAG
|
||||
from openedx.features.course_experience.url_helpers import is_request_from_learning_mfe
|
||||
from openedx.features.course_experience.utils import dates_banner_should_display
|
||||
|
||||
@@ -37,7 +38,10 @@ class PersonalizedLearnerScheduleCallToAction:
|
||||
request = get_current_request()
|
||||
|
||||
course_key = xblock.scope_ids.usage_id.context_key
|
||||
missed_deadlines, missed_gated_content = dates_banner_should_display(course_key, request.user)
|
||||
missed_deadlines, missed_gated_content = dates_banner_should_display(
|
||||
course_key, request.user, allow_warning=True
|
||||
)
|
||||
|
||||
# Not showing in the missed_gated_content case because those learners are not eligible
|
||||
# to shift due dates.
|
||||
if missed_gated_content:
|
||||
@@ -52,13 +56,13 @@ class PersonalizedLearnerScheduleCallToAction:
|
||||
# xblock is a capa problem, and the submit button is disabled. Check if it's because of a personalized
|
||||
# schedule due date being missed, and if so, we can offer to shift it.
|
||||
if self._is_block_shiftable(xblock, category):
|
||||
ctas.append(self._make_reset_deadlines_cta(xblock, category, is_learning_mfe))
|
||||
ctas.append(self._make_deadlines_cta(course_key, xblock, category, is_learning_mfe))
|
||||
|
||||
elif category == self.VERTICAL_BANNER and not completed and missed_deadlines:
|
||||
# xblock is a vertical, so we'll check all the problems inside it. If there are any that will show a
|
||||
# a "shift dates" CTA under CAPA_SUBMIT_DISABLED, then we'll also show the same CTA as a vertical banner.
|
||||
if any(self._is_block_shiftable(item, category) for item in xblock.get_children()):
|
||||
ctas.append(self._make_reset_deadlines_cta(xblock, category, is_learning_mfe))
|
||||
ctas.append(self._make_deadlines_cta(course_key, xblock, category, is_learning_mfe))
|
||||
|
||||
return ctas
|
||||
|
||||
@@ -107,11 +111,15 @@ class PersonalizedLearnerScheduleCallToAction:
|
||||
PersonalizedLearnerScheduleCallToAction.past_due_class_warnings.add(name)
|
||||
|
||||
@classmethod
|
||||
def _make_reset_deadlines_cta(cls, xblock, category, is_learning_mfe=False):
|
||||
def _make_deadlines_cta(cls, course_key, xblock, category, is_learning_mfe=False):
|
||||
"""
|
||||
Constructs a call to action object containing the necessary information for the view
|
||||
"""
|
||||
from lms.urls import RESET_COURSE_DEADLINES_NAME
|
||||
|
||||
if RELATIVE_DATES_DISABLE_RESET_FLAG.is_enabled(course_key):
|
||||
return {"description": _("The deadline to complete this assignment has passed.")}
|
||||
|
||||
course_key = xblock.scope_ids.usage_id.context_key
|
||||
|
||||
cta_data = {
|
||||
|
||||
Reference in New Issue
Block a user