feat: added ORA graded notification (#35389)

* feat: added ORA graded by staff notification

* test: updated and added new unit tests

* feat: added waffle flag and updated notification
This commit is contained in:
Eemaan Amir
2024-09-19 13:09:09 +05:00
committed by GitHub
parent 00632d9cae
commit ad23992a5d
5 changed files with 46 additions and 3 deletions

View File

@@ -207,6 +207,26 @@ COURSE_NOTIFICATION_TYPES = {
'filters': [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE],
'visible_to': [CourseStaffRole.ROLE, CourseInstructorRole.ROLE]
},
'ora_grade_assigned': {
'notification_app': 'grading',
'name': 'ora_grade_assigned',
'is_core': False,
'info': '',
'web': False,
'email': False,
'push': False,
'email_cadence': EmailCadence.DAILY,
'non_editable': [],
'content_template': _('<{p}>You have received {points_earned} out of {points_possible} on your assessment: '
'<{strong}>{ora_name}</{strong}></{p}>'),
'content_context': {
'ora_name': 'Name of ORA in course',
'points_earned': 'Points earned',
'points_possible': 'Points possible',
},
'email_template': '',
'filters': [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE],
},
}
COURSE_NOTIFICATION_APPS = {

View File

@@ -28,3 +28,13 @@ ENABLE_NOTIFICATIONS = CourseWaffleFlag(f'{WAFFLE_NAMESPACE}.enable_notification
# .. toggle_warning: When the flag is ON, Email Notifications feature is enabled.
# .. toggle_tickets: INF-1259
ENABLE_EMAIL_NOTIFICATIONS = WaffleFlag(f'{WAFFLE_NAMESPACE}.enable_email_notifications', __name__)
# .. toggle_name: notifications.enable_ora_grade_notifications
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_default: False
# .. toggle_description: Waffle flag to enable ORA grade notifications
# .. toggle_use_cases: temporary, open_edx
# .. toggle_creation_date: 2024-09-10
# .. toggle_target_removal_date: 2024-10-10
# .. toggle_tickets: INF-1304
ENABLE_ORA_GRADE_NOTIFICATION = CourseWaffleFlag(f"{WAFFLE_NAMESPACE}.enable_ora_grade_notifications", __name__)

View File

@@ -21,7 +21,7 @@ from openedx.core.djangoapps.notifications.audience_filters import (
ForumRoleAudienceFilter,
TeamAudienceFilter
)
from openedx.core.djangoapps.notifications.config.waffle import ENABLE_NOTIFICATIONS
from openedx.core.djangoapps.notifications.config.waffle import ENABLE_NOTIFICATIONS, ENABLE_ORA_GRADE_NOTIFICATION
from openedx.core.djangoapps.notifications.models import CourseNotificationPreference
log = logging.getLogger(__name__)
@@ -72,6 +72,12 @@ def generate_user_notifications(signal, sender, notification_data, metadata, **k
"""
Watches for USER_NOTIFICATION_REQUESTED signal and calls send_web_notifications task
"""
if (
notification_data.notification_type == 'ora_grade_assigned'
and not ENABLE_ORA_GRADE_NOTIFICATION.is_enabled(notification_data.course_key)
):
return
from openedx.core.djangoapps.notifications.tasks import send_notifications
notification_data = notification_data.__dict__
notification_data['course_key'] = str(notification_data['course_key'])

View File

@@ -23,7 +23,7 @@ NOTIFICATION_CHANNELS = ['web', 'push', 'email']
ADDITIONAL_NOTIFICATION_CHANNEL_SETTINGS = ['email_cadence']
# Update this version when there is a change to any course specific notification type or app.
COURSE_NOTIFICATION_CONFIG_VERSION = 11
COURSE_NOTIFICATION_CONFIG_VERSION = 12
def get_course_notification_preference_config():

View File

@@ -313,7 +313,14 @@ class UserNotificationPreferenceAPITest(ModuleStoreTestCase):
'push': True,
'email_cadence': 'Daily',
'info': 'Notifications for submission grading.'
}
},
'ora_grade_assigned': {
'web': False,
'email': False,
'push': False,
'email_cadence': 'Daily',
'info': ''
},
},
'non_editable': {}
}