feat: external plugin integration in instructor dashboard (#29376)
* feat: external plugin integration fixes
This commit is contained in:
@@ -545,16 +545,16 @@ SYSTEM_WIDE_ROLE_CLASSES = ENV_TOKENS.get('SYSTEM_WIDE_ROLE_CLASSES') or SYSTEM_
|
||||
######################## Setting for content libraries ########################
|
||||
MAX_BLOCKS_PER_CONTENT_LIBRARY = ENV_TOKENS.get('MAX_BLOCKS_PER_CONTENT_LIBRARY', MAX_BLOCKS_PER_CONTENT_LIBRARY)
|
||||
|
||||
########################## Derive Any Derived Settings #######################
|
||||
|
||||
derive_settings(__name__)
|
||||
|
||||
####################### Plugin Settings ##########################
|
||||
|
||||
# This is at the bottom because it is going to load more settings after base settings are loaded
|
||||
|
||||
add_plugins(__name__, ProjectType.CMS, SettingsType.PRODUCTION)
|
||||
|
||||
########################## Derive Any Derived Settings #######################
|
||||
|
||||
derive_settings(__name__)
|
||||
|
||||
############# CORS headers for cross-domain requests #################
|
||||
if FEATURES.get('ENABLE_CORS_HEADERS'):
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
|
||||
9
lms/djangoapps/instructor/constants.py
Normal file
9
lms/djangoapps/instructor/constants.py
Normal file
@@ -0,0 +1,9 @@
|
||||
"""
|
||||
Constants used by Instructor.
|
||||
"""
|
||||
|
||||
# this is the UserPreference key for the user's recipient invoice copy
|
||||
INVOICE_KEY = 'pref-invoice-copy'
|
||||
|
||||
# external plugins (if any) will use this constant to return context to instructor dashboard
|
||||
INSTRUCTOR_DASHBOARD_PLUGIN_VIEW_NAME = 'instructor_dashboard'
|
||||
@@ -23,6 +23,7 @@ from common.djangoapps.student.tests.factories import AdminFactory, CourseAccess
|
||||
from common.djangoapps.student.tests.factories import StaffFactory
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from common.test.utils import XssTestMixin
|
||||
from lms.djangoapps.courseware.courses import get_studio_url
|
||||
from lms.djangoapps.courseware.tabs import get_course_tab_list
|
||||
from lms.djangoapps.courseware.tests.factories import StudentModuleFactory
|
||||
from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase
|
||||
@@ -582,6 +583,21 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase, XssT
|
||||
# assert we don't get a 500 error
|
||||
assert 200 == response.status_code
|
||||
|
||||
@patch("lms.djangoapps.instructor.views.instructor_dashboard.get_plugins_view_context")
|
||||
def test_external_plugin_integration(self, mock_get_plugins_view_context):
|
||||
"""
|
||||
Tests that whether context from plugins is being reflected/added in instructor dashboard.
|
||||
"""
|
||||
test_studio_url = get_studio_url(self.course, 'course')
|
||||
|
||||
context = {
|
||||
'studio_url': test_studio_url
|
||||
}
|
||||
mock_get_plugins_view_context.return_value = context
|
||||
|
||||
response = self.client.get(self.url)
|
||||
self.assertContains(response, test_studio_url)
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class TestInstructorDashboardPerformance(ModuleStoreTestCase, LoginEnrollmentTestCase, XssTestMixin):
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
"""
|
||||
This is the UserPreference key for the user's recipient invoice copy
|
||||
"""
|
||||
INVOICE_KEY = 'pref-invoice-copy'
|
||||
|
||||
@@ -87,6 +87,7 @@ from lms.djangoapps.discussion.django_comment_client.utils import (
|
||||
)
|
||||
from lms.djangoapps.instructor import enrollment
|
||||
from lms.djangoapps.instructor.access import ROLES, allow_access, list_with_level, revoke_access, update_forum_role
|
||||
from lms.djangoapps.instructor.constants import INVOICE_KEY
|
||||
from lms.djangoapps.instructor.enrollment import (
|
||||
enroll_email,
|
||||
get_email_params,
|
||||
@@ -95,7 +96,6 @@ from lms.djangoapps.instructor.enrollment import (
|
||||
send_mail_to_student,
|
||||
unenroll_email,
|
||||
)
|
||||
from lms.djangoapps.instructor.views import INVOICE_KEY
|
||||
from lms.djangoapps.instructor.views.instructor_task_helpers import extract_email_features, extract_task_features
|
||||
from lms.djangoapps.instructor_analytics import basic as instructor_analytics_basic, csvs as instructor_analytics_csvs
|
||||
from lms.djangoapps.instructor_task import api as task_api
|
||||
|
||||
@@ -22,6 +22,7 @@ from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from django.views.decorators.http import require_POST
|
||||
from edx_proctoring.api import does_backend_support_onboarding
|
||||
from edx_when.api import is_enabled_for_course
|
||||
from edx_django_utils.plugins import get_plugins_view_context
|
||||
from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from xblock.field_data import DictFieldData
|
||||
@@ -52,10 +53,12 @@ from lms.djangoapps.courseware.courses import get_studio_url
|
||||
from lms.djangoapps.courseware.module_render import get_module_by_usage_id
|
||||
from lms.djangoapps.discussion.django_comment_client.utils import has_forum_access
|
||||
from lms.djangoapps.grades.api import is_writable_gradebook_enabled
|
||||
from lms.djangoapps.instructor.constants import INSTRUCTOR_DASHBOARD_PLUGIN_VIEW_NAME
|
||||
from openedx.core.djangoapps.course_groups.cohorts import DEFAULT_COHORT_NAME, get_course_cohorts, is_course_cohorted
|
||||
from openedx.core.djangoapps.discussions.config.waffle_utils import legacy_discussion_experience_enabled
|
||||
from openedx.core.djangoapps.discussions.utils import available_division_schemes
|
||||
from openedx.core.djangoapps.django_comment_common.models import FORUM_ROLE_ADMINISTRATOR, CourseDiscussionSettings
|
||||
from openedx.core.djangoapps.plugins.constants import ProjectType
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from openedx.core.djangoapps.verified_track_content.models import VerifiedTrackCohortedCourse
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
@@ -255,6 +258,14 @@ def instructor_dashboard_2(request, course_id): # lint-amnesty, pylint: disable
|
||||
'xqa_server': settings.FEATURES.get('XQA_SERVER', "http://your_xqa_server.com"),
|
||||
}
|
||||
|
||||
context_from_plugins = get_plugins_view_context(
|
||||
ProjectType.LMS,
|
||||
INSTRUCTOR_DASHBOARD_PLUGIN_VIEW_NAME,
|
||||
context
|
||||
)
|
||||
|
||||
context.update(context_from_plugins)
|
||||
|
||||
return render_to_response('instructor/instructor_dashboard_2/instructor_dashboard_2.html', context)
|
||||
|
||||
|
||||
|
||||
@@ -953,6 +953,10 @@ DASHBOARD_COURSE_LIMIT = ENV_TOKENS.get('DASHBOARD_COURSE_LIMIT', None)
|
||||
######################## Setting for content libraries ########################
|
||||
MAX_BLOCKS_PER_CONTENT_LIBRARY = ENV_TOKENS.get('MAX_BLOCKS_PER_CONTENT_LIBRARY', MAX_BLOCKS_PER_CONTENT_LIBRARY)
|
||||
|
||||
########################## Derive Any Derived Settings #######################
|
||||
|
||||
derive_settings(__name__)
|
||||
|
||||
############################### Plugin Settings ###############################
|
||||
|
||||
# This is at the bottom because it is going to load more settings after base settings are loaded
|
||||
@@ -960,10 +964,6 @@ MAX_BLOCKS_PER_CONTENT_LIBRARY = ENV_TOKENS.get('MAX_BLOCKS_PER_CONTENT_LIBRARY'
|
||||
# Load production.py in plugins
|
||||
add_plugins(__name__, ProjectType.LMS, SettingsType.PRODUCTION)
|
||||
|
||||
########################## Derive Any Derived Settings #######################
|
||||
|
||||
derive_settings(__name__)
|
||||
|
||||
############## Settings for Completion API #########################
|
||||
|
||||
# Once a user has watched this percentage of a video, mark it as complete:
|
||||
|
||||
@@ -130,7 +130,7 @@ from openedx.core.djangolib.markup import HTML
|
||||
<% is_hidden = section_data.get('is_hidden', False) %>
|
||||
<section id="${ section_data['section_key'] }" class="idash-section${' hidden' if hidden else ''}" aria-labelledby="header-${section_data['section_key']}">
|
||||
<h3 class="hd hd-3" id="header-${ section_data['section_key'] }">${ section_data['section_display_name'] }</h3>
|
||||
<%include file="${ section_data['section_key'] }.html" args="section_data=section_data" />
|
||||
<%include file="${ section_data.get('template_path_prefix', '') }${ section_data['section_key'] }.html" args="section_data=section_data" />
|
||||
</section>
|
||||
% endfor
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user