Skip to content

Commit

Permalink
feat: added ORA graded notification (#35389)
Browse files Browse the repository at this point in the history
* feat: added ORA graded by staff notification

* test: updated and added new unit tests

* feat: added waffle flag and updated notification
  • Loading branch information
eemaanamir committed Sep 19, 2024
1 parent 00632d9 commit ad23992
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
20 changes: 20 additions & 0 deletions openedx/core/djangoapps/notifications/base_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,26 @@
'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 = {
Expand Down
10 changes: 10 additions & 0 deletions openedx/core/djangoapps/notifications/config/waffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@
# .. 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__)
8 changes: 7 additions & 1 deletion openedx/core/djangoapps/notifications/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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__)
Expand Down Expand Up @@ -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'])
Expand Down
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/notifications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
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():
Expand Down
9 changes: 8 additions & 1 deletion openedx/core/djangoapps/notifications/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,14 @@ def _expected_api_response(self, course=None):
'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': {}
}
Expand Down

0 comments on commit ad23992

Please sign in to comment.