refactor: convert course_module term to course_block

This commit is contained in:
0x29a
2022-10-27 03:24:30 +02:00
committed by Piotr Surowiec
parent d3fee38a37
commit 83396ffb07
62 changed files with 335 additions and 335 deletions

View File

@@ -161,7 +161,7 @@ class CourseOverviewTestCase(CatalogIntegrationMixin, ModuleStoreTestCase, Cache
time_field_accessor = lambda object, field_name: get_seconds_since_epoch(getattr(object, field_name))
# The course about fields are accessed through the CourseDetail
# class for the course module, and stored as attributes on the
# class for the course block, and stored as attributes on the
# CourseOverview objects.
course_about_accessor = lambda object, field_name: CourseDetails.fetch_about_attribute(object.id, field_name)

View File

@@ -35,7 +35,7 @@ def get_expected_duration(course_id):
def spaced_out_sections(course):
"""
Generator that returns sections of the course module with a suggested time to complete for each
Generator that returns sections of the course block with a suggested time to complete for each
Returns:
index (int): index of section

View File

@@ -238,7 +238,7 @@ class CourseCohortsSettings(models.Model):
# Note that although a default value is specified here for always_cohort_inline_discussions (False),
# in reality the default value at the time that cohorting is enabled for a course comes from
# course_module.always_cohort_inline_discussions (via `migrate_cohort_settings`).
# course_block.always_cohort_inline_discussions (via `migrate_cohort_settings`).
# DEPRECATED-- DO NOT USE: Instead use `CourseDiscussionSettings.always_divide_inline_discussions`
# via `CourseDiscussionSettings.get` or `CourseDiscussionSettings.update`.
always_cohort_inline_discussions = models.BooleanField(default=False)

View File

@@ -149,7 +149,7 @@ def permission_blacked_out(course, role_names, permission_name):
Returns true if a user in course with the given roles would have permission_name blacked out.
This will return true if it is a permission that the user might have normally had for the course, but does not have
right this moment because we are in a discussion blackout period (as defined by the settings on the course module).
right this moment because we are in a discussion blackout period (as defined by the settings on the course block).
Namely, they can still view, but they can't edit, update, or create anything. This only applies to students, as
moderators of any kind still have posting privileges during discussion blackouts.
"""

View File

@@ -582,8 +582,8 @@ def is_enrollment_valid_for_proctoring(username, course_id):
return False
# Check that the course has proctored exams enabled
course_module = modulestore().get_course(course_id)
if not course_module or not course_module.enable_proctored_exams:
course_block = modulestore().get_course(course_id)
if not course_block or not course_block.enable_proctored_exams:
return False
# Only allow verified modes
@@ -592,7 +592,7 @@ def is_enrollment_valid_for_proctoring(username, course_id):
]
# If the proctoring provider allows learners in honor mode to take exams, include it
if settings.PROCTORING_BACKENDS.get(course_module.proctoring_provider, {}).get('allow_honor_mode'):
if settings.PROCTORING_BACKENDS.get(course_block.proctoring_provider, {}).get('allow_honor_mode'):
appropriate_modes.append(CourseMode.HONOR)
if enrollment['mode'] not in appropriate_modes:

View File

@@ -83,8 +83,8 @@ def get_week_highlights(user, course_key, week_num):
the requested week_num.
"""
course_descriptor = _get_course_with_highlights(course_key)
course_module = _get_course_module(course_descriptor, user)
sections_with_highlights = _get_sections_with_highlights(course_module)
course_block = _get_course_block(course_descriptor, user)
sections_with_highlights = _get_sections_with_highlights(course_block)
highlights = _get_highlights_for_week(
sections_with_highlights,
week_num,
@@ -101,8 +101,8 @@ def get_next_section_highlights(user, course_key, start_date, target_date):
CourseUpdateDoeNotExist: if highlights do not exist for the requested date
"""
course_descriptor = _get_course_with_highlights(course_key)
course_module = _get_course_module(course_descriptor, user)
return _get_highlights_for_next_section(course_module, start_date, target_date)
course_block = _get_course_block(course_descriptor, user)
return _get_highlights_for_next_section(course_block, start_date, target_date)
def _get_course_with_highlights(course_key):
@@ -126,8 +126,8 @@ def _get_course_descriptor(course_key):
return course_descriptor
def _get_course_module(course_descriptor, user):
""" Gets course module that takes into account user state and permissions """
def _get_course_block(course_descriptor, user):
""" Gets course block that takes into account user state and permissions """
# Adding courseware imports here to insulate other apps (e.g. schedules) to
# avoid import errors.
from lms.djangoapps.courseware.model_data import FieldDataCache
@@ -142,12 +142,12 @@ def _get_course_module(course_descriptor, user):
field_data_cache = FieldDataCache.cache_for_descriptor_descendents(
course_descriptor.id, user, course_descriptor, depth=1, read_only=True,
)
course_module = get_module_for_descriptor(
course_block = get_module_for_descriptor(
user, request, course_descriptor, field_data_cache, course_descriptor.id, course=course_descriptor,
)
if not course_module:
raise CourseUpdateDoesNotExist(f'Course module {course_descriptor.id} not found')
return course_module
if not course_block:
raise CourseUpdateDoesNotExist(f'Course block {course_descriptor.id} not found')
return course_block
def _section_has_highlights(section):
@@ -155,9 +155,9 @@ def _section_has_highlights(section):
return section.highlights and not section.hide_from_toc
def _get_sections_with_highlights(course_module):
def _get_sections_with_highlights(course_block):
""" Returns all sections that have highlights in a course """
return list(filter(_section_has_highlights, course_module.get_children()))
return list(filter(_section_has_highlights, course_block.get_children()))
def _get_highlights_for_week(sections, week_num, course_key):

View File

@@ -168,10 +168,10 @@ class TestContentHighlights(ModuleStoreTestCase): # lint-amnesty, pylint: disab
with self.store.bulk_operations(self.course_key):
self._create_chapter(highlights=['Test highlight'])
with self.assertRaisesRegex(CourseUpdateDoesNotExist, 'Course module .* not found'):
with self.assertRaisesRegex(CourseUpdateDoesNotExist, 'Course block .* not found'):
get_week_highlights(self.user, self.course_key, 1)
yesterday = datetime.datetime.utcnow() - datetime.timedelta(days=1)
today = datetime.datetime.utcnow()
with self.assertRaisesRegex(CourseUpdateDoesNotExist, 'Course module .* not found'):
with self.assertRaisesRegex(CourseUpdateDoesNotExist, 'Course block .* not found'):
get_next_section_highlights(self.user, self.course_key, yesterday, today.date())