diff --git a/openassessment/__init__.py b/openassessment/__init__.py index 3ccd3f9872..82cfbd011a 100644 --- a/openassessment/__init__.py +++ b/openassessment/__init__.py @@ -2,4 +2,4 @@ Initialization Information for Open Assessment Module """ -__version__ = '6.11.1' +__version__ = '6.11.2' diff --git a/openassessment/xblock/test/test_notifications.py b/openassessment/xblock/test/test_notifications.py index 7c3446a873..f0b3786d4b 100644 --- a/openassessment/xblock/test/test_notifications.py +++ b/openassessment/xblock/test/test_notifications.py @@ -2,7 +2,7 @@ Unit test for notification util """ import unittest -from unittest.mock import patch +from unittest.mock import patch, MagicMock from openassessment.xblock.utils.notifications import send_staff_notification @@ -11,8 +11,9 @@ class TestSendStaffNotification(unittest.TestCase): """ Test for send_staff_notification function """ + @patch('openassessment.xblock.utils.notifications.modulestore') @patch('openassessment.xblock.utils.notifications.COURSE_NOTIFICATION_REQUESTED.send_event') - def test_send_staff_notification(self, mock_send_event): + def test_send_staff_notification(self, mock_send_event, mocked_modulestore): """ Test send_staff_notification function """ @@ -21,6 +22,8 @@ def test_send_staff_notification(self, mock_send_event): problem_id = 'problem_id' ora_name = 'ora_name' + mocked_modulestore.return_value = MagicMock() + # Call the function send_staff_notification(course_id, problem_id, ora_name) @@ -37,9 +40,10 @@ def test_send_staff_notification(self, mock_send_event): self.assertEqual(notification_data.app_name, "grading") self.assertEqual(notification_data.audience_filters['course_roles'], ['staff', 'instructor']) + @patch('openassessment.xblock.utils.notifications.modulestore') @patch('openassessment.xblock.utils.notifications.logger.error') @patch('openassessment.xblock.utils.notifications.COURSE_NOTIFICATION_REQUESTED.send_event') - def test_send_staff_notification_error_logging(self, mock_send_event, mock_logger_error): + def test_send_staff_notification_error_logging(self, mock_send_event, mock_logger_error, mocked_modulestore): """ Test send_staff_notification function when an exception is raised """ @@ -48,6 +52,8 @@ def test_send_staff_notification_error_logging(self, mock_send_event, mock_logge problem_id = 'problem_id' ora_name = 'ora_name' + mocked_modulestore.return_value = MagicMock() + # Mock exception mock_exception = Exception('Test exception') diff --git a/openassessment/xblock/utils/notifications.py b/openassessment/xblock/utils/notifications.py index 176206813a..756699f576 100644 --- a/openassessment/xblock/utils/notifications.py +++ b/openassessment/xblock/utils/notifications.py @@ -6,6 +6,7 @@ from django.conf import settings from openedx_events.learning.signals import COURSE_NOTIFICATION_REQUESTED from openedx_events.learning.data import CourseNotificationData +from openassessment.runtime_imports.functions import modulestore logger = logging.getLogger(__name__) @@ -18,10 +19,12 @@ def send_staff_notification(course_id, problem_id, ora_name): audience_filters = { 'course_roles': ['staff', 'instructor'] } + course = modulestore().get_course(course_id) notification_data = CourseNotificationData( course_key=course_id, content_context={ - 'ora_name': ora_name + 'ora_name': ora_name, + 'course_name': course.display_name, }, notification_type='ora_staff_notification', content_url=f"{getattr(settings, 'ORA_GRADING_MICROFRONTEND_URL', '')}/{problem_id}", diff --git a/package.json b/package.json index 772cc8657b..a8d4d10414 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "edx-ora2", - "version": "6.11.1", + "version": "6.11.2", "repository": "https://github.com/openedx/edx-ora2.git", "dependencies": { "@edx/frontend-build": "8.0.6",