Skip to content

Commit

Permalink
fix: course name missing from ORA notification context (#2220)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemaanamir authored Aug 2, 2024
1 parent 8b320d6 commit 3b29778
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion openassessment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Initialization Information for Open Assessment Module
"""

__version__ = '6.11.1'
__version__ = '6.11.2'
12 changes: 9 additions & 3 deletions openassessment/xblock/test/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
"""
Expand All @@ -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)

Expand All @@ -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
"""
Expand All @@ -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')

Expand Down
5 changes: 4 additions & 1 deletion openassessment/xblock/utils/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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}",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 3b29778

Please sign in to comment.