Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only send progress email one time if user passing or or more milestones #521

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading