refactor: xmodule/seq_module.py -> xmodule/seq_block.py

This commit is contained in:
0x29a
2022-10-26 21:08:07 +02:00
committed by Piotr Surowiec
parent e443e253df
commit 70019bac04
20 changed files with 37 additions and 37 deletions

View File

@@ -37,7 +37,7 @@ from xmodule.modulestore.inheritance import own_metadata
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls
from xmodule.modulestore.xml_exporter import export_course_to_xml
from xmodule.modulestore.xml_importer import import_course_from_xml, perform_xlint
from xmodule.seq_module import SequenceBlock
from xmodule.seq_block import SequenceBlock
from xmodule.video_module import VideoBlock
from cms.djangoapps.contentstore.config import waffle

View File

@@ -9,7 +9,7 @@ from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.exceptions import DuplicateCourseError
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.seq_module import SequenceBlock
from xmodule.seq_block import SequenceBlock
class TemplateTests(ModuleStoreTestCase):

View File

@@ -813,7 +813,7 @@ class TestCourseReIndex(CourseTestCase):
with self.assertRaises(SearchIndexingError):
reindex_course_and_check_access(self.course.id, self.user)
@mock.patch('xmodule.seq_module.SequenceBlock.index_dictionary')
@mock.patch('xmodule.seq_block.SequenceBlock.index_dictionary')
def test_reindex_seq_error_json_responses(self, mock_index_dictionary):
"""
Test json response with mocked error data for sequence
@@ -923,7 +923,7 @@ class TestCourseReIndex(CourseTestCase):
with self.assertRaises(SearchIndexingError):
CoursewareSearchIndexer.do_course_reindex(modulestore(), self.course.id)
@mock.patch('xmodule.seq_module.SequenceBlock.index_dictionary')
@mock.patch('xmodule.seq_block.SequenceBlock.index_dictionary')
def test_indexing_seq_error_responses(self, mock_index_dictionary):
"""
Test do_course_reindex response with mocked error data for sequence

View File

@@ -8,7 +8,7 @@ from datetime import datetime
from pytz import utc
from openedx.core.djangoapps.content.block_structure.transformer import BlockStructureTransformer
from xmodule.seq_module import SequenceBlock # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.seq_block import SequenceBlock # lint-amnesty, pylint: disable=wrong-import-order
from .utils import collect_merged_boolean_field, collect_merged_date_field

View File

