Skip to content
Open
Show file tree
Hide file tree
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
18 changes: 14 additions & 4 deletions lms/djangoapps/instructor/tests/test_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,22 @@ def _get_url(self, course_id=None):
course_id = str(self.course_key)
return reverse('instructor_api_v2:course_metadata', kwargs={'course_id': course_id})

@override_settings(COURSE_AUTHORING_MICROFRONTEND_URL='http://localhost:2001/authoring')
@override_settings(ADMIN_CONSOLE_MICROFRONTEND_URL='http://localhost:2025/admin-console')
@override_settings(
COURSE_AUTHORING_MICROFRONTEND_URL='http://localhost:2001/authoring',
ADMIN_CONSOLE_MICROFRONTEND_URL='http://localhost:2025/admin-console',
# intentionally include trailing slash to test URL joining logic
WRITABLE_GRADEBOOK_URL='http://localhost:1994/gradebook/',
)
def test_get_course_metadata_as_instructor(self):
"""
Test that an instructor can retrieve comprehensive course metadata.
"""
self.client.force_authenticate(user=self.instructor)
response = self.client.get(self._get_url())
with patch(
'lms.djangoapps.instructor.views.serializers_v2.is_writable_gradebook_enabled',
return_value=True,
):
self.client.force_authenticate(user=self.instructor)
response = self.client.get(self._get_url())

assert response.status_code == status.HTTP_200_OK
data = response.data
Expand Down Expand Up @@ -176,9 +184,11 @@ def test_get_course_metadata_as_instructor(self):
assert 'analytics_dashboard_message' in data
assert 'studio_grading_url' in data
assert 'admin_console_url' in data
assert 'gradebook_url' in data

assert data['studio_grading_url'] == f'http://localhost:2001/authoring/course/{self.course.id}/settings/grading'
assert data['admin_console_url'] == 'http://localhost:2025/admin-console/authz'
assert data['gradebook_url'] == f'http://localhost:1994/gradebook/{self.course.id}'

@override_settings(ADMIN_CONSOLE_MICROFRONTEND_URL='http://localhost:2025/admin-console')
def test_admin_console_url_requires_instructor_access(self):
Expand Down
14 changes: 9 additions & 5 deletions lms/djangoapps/instructor/views/serializers_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,13 @@ def get_studio_url(self, data):
def get_gradebook_url(self, data):
"""Get MFE gradebook URL for the course."""
course_key = data['course'].id
if is_writable_gradebook_enabled(course_key) and settings.WRITABLE_GRADEBOOK_URL:
return f'{settings.WRITABLE_GRADEBOOK_URL}/gradebook/{course_key}'
return None
mfe_base_url = configuration_helpers.get_value(
'WRITABLE_GRADEBOOK_URL',
getattr(settings, 'WRITABLE_GRADEBOOK_URL', None)
)
if not is_writable_gradebook_enabled(course_key) or not mfe_base_url:
return None
return f'{mfe_base_url.rstrip("/")}/{course_key}'

def get_studio_grading_url(self, data):
"""Get Studio MFE grading settings URL for the course."""
Expand All @@ -472,7 +476,7 @@ def get_studio_grading_url(self, data):
)
if not mfe_base_url:
return None
return f'{mfe_base_url}/course/{course_key}/settings/grading'
return f'{mfe_base_url.rstrip("/")}/course/{course_key}/settings/grading'

def get_admin_console_url(self, data):
"""Get admin console URL (requires instructor access and MFE configuration, null if not accessible)."""
Expand All @@ -486,7 +490,7 @@ def get_admin_console_url(self, data):
has_permissions = request.user.is_staff or has_instructor_access
if not mfe_base_url or not has_permissions:
return None
return f'{mfe_base_url}/authz'
return f'{mfe_base_url.rstrip("/")}/authz'

def get_disable_buttons(self, data):
"""Check if buttons should be disabled for large courses."""
Expand Down
2 changes: 1 addition & 1 deletion lms/envs/devstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def should_show_debug_toolbar(request): # lint-amnesty, pylint: disable=missing
ENTERPRISE_ADMIN_PORTAL_BASE_URL = 'http://' + ENTERPRISE_ADMIN_PORTAL_NETLOC

########################## GRADEBOOK APP ##############################
WRITABLE_GRADEBOOK_URL = 'http://localhost:1994'
WRITABLE_GRADEBOOK_URL = 'http://localhost:1994/gradebook'

########################## ORA STAFF GRADING APP ##############################
ORA_GRADING_MICROFRONTEND_URL = 'http://localhost:1993'
Expand Down
Loading