From 707c45a2e97d86be4992a588445816caa992427d Mon Sep 17 00:00:00 2001 From: Samuel Walladge Date: Wed, 14 Aug 2019 12:10:48 +0930 Subject: [PATCH 1/5] PoC dynamically add sections to dashboard --- lms/djangoapps/instructor/views/instructor_dashboard.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index 0c596b73bfad..90dbad4b3c7f 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -8,6 +8,7 @@ import logging import uuid +import pkg_resources import pytz import six from django.conf import settings @@ -234,6 +235,11 @@ def instructor_dashboard_2(request, course_id): certificate_invalidations = CertificateInvalidation.get_certificate_invalidations(course_key) + # load externally registered sections + for entrypoint in pkg_resources.iter_entry_points(group="lms.instructor_dashboard.section"): + section = entrypoint.load() + sections.append(section(course, access)) + context = { 'course': course, 'studio_url': get_studio_url(course, 'course'), From 1f71432b3020d9f2f0936479fe7307983af1a62c Mon Sep 17 00:00:00 2001 From: Samuel Walladge Date: Mon, 26 Aug 2019 13:15:12 +0930 Subject: [PATCH 2/5] add note; fix cohort api bug --- openedx/core/djangoapps/course_groups/views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openedx/core/djangoapps/course_groups/views.py b/openedx/core/djangoapps/course_groups/views.py index 696e0fcc469a..7a0726b5c1de 100644 --- a/openedx/core/djangoapps/course_groups/views.py +++ b/openedx/core/djangoapps/course_groups/views.py @@ -503,6 +503,7 @@ class CohortHandler(DeveloperErrorViewMixin, APIPermissions): * user_partition_id: The integer identified of the UserPartition. * group_id: The integer identified of the specific group in the partition. """ + queryset = '' def get(self, request, course_key_string, cohort_id=None): """ Endpoint to get either one or all cohorts. @@ -528,6 +529,8 @@ def post(self, request, course_key_string, cohort_id=None): 'Please use the parent endpoint.', 'wrong-endpoint') course_key, course = _get_course_with_access(request, course_key_string) + + # TODO: add bulk import support for this name = request.data.get('name') if not name: raise self.api_error(status.HTTP_400_BAD_REQUEST, From ad4f844af9b335b0668a8cb340722dec4cab0a67 Mon Sep 17 00:00:00 2001 From: Samuel Walladge Date: Tue, 27 Aug 2019 12:49:01 +0930 Subject: [PATCH 3/5] use stevedore for loading instructor dashboard tabs --- .../instructor/views/instructor_dashboard.py | 6 ++-- openedx/core/lib/instructor_dashboard_tabs.py | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 openedx/core/lib/instructor_dashboard_tabs.py diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index 90dbad4b3c7f..87984393d350 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -30,6 +30,7 @@ from xblock.field_data import DictFieldData from xblock.fields import ScopeIds +from openedx.core.lib.instructor_dashboard_tabs import InstructorDashboardTabPluginManager from bulk_email.api import is_bulk_email_feature_enabled from class_dashboard.dashboard_data import get_array_section_has_problem, get_section_display_name from course_modes.models import CourseMode, CourseModesArchive @@ -236,9 +237,8 @@ def instructor_dashboard_2(request, course_id): certificate_invalidations = CertificateInvalidation.get_certificate_invalidations(course_key) # load externally registered sections - for entrypoint in pkg_resources.iter_entry_points(group="lms.instructor_dashboard.section"): - section = entrypoint.load() - sections.append(section(course, access)) + for Tab in InstructorDashboardTabPluginManager.get_tabs(): + sections.append(Tab(course, access).to_dict()) context = { 'course': course, diff --git a/openedx/core/lib/instructor_dashboard_tabs.py b/openedx/core/lib/instructor_dashboard_tabs.py new file mode 100644 index 000000000000..efcc05795afd --- /dev/null +++ b/openedx/core/lib/instructor_dashboard_tabs.py @@ -0,0 +1,28 @@ +""" +Tabs for the instructor dashboard. +""" +from __future__ import absolute_import + +from openedx.core.lib.plugins import PluginManager + + +# Stevedore extension point namespaces +INSTRUCTOR_DASHBOARD_TAB_NAMESPACE = 'lms.instructor_dashboard.tab' + + +class InstructorDashboardTabPluginManager(PluginManager): + """ + Manager for all of the course tabs that have been made available. + + TODO: develop abstract base class for tabs to implement. + """ + NAMESPACE = INSTRUCTOR_DASHBOARD_TAB_NAMESPACE + + @classmethod + def get_tabs(cls): + """ + Returns the list of available tabs in their canonical order. + """ + tabs = list(cls.get_available_plugins().values()) + tabs.sort(key=lambda tab: (tab.priority, tab.section_key)) + return tabs From 8886470509d26e3e83e510a0d369ce7066520dd0 Mon Sep 17 00:00:00 2001 From: Samuel Walladge Date: Fri, 30 Aug 2019 16:05:11 +0930 Subject: [PATCH 4/5] keep pep happy --- openedx/core/djangoapps/course_groups/views.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openedx/core/djangoapps/course_groups/views.py b/openedx/core/djangoapps/course_groups/views.py index 7a0726b5c1de..4479b829327d 100644 --- a/openedx/core/djangoapps/course_groups/views.py +++ b/openedx/core/djangoapps/course_groups/views.py @@ -503,7 +503,9 @@ class CohortHandler(DeveloperErrorViewMixin, APIPermissions): * user_partition_id: The integer identified of the UserPartition. * group_id: The integer identified of the specific group in the partition. """ + queryset = '' + def get(self, request, course_key_string, cohort_id=None): """ Endpoint to get either one or all cohorts. From a2ced80e5e5ed8fdaa3a501d69ebc6aab79809e1 Mon Sep 17 00:00:00 2001 From: Samuel Walladge Date: Fri, 30 Aug 2019 16:33:41 +0930 Subject: [PATCH 5/5] remove unused import --- lms/djangoapps/instructor/views/instructor_dashboard.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index 87984393d350..7b5dddc0294f 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -8,7 +8,6 @@ import logging import uuid -import pkg_resources import pytz import six from django.conf import settings