refactor: rename module -> block within openedx/core
This commit is contained in:
@@ -794,8 +794,8 @@ class ForumFormDiscussionContentGroupTestCase(ForumsEnableMixin, ContentGroupTes
|
||||
"""
|
||||
Tests `forum_form_discussion api` works with different content groups.
|
||||
Discussion modules are setup in ContentGroupTestCase class i.e
|
||||
alpha_module => alpha_group_discussion => alpha_cohort => alpha_user/community_ta
|
||||
beta_module => beta_group_discussion => beta_cohort => beta_user
|
||||
alpha_block => alpha_group_discussion => alpha_cohort => alpha_user/community_ta
|
||||
beta_block => beta_group_discussion => beta_cohort => beta_user
|
||||
"""
|
||||
|
||||
@patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
|
||||
@@ -803,11 +803,11 @@ class ForumFormDiscussionContentGroupTestCase(ForumsEnableMixin, ContentGroupTes
|
||||
super().setUp()
|
||||
self.thread_list = [
|
||||
{"thread_id": "test_general_thread_id"},
|
||||
{"thread_id": "test_global_group_thread_id", "commentable_id": self.global_module.discussion_id},
|
||||
{"thread_id": "test_alpha_group_thread_id", "group_id": self.alpha_module.group_access[0][0],
|
||||
"commentable_id": self.alpha_module.discussion_id},
|
||||
{"thread_id": "test_beta_group_thread_id", "group_id": self.beta_module.group_access[0][0],
|
||||
"commentable_id": self.beta_module.discussion_id}
|
||||
{"thread_id": "test_global_group_thread_id", "commentable_id": self.global_block.discussion_id},
|
||||
{"thread_id": "test_alpha_group_thread_id", "group_id": self.alpha_block.group_access[0][0],
|
||||
"commentable_id": self.alpha_block.discussion_id},
|
||||
{"thread_id": "test_beta_group_thread_id", "group_id": self.beta_block.group_access[0][0],
|
||||
"commentable_id": self.beta_block.discussion_id}
|
||||
]
|
||||
|
||||
def assert_has_access(self, response, expected_discussion_threads):
|
||||
@@ -907,7 +907,7 @@ class SingleThreadContentGroupTestCase(ForumsEnableMixin, UrlResetMixin, Content
|
||||
thread_id = "test_thread_id"
|
||||
mock_request.side_effect = make_mock_request_impl(course=self.course, text="dummy content", thread_id=thread_id)
|
||||
|
||||
for discussion_xblock in [self.alpha_module, self.beta_module, self.global_module]:
|
||||
for discussion_xblock in [self.alpha_block, self.beta_block, self.global_block]:
|
||||
self.assert_can_access(self.staff_user, discussion_xblock.discussion_id, thread_id, True)
|
||||
|
||||
def test_alpha_user(self, mock_request):
|
||||
@@ -918,10 +918,10 @@ class SingleThreadContentGroupTestCase(ForumsEnableMixin, UrlResetMixin, Content
|
||||
thread_id = "test_thread_id"
|
||||
mock_request.side_effect = make_mock_request_impl(course=self.course, text="dummy content", thread_id=thread_id)
|
||||
|
||||
for discussion_xblock in [self.alpha_module, self.global_module]:
|
||||
for discussion_xblock in [self.alpha_block, self.global_block]:
|
||||
self.assert_can_access(self.alpha_user, discussion_xblock.discussion_id, thread_id, True)
|
||||
|
||||
self.assert_can_access(self.alpha_user, self.beta_module.discussion_id, thread_id, False)
|
||||
self.assert_can_access(self.alpha_user, self.beta_block.discussion_id, thread_id, False)
|
||||
|
||||
def test_beta_user(self, mock_request):
|
||||
"""
|
||||
@@ -931,10 +931,10 @@ class SingleThreadContentGroupTestCase(ForumsEnableMixin, UrlResetMixin, Content
|
||||
thread_id = "test_thread_id"
|
||||
mock_request.side_effect = make_mock_request_impl(course=self.course, text="dummy content", thread_id=thread_id)
|
||||
|
||||
for discussion_xblock in [self.beta_module, self.global_module]:
|
||||
for discussion_xblock in [self.beta_block, self.global_block]:
|
||||
self.assert_can_access(self.beta_user, discussion_xblock.discussion_id, thread_id, True)
|
||||
|
||||
self.assert_can_access(self.beta_user, self.alpha_module.discussion_id, thread_id, False)
|
||||
self.assert_can_access(self.beta_user, self.alpha_block.discussion_id, thread_id, False)
|
||||
|
||||
def test_non_cohorted_user(self, mock_request):
|
||||
"""
|
||||
@@ -944,11 +944,11 @@ class SingleThreadContentGroupTestCase(ForumsEnableMixin, UrlResetMixin, Content
|
||||
thread_id = "test_thread_id"
|
||||
mock_request.side_effect = make_mock_request_impl(course=self.course, text="dummy content", thread_id=thread_id)
|
||||
|
||||
self.assert_can_access(self.non_cohorted_user, self.global_module.discussion_id, thread_id, True)
|
||||
self.assert_can_access(self.non_cohorted_user, self.global_block.discussion_id, thread_id, True)
|
||||
|
||||
self.assert_can_access(self.non_cohorted_user, self.alpha_module.discussion_id, thread_id, False)
|
||||
self.assert_can_access(self.non_cohorted_user, self.alpha_block.discussion_id, thread_id, False)
|
||||
|
||||
self.assert_can_access(self.non_cohorted_user, self.beta_module.discussion_id, thread_id, False)
|
||||
self.assert_can_access(self.non_cohorted_user, self.beta_block.discussion_id, thread_id, False)
|
||||
|
||||
def test_course_context_respected(self, mock_request):
|
||||
"""
|
||||
@@ -959,8 +959,8 @@ class SingleThreadContentGroupTestCase(ForumsEnableMixin, UrlResetMixin, Content
|
||||
course=self.course, text="dummy content", thread_id=thread_id
|
||||
)
|
||||
|
||||
# Beta user does not have access to alpha_module.
|
||||
self.assert_can_access(self.beta_user, self.alpha_module.discussion_id, thread_id, False)
|
||||
# Beta user does not have access to alpha_block.
|
||||
self.assert_can_access(self.beta_user, self.alpha_block.discussion_id, thread_id, False)
|
||||
|
||||
def test_standalone_context_respected(self, mock_request):
|
||||
"""
|
||||
@@ -973,16 +973,16 @@ class SingleThreadContentGroupTestCase(ForumsEnableMixin, UrlResetMixin, Content
|
||||
name="A team",
|
||||
course_id=self.course.id,
|
||||
topic_id='topic_id',
|
||||
discussion_topic_id=self.alpha_module.discussion_id
|
||||
discussion_topic_id=self.alpha_block.discussion_id
|
||||
)
|
||||
mock_request.side_effect = make_mock_request_impl(
|
||||
course=self.course, text="dummy content", thread_id=thread_id,
|
||||
commentable_id=self.alpha_module.discussion_id
|
||||
commentable_id=self.alpha_block.discussion_id
|
||||
)
|
||||
|
||||
# If a thread returns context other than "course", the access check is not done, and the beta user
|
||||
# can see the alpha discussion module.
|
||||
self.assert_can_access(self.beta_user, self.alpha_module.discussion_id, thread_id, True)
|
||||
self.assert_can_access(self.beta_user, self.alpha_block.discussion_id, thread_id, True)
|
||||
|
||||
|
||||
@patch('openedx.core.djangoapps.django_comment_common.comment_client.utils.requests.request', autospec=True)
|
||||
|
||||
@@ -94,7 +94,7 @@ class XBlockSerializer:
|
||||
block.add_xml_to_node(olx_node)
|
||||
block.children = children
|
||||
|
||||
# Now the block/module may have exported addtional data as files in
|
||||
# Now the block may have exported addtional data as files in
|
||||
# 'filesystem'. If so, store them:
|
||||
for item in filesystem.walk(): # pylint: disable=not-callable
|
||||
for unit_file in item.files:
|
||||
|
||||
@@ -19,8 +19,8 @@ from xmodule.partitions.partitions import Group, UserPartition # lint-amnesty,
|
||||
|
||||
class ContentGroupTestCase(ModuleStoreTestCase):
|
||||
"""
|
||||
Sets up discussion modules visible to content groups 'Alpha' and
|
||||
'Beta', as well as a module visible to all students. Creates a
|
||||
Sets up discussion blocks visible to content groups 'Alpha' and
|
||||
'Beta', as well as a block visible to all students. Creates a
|
||||
staff user, users with access to Alpha/Beta (by way of cohorts),
|
||||
and a non-cohorted user with no special access.
|
||||
"""
|
||||
@@ -99,21 +99,21 @@ class ContentGroupTestCase(ModuleStoreTestCase):
|
||||
partition_id=self.course.user_partitions[0].id,
|
||||
group_id=self.course.user_partitions[0].groups[1].id
|
||||
)
|
||||
self.alpha_module = BlockFactory.create(
|
||||
self.alpha_block = BlockFactory.create(
|
||||
parent_location=self.course.location,
|
||||
category='discussion',
|
||||
discussion_id='alpha_group_discussion',
|
||||
discussion_target='Visible to Alpha',
|
||||
group_access={self.course.user_partitions[0].id: [self.course.user_partitions[0].groups[0].id]}
|
||||
)
|
||||
self.beta_module = BlockFactory.create(
|
||||
self.beta_block = BlockFactory.create(
|
||||
parent_location=self.course.location,
|
||||
category='discussion',
|
||||
discussion_id='beta_group_discussion',
|
||||
discussion_target='Visible to Beta',
|
||||
group_access={self.course.user_partitions[0].id: [self.course.user_partitions[0].groups[1].id]}
|
||||
)
|
||||
self.global_module = BlockFactory.create(
|
||||
self.global_block = BlockFactory.create(
|
||||
parent_location=self.course.location,
|
||||
category='discussion',
|
||||
discussion_id='global_group_discussion',
|
||||
|
||||
@@ -21,6 +21,6 @@ class PageNotFoundError(ObjectDoesNotExist):
|
||||
|
||||
class DiscussionNotFoundError(ObjectDoesNotExist):
|
||||
"""
|
||||
Discussion Module was not found.
|
||||
Discussion Block was not found.
|
||||
"""
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
@@ -225,11 +225,11 @@ def wrap_xblock_aside(
|
||||
return wrap_fragment(frag, render_to_string('xblock_wrapper.html', template_context))
|
||||
|
||||
|
||||
def grade_histogram(module_id):
|
||||
def grade_histogram(block_id):
|
||||
'''
|
||||
Print out a histogram of grades on a given problem in staff member debug info.
|
||||
|
||||
Warning: If a student has just looked at an xmodule and not attempted
|
||||
Warning: If a student has just looked at an xblock and not attempted
|
||||
it, their grade is None. Since there will always be at least one such student
|
||||
this function almost always returns [].
|
||||
'''
|
||||
@@ -242,8 +242,8 @@ def grade_histogram(module_id):
|
||||
FROM courseware_studentmodule
|
||||
WHERE courseware_studentmodule.module_id=%s
|
||||
GROUP BY courseware_studentmodule.grade"""
|
||||
# Passing module_id this way prevents sql-injection.
|
||||
cursor.execute(query, [str(module_id)])
|
||||
# Passing block_id this way prevents sql-injection.
|
||||
cursor.execute(query, [str(block_id)])
|
||||
|
||||
grades = list(cursor.fetchall())
|
||||
grades.sort(key=lambda x: x[0]) # Add ORDER BY to sql query?
|
||||
@@ -262,13 +262,13 @@ def sanitize_html_id(html_id):
|
||||
|
||||
def add_staff_markup(user, disable_staff_debug_info, block, view, frag, context): # pylint: disable=unused-argument
|
||||
"""
|
||||
Updates the supplied module with a new get_html function that wraps
|
||||
Updates the supplied block with a new get_html function that wraps
|
||||
the output of the old get_html function with additional information
|
||||
for admin users only, including a histogram of student answers, the
|
||||
definition of the xmodule, and a link to view the module in Studio
|
||||
definition of the xblock, and a link to view the block in Studio
|
||||
if it is a Studio edited, mongo stored course.
|
||||
|
||||
Does nothing if module is a SequenceBlock.
|
||||
Does nothing if block is a SequenceBlock.
|
||||
"""
|
||||
if context and context.get('hide_staff_markup', False):
|
||||
# If hide_staff_markup is passed, don't add the markup
|
||||
|
||||
Reference in New Issue
Block a user