@@ -920,7 +920,7 @@ class TestHandleXBlockCallback(SharedModuleStoreTestCase, LoginEnrollmentTestCas
assert not mock_score_signal.called
@ddt.data(
# See seq_module.py for the definition of these handlers
# See seq_block.py for the definition of these handlers
('get_completion', True), # has the 'will_recheck_access' attribute set to True
('goto_position', False), # does not set it
)

View File

@@ -561,17 +561,17 @@ def render_accordion(request, course, table_of_contents):
return render_to_string('courseware/accordion.html', context)
def save_child_position(seq_module, child_name):
def save_child_position(seq_block, child_name):
"""
child_name: url_name of the child
"""
for position, child in enumerate(seq_module.get_display_items(), start=1):
for position, child in enumerate(seq_block.get_display_items(), start=1):
if child.location.block_id == child_name:
# Only save if position changed
if position != seq_module.position:
seq_module.position = position
if position != seq_block.position:
seq_block.position = position
# Save this new position to the underlying KeyValueStore
seq_module.save()
seq_block.save()
def save_positions_recursively_up(user, request, field_data_cache, xmodule, course=None):

View File

@@ -149,7 +149,7 @@ class TestGatedContent(MilestonesTestCaseMixin, SharedModuleStoreTestCase):
# access to gating content (seq1) remains constant
assert bool(has_access(user, 'load', self.seq1, self.course.id))
# access to gated content (seq2) remains constant, access is prevented in SeqModule loading
# access to gated content (seq2) remains constant, access is prevented in SeqBlock loading
assert bool(has_access(user, 'load', self.seq2, self.course.id))
def assert_user_has_prereq_milestone(self, user, expected_has_milestone):

View File

@@ -28,7 +28,7 @@ from xblock.scorable import ScorableXBlockMixin
from common.djangoapps import static_replace
from common.djangoapps.edxmako.shortcuts import render_to_string
from xmodule.seq_module import SequenceBlock # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.seq_block import SequenceBlock # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.util.xmodule_django import add_webpack_to_fragment # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.vertical_block import VerticalBlock # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.x_module import ( # lint-amnesty, pylint: disable=wrong-import-order

View File

@@ -8,7 +8,7 @@ XBLOCKS = [
"about = xmodule.html_block:AboutBlock",
"book = xmodule.template_module:TranslateCustomTagBlock",
"annotatable = xmodule.annotatable_block:AnnotatableBlock",
"chapter = xmodule.seq_module:SectionBlock",
"chapter = xmodule.seq_block:SectionBlock",
"conditional = xmodule.conditional_block:ConditionalBlock",
"course = xmodule.course_block:CourseBlock",
"course_info = xmodule.html_block:CourseInfoBlock",
@@ -27,7 +27,7 @@ XBLOCKS = [
"poll_question = xmodule.poll_block:PollBlock",
"problem = xmodule.capa_block:ProblemBlock",
"randomize = xmodule.randomize_block:RandomizeBlock",
"sequential = xmodule.seq_module:SequenceBlock",
"sequential = xmodule.seq_block:SequenceBlock",
"slides = xmodule.template_module:TranslateCustomTagBlock",
"split_test = xmodule.split_test_module:SplitTestBlock",
"static_tab = xmodule.html_block:StaticTabBlock",

View File

@@ -17,7 +17,7 @@ from xblock.fields import ReferenceList, Scope, String
from openedx.core.djangolib.markup import HTML, Text
from xmodule.mako_block import MakoTemplateBlockBase
from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.seq_module import SequenceMixin
from xmodule.seq_block import SequenceMixin
from xmodule.studio_editable import StudioEditableBlock
from xmodule.util.xmodule_django import add_webpack_to_fragment
from xmodule.validation import StudioValidation, StudioValidationMessage

View File

@@ -23,7 +23,7 @@ from xmodule import course_metadata_utils
from xmodule.course_metadata_utils import DEFAULT_GRADING_POLICY, DEFAULT_START_DATE
from xmodule.data import CertificatesDisplayBehaviors
from xmodule.graders import grader_from_conf
from xmodule.seq_module import SequenceBlock
from xmodule.seq_block import SequenceBlock
from xmodule.tabs import CourseTabList, InvalidTabsException
from .fields import Date

View File

@@ -8,7 +8,7 @@ from lxml import etree
from web_fragments.fragment import Fragment
from xblock.fields import Integer, Scope
from xmodule.mako_block import MakoTemplateBlockBase
from xmodule.seq_module import SequenceMixin
from xmodule.seq_block import SequenceMixin
from xmodule.xml_module import XmlMixin
from xmodule.x_module import (
HTMLSnippet,

View File

@@ -615,7 +615,7 @@ class SequenceBlock(
parent_block_id = self.get_parent().scope_ids.usage_id.block_id
params['chapter_completion_aggregator_url'] = '/'.join(
[settings.COMPLETION_AGGREGATOR_URL, str(self.scope_ids.usage_id.context_key), parent_block_id]) + '/'
fragment.add_content(self.runtime.service(self, 'mako').render_template("seq_module.html", params))
fragment.add_content(self.runtime.service(self, 'mako').render_template("seq_block.html", params))
self._capture_full_seq_item_metrics(display_items)
self._capture_current_unit_metrics(display_items)

View File

@@ -20,7 +20,7 @@ from xblock.fields import Integer, ReferenceValueDict, Scope, String
from xmodule.mako_block import MakoTemplateBlockBase
from xmodule.modulestore.inheritance import UserPartitionList
from xmodule.progress import Progress
from xmodule.seq_module import ProctoringFields, SequenceMixin
from xmodule.seq_block import ProctoringFields, SequenceMixin
from xmodule.studio_editable import StudioEditableBlock
from xmodule.util.xmodule_django import add_webpack_to_fragment
from xmodule.validation import StudioValidation, StudioValidationMessage

View File

@@ -26,7 +26,7 @@ from xmodule.html_block import AboutBlock, CourseInfoBlock, HtmlBlock, StaticTab
from xmodule.library_content_block import LibraryContentBlock
from xmodule.lti_block import LTIBlock
from xmodule.poll_block import PollBlock
from xmodule.seq_module import SequenceBlock
from xmodule.seq_block import SequenceBlock
from xmodule.split_test_module import SplitTestBlock
from xmodule.template_module import CustomTagBlock
from xmodule.word_cloud_module import WordCloudBlock

View File

@@ -183,7 +183,7 @@ class ModelsTest(unittest.TestCase): # lint-amnesty, pylint: disable=missing-cl
def test_load_class(self):
vc = XBlock.load_class('sequential')
vc_str = "<class 'xmodule.seq_module.SequenceBlock'>"
vc_str = "<class 'xmodule.seq_block.SequenceBlock'>"
assert str(vc) == vc_str

View File

@@ -18,7 +18,7 @@ from web_fragments.fragment import Fragment
from edx_toggles.toggles.testutils import override_waffle_flag
from openedx.features.content_type_gating.models import ContentTypeGatingConfig
from xmodule.seq_module import TIMED_EXAM_GATING_WAFFLE_FLAG, SequenceBlock
from xmodule.seq_block import TIMED_EXAM_GATING_WAFFLE_FLAG, SequenceBlock
from xmodule.tests import get_test_system
from xmodule.tests.helpers import StubUserService
from xmodule.tests.xml import XModuleXmlImportTest
@@ -141,9 +141,9 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
def test_student_view_init(self):
module_system = get_test_system()
module_system.position = 2
seq_module = SequenceBlock(runtime=module_system, scope_ids=Mock())
seq_module.bind_for_student(module_system, 34)
assert seq_module.position == 2
seq_block = SequenceBlock(runtime=module_system, scope_ids=Mock())
seq_block.bind_for_student(module_system, 34)
assert seq_block.position == 2
# matches position set in the runtime
@ddt.unpack
@@ -165,7 +165,7 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
assert 'fa fa-check-circle check-circle is-hidden' not in html
# pylint: disable=line-too-long
@patch('xmodule.seq_module.SequenceBlock.gate_entire_sequence_if_it_is_a_timed_exam_and_contains_content_type_gated_problems')
@patch('xmodule.seq_block.SequenceBlock.gate_entire_sequence_if_it_is_a_timed_exam_and_contains_content_type_gated_problems')
def test_timed_exam_gating_waffle_flag(self, mocked_function): # pylint: disable=unused-argument
"""
Verify the code inside the waffle flag is not executed with the flag off
@@ -209,7 +209,7 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
)
assert 'i_am_gated' in view
# check a few elements to ensure the correct page was loaded
assert 'seq_module.html' in view
assert 'seq_block.html' in view
assert 'NextSequential' in view
assert 'PrevSequential' in view
@@ -240,7 +240,7 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
def test_hidden_content_before_due(self):
html = self._get_rendered_view(self.sequence_4_1)
assert 'seq_module.html' in html
assert 'seq_block.html' in html
assert "'banner_text': None" in html
def test_hidden_content_past_due(self):
@@ -259,14 +259,14 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
self.sequence_4_1,
extra_context=dict(specific_masquerade=True),
)
assert 'seq_module.html' in html
assert 'seq_block.html' in html
html = self.get_context_dict_from_string(html)
assert 'Because the due date has passed, this assignment is hidden from the learner.' == html['banner_text']
def test_hidden_content_self_paced_past_due_before_end(self):
with freeze_time(PAST_DUE_BEFORE_END_DATE):
html = self._get_rendered_view(self.sequence_4_1, self_paced=True)
assert 'seq_module.html' in html
assert 'seq_block.html' in html
assert "'banner_text': None" in html
def test_hidden_content_self_paced_past_end(self):
@@ -284,7 +284,7 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
"""
Assert sequence content is gated
"""
assert 'seq_module.html' in html
assert 'seq_block.html' in html
html = self.get_context_dict_from_string(html)
assert html['banner_text'] is None
assert [] == html['items']
@@ -299,7 +299,7 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
"""
Assert sequence is a prerequisite with unfulfilled gates
"""
assert 'seq_module.html' in html
assert 'seq_block.html' in html
html = self.get_context_dict_from_string(html)
assert 'This section is a prerequisite. You must complete this section in order to unlock additional content.' == html['banner_text']
assert not html['gated_content']['gated']
@@ -313,7 +313,7 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
"""
Assert sequence is not gated
"""
assert 'seq_module.html' in html
assert 'seq_block.html' in html
assert "'banner_text': None" in html
assert "'gated': False" in html
assert str(sequence.location) in html
@@ -464,5 +464,5 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
Retrieve dictionary from string.
"""
# Replace tuple and un-necessary info from inside string and get the dictionary.
cleaned_data = data.replace("(('seq_module.html',\n", '').replace("),\n {})", '').strip()
cleaned_data = data.replace("(('seq_block.html',\n", '').replace("),\n {})", '').strip()
return ast.literal_eval(cleaned_data)

View File

@@ -15,7 +15,7 @@ from xmodule.course_block import CourseBlock
from xmodule.fields import Date, RelativeTime, Timedelta
from xmodule.modulestore.inheritance import InheritanceKeyValueStore, InheritanceMixin, InheritingFieldData
from xmodule.modulestore.split_mongo.split_mongo_kvs import SplitMongoKVS
from xmodule.seq_module import SequenceBlock
from xmodule.seq_block import SequenceBlock
from xmodule.tests import get_test_descriptor_system
from xmodule.tests.xml import XModuleXmlImportTest
from xmodule.tests.xml.factories import CourseFactory, ProblemFactory, SequenceFactory

View File

@@ -16,7 +16,7 @@ from xblock.fields import Boolean, Scope
from openedx_filters.learning.filters import VerticalBlockChildRenderStarted
from xmodule.mako_block import MakoTemplateBlockBase
from xmodule.progress import Progress
from xmodule.seq_module import SequenceFields
from xmodule.seq_block import SequenceFields
from xmodule.studio_editable import StudioEditableBlock
from xmodule.util.misc import is_xblock_an_assignment
from xmodule.util.xmodule_django import add_webpack_to_fragment