Convert AboutModule, CourseInfoModule, HtmlModule and StaticTabModule to XBlocks.

This commit is contained in:
Usman Khalid
2019-07-06 03:18:38 +05:00
parent 8526a989c3
commit 8dfc8e5fda
21 changed files with 139 additions and 153 deletions

View File

@@ -49,9 +49,7 @@ class StudentViewTransformer(BlockStructureTransformer):
# problem where your particular XModule explodes here (and don't
# have the time to convert it to an XBlock), please try refactoring
# so that you declare your student_view() method in a common
# ancestor class of both your Descriptor and Module classes. As an
# example, I changed the name of HtmlFields to HtmlBlock and moved
# student_view() from HtmlModuleMixin to HtmlBlock.
# ancestor class of both your Descriptor and Module classes.
student_view = getattr(block.__class__, 'student_view', None)
supports_multi_device = block.has_support(student_view, 'multi_device')

View File

@@ -66,6 +66,7 @@ from student.models import CourseEnrollment, anonymous_id_for_user
from verify_student.tests.factories import SoftwareSecurePhotoVerificationFactory
from xblock_django.models import XBlockConfiguration
from xmodule.capa_module import ProblemBlock
from xmodule.html_module import AboutBlock, CourseInfoBlock, HtmlBlock, StaticTabBlock
from xmodule.lti_module import LTIDescriptor
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
@@ -1524,7 +1525,7 @@ class TestHtmlModifiers(ModuleStoreTestCase):
)
result_fragment = module.render(STUDENT_VIEW)
self.assertEquals(len(PyQuery(result_fragment.content)('div.xblock.xblock-student_view.xmodule_HtmlModule')), 1)
self.assertEquals(len(PyQuery(result_fragment.content)('div.xblock.xblock-student_view.xmodule_HtmlBlock')), 1)
def test_xmodule_display_wrapper_disabled(self):
module = render.get_module(
@@ -1536,7 +1537,7 @@ class TestHtmlModifiers(ModuleStoreTestCase):
)
result_fragment = module.render(STUDENT_VIEW)
self.assertNotIn('div class="xblock xblock-student_view xmodule_display xmodule_HtmlModule"',
self.assertNotIn('div class="xblock xblock-student_view xmodule_display xmodule_HtmlBlock"',
result_fragment.content)
def test_static_link_rewrite(self):
@@ -1933,7 +1934,11 @@ class TestStaffDebugInfo(SharedModuleStoreTestCase):
PER_COURSE_ANONYMIZED_DESCRIPTORS = (LTIDescriptor, )
PER_STUDENT_ANONYMIZED_XBLOCKS = [
AboutBlock,
CourseInfoBlock,
HtmlBlock,
ProblemBlock,
StaticTabBlock,
VideoBlock,
]

View File

@@ -25,7 +25,7 @@ def edxnotes(cls):
# Import is placed here to avoid model import at project startup.
from edxnotes.helpers import generate_uid, get_edxnotes_id_token, get_public_endpoint, get_token_url, is_feature_enabled
is_studio = getattr(self.system, "is_author_mode", False)
course = self.descriptor.runtime.modulestore.get_course(self.runtime.course_id)
course = getattr(self, 'descriptor', self).runtime.modulestore.get_course(self.runtime.course_id)
# Must be disabled when:
# - in Studio

View File

@@ -58,7 +58,7 @@ from shoppingcart.models import Coupon, CourseRegCodeItem, PaidCourseRegistratio
from student.models import CourseEnrollment
from student.roles import CourseFinanceAdminRole, CourseInstructorRole, CourseSalesAdminRole, CourseStaffRole
from util.json_request import JsonResponse
from xmodule.html_module import HtmlDescriptor
from xmodule.html_module import HtmlBlock
from xmodule.modulestore.django import modulestore
from xmodule.tabs import CourseTab
@@ -714,7 +714,7 @@ def _section_data_download(course, access):
def null_applicable_aside_types(block): # pylint: disable=unused-argument
"""
get_aside method for monkey-patching into applicable_aside_types
while rendering an HtmlDescriptor for email text editing. This returns
while rendering an HtmlBlock for email text editing. This returns
an empty list.
"""
return []
@@ -726,8 +726,8 @@ def _section_send_email(course, access):
# Monkey-patch applicable_aside_types to return no asides for the duration of this render
with patch.object(course.runtime, 'applicable_aside_types', null_applicable_aside_types):
# This HtmlDescriptor is only being used to generate a nice text editor.
html_module = HtmlDescriptor(
# This HtmlBlock is only being used to generate a nice text editor.
html_module = HtmlBlock(
course.system,
DictFieldData({'data': ''}),
ScopeIds(None, None, None, course_key.make_usage_key('html', 'fake'))

View File

@@ -11,7 +11,7 @@ from six.moves import range
from mobile_api.testutils import MobileAPITestCase, MobileAuthTestMixin, MobileCourseAccessTestMixin
from mobile_api.utils import API_V1, API_V05
from xmodule.html_module import CourseInfoModule
from xmodule.html_module import CourseInfoBlock
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.xml_importer import import_course_from_xml
@@ -60,7 +60,7 @@ class TestUpdates(MobileAPITestCase, MobileAuthTestMixin, MobileCourseAccessTest
"id": num,
"date": "Date" + str(num),
"content": "<a href=\"/static/\">Update" + str(num) + "</a>",
"status": CourseInfoModule.STATUS_VISIBLE
"status": CourseInfoBlock.STATUS_VISIBLE
}
)
else: