From 6867d55364c0b8d41ea1611b83f2d864e3f7b18f Mon Sep 17 00:00:00 2001 From: Arunmozhi Date: Sun, 24 Jul 2022 00:03:02 +0530 Subject: [PATCH] feat: adds openedx-filter hook to the child blocks of VerticalBlock This commit adds a openedx-filters hook to the VerticalBlock XBlock before rendering of it's children. This allows Open edX plugins to customize the presentation of specific blocks based on the context. --- docs/guides/hooks/filters.rst | 4 ++++ requirements/edx/base.txt | 2 +- requirements/edx/development.txt | 2 +- requirements/edx/testing.txt | 2 +- xmodule/vertical_block.py | 8 ++++++++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/guides/hooks/filters.rst b/docs/guides/hooks/filters.rst index d2f15c7997..bea7999081 100644 --- a/docs/guides/hooks/filters.rst +++ b/docs/guides/hooks/filters.rst @@ -181,3 +181,7 @@ well as the trigger location in this same repository. * - `DashboardRenderStarted `_ - org.openedx.learning.dashboard.render.started.v1 - `2022-06-14 `_ + + * - `VerticalChildRenderStarted `_ + - org.openedx.learning.veritical_child_block.render.started.v1 + - `2022-08-18 `_ diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index 15480460d3..0e62a356ab 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -746,7 +746,7 @@ openedx-calc==3.0.1 # via -r requirements/edx/base.in openedx-events==0.11.1 # via -r requirements/edx/base.in -openedx-filters==0.7.0 +openedx-filters==0.8.0 # via # -r requirements/edx/base.in # lti-consumer-xblock diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index b61b9bb007..a881668167 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -974,7 +974,7 @@ openedx-calc==3.0.1 # via -r requirements/edx/testing.txt openedx-events==0.11.1 # via -r requirements/edx/testing.txt -openedx-filters==0.7.0 +openedx-filters==0.8.0 # via # -r requirements/edx/testing.txt # lti-consumer-xblock diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index 38603fe2ed..c1f01da6e9 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -921,7 +921,7 @@ openedx-calc==3.0.1 # via -r requirements/edx/base.txt openedx-events==0.11.1 # via -r requirements/edx/base.txt -openedx-filters==0.7.0 +openedx-filters==0.8.0 # via # -r requirements/edx/base.txt # lti-consumer-xblock diff --git a/xmodule/vertical_block.py b/xmodule/vertical_block.py index 14baf86784..03c7b37f9e 100644 --- a/xmodule/vertical_block.py +++ b/xmodule/vertical_block.py @@ -13,6 +13,7 @@ from lxml import etree from web_fragments.fragment import Fragment from xblock.core import XBlock # lint-amnesty, pylint: disable=wrong-import-order from xblock.fields import Boolean, Scope +from openedx_filters.learning.filters import VerticalBlockChildRenderStarted from xmodule.mako_module import MakoTemplateBlockBase from xmodule.progress import Progress from xmodule.seq_module import SequenceFields @@ -117,6 +118,13 @@ class VerticalBlock( child_block_context['wrap_xblock_data'] = { 'mark-completed-on-view-after-delay': complete_on_view_delay } + + # .. filter_implemented_name: VerticalBlockChildRenderStarted + # .. filter_type: org.openedx.learning.vertical_block_child.render.started.v1 + child, child_block_context = VerticalBlockChildRenderStarted.run_filter( + block=child, context=child_block_context + ) + rendered_child = child.render(view, child_block_context) fragment.add_fragment_resources(rendered_child)