Skip to content
Draft
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
16 changes: 15 additions & 1 deletion lms/djangoapps/instructor/views/serializers_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from django.utils.html import escape
from django.utils.translation import gettext as _
from edx_when.api import is_enabled_for_course
from openedx_filters.learning.filters import InstructorDashboardTabsGenerated
from rest_framework import serializers

from common.djangoapps.course_modes.models import CourseMode
Expand Down Expand Up @@ -323,7 +324,20 @@ def get_tabs(self, data):
]
order_index = {tab: i for i, tab in enumerate(tabs_order)}
tabs = sorted(tabs, key=lambda x: order_index.get(x['tab_id'], float("inf")))
return tabs

# Apply the InstructorDashboardTabsGenerated filter to allow plugins to modify tabs
try:
filtered_tabs = InstructorDashboardTabsGenerated.run_filter(
tabs=tabs,
course=course,
user=request.user,
course_key=course_key
)
return filtered_tabs if filtered_tabs is not None else tabs
except InstructorDashboardTabsGenerated.PreventTabsGeneration as exc:
# Plugin provided custom tabs or prevented tab generation
custom_tabs = getattr(exc, 'tabs', [])
return custom_tabs
Comment on lines +328 to +340
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.

Every other filter consumer in edx-platform includes # .. filter_implemented_name: and # .. filter_type: annotations (these are used by the code_annotations tooling). See instructor_dashboard.py line 295 for the sibling example.

Also, if the filter's run_filter is simplified to the standard pattern (see the openedx-filters PR review), it returns data.get("tabs") directly, so the None guard isn't needed. And exc.tabs or [] is a bit more direct than getattr:

Suggested change
# Apply the InstructorDashboardTabsGenerated filter to allow plugins to modify tabs
try:
filtered_tabs = InstructorDashboardTabsGenerated.run_filter(
tabs=tabs,
course=course,
user=request.user,
course_key=course_key
)
return filtered_tabs if filtered_tabs is not None else tabs
except InstructorDashboardTabsGenerated.PreventTabsGeneration as exc:
# Plugin provided custom tabs or prevented tab generation
custom_tabs = getattr(exc, 'tabs', [])
return custom_tabs
# Apply the InstructorDashboardTabsGenerated filter to allow plugins to modify tabs
try:
# .. filter_implemented_name: InstructorDashboardTabsGenerated
# .. filter_type: org.openedx.learning.instructor.dashboard.tabs.generated.v1
tabs = InstructorDashboardTabsGenerated.run_filter(
tabs=tabs,
course=course,
user=request.user,
course_key=course_key
)
except InstructorDashboardTabsGenerated.PreventTabsGeneration as exc:
tabs = exc.tabs or []
return tabs


def get_course_id(self, data):
"""Get course ID as string."""
Expand Down
Loading