Skip to content

feat: add use of new filter for instructor dash tabs#38499

Draft
holaontiveros wants to merge 2 commits intoopenedx:masterfrom
WGU-Open-edX:feat/add-filter-instructor-tabs
Draft

feat: add use of new filter for instructor dash tabs#38499
holaontiveros wants to merge 2 commits intoopenedx:masterfrom
WGU-Open-edX:feat/add-filter-instructor-tabs

Conversation

@holaontiveros
Copy link
Copy Markdown
Contributor

@holaontiveros holaontiveros commented May 1, 2026

Description

In order to achieve openedx/frontend-app-instructor-dashboard#86 this PR will add use the new filter for the instructor dash tabs

depens on: openedx/openedx-filters#355

Once this is in place any operator / plugin creator can do something like:

# Add the pipeline step to the LMS configuration
hooks.Filters.ENV_PATCHES.add_item(
    (
        "openedx-lms-common-settings",
        """
# Custom tabs plugin configuration and pipeline step
import logging
from django.conf import settings

# Define the pipeline step class
class CustomTabsStep:
    def __init__(self, filter_type, running_pipeline, **kwargs):
        self.filter_type = filter_type
        self.running_pipeline = running_pipeline
    
    def run_filter(self, tabs, course, user, course_key, **kwargs):
        logger = logging.getLogger(__name__)
        logger.error(f"DEBUG: CustomTabsStep.run_filter called for user {user.username if hasattr(user, 'username') else 'unknown'}")
        
        modified_tabs = tabs.copy()
        
        # Check if user has permission
        user_has_access = (
            user.is_staff or 
            user.is_superuser
        )
        logger.error(f"DEBUG: User access check - is_staff: {user.is_staff}, is_superuser: {user.is_superuser}, has_access: {user_has_access}")
        
        if not user_has_access:
            logger.error("DEBUG: User does not have access to custom tabs")
            return {"tabs": modified_tabs}
        
        # Add custom tab
        custom_tab = {
            'tab_id': 'custom_analytics',
            'title': 'Custom Analytics',
            'url': f"{getattr(settings, 'CUSTOM_TABS_URL', '/instructor-dashboard/course-v1:OpenedX+DemoX+DemoCourse/custom_analytics')}",
            'sort_order': 120,
        }
        
        modified_tabs.append(custom_tab)
        logger.error(f"DEBUG: Added custom tab. Total tabs: {len(modified_tabs)}")
        
        return {"tabs": modified_tabs}

# Add the class to sys.modules so it can be imported by string
import sys
import types

# Create a module for our custom class
custom_module = types.ModuleType('custom_tabs_module')
custom_module.CustomTabsStep = CustomTabsStep
sys.modules['custom_tabs_module'] = custom_module

# Register the filter configuration
if "OPEN_EDX_FILTERS_CONFIG" not in locals():
    OPEN_EDX_FILTERS_CONFIG = {}

OPEN_EDX_FILTERS_CONFIG.update({
    "org.openedx.learning.instructor.dashboard.tabs.generated.v1": {
        "pipeline": [
            "custom_tabs_module.CustomTabsStep",
        ],
        "fail_silently": False,
    },
})
""",
    )
)

in whichever shape fits their need to be able to conditionally add or modify data of the tabs for the instructor dashboard.

Testing instructions

Note: to test this through the API or the UI edx-filters changes need to be in place

  • While having instructor dashbboard app and openedx-platform working add the example tutor-plugin from the description
  • Save configs
  • Restart server
  • Go to instructor dashboard, the new tab should be available

Take in account that the frontend should have a slot to manage the URL that it's being returned for example a slot like this

{
    slotId: 'org.openedx.frontend.slot.instructorDashboard.routes.v1',
    id: 'org.openedx.frontend.widget.instructorDashboard.route.custom_analytics',
    op: WidgetOperationTypes.APPEND,
    element: <PlaceholderSlot tabId="custom_analytics" content={<div>Dynamic Content</div>} />,
  }

is added to the frontend-base build then the custom_analytics from the path from the plugin example will match the tabId custom_analytics from here and the tab will be displayed

The API request that uses this is: `http://local.openedx.io:8000/api/instructor/v2/courses/{:courseId}

Deadline

None

Other information

Include anything else that will help reviewers and consumers understand the change.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels May 1, 2026
@openedx-webhooks
Copy link
Copy Markdown

Thanks for the pull request, @holaontiveros!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

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

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants