Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: add ORA filter for student_view rendering intervention #107

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions openedx_filters/learning/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,3 +662,61 @@
"""
data = super().run_pipeline(context=context, template_name=template_name)
return data.get("context"), data.get("template_name")


class ORAStudentViewRenderStarted(OpenEdxPublicFilter):
"""
Custom class used to create dashboard render filters and its custom methods.
"""

filter_type = "org.openedx.learning.ora.student_view.render.started.v1"

class RenderInvalidTemplate(OpenEdxFilterException):
"""
Custom class used to stop the dashboard render process.
"""

def __init__(self, message, dashboard_template="", template_context=None):
"""
Override init that defines specific arguments used in the dashboard render process.

Arguments:
message: error message for the exception.
dashboard_template: template path rendered instead.
template_context: context used to the new dashboard_template.
"""
super().__init__(

Check warning on line 688 in openedx_filters/learning/filters.py

View check run for this annotation

Codecov / codecov/patch

openedx_filters/learning/filters.py#L688

Added line #L688 was not covered by tests
message,
dashboard_template=dashboard_template,
template_context=template_context,
)

class RenderCustomFragment(OpenEdxFilterException):
"""
Custom class used to stop the dashboard rendering process.
"""

def __init__(self, message, fragment=None):
"""
Override init that defines specific arguments used in the dashboard render process.

Arguments:
message: error message for the exception.
response: custom response which will be returned by the dashboard view.
"""
super().__init__(

Check warning on line 707 in openedx_filters/learning/filters.py

View check run for this annotation

Codecov / codecov/patch

openedx_filters/learning/filters.py#L707

Added line #L707 was not covered by tests
message,
fragment=fragment,
)

@classmethod
def run_filter(cls, context, template_name):
"""
Execute a filter with the signature specified.

Arguments:
context (dict): context dictionary for student's dashboard template.
template_name (str): template name to be rendered by the student's dashboard.
"""
data = super().run_pipeline(context=context, template_name=template_name)
return data.get("context"), data.get("template_name")

Check warning on line 722 in openedx_filters/learning/filters.py

View check run for this annotation

Codecov / codecov/patch

openedx_filters/learning/filters.py#L721-L722

Added lines #L721 - L722 were not covered by tests
Loading