Skip to content

[BD-13] Deprecate ModuleSystem.render_template - #28571

Merged
ormsbee merged 3 commits into
openedx:masterfrom
open-craft:jill/bd-13-render_template
Nov 9, 2021
Merged

[BD-13] Deprecate ModuleSystem.render_template#28571
ormsbee merged 3 commits into
openedx:masterfrom
open-craft:jill/bd-13-render_template

Conversation

@pomegranited

@pomegranited pomegranited commented Aug 29, 2021

Copy link
Copy Markdown
Contributor

Description

Builds on the shim added by https://github.com/edx/edx-platform/pull/28440 to deprecate the ModuleSystem.render_template attribute, in favor of using the added MakoService.render_template.

This change is only a refactoring, and should not affect Learners, Course Authors, or anyone else using edx-platform.

Supporting information

Testing instructions

LMS as learner:

  1. Login as a demo learner (honor@example.com / edx)
  2. Browse around the BD-13 test course and ensure that blocks render as expected, and that you can submit answers to problems. This course has all of the affected XBlocks in it, including an example Video block which shows the CC license wrapper (cf 7fd1467).
  3. Switch to the Legacy Course Experience and browse around in that too.

LMS as course staff:

  1. Login as a demo staff user (staff@example.com / edx)
  2. Navigate to a course and its Instructor Dashboard > Email tab
  3. Ensure that you can see and use the HTML WYSIWYG editor to craft emails to students. (cf 96d9208)

Studio:

  1. Login as a demo staff (staff@example.com / edx)
  2. Navigate to the BD-13 test course and browse through the blocks. Ensure they render and edit as expected.
  3. Check that you can submit answers to problems, and save changes to blocks.
  4. Preview unpublished changes and ensure they render as expected.
  5. Publish changes, and ensure they render in the LMS as expected.

Deadline

None

@openedx-webhooks

openedx-webhooks commented Aug 29, 2021

Copy link
Copy Markdown

Thanks for the pull request, @pomegranited! I've created BLENDED-947 to keep track of it in Jira. More details are on the BD-13 project page.

