Skip to content

Commit

Permalink
Only send progress email one time if user passing or or more mileston…
Browse files Browse the repository at this point in the history
…es (#521)

* testing emails

* only send one progress email on crossing multiple milestones

---------

Co-authored-by: Muhammad Faraz  Maqsood <[email protected]>
  • Loading branch information
Faraz32123 and Muhammad Faraz Maqsood authored Mar 6, 2024
1 parent 94ff99a commit 3878414
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion openedx/features/sdaia_features/course_progress/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ def send_course_progress_milestones_achievement_emails(**kwargs):
user_completion_percentage = get_user_course_progress(user, course_key)

if user_completion_percentage > progress_last_email_sent_at:
percentage_crossed = 0
for course_completion_percentages_for_email in course_completion_percentages_for_emails:
if user_completion_percentage >= course_completion_percentages_for_email > progress_last_email_sent_at:
send_user_course_progress_email.delay(user_completion_percentage, progress_last_email_sent_at, course_completion_percentages_for_email, str(course_key), user_id)
percentage_crossed = course_completion_percentages_for_email
if percentage_crossed > 0:
send_user_course_progress_email.delay(user_completion_percentage, progress_last_email_sent_at, percentage_crossed, str(course_key), user_id)


@receiver(COURSE_GRADE_NOW_PASSED, dispatch_uid="course_completion")
Expand Down
3 changes: 2 additions & 1 deletion openedx/features/sdaia_features/course_progress/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def send_user_course_progress_email(current_progress, progress_last_email_sent_a
'PLATFORM_NAME',
settings.PLATFORM_NAME
)

logger.info(f'\n\n Last email was sent at: {progress_last_email_sent_at} \n\n')
logger.info(f'\n\n User current progress is: {current_progress} and has crossed milestone of {course_completion_percentages_for_email} \n\n')
context={
'current_progress': int(current_progress),
'progress_milestone_crossed': progress_last_email_sent_at,
Expand Down

0 comments on commit 3878414

Please sign in to comment.