Merge pull request #28837 from edx/ormsbee/edx_when_outline_optimization
Re-enable edx-when outline optimization
This commit is contained in:
@@ -22,6 +22,8 @@ from lms.djangoapps.courseware.courses import (
|
||||
get_permission_for_course_about
|
||||
)
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.djangoapps.content.learning_sequences.api import get_course_outline
|
||||
from openedx.core.djangoapps.content.learning_sequences.data import CourseOutlineData
|
||||
from openedx.core.lib.api.view_utils import LazySequence
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError
|
||||
@@ -235,9 +237,18 @@ def get_due_dates(request, course_key, user):
|
||||
url: the deep link to the block
|
||||
date: the due date for the block
|
||||
"""
|
||||
try:
|
||||
outline = get_course_outline(course_key)
|
||||
except (ValueError, CourseOutlineData.DoesNotExist):
|
||||
# Either this course is Old Mongo-backed or doesn't have a generated course outline.
|
||||
course_version = None
|
||||
else:
|
||||
course_version = outline.published_version
|
||||
|
||||
dates = get_dates_for_course(
|
||||
course_key,
|
||||
user,
|
||||
published_version=course_version
|
||||
)
|
||||
|
||||
store = modulestore()
|
||||
|
||||
@@ -1559,8 +1559,8 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ASSUME_ZERO_GRADE_IF_ABSENT_FOR_ALL_TESTS': False})
|
||||
@ddt.data(
|
||||
(False, 63, 46),
|
||||
(True, 55, 40)
|
||||
(False, 63, 44),
|
||||
(True, 55, 38)
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_progress_queries(self, enable_waffle, initial, subsequent):
|
||||
|
||||
@@ -2739,7 +2739,9 @@ def reset_due_date(request, course_id):
|
||||
unit = find_unit(course, request.POST.get('url'))
|
||||
reason = strip_tags(request.POST.get('reason', ''))
|
||||
|
||||
original_due_date = get_date_for_block(course_id, unit.location)
|
||||
version = getattr(course, 'course_version', None)
|
||||
|
||||
original_due_date = get_date_for_block(course_id, unit.location, published_version=version)
|
||||
|
||||
set_due_date_extension(course, unit, student, None, request.user, reason=reason)
|
||||
if not original_due_date:
|
||||
|
||||
@@ -125,11 +125,13 @@ def get_units_with_due_date(course):
|
||||
"""
|
||||
units = []
|
||||
|
||||
version = getattr(course, 'course_version', None)
|
||||
|
||||
# Pass in a schedule here so that we get back any relative dates in the course, but actual value
|
||||
# doesn't matter, since we don't care about the dates themselves, just whether they exist.
|
||||
# Thus we don't save or care about this temporary schedule object.
|
||||
schedule = Schedule(start_date=course.start)
|
||||
course_dates = api.get_dates_for_course(course.id, schedule=schedule)
|
||||
course_dates = api.get_dates_for_course(course.id, schedule=schedule, published_version=version)
|
||||
|
||||
def visit(node):
|
||||
"""
|
||||
@@ -173,7 +175,8 @@ def set_due_date_extension(course, unit, student, due_date, actor=None, reason='
|
||||
# We normally set dates at the subsection level. But technically dates can be anywhere down the tree (and
|
||||
# usually are in self paced courses, where the subsection date gets propagated down).
|
||||
# So find all children that we need to set the date on, then set those dates.
|
||||
course_dates = api.get_dates_for_course(course.id, user=student)
|
||||
version = getattr(course, 'course_version', None)
|
||||
course_dates = api.get_dates_for_course(course.id, user=student, published_version=version)
|
||||
blocks_to_set = {unit} # always include the requested unit, even if it doesn't appear to have a due date now
|
||||
|
||||
def visit(node):
|
||||
@@ -191,8 +194,9 @@ def set_due_date_extension(course, unit, student, due_date, actor=None, reason='
|
||||
for block in blocks_to_set:
|
||||
if due_date:
|
||||
try:
|
||||
api.set_date_for_block(course.id, block.location, 'due', due_date, user=student, reason=reason,
|
||||
actor=actor)
|
||||
api.set_date_for_block(
|
||||
course.id, block.location, 'due', due_date, user=student, reason=reason, actor=actor
|
||||
)
|
||||
except api.MissingDateError as ex:
|
||||
raise DashboardError(_("Unit {0} has no due date to extend.").format(unit.location)) from ex
|
||||
except api.InvalidDateError as ex:
|
||||
|
||||
Reference in New Issue
Block a user