When this pull request is ready, tag your edX technical lead.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Aug 29, 2021
@pomegranited pomegranited changed the title Deprecate ModuleSystem.render_template [BD-13] Deprecate ModuleSystem.render_template Aug 29, 2021
@openedx-webhooks openedx-webhooks added blended PR is managed through 2U's blended developmnt program and removed open-source-contribution PR author is not from Axim or 2U labels Aug 29, 2021
Comment thread common/lib/xmodule/xmodule/word_cloud_module.py Outdated
@pomegranited
pomegranited force-pushed the jill/bd-13-render_template branch from 1c8b506 to dc141f6 Compare September 1, 2021 05:44
Comment thread lms/djangoapps/courseware/module_render.py Outdated
Comment thread common/djangoapps/edxmako/services.py Outdated
@pomegranited
pomegranited force-pushed the jill/bd-13-render_template branch 3 times, most recently from 5a1698a to 96d9208 Compare September 28, 2021 12:30
@pomegranited
pomegranited marked this pull request as ready for review September 29, 2021 05:04
@pomegranited
pomegranited requested a review from a team September 29, 2021 05:04
@openedx-webhooks openedx-webhooks added needs triage and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Sep 29, 2021
@pomegranited
pomegranited force-pushed the jill/bd-13-render_template branch from d30556f to c3eb358 Compare September 29, 2021 05:47
Comment thread common/lib/xmodule/xmodule/word_cloud_module.py Outdated
This class is only intended to be used with an XBlock!
"""
_services_requested = {
'mako': 'need',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?

@pomegranited pomegranited Oct 1, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StudioEditableBlock needs the mako service now, but since it's not an XBlock, it doesn't have the _services_requested class property itself, so the XBlock.needs decorator causes this error on init:

AttributeError: type object 'StudioEditableBlock' has no attribute '_services_requested'

I borrowed this trick from AuthoringMixin, but an empty dict can perform the same duty, so I'll fix that here.

@pomegranited pomegranited Oct 4, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread openedx/core/lib/license/wrapper.py Outdated
Comment thread cms/djangoapps/contentstore/views/tests/test_preview.py Outdated
Comment thread common/djangoapps/edxmako/services.py Outdated
Comment thread common/djangoapps/edxmako/tests.py Outdated
Comment thread common/lib/xmodule/xmodule/mako_module.py
Comment thread cms/lib/xblock/authoring_mixin.py Outdated
Comment thread common/lib/xmodule/xmodule/tests/test_editing_module.py Outdated
Comment thread common/lib/xmodule/xmodule/tests/test_xml_module.py Outdated
@pomegranited
pomegranited force-pushed the jill/bd-13-render_template branch 2 times, most recently from eed7d32 to a50742f Compare October 5, 2021 02:56

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this raised in a test because otherwise this mixin should only be used as a mixin by other XBlocks. In that case maybe we can just make it inherit from XBlock instead?

Comment thread common/lib/xmodule/xmodule/mako_module.py
@pomegranited

Copy link
Copy Markdown
Contributor Author

@symbolist There's 1 error reported in the JS test, but it's unrelated to this work:

  CMS.Views.Metadata.VideoList
    ✓ Initialize
    Render
      ✓ is rendered in correct way
      ✓ is rendered with opened extra videos bar
      ✗ is rendered without opened extra videos bar
	Expected spy closeExtraVideosBar to have been called.
	@/home/runner/work/edx-platform/edx-platform/cms/static/js/spec/video/transcripts/videolist_spec.js:9:12828
	then/</</<@/home/runner/work/edx-platform/edx-platform/cms/static/common/js/vendor/jquery.js:3366:30
	fire@/home/runner/work/edx-platform/edx-platform/cms/static/common/js/vendor/jquery.js:3187:11
	fireWith@/home/runner/work/edx-platform/edx-platform/cms/static/common/js/vendor/jquery.js:3317:7

Firefox 61.0.0 (Linux 0.0.0) CMS.Views.Metadata.VideoList Render is rendered without opened extra videos bar FAILED
	Expected spy closeExtraVideosBar to have been called.
	@/home/runner/work/edx-platform/edx-platform/cms/static/js/spec/video/transcripts/videolist_spec.js:9:12828
	then/</</<@/home/runner/work/edx-platform/edx-platform/cms/static/common/js/vendor/jquery.js:3366:30
	fire@/home/runner/work/edx-platform/edx-platform/cms/static/common/js/vendor/jquery.js:3187:11
	fireWith@/home/runner/work/edx-platform/edx-platform/cms/static/common/js/vendor/jquery.js:3317:7

Does this need to be resolved before merging?

@symbolist

Copy link
Copy Markdown
Contributor

jenkins run js

@symbolist

Copy link
Copy Markdown
Contributor

Ah, looks like that is being run by Github Actions now.

@pomegranited
pomegranited force-pushed the jill/bd-13-render_template branch from fd844ee to 924d0d0 Compare October 19, 2021 23:21

@symbolist symbolist left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pomegranited Thanks!

  • I tested this by viewing and editing all the XBlocks in the test course and confirming they are rendering.
  • I read through the code
  • I checked for accessibility issues. There are no UI changes.
  • Includes documentation

@symbolist

Copy link
Copy Markdown
Contributor

@ormsbee This is ready to go!

@ormsbee

ormsbee commented Nov 8, 2021

Copy link
Copy Markdown
Contributor

@pomegranited: I realize this is entirely my fault for sitting on this PR too long, but may I please ask for a rebase? I should be able to merge tomorrow morning.

Thank you.

in favor of the added MakoSystem render_template method.

Related changes:
* Adds the MakoService to the StudioEditModuleRuntime,
  PreviewModuleSystem, LmsModuleSystem, and XBlockRuntime
* MakoService constructor takes a `namespace_prefix` string, so that the
  CMS PreviewModuleSystem can render to LMS templates, without needing
  the special render_from_lms helper method.
* ModuleSystem.render_template becomes a read-only property, so the
  constructor calls and test module systems are updated accordingly.
* Adds tests for the MakoService and module system shims.
@pomegranited
pomegranited force-pushed the jill/bd-13-render_template branch from 924d0d0 to 26b4346 Compare November 9, 2021 03:38
@edx-status-bot

Copy link
Copy Markdown

Your PR has finished running tests. There were no failures.

@pomegranited

Copy link
Copy Markdown
Contributor Author

@ormsbee No worries at all! Those conflicts are all from my other https://github.com/edx/edx-platform/pull/29190 that you just merged, so rebasing would have been a necessity either way.

Fixed the conflicts and rebased, and the tests look good again, so this should be ready to merge now. Thank you! 😄

@ormsbee
ormsbee merged commit 2d60224 into openedx:master Nov 9, 2021
@openedx-webhooks

Copy link
Copy Markdown

@pomegranited 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@pomegranited
pomegranited deleted the jill/bd-13-render_template branch November 9, 2021 23:40
@dianakhuang

Copy link
Copy Markdown
Contributor

@pomegranited We were seeing issues with visibility settings for ORA and LTI blocks and the error "Error: service 'mako' was not requested", so we are going to revert this PR.

@pomegranited

Copy link
Copy Markdown
Contributor Author

Thanks for the heads up @dianakhuang and @jnlapierre -- if you could provide some details here, I'll address them with a follow-up PR.

@dianakhuang

Copy link
Copy Markdown
Contributor

@pomegranited

The steps to reproduce are this:

  1. Create an LTI or ORA component in Studio
  2. Click the 'gear' icon: Visibility Setting
  3. We expect to see visibility settings, but instead we get the error message:
Students will not be able to access this component. Re-edit your component to fix the error.

Error: Service 'mako' was not requested.

Screenshot 2021-11-16 at 13 58 23

I did some digging on our own services, but I wasn't able to find the corresponding stacktrace in our Splunk logs.

@pomegranited

Copy link
Copy Markdown
Contributor Author

Thanks for the info @dianakhuang ! I can reproduce this on my devstack with ORA2, so will sort that one out.

But I was unable to reproduce the issue with an LTI component, and (other than XBlock) the LTIBlock doesn't seem to share any common base classes with OpenAssessmentBlock. Would it be possible for you to provide a course export which demonstrates this issue for LTI?

CC @jnlapierre

@pomegranited

Copy link
Copy Markdown
Contributor Author

@dianakhuang CC @jnlapierre I've identified the issue with ORA2, which was caused by a missed change to the AuthoringMixin, and would affect any XBlock which didn't explicitly @need("mako"). The LTIBlock did @need("mako"), so I'm still not clear on why this would cause a problem -- maybe there's a different LTI XBlock out there somewhere in a separate repo?

But I'm re-submitting this PR, and will add a test to show the issue, then add the fix to show the issue has been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blended PR is managed through 2U's blended developmnt program merